openpond 0.2.16 → 0.2.17

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 (85) hide show
  1. package/dist/app-server.js +1 -1
  2. package/dist/chunks/{app-server-runtime-TAFUJGQS.js → app-server-runtime-Q7NJ6PXF.js} +1 -1
  3. package/dist/chunks/{chunk-3QVNGZFY.js → chunk-BE35DIOI.js} +1 -1
  4. package/dist/chunks/{chunk-RFPSEQO2.js → chunk-CULWDNK3.js} +218 -218
  5. package/dist/chunks/{chunk-OTUTSGMI.js → chunk-G54T4IWQ.js} +1 -1
  6. package/dist/chunks/{chunk-UQ4OBVRS.js → chunk-GHKJKXDF.js} +1 -1
  7. package/dist/chunks/{cli-AUDD3IP5.js → cli-BCBRWI2M.js} +1 -1
  8. package/dist/chunks/{src-VWAWQGVE.js → src-ITECV3AD.js} +25 -25
  9. package/dist/chunks/{workspaces-EGHYKQZF.js → workspaces-WI56RXUN.js} +1 -1
  10. package/dist/cli.js +1 -1
  11. package/dist/web/assets/{App-BGI70Zj6.js → App-DQfdLgyV.js} +3 -3
  12. package/dist/web/assets/{AppDialog-D4siaKMi.js → AppDialog-BnldMLvF.js} +1 -1
  13. package/dist/web/assets/{AppTerminalPanel-DSaxM9R8.js → AppTerminalPanel-DR5SeX9y.js} +2 -2
  14. package/dist/web/assets/{AppsView-C14dtBI0.js → AppsView-Bu_XEgkd.js} +1 -1
  15. package/dist/web/assets/{BrowserSidebar-BbB0tvuH.js → BrowserSidebar-BdKPWbN8.js} +1 -1
  16. package/dist/web/assets/{CartesianChart-GJVxLGBn.js → CartesianChart-CSkLcF_5.js} +1 -1
  17. package/dist/web/assets/{CollaborationTabs-wT2ymsi7.js → CollaborationTabs-C9cRq5ob.js} +1 -1
  18. package/dist/web/assets/{CommandMenu-DLe1d-iP.js → CommandMenu-Deqzk3u9.js} +1 -1
  19. package/dist/web/assets/{CommunityView-BoTn5n7e.js → CommunityView-B5dKYacH.js} +1 -1
  20. package/dist/web/assets/{ComposerCreateImproveStrip-S2sXX8UJ.js → ComposerCreateImproveStrip-5LPlQFN4.js} +1 -1
  21. package/dist/web/assets/{GetStartedView-DhpWR1nb.js → GetStartedView-DmuGykfx.js} +1 -1
  22. package/dist/web/assets/HostedModelLearningReview-BRPSFNza.js +1 -0
  23. package/dist/web/assets/{HostedModelLearningSettings-BN4bvlGK.js → HostedModelLearningSettings-BsdX-CkH.js} +1 -1
  24. package/dist/web/assets/{LabModelVersionDetailPage-B0jRK9u9.js → LabModelVersionDetailPage-BUO5cpDh.js} +1 -1
  25. package/dist/web/assets/{LabSkillSidebar-CoHjFsXh.js → LabSkillSidebar-mTpdM-G8.js} +1 -1
  26. package/dist/web/assets/{LabsRoute-B5UTYHeh.js → LabsRoute-BhfxBg5_.js} +4 -4
  27. package/dist/web/assets/{MainChatThread-CcH2yLdM.js → MainChatThread-BAxA18lN.js} +2 -2
  28. package/dist/web/assets/{MainPane-BT58d6eG.js → MainPane-Dv5USGqR.js} +4 -4
  29. package/dist/web/assets/{MarkdownText-D43uIpOy.js → MarkdownText-DWGLUbdE.js} +1 -1
  30. package/dist/web/assets/{Messages-DarNW0e1.js → Messages-CuhCtaya.js} +1 -1
  31. package/dist/web/assets/{NativeSkillSidebar-3yNmqIFw.js → NativeSkillSidebar-B8OMVpPT.js} +1 -1
  32. package/dist/web/assets/{NewExperienceSwitcher-Cle9jAk2.js → NewExperienceSwitcher-kIKV8_Wd.js} +1 -1
  33. package/dist/web/assets/{NewProjectDialog-DFAGQHU5.js → NewProjectDialog-B-7dHoT6.js} +1 -1
  34. package/dist/web/assets/{OutputsPage-BvoFsIeo.js → OutputsPage-C4DRT8pF.js} +1 -1
  35. package/dist/web/assets/{ProjectsPage-DLo3YoMa.js → ProjectsPage-CLjW6Kc3.js} +1 -1
  36. package/dist/web/assets/{RightChatPanelStack-B4v_t1S8.js → RightChatPanelStack-C4-4VLb-.js} +1 -1
  37. package/dist/web/assets/{RightSidebarHomePanel-jZW_Bepf.js → RightSidebarHomePanel-CVbfOg2p.js} +1 -1
  38. package/dist/web/assets/{ScheduledWorkPage-DLX-weE0.js → ScheduledWorkPage-CWzwbOOZ.js} +1 -1
  39. package/dist/web/assets/{SettingsView-Bjf1bZOw.js → SettingsView-BIwO8elm.js} +6 -6
  40. package/dist/web/assets/{SettingsView-B9Tn0_zX.css → SettingsView-BaWWvIJW.css} +1 -1
  41. package/dist/web/assets/{TeamChatView-BqhLy7OA.js → TeamChatView-miR9w_53.js} +1 -1
  42. package/dist/web/assets/{TerminalOverlay-CJTUNqkk.js → TerminalOverlay-BOmx_hJX.js} +1 -1
  43. package/dist/web/assets/{TrainingCreationPanel-smGwEmo9.js → TrainingCreationPanel-DSRejaYV.js} +1 -1
  44. package/dist/web/assets/{TrainingDraftPanel-B2UKQHN3.js → TrainingDraftPanel-XBH6Uh0_.js} +1 -1
  45. package/dist/web/assets/{UsageSettingsSection-eyvYtzgi.js → UsageSettingsSection-DROtDdak.js} +1 -1
  46. package/dist/web/assets/{WorkSidebarPanel-DoruAoEt.js → WorkSidebarPanel-CHwObGs6.js} +1 -1
  47. package/dist/web/assets/{WorkspaceDiffPanel-DeHSMDXy.js → WorkspaceDiffPanel-BoB_1R8w.js} +3 -3
  48. package/dist/web/assets/{WorkspaceEnvironmentMenu-sgYQj7uK.js → WorkspaceEnvironmentMenu-Dvqy2NJP.js} +1 -1
  49. package/dist/web/assets/{WorkspaceGitDialogs-WpfoEpEk.js → WorkspaceGitDialogs-BC45mifk.js} +1 -1
  50. package/dist/web/assets/{WorkspaceMonacoEditor-jqG5AL7d.js → WorkspaceMonacoEditor-cDO3Elh0.js} +3 -3
  51. package/dist/web/assets/{arrow-up-right-Dw1pcY62.js → arrow-up-right-Dv3nebbh.js} +1 -1
  52. package/dist/web/assets/{chat-file-links-BYbiaIO1.js → chat-file-links-DQYtkwit.js} +1 -1
  53. package/dist/web/assets/chevron-up-BUOpWd2a.js +1 -0
  54. package/dist/web/assets/{clipboard-Dfk4RCIt.js → clipboard-CnNPmg50.js} +1 -1
  55. package/dist/web/assets/{cloud-upload-BCFuH4X6.js → cloud-upload-DisZOwXE.js} +1 -1
  56. package/dist/web/assets/{cssMode-D4TD1xov.js → cssMode-Bd8sFlb5.js} +1 -1
  57. package/dist/web/assets/{folder-open-DvI8m5Sx.js → folder-open-D0PIN0Cj.js} +1 -1
  58. package/dist/web/assets/{folder-plus-By8mYY0v.js → folder-plus-DTNZNwa9.js} +1 -1
  59. package/dist/web/assets/{git-commit-horizontal-BaO4kijC.js → git-commit-horizontal-C0QdA7uv.js} +1 -1
  60. package/dist/web/assets/{htmlMode-M02_qd4A.js → htmlMode-Cu-nKV7Z.js} +1 -1
  61. package/dist/web/assets/{index-BvXW3YXD.js → index-De4k_YMo.js} +2 -2
  62. package/dist/web/assets/{info-Dc_GhhOz.js → info-B-n_omgE.js} +1 -1
  63. package/dist/web/assets/{jsonMode-DiQI8vFK.js → jsonMode-B377iBCv.js} +1 -1
  64. package/dist/web/assets/{lspLanguageFeatures-tEe-JDHC.js → lspLanguageFeatures-BBHfVtV0.js} +1 -1
  65. package/dist/web/assets/{minimize-2-DGtAI2xp.js → minimize-2-C6JQGKgk.js} +1 -1
  66. package/dist/web/assets/{monaco.contribution-BdUm7liL.js → monaco.contribution-B0l6Oe3a.js} +2 -2
  67. package/dist/web/assets/{monaco.contribution-1SG8tKDo.js → monaco.contribution-BDLeUQLG.js} +2 -2
  68. package/dist/web/assets/{monaco.contribution-4H5UNLKI.js → monaco.contribution-CCSCAu65.js} +2 -2
  69. package/dist/web/assets/{monaco.contribution-COeaSn0J.js → monaco.contribution-CIq6sYw4.js} +2 -2
  70. package/dist/web/assets/{play-Dm-ygxKN.js → play-B5O4Hz_W.js} +1 -1
  71. package/dist/web/assets/{python-rqeHprul.js → python-BQkq0gZA.js} +1 -1
  72. package/dist/web/assets/{refresh-cw-BIkrZ0pv.js → refresh-cw-D2E-pp4H.js} +1 -1
  73. package/dist/web/assets/{save-EdH_bDsl.js → save-CPNNuWwp.js} +1 -1
  74. package/dist/web/assets/{square-pCmN_gDj.js → square-DUgXVoF0.js} +1 -1
  75. package/dist/web/assets/{toggleHighContrast-BJSQSsib.js → toggleHighContrast-BbQBtO9I.js} +1 -1
  76. package/dist/web/assets/{tsMode-3mUrkBEX.js → tsMode-CsVhouTE.js} +1 -1
  77. package/dist/web/assets/{upload-BPPE0xhi.js → upload-t7xHt3GY.js} +1 -1
  78. package/dist/web/assets/{useLocalAgentSchedules-CHOz2V-t.js → useLocalAgentSchedules-D4lJelHt.js} +1 -1
  79. package/dist/web/assets/{wifi-off-217UMa2b.js → wifi-off-B_QPKtA-.js} +1 -1
  80. package/dist/web/assets/{workers-T9yMlI_c.js → workers-p7TrE4Qa.js} +1 -1
  81. package/dist/web/assets/{yaml-DjGDwz3-.js → yaml-C8adeAyH.js} +1 -1
  82. package/dist/web/index.html +1 -1
  83. package/package.json +1 -1
  84. package/dist/web/assets/HostedModelLearningReview-BHboiGq4.js +0 -1
  85. package/dist/web/assets/chevron-up-DI8qm7Ek.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CommandMenu-DLe1d-iP.js","./index-BvXW3YXD.js","./index-C5EoPZr0.css","./CommandMenu-Cb3vNGJr.css","./SettingsView-Bjf1bZOw.js","./refresh-cw-BIkrZ0pv.js","./chat-file-links-BYbiaIO1.js","./save-EdH_bDsl.js","./folder-open-DvI8m5Sx.js","./chevron-up-DI8qm7Ek.js","./play-Dm-ygxKN.js","./wifi-off-217UMa2b.js","./useLocalAgentSchedules-CHOz2V-t.js","./cloud-upload-BCFuH4X6.js","./git-commit-horizontal-BaO4kijC.js","./folder-plus-By8mYY0v.js","./AppDialog-D4siaKMi.js","./WorkspaceDiffPanel-DeHSMDXy.js","./MarkdownText-D43uIpOy.js","./desktop-files-BQj1J-ob.js","./training-model-data-CKOkpBBL.js","./info-Dc_GhhOz.js","./minimize-2-DGtAI2xp.js","./clipboard-Dfk4RCIt.js","./SettingsView-B9Tn0_zX.css","./git-dialogs-BZDqS1eT.css","./NewProjectDialog-DFAGQHU5.js","./WorkspaceGitDialogs-WpfoEpEk.js","./upload-BPPE0xhi.js","./WorkspaceEnvironmentMenu-sgYQj7uK.js","./square-pCmN_gDj.js","./WorkspaceEnvironmentMenu-DGIFdG3o.css","./MainPane-BT58d6eG.js","./arrow-up-right-Dw1pcY62.js"])))=>i.map(i=>d[i]);
2
- import{r as g,j as x,a as L_,_ as Nr}from"./index-BvXW3YXD.js";const C0=g.createContext(void 0),R0=e=>{const t=g.useContext(C0);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},U_=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),x.jsx(C0.Provider,{value:e,children:t})),z_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var H_=class{#e=z_;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};const Ir=new H_;function q_(e){setTimeout(e,0)}const B_=typeof window>"u"||"Deno"in globalThis;function Gn(){}function F_(e,t){return typeof e=="function"?e(t):e}function P0(e){return typeof e=="number"&&e>=0&&e!==1/0}function A0(e,t){return Math.max(e+(t||0)-Date.now(),0)}function an(e,t){return typeof e=="function"?e(t):e}function Lg(e,t){const{type:n="all",exact:a,fetchStatus:r,predicate:i,queryKey:s,stale:l}=e;if(s){if(a){if(t.queryHash!==Mf(s,t.options))return!1}else if(!Ni(t.queryKey,s))return!1}if(n!=="all"){const m=t.isActive();if(n==="active"&&!m||n==="inactive"&&m)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||r&&r!==t.state.fetchStatus||i&&!i(t))}function Ug(e,t){const{exact:n,status:a,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ll(t.options.mutationKey)!==ll(i))return!1}else if(!Ni(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||r&&!r(t))}function Mf(e,t){return(t?.queryKeyHashFn||ll)(e)}function ll(e){return JSON.stringify(e,(t,n)=>Rp(n)?Object.keys(n).sort().reduce((a,r)=>(a[r]=n[r],a),{}):n)}function Ni(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){for(let a=0;a<t.length;a++)if(!Ni(e[a],t[a]))return!1;return!0}const n=Object.keys(t);for(const a of n)if(!Ni(e[a],t[a]))return!1;return!0}return!1}const V_=Object.prototype.hasOwnProperty;function T0(e,t,n=0){if(e===t)return e;if(n>500)return t;const a=zg(e)&&zg(t);if(!a&&!(Rp(e)&&Rp(t)))return t;const r=(a?e:Object.keys(e)).length,i=a?t:Object.keys(t),s=i.length,l=a?new Array(s):{};let m=0;for(let u=0;u<s;u++){const h=a?u:i[u],b=e[h],y=t[h];if(b===y){l[h]=b,(a?u<r:V_.call(e,h))&&m++;continue}if(b===null||y===null||typeof b!="object"||typeof y!="object"){l[h]=y;continue}const w=T0(b,y,n+1);l[h]=w,w===b&&m++}return r===s&&m===r?e:l}function pm(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function zg(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Rp(e){if(!Hg(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Hg(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Hg(e){return Object.prototype.toString.call(e)==="[object Object]"}function K_(e){return new Promise(t=>{Ir.setTimeout(t,e)})}function Pp(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?T0(e,t):t}function W_(e,t,n=0){const a=[...e,t];return n&&a.length>n?a.slice(1):a}function G_(e,t,n=0){const a=[t,...e];return n&&a.length>n?a.slice(0,-1):a}const jf=Symbol();function E0(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===jf?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function M0(e,t){return typeof e=="function"?e(...t):!!e}function Z_(e,t,n){let a=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??=t(),a||(a=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),e}let J_=()=>B_;const Of=()=>J_();var Rl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Y_=class extends Rl{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}};const $f=new Y_,Q_=q_;function X_(){let e=[],t=0,n=l=>{l()},a=l=>{l()},r=Q_;const i=l=>{t?e.push(l):r(()=>{n(l)})},s=()=>{const l=e;e=[],l.length&&r(()=>{a(()=>{l.forEach(m=>{n(m)})})})};return{batch:l=>{let m;t++;try{m=l()}finally{t--,t||s()}return m},batchCalls:l=>(...m)=>{i(()=>{l(...m)})},schedule:i,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{a=l},setScheduler:l=>{r=l}}}const Rn=X_();var eC=class extends Rl{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};const Zc=new eC;function tC(e){return Math.min(1e3*2**e,3e4)}function j0(e){return(e??"online")==="online"?Zc.isOnline():!0}var Ap=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function O0(e){let t=!1,n=0,a,r="pending",i,s;const l=new Promise((L,$)=>{i=L,s=$});l.catch(Gn);const m=()=>r!=="pending",u=L=>{if(!m()){const $=new Ap(L);E($),e.onCancel?.($)}},h=()=>{t=!0},b=()=>{t=!1},y=()=>$f.isFocused()&&(e.networkMode==="always"||Zc.isOnline())&&e.canRun(),w=()=>j0(e.networkMode)&&e.canRun(),_=L=>{m()||(a?.(),r="resolved",i(L))},E=L=>{m()||(a?.(),r="rejected",s(L))},j=()=>new Promise(L=>{a=$=>{(m()||y())&&L($)},e.onPause?.()}).then(()=>{a=void 0,m()||e.onContinue?.()}),P=()=>{if(m())return;let L;const $=n===0?e.initialPromise:void 0;try{L=$??e.fn()}catch(O){L=Promise.reject(O)}Promise.resolve(L).then(_).catch(O=>{if(m())return;const k=e.retry??(Of()?0:3),C=e.retryDelay??tC,A=typeof C=="function"?C(n,O):C,z=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,O);if(t||!z){E(O);return}n++,e.onFail?.(n,O),K_(A).then(()=>y()?void 0:j()).then(()=>{t?E(O):P()})})};return{promise:l,status:()=>r,cancel:u,continue:()=>(a?.(),l),cancelRetry:h,continueRetry:b,canStart:w,start:()=>(w()?P():j().then(P),l)}}var $0=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),P0(this.gcTime)&&(this.#e=Ir.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Of()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Ir.clearTimeout(this.#e),this.#e=void 0)}};function nC(e){return{onFetch:(t,n)=>{const a=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],s=t.state.data?.pageParams||[];let l={pages:[],pageParams:[]},m=0;const u=async()=>{let h=!1;const b=_=>{Z_(_,()=>t.signal,()=>h=!0)},y=E0(t.options,t.fetchOptions),w=async(_,E,j)=>{if(h)return Promise.reject(t.signal.reason);if(E==null&&_.pages.length)return Promise.resolve(_);const L=(()=>{const C={client:t.client,queryKey:t.queryKey,pageParam:E,direction:j?"backward":"forward",meta:t.options.meta};return b(C),C})(),$=await y(L),{maxPages:O}=t.options,k=j?G_:W_;return{pages:k(_.pages,$,O),pageParams:k(_.pageParams,E,O)}};if(r&&i.length){const _=r==="backward",E=_?aC:qg,j={pages:i,pageParams:s};l=await w(j,E(a,j),_)}else{const _=e??i.length;do{const E=m===0?s[0]??a.initialPageParam:qg(a,l);if(m>0&&E==null)break;l=await w(l,E),m++}while(m<_)}return l};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function qg(e,{pages:t,pageParams:n}){const a=t.length-1;return t.length>0?e.getNextPageParam(t[a],t,n[a],n):void 0}function aC(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var oC=class extends $0{#e;#t;#n;#a;#r;#o;#i;#l;constructor(e){super(),this.#l=!1,this.#i=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#a=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Fg(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#o?.promise}setOptions(e){if(this.options={...this.#i,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Fg(this.options);t.data!==void 0&&(this.setState(Bg(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(e,t){const n=Pp(this.state.data,e,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#s({type:"setState",state:e})}cancel(e){const t=this.#o?.promise;return this.#o?.cancel(e),t?t.then(Gn).catch(Gn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>an(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===jf||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>an(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!A0(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#o?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#o?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){const t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#o&&(this.#l||this.state.fetchStatus==="paused"&&this.state.status==="pending"?this.#o.cancel({revert:!0}):this.#o.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#o?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#o)return this.#o.continueRetry(),this.#o.promise}if(e&&this.setOptions(e),!this.options.queryFn){const m=this.observers.find(u=>u.options.queryFn);m&&this.setOptions(m.options)}const n=new AbortController,a=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(this.#l=!0,n.signal)})},r=()=>{const m=E0(this.options,t),h=(()=>{const b={client:this.#r,queryKey:this.queryKey,meta:this.meta};return a(b),b})();return this.#l=!1,this.options.persister?this.options.persister(m,h,this):m(h)},s=(()=>{const m={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return a(m),m})();(this.#e==="infinite"?nC(this.options.pages):this.options.behavior)?.onFetch(s,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#s({type:"fetch",meta:s.fetchOptions?.meta});const l=this.#o=O0({initialPromise:t?.initialPromise,fn:s.fetchFn,onCancel:m=>{m instanceof Ap&&m.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(m,u)=>{this.#s({type:"failed",failureCount:m,error:u})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const m=await l.start();if(m===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(m),this.#a.config.onSuccess?.(m,this),this.#a.config.onSettled?.(m,this.state.error,this),m}catch(m){if(m instanceof Ap){if(m.silent)return this.#o.promise;if(m.revert){if(this.state.data===void 0)throw m;return this.state.data}}throw this.#s({type:"error",error:m}),this.#a.config.onError?.(m,this),this.#a.config.onSettled?.(this.state.data,m,this),m}finally{this.#o===l&&(this.#o=void 0),this.scheduleGc()}}#s(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...N0(n.data,this.options),fetchMeta:e.meta??null};case"success":const a={...n,...Bg(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?a:void 0,a;case"error":const r=e.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),Rn.batch(()=>{this.observers.slice().forEach(n=>{n.onQueryUpdate()}),this.#a.notify({query:this,type:"updated",action:e})})}};function N0(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:j0(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Bg(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Fg(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,a=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var rC=class extends Rl{#e;#t=void 0;#n=void 0;#a=void 0;#r;#o;#i;#l;#s;#p;#d;#u;#c;#f=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Vg(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Tp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Tp(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof an(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#k(),this.#t.setOptions(this.options),t._defaulted&&!pm(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const a=this.hasListeners();a&&Kg(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),a&&(this.#t!==n||an(this.options.enabled,this.#t)!==an(t.enabled,this.#t)||an(this.options.staleTime,this.#t)!==an(t.staleTime,this.#t))&&this.#g();const r=this.#v();a&&(this.#t!==n||an(this.options.enabled,this.#t)!==an(t.enabled,this.#t)||r!==this.#c)&&this.#b(r)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return pm(this.getCurrentResult(),n)||(this.#a=n,this.#o=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#a}trackResult(e,t){return new Proxy(e,{get:(n,a)=>(this.trackProp(a),t?.(a),Reflect.get(n,a))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);let a=()=>{},r;const i=new Promise(s=>{r=s,a=this.#e.getQueryCache().subscribe(l=>{l.type==="updated"&&l.query.queryHash===n.queryHash&&n.state.data!==void 0&&(a(),s(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{const s=this.createResult(n,t);return r?.(s),s}).finally(()=>{a()}),i])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#m(e){this.#k();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Gn)),t}#h(e){return!Of()&&an(this.options.enabled,this.#t)!==!1&&P0(e)}#g(){this.#S();const e=an(this.options.staleTime,this.#t);if(this.#a.isStale||!this.#h(e))return;const t=A0(this.#a.dataUpdatedAt,e)+1;this.#d=Ir.setTimeout(()=>{this.#a.isStale||this.updateResult()},t)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(e){this.#x(),this.#c=e,!(this.#c===0||!this.#h(this.#c))&&(this.#u=Ir.setInterval(()=>{(this.options.refetchIntervalInBackground||$f.isFocused())&&this.#m()},this.#c))}#y(){this.#g(),this.#b(this.#v())}#S(){this.#d!==void 0&&(Ir.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#u!==void 0&&(Ir.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#t,a=this.options,r=this.#a,i=this.#r,s=this.#o,l=e!==n?e.state:this.#n,{state:m}=e;let u={...m},h=!1,b;if(t._optimisticResults){const k=this.hasListeners(),C=!k&&Vg(e,t),A=k&&Kg(e,n,t,a);(C||A)&&(u={...u,...N0(m.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:y,errorUpdatedAt:w,status:_}=u;b=u.data;let E=!1;if(t.placeholderData!==void 0&&b===void 0&&_==="pending"){let k;r?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(k=r.data,E=!0):k=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,k!==void 0&&(_="success",b=Pp(r?.data,k,t),h=!0)}if(t.select&&b!==void 0&&!E)if(r&&b===i?.data&&t.select===this.#l)b=this.#s;else try{this.#l=t.select,b=t.select(b),b=Pp(r?.data,b,t),this.#s=b,this.#i=null}catch(k){this.#i=k}else b===void 0&&(this.#i=null);this.#i&&(y=this.#i,b=this.#s,w=Date.now(),_="error",h=!1);const j=u.fetchStatus==="fetching",P=_==="pending",L=_==="error",$=P&&j,O=b!==void 0;return{status:_,fetchStatus:u.fetchStatus,isPending:P,isSuccess:_==="success",isError:L,isInitialLoading:$,isLoading:$,data:b,dataUpdatedAt:u.dataUpdatedAt,error:y,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:j,isRefetching:j&&!P,isLoadingError:L&&!O,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:L&&O,isStale:Nf(e,t),refetch:this.refetch,isEnabled:an(t.enabled,e)!==!1}}updateResult(){const e=this.#a,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#o=this.options,this.#r.data!==void 0&&(this.#p=this.#t),pm(t,e))return;this.#a=t;const a=(()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#f.size)return!0;const s=new Set(i??this.#f);return this.options.throwOnError&&s.add("error"),Object.keys(this.#a).some(l=>{const m=l;return this.#a[m]!==e[m]&&s.has(m)})})();Rn.batch(()=>{a&&this.listeners.forEach(r=>{r(this.#a)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#k(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function iC(e,t){return an(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&an(t.retryOnMount,e)===!1)}function Vg(e,t){return iC(e,t)||e.state.data!==void 0&&Tp(e,t,t.refetchOnMount)}function Tp(e,t,n){if(an(t.enabled,e)!==!1&&an(t.staleTime,e)!=="static"){const a=typeof n=="function"?n(e):n;return a==="always"||a!==!1&&Nf(e,t)}return!1}function Kg(e,t,n,a){return(e!==t||an(a.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Nf(e,n)}function Nf(e,t){return an(t.enabled,e)!==!1&&e.isStaleByTime(an(t.staleTime,e))}var sC=class extends $0{#e;#t;#n;#a;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||lC(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#a?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(e){const t=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},a=this.#a=O0({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,l)=>{this.#r({type:"failed",failureCount:s,error:l})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),r=this.state.status==="pending",i=!a.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const l=await this.options.onMutate?.(e,n);l!==this.state.context&&this.#r({type:"pending",context:l,variables:e,isPaused:i})}const s=await a.start();return await this.#n.config.onSuccess?.(s,e,this.state.context,this,n),await this.options.onSuccess?.(s,e,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,e,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{await this.#n.config.onError?.(s,e,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onError?.(s,e,this.state.context,n)}catch(l){Promise.reject(l)}try{await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,s,e,this.state.context,n)}catch(l){Promise.reject(l)}throw this.#r({type:"error",error:s}),s}finally{this.#a===a&&(this.#a=void 0),this.#n.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),Rn.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function lC(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var cC=class extends Rl{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){const a=new sC({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(a),a}add(e){this.#e.add(e);const t=fc(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=fc(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const a=n.indexOf(e);a!==-1&&n.splice(a,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=fc(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(a=>a.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=fc(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Rn.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ug(t,n))}findAll(e={}){return this.getAll().filter(t=>Ug(e,t))}notify(e){Rn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Rn.batch(()=>Promise.all(e.map(t=>t.continue().catch(Gn))))}};function fc(e){return e.options.scope?.id}var dC=class extends Rl{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const a=t.queryKey,r=t.queryHash??Mf(a,t);let i=this.get(r);return i||(i=new oC({client:e,queryKey:a,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(a)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Rn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Lg(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Lg(e,n)):t}notify(e){Rn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Rn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Rn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},uC=class{#e;#t;#n;#a;#r;#o;#i;#l;constructor(e={}){this.#e=e.queryCache||new dC,this.#t=e.mutationCache||new cC,this.#n=e.defaultOptions||{},this.#a=new Map,this.#r=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=$f.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#l=Zc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#l?.(),this.#l=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),a=n.state.data;return a===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(an(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(a))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const a=this.defaultQueryOptions({queryKey:e}),r=this.#e.get(a.queryHash)?.state.data,i=F_(t,r);if(i!==void 0)return this.#e.build(this,a).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Rn.batch(()=>this.#e.findAll(e).map(({queryKey:a})=>[a,this.setQueryData(a,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Rn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return Rn.batch(()=>{const a=n.findAll(e),r=new Set(a);return a.forEach(i=>{i.reset()}),this.refetchQueries({type:"active",predicate:i=>r.has(i)},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},a=Rn.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(a).then(Gn).catch(Gn)}invalidateQueries(e,t={}){return Rn.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},a=Rn.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(Gn)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(Gn)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),a=n.isStaleByTime(an(t.staleTime,n))?await n.fetch(t):n.state.data,r=t.select;return r?r(a):a}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(an(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Gn).catch(Gn)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Gn).catch(Gn)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Zc.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#a.set(ll(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#a.values()],n={};return t.forEach(a=>{Ni(e,a.queryKey)&&Object.assign(n,a.defaultOptions)}),n}setMutationDefaults(e,t){this.#r.set(ll(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(a=>{Ni(e,a.mutationKey)&&Object.assign(n,a.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Mf(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===jf&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};const D0=g.createContext(!1),mC=()=>g.useContext(D0);D0.Provider;function pC(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const fC=g.createContext(pC()),hC=()=>g.useContext(fC),gC=(e,t,n)=>{const a=n?.state.error&&typeof e.throwOnError=="function"?M0(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||a)&&(t.isReset()||(e.retryOnMount=!1))},vC=e=>{g.useEffect(()=>{e.clearReset()},[e])},bC=({result:e,errorResetBoundary:t,throwOnError:n,query:a,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&a&&(r&&e.data===void 0||M0(n,[e.error,a])),yC=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),a=e.staleTime;e.staleTime=typeof a=="function"?(...r)=>n(a(...r)):n(a),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},SC=(e,t)=>e?.suspense&&t.isPending,xC=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function kC(e,t,n){const a=mC(),r=hC(),i=R0(),s=i.defaultQueryOptions(e),l=i.getQueryCache().get(s.queryHash),m=e.subscribed!==!1;s._optimisticResults=a?"isRestoring":m?"optimistic":void 0,yC(s),gC(s,r,l),vC(r);const[u]=g.useState(()=>new t(i,s)),h=u.getOptimisticResult(s),b=!a&&m;if(g.useSyncExternalStore(g.useCallback(y=>{const w=b?u.subscribe(Rn.batchCalls(y)):Gn;return u.updateResult(),w},[u,b]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(s)},[s,u]),SC(s,h))throw xC(s,u,r);if(bC({result:h,errorResetBoundary:r,throwOnError:s.throwOnError,query:l,suspense:s.suspense}))throw h.error;return s.notifyOnChangeProps?h:u.trackResult(h)}function wC(e,t){return kC(e,rC)}function IC(){return new uC({defaultOptions:{queries:{staleTime:6e4,gcTime:15*6e4,retry:1,refetchOnWindowFocus:!1}}})}var Wg;function ve(e,t,n){function a(l,m){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:m,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,m);const u=s.prototype,h=Object.keys(u);for(let b=0;b<h.length;b++){const y=h[b];y in l||(l[y]=u[y].bind(l))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(l){var m;const u=n?.Parent?new i:this;a(u,l),(m=u._zod).deferred??(m.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class Ei extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class L0 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Wg=globalThis).__zod_globalConfig??(Wg.__zod_globalConfig={});const Df=globalThis.__zod_globalConfig;function Lo(e){return Df}function U0(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Ep(e,t){return typeof t=="bigint"?t.toString():t}function bd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Lf(e){return e==null}function Uf(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _C(e,t){const n=e/t,a=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-a)<r?0:n-a}const Gg=Symbol("evaluating");function Pt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Gg)return a===void 0&&(a=Gg,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Dr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function rr(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Zg(e){return JSON.stringify(e)}function CC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const z0="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const RC=bd(()=>{if(Df.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Di(e){if(cl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(cl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function H0(e){return Di(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const PC=new Set(["string","number","symbol"]);function Li(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ir(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function nt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function AC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const TC={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function EC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=rr(e._zod.def,{get shape(){const s={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(s[l]=n.shape[l])}return Dr(this,"shape",s),s},checks:[]});return ir(e,i)}function MC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=rr(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete s[l]}return Dr(this,"shape",s),s},checks:[]});return ir(e,i)}function jC(e,t){if(!Di(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=rr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Dr(this,"shape",i),i}});return ir(e,r)}function OC(e,t){if(!Di(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=rr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Dr(this,"shape",a),a}});return ir(e,n)}function $C(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=rr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Dr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ir(e,n)}function NC(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=rr(t._zod.def,{get shape(){const l=t._zod.def.shape,m={...l};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(m[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)m[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return Dr(this,"shape",m),m},checks:[]});return ir(t,s)}function DC(e,t,n){const a=rr(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Dr(this,"shape",i),i}});return ir(t,a)}function ki(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function LC(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function wi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function hc(e){return typeof e=="string"?e:e?.message}function Uo(e,t,n){const a=e.message?e.message:hc(e.inst?._zod.def?.error?.(e))??hc(t?.error?.(e))??hc(n.customError?.(e))??hc(n.localeError?.(e))??"Invalid input",{inst:r,continue:i,input:s,...l}=e;return l.path??(l.path=[]),l.message=a,t?.reportInput&&(l.input=s),l}function zf(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function dl(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const q0=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ep,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},B0=ve("$ZodError",q0),F0=ve("$ZodError",q0,{Parent:Error});function UC(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function zC(e,t=n=>n.message){const n={_errors:[]},a=(r,i=[])=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(l=>a({issues:l},[...i,...s.path]));else if(s.code==="invalid_key")a({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")a({issues:s.issues},[...i,...s.path]);else{const l=[...i,...s.path];if(l.length===0)n._errors.push(t(s));else{let m=n,u=0;for(;u<l.length;){const h=l[u];u===l.length-1?(m[h]=m[h]||{_errors:[]},m[h]._errors.push(t(s))):m[h]=m[h]||{_errors:[]},m=m[h],u++}}}};return a(e),n}const Hf=e=>(t,n,a,r)=>{const i=a?{...a,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ei;if(s.issues.length){const l=new(r?.Err??e)(s.issues.map(m=>Uo(m,i,Lo())));throw z0(l,r?.callee),l}return s.value},qf=e=>async(t,n,a,r)=>{const i=a?{...a,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const l=new(r?.Err??e)(s.issues.map(m=>Uo(m,i,Lo())));throw z0(l,r?.callee),l}return s.value},yd=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Ei;return i.issues.length?{success:!1,error:new(e??B0)(i.issues.map(s=>Uo(s,r,Lo())))}:{success:!0,data:i.value}},HC=yd(F0),Sd=e=>async(t,n,a)=>{const r=a?{...a,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Uo(s,r,Lo())))}:{success:!0,data:i.value}},qC=Sd(F0),BC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return Hf(e)(t,n,r)},FC=e=>(t,n,a)=>Hf(e)(t,n,a),VC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return qf(e)(t,n,r)},KC=e=>async(t,n,a)=>qf(e)(t,n,a),WC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return yd(e)(t,n,r)},GC=e=>(t,n,a)=>yd(e)(t,n,a),ZC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return Sd(e)(t,n,r)},JC=e=>async(t,n,a)=>Sd(e)(t,n,a),YC=/^[cC][0-9a-z]{6,}$/,QC=/^[0-9a-z]+$/,XC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eR=/^[0-9a-vA-V]{20}$/,tR=/^[A-Za-z0-9]{27}$/,nR=/^[a-zA-Z0-9_-]{21}$/,aR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,oR=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Jg=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,rR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,iR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sR(){return new RegExp(iR,"u")}const lR=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,dR=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,uR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,V0=/^[A-Za-z0-9_-]*$/,pR=/^https?$/,fR=/^\+[1-9]\d{6,14}$/,K0="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",hR=new RegExp(`^${K0}$`);function W0(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function gR(e){return new RegExp(`^${W0(e)}$`)}function vR(e){const t=W0({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${K0}T(?:${a})$`)}const bR=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},yR=/^-?\d+$/,G0=/^-?\d+(?:\.\d+)?$/,SR=/^(?:true|false)$/i,xR=/^null$/i,kR=/^[^A-Z]*$/,wR=/^[^a-z]*$/,Xn=ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Z0={number:"number",bigint:"bigint",object:"date"},J0=ve("$ZodCheckLessThan",(e,t)=>{Xn.init(e,t);const n=Z0[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Y0=ve("$ZodCheckGreaterThan",(e,t)=>{Xn.init(e,t);const n=Z0[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),IR=ve("$ZodCheckMultipleOf",(e,t)=>{Xn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):_C(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),_R=ve("$ZodCheckNumberFormat",(e,t)=>{Xn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=TC[t.format];e._zod.onattach.push(s=>{const l=s._zod.bag;l.format=t.format,l.minimum=r,l.maximum=i,n&&(l.pattern=yR)}),e._zod.check=s=>{const l=s.value;if(n){if(!Number.isInteger(l)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}l<r&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),l>i&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),CR=ve("$ZodCheckMaxLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Lf(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const s=zf(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),RR=ve("$ZodCheckMinLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Lf(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const s=zf(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),PR=ve("$ZodCheckLengthEquals",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Lf(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const s=zf(r),l=i>t.length;a.issues.push({origin:s,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),xd=ve("$ZodCheckStringFormat",(e,t)=>{var n,a;Xn.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),AR=ve("$ZodCheckRegex",(e,t)=>{xd.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),TR=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kR),xd.init(e,t)}),ER=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wR),xd.init(e,t)}),MR=ve("$ZodCheckIncludes",(e,t)=>{Xn.init(e,t);const n=Li(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),jR=ve("$ZodCheckStartsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`^${Li(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),OR=ve("$ZodCheckEndsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`.*${Li(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),$R=ve("$ZodCheckOverwrite",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class NR{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CommandMenu-Deqzk3u9.js","./index-De4k_YMo.js","./index-C5EoPZr0.css","./CommandMenu-Cb3vNGJr.css","./SettingsView-BIwO8elm.js","./refresh-cw-D2E-pp4H.js","./chat-file-links-DQYtkwit.js","./save-CPNNuWwp.js","./folder-open-D0PIN0Cj.js","./chevron-up-BUOpWd2a.js","./play-B5O4Hz_W.js","./wifi-off-B_QPKtA-.js","./useLocalAgentSchedules-D4lJelHt.js","./cloud-upload-DisZOwXE.js","./git-commit-horizontal-C0QdA7uv.js","./folder-plus-DTNZNwa9.js","./AppDialog-BnldMLvF.js","./WorkspaceDiffPanel-BoB_1R8w.js","./MarkdownText-DWGLUbdE.js","./desktop-files-BQj1J-ob.js","./training-model-data-CKOkpBBL.js","./info-B-n_omgE.js","./minimize-2-C6JQGKgk.js","./clipboard-CnNPmg50.js","./SettingsView-BaWWvIJW.css","./git-dialogs-BZDqS1eT.css","./NewProjectDialog-B-7dHoT6.js","./WorkspaceGitDialogs-BC45mifk.js","./upload-t7xHt3GY.js","./WorkspaceEnvironmentMenu-Dvqy2NJP.js","./square-DUgXVoF0.js","./WorkspaceEnvironmentMenu-DGIFdG3o.css","./MainPane-Dv5USGqR.js","./arrow-up-right-Dv3nebbh.js"])))=>i.map(i=>d[i]);
2
+ import{r as g,j as x,a as L_,_ as Nr}from"./index-De4k_YMo.js";const C0=g.createContext(void 0),R0=e=>{const t=g.useContext(C0);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},U_=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),x.jsx(C0.Provider,{value:e,children:t})),z_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var H_=class{#e=z_;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};const Ir=new H_;function q_(e){setTimeout(e,0)}const B_=typeof window>"u"||"Deno"in globalThis;function Gn(){}function F_(e,t){return typeof e=="function"?e(t):e}function P0(e){return typeof e=="number"&&e>=0&&e!==1/0}function A0(e,t){return Math.max(e+(t||0)-Date.now(),0)}function an(e,t){return typeof e=="function"?e(t):e}function Lg(e,t){const{type:n="all",exact:a,fetchStatus:r,predicate:i,queryKey:s,stale:l}=e;if(s){if(a){if(t.queryHash!==Mf(s,t.options))return!1}else if(!Ni(t.queryKey,s))return!1}if(n!=="all"){const m=t.isActive();if(n==="active"&&!m||n==="inactive"&&m)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||r&&r!==t.state.fetchStatus||i&&!i(t))}function Ug(e,t){const{exact:n,status:a,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ll(t.options.mutationKey)!==ll(i))return!1}else if(!Ni(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||r&&!r(t))}function Mf(e,t){return(t?.queryKeyHashFn||ll)(e)}function ll(e){return JSON.stringify(e,(t,n)=>Rp(n)?Object.keys(n).sort().reduce((a,r)=>(a[r]=n[r],a),{}):n)}function Ni(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){for(let a=0;a<t.length;a++)if(!Ni(e[a],t[a]))return!1;return!0}const n=Object.keys(t);for(const a of n)if(!Ni(e[a],t[a]))return!1;return!0}return!1}const V_=Object.prototype.hasOwnProperty;function T0(e,t,n=0){if(e===t)return e;if(n>500)return t;const a=zg(e)&&zg(t);if(!a&&!(Rp(e)&&Rp(t)))return t;const r=(a?e:Object.keys(e)).length,i=a?t:Object.keys(t),s=i.length,l=a?new Array(s):{};let m=0;for(let u=0;u<s;u++){const h=a?u:i[u],b=e[h],y=t[h];if(b===y){l[h]=b,(a?u<r:V_.call(e,h))&&m++;continue}if(b===null||y===null||typeof b!="object"||typeof y!="object"){l[h]=y;continue}const w=T0(b,y,n+1);l[h]=w,w===b&&m++}return r===s&&m===r?e:l}function pm(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function zg(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Rp(e){if(!Hg(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Hg(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Hg(e){return Object.prototype.toString.call(e)==="[object Object]"}function K_(e){return new Promise(t=>{Ir.setTimeout(t,e)})}function Pp(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?T0(e,t):t}function W_(e,t,n=0){const a=[...e,t];return n&&a.length>n?a.slice(1):a}function G_(e,t,n=0){const a=[t,...e];return n&&a.length>n?a.slice(0,-1):a}const jf=Symbol();function E0(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===jf?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function M0(e,t){return typeof e=="function"?e(...t):!!e}function Z_(e,t,n){let a=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??=t(),a||(a=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),e}let J_=()=>B_;const Of=()=>J_();var Rl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Y_=class extends Rl{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}};const $f=new Y_,Q_=q_;function X_(){let e=[],t=0,n=l=>{l()},a=l=>{l()},r=Q_;const i=l=>{t?e.push(l):r(()=>{n(l)})},s=()=>{const l=e;e=[],l.length&&r(()=>{a(()=>{l.forEach(m=>{n(m)})})})};return{batch:l=>{let m;t++;try{m=l()}finally{t--,t||s()}return m},batchCalls:l=>(...m)=>{i(()=>{l(...m)})},schedule:i,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{a=l},setScheduler:l=>{r=l}}}const Rn=X_();var eC=class extends Rl{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};const Zc=new eC;function tC(e){return Math.min(1e3*2**e,3e4)}function j0(e){return(e??"online")==="online"?Zc.isOnline():!0}var Ap=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function O0(e){let t=!1,n=0,a,r="pending",i,s;const l=new Promise((L,$)=>{i=L,s=$});l.catch(Gn);const m=()=>r!=="pending",u=L=>{if(!m()){const $=new Ap(L);E($),e.onCancel?.($)}},h=()=>{t=!0},b=()=>{t=!1},y=()=>$f.isFocused()&&(e.networkMode==="always"||Zc.isOnline())&&e.canRun(),w=()=>j0(e.networkMode)&&e.canRun(),_=L=>{m()||(a?.(),r="resolved",i(L))},E=L=>{m()||(a?.(),r="rejected",s(L))},j=()=>new Promise(L=>{a=$=>{(m()||y())&&L($)},e.onPause?.()}).then(()=>{a=void 0,m()||e.onContinue?.()}),P=()=>{if(m())return;let L;const $=n===0?e.initialPromise:void 0;try{L=$??e.fn()}catch(O){L=Promise.reject(O)}Promise.resolve(L).then(_).catch(O=>{if(m())return;const k=e.retry??(Of()?0:3),C=e.retryDelay??tC,A=typeof C=="function"?C(n,O):C,z=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,O);if(t||!z){E(O);return}n++,e.onFail?.(n,O),K_(A).then(()=>y()?void 0:j()).then(()=>{t?E(O):P()})})};return{promise:l,status:()=>r,cancel:u,continue:()=>(a?.(),l),cancelRetry:h,continueRetry:b,canStart:w,start:()=>(w()?P():j().then(P),l)}}var $0=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),P0(this.gcTime)&&(this.#e=Ir.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Of()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Ir.clearTimeout(this.#e),this.#e=void 0)}};function nC(e){return{onFetch:(t,n)=>{const a=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],s=t.state.data?.pageParams||[];let l={pages:[],pageParams:[]},m=0;const u=async()=>{let h=!1;const b=_=>{Z_(_,()=>t.signal,()=>h=!0)},y=E0(t.options,t.fetchOptions),w=async(_,E,j)=>{if(h)return Promise.reject(t.signal.reason);if(E==null&&_.pages.length)return Promise.resolve(_);const L=(()=>{const C={client:t.client,queryKey:t.queryKey,pageParam:E,direction:j?"backward":"forward",meta:t.options.meta};return b(C),C})(),$=await y(L),{maxPages:O}=t.options,k=j?G_:W_;return{pages:k(_.pages,$,O),pageParams:k(_.pageParams,E,O)}};if(r&&i.length){const _=r==="backward",E=_?aC:qg,j={pages:i,pageParams:s};l=await w(j,E(a,j),_)}else{const _=e??i.length;do{const E=m===0?s[0]??a.initialPageParam:qg(a,l);if(m>0&&E==null)break;l=await w(l,E),m++}while(m<_)}return l};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function qg(e,{pages:t,pageParams:n}){const a=t.length-1;return t.length>0?e.getNextPageParam(t[a],t,n[a],n):void 0}function aC(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var oC=class extends $0{#e;#t;#n;#a;#r;#o;#i;#l;constructor(e){super(),this.#l=!1,this.#i=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#a=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Fg(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#o?.promise}setOptions(e){if(this.options={...this.#i,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Fg(this.options);t.data!==void 0&&(this.setState(Bg(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(e,t){const n=Pp(this.state.data,e,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#s({type:"setState",state:e})}cancel(e){const t=this.#o?.promise;return this.#o?.cancel(e),t?t.then(Gn).catch(Gn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>an(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===jf||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>an(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!A0(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#o?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#o?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){const t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#o&&(this.#l||this.state.fetchStatus==="paused"&&this.state.status==="pending"?this.#o.cancel({revert:!0}):this.#o.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#o?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#o)return this.#o.continueRetry(),this.#o.promise}if(e&&this.setOptions(e),!this.options.queryFn){const m=this.observers.find(u=>u.options.queryFn);m&&this.setOptions(m.options)}const n=new AbortController,a=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(this.#l=!0,n.signal)})},r=()=>{const m=E0(this.options,t),h=(()=>{const b={client:this.#r,queryKey:this.queryKey,meta:this.meta};return a(b),b})();return this.#l=!1,this.options.persister?this.options.persister(m,h,this):m(h)},s=(()=>{const m={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return a(m),m})();(this.#e==="infinite"?nC(this.options.pages):this.options.behavior)?.onFetch(s,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#s({type:"fetch",meta:s.fetchOptions?.meta});const l=this.#o=O0({initialPromise:t?.initialPromise,fn:s.fetchFn,onCancel:m=>{m instanceof Ap&&m.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(m,u)=>{this.#s({type:"failed",failureCount:m,error:u})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const m=await l.start();if(m===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(m),this.#a.config.onSuccess?.(m,this),this.#a.config.onSettled?.(m,this.state.error,this),m}catch(m){if(m instanceof Ap){if(m.silent)return this.#o.promise;if(m.revert){if(this.state.data===void 0)throw m;return this.state.data}}throw this.#s({type:"error",error:m}),this.#a.config.onError?.(m,this),this.#a.config.onSettled?.(this.state.data,m,this),m}finally{this.#o===l&&(this.#o=void 0),this.scheduleGc()}}#s(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...N0(n.data,this.options),fetchMeta:e.meta??null};case"success":const a={...n,...Bg(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?a:void 0,a;case"error":const r=e.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),Rn.batch(()=>{this.observers.slice().forEach(n=>{n.onQueryUpdate()}),this.#a.notify({query:this,type:"updated",action:e})})}};function N0(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:j0(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Bg(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Fg(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,a=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var rC=class extends Rl{#e;#t=void 0;#n=void 0;#a=void 0;#r;#o;#i;#l;#s;#p;#d;#u;#c;#f=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Vg(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Tp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Tp(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof an(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#k(),this.#t.setOptions(this.options),t._defaulted&&!pm(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const a=this.hasListeners();a&&Kg(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),a&&(this.#t!==n||an(this.options.enabled,this.#t)!==an(t.enabled,this.#t)||an(this.options.staleTime,this.#t)!==an(t.staleTime,this.#t))&&this.#g();const r=this.#v();a&&(this.#t!==n||an(this.options.enabled,this.#t)!==an(t.enabled,this.#t)||r!==this.#c)&&this.#b(r)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return pm(this.getCurrentResult(),n)||(this.#a=n,this.#o=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#a}trackResult(e,t){return new Proxy(e,{get:(n,a)=>(this.trackProp(a),t?.(a),Reflect.get(n,a))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);let a=()=>{},r;const i=new Promise(s=>{r=s,a=this.#e.getQueryCache().subscribe(l=>{l.type==="updated"&&l.query.queryHash===n.queryHash&&n.state.data!==void 0&&(a(),s(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{const s=this.createResult(n,t);return r?.(s),s}).finally(()=>{a()}),i])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#m(e){this.#k();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Gn)),t}#h(e){return!Of()&&an(this.options.enabled,this.#t)!==!1&&P0(e)}#g(){this.#S();const e=an(this.options.staleTime,this.#t);if(this.#a.isStale||!this.#h(e))return;const t=A0(this.#a.dataUpdatedAt,e)+1;this.#d=Ir.setTimeout(()=>{this.#a.isStale||this.updateResult()},t)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(e){this.#x(),this.#c=e,!(this.#c===0||!this.#h(this.#c))&&(this.#u=Ir.setInterval(()=>{(this.options.refetchIntervalInBackground||$f.isFocused())&&this.#m()},this.#c))}#y(){this.#g(),this.#b(this.#v())}#S(){this.#d!==void 0&&(Ir.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#u!==void 0&&(Ir.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#t,a=this.options,r=this.#a,i=this.#r,s=this.#o,l=e!==n?e.state:this.#n,{state:m}=e;let u={...m},h=!1,b;if(t._optimisticResults){const k=this.hasListeners(),C=!k&&Vg(e,t),A=k&&Kg(e,n,t,a);(C||A)&&(u={...u,...N0(m.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:y,errorUpdatedAt:w,status:_}=u;b=u.data;let E=!1;if(t.placeholderData!==void 0&&b===void 0&&_==="pending"){let k;r?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(k=r.data,E=!0):k=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,k!==void 0&&(_="success",b=Pp(r?.data,k,t),h=!0)}if(t.select&&b!==void 0&&!E)if(r&&b===i?.data&&t.select===this.#l)b=this.#s;else try{this.#l=t.select,b=t.select(b),b=Pp(r?.data,b,t),this.#s=b,this.#i=null}catch(k){this.#i=k}else b===void 0&&(this.#i=null);this.#i&&(y=this.#i,b=this.#s,w=Date.now(),_="error",h=!1);const j=u.fetchStatus==="fetching",P=_==="pending",L=_==="error",$=P&&j,O=b!==void 0;return{status:_,fetchStatus:u.fetchStatus,isPending:P,isSuccess:_==="success",isError:L,isInitialLoading:$,isLoading:$,data:b,dataUpdatedAt:u.dataUpdatedAt,error:y,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:j,isRefetching:j&&!P,isLoadingError:L&&!O,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:L&&O,isStale:Nf(e,t),refetch:this.refetch,isEnabled:an(t.enabled,e)!==!1}}updateResult(){const e=this.#a,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#o=this.options,this.#r.data!==void 0&&(this.#p=this.#t),pm(t,e))return;this.#a=t;const a=(()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#f.size)return!0;const s=new Set(i??this.#f);return this.options.throwOnError&&s.add("error"),Object.keys(this.#a).some(l=>{const m=l;return this.#a[m]!==e[m]&&s.has(m)})})();Rn.batch(()=>{a&&this.listeners.forEach(r=>{r(this.#a)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#k(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function iC(e,t){return an(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&an(t.retryOnMount,e)===!1)}function Vg(e,t){return iC(e,t)||e.state.data!==void 0&&Tp(e,t,t.refetchOnMount)}function Tp(e,t,n){if(an(t.enabled,e)!==!1&&an(t.staleTime,e)!=="static"){const a=typeof n=="function"?n(e):n;return a==="always"||a!==!1&&Nf(e,t)}return!1}function Kg(e,t,n,a){return(e!==t||an(a.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Nf(e,n)}function Nf(e,t){return an(t.enabled,e)!==!1&&e.isStaleByTime(an(t.staleTime,e))}var sC=class extends $0{#e;#t;#n;#a;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||lC(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#a?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(e){const t=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},a=this.#a=O0({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,l)=>{this.#r({type:"failed",failureCount:s,error:l})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),r=this.state.status==="pending",i=!a.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);const l=await this.options.onMutate?.(e,n);l!==this.state.context&&this.#r({type:"pending",context:l,variables:e,isPaused:i})}const s=await a.start();return await this.#n.config.onSuccess?.(s,e,this.state.context,this,n),await this.options.onSuccess?.(s,e,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,e,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{await this.#n.config.onError?.(s,e,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onError?.(s,e,this.state.context,n)}catch(l){Promise.reject(l)}try{await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,s,e,this.state.context,n)}catch(l){Promise.reject(l)}throw this.#r({type:"error",error:s}),s}finally{this.#a===a&&(this.#a=void 0),this.#n.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),Rn.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function lC(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var cC=class extends Rl{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){const a=new sC({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(a),a}add(e){this.#e.add(e);const t=fc(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=fc(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const a=n.indexOf(e);a!==-1&&n.splice(a,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=fc(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(a=>a.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=fc(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Rn.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ug(t,n))}findAll(e={}){return this.getAll().filter(t=>Ug(e,t))}notify(e){Rn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Rn.batch(()=>Promise.all(e.map(t=>t.continue().catch(Gn))))}};function fc(e){return e.options.scope?.id}var dC=class extends Rl{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const a=t.queryKey,r=t.queryHash??Mf(a,t);let i=this.get(r);return i||(i=new oC({client:e,queryKey:a,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(a)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Rn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Lg(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Lg(e,n)):t}notify(e){Rn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Rn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Rn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},uC=class{#e;#t;#n;#a;#r;#o;#i;#l;constructor(e={}){this.#e=e.queryCache||new dC,this.#t=e.mutationCache||new cC,this.#n=e.defaultOptions||{},this.#a=new Map,this.#r=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=$f.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#l=Zc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#l?.(),this.#l=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),a=n.state.data;return a===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(an(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(a))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const a=this.defaultQueryOptions({queryKey:e}),r=this.#e.get(a.queryHash)?.state.data,i=F_(t,r);if(i!==void 0)return this.#e.build(this,a).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Rn.batch(()=>this.#e.findAll(e).map(({queryKey:a})=>[a,this.setQueryData(a,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Rn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return Rn.batch(()=>{const a=n.findAll(e),r=new Set(a);return a.forEach(i=>{i.reset()}),this.refetchQueries({type:"active",predicate:i=>r.has(i)},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},a=Rn.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(a).then(Gn).catch(Gn)}invalidateQueries(e,t={}){return Rn.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},a=Rn.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(Gn)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(Gn)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),a=n.isStaleByTime(an(t.staleTime,n))?await n.fetch(t):n.state.data,r=t.select;return r?r(a):a}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(an(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Gn).catch(Gn)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Gn).catch(Gn)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Zc.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#a.set(ll(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#a.values()],n={};return t.forEach(a=>{Ni(e,a.queryKey)&&Object.assign(n,a.defaultOptions)}),n}setMutationDefaults(e,t){this.#r.set(ll(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(a=>{Ni(e,a.mutationKey)&&Object.assign(n,a.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Mf(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===jf&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};const D0=g.createContext(!1),mC=()=>g.useContext(D0);D0.Provider;function pC(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const fC=g.createContext(pC()),hC=()=>g.useContext(fC),gC=(e,t,n)=>{const a=n?.state.error&&typeof e.throwOnError=="function"?M0(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||a)&&(t.isReset()||(e.retryOnMount=!1))},vC=e=>{g.useEffect(()=>{e.clearReset()},[e])},bC=({result:e,errorResetBoundary:t,throwOnError:n,query:a,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&a&&(r&&e.data===void 0||M0(n,[e.error,a])),yC=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),a=e.staleTime;e.staleTime=typeof a=="function"?(...r)=>n(a(...r)):n(a),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},SC=(e,t)=>e?.suspense&&t.isPending,xC=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function kC(e,t,n){const a=mC(),r=hC(),i=R0(),s=i.defaultQueryOptions(e),l=i.getQueryCache().get(s.queryHash),m=e.subscribed!==!1;s._optimisticResults=a?"isRestoring":m?"optimistic":void 0,yC(s),gC(s,r,l),vC(r);const[u]=g.useState(()=>new t(i,s)),h=u.getOptimisticResult(s),b=!a&&m;if(g.useSyncExternalStore(g.useCallback(y=>{const w=b?u.subscribe(Rn.batchCalls(y)):Gn;return u.updateResult(),w},[u,b]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(s)},[s,u]),SC(s,h))throw xC(s,u,r);if(bC({result:h,errorResetBoundary:r,throwOnError:s.throwOnError,query:l,suspense:s.suspense}))throw h.error;return s.notifyOnChangeProps?h:u.trackResult(h)}function wC(e,t){return kC(e,rC)}function IC(){return new uC({defaultOptions:{queries:{staleTime:6e4,gcTime:15*6e4,retry:1,refetchOnWindowFocus:!1}}})}var Wg;function ve(e,t,n){function a(l,m){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:m,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,m);const u=s.prototype,h=Object.keys(u);for(let b=0;b<h.length;b++){const y=h[b];y in l||(l[y]=u[y].bind(l))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(l){var m;const u=n?.Parent?new i:this;a(u,l),(m=u._zod).deferred??(m.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class Ei extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class L0 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Wg=globalThis).__zod_globalConfig??(Wg.__zod_globalConfig={});const Df=globalThis.__zod_globalConfig;function Lo(e){return Df}function U0(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Ep(e,t){return typeof t=="bigint"?t.toString():t}function bd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Lf(e){return e==null}function Uf(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _C(e,t){const n=e/t,a=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-a)<r?0:n-a}const Gg=Symbol("evaluating");function Pt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Gg)return a===void 0&&(a=Gg,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Dr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function rr(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Zg(e){return JSON.stringify(e)}function CC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const z0="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const RC=bd(()=>{if(Df.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Di(e){if(cl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(cl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function H0(e){return Di(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const PC=new Set(["string","number","symbol"]);function Li(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ir(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function nt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function AC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const TC={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function EC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=rr(e._zod.def,{get shape(){const s={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(s[l]=n.shape[l])}return Dr(this,"shape",s),s},checks:[]});return ir(e,i)}function MC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=rr(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete s[l]}return Dr(this,"shape",s),s},checks:[]});return ir(e,i)}function jC(e,t){if(!Di(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=rr(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Dr(this,"shape",i),i}});return ir(e,r)}function OC(e,t){if(!Di(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=rr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Dr(this,"shape",a),a}});return ir(e,n)}function $C(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=rr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Dr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ir(e,n)}function NC(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=rr(t._zod.def,{get shape(){const l=t._zod.def.shape,m={...l};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(m[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)m[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return Dr(this,"shape",m),m},checks:[]});return ir(t,s)}function DC(e,t,n){const a=rr(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Dr(this,"shape",i),i}});return ir(t,a)}function ki(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function LC(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function wi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function hc(e){return typeof e=="string"?e:e?.message}function Uo(e,t,n){const a=e.message?e.message:hc(e.inst?._zod.def?.error?.(e))??hc(t?.error?.(e))??hc(n.customError?.(e))??hc(n.localeError?.(e))??"Invalid input",{inst:r,continue:i,input:s,...l}=e;return l.path??(l.path=[]),l.message=a,t?.reportInput&&(l.input=s),l}function zf(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function dl(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const q0=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ep,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},B0=ve("$ZodError",q0),F0=ve("$ZodError",q0,{Parent:Error});function UC(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function zC(e,t=n=>n.message){const n={_errors:[]},a=(r,i=[])=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(l=>a({issues:l},[...i,...s.path]));else if(s.code==="invalid_key")a({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")a({issues:s.issues},[...i,...s.path]);else{const l=[...i,...s.path];if(l.length===0)n._errors.push(t(s));else{let m=n,u=0;for(;u<l.length;){const h=l[u];u===l.length-1?(m[h]=m[h]||{_errors:[]},m[h]._errors.push(t(s))):m[h]=m[h]||{_errors:[]},m=m[h],u++}}}};return a(e),n}const Hf=e=>(t,n,a,r)=>{const i=a?{...a,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ei;if(s.issues.length){const l=new(r?.Err??e)(s.issues.map(m=>Uo(m,i,Lo())));throw z0(l,r?.callee),l}return s.value},qf=e=>async(t,n,a,r)=>{const i=a?{...a,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const l=new(r?.Err??e)(s.issues.map(m=>Uo(m,i,Lo())));throw z0(l,r?.callee),l}return s.value},yd=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Ei;return i.issues.length?{success:!1,error:new(e??B0)(i.issues.map(s=>Uo(s,r,Lo())))}:{success:!0,data:i.value}},HC=yd(F0),Sd=e=>async(t,n,a)=>{const r=a?{...a,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Uo(s,r,Lo())))}:{success:!0,data:i.value}},qC=Sd(F0),BC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return Hf(e)(t,n,r)},FC=e=>(t,n,a)=>Hf(e)(t,n,a),VC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return qf(e)(t,n,r)},KC=e=>async(t,n,a)=>qf(e)(t,n,a),WC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return yd(e)(t,n,r)},GC=e=>(t,n,a)=>yd(e)(t,n,a),ZC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return Sd(e)(t,n,r)},JC=e=>async(t,n,a)=>Sd(e)(t,n,a),YC=/^[cC][0-9a-z]{6,}$/,QC=/^[0-9a-z]+$/,XC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eR=/^[0-9a-vA-V]{20}$/,tR=/^[A-Za-z0-9]{27}$/,nR=/^[a-zA-Z0-9_-]{21}$/,aR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,oR=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Jg=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,rR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,iR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sR(){return new RegExp(iR,"u")}const lR=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,dR=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,uR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,V0=/^[A-Za-z0-9_-]*$/,pR=/^https?$/,fR=/^\+[1-9]\d{6,14}$/,K0="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",hR=new RegExp(`^${K0}$`);function W0(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function gR(e){return new RegExp(`^${W0(e)}$`)}function vR(e){const t=W0({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${K0}T(?:${a})$`)}const bR=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},yR=/^-?\d+$/,G0=/^-?\d+(?:\.\d+)?$/,SR=/^(?:true|false)$/i,xR=/^null$/i,kR=/^[^A-Z]*$/,wR=/^[^a-z]*$/,Xn=ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Z0={number:"number",bigint:"bigint",object:"date"},J0=ve("$ZodCheckLessThan",(e,t)=>{Xn.init(e,t);const n=Z0[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Y0=ve("$ZodCheckGreaterThan",(e,t)=>{Xn.init(e,t);const n=Z0[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),IR=ve("$ZodCheckMultipleOf",(e,t)=>{Xn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):_C(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),_R=ve("$ZodCheckNumberFormat",(e,t)=>{Xn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=TC[t.format];e._zod.onattach.push(s=>{const l=s._zod.bag;l.format=t.format,l.minimum=r,l.maximum=i,n&&(l.pattern=yR)}),e._zod.check=s=>{const l=s.value;if(n){if(!Number.isInteger(l)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}l<r&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),l>i&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),CR=ve("$ZodCheckMaxLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Lf(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const s=zf(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),RR=ve("$ZodCheckMinLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Lf(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const s=zf(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),PR=ve("$ZodCheckLengthEquals",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Lf(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const s=zf(r),l=i>t.length;a.issues.push({origin:s,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),xd=ve("$ZodCheckStringFormat",(e,t)=>{var n,a;Xn.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),AR=ve("$ZodCheckRegex",(e,t)=>{xd.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),TR=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kR),xd.init(e,t)}),ER=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wR),xd.init(e,t)}),MR=ve("$ZodCheckIncludes",(e,t)=>{Xn.init(e,t);const n=Li(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),jR=ve("$ZodCheckStartsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`^${Li(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),OR=ve("$ZodCheckEndsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`.*${Li(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),$R=ve("$ZodCheckOverwrite",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class NR{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
3
3
  `).filter(s=>s),r=Math.min(...a.map(s=>s.length-s.trimStart().length)),i=a.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
4
4
  `))}}const DR={major:4,minor:4,patch:3},Jt=ve("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=DR;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const r of a)for(const i of r._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(s,l,m)=>{let u=ki(s),h;for(const b of l){if(b._zod.def.when){if(LC(s)||!b._zod.def.when(s))continue}else if(u)continue;const y=s.issues.length,w=b._zod.check(s);if(w instanceof Promise&&m?.async===!1)throw new Ei;if(h||w instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await w,s.issues.length!==y&&(u||(u=ki(s,y)))});else{if(s.issues.length===y)continue;u||(u=ki(s,y))}}return h?h.then(()=>s):s},i=(s,l,m)=>{if(ki(s))return s.aborted=!0,s;const u=r(l,a,m);if(u instanceof Promise){if(m.async===!1)throw new Ei;return u.then(h=>e._zod.parse(h,m))}return e._zod.parse(u,m)};e._zod.run=(s,l)=>{if(l.skipChecks)return e._zod.parse(s,l);if(l.direction==="backward"){const u=e._zod.parse({value:s.value,issues:[]},{...l,skipChecks:!0});return u instanceof Promise?u.then(h=>i(h,s,l)):i(u,s,l)}const m=e._zod.parse(s,l);if(m instanceof Promise){if(l.async===!1)throw new Ei;return m.then(u=>r(u,a,l))}return r(m,a,l)}}Pt(e,"~standard",()=>({validate:r=>{try{const i=HC(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return qC(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Bf=ve("$ZodString",(e,t)=>{Jt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??bR(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),en=ve("$ZodStringFormat",(e,t)=>{xd.init(e,t),Bf.init(e,t)}),LR=ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=oR),en.init(e,t)}),UR=ve("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Jg(a))}else t.pattern??(t.pattern=Jg());en.init(e,t)}),zR=ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=rR),en.init(e,t)}),HR=ve("$ZodURL",(e,t)=>{en.init(e,t),e._zod.check=n=>{try{const a=n.value.trim();if(!t.normalize&&t.protocol?.source===pR.source&&!/^https?:\/\//i.test(a)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const r=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),qR=ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sR()),en.init(e,t)}),BR=ve("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nR),en.init(e,t)}),FR=ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=YC),en.init(e,t)}),VR=ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=QC),en.init(e,t)}),KR=ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=XC),en.init(e,t)}),WR=ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eR),en.init(e,t)}),GR=ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tR),en.init(e,t)}),ZR=ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=vR(t)),en.init(e,t)}),JR=ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=hR),en.init(e,t)}),YR=ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=gR(t)),en.init(e,t)}),QR=ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=aR),en.init(e,t)}),XR=ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=lR),en.init(e,t),e._zod.bag.format="ipv4"}),eP=ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cR),en.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),tP=ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=dR),en.init(e,t)}),nP=ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=uR),en.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[r,i]=a;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Q0(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const aP=ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=mR),en.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Q0(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function oP(e){if(!V0.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Q0(n)}const rP=ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=V0),en.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{oP(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),iP=ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=fR),en.init(e,t)});function sP(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const lP=ve("$ZodJWT",(e,t)=>{en.init(e,t),e._zod.check=n=>{sP(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),X0=ve("$ZodNumber",(e,t)=>{Jt.init(e,t),e._zod.pattern=e._zod.bag.pattern??G0,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),cP=ve("$ZodNumberFormat",(e,t)=>{_R.init(e,t),X0.init(e,t)}),dP=ve("$ZodBoolean",(e,t)=>{Jt.init(e,t),e._zod.pattern=SR,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),uP=ve("$ZodNull",(e,t)=>{Jt.init(e,t),e._zod.pattern=xR,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),mP=ve("$ZodUnknown",(e,t)=>{Jt.init(e,t),e._zod.parse=n=>n}),pP=ve("$ZodNever",(e,t)=>{Jt.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Yg(e,t,n){e.issues.length&&t.issues.push(...wi(n,e.issues)),t.value[n]=e.value}const fP=ve("$ZodArray",(e,t)=>{Jt.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const l=r[s],m=t.element._zod.run({value:l,issues:[]},a);m instanceof Promise?i.push(m.then(u=>Yg(u,n,s))):Yg(m,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function Jc(e,t,n,a,r,i){const s=n in a;if(e.issues.length){if(r&&i&&!s)return;t.issues.push(...wi(n,e.issues))}if(!s&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}function eS(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=AC(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function tS(e,t,n,a,r,i){const s=[],l=r.keySet,m=r.catchall._zod,u=m.def.type,h=m.optin==="optional",b=m.optout==="optional";for(const y in t){if(y==="__proto__"||l.has(y))continue;if(u==="never"){s.push(y);continue}const w=m.run({value:t[y],issues:[]},a);w instanceof Promise?e.push(w.then(_=>Jc(_,n,y,t,h,b))):Jc(w,n,y,t,h,b)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const hP=ve("$ZodObject",(e,t)=>{if(Jt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const m={...l};return Object.defineProperty(t,"shape",{value:m}),m}})}const a=bd(()=>eS(t));Pt(e._zod,"propValues",()=>{const l=t.shape,m={};for(const u in l){const h=l[u]._zod;if(h.values){m[u]??(m[u]=new Set);for(const b of h.values)m[u].add(b)}}return m});const r=cl,i=t.catchall;let s;e._zod.parse=(l,m)=>{s??(s=a.value);const u=l.value;if(!r(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const h=[],b=s.shape;for(const y of s.keys){const w=b[y],_=w._zod.optin==="optional",E=w._zod.optout==="optional",j=w._zod.run({value:u[y],issues:[]},m);j instanceof Promise?h.push(j.then(P=>Jc(P,l,y,u,_,E))):Jc(j,l,y,u,_,E)}return i?tS(h,u,l,m,a.value,e):h.length?Promise.all(h).then(()=>l):l}}),gP=ve("$ZodObjectJIT",(e,t)=>{hP.init(e,t);const n=e._zod.parse,a=bd(()=>eS(t)),r=y=>{const w=new NR(["shape","payload","ctx"]),_=a.value,E=$=>{const O=Zg($);return`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`};w.write("const input = payload.value;");const j=Object.create(null);let P=0;for(const $ of _.keys)j[$]=`key_${P++}`;w.write("const newResult = {};");for(const $ of _.keys){const O=j[$],k=Zg($),C=y[$],A=C?._zod?.optin==="optional",z=C?._zod?.optout==="optional";w.write(`const ${O} = ${E($)};`),A&&z?w.write(`
5
5
  if (${O}.issues.length) {
@@ -131,7 +131,7 @@ Surface risks, constraints, and verification steps.`}],sh=o().trim().min(1).max(
131
131
 
132
132
  `)}}!a?.aborted&&s.trim()&&Ob(s,t,n)}function b1(e){if(!e.ok)throw new Error(`event stream failed: ${e.status} ${e.statusText||"HTTP error"}`);if(!e.body)throw new Error("event stream did not return a response body")}function NB(e,t,n,a,r={}){const i=new AbortController,s=r.fetchImpl??fetch,l=r.reconnectDelayMs??OB;let m=jb(r.afterSequence),u=!1;return(async()=>{let h=0;for(;!i.signal.aborted;)try{const b=jB(e,i.signal,m),y=await s(b.url,b.init);if(b1(y),u=!0,h=0,await $B(y,w=>{const _=jb(w.sequence);_>0&&_<=m||(_>0&&(m=_),t(w))},a,i.signal),u=!1,i.signal.aborted)break;throw new Error("event stream ended")}catch(b){if(u=!1,i.signal.aborted)break;n(b),await DB(l(h),i.signal),h+=1}})().catch(()=>{}),{close(){i.abort()},isOpen(){return u}}}function jb(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?e:0}function Ob(e,t,n){let a="message";const r=[];for(const i of e.split(`
133
133
  `))i.startsWith(":")||(i.startsWith("event: ")&&(a=i.slice(7).trim()),i.startsWith("data: ")&&r.push(i.slice(6)));if(a==="ready"){n?.();return}if(!(a!=="runtime"||r.length===0))try{t(JSON.parse(r.join(`
134
- `)))}catch{}}async function DB(e,t){e<=0||t.aborted||await new Promise(n=>{const a=globalThis.setTimeout(n,e);t.addEventListener("abort",()=>{globalThis.clearTimeout(a),n()},{once:!0})})}class LB extends Error{constructor(t,n){super(t),this.status=n,this.name="ApiRequestError"}status}function $b(e={}){const t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),t}const Nb=new WeakMap,Db=new WeakMap,kc=new WeakMap;let UB=0;async function q(e,t,n){if(t==="/v1/preferences"&&typeof n?.body=="string"){const r=(kc.get(e)??Promise.resolve()).catch(()=>{}).then(()=>Lb(e,t,n));kc.set(e,r);try{return await r}finally{kc.get(e)===r&&kc.delete(e)}}return Lb(e,t,n)}async function Lb(e,t,n){const a=++UB;if(t==="/v1/preferences"&&typeof n?.body=="string"){const m=Nb.get(e);if(!m)throw new Error("Reload settings before saving so changes can be checked against the current file.");n={...n,body:JSON.stringify({expectedRevision:m,...JSON.parse(n.body)})}}const r=new Headers(n?.headers);r.set("Content-Type","application/json"),r.set("Authorization",`Bearer ${e.token}`);const i=await fetch(`${e.serverUrl}${t}`,{...n,headers:r});if(!i.ok){const m=await i.json().catch(()=>({})),u=m&&typeof m=="object"&&"error"in m?String(m.error):i.statusText;throw new LB(u,i.status)}const s=await i.json(),l=s?.configuration?.rawRevision??(t==="/v1/preferences"?s?.rawRevision:void 0);return typeof l=="string"&&a>=(Db.get(e)??0)&&(Nb.set(e,l),Db.set(e,a)),s}function JZ(e){const t=new URL("/v1/terminal",e.serverUrl);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.toString()}function YZ(e){return["openpond-terminal",`openpond-token.${HB(e.token)}`]}function zB(e){const t=new TextEncoder().encode(e);let n="";for(let a=0;a<t.length;a+=32768){const r=t.subarray(a,a+32768);n+=String.fromCharCode(...r)}return btoa(n)}function HB(e){return zB(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function qB(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return new TextDecoder().decode(n)}const BB={teamInvitations:e=>q(e,"/v1/team-invitations"),decideTeamInvitation:(e,t,n)=>q(e,`/v1/team-invitations/${t}`,{method:"POST",body:JSON.stringify({token:n})}),organizations:e=>q(e,"/v1/organizations"),createOrganization:(e,t)=>q(e,"/v1/organizations",{method:"POST",body:JSON.stringify(t)}),updateOrganization:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),organizationMembers:(e,t)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/members`),upsertOrganizationMember:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify(n)}),organizationMcpServer:(e,t)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`),generateOrganizationMcpServer:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`,{method:"POST",body:JSON.stringify(n)}),setOrganizationMcpServerStatus:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server/${n}`,{method:"POST"})},FB={taskInbox:(e,t)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/inbox`),steerTurn:(e,t,n)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/turns/steer`,{method:"POST",body:JSON.stringify(n)}),queueTaskInput:(e,t,n,a)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/inbox`,{method:"POST",body:JSON.stringify({input:n,idempotencyKey:a})}),updateTaskInput:(e,t,n,a)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/inbox/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)}),sendTurn:(e,t,n)=>q(e,`/v1/sessions/${t}/turns`,{method:"POST",body:JSON.stringify(n)}),runSessionCommand:(e,t,n)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/commands`,{method:"POST",body:JSON.stringify(n)}),recordPreflightTurnFailure:(e,t,n)=>q(e,`/v1/sessions/${t}/preflight-turns/failure`,{method:"POST",body:JSON.stringify(n)}),listCreateImproveRuns:(e,t={})=>q(e,`/v1/create-improve-runs?${VB(t).toString()}`),getCreateImproveRun:(e,t)=>q(e,`/v1/create-improve-runs/${encodeURIComponent(t)}`),getCreateImproveCandidateDiff:(e,t,n)=>q(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/candidates/${encodeURIComponent(n)}/diff`),applyCreateImproveAction:(e,t,n)=>q(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/actions`,{method:"POST",body:JSON.stringify(n)}),interruptTurn:(e,t,n)=>q(e,`/v1/sessions/${t}/turns/interrupt`,{method:"POST",body:JSON.stringify({reason:n})}),compactSession:(e,t,n={reason:"manual"})=>q(e,`/v1/sessions/${t}/compact`,{method:"POST",body:JSON.stringify(n)}),workspaceTool:(e,t,n)=>q(e,`/v1/sessions/${t}/workspace-tools`,{method:"POST",body:JSON.stringify(n)}),ensureCloudWorkspaceReady:(e,t,n)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/workspace/ensure-ready`,{method:"POST",body:JSON.stringify(n)})};function VB(e){const t=new URLSearchParams;return e.profileId&&t.set("profileId",e.profileId),e.conversationId&&t.set("conversationId",e.conversationId),e.targetKind&&t.set("targetKind",e.targetKind),e.targetId&&t.set("targetId",e.targetId),e.limit&&t.set("limit",String(e.limit)),t}const KB={sandboxFiles:(e,t,n={})=>{const a=new URLSearchParams({list:"1"});return n.path&&a.set("path",n.path),n.recursive!==void 0&&a.set("recursive",String(n.recursive)),n.maxEntries!==void 0&&a.set("maxEntries",String(n.maxEntries)),q(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${a.toString()}`)},sandboxUploadFile:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/files`,{method:"POST",body:JSON.stringify(n)}),preserveSandboxSource:(e,t,n={})=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/preserve-source`,{method:"POST",body:JSON.stringify(n)}),sandboxDownloadFile:async(e,t,n,a={})=>{const r=new URLSearchParams({path:n});a.offsetBytes!==void 0&&r.set("offsetBytes",String(a.offsetBytes)),a.maxBytes!==void 0&&r.set("maxBytes",String(a.maxBytes));const i=await q(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${r.toString()}`);return{...i,contents:i.file.isBinary?"":qB(i.file.contentsBase64)}}},WB={sandboxGitStatus:(e,t)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/status`),sandboxGitDiff:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/diff`,{method:"POST",body:JSON.stringify(n)})},GB={connectedAppStatus:(e,t={})=>{const n=$b(t);return n.set("status",t.status??"all"),q(e,`/v1/connected-apps/status${n.size>0?`?${n.toString()}`:""}`)},integrationConnections:(e,t={})=>{const n=$b(t);return t.status&&n.set("status",t.status),q(e,`/v1/integrations/connections${n.size>0?`?${n.toString()}`:""}`)},sandboxIntegrationLeases:(e,t)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`),attachSandboxIntegrationConnection:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"POST",body:JSON.stringify(n)}),removeSandboxIntegrationLease:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:n})})},ZB={listSandboxProjects:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return q(e,`/v1/sandbox-projects?${n.toString()}`)},getSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`)},getSandboxProjectWorkspace:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/workspace?${a.toString()}`)},upsertSandboxProject:(e,t)=>q(e,"/v1/sandbox-projects",{method:"POST",body:JSON.stringify(t)}),syncSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/sync?${a.toString()}`,{method:"POST"})},uploadSandboxProjectSource:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId}),{teamId:r,...i}=n;return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/source?${a.toString()}`,{method:"POST",body:JSON.stringify(i)})},archiveSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`,{method:"DELETE"})},listSandboxAgents:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return q(e,`/v1/sandbox-agents?${n.toString()}`)},upsertSandboxAgent:(e,t)=>q(e,"/v1/sandbox-agents",{method:"POST",body:JSON.stringify(t)}),runSandboxAgent:(e,t,n)=>q(e,`/v1/sandbox-agents/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n)}),runProfileAction:(e,t)=>q(e,"/v1/profile/run",{method:"POST",body:JSON.stringify(t)})},JB={sandbox:(e,t)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}`)},YB={...GB,...ZB,...JB,...WB,...KB},QB={communities:(e,t)=>{const n=new URLSearchParams;return t&&n.set("cursor",t),q(e,`/v1/communities${n.size?`?${n}`:""}`)},communityPreview:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/preview`),communityRules:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/rules/current`),joinCommunity:(e,t,n)=>q(e,`/v1/communities/${encodeURIComponent(t)}/join`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),acceptCommunityRules:(e,t,n)=>q(e,`/v1/communities/${encodeURIComponent(t)}/rules/accept`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),leaveCommunity:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/leave`,{method:"POST",body:"{}"}),communityChannels:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels`),communityMessages:(e,t,n,a={})=>{const r=new URLSearchParams;return a.beforeSequence!=null&&r.set("beforeSequence",String(a.beforeSequence)),a.limit!=null&&r.set("limit",String(a.limit)),q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages${r.size?`?${r}`:""}`)},sendCommunityMessage:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify(a)}),editCommunityMessage:(e,t,n,a,r)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({body:r})}),deleteCommunityMessage:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"DELETE",body:"{}"}),markCommunityRead:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/read`,{method:"POST",body:JSON.stringify({sequence:a})}),setCommunityChannelMuted:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/mute`,{method:"POST",body:JSON.stringify({muted:a})}),searchCommunityMembers:(e,t,n={})=>{const a=new URLSearchParams;return n.query&&a.set("query",n.query),n.cursor&&a.set("cursor",n.cursor),n.limit!=null&&a.set("limit",String(n.limit)),q(e,`/v1/communities/${encodeURIComponent(t)}/members/search${a.size?`?${a}`:""}`)},updateCommunityNotifications:(e,t,n)=>q(e,`/v1/communities/${encodeURIComponent(t)}/notifications`,{method:"POST",body:JSON.stringify({mode:n})}),communityEvents:(e,t,n={})=>{const a=new URLSearchParams;return n.after!=null&&a.set("after",String(n.after)),n.limit!=null&&a.set("limit",String(n.limit)),q(e,`/v1/communities/${encodeURIComponent(t)}/events${a.size?`?${a}`:""}`)},communityRealtimeSession:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/realtime-session`),uploadCommunityAttachment:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/upload`,{method:"POST",body:JSON.stringify({attachment:a})}),communityAttachmentDownload:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/${encodeURIComponent(a)}/download`)},eg="openpond-app-server-url",Sl="openpond-app-token",XB=750;function y1(){return window.location.protocol!=="http:"&&window.location.protocol!=="https:"?null:window.location.origin&&window.location.origin!=="null"?window.location.origin:null}function ef(e){const t=e.getItem(eg)?.trim(),n=e.getItem(Sl)?.trim();return t&&n?{serverUrl:t,token:n}:null}function id(e){if(!e)return null;try{const t="__openpond_storage_probe__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}function gi(e,t){e.setItem(eg,t.serverUrl),e.setItem(Sl,t.token)}function Ub(e,t){const n=ef(e);n?.serverUrl!==t.serverUrl||n.token!==t.token||(e.removeItem(eg),e.removeItem(Sl))}function eF(){const e=window.__OPENPOND_WEB_CONNECTION__,t=e?.serverUrl?.trim(),n=e?.token?.trim();return t&&n?{serverUrl:t,token:n}:null}function tF(){const e=window.location.hash.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!e)return null;const t=new URLSearchParams(e),n=t.get("openpondToken")?.trim(),a=t.get("openpondServerUrl")?.trim()||y1();return!a||!n?null:{serverUrl:a,token:n}}function nF(){window.location.hash&&window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`)}function wc(e,t){t&&(e.some(n=>n.serverUrl===t.serverUrl&&n.token===t.token)||e.push(t))}function aF(){const e=[],t=id(window.sessionStorage),n=id(window.localStorage),a=y1(),r=t?.getItem(Sl)??n?.getItem(Sl);return wc(e,null),wc(e,a&&r?{serverUrl:a,token:r.trim()}:null),wc(e,t?ef(t):null),wc(e,n?ef(n):null),e}async function Zm(e){const t=new AbortController,n=window.setTimeout(()=>t.abort(),XB);try{const a=await fetch(`${e}/health`,{signal:t.signal}),r=await a.json().catch(()=>null);return a.ok&&r?.server==="openpond-app-server"}catch{return!1}finally{window.clearTimeout(n)}}async function oF(){if(window.openpond)return window.openpond.getConnection();const e=id(window.sessionStorage),t=id(window.localStorage),n=tF();if(n&&await Zm(n.serverUrl))return t&&gi(t,n),e&&gi(e,n),nF(),{...n,platform:navigator.platform};const a=eF();if(a&&await Zm(a.serverUrl))return t&&gi(t,a),e&&gi(e,a),{...a,platform:navigator.platform};const r=aF();for(const i of r){if(await Zm(i.serverUrl))return t&&gi(t,i),e&&gi(e,i),{...i,platform:navigator.platform};e&&Ub(e,i),t&&Ub(t,i)}throw new Error("No reachable OpenPond app server. Start `openpond ui` again and open the full printed URL.")}const J={...QB,bootstrap:e=>q(e,"/v1/bootstrap?refreshCodex=1"),localProjectActions:(e,t)=>q(e,`/v1/projects/${encodeURIComponent(t)}/actions`),extensionCatalog:e=>q(e,"/v1/extensions"),extensionPreview:(e,t)=>q(e,"/v1/extensions/preview",{method:"POST",body:JSON.stringify(t)}),extensionAdd:(e,t)=>q(e,"/v1/extensions",{method:"POST",body:JSON.stringify(t)}),extensionUpdate:(e,t,n={})=>q(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}/update`,{method:"POST",body:JSON.stringify(n)}),extensionUpdateAll:e=>q(e,"/v1/extensions/update-all",{method:"POST"}),extensionRemove:(e,t)=>q(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}`,{method:"DELETE"}),skillSourceFile:(e,t,n,a)=>q(e,`/v1/skills/${t}/${encodeURIComponent(n)}/source?path=${encodeURIComponent(a)}`),teamChatMembers:(e,t)=>q(e,`/v1/team-chat/members?teamId=${encodeURIComponent(t)}`),teamChatAgents:(e,t)=>q(e,`/v1/team-chat/agents?teamId=${encodeURIComponent(t)}`),teamChatThreads:(e,t)=>q(e,`/v1/team-chat/threads?teamId=${encodeURIComponent(t)}`),teamChatRealtimeSession:(e,t)=>q(e,`/v1/team-chat/realtime-session?teamId=${encodeURIComponent(t)}`),teamChatEvents:(e,t,n={})=>{const a=new URLSearchParams({teamId:t});return n.after!=null&&a.set("after",String(n.after)),n.limit!=null&&a.set("limit",String(n.limit)),q(e,`/v1/team-chat/events?${a.toString()}`)},teamChatGeneral:(e,t)=>q(e,"/v1/team-chat/threads/general",{method:"POST",body:JSON.stringify({teamId:t})}),teamChatDm:(e,t,n)=>q(e,"/v1/team-chat/threads/dm",{method:"POST",body:JSON.stringify({teamId:t,otherUserId:n})}),teamChatThread:(e,t,n,a={})=>{const r=new URLSearchParams({teamId:t});return a.beforeSequence!=null&&r.set("beforeSequence",String(a.beforeSequence)),a.limit!=null&&r.set("limit",String(a.limit)),q(e,`/v1/team-chat/threads/${encodeURIComponent(n)}?${r.toString()}`)},uploadTeamChatAttachment:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/attachments/upload`,{method:"POST",body:JSON.stringify(n)}),teamChatAttachmentDownload:(e,t,n)=>q(e,`/v1/team-chat/attachments/${encodeURIComponent(n)}/download?teamId=${encodeURIComponent(t)}`),sendTeamChatMessage:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:JSON.stringify(n)}),createTeamChatAgentRun:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/agent-runs`,{method:"POST",body:JSON.stringify(n)}),teamChatAgentConversation:(e,t,n)=>q(e,`/v1/team-chat/agent-runs/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),editTeamChatMessage:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)}),deleteTeamChatMessage:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"DELETE",body:JSON.stringify({teamId:a})}),markTeamChatRead:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/read`,{method:"POST",body:JSON.stringify({teamId:n,sequence:a})}),setTeamChatThreadMuted:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/mute`,{method:"POST",body:JSON.stringify({teamId:n,muted:a})}),createTeamChatAiThread:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/ai-threads`,{method:"POST",body:JSON.stringify(n)}),teamChatAiThread:(e,t,n)=>q(e,`/v1/team-chat/ai-threads/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),sendTeamChatAiTurn:(e,t,n)=>q(e,`/v1/team-chat/ai-threads/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),executeTeamChatAiTurn:(e,t,n)=>q(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute`,{method:"POST",body:JSON.stringify({teamId:n})}),cancelTeamChatAiTurnExecution:(e,t,n)=>q(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute/cancel`,{method:"POST",body:JSON.stringify({teamId:n})}),usage:(e,t={})=>{const n=zb(t),a=n.size?`?${n.toString()}`:"";return q(e,`/v1/usage${a}`)},usageRecords:(e,t={})=>{const n=zb(t);t.sessionId&&n.set("sessionId",t.sessionId),t.turnId&&n.set("turnId",t.turnId),t.limit!==void 0&&n.set("limit",String(t.limit));const a=n.size?`?${n.toString()}`:"";return q(e,`/v1/usage/records${a}`)},usageTurnCache:(e,t)=>q(e,`/v1/usage/turn-cache?sessionId=${encodeURIComponent(t)}`),runtimeEventsPage:(e,t={})=>{const n=new URLSearchParams;t.sessionId&&n.set("sessionId",t.sessionId),t.afterSequence!==void 0&&n.set("afterSequence",String(t.afterSequence)),t.beforeSequence!==void 0&&t.beforeSequence!==null&&n.set("beforeSequence",String(t.beforeSequence)),t.limit!==void 0&&n.set("limit",String(t.limit));const a=n.size?`?${n.toString()}`:"";return q(e,`/v1/events/page${a}`)},workOutputs:e=>q(e,"/v1/work/outputs"),harnessHistory:e=>q(e,"/v1/harness"),refinerHistory:e=>q(e,"/v1/refiner"),updateRefinerProfile:(e,t)=>q(e,"/v1/refiner/update",{method:"POST",body:JSON.stringify(t)}),activateRefinerRelease:(e,t)=>q(e,"/v1/refiner/activate",{method:"POST",body:JSON.stringify(t)}),rollbackRefinerRelease:(e,t)=>q(e,"/v1/refiner/rollback",{method:"POST",body:JSON.stringify(t)}),updateHarnessBackgroundReview:(e,t)=>q(e,"/v1/harness/background-review",{method:"POST",body:JSON.stringify(t)}),reviewHarnessEvaluation:(e,t)=>q(e,"/v1/harness/evaluation-review",{method:"POST",body:JSON.stringify(t)}),updateHarnessEvaluationReviewSchedule:(e,t)=>q(e,"/v1/harness/evaluation-review/settings",{method:"POST",body:JSON.stringify(t)}),harnessReleaseDiff:(e,t)=>q(e,"/v1/harness/diff",{method:"POST",body:JSON.stringify(t)}),rollbackHarness:(e,t)=>q(e,"/v1/harness/rollback",{method:"POST",body:JSON.stringify(t)}),reviewHarnessProposal:(e,t)=>q(e,"/v1/harness/review",{method:"POST",body:JSON.stringify(t)}),runSubagentLifecycleAction:(e,t,n)=>q(e,`/v1/subagents/${encodeURIComponent(t)}/lifecycle`,{method:"POST",body:JSON.stringify(n)}),trainingState:(e,t)=>q(e,`/v1/training?profileId=${encodeURIComponent(t)}`),trainingActivity:(e,t)=>q(e,`/v1/training/activity?profileId=${encodeURIComponent(t)}`),portableTrainingCatalog:(e,t="",n)=>{const a=new URLSearchParams;return t.trim()&&a.set("query",t.trim()),n&&a.set("method",n),q(e,`/v1/training/catalog${a.size?`?${a.toString()}`:""}`)},datasetCatalog:(e,t)=>q(e,`/v1/training/datasets?profileId=${encodeURIComponent(t)}`),trainingRunDetail:(e,t,n={})=>q(e,`/v1/training/jobs/${encodeURIComponent(t)}/detail?evaluation=${n.includeEvaluation===!1?"false":"true"}`),candidateReview:(e,t,n=!1,a="models")=>q(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision?refresh=${n}`),recordCandidateReview:(e,t,n,a="models")=>q(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision`,{method:"POST",body:JSON.stringify(n)}),candidateReviewHistory:(e,t,n,a="models")=>q(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision-history?decisionId=${encodeURIComponent(n.id)}&decisionHash=${n.contentHash}`),trainingEvaluationTasks:async(e,t,n,a)=>{const r=new URLSearchParams({limit:"25"});return a&&r.set("cursor",a),q(e,`/v1/training/jobs/${encodeURIComponent(t)}/evaluations/${encodeURIComponent(n.id)}/tasks?${r}`)},trainingRequest:(e,t,n,a="POST")=>q(e,`/v1/training${t}`,{method:a,body:a==="GET"||a==="DELETE"?void 0:JSON.stringify(n)}),datasetStorageState:e=>q(e,"/v1/settings/dataset-storage"),updateDatasetStorage:(e,t)=>q(e,"/v1/settings/dataset-storage",{method:"PATCH",body:JSON.stringify({datasetStorePath:t})}),hostedSavedWork:e=>q(e,"/v1/saved-work"),createHostedSavedWork:(e,t)=>q(e,"/v1/saved-work",{method:"POST",body:JSON.stringify(t)}),updateHostedSavedWork:(e,t,n)=>q(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteHostedSavedWork:(e,t)=>q(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"DELETE"}),runHostedSavedWork:(e,t,n)=>q(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({clientRequestId:n})}),chatWorkflows:(e,t)=>{const n=t?`?sessionId=${encodeURIComponent(t)}`:"";return q(e,`/v1/chat-workflows${n}`)},createChatWorkflow:(e,t)=>q(e,"/v1/chat-workflows",{method:"POST",body:JSON.stringify(t)}),updateChatWorkflow:(e,t,n)=>q(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteChatWorkflow:(e,t)=>q(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),runChatWorkflow:(e,t)=>q(e,`/v1/chat-workflows/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({})}),localAgentSchedules:(e,t={})=>{const n=new URLSearchParams;t.localProjectId&&n.set("localProjectId",t.localProjectId);const a=n.size?`?${n.toString()}`:"";return q(e,`/v1/local-agent-schedules${a}`)},syncLocalAgentSchedules:e=>q(e,"/v1/local-agent-schedules/sync",{method:"POST",body:JSON.stringify({})}),patchLocalAgentSchedule:(e,t,n)=>q(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),runLocalAgentSchedule:(e,t,n={})=>q(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n)}),localAgentScheduleRuns:(e,t,n={})=>{const a=new URLSearchParams;n.limit!==void 0&&a.set("limit",String(n.limit));const r=a.size?`?${a.toString()}`:"";return q(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}/runs${r}`)},refreshOpenPondAccounts:e=>q(e,"/v1/openpond/accounts/refresh",{method:"POST",body:JSON.stringify({})}),refreshOpenPondAccount:e=>q(e,"/v1/openpond/account?refresh=1"),loadMoreOpenPondApps:(e,t)=>q(e,`/v1/openpond/apps/more?offset=${encodeURIComponent(String(t.offset))}&limit=${encodeURIComponent(String(t.limit))}`),switchOpenPondAccount:(e,t)=>q(e,"/v1/openpond/accounts/switch",{method:"POST",body:JSON.stringify(t)}),removeOpenPondAccount:(e,t)=>q(e,"/v1/openpond/accounts",{method:"DELETE",body:JSON.stringify(t)}),signOutOpenPondAccount:e=>q(e,"/v1/openpond/accounts/logout",{method:"POST",body:JSON.stringify({})}),saveOpenPondAccount:(e,t)=>q(e,"/v1/openpond/accounts/login",{method:"POST",body:JSON.stringify(t)}),updateOpenPondAccountConfig:(e,t)=>q(e,"/v1/openpond/accounts/config",{method:"PATCH",body:JSON.stringify(t)}),savePreferences:(e,t)=>q(e,"/v1/preferences",{method:"PATCH",body:JSON.stringify(t)}),saveProviderSettings:(e,t)=>q(e,"/v1/providers",{method:"PATCH",body:JSON.stringify(t)}),providerSettings:e=>q(e,"/v1/providers"),loadProviderModels:(e,t,n={})=>{const a=new URLSearchParams;n.query?.trim()&&a.set("query",n.query.trim()),n.limit&&a.set("limit",String(n.limit));const r=a.size?`?${a.toString()}`:"";return q(e,`/v1/providers/${encodeURIComponent(t)}/models${r}`)},refreshProviderModels:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/models`,{method:"POST",body:JSON.stringify(n)}),saveProviderCredential:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"PUT",body:JSON.stringify(n)}),deleteProviderCredential:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"DELETE",body:JSON.stringify(n)}),startOpenAiSubscriptionAuth:(e,t)=>q(e,"/v1/providers/openai/subscription-auth",{method:"POST",body:JSON.stringify(t)}),validateProviderCredential:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(n)}),savePersonalization:(e,t)=>q(e,"/v1/personalization",{method:"PATCH",body:JSON.stringify(t)}),recordClientDiagnostic:(e,t)=>q(e,"/v1/diagnostics/client",{method:"POST",body:JSON.stringify(t)}),profileCurrent:e=>q(e,"/v1/profile"),profileCatalog:e=>q(e,"/v1/profile/catalog"),profileWorkflows:e=>q(e,"/v1/profile/workflows"),profileEvaluations:e=>q(e,"/v1/profile/evaluations"),profileEvaluationPrepare:(e,t)=>q(e,"/v1/profile/evaluations/prepare",{method:"POST",body:JSON.stringify(t)}),profileEvaluationRun:(e,t)=>q(e,"/v1/profile/evaluations/run",{method:"POST",body:JSON.stringify(t)}),profileEvaluationRunSuite:(e,t)=>q(e,"/v1/profile/evaluations/run-suite",{method:"POST",body:JSON.stringify(t)}),profileEvaluationCompare:(e,t)=>q(e,"/v1/profile/evaluations/compare",{method:"POST",body:JSON.stringify({id:`comparison-${crypto.randomUUID()}`,runIds:t})}),profileSelect:(e,t)=>q(e,"/v1/profile/select",{method:"POST",body:JSON.stringify({ref:t})}),profileRemove:(e,t)=>q(e,"/v1/profile/remove",{method:"POST",body:JSON.stringify({ref:t})}),profilePublicationPreview:(e,t)=>q(e,"/v1/profile/publication/preview",{method:"POST",body:JSON.stringify(t)}),profilePublicationPublish:(e,t)=>q(e,"/v1/profile/publication/publish",{method:"POST",body:JSON.stringify(t)}),profileInstall:(e,t)=>q(e,"/v1/profile/install",{method:"POST",body:JSON.stringify(t)}),profileUpdate:(e,t)=>q(e,"/v1/profile/update",{method:"POST",body:JSON.stringify({ref:t})}),profileInit:(e,t)=>q(e,"/v1/profile/init",{method:"POST",body:JSON.stringify(t)}),profileLoad:(e,t)=>q(e,"/v1/profile/load",{method:"POST",body:JSON.stringify(t)}),profileCheck:(e,t)=>q(e,"/v1/profile/check",{method:"POST",body:JSON.stringify(t)}),profileAgentRename:(e,t,n)=>q(e,`/v1/profile/agents/${encodeURIComponent(t)}/name`,{method:"PATCH",body:JSON.stringify(n)}),profileCommit:(e,t)=>q(e,"/v1/profile/commit",{method:"POST",body:JSON.stringify(t)}),profilePush:(e,t)=>q(e,"/v1/profile/push",{method:"POST",body:JSON.stringify(t)}),workspaceLspSettingsStatus:e=>q(e,"/v1/lsp/settings-status"),workspaceLspRuntimeStatus:e=>q(e,"/v1/lsp/status"),restartWorkspaceLsp:e=>q(e,"/v1/lsp/restart",{method:"POST"}),remoteAccess:e=>q(e,"/v1/remote-access"),enableRemoteAccess:e=>q(e,"/v1/remote-access/enable",{method:"POST"}),disableRemoteAccess:e=>q(e,"/v1/remote-access/disable",{method:"POST"}),voiceTranscriptionStatus:(e,t={})=>q(e,"/v1/audio/transcriptions/status",{signal:t.signal}),transcribeVoice:(e,t,n={})=>q(e,"/v1/audio/transcriptions",{method:"POST",body:JSON.stringify(t),signal:n.signal}),createSession:(e,t)=>q(e,"/v1/sessions",{method:"POST",body:JSON.stringify(t)}),patchSession:(e,t,n)=>q(e,`/v1/sessions/${t}`,{method:"PATCH",body:JSON.stringify(n)}),codexHistoryThread:(e,t,n={})=>{const a=new URLSearchParams;n.limit!==void 0&&a.set("limit",String(n.limit)),n.tail&&a.set("tail","1");const r=a.size?`?${a.toString()}`:"";return q(e,`/v1/codex-history/${encodeURIComponent(t)}${r}`)},codexHistoryThreadIncremental:(e,t,n={})=>{const a=new URLSearchParams({incremental:"1"});return n.afterEventId&&a.set("afterEventId",n.afterEventId),n.limit!==void 0&&a.set("limit",String(n.limit)),n.revision&&a.set("revision",n.revision),n.tail&&a.set("tail","1"),q(e,`/v1/codex-history/${encodeURIComponent(t)}?${a.toString()}`)},sendCodexHistoryTurn:(e,t,n)=>q(e,`/v1/codex-history/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),interruptCodexHistoryTurn:(e,t)=>q(e,`/v1/codex-history/${encodeURIComponent(t)}/turns/interrupt`,{method:"POST"}),patchSidebarAppPreference:(e,t,n)=>q(e,`/v1/sidebar/apps/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),reorderSidebarApps:(e,t)=>q(e,"/v1/sidebar/apps/reorder",{method:"POST",body:JSON.stringify(t)}),sidebarFiles:e=>q(e,"/v1/sidebar/files"),patchSidebarFile:(e,t)=>q(e,"/v1/sidebar/files",{method:"PATCH",body:JSON.stringify(t)}),workspaceStatus:(e,t,n=!1,a={})=>q(e,`/v1/workspaces/${encodeURIComponent(t)}${n?"?ensure=1":""}`,{signal:a.signal}),createWorkspaceBranch:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/branches`,{method:"POST",body:JSON.stringify(n)}),checkoutWorkspaceBranch:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/branch`,{method:"PATCH",body:JSON.stringify(n)}),workspaceDiff:(e,t,n={})=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/diff`,{signal:n.signal}),workspaceFile:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`),saveWorkspaceFile:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/file`,{method:"PATCH",body:JSON.stringify(n)}),signWorkspaceImageUrl:(e,t)=>q(e,"/v1/assets/workspace-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalImageUrl:(e,t)=>q(e,"/v1/assets/local-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalVideoUrl:(e,t)=>q(e,"/v1/assets/local-video-url",{method:"POST",body:JSON.stringify(t)}),signChatAttachmentImageUrl:(e,t)=>q(e,"/v1/assets/chat-attachment-image-url",{method:"POST",body:JSON.stringify(t)}),chatAttachmentFile:(e,t)=>q(e,"/v1/assets/chat-attachment-file",{method:"POST",body:JSON.stringify(t)}),workspaceLspTouch:(e,t,n,a={})=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/touch`,{method:"POST",body:JSON.stringify(n),signal:a.signal}),workspaceLspAction:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/action`,{method:"POST",body:JSON.stringify(n)}),workspaceTemplateConfig:(e,t)=>q(e,`/v1/openpond/apps/${encodeURIComponent(t)}/template-config`),...BB,...YB,createLocalProject:(e,t)=>q(e,"/v1/projects",{method:"POST",body:JSON.stringify(t)}),updateLocalProjectAgentSetup:(e,t,n)=>q(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),uploadLocalProjectCloudSource:(e,t,n)=>q(e,`/v1/projects/${encodeURIComponent(t)}/cloud-source`,{method:"POST",body:JSON.stringify(n)}),previewLocalProjectCloudSource:(e,t,n={})=>{const a=new URLSearchParams;n.branch?.trim()&&a.set("branch",n.branch.trim());const r=a.toString()?`?${a.toString()}`:"";return q(e,`/v1/projects/${encodeURIComponent(t)}/cloud-source/preview${r}`)},deleteLocalProject:(e,t)=>q(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"DELETE"}),gitAvailability:e=>q(e,"/v1/system/git"),installMacOSCommandLineTools:e=>q(e,"/v1/system/git/install-command-line-tools",{method:"POST",body:JSON.stringify({})}),...FB,resolveApproval:(e,t,n)=>q(e,`/v1/approvals/${t}`,{method:"POST",body:JSON.stringify(n)})};function zb(e){const t=new URLSearchParams;return e.range&&t.set("range",e.range),e.visibility&&t.set("visibility",e.visibility),e.status&&t.set("status",e.status),e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),t}const rF=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),iF=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),Hb=e=>{const t=iF(e);return t.charAt(0).toUpperCase()+t.slice(1)},S1=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),sF=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var lF={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const cF=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...l},m)=>g.createElement("svg",{ref:m,...lF,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:S1("lucide",r),...!i&&!sF(l)&&{"aria-hidden":"true"},...l},[...s.map(([u,h])=>g.createElement(u,h)),...Array.isArray(i)?i:[i]]));const dt=(e,t)=>{const n=g.forwardRef(({className:a,...r},i)=>g.createElement(cF,{ref:i,iconNode:t,className:S1(`lucide-${rF(Hb(e))}`,`lucide-${e}`,a),...r}));return n.displayName=Hb(e),n};const dF=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],uF=dt("activity",dF);const mF=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],pF=dt("archive-restore",mF);const fF=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],hF=dt("arrow-left",fF);const gF=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],x1=dt("bookmark",gF);const vF=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]],k1=dt("bookmark-x",vF);const bF=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]],qb=dt("book-open-text",bF);const yF=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],Jm=dt("boxes",yF);const SF=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],xF=dt("calendar-clock",SF);const kF=[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]],w1=dt("chart-column-stacked",kF);const wF=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wo=dt("check",wF);const IF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],tf=dt("circle-check",IF);const _F=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],zo=dt("chevron-down",_F);const CF=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$r=dt("chevron-right",CF);const RF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],PF=dt("circle-alert",RF);const AF=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Jd=dt("cloud",AF);const TF=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],EF=dt("credit-card",TF);const MF=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],jF=dt("download",MF);const OF=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ym=dt("external-link",OF);const $F=[["path",{d:"M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127",key:"wfxp4w"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],NF=dt("file-output",$F);const DF=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],tg=dt("file-text",DF);const LF=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],I1=dt("folder",LF);const UF=[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],_1=dt("folder-git-2",UF);const zF=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],HF=dt("git-branch",zF);const qF=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],BF=dt("github",qF);const FF=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],C1=dt("earth",FF);const VF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],KF=dt("circle-question-mark",VF);const WF=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],GF=dt("list-filter",WF);const ZF=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],JF=dt("loader-circle",ZF);const YF=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],QF=dt("maximize-2",YF);const XF=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Yd=dt("message-square",XF);const e4=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Qd=dt("ellipsis",e4);const t4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],R1=dt("panel-left",t4);const n4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],nf=dt("panel-right",n4);const a4=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],ng=dt("pin",a4);const o4=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],ag=dt("pin-off",o4);const r4=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],i4=dt("plus",r4);const s4=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],l4=dt("power",s4);const c4=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],d4=dt("search",c4);const u4=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],og=dt("settings",u4);const m4=[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]],P1=dt("shapes",m4);const p4=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],f4=dt("shield",p4);const h4=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Xd=dt("square-pen",h4);const g4=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],A1=dt("square-terminal",g4);const v4=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],Bb=dt("user-round",v4);const b4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],os=dt("x",b4);function y4({platform:e}){return!eu()||rg(e)?null:x.jsxs("div",{className:"window-controls","aria-label":"Window controls",children:[x.jsx("button",{type:"button",className:"window-control minimize",title:"Minimize",onClick:()=>{Qm("minimize")},children:x.jsx(zo,{size:14})}),x.jsx("button",{type:"button",className:"window-control maximize",title:"Maximize",onClick:()=>{Qm("toggleMaximize")},children:x.jsx(QF,{size:12})}),x.jsx("button",{type:"button",className:"window-control close",title:"Close",onClick:()=>{Qm("close")},children:x.jsx(os,{size:13})})]})}function rg(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")}function eu(){if(typeof window>"u")return!1;const e=window.openpond;return!!(e?.minimizeWindow||e?.toggleMaximizeWindow||e?.closeWindow)}async function Qm(e){const t=window.openpond;if(!(t&&(e==="minimize"?await t.minimizeWindow?.():e==="toggleMaximize"?await t.toggleMaximizeWindow?.():await t.closeWindow?.())!==!1)){if(e==="toggleMaximize"&&document.fullscreenEnabled){document.fullscreenElement?await document.exitFullscreen():await document.documentElement.requestFullscreen();return}if(e==="close"){window.close();return}console.warn("Window controls require the Electron desktop shell.")}}function S4({value:e,options:t,disabled:n,compact:a,className:r,icon:i,placement:s="bottom",label:l,tooltip:m,searchable:u=!1,floating:h=!1,onChange:b}){const[y,w]=g.useState(!1),[_,E]=g.useState(""),j=g.useRef(null),[P,L]=g.useState();g.useLayoutEffect(()=>{if(!y||!h)return;function C(){const A=j.current?.getBoundingClientRect();if(!A)return;const z=window.innerHeight-A.bottom-12,B=A.top-12,N=z<180&&B>z;L({position:"fixed",left:Math.max(12,A.left),width:Math.min(A.width,window.innerWidth-24),minWidth:0,maxWidth:"calc(100vw - 24px)",right:"auto",top:N?"auto":A.bottom+5,bottom:N?window.innerHeight-A.top+5:"auto",maxHeight:Math.max(80,Math.min(320,N?B-5:z-5)),overflowY:"auto",zIndex:1e3})}return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[y,h]);const $=t.find(C=>C.value===e)??t[0],O=_.trim().toLowerCase(),k=O?t.filter(C=>[C.label,C.shortLabel,C.description].some(A=>A?.toLowerCase().includes(O))):t;return g.useEffect(()=>{if(!y){E("");return}function C(z){j.current?.contains(z.target)||w(!1)}function A(z){z.key==="Escape"&&w(!1)}return document.addEventListener("pointerdown",C),document.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",C),document.removeEventListener("keydown",A)}},[y]),x.jsxs("div",{className:`dropdown-select ${r??""} ${a?"compact":""} ${s==="top"?"open-up":""}`,"data-tooltip":m,ref:j,children:[x.jsxs("button",{type:"button",className:`dropdown-trigger ${y?"active":""}`,disabled:n,"aria-label":l,"aria-haspopup":"menu","aria-expanded":y,onClick:()=>w(C=>!C),children:[i,x.jsx("span",{children:$?.shortLabel??$?.label??e}),x.jsx(zo,{size:14})]}),y&&x.jsxs("div",{className:"dropdown-menu",role:"menu",style:h?P:void 0,children:[u?x.jsxs("label",{className:"dropdown-search",onClick:C=>C.stopPropagation(),children:[x.jsxs("span",{className:"sr-only",children:["Search ",l]}),x.jsx("input",{autoFocus:!0,placeholder:`Search ${l.toLowerCase()}`,value:_,onChange:C=>E(C.target.value)})]}):null,k.map(C=>x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":C.value===e,disabled:C.disabled,className:[C.value===e?"selected":"",C.separatorBefore?"separator-before":"",C.icon?"with-icon":""].filter(Boolean).join(" "),onClick:()=>{C.disabled||(b(C.value),E(""),w(!1))},children:[x.jsxs("span",{children:[C.icon==="plus"?x.jsx(i4,{size:13}):null,x.jsx("span",{children:C.label})]}),C.description&&x.jsx("small",{children:C.description})]},C.value)),k.length?null:x.jsx("div",{className:"dropdown-empty",children:"No matches"})]})]})}const x4=[{destination:"walkthroughs",icon:qb,label:"Walkthroughs"},{destination:"external",icon:qb,label:"Docs",url:"https://openpond.ai/docs"},{destination:"external",icon:tg,label:"Blog",url:"https://openpond.ai/blog"},{destination:"external",icon:EF,label:"Pricing",url:"https://openpond.ai/pricing"},{destination:"external",icon:C1,label:"Web app",url:"https://openpond.ai/sandboxes"},{destination:"external",icon:BF,label:"GitHub",url:"https://github.com/openpond/openpond"},{destination:"external",icon:Yd,label:"Submit issue",url:"https://github.com/openpond/openpond/issues/new/choose"}];function k4({onOpenWalkthroughs:e,walkthroughsActive:t}){const[n,a]=g.useState(!1),r=g.useRef(null);return g.useEffect(()=>{if(!n)return;function i(l){r.current?.contains(l.target)||a(!1)}function s(l){l.key==="Escape"&&a(!1)}return document.addEventListener("pointerdown",i),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",s)}},[n]),x.jsxs("div",{className:"sidebar-help-menu",ref:r,children:[x.jsx("button",{"aria-expanded":n,"aria-haspopup":"menu","aria-label":"Open docs and help menu",className:`sidebar-icon sidebar-help-trigger ${t?"active":""}`,"data-tooltip":"Help",onClick:()=>a(i=>!i),type:"button",children:x.jsx(KF,{size:17})}),n?x.jsx("div",{className:"sidebar-help-popover",role:"menu","aria-label":"Help",children:x4.map(i=>{const s=i.icon,l=x.jsxs(x.Fragment,{children:[x.jsx(s,{size:15}),x.jsx("span",{children:i.label})]});return i.destination==="walkthroughs"?x.jsx("button",{"aria-current":t?"page":void 0,className:"sidebar-help-item",onClick:()=>{a(!1),e()},role:"menuitem",type:"button",children:l},i.label):x.jsx("a",{className:"sidebar-help-item",href:i.url,onClick:m=>{m.preventDefault(),a(!1),w4(i.url)},rel:"noreferrer",role:"menuitem",target:"_blank",children:l},i.label)})}):null]})}async function w4(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-help",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const QZ=[{value:"chat",label:"Chat"},{value:"work",label:"Work"}],Xm=[{value:"chat",label:"Work",description:"Chat and complete tasks"},{value:"models",label:"Models",description:"Evaluate, train, and serve models"}];function T1(e){return e==="chat"?"New chat":"New task"}const af=["get-started","models","tasks","tasksets","labeling","rewards","evaluations","runs","versions","serving"],I4={"get-started":"Get started",models:"Models",tasks:"Tasks",tasksets:"Tasksets",labeling:"Labeling",rewards:"Rewards",evaluations:"Runs",runs:"Runs",versions:"Versions",serving:"Serving"},_4={tasks:["drafts"],tasksets:["drafts","formats","batches"],rewards:["scorers","combined"],evaluations:["results","review","comparisons"],runs:["series","new"]},C4={tasksets:["overview","tasks","reward","attempts","releases"],rewards:["definition","usage","evidence"],evaluations:["overview","comparison","activity"],runs:["details","metrics","evaluation","rollouts","activity","artifacts"],versions:["overview","metrics","evaluation","rollouts","activity","artifacts"]};function ro(e="models",t=null,n={}){return e==="evaluations"&&n.collection==="review"?ro("labeling",t,{...n,collection:"default"}):{page:e,modelId:e==="get-started"?null:t,collection:e==="evaluations"?"results":"default",resourceId:null,detailTab:null,query:"",after:null,...n}}function ig(e){const t=e.pathname.split("/").filter(Boolean);if(t[0]!=="models")return null;let n;try{n=t.slice(1).map(decodeURIComponent)}catch{return null}if(n.some(E=>!E.trim()||E.length>2e3||E.includes("\0")))return null;const a=n[0]&&!af.includes(n[0])?n.shift():null;if(a&&(a.length>500||["projects","scorers"].includes(a)))return null;n[0]==="runs"&&n[1]==="evaluations"&&n.splice(0,2,"evaluations","results"),n[0]==="runs"&&n[1]==="comparisons"&&n.splice(0,2,"evaluations","comparisons");const r=n.shift(),i=r??"models";if(!af.includes(i)||r==="models"||a&&i==="get-started")return null;let s=i==="evaluations"?"results":"default";if(_4[i]?.includes(n[0]))s=n.shift();else if(i==="evaluations"&&n.length)return null;const l=n.shift()??null,m=n.shift()??null;if(n.length||m&&!l||(i==="models"||i==="get-started")&&l)return null;if(s==="drafts"||s==="new"){if(!l||m)return null}else if(s!=="series"){if(["review","formats","batches","comparisons","scorers","combined"].includes(s)){if(m)return null}else if(m&&!C4[i]?.includes(m))return null}if(i==="serving"&&m)return null;const u=new URLSearchParams(e.search??"");if([...u.keys()].some(E=>!["model","q","after","source"].includes(E))||[...u.keys()].some(E=>u.getAll(E).length!==1))return null;const h=u.get("source");if(h!==null&&(i!=="labeling"&&(i!=="evaluations"||s!=="review")||!h.trim()||h.length>500))return null;const b=u.get("model");if(a&&b&&a!==b)return null;const y=a??b;if(i==="get-started"&&u.size!==0)return null;const w=u.get("q")??"",_=u.get("after");return y!==null&&(!y.trim()||y.length>500)||w.length>1e3||_!==null&&(!_.trim()||_.length>2e3)?null:ro(i,y,{collection:s,resourceId:l,detailTab:m,query:w,after:_,...h!==null?{sourceId:h}:{}})}function tu(e){const t=["/models"];if(e.modelId&&t.push(encodeURIComponent(e.modelId)),e.page==="evaluations"&&e.collection==="review")return tu(ro("labeling",e.modelId,{collection:"default",resourceId:e.resourceId,sourceId:e.sourceId,query:e.query,after:e.after}));e.page==="evaluations"?t.push("runs",e.collection==="comparisons"?"comparisons":"evaluations"):(e.page!=="models"&&t.push(e.page),e.collection!=="default"&&t.push(e.collection)),e.resourceId&&t.push(encodeURIComponent(e.resourceId)),e.resourceId&&e.detailTab&&t.push(encodeURIComponent(e.detailTab));const n=new URLSearchParams;return e.query&&n.set("q",e.query),e.after&&n.set("after",e.after),(e.page==="labeling"||e.page==="evaluations"&&e.collection==="review")&&e.sourceId&&n.set("source",e.sourceId),`${t.join("/")}${n.size?`?${n}`:""}`}function R4(e,t){return ro(e.page,t,{collection:e.collection==="new"||e.collection==="drafts"?"default":e.collection})}function XZ(e,t,n=null){return{...e,resourceId:t,detailTab:n,after:null}}const sd=new Set,of=new Set,P4=new Set(["account","notifications","harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases","profile","skills","configuration","context","training","subagents","editor","providers","dataset-storage","remote","usage","personalization","diagnostics"]),rf={apps:"/apps",outputs:"/outputs",projects:"/projects",scheduled:"/workflows","get-started":"/get-started"};let sf=!1,lf="",zc=null,E1=null,xl="",Ta=0,Vs=null,rl=!1,ep=null,Hc=!1;function sg(e){const t=ig(e);if(t)return{kind:"models",route:t};const n=e.pathname.split("/").filter(Boolean);if(n[0]==="models")return{kind:"models_unavailable",pathname:e.pathname,search:e.search??""};if(n[0]==="settings"&&n.length===2&&P4.has(n[1])){const r=lg(new URLSearchParams(e.search??"").get("returnTo"));return{kind:"settings",section:n[1],...r?{returnTo:r}:{}}}if(n[0]==="chat"&&n.length<=2)try{return{kind:"chat",sessionId:n[1]&&n[1]!=="new"?decodeURIComponent(n[1]):null}}catch{return null}const a=Object.keys(rf).find(r=>rf[r]===e.pathname);return a?{kind:"view",view:a}:null}function M1(e){if(e.kind==="models")return tu(e.route);if(e.kind==="models_unavailable")return`${e.pathname}${e.search}`;if(e.kind==="settings"){const t=lg(e.returnTo??null);return`/settings/${e.section}${t?`?${new URLSearchParams({returnTo:t})}`:""}`}return e.kind==="chat"?e.sessionId?`/chat/${encodeURIComponent(e.sessionId)}`:"/chat/new":rf[e.view]}function A4(e){const t=e?.kind==="settings"?lg(e.returnTo??null):null;if(t){const n=new URL(t,"https://local.openpond.invalid"),a=ig(n);if(a)return{kind:"models",route:a}}return{kind:"chat",sessionId:null}}function lg(e){if(!e||e.length>6e3||!e.startsWith("/models")||e.startsWith("//"))return null;const t=new URL(e,"https://local.openpond.invalid");if(t.origin!=="https://local.openpond.invalid"||t.hash)return null;const n=ig(t);return n?tu(n):null}function Vl(){return`${window.location.pathname}${window.location.search}`}function cg(){if(typeof window>"u")return;const e=sf?xl:Vl();e!==lf&&(lf=e,zc=sg(new URL(e,window.location.origin)),E1=zc?.kind==="models"?zc.route:null)}function j1(){lf="",cg();for(const e of of)e()}async function dg(e){if(Hc)return!1;Hc=!0;try{for(const t of[...sd].reverse())if(!await t(e))return!1;return!0}finally{Hc=!1}}function ug(e){return{...window.history.state,openpondNavigationIndex:e}}async function T4(){const e=Vl(),t=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:Ta-1;if(Vs&&t===Ta){const a=Vs;Vs=null,a();return}if(ep===t||sd.size===0){ep=null,xl=e,Ta=t,window.history.replaceState(ug(Ta),"",e),j1();return}if(t===Ta)return;if(rl||Hc){Vs??=()=>{},window.history.go(Ta-t);return}rl=!0;const n=t-Ta;try{await new Promise(a=>{Vs=a,window.history.go(-n)}),await dg(e)&&(ep=t,window.history.go(n))}finally{rl=!1}}function mg(){if(sf||typeof window>"u")return;const e=sg(window.location);xl=e?M1(e):Vl(),Ta=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:0,window.history.replaceState(ug(Ta),"",xl),window.addEventListener("popstate",T4),sf=!0}function O1(e){return of.add(e),mg(),()=>{of.delete(e)}}function eJ(e){return sd.add(e),mg(),()=>{sd.delete(e)}}async function tJ(e){!rl&&await dg(Vl())&&e()}function E4(){return g.useSyncExternalStore(O1,()=>(cg(),E1),()=>null)}function M4(){return g.useSyncExternalStore(O1,()=>(cg(),zc),()=>null)}async function ln(e,t="push"){if(typeof window>"u"||(mg(),rl))return!1;if(e.kind==="settings"&&!e.returnTo){const a=sg(window.location),r=a?.kind==="models"?tu(a.route):a?.kind==="settings"?a.returnTo:void 0;r&&(e={...e,returnTo:r})}const n=M1(e);return Vl()===n?!0:await dg(n)?(t==="push"&&Ta++,window.history[t==="replace"?"replaceState":"pushState"](ug(Ta),"",n),xl=n,j1(),!0):!1}function ji(e,t="push"){return ln({kind:"models",route:e},t)}function j4({experience:e="work",productArea:t="chat",beginNewChat:n,setSectionMenuOpen:a,setSelectedAppId:r,setSelectedProjectId:i,setSelectedSessionId:s,setView:l,view:m,modelProjects:u=[],modelTrainingActivityByProjectId:h={}}){const b=E4(),y=b?.modelId??null,w=b?.page??"models";function _(){r(null),i(null),s(null),a(null)}async function E($){await ji(ro($,y))&&(_(),l("labs"))}async function j($){await ji(R4(b??ro(),$||null))&&(_(),l("labs"))}async function P($){await ln({kind:"view",view:$})&&(_(),l($))}const L=y?h[y]??null:null;return x.jsxs("nav",{className:"sidebar-nav","aria-label":"Primary",children:[t==="models"?null:x.jsxs("button",{className:"nav-command nav-command-new-task",type:"button",onClick:()=>{ln({kind:"chat",sessionId:null}),n(null)},children:[x.jsx(Xd,{size:18}),x.jsx("span",{children:T1(e)})]}),t==="models"?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"sidebar-model-project-picker",children:[x.jsx("span",{className:"sidebar-nav-group-label",children:"Model"}),x.jsx(S4,{label:"Model",searchable:u.length>8,value:y??"",options:[{value:"",label:"All models"},...y&&!u.some($=>$.id===y)?[{value:y,label:"Unavailable model",disabled:!0}]:[],...u.map($=>({value:$.id,label:$.name}))],onChange:$=>{j($)}})]}),af.filter($=>$!=="tasksets"&&$!=="evaluations").map($=>{const O={"get-started":Jm,models:uF,tasks:Jm,tasksets:Jm,labeling:tf,rewards:f4,evaluations:tf,runs:w1,versions:HF,serving:Jd}[$];return x.jsxs("button",{className:`nav-command ${m==="labs"&&(w===$||$==="runs"&&w==="evaluations")?"active":""}`,"aria-current":m==="labs"&&(w===$||$==="runs"&&w==="evaluations")?"page":void 0,type:"button",onClick:()=>{E($)},children:[x.jsx(O,{size:16}),x.jsx("span",{children:I4[$]}),$==="runs"&&L?x.jsx("span",{className:"sidebar-running-dot","aria-label":L.label}):null]},$)})]}):null,t==="chat"?x.jsxs(x.Fragment,{children:[x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="scheduled"?"active":""}`,"aria-label":"Workflows",type:"button",onClick:()=>{P("scheduled")},children:[x.jsx(xF,{size:18}),x.jsx("span",{children:"Workflows"})]}),x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="outputs"?"active":""}`,"aria-label":"Outputs",type:"button",onClick:()=>{P("outputs")},children:[x.jsx(NF,{size:18}),x.jsx("span",{children:"Outputs"})]}),x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="apps"?"active":""}`,"aria-label":"Apps",type:"button",onClick:()=>{P("apps")},children:[x.jsx(P1,{size:18}),x.jsx("span",{children:"Apps"})]}),x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="projects"?"active":""}`,"aria-label":"Projects",type:"button",onClick:()=>{P("projects")},children:[x.jsx(_1,{size:18}),x.jsx("span",{children:"Projects"})]})]}):null]})}function O4({setSectionMenuOpen:e,setSelectedAppId:t,setSelectedProjectId:n,setSelectedSessionId:a,setView:r,view:i}){function s(){t(null),n(null),a(null),e(null),r("get-started"),ln({kind:"view",view:"get-started"})}return x.jsx("nav",{className:"sidebar-utility-nav","aria-label":"Resources",children:x.jsx(k4,{onOpenWalkthroughs:s,walkthroughsActive:i==="get-started"})})}const $1=gm({chatMode:v(["chat","work"]).optional(),notificationMode:v(["all","direct_mentions","none"]).optional(),learningNoticeDismissed:R().optional(),sidebarVisibility:gm({showCodexChats:R(),onlyRunningTasks:R()}).optional(),scheduledWorkView:v(["calendar","list"]).optional(),editorControlsVisible:R().optional(),voiceNoticeAcknowledged:R().optional(),lessonProgress:se(o().min(1).max(200),gm({completed:R(),currentTime:d().finite().nonnegative(),duration:d().finite().positive(),updatedAt:d().finite().nonnegative()})).refine(e=>Object.keys(e).length<=200,"Too many lessons").optional()}),cf={"openpond:last-chat-task-mode":"chatMode","openpond.team-chat.notification-mode":"notificationMode","openpond.sidebar.continuous-learning.dismissed.v1":"learningNoticeDismissed","openpond.sidebar-task-visibility.v1":"sidebarVisibility","openpond.scheduled-work.view.v1":"scheduledWorkView","openpond.workspace.editorControlsVisible":"editorControlsVisible","openpond.voice.setupNoticeAcknowledged":"voiceNoticeAcknowledged","openpond.post-training-progress.v1":"lessonProgress"},df=new Set;let il=null,No=null,Ma={},kl={},tp=!1,qc=0,Oi=null,Fb=0;const $4="openpond-client-choices-changed";function pg(){df.forEach(e=>e()),typeof window<"u"&&window.dispatchEvent(new Event($4))}function N4(){return Oi}function D4(e){return df.add(e),()=>{df.delete(e)}}function Kl(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>D4(()=>t.current()),[])}async function Vb(e){const t=++Fb,n=await q(e,"/v1/configuration");if(n.clientState?.revision===null){const r=L4();if(Object.keys(r.patch).length){n.clientState=await q(e,"/v1/configuration",{method:"POST",body:JSON.stringify({action:"client-state",owner:n.clientState.owner,patch:r.patch,importOnly:!0})});for(const i of r.keys)try{window.localStorage.removeItem(i)}catch{}}}if(t!==Fb)return;const a=il?.serverUrl!==e.serverUrl||il?.token!==e.token||No?.owner!==n.clientState?.owner;a&&(qc++,Ma={},kl={},Oi=null),il=e,(a||(n.clientState?.revision??0)>=(No?.revision??0))&&(No=n.clientState),pg()}async function fg(){if(tp||!il||!No||!Object.keys(Ma).length)return;tp=!0;const e=Ma,t=il,n=No.owner,a=qc;Ma={},kl=e;try{const r=await q(t,"/v1/configuration",{method:"POST",body:JSON.stringify({action:"client-state",owner:n,patch:e})});a===qc&&(No=r,Oi=null)}catch(r){a===qc&&(Ma={...e,...Ma},Oi=`Preference changes have not been saved. ${r instanceof Error?r.message:String(r)}`)}finally{kl={},tp=!1,pg(),!Oi&&Object.keys(Ma).length&&fg()}}function nJ(){Oi=null,fg()}const Wl={getItem(e){const t=cf[e];if(!t)return null;const n={...No?.value,...kl,...Ma}[t];return n===void 0?null:typeof n=="string"?n:JSON.stringify(n)},setItem(e,t){if(!No)return;const n=cf[e];if(!n)throw new Error("Unregistered client preference.");let a;try{a=JSON.parse(t)}catch{a=t}const r=$1.parse({[n]:a});JSON.stringify({...No.value,...kl,...Ma}[n])!==JSON.stringify(r[n])&&(Ma={...Ma,...r},pg(),fg())}};function L4(){const e={},t=[];if(typeof window>"u")return{patch:e,keys:t};for(const[n,a]of Object.entries(cf))try{const r=window.localStorage.getItem(n);if(r===null)continue;let i;try{i=JSON.parse(r)}catch{i=r}const s=$1.safeParse({[a]:i});s.success&&(Object.assign(e,s.data),t.push(n))}catch{}return{patch:e,keys:t}}const Bc=5,Cn=15,uf=10,Et={defaultChatProvider:Mr,subagents:qE(),codexPermissionMode:oh,codexReasoningEffort:rh,openPondCommandAccessMode:Rd,defaultBranchPrefix:"feat/",defaultNewProjectDirectory:"",advancedWorkspaceControls:!1,steerActiveResponses:!0,contextCompaction:{autoEnabled:!0,triggerPercent:85,summaryModel:"same_model"},training:{defaultModelRef:null,creationMode:"customize",autoApproveEvidence:!1},sidebarWidth:332,diffPanelWidth:560,sidebarSectionsCollapsed:{pinned:!1,projects:!1,cloudProjects:!1,chats:!1,savedForLater:!0},editor:{languageServers:"auto",diagnosticsWhileEditing:!0,checkOnSave:!0,languages:{typescript:{mode:"auto",customCommand:""},python:{mode:"auto",customCommand:""},rust:{mode:"auto",customCommand:""}}}},aJ={activeTemplateId:"default",customized:!1,soul:"",soulPath:null,updatedAt:null,templates:[]},N1=[{value:"accounts/fireworks/models/deepseek-v4-pro",label:"DeepSeek V4 Pro",description:"reasoning"},{value:"accounts/fireworks/models/kimi-k3",label:"Kimi K3",description:"reasoning"},{value:"accounts/fireworks/models/glm-5p3",label:"GLM-5.3",description:"reasoning"},{value:"accounts/fireworks/models/deepseek-v4-flash",label:"DeepSeek V4 Flash",description:"reasoning"},{value:"accounts/fireworks/models/nemotron-lightning-3p5-30b-a3b",label:"Nemotron Lightning 3.5 30B A3B",description:"reasoning"},{value:"accounts/fireworks/models/minimax-m3",label:"MiniMax M3",description:"reasoning"}],np=[{value:"openpond",label:"OpenPond Chat"},{value:"codex",label:"OpenAI Codex",description:"Codex login"}],U4=["openai","xai","openrouter","deepseek","zai","moonshot","together","groq","custom-openai-compatible"],z4=["openpond","codex",...U4],D1=new Set(z4),L1=[{value:ah,label:"GPT-5.6 Sol"},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra"},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna"},{value:"gpt-5.5",label:"GPT-5.5"},{value:"gpt-5.4",label:"GPT-5.4"},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark"},{value:"gpt-5.2",label:"GPT-5.2"}],oJ=[{value:"default",label:"Default permissions",shortLabel:"Default",description:"Workspace sandbox; asks before crossing boundaries."},{value:"auto-review",label:"Auto-review",description:"Workspace sandbox; reviewer handles eligible approvals."},{value:"full-access",label:"Full access",description:"No sandbox or approval prompts."}],rJ=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High",shortLabel:"Extra High"}],iJ=[{value:"ask",label:"Ask",description:"Ask before running shell commands."},{value:"full-access",label:"Full access",description:"Run shell commands without approval prompts."}],sJ=[{value:"auto",label:"Auto",description:"Use installed language servers when available."},{value:"off",label:"Off",description:"Disable editor language servers."}],lJ=[{value:"auto",label:"Auto",description:"Find the local executable automatically."},{value:"disabled",label:"Disabled",description:"Do not start this language server."},{value:"custom",label:"Custom",description:"Use a specific executable path or command name."}];function hg(e){return e.kind==="local"}function H4(e){return e.kind==="cloud"}function vt(e,t){return`${e}:${t}`}function U1(e){const t=e?.trim();if(!t)return null;const n=t.indexOf(":");if(n<=0)return{kind:"local",id:t};const a=t.slice(0,n),r=t.slice(n+1);return(a==="local"||a==="cloud")&&r?{kind:a,id:r}:{kind:"local",id:t}}function Pr(e){return`${e.type}:${e.id}`}function ld(e){const t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?"before":"after"}function cd(e,t,n,a="before"){if(t===n)return e;const r=e.filter(s=>s!==t),i=r.indexOf(n);return i===-1?e:(r.splice(a==="after"?i+1:i,0,t),r)}function Kb(e,t){return e.length===t.length&&e.every((n,a)=>n===t[a])}function q4(e,t){if(!t)return e;const n=new Map(e.map(i=>[i.key,i])),a=t.map(i=>n.get(i)).filter(i=>!!i),r=new Set(a.map(i=>i.key));return[...a,...e.filter(i=>!r.has(i.key))]}function gg(e,t){return e?.statuses?.[t]??null}function z1(e,t){return e?.providers?.[t]??null}function H1(e,t){return e?.modelCaches?.[t]??null}function B4(e){const t=[e.contextWindow?`${Math.round(e.contextWindow/1e3)}K context`:"",e.capabilities.reasoning?"reasoning":"",e.source].filter(Boolean);return{value:e.id,label:e.displayName||e.id,description:t.join(" · ")||void 0}}function F4(e){return e==="openpond"?N1:e==="codex"||e==="openai"?L1:[]}function V4(e){const t=new Set,n=[];for(const a of e)!a.value||t.has(a.value)||(t.add(a.value),n.push(a));return n}function cJ(e){return D1.has(e)}function mf(e,t={}){if(!e)return t.localOnly,np;const n=t.includeUnavailable??!1,a=t.enabledOnly??!1,r=[];for(const i of Kf){if(!D1.has(i)||t.localOnly&&i==="openpond")continue;const s=gg(e,i);s&&(!n&&(i==="codex"&&!s.available&&!s.credential.connected||i!=="openpond"&&i!=="codex"&&!s.enabled)||a&&i!=="openpond"&&!s.enabled||a&&i==="codex"&&!s.available&&!s.credential.connected||r.push({value:i,label:i==="openpond"?"OpenPond Chat":s.displayName,description:i==="openpond"?void 0:s.available?"Connected":s.credential.connected?"Configured":s.routing.localByok?"Set up key":s.enabled?"Enabled":void 0}))}return r.length>0?r:np}function wl(e,t){const a=(H1(t,e)?.models??[]).filter(s=>e!=="openpond"||s.id!==Ui).map(B4),r=z1(t,e),i=[...r?.modelOverrides??[],r?.defaultModel].filter(s=>!!s?.trim()&&(e!=="openpond"||s!==Ui)).map(s=>({value:s,label:s}));return V4([...a,...i,...F4(e)])}function K4(e,t,n){if(e==="codex"||e==="openai")return!0;const a=t.trim();if(!a)return!1;const r=H1(n,e)?.models.find(i=>i.id===a);return r?!!r.capabilities.reasoning:wl(e,n).some(i=>i.value===a&&/\breasoning\b/i.test(i.description??""))}function dd(e,t){const n=z1(t,e)?.defaultModel?.trim();if(n)return n;const a=gg(t,e)?.defaultModel?.trim();if(a)return a;const r=wl(e,t)[0]?.value?.trim();return r||(e==="codex"?ah:e==="openpond"?Ui:"")}function cr(e,t,n){const a=t?.trim();if(e==="codex"&&(a==="codex-default"||a==="gpt-5.5"))return ah;const r=wl(e,n);return a&&r.some(i=>i.value===a)||a&&e!=="codex"&&r.length===0&&!n?a:dd(e,n)}function q1(e,t){const n=e.modelRef?.providerId??e.provider;return{provider:n,model:cr(n,e.modelRef?.modelId,t)}}function vg(e,t,n){return cr(e,t,n)||void 0}function Pa(e,t,n){const a=vg(e,t,n);return a?{providerId:e,modelId:a}:void 0}function Wb(e){return e==="full-access"?{approvalPolicy:"never",sandbox:"danger-full-access"}:{approvalPolicy:"on-request",sandbox:"workspace-write"}}function pa(e){const t=e?.defaultChatProvider??Et.defaultChatProvider;return{defaultChatProvider:t,defaultChatModel:cr(t,e?.defaultChatModel),subagents:ul.parse(e?.subagents??Et.subagents),codexPermissionMode:e?.codexPermissionMode??Et.codexPermissionMode,codexReasoningEffort:e?.codexReasoningEffort??Et.codexReasoningEffort,openPondCommandAccessMode:e?.openPondCommandAccessMode??Et.openPondCommandAccessMode,defaultBranchPrefix:B1(e?.defaultBranchPrefix),defaultNewProjectDirectory:e?.defaultNewProjectDirectory??Et.defaultNewProjectDirectory,defaultTeamId:e?.defaultTeamId?.trim()||null,advancedWorkspaceControls:e?.advancedWorkspaceControls??Et.advancedWorkspaceControls,steerActiveResponses:e?.steerActiveResponses??Et.steerActiveResponses,contextCompaction:{autoEnabled:e?.contextCompaction?.autoEnabled??Et.contextCompaction.autoEnabled,triggerPercent:e?.contextCompaction?.triggerPercent??Et.contextCompaction.triggerPercent,summaryModel:e?.contextCompaction?.summaryModel??Et.contextCompaction.summaryModel},training:{defaultModelRef:e?.training?.defaultModelRef??Et.training.defaultModelRef,creationMode:e?.training?.creationMode??Et.training.creationMode,autoApproveEvidence:e?.training?.autoApproveEvidence??Et.training.autoApproveEvidence},sidebarWidth:e?.sidebarWidth??Et.sidebarWidth,diffPanelWidth:e?.diffPanelWidth??Et.diffPanelWidth,sidebarSectionsCollapsed:{pinned:e?.sidebarSectionsCollapsed?.pinned??Et.sidebarSectionsCollapsed.pinned,projects:e?.sidebarSectionsCollapsed?.projects??Et.sidebarSectionsCollapsed.projects,cloudProjects:e?.sidebarSectionsCollapsed?.cloudProjects??Et.sidebarSectionsCollapsed.cloudProjects,chats:e?.sidebarSectionsCollapsed?.chats??Et.sidebarSectionsCollapsed.chats,savedForLater:e?.sidebarSectionsCollapsed?.savedForLater??Et.sidebarSectionsCollapsed.savedForLater},editor:{languageServers:e?.editor?.languageServers??Et.editor.languageServers,diagnosticsWhileEditing:e?.editor?.diagnosticsWhileEditing??Et.editor.diagnosticsWhileEditing,checkOnSave:e?.editor?.checkOnSave??Et.editor.checkOnSave,languages:{typescript:{mode:e?.editor?.languages?.typescript?.mode??Et.editor.languages.typescript.mode,customCommand:e?.editor?.languages?.typescript?.customCommand??Et.editor.languages.typescript.customCommand},python:{mode:e?.editor?.languages?.python?.mode??Et.editor.languages.python.mode,customCommand:e?.editor?.languages?.python?.customCommand??Et.editor.languages.python.customCommand},rust:{mode:e?.editor?.languages?.rust?.mode??Et.editor.languages.rust.mode,customCommand:e?.editor?.languages?.rust?.customCommand??Et.editor.languages.rust.customCommand}}}}}function B1(e){const t=e?.trim()??Et.defaultBranchPrefix;if(!t)return"";const a=t.toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/\/{2,}/g,"/").replace(/^-+/,"").slice(0,48).split("/").map(r=>r.replace(/^-+|-+$/g,"")).filter(Boolean).join("/");return a?`${a}/`:""}function dJ(e,t){return e==="openpond"?"OpenPond Chat":gg(t,e)?.displayName??(e==="codex"?"OpenAI Codex":e)}function uJ(e,t,n){if(n){const a=wl(n,t).find(r=>r.value===e);if(a)return a.label}if(t)for(const a of Kf){const r=wl(a,t).find(i=>i.value===e);if(r)return r.label}return[...N1,...L1].find(a=>a.value===e)?.label??e}function W4(e,t){return t==="chat"?e.filter(n=>n.experience==="chat"):e.filter(n=>n.experience==="work"||n.experience==="development")}function G4(e){return e.experience==="chat"?"Chat":"Work"}const bg="taskDraft";function F1(e){if(e?.experience!=="work")return null;const t=e.metadata?.[bg];if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.prompt;return typeof n=="string"&&n.trim()?n:null}function Il(e){return F1(e)!==null}function Z4(e){return(e.split(/\r?\n/u).map(n=>n.trim()).find(Boolean)||"Task draft").slice(0,64)}function ap(e,t,n=new Date().toISOString()){const a={version:1,prompt:t,savedAt:n};return{...e??{},[bg]:a}}function J4(e){const t={...e??{}};return delete t[bg],t}function tr(e){const t=Ic(e.metadata?.trainingTasksetId)??Ic(e.metadata?.tasksetId);return t?{id:t,name:Ic(e.metadata?.trainingTasksetName)??Ic(e.metadata?.tasksetName)??Y4(t)}:null}function Y4(e){const n=e.replace(/[-_][a-f0-9]{8,}$/i,"").replace(/^(?:benchmark[-_])?taskset[-_]/i,"").replace(/^benchmark[-_]/i,"").split(/[-_]+/).filter(Boolean);return n.length===0?"Taskset":n.map(a=>/^[A-Z0-9]{2,}$/.test(a)?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join(" ")}function Ic(e){return typeof e=="string"&&e.trim()?e.trim():null}const Q4="codex_history_";function Ht(e){return!!e?.startsWith(Q4)}function V1(e){const t=[],n=new Set;for(const a of e)for(const r of[a.workspacePath,a.path]){const i=nu(r);if(!i)continue;const s=`${a.id}:${i}`;n.has(s)||(n.add(s),t.push({projectId:a.id,path:i}))}return t.sort((a,r)=>r.path.length-a.path.length)}function X4(e,t,n,a=new Set){if(e.localProjectId&&t.has(e.localProjectId))return e.localProjectId;if(e.workspaceKind==="local_project"&&e.workspaceId&&t.has(e.workspaceId))return e.workspaceId;if(e.metadata?.workspaceTarget==="hybrid"&&e.cwd){const i=K1(e.cwd,n);if(i)return i}if(e.cloudProjectId&&a.has(e.cloudProjectId))return e.cloudProjectId;if(!e.cwd||e.workspaceKind==="sandbox"||e.workspaceKind==="sandbox_template"||e.workspaceKind==="sandbox_app"||!W1(e))return null;const r=nu(e.cwd);if(!r)return null;for(const i of n)if(yg(r,i.path))return i.projectId;return null}function Gb(e,t,n,a=new Set){if(e.localProjectId&&t.has(e.localProjectId))return vt("local",e.localProjectId);if(e.workspaceKind==="local_project"&&e.workspaceId&&t.has(e.workspaceId))return vt("local",e.workspaceId);if(e.metadata?.workspaceTarget==="hybrid"&&e.cwd){const i=K1(e.cwd,n);if(i)return vt("local",i)}if(e.cloudProjectId&&a.has(e.cloudProjectId))return vt("cloud",e.cloudProjectId);if(!e.cwd||e.workspaceKind==="sandbox"||e.workspaceKind==="sandbox_template"||e.workspaceKind==="sandbox_app"||!W1(e))return null;const r=nu(e.cwd);if(!r)return null;for(const i of n)if(yg(r,i.path))return vt("local",i.projectId);return null}function K1(e,t){const n=nu(e);if(!n)return null;for(const a of t)if(yg(n,a.path))return a.projectId;return null}function W1(e){return e.workspaceKind==="local_project"||e.provider==="codex"||Ht(e.id)}function nu(e){const t=e?.trim();if(!t)return null;let n=t.replace(/^file:\/\/+/i,"/").replace(/\\/g,"/").replace(/\/+/g,"/");return/^[a-z]:/i.test(n)&&(n=n[0].toUpperCase()+n.slice(1)),n=n.replace(/\/+$/g,""),n||"/"}function yg(e,t){const n=Zb(e),a=Zb(t);return n===a||n.startsWith(`${a}/`)}function Zb(e){return/^[A-Z]:\//.test(e)?e.toLowerCase():e}const Jb=[{value:"active",label:"Active"},{value:"in_progress",label:"In progress"},{value:"pinned",label:"Pinned"},{value:"saved_for_later",label:"Save for later"},{value:"tasksets",label:"Tasksets"},{value:"done",label:"Done"},{value:"all",label:"All"}],e5=[{value:"recent",label:"Recent first"},{value:"manual",label:"Manual order"}];function Yb(e){const t=[];if(e.filter==="done")t.push(...e.doneSessions.filter(r=>!tr(r)));else if(e.filter==="all")t.push(...e.activeSessions.filter(r=>!tr(r)),...e.doneSessions.filter(r=>!tr(r)));else if(e.filter==="tasksets")t.push(...e.activeSessions.filter(r=>Qb(r,e.selectedTasksetId)),...e.doneSessions.filter(r=>Qb(r,e.selectedTasksetId)));else for(const r of e.activeSessions)tr(r)||(e.filter==="active"?r.savedForLater||t.push(r):e.filter==="in_progress"?!r.savedForLater&&e.inProgressSessionIds.has(r.id)&&t.push(r):e.filter==="pinned"?r.pinned&&!r.savedForLater&&t.push(r):e.filter==="saved_for_later"&&r.savedForLater&&t.push(r));const n=t.filter(r=>bi(r,{inProgressSessionIds:e.inProgressSessionIds,onlyRunningTasks:e.onlyRunningTasks,showCodexChats:e.showCodexChats})),a=e.previewSessionIds?new Map(e.previewSessionIds.map((r,i)=>[r,i])):null;return e.sort==="recent"?n.sort((r,i)=>ey(r,i,a)):n.sort((r,i)=>{const s=a?.get(r.id),l=a?.get(i.id);if(s!==void 0||l!==void 0){if(s===void 0)return 1;if(l===void 0)return-1;if(s!==l)return s-l}return r.order!==i.order?r.order-i.order:ey(r,i)})}function bi(e,t){return t.showCodexChats===!1&&(e.provider==="codex"||Ht(e.id))?!1:!t.onlyRunningTasks||t.inProgressSessionIds.has(e.id)}function Qb(e,t){const n=tr(e);return!!(n&&(!t||n.id===t))}function t5(e){return e.filter==="saved_for_later"||e.filter==="tasksets"?{count:Math.max(0,e.activeCount),label:"In Progress",targetFilter:"active",targetLabel:"active"}:{count:Math.max(0,e.savedForLaterCount),label:"Later",targetFilter:"saved_for_later",targetLabel:"saved for later"}}function n5(e,t){switch(e){case"active":return`No active ${t}`;case"in_progress":return"No work in progress";case"pinned":return`No pinned ${t}`;case"saved_for_later":return"Nothing saved for later";case"tasksets":return"No Taskset chats yet";case"done":return`No done ${t}`;case"all":return`No ${t}`}}function Xb(e,t,n){const a=new Set(t);let r=0;return e.map(i=>{if(!a.has(i))return i;const s=n[r];return r+=1,s??i})}function ey(e,t,n=null){const a=sl(e),r=sl(t);if(a!==r)return a?-1:1;if(a&&r){const s=n?.get(e.id),l=n?.get(t.id);if(s!==void 0||l!==void 0){if(s===void 0)return 1;if(l===void 0)return-1;if(s!==l)return s-l}if(e.order!==t.order)return e.order-t.order}const i=Date.parse(t.updatedAt)-Date.parse(e.updatedAt);return i!==0?i:e.title.localeCompare(t.title)}function sl(e){return e.pinned&&!e.savedForLater&&!e.archived}const _c={showCodexChats:!0,onlyRunningTasks:!1},G1="openpond.sidebar-task-visibility.v1";function ty(e=Z1()){try{const t=e?.getItem(G1);if(!t)return _c;const n=JSON.parse(t);return{showCodexChats:typeof n.showCodexChats=="boolean"?n.showCodexChats:_c.showCodexChats,onlyRunningTasks:typeof n.onlyRunningTasks=="boolean"?n.onlyRunningTasks:_c.onlyRunningTasks}}catch{return _c}}function ny(e,t=Z1()){try{t?.setItem(G1,JSON.stringify(e))}catch{}}function Z1(){return typeof window>"u"?null:Wl}function J1(e){return`${e.kind}:${e.id}`}function _l(e,t){return!!(e&&t&&e.kind===t.kind&&e.id===t.id)}function a5(e){return{kind:"session",id:e}}function o5(e){return{kind:"project",id:e}}function r5(e){return{kind:"draft",id:e}}function i5(e){return e.selectedSessionId?a5(e.selectedSessionId):e.selectedProjectId?o5(e.selectedProjectId):r5(e.selectedAppId?`app:${e.selectedAppId}`:"new-chat")}function s5(e){if(!e.previousScope||e.previousScope.kind!=="draft"||e.activeScope.kind!=="session")return[...e.tabs];if(_l(e.previousScope,e.activeScope))return[...e.tabs];const t=e.now??Date.now();return e.tabs.map(n=>_l(n.scope,e.previousScope)?{...n,scope:e.activeScope,updatedAt:t}:n)}function mJ(e,t){return e.filter(n=>_l(n.scope,t))}function pJ(e,t){return!!(e&&_l(e.scope,t))}function l5(e){const t={};for(const n of e){const a=J1(n.scope),r=t[a]??{scope:n.scope,tabCount:0,runningCount:0,failedCount:0,lastExitCode:null,status:"none"};r.tabCount+=1,n.commandStatus==="running"&&(r.runningCount+=1),(n.commandStatus==="failed"||n.status==="error")&&(r.failedCount+=1),n.lastExitCode!==null&&(r.lastExitCode=n.lastExitCode),r.status=d5(r.status,n.status,n.commandStatus),t[a]=r}return t}function c5(e){return!e||e.status==="none"||e.tabCount===0?null:e.status==="running"?{status:"running",label:"Terminal running"}:e.status==="failed"?{status:"failed",label:"Terminal last command failed"}:e.status==="success"?{status:"success",label:"Terminal last command succeeded"}:e.status==="idle"?{status:"idle",label:"Terminal idle"}:{status:"unknown",label:"Terminal open"}}function d5(e,t,n){return n==="running"?"running":e==="running"?e:n==="failed"||t==="error"?"failed":e==="failed"?e:n==="success"?e==="none"||e==="unknown"||e==="idle"?"success":e:n==="idle"?e==="none"||e==="unknown"?"idle":e:e==="none"?"unknown":e}function Y1(e,t){if(!e)return t?.path??"Use files on this machine";if(e.error)return"status unavailable";if(!e.initialized)return"not checked out";const a=[e.currentBranch??t?.branch??e.defaultBranch??"no branch"],r=m5(e),i=t?.linkedCloudSourceKnown===!1&&!!e.headCommit;return r?a.push(r):i?a.push("upload required"):e.diverged?(e.ahead>0&&a.push(nr("ahead",e.ahead)),e.behind>0&&a.push(nr("behind",e.behind)),a.push("diverged")):(e.ahead>0&&a.push(nr("ahead",e.ahead)),e.behind>0&&a.push(nr("behind",e.behind))),e.changedFilesCount>0?a.push(`${e.changedFilesCount} changed`):e.dirty&&a.push("dirty"),e.untrackedFilesCount>0&&a.push(`${e.untrackedFilesCount} untracked`),a.length===1&&a.push("synced"),a.join(" / ")}function Q1(e,t,n,a={}){const r=e?.linkedSandboxProject??null;if(!r?.projectId&&!t)return"upload required";if(r?.projectId&&a.cloudLinkTrusted===!1)return"uploaded to a different account";const i=r?.defaultBranch??t?.defaultBranch??"main",s=r?.manifestHash??null,l=e?.sandboxTemplate?.manifestHash??null,m=r?.syncedAt??t?.syncedAt??null,u=!!(s&&l&&s!==l),h=!!(r?.projectId&&n?.headCommit&&!r.lastUploadedCommit),b=p5(n);return b?`${i} / ${b}`:h?`${i} / upload required`:`${i} / ${u||!m?"needs sync":"setup ready"}`}function u5(e,t,n={}){if(!e)return"select a local project";if(e.linkedSandboxProject?.projectId&&n.cloudLinkTrusted===!1)return"sync to this account";if(!t)return e.linkedSandboxProject?"sync source to cloud":"push local source to cloud";if(t.error)return"repo status unavailable";if(!t.initialized)return"local repo unavailable";const a=[],r=t.aheadOfLinkedSource>0?t.aheadOfLinkedSource:t.ahead;return e.linkedSandboxProject?.projectId||a.push("upload required"),e.linkedSandboxProject?.projectId&&t.headCommit&&!e.linkedSandboxProject.lastUploadedCommit&&a.push("upload required"),r>0&&a.push(X1(r)),t.linkedSourceHeadCommit&&t.headCommit&&t.linkedSourceHeadCommit!==t.headCommit&&t.linkedSourceComparisonError&&r===0&&a.push("source changed"),t.changedFilesCount>0&&a.push(`${t.changedFilesCount} changed file${t.changedFilesCount===1?"":"s"}`),t.untrackedFilesCount>0&&a.push(`${t.untrackedFilesCount} untracked skipped`),a.length>0?a.join(" / "):"nothing to upload"}function m5(e){return e.linkedSourceHeadCommit?e.divergedFromLinkedSource?"diverged":e.aheadOfLinkedSource>0?nr("local ahead",e.aheadOfLinkedSource):e.behindLinkedSource>0?nr("cloud ahead",e.behindLinkedSource):e.linkedSourceComparisonError&&e.headCommit&&e.linkedSourceHeadCommit!==e.headCommit?"sync unknown":null:null}function p5(e){return e?.linkedSourceHeadCommit?e.dirty?"local dirty files not in cloud":e.divergedFromLinkedSource?"diverged from local":e.aheadOfLinkedSource>0?nr("cloud behind local",e.aheadOfLinkedSource):e.behindLinkedSource>0?nr("cloud ahead local",e.behindLinkedSource):e.linkedSourceComparisonError&&e.headCommit&&e.linkedSourceHeadCommit!==e.headCommit?"source check unavailable":"synced":null}function nr(e,t){return`${e} by ${X1(t)}`}function X1(e){return`${e} commit${e===1?"":"s"}`}function f5({size:e=14,className:t}){return x.jsxs("svg",{className:["lucide lucide-cloud-upload",t??""].filter(Boolean).join(" "),xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[x.jsx("path",{d:"M12 13v8"}),x.jsx("path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"}),x.jsx("path",{d:"m8 17 4-4 4 4"})]})}function eI({kind:e,linkedCloud:t=!1,open:n=!1,className:a,baseSize:r=15}){const i=e==="cloud"?"cloud":n?"folder-open":"folder";return x.jsx("span",{className:["project-kind-icon",e,t?"linked-cloud":"",a??""].filter(Boolean).join(" "),"aria-hidden":"true",children:x.jsxs("svg",{className:`lucide lucide-${i} project-kind-icon-svg`,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="cloud"?x.jsx(v5,{}):n?x.jsx(g5,{}):x.jsx(h5,{}),t&&e==="local"?x.jsx(b5,{}):null]})})}function h5(){return x.jsx("path",{className:"project-kind-icon-base",d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}function g5(){return x.jsx("path",{className:"project-kind-icon-base",d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"})}function v5(){return x.jsx("path",{className:"project-kind-icon-base",d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"})}function b5(){return x.jsxs("g",{className:"project-kind-icon-cloud-badge",children:[x.jsx("circle",{cx:"18",cy:"17",r:"5"}),x.jsx("path",{d:"M20.4 18.6h-4.2a2.2 2.2 0 1 1 2.08-2.9h.88a1.45 1.45 0 1 1 1.24 2.9Z"})]})}var pf=L_();function y5({title:e,pinned:t,savedForLater:n,archived:a,onRename:r,onTogglePin:i,onToggleSaveForLater:s,onDockRight:l,onArchive:m}){const u=g.useRef(null),h=g.useRef(null),[b,y]=g.useState(null),w=[...r?[{label:"Rename",Icon:Xd,action:r}]:[],{label:t?"Unpin":"Pin",Icon:t?ag:ng,action:i},...s?[{label:n?"Return to active":"Save for later",Icon:n?k1:x1,action:s}]:[],...l?[{label:"Open in right panel",Icon:nf,action:l}]:[],{label:a?"Reopen":"Mark done",Icon:a?pF:wo,action:m}];function _(E=!1){y(null),E&&u.current?.focus()}return g.useEffect(()=>{if(!b)return;h.current?.querySelector("button")?.focus();const E=P=>{!h.current?.contains(P.target)&&!u.current?.contains(P.target)&&y(null)},j=()=>y(null);return document.addEventListener("pointerdown",E),window.addEventListener("resize",j),()=>{document.removeEventListener("pointerdown",E),window.removeEventListener("resize",j)}},[b]),x.jsxs(x.Fragment,{children:[x.jsx("div",{className:`sidebar-row-actions sidebar-task-menu-trigger${b?" is-open":""}`,children:x.jsx("button",{ref:u,type:"button",className:"sidebar-row-action","aria-label":`More actions for task ${e}`,"aria-haspopup":"menu","aria-expanded":!!b,draggable:!1,onDoubleClick:E=>E.stopPropagation(),onClick:E=>{if(E.stopPropagation(),b){_(!0);return}const j=E.currentTarget.getBoundingClientRect();y({left:Math.max(8,Math.min(j.right-192,window.innerWidth-200)),top:Math.max(8,Math.min(j.bottom+4,window.innerHeight-(w.length*32+17)))})},children:x.jsx(Qd,{size:16})})}),b&&pf.createPortal(x.jsx("div",{ref:h,role:"menu","aria-label":`Actions for ${e}`,className:"sidebar-task-menu",style:b,onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),onBlur:E=>{E.currentTarget.contains(E.relatedTarget)||_()},onKeyDown:E=>{E.stopPropagation();const j=Array.from(E.currentTarget.querySelectorAll("button")),P=j.indexOf(document.activeElement);if(E.key==="Escape"&&(E.preventDefault(),_(!0)),["ArrowDown","ArrowUp","Home","End"].includes(E.key)){E.preventDefault();const L=E.key==="Home"?0:E.key==="End"?j.length-1:(P+(E.key==="ArrowDown"?1:-1)+j.length)%j.length;j[L]?.focus()}},children:w.map(({label:E,Icon:j,action:P},L)=>x.jsxs("button",{type:"button",role:"menuitem",className:L===w.length-1?"task-menu-done":void 0,onClick:()=>{_(!0),P()},children:[x.jsx(j,{size:15}),E]},E))}),document.body)]})}function S5({session:e,onSave:t,onClose:n}){const[a,r]=g.useState(e.title),i=g.useRef(null);g.useEffect(()=>{const m=i.current;m&&(m.focus(),m.select())},[]),g.useEffect(()=>{function m(u){u.key==="Escape"&&n()}return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n]);function s(){const m=a.trim();m&&(t(m),n())}function l(m){m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),s())}return x.jsx("div",{className:"git-dialog-backdrop rename-chat-backdrop",role:"presentation",onMouseDown:n,children:x.jsxs("section",{className:"git-dialog rename-chat-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rename-chat-title",onMouseDown:m=>m.stopPropagation(),children:[x.jsx("h2",{id:"rename-chat-title",children:"Rename chat"}),x.jsx("textarea",{ref:i,className:"rename-chat-input",value:a,rows:1,maxLength:200,onChange:m=>r(m.target.value),onKeyDown:l,"aria-label":"Chat title"}),x.jsxs("div",{className:"git-dialog-footer",children:[x.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:n,children:"Cancel"}),x.jsx("button",{type:"button",className:"git-dialog-primary",autoFocus:!0,onClick:s,disabled:!a.trim(),children:"Save"})]})]})})}const x5=24;function k5({title:e}){const t=g.useRef(e),[n,a]=g.useState(e);return g.useEffect(()=>{const r=t.current;if(t.current=e,!e){a("");return}if(r||window.matchMedia("(prefers-reduced-motion: reduce)").matches){a(e);return}const i=Array.from(e);let s=0;a("");const l=window.setInterval(()=>{s+=1,a(i.slice(0,s).join("")),s>=i.length&&window.clearInterval(l)},x5);return()=>window.clearInterval(l)},[e]),x.jsx("span",{className:"sidebar-task-title-text","aria-label":e||"New task",children:n||"New task"})}const w5=2650,I5=304,_5=260,C5=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}),R5=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit"}),P5=new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"});function A5(){return{animationDelay:`${-(Date.now()%w5)}ms`}}function T5(e){const t=e.currentTarget,n=t.firstElementChild;if(!(n instanceof HTMLElement))return;const a=Math.max(0,n.scrollWidth-t.clientWidth),r=a>2;t.dataset.overflowing=String(r),t.style.setProperty("--sidebar-title-ticker-distance",`${-a}px`),t.style.setProperty("--sidebar-title-ticker-duration",`${Math.min(6.5,Math.max(2.8,a/42+2.4))}s`)}function ay({label:e,actions:t,actionsVisible:n=!1,className:a,titleAccessory:r,children:i,collapsed:s=!1,titleActive:l=!1,onTitleClick:m,onToggleCollapsed:u}){return x.jsxs("section",{className:["sidebar-section",a,n?"actions-visible":""].filter(Boolean).join(" "),children:[x.jsxs("div",{className:"section-header",children:[x.jsxs("div",{className:"section-title-row",children:[m?x.jsxs("div",{className:"section-title-combo",children:[x.jsx("button",{type:"button",className:`section-title-link${l?" active":""}`,onClick:m,children:x.jsx("span",{children:e})}),u&&x.jsx("button",{type:"button",className:"section-chevron-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:s?x.jsx($r,{size:13}):x.jsx(zo,{size:13})})]}):u?x.jsxs("button",{type:"button",className:"section-title-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:[x.jsx("span",{children:e}),s?x.jsx($r,{size:13}):x.jsx(zo,{size:13})]}):x.jsx("span",{children:e}),r]}),t&&x.jsx("div",{className:"section-actions",children:t})]}),!s&&x.jsx("div",{className:"sidebar-section-body",children:i})]})}function oy({children:e,expanded:t=!1,onClick:n}){return x.jsx("button",{type:"button",className:"sidebar-show-more",onClick:n,children:e??(t?"Show less":"Show more")})}function op({session:e,selected:t,icon:n,archived:a=!1,hideIcon:r=!1,nested:i=!1,dragging:s,placeholder:l,running:m,goalRuntime:u,subagentRuntime:h,terminalIndicator:b,projectLabel:y,ariaDescribedBy:w,childSessionCount:_=0,childSessionsExpanded:E=!1,onSelect:j,onToggleChildSessions:P,onTogglePin:L,onToggleSaveForLater:$,onDockRight:O,onArchive:k,onDragStart:C,onDragEnd:A,onDragOver:z,onDrop:B,onRename:N}){const[K,de]=g.useState(!1),te=u?.status==="queued",Ie=u?.tone==="active"&&!te,xe=(h?.activeCount??0)>0,Z=_>0&&!!P,Ae=r&&!Z,he=xe||Ie||!te&&(m??e.status==="active"),ue=xe&&h?h.label:Ie&&u?M5(u):"Running",be=["sidebar-task-row",Il(e)?"is-draft":"",he?"has-running-dot":""].filter(Boolean).join(" "),ne=g.useMemo(A5,[]),ge=x.jsx(y5,{title:e.title,pinned:!!e.pinned,savedForLater:!!e.savedForLater,archived:a,onRename:N?()=>de(!0):void 0,onTogglePin:L,onToggleSaveForLater:$,onDockRight:O,onArchive:k}),ke=x.jsxs(Sg,{selected:t,dataSessionId:e.id,dragging:s,iconless:Ae,nested:i,placeholder:l,className:be||void 0,ariaExpanded:Z?E:void 0,ariaDescribedBy:w,onSelect:j,onDragStart:C,onDragEnd:A,onDragOver:z,onDrop:B,onDoubleClick:N?()=>de(!0):void 0,children:[Ae?null:Z?x.jsx("button",{type:"button",className:"sidebar-child-toggle","data-tooltip":E?"Hide subagent conversations":"Show subagent conversations","aria-label":`${E?"Hide":"Show"} ${_} subagent ${_===1?"conversation":"conversations"}`,"aria-expanded":E,onClick:Se=>{Se.stopPropagation(),P?.()},children:E?x.jsx(zo,{size:13}):x.jsx($r,{size:13})}):n??x.jsx(Yd,{size:15}),x.jsx("span",{className:"row-label-shell",title:y||void 0,children:x.jsx("span",{className:"sidebar-session-title-line",children:x.jsx("span",{className:"row-label sidebar-task-title","data-overflowing":"false",onPointerEnter:T5,children:x.jsx(k5,{title:e.title})})})}),x.jsxs("div",{className:"row-meta",children:[x.jsxs("span",{className:"row-meta-status",children:[b?x.jsx(tI,{indicator:b}):null,he?x.jsx("span",{className:`sidebar-running-dot${xe?" subagent":Ie?" goal":""}`,style:ne,"aria-label":ue}):null]}),ge]})]}),qe=K&&N?x.jsx(S5,{session:e,onSave:Se=>N(e,Se),onClose:()=>de(!1)}):null;return x.jsxs(x.Fragment,{children:[ke,qe]})}function E5({file:e,selected:t=!1,placeholder:n,onSelect:a,onTogglePin:r,onToggleSaveForLater:i,onDragStart:s,onDragEnd:l,onDragOver:m,onDrop:u}){const h=e.path.split("/").at(-1)??e.path,b=`${e.workspaceName} · ${e.path}`;return x.jsxs(Sg,{selected:t,placeholder:n,className:`sidebar-file-row actions-2${e.available?"":" unavailable"}`,onSelect:a,onDragStart:s,onDragEnd:l,onDragOver:m,onDrop:u,children:[e.available?x.jsx(tg,{size:15}):x.jsx(PF,{size:15}),x.jsx("span",{className:"row-label-shell",title:b,children:x.jsx("span",{className:"row-label",children:h})}),x.jsx("div",{className:"row-meta",children:x.jsxs("div",{className:"sidebar-row-actions",children:[x.jsx(ud,{label:e.status==="pinned"?"Unpin file":"Pin file",onClick:r,children:e.status==="pinned"?x.jsx(ag,{size:13}):x.jsx(ng,{size:13})}),x.jsx(ud,{label:e.status==="saved_for_later"?"Remove from Save for later":"Save file for later",onClick:i,children:e.status==="saved_for_later"?x.jsx(k1,{size:13}):x.jsx(x1,{size:13})})]})})]})}function M5(e){return e.actionLabel}function j5({kind:e="local",project:t,pinned:n=!1,selected:a,expanded:r=!1,disclosure:i=!0,workspaceState:s,cloudLinkTrusted:l=!0,cloudLinkWarning:m=null,placeholder:u,terminalIndicator:h,onSelect:b,onNewChat:y,onMoveToCloud:w,onWorkspaceTargetSelect:_,onTogglePin:E,onRemove:j,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:O}){const[k,C]=g.useState(!1),A=g.useRef(null),[z,B]=g.useState({}),N=!!w||!!j,K=e==="local"&&l!==!1&&!!t.linkedSandboxProject?.projectId,de=g.useCallback(()=>{if(typeof window>"u")return;const xe=A.current?.getBoundingClientRect();if(!xe)return;const Z=Math.max(12,window.innerWidth-I5-12),Ae=Math.max(12,window.innerHeight-_5),he=Math.max(12,Math.min(xe.right+10,Z)),ue=Math.max(12,Math.min(xe.top-4,Ae)),be={"--sidebar-project-locations-left":`${Math.round(he)}px`,"--sidebar-project-locations-top":`${Math.round(ue)}px`};B(ne=>ne["--sidebar-project-locations-left"]===be["--sidebar-project-locations-left"]&&ne["--sidebar-project-locations-top"]===be["--sidebar-project-locations-top"]?ne:be)},[]),te=g.useCallback(()=>{de(),b()},[b,de]);function Ie(){C(!1)}return x.jsxs("div",{ref:A,className:["sidebar-project-row-shell",k?"project-menu-open":""].filter(Boolean).join(" "),onFocusCapture:de,onPointerEnter:de,children:[x.jsxs(Sg,{selected:a,placeholder:u,className:["sidebar-project-row",k?"project-menu-open":""].filter(Boolean).join(" "),ariaExpanded:i?r:void 0,onSelect:te,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:O,children:[x.jsx(eI,{kind:e,linkedCloud:K,open:e==="local"&&r,className:"sidebar-row-icon",baseSize:15}),x.jsx("span",{className:"row-label-shell",children:x.jsxs("span",{className:"sidebar-project-title-line",children:[x.jsx("span",{className:"row-label",children:t.name}),x.jsx(O5,{value:t.updatedAt}),i?x.jsx("span",{className:"sidebar-project-caret","aria-hidden":"true",children:r?x.jsx(zo,{size:13}):x.jsx($r,{size:13})}):null]})}),x.jsxs("div",{className:"row-meta",children:[x.jsx("span",{className:"row-meta-status",children:h?x.jsx(tI,{indicator:h}):null}),x.jsxs("div",{className:"sidebar-row-actions",children:[x.jsx(ud,{label:n?"Unpin project":"Pin project",onClick:E,children:n?x.jsx(ag,{size:13}):x.jsx(ng,{size:13})}),N&&x.jsx(G5,{open:k,onToggleOpen:()=>C(xe=>!xe)}),x.jsx(ud,{label:"New task",onClick:y,children:x.jsx(Xd,{size:13})})]})]})]}),x.jsx(N5,{kind:e,project:t,workspaceState:s,cloudLinkTrusted:l,cloudLinkWarning:m,onWorkspaceTargetSelect:_,style:z}),k&&x.jsx(Z5,{onClose:Ie,onMoveToCloud:w?()=>{Ie(),w()}:void 0,onRemove:()=>{Ie(),j()}})]})}function O5({value:e}){const t=$5(e);if(!t||!e)return null;const n=new Date(e);return x.jsx("time",{className:"sidebar-row-updated-at",dateTime:e,title:`Last updated ${P5.format(n)}`,children:t})}function $5(e,t=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const a=R5.format(n);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?a:`${C5.format(n)} ${a}`}function tI({indicator:e}){return x.jsx("span",{className:`sidebar-terminal-indicator ${e.status}`,"data-tooltip":e.label,"aria-label":e.label,title:e.label,children:x.jsx(A1,{size:13})})}function N5({kind:e,project:t,workspaceState:n,cloudLinkTrusted:a,cloudLinkWarning:r,onWorkspaceTargetSelect:i,style:s}){const l=U5(e,t,n,a,r);return x.jsxs("aside",{className:"sidebar-project-locations-popover","aria-label":`${t.name} status`,style:s,children:[x.jsx("div",{className:"sidebar-project-locations-title",children:t.name}),x.jsx("div",{className:"sidebar-project-location-list",children:l.map(m=>{const u=["sidebar-project-location-row",m.tone??"",m.actionTarget?"clickable":""].filter(Boolean).join(" "),h=x.jsxs(x.Fragment,{children:[x.jsx("span",{className:["sidebar-project-location-icon",m.key].filter(Boolean).join(" "),"aria-hidden":"true",children:m.icon}),x.jsx("span",{className:"sidebar-project-location-copy",children:x.jsx(D5,{value:m.value})})]});return m.actionTarget?x.jsx("button",{type:"button",className:u,"data-workspace-target":m.actionTarget,disabled:m.disabled||!i,title:m.disabledReason??void 0,onClick:b=>{b.stopPropagation(),!m.disabled&&i?.(m.actionTarget)},children:h},m.key):x.jsx("div",{className:u,children:h},m.key)})})]})}function D5({value:e}){const t=L5(e);return x.jsxs("span",{className:"sidebar-project-location-value","aria-label":e,children:[t.branch?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"sidebar-project-location-branch",children:t.branch}),x.jsx("span",{className:"sidebar-project-location-separator","aria-hidden":"true",children:"/"})]}):null,x.jsx("span",{className:"sidebar-project-location-status",children:t.status})]})}function L5(e){const n=e.indexOf(" / ");return n===-1?{branch:null,status:e}:{branch:e.slice(0,n),status:e.slice(n+3)}}function U5(e,t,n,a=!0,r=null){return e==="cloud"?H5(t):z5(t,n,a,r)}function z5(e,t,n=!0,a=null){const r=q5(e,t,n),i=B5(t),s=V5(e,n),l=n===!1&&a;return[{key:"local",value:r,tone:i?"attention":"local",icon:e.source==="git"?x.jsx(_1,{size:13}):x.jsx(I1,{size:13}),actionTarget:"local"},{key:"cloud",value:l||(s?K5(e,t,n):"not in cloud"),tone:l?"attention":"cloud",icon:x.jsx(Jd,{size:13}),actionTarget:s?"cloud":"upload_cloud"}]}function H5(e){return[{key:"cloud",value:W5(e),tone:e.syncedAt?"cloud":"attention",icon:x.jsx(Jd,{size:13}),actionTarget:"cloud"}]}function q5(e,t,n){const a=F5(e,t);return t?t.error?`${a} / status unavailable`:t.initialized?Y1(t,{branch:e.linkedSandboxProject?.defaultBranch??null,linkedCloudSourceKnown:e.linkedSandboxProject?.projectId&&n?!!e.linkedSandboxProject.lastUploadedCommit||!t.headCommit:!0}):`${a} / not checked out`:`${a} / available`}function B5(e){return!!(e?.dirty||(e?.changedFilesCount??0)>0||(e?.untrackedFilesCount??0)>0)}function F5(e,t){return t?.currentBranch??t?.defaultBranch??e.linkedSandboxProject?.defaultBranch??"local"}function V5(e,t=!0){return!!(t&&e.linkedSandboxProject?.projectId||e.linkedOpenPondApp?.appId)}function K5(e,t,n){return Q1(e,null,t,{cloudLinkTrusted:n})}function W5(e){const t=e.defaultBranch??"main",n=e.syncedAt?"setup ready":"needs setup";return`${t} / ${n}`}function G5({open:e,onToggleOpen:t}){return x.jsx("button",{type:"button",className:`sidebar-row-action ${e?"active":""}`,"data-tooltip":"More project actions","aria-label":"More project actions","aria-haspopup":"menu","aria-expanded":e,onClick:n=>{n.stopPropagation(),t()},children:x.jsx(Qd,{size:13})})}function Z5({onClose:e,onMoveToCloud:t,onRemove:n}){return x.jsxs(x.Fragment,{children:[x.jsx("button",{type:"button",className:"sidebar-project-menu-backdrop","aria-label":"Close project actions",onClick:a=>{a.stopPropagation(),e()}}),x.jsxs("div",{className:"section-menu-popover sidebar-project-row-popover",role:"menu",children:[t&&x.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),t()},children:[x.jsx(f5,{size:13}),x.jsx("span",{children:"Move to Cloud"})]}),x.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),n()},children:[x.jsx(os,{size:13}),x.jsx("span",{children:"Remove from Projects"})]})]})]})}function Sg({children:e,className:t,dataSessionId:n,dragging:a,iconless:r=!1,nested:i=!1,placeholder:s=!1,selected:l,ariaExpanded:m,ariaDescribedBy:u,onSelect:h,onDragStart:b,onDragEnd:y,onDragOver:w,onDrop:_,onDoubleClick:E}){const j=!!b;return x.jsx("div",{className:["sidebar-row",t??"",l?"selected":"",a?"dragging":"",r?"iconless":"",i?"nested":"",s?"placeholder":""].filter(Boolean).join(" "),draggable:j,"data-session-id":n,role:"button",tabIndex:0,"aria-expanded":m,"aria-describedby":u,onClick:h,onDoubleClick:E,onKeyDown:P=>{P.target===P.currentTarget&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),h())},onDragStart:b,onDragEnd:y,onDragEnter:P=>{w&&(P.preventDefault(),P.dataTransfer.dropEffect="move",w(P))},onDragOver:P=>{w&&(P.preventDefault(),P.dataTransfer.dropEffect="move",w(P))},onDrop:P=>{_&&(P.preventDefault(),_(P))},children:e})}function ud({children:e,label:t,onClick:n}){return x.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":t,"aria-label":t,onClick:a=>{a.stopPropagation(),n()},children:e})}function J5({filter:e,groupByProject:t,noun:n,onFilterChange:a,onGroupByProjectChange:r,onOnlyRunningTasksChange:i,onShowCodexChatsChange:s,onTasksetChange:l,onSortChange:m,onlyRunningTasks:u,openMenu:h,setOpenMenu:b,showCodexChats:y,sort:w,selectedTasksetId:_,tasksets:E}){const j=g.useRef(null),[P,L]=g.useState(!1),O=E.find(A=>A.id===_)?.name??Jb.find(A=>A.value===e)?.label??"Active",k=h==="tasks-filter",C=h==="chats";return g.useEffect(()=>{if(!k&&!C)return;function A(z){j.current?.contains(z.target)||b(null)}return document.addEventListener("pointerdown",A),()=>document.removeEventListener("pointerdown",A)},[k,b,C]),x.jsxs("div",{className:"sidebar-task-list-controls",ref:j,children:[x.jsxs("div",{className:"section-menu",children:[x.jsx("button",{type:"button",className:`section-icon ${C?"active":""}`,"aria-label":`${n==="tasks"?"Task":"Chat"} list options`,"aria-haspopup":"menu","aria-expanded":C,onClick:()=>b(A=>A==="chats"?null:"chats"),children:x.jsx(Qd,{size:14})}),C?x.jsxs("div",{className:"section-menu-popover",role:"menu","aria-label":`${n==="tasks"?"Task":"Chat"} list options`,children:[x.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":y,onClick:()=>s(!y),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:y?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"Show Codex chats"})]}),x.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":u,onClick:()=>i(!u),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:u?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"Only running tasks"})]}),n==="tasks"?x.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":t,onClick:()=>r(!t),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:t?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"Group by project"})]}):null,e5.map(A=>x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w===A.value,onClick:()=>{m(A.value),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:w===A.value?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:A.label})]},A.value))]}):null]}),x.jsxs("div",{className:"section-menu",children:[x.jsx("button",{type:"button",className:`section-icon ${k?"active":""}`,"aria-label":`Filter ${n}: ${O}`,"aria-haspopup":"menu","aria-expanded":k,onClick:()=>b(A=>A==="tasks-filter"?null:"tasks-filter"),children:x.jsx(GF,{size:14})}),k?x.jsx("div",{className:"section-menu-popover",role:"menu","aria-label":`Filter ${n}`,children:Jb.map(A=>x.jsxs(g.Fragment,{children:[A.value==="tasksets"?x.jsxs("button",{type:"button",role:"menuitem","aria-expanded":P,onClick:()=>L(z=>!z),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:P?x.jsx(zo,{size:13}):x.jsx($r,{size:13})}),x.jsx("span",{children:A.label})]}):x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":e===A.value,onClick:()=>{a(A.value),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e===A.value?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:A.label})]}),A.value==="tasksets"&&P?x.jsxs(x.Fragment,{children:[x.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&!_,onClick:()=>{l(null),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&!_?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"All Tasksets"})]}),E.map(z=>x.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&_===z.id,onClick:()=>{l(z.id),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&_===z.id?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:z.name}),x.jsx("span",{className:"section-menu-option-count","aria-hidden":"true",children:z.chatCount})]},z.id))]}):null]},A.value))}):null]})]})}const Y5=240,Q5=36;function X5(e,t,n=!1){const a=Math.max(12,t.width-Y5-12),r=Math.max(12,t.height-Q5-(n?22:0)-12);return{"--sidebar-task-detail-left":`${Math.round(Math.max(12,Math.min(e.right+10,a)))}px`,"--sidebar-task-detail-top":`${Math.round(Math.max(12,Math.min(e.top-4,r)))}px`}}function e3({detail:e,onClose:t}){if(g.useEffect(()=>{if(!e||typeof window>"u")return;const r=l=>{l.key==="Escape"&&t()};let i=!1;const s=window.requestAnimationFrame(()=>{window.addEventListener("scroll",t,!0),i=!0});return window.addEventListener("keydown",r),()=>{window.cancelAnimationFrame(s),window.removeEventListener("keydown",r),i&&window.removeEventListener("scroll",t,!0)}},[e,t]),!e)return null;const n=new Date(e.updatedAt),a=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(n);return x.jsxs("aside",{id:e.descriptionId,className:"sidebar-task-detail-popover",style:e.style,role:"tooltip","aria-label":`Last updated for ${e.title}`,children:[x.jsx("time",{dateTime:e.updatedAt,children:a}),e.folderName?x.jsxs("div",{className:"sidebar-task-detail-folder",children:[x.jsx(I1,{size:13,"aria-hidden":"true"}),x.jsx("span",{children:e.folderName})]}):null]})}function t3({children:e,expanded:t,groupKey:n,kind:a,label:r,onToggle:i,onNewTask:s,onOpenProject:l,onRemoveProject:m,project:u}){const h=`sidebar-task-group-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,b=a==="draft"?tg:Yd,[y,w]=g.useState(!1),_=!!(s||l||m);return x.jsxs("section",{className:"sidebar-task-project-group",children:[x.jsxs("div",{className:`sidebar-task-project-group-header-shell${y?" menu-open":""}`,children:[x.jsxs("button",{type:"button",className:"sidebar-task-project-group-header","aria-controls":h,"aria-expanded":t,onClick:()=>{w(!1),i()},children:[u?x.jsx(eI,{kind:u.kind,linkedCloud:!!(u.kind==="local"&&u.project.linkedSandboxProject?.projectId),open:u.kind==="local"&&t,className:"sidebar-task-project-group-icon",baseSize:14}):x.jsx(b,{className:"sidebar-task-project-group-icon",size:14,"aria-hidden":"true"}),x.jsx("span",{className:"sidebar-task-project-group-name",children:r}),x.jsx("span",{className:"sidebar-task-project-group-caret","aria-hidden":"true",children:t?x.jsx(zo,{size:13}):x.jsx($r,{size:13})})]}),u&&_?x.jsxs("div",{className:"sidebar-task-project-group-actions",children:[l||m?x.jsx("button",{type:"button",className:`sidebar-row-action${y?" active":""}`,"data-tooltip":"More project actions","aria-label":"More project actions","aria-expanded":y,"aria-haspopup":"menu",onClick:()=>w(E=>!E),children:x.jsx(Qd,{size:13})}):null,s?x.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":"New task","aria-label":"New task",onClick:s,children:x.jsx(Xd,{size:13})}):null]}):null,y?x.jsxs(x.Fragment,{children:[x.jsx("button",{type:"button",className:"sidebar-task-project-group-menu-backdrop","aria-label":"Close project actions",onClick:()=>w(!1)}),x.jsxs("div",{className:"section-menu-popover sidebar-task-project-group-menu",role:"menu",children:[l?x.jsx("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),l()},children:x.jsx("span",{children:"Open project"})}):null,m?x.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),m()},children:[x.jsx(os,{size:13}),x.jsx("span",{children:"Remove from Projects"})]}):null]})]}):null]}),t?x.jsx("div",{id:h,className:"sidebar-task-project-group-content",children:e}):null]})}const n3={},a3=new Map,o3=new Map;function r3(e,t){return Math.min(Math.max(e,Cn)+uf,t)}function i3(e,t){const n=Math.max(Cn,Math.min(e,t));if(n<=Cn)return Cn;const a=Math.ceil((n-Cn)/uf);return Math.max(Cn,Cn+(a-1)*uf)}function s3(e,t){const n=new Map;for(const a of e){const r=t(a),i=n.get(r.key);i?i.sessions.push(a):n.set(r.key,{...r,sessions:[a]})}return[...n.values()]}function l3({activeSessions:e,archiveSession:t,archivedSessions:n,chatRowsVisibleCount:a,childSessionRowsByParentId:r={},cloudProjectRows:i,beginProjectChat:s,commitTaskDrop:l,commitTaskPreviewDrop:m,dockSessionRight:u,experience:h="work",goalRuntimeBySessionId:b=a3,localProjectRows:y,openSidebarFile:w,pinnedCollapsed:_,pinnedRows:E,previewTaskDrop:j,previewPinnedDrop:P,projectRows:L,renameSession:$,restoreSession:O,runningSessionIds:k,savedForLaterSessions:C,sectionMenuOpen:A,selectedProjectId:z,selectedSessionId:B,setChatRowsVisibleCount:N,setSectionMenuOpen:K,setSelectedAppId:de,setSelectedProjectId:te,setSelectedSessionId:Ie,setView:xe,sidebarProjectIdBySessionId:Z,startTaskDrag:Ae,startPinnedDrag:he,subagentRuntimeBySessionId:ue=o3,taskDragSessionId:be,taskPreviewSessionIds:ne,terminalSummaries:ge=n3,toggleSessionPinned:ke,toggleSessionSavedForLater:qe,view:Se,clearTaskDrag:ie,removeProject:we,toggleProjectPinned:Oe,onTogglePinnedCollapsed:Qe,setSidebarFileStatus:Ge,commitPinnedDrop:st,commitPinnedPreviewDrop:Le,clearSidebarDrag:Fe,dragItem:De}){const[D,M]=g.useState("active"),[H,Q]=g.useState("manual"),[me,_e]=g.useState(h!=="chat"),[$e,Xe]=g.useState(ty);Kl(()=>Xe(ty()));const{onlyRunningTasks:et,showCodexChats:rt}=$e,[it,Me]=g.useState(null),[Be,p]=g.useState(()=>new Set),[U,V]=g.useState(()=>new Map),[le,re]=g.useState(null),F=h==="chat"?"chats":"tasks",I=h==="chat"?"Chats":"Tasks",W=L??[...y,...i],X=g.useMemo(()=>new Map(W.map(ae=>[ae.id,ae.project.name])),[W]),oe=g.useMemo(()=>new Map(W.map(ae=>[ae.id,ae])),[W]),G=g.useMemo(()=>{const ae=new Set(k);for(const Ke of e){const ze=b.get(Ke.id),Ze=ue.get(Ke.id);(ze?.tone==="active"&&ze.status!=="queued"||(Ze?.activeCount??0)>0||yt(Ke.id)?.status==="running")&&ae.add(Ke.id)}return ae},[e,b,k,ue,ge]),pe=g.useMemo(()=>e.filter(ae=>tr(ae)===null&&bi(ae,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[e,G,et,rt]),fe=g.useMemo(()=>C.filter(ae=>tr(ae)===null&&bi(ae,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,C,rt]),je=Math.max(0,pe.length-fe.length),Ee=t5({activeCount:je,filter:D,savedForLaterCount:fe.length}),Ne=g.useMemo(()=>Yb({activeSessions:e,doneSessions:n,filter:"all",inProgressSessionIds:G,sort:"manual"}),[e,n,G]),Ve=g.useMemo(()=>Yb({activeSessions:e,doneSessions:n,filter:D,inProgressSessionIds:G,onlyRunningTasks:et,selectedTasksetId:it,previewSessionIds:ne,showCodexChats:rt,sort:H}),[e,n,G,et,it,rt,D,ne,H]),Ue=g.useMemo(()=>{const ae=new Map;for(const Ke of[...e,...n]){if(!bi(Ke,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))continue;const ze=tr(Ke);if(!ze)continue;const Ze=ae.get(ze.id);Ze?Ze.chatCount+=1:ae.set(ze.id,{...ze,chatCount:1})}return[...ae.values()].sort((Ke,ze)=>Ke.name.localeCompare(ze.name))},[e,n,G,et,rt]),ut=g.useMemo(()=>E.filter(ae=>ae.type!=="session"||bi(ae.session,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,E,rt]),Qt=g.useMemo(()=>Ve.filter(ae=>!sl(ae)).slice(0,Math.max(Cn,a)),[a,Ve]),Lt=g.useMemo(()=>s3(Qt,ae=>{if(Il(ae))return{key:"draft",label:"Drafts",projectId:null,project:null,kind:"draft"};const Ke=Z[ae.id],ze=sn(ae)??"No project";return{key:Ke?`project:${Ke}`:`projectless:${ze}`,label:ze,projectId:Ke??null,project:Ke?oe.get(Ke)??null:null,kind:Ke?"project":"projectless"}}),[X,oe,Z,Qt]),An=Qt.length<Ve.length,Sn=Qt.length>Cn,nn=g.useMemo(()=>new Set(Lt.filter(ae=>ae.sessions.some(Ke=>Ke.id===B||G.has(Ke.id))).map(ae=>ae.key)),[Lt,G,B]),bt=Ne.filter(ae=>!sl(ae)).map(ae=>ae.id),rn=Qt.map(ae=>ae.id),Nt=JSON.stringify(Object.entries(r).filter(([ae,Ke])=>Ke.length>0&&(ue.get(ae)?.activeCount??0)>0).flatMap(([ae,Ke])=>Ke.map(ze=>[ae,ze.id])).sort(([ae,Ke],[ze,Ze])=>ae.localeCompare(ze)||Ke.localeCompare(Ze)));g.useEffect(()=>{const ae=JSON.parse(Nt);if(ae.length===0)return;const Ke=new Set(ae.map(([ze])=>ze));p(ze=>[...Ke].every(Ze=>ze.has(Ze))?ze:new Set([...ze,...Ke]))},[Nt]);function yt(ae){return c5(ge[J1({kind:"session",id:ae})])}function sn(ae){if(Il(ae))return"Draft";const Ke=Z[ae.id];return Ke?X.get(Ke)??ae.workspaceName??"Project":G4(ae)}function Ut(ae){ln({kind:"chat",sessionId:ae.id}),Ie(ae.id);const Ke=Z[ae.id]??null;de(Ke?null:ae.appId),te(Ke),xe("chat")}function mn(ae){return(r[ae.id]??[]).filter(Ke=>bi(Ke,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))}function On(ae,Ke){return Be.has(ae.id)||Ke.some(ze=>ze.id===B)}function gn(ae){p(Ke=>{const ze=new Set(Ke);return ze.has(ae)?ze.delete(ae):ze.add(ae),ze})}function Da(ae){const Ke=mn(ae);return Ke.length===0||!On(ae,Ke)?null:x.jsx("div",{className:"sidebar-child-session-group",children:Ke.map(ze=>x.jsx(op,{session:ze,selected:Se==="chat"&&B===ze.id,hideIcon:!0,nested:!0,running:G.has(ze.id),goalRuntime:b.get(ze.id)??null,subagentRuntime:ue.get(ze.id)??null,terminalIndicator:yt(ze.id),projectLabel:sn(ae),onSelect:()=>Ut(ze),onTogglePin:()=>ke(ze),onToggleSaveForLater:()=>qe(ze),onDockRight:()=>u(ze),onArchive:()=>ze.archived?O(ze):t(ze),onRename:$},ze.id))})}function ia(ae,Ke){if(typeof window>"u")return;const ze=sl(ae)?sn(ae):null;re({descriptionId:`sidebar-task-detail-${ae.id}`,sessionId:ae.id,title:ae.title,updatedAt:ae.updatedAt,folderName:ze,style:X5(Ke.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight},!!ze)})}function qt(ae,Ke={}){const ze=ae.archived,Ze=be===ae.id,xt=mn(ae),gt="sidebar-session-group",lt=H==="manual"?{onDragStart:Ct=>Ae(Ct,{allSessionIds:bt,visibleSessionIds:rn,sessionId:ae.id}),onDragEnd:ie,onDragOver:Ct=>{Ze||j(Ct,ae.id)},onDrop:Ct=>{Ze?m():l(Ct,ae.id)}}:{};return x.jsxs("div",{className:gt,onPointerEnter:Ct=>ia(ae,Ct.currentTarget),onPointerLeave:()=>re(null),onFocusCapture:Ct=>ia(ae,Ct.currentTarget),onBlurCapture:Ct=>{Ct.currentTarget.contains(Ct.relatedTarget)||re(null)},children:[x.jsx(op,{session:ae,selected:!ze&&Se==="chat"&&B===ae.id,archived:ze,hideIcon:!0,placeholder:Ze,running:G.has(ae.id),goalRuntime:b.get(ae.id)??null,subagentRuntime:ue.get(ae.id)??null,terminalIndicator:yt(ae.id),projectLabel:Ke.projectLabel===void 0?sn(ae):Ke.projectLabel,metadataPresentation:Ke.metadataPresentation,ariaDescribedBy:le?.sessionId===ae.id?le.descriptionId:void 0,childSessionCount:xt.length,childSessionsExpanded:On(ae,xt),onToggleChildSessions:()=>gn(ae.id),onSelect:()=>{re(null),ze&&O(ae),Ut(ae)},onTogglePin:()=>ke(ae),onToggleSaveForLater:()=>qe(ae),onDockRight:()=>u(ae),onArchive:()=>ze?O(ae):t(ae),onRename:$,...lt}),Ze?null:Da(ae)]},ae.id)}function qn(ae){ae!=="tasksets"&&Me(null),M(ae),N(Cn)}function ot(ae){Me(ae),M("tasksets"),N(Cn)}function xn(ae){Q(ae),N(Cn)}function La(){N(ae=>r3(ae,Ve.length))}function Ua(){N(ae=>i3(ae,Ve.length))}function sa(ae){const Ke={id:ae.id,type:ae.type};return{onDragStart:ze=>he(ze,Ke),onDragEnd:Fe,onDragOver:ze=>P(ze,Ke),onDrop:ze=>{De?.id===ae.id&&De.type===ae.type?Le():st(ze,Ke)}}}function za(ae){const Ke=sa(ae),ze=De?.id===ae.id&&De.type===ae.type;if(ae.type==="project"){const xt=ae.item;return x.jsx(j5,{kind:xt.kind,project:xt.project,pinned:!0,selected:Se==="chat"&&z===xt.id,expanded:!1,disclosure:!1,placeholder:ze,onSelect:()=>{de(null),te(xt.id),Ie(null),xe("chat")},onNewChat:()=>s(xt.id),onTogglePin:()=>Oe(xt),onRemove:()=>we(xt),...Ke},ae.key)}if(ae.type==="file")return x.jsx(E5,{file:ae.file,placeholder:ze,onSelect:()=>w(ae.file),onTogglePin:()=>Ge(ae.file,"none"),onToggleSaveForLater:()=>Ge(ae.file,"saved_for_later"),...Ke},ae.key);const Ze=ae.session;return x.jsx("div",{onPointerEnter:xt=>ia(Ze,xt.currentTarget),onPointerLeave:()=>re(null),onFocusCapture:xt=>ia(Ze,xt.currentTarget),onBlurCapture:xt=>{xt.currentTarget.contains(xt.relatedTarget)||re(null)},children:x.jsx(op,{ariaDescribedBy:le?.sessionId===Ze.id?le.descriptionId:void 0,session:Ze,selected:Se==="chat"&&B===Ze.id,hideIcon:!0,placeholder:ze,running:G.has(Ze.id),goalRuntime:b.get(Ze.id)??null,subagentRuntime:ue.get(Ze.id)??null,terminalIndicator:yt(Ze.id),projectLabel:sn(Ze),metadataPresentation:"flyout",onSelect:()=>{re(null),Ut(Ze)},onTogglePin:()=>ke(Ze),onToggleSaveForLater:()=>qe(Ze),onDockRight:()=>u(Ze),onArchive:()=>t(Ze),onRename:$,...Ke})},ae.key)}return x.jsxs("div",{className:"sidebar-scroll",children:[x.jsxs(ay,{label:I,className:`sidebar-task-section${h!=="chat"?" development":""}`,titleAccessory:h!=="chat"?x.jsx("div",{className:"sidebar-task-mode-buttons",children:x.jsxs("button",{type:"button",className:`section-icon sidebar-task-count-bubble${D==="saved_for_later"?" active":""}`,"aria-label":`Show ${Ee.count} ${Ee.targetLabel} ${Ee.count===1?"task":"tasks"}`,onClick:()=>qn(Ee.targetFilter),children:[x.jsx("span",{children:Ee.label}),x.jsx("span",{className:"sidebar-task-count-badge","aria-hidden":"true",children:Ee.count>99?"99+":Ee.count})]})}):null,actionsVisible:A==="chats"||A==="tasks-filter",actions:x.jsx(J5,{filter:D,groupByProject:me,noun:F,onFilterChange:qn,onGroupByProjectChange:_e,onOnlyRunningTasksChange:ae=>{Xe(Ke=>{const ze={...Ke,onlyRunningTasks:ae};return ny(ze),ze}),N(Cn)},onShowCodexChatsChange:ae=>{Xe(Ke=>{const ze={...Ke,showCodexChats:ae};return ny(ze),ze}),N(Cn)},onTasksetChange:ot,onSortChange:xn,onlyRunningTasks:et,openMenu:A,setOpenMenu:K,showCodexChats:rt,sort:H,selectedTasksetId:it,tasksets:Ue}),children:[ut.length>0?x.jsx(ay,{label:"Pinned",className:"sidebar-pinned-section",collapsed:_,onToggleCollapsed:Qe,children:ut.map(za)}):null,me&&h!=="chat"?Lt.map(ae=>{const Ke=nn.has(ae.key)||U.get(ae.key)!==!1;return x.jsx(t3,{expanded:Ke,groupKey:ae.key,kind:ae.kind,label:ae.label,onToggle:()=>{V(ze=>{const Ze=new Map(ze);return Ze.set(ae.key,!Ke),Ze})},onNewTask:ae.project?()=>s(ae.project.id):void 0,onOpenProject:ae.project?()=>{de(null),te(ae.project.id),Ie(null),xe("chat")}:void 0,onRemoveProject:ae.project?()=>we(ae.project):void 0,project:ae.project,children:ae.sessions.map(ze=>qt(ze,{metadataPresentation:"flyout",projectLabel:ae.label}))},ae.key)}):Qt.map(ae=>qt(ae)),Ve.length===0?x.jsx("div",{className:"empty-row",children:n5(D,F)}):null,Ve.length>Cn&&(An||Sn)?x.jsxs("div",{className:"sidebar-pagination-controls","aria-label":`Showing ${Qt.length} of ${Ve.length} ${F}`,children:[An?x.jsx(oy,{onClick:La,children:"Show more"}):null,Sn?x.jsx(oy,{onClick:Ua,children:"Show less"}):null]}):null]}),x.jsx(e3,{detail:le,onClose:()=>re(null)})]})}const c3="/";function Jn(e){return`${c3}${e.replace(/^\.?\//,"")}`}const d3=Jn("openpond-icon.png"),u3=Jn("openpond-wordlogo-white.png"),fJ=Jn("tutorials/what-is-an-openpond-agent-poster.png"),hJ=Jn("tutorials/what-is-an-openpond-agent.vtt"),gJ=Jn("tutorials/how-to-make-an-agent-poster.png"),vJ=Jn("tutorials/how-to-make-an-agent.vtt");function bJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}-poster.png`)}function yJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}.vtt`)}const ry={github:Jn("connected-apps/github.svg"),google:Jn("connected-apps/google.svg"),microsoft_teams:Jn("connected-apps/microsoft.svg"),mcp:Jn("connected-apps/openpond-mcp.svg"),slack:Jn("connected-apps/slack.svg"),x:Jn("connected-apps/x.svg")};function SJ(e){return ry[e]??ry.mcp}function m3({value:e,onChange:t}){const[n,a]=g.useState(!1),r=g.useRef(null),i=g.useRef(null),s=g.useRef(null),l=g.useRef(null),m=Xm.find(y=>y.value===e)??Xm[0];g.useEffect(()=>{if(!n)return;const y=_=>{_.target instanceof Node&&!r.current?.contains(_.target)&&a(!1)},w=()=>a(!1);return window.addEventListener("pointerdown",y),window.addEventListener("blur",w),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("blur",w)}},[n]),g.useLayoutEffect(()=>{n&&l.current&&iy(s.current,l.current),l.current=null},[n]);const u=y=>{if(n){iy(s.current,y);return}l.current=y,a(!0)},h=y=>{y.key==="ArrowDown"?(y.preventDefault(),u("first")):y.key==="ArrowUp"&&(y.preventDefault(),u("last"))},b=y=>{const w=nI(s.current),_=w.findIndex(P=>P===document.activeElement);if(y.key==="Escape"){y.preventDefault(),a(!1),i.current?.focus();return}if(y.key==="Home"||y.key==="End"){y.preventDefault(),w[y.key==="Home"?0:w.length-1]?.focus();return}if(y.key!=="ArrowDown"&&y.key!=="ArrowUp")return;y.preventDefault();const E=y.key==="ArrowDown"?1:-1,j=_<0?0:(_+E+w.length)%w.length;w[j]?.focus()};return x.jsxs("div",{className:"sidebar-experience-menu",ref:r,children:[x.jsxs("button",{ref:i,type:"button",className:"sidebar-wordmark-button sidebar-experience-trigger","aria-label":`OpenPond product: ${m.label}`,"aria-haspopup":"menu","aria-expanded":n,onClick:()=>{l.current=null,a(y=>!y)},onKeyDown:h,children:[x.jsx("img",{className:"sidebar-wordmark",src:u3,alt:""}),x.jsx("span",{className:"sidebar-experience-label",children:m.label}),x.jsx(zo,{size:13,"aria-hidden":"true"})]}),n?x.jsx("div",{ref:s,className:"sidebar-experience-popover",role:"menu","aria-label":"Choose product",onKeyDown:b,children:Xm.map(y=>{const w=y.value===e;return x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w,className:w?"active":"","data-product-area":y.value,onClick:()=>{a(!1),w||t(y.value)},children:[x.jsxs("span",{children:[x.jsx("strong",{children:y.label}),x.jsx("small",{children:y.description})]}),w?x.jsx(wo,{size:14,"aria-hidden":"true"}):null]},y.value)})}):null]})}function nI(e){return e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[]}function iy(e,t){const n=nI(e);(t==="first"?n[0]:n.at(-1))?.focus()}function p3(...e){for(const t of e){const n=t?.trim();if(n)return n}return null}function f3(e){const t=e?.accounts.find(s=>s.isActive)??null,n=e?.profile??null,a=e?.activeProfile?.handle??null;return{label:(e?.state==="signed_in"?p3(e?.label,n?.handle,n?.name,n?.email,t?.displayLabel,t?.handle,a,e?.email,"Signed in"):e?.state==="loading"||e?.state==="switching"?"Loading account":"Sign in")??"Account",image:e?.avatarUrl??n?.image??t?.avatarUrl??null}}function h3({account:e,open:t,organizations:n,selectedTeamId:a,onOpenActivity:r,onOpenChange:i,onOpenSettings:s,onSelectTeam:l,onLogOut:m}){const[u,h]=g.useState(null),[b,y]=g.useState(!1),w=g.useRef(null),_=g.useMemo(()=>f3(e),[e]),E=_.label.trim().slice(0,1).toUpperCase(),j=n.find(P=>P.teamId===a)??n[0]??null;return g.useEffect(()=>{if(!t)return;function P($){w.current?.contains($.target)||i(!1)}function L($){$.key==="Escape"&&i(!1)}return document.addEventListener("pointerdown",P),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",L)}},[i,t]),x.jsxs("div",{className:"user-auth-footer",ref:w,children:[x.jsxs("button",{type:"button",className:`user-auth-trigger ${t?"active":""}`,"aria-haspopup":"menu","aria-expanded":t,"aria-label":`${_.label} account menu`,onClick:()=>i(!t),children:[x.jsx("span",{className:"user-auth-avatar","aria-hidden":"true",children:_.image?x.jsx("img",{src:_.image,alt:""}):E?x.jsx("span",{children:E}):x.jsx(Bb,{size:16})}),x.jsx("span",{className:"user-auth-name",children:_.label})]}),t?x.jsxs("div",{className:"user-auth-menu",role:"menu","aria-label":"Account",children:[x.jsxs("div",{className:"user-auth-menu-header",children:[x.jsx("span",{className:"user-auth-menu-avatar","aria-hidden":"true",children:_.image?x.jsx("img",{src:_.image,alt:""}):E?x.jsx("span",{children:E}):x.jsx(Bb,{size:17})}),x.jsx("span",{className:"user-auth-menu-identity",children:x.jsx("strong",{children:_.label})})]}),n.length>0&&l?x.jsxs("label",{className:"user-auth-team-picker",children:[x.jsx(P1,{size:15,"aria-hidden":"true"}),x.jsx("span",{className:"user-auth-team-picker-label",children:"Team"}),x.jsx("select",{"aria-label":"Active team",disabled:u!==null,value:j?.teamId??"",onChange:async P=>{const L=P.currentTarget.value;h(L);try{await l(L)}catch{}finally{h(null)}},children:n.map(P=>x.jsx("option",{value:P.teamId,children:P.displayName},P.teamId))})]}):null,x.jsx("div",{className:"user-auth-menu-divider"}),r?x.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),r()},children:[x.jsx(w1,{size:15}),x.jsx("span",{children:"Activity"})]}):null,x.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),s()},children:[x.jsx(og,{size:15}),x.jsx("span",{children:"Settings"})]}),e?.state==="signed_in"&&m?x.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",disabled:b,onClick:async()=>{y(!0);try{await m(),i(!1)}catch{}finally{y(!1)}},children:[x.jsx(l4,{size:15}),x.jsx("span",{children:b?"Logging out…":"Log out"})]}):null]}):null]})}function sy(e){const t=/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e?.trim()??"");return t?[Number.parseInt(t[1],10),Number.parseInt(t[2],10),Number.parseInt(t[3],10)]:null}function g3(e,t){const n=sy(e),a=sy(t);if(!n||!a)return!1;for(let r=0;r<a.length;r+=1){if(a[r]>n[r])return!0;if(a[r]<n[r])return!1}return!1}function aI(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")?"mac":t==="linux"||t.includes("linux")?"linux":null}function v3(e){const t=e?.toLowerCase()??"";return t==="arm64"||t==="aarch64"?"arm64":t==="x64"||t==="x86_64"||t==="amd64"?"x64":null}function b3(e,t,n){const a=aI(t),r=v3(n);if(a==="mac"){const i=e.filter(s=>/-mac-.*\.zip$/i.test(s.name));return r==="arm64"?i.find(s=>/-mac-arm64\.zip$/i.test(s.name))??null:r==="x64"?i.find(s=>/-mac-x64\.zip$/i.test(s.name))??i.find(s=>/-mac-universal\.zip$/i.test(s.name))??null:i.find(s=>/-mac-universal\.zip$/i.test(s.name))??i.find(s=>/-mac-arm64\.zip$/i.test(s.name))??i[0]??null}if(a==="linux"){const i=e.filter(s=>/\.AppImage$/i.test(s.name));return r==="arm64"?i.find(s=>/(?:arm64|aarch64).*\.AppImage$/i.test(s.name))??null:r==="x64"?i.find(s=>/(?:x86_64|x64|amd64).*\.AppImage$/i.test(s.name))??i[0]??null:i[0]??null}return null}function y3(e){if(!e.payload||typeof e.payload!="object")return null;const t=e.payload,a=(typeof t.tag_name=="string"?t.tag_name.trim():"").replace(/^v/,"");if(!g3(e.currentVersion,a))return null;const r=typeof t.html_url=="string"?t.html_url:"",s=(Array.isArray(t.assets)?t.assets:[]).flatMap(m=>{if(!m||typeof m!="object")return[];const u=m;return typeof u.name!="string"||typeof u.browser_download_url!="string"?[]:[{name:u.name,downloadUrl:u.browser_download_url}]}),l=b3(s,e.platform,e.arch);return!l||!r?null:{version:a,releaseUrl:r,assetName:l.name,downloadUrl:l.downloadUrl}}const S3=3600*1e3,x3="https://api.github.com/repos/openpond/openpond/releases/latest";function k3(e){const[t,n]=g.useState({status:"idle",update:null,lastCheckedAt:null}),a=e.currentVersion?.trim()??"",r=e.platform??"",i=e.arch??"",s=e.enabled&&!!a&&!!aI(r);return g.useEffect(()=>{if(!s){n({status:"idle",update:null,lastCheckedAt:null});return}let l=!1;async function m(){n(h=>({...h,status:h.update?"available":"checking"}));try{const h=await fetch(x3,{headers:{Accept:"application/vnd.github+json"}});if(!h.ok)throw new Error(`GitHub release check failed: ${h.status}`);const b=await h.json(),y=y3({payload:b,currentVersion:a,platform:r,arch:i});if(l)return;n({status:y?"available":"current",update:y,lastCheckedAt:Date.now()})}catch{if(l)return;n(h=>({status:h.update?"available":"error",update:h.update,lastCheckedAt:Date.now()}))}}m();const u=window.setInterval(()=>{m()},S3);return()=>{l=!0,window.clearInterval(u)}},[i,a,s,r]),t}const oI="openpond.sidebar.continuous-learning.dismissed.v1";function ly(e=rI()){if(!e)return!1;try{return e.getItem(oI)==="true"}catch{return!1}}function w3(e=rI()){if(e)try{e.setItem(oI,"true")}catch{}}function rI(){return typeof window>"u"?null:Wl}function I3({connection:e,onOpenSettings:t}){const[n,a]=g.useState(null),[r,i]=g.useState(ly);Kl(()=>i(ly()));const s=g.useCallback(async()=>{if(!e){a(null);return}try{a(await J.harnessHistory(e))}catch{a(null)}},[e]);if(g.useEffect(()=>{s()},[s]),r||!e||!n?.workspace)return null;const l=n.evaluationReviewSchedule,m=l.activityEnabled?`${l.activityBatchSize} outcomes${l.enabled?` + ${l.cadence}`:""}`:l.enabled?l.cadence:"Manual";return x.jsxs("section",{className:"sidebar-learning-notice","aria-label":"Continuous learning",children:[x.jsxs("header",{children:[x.jsx("strong",{children:"Continuous learning"}),x.jsxs("div",{className:"sidebar-learning-notice-actions",children:[x.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Open Continuous learning settings",onClick:t,type:"button",children:x.jsx(og,{size:14})}),x.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Close continuous learning",onClick:()=>{i(!0),w3()},type:"button",children:x.jsx(os,{size:14})})]})]}),x.jsxs("div",{className:"sidebar-learning-status",children:[x.jsx("strong",{children:"Refiner"}),x.jsx("span",{children:n.backgroundReview.enabled?"On":"Off"})]}),x.jsxs("div",{className:"sidebar-learning-status",children:[x.jsx("strong",{children:"Continuous Review"}),x.jsx("span",{children:m})]})]})}function _3(e){const[t,n]=g.useState(!1),{beginNewChat:a,arch:r,currentVersion:i,experience:s,productArea:l,onProductAreaChange:m,onSidebarResizeStart:u,platform:h,setSectionMenuOpen:b,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setSidebarOpen:E,setView:j,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}=e,O=g.useCallback(z=>{n(!1),b(z)},[b]),k=g.useCallback(z=>{n(z),z&&b(null)},[b]),C=k3({currentVersion:i,platform:h,arch:r,enabled:eu()}),A=C.status==="available"?C.update:null;return x.jsxs("aside",{className:"sidebar",children:[x.jsxs("div",{className:"sidebar-toolbar",children:[x.jsx("button",{className:"sidebar-icon","aria-label":"Hide sidebar",onClick:()=>E(!1),children:x.jsx(R1,{size:16})}),x.jsx(m3,{value:l,onChange:m}),A&&x.jsxs("button",{type:"button",className:"sidebar-update-pill",title:`Download OpenPond ${A.version}: ${A.assetName}`,"aria-label":`Download OpenPond ${A.version}`,onClick:()=>{C3(A.downloadUrl)},children:[x.jsx(jF,{size:14}),x.jsx("span",{children:"Update"})]})]}),x.jsx(j4,{productArea:l,experience:s,beginNewChat:a,setSectionMenuOpen:O,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:j,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}),l==="models"?null:x.jsx(l3,{...e,setSectionMenuOpen:O}),x.jsxs("div",{className:"sidebar-bottom-stack",children:[l==="models"?null:x.jsx(I3,{connection:e.connection,onOpenSettings:()=>{b(null),ln({kind:"settings",section:"harness"})}}),x.jsxs("div",{className:"sidebar-footer-row",children:[x.jsx(h3,{account:e.account,open:t,organizations:e.organizations,selectedTeamId:e.teamChatOrganization?.teamId??null,onOpenChange:k,onOpenActivity:()=>{b(null),ln({kind:"settings",section:"usage"})},onOpenSettings:()=>{b(null),ln({kind:"settings",section:"account"})},onSelectTeam:e.onSelectTeam,onLogOut:e.onLogOut}),x.jsx(O4,{setSectionMenuOpen:O,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:j,view:P})]})]}),x.jsx("div",{className:"sidebar-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:u})]})}async function C3(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-update",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const R3=[/^(?:(?:type)?error:\s*)?failed to fetch\.?$/i,/^networkerror when attempting to fetch resource\.?$/i,/^load failed\.?$/i];function iI(e,t="Something went wrong."){const a=(e instanceof Error?e.message:String(e??"")).trim();return a?sI(a)?"Couldn’t connect to OpenPond.":a:t}function sI(e){const t=e.trim();return R3.some(n=>n.test(t))}const lI=g.createContext(null);function cy({children:e,showToast:t}){return x.jsx(lI.Provider,{value:t,children:e})}function P3(){return g.useContext(lI)}function dy(e,t={}){const n=P3(),a=g.useRef(null),r=t.enabled??!0,i=t.fallback??"Something went wrong.",s=t.prefix?.trim()??"",l=e==null||e===""?null:`${s}${s?": ":""}${iI(e,i)}`;g.useEffect(()=>{if(!r||!l){a.current=null;return}a.current!==l&&(a.current=l,n?.(l,"error",{dismissible:!0}))},[r,l,n])}function A3({state:e,onClose:t,onOpenBrowserUrl:n,onStart:a}){if(dy(e?.previewError,{prefix:"Upload preview"}),dy(e?.error,{prefix:"Cloud setup"}),!e)return null;const r=e.status==="uploading",i=e.status==="ready",s=e.status==="error",l=e.projectKind==="cloud",m=e.preview??null;return x.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:x.jsxs("section",{className:"git-dialog cloud-setup-dialog",role:"dialog","aria-modal":"true","aria-label":"Set up Cloud coding",children:[x.jsx("button",{className:"git-dialog-close",disabled:r,type:"button",onClick:t,"aria-label":"Close Cloud setup",title:"Close",children:x.jsx(os,{size:14})}),x.jsx("div",{className:"git-dialog-icon",children:i?x.jsx(tf,{size:18}):x.jsx(Jd,{size:18})}),x.jsx("h2",{children:i?"Cloud repo ready":"Set up Cloud coding"}),x.jsx("p",{children:i?"Your source is ready in OpenPond Git. Finish by creating the Cloud sandbox environment.":l?"This Cloud Project is ready for a sandbox environment.":"OpenPond will upload tracked and unignored files into OpenPond Git, then send you to the Cloud sandbox setup page."}),x.jsxs("div",{className:"cloud-setup-summary",children:[x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Project"}),x.jsx("strong",{children:e.projectName})]}),x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Source"}),x.jsx("strong",{children:l?"OpenPond Git":"Local project upload"})]}),x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Branch"}),x.jsx("strong",{children:m?.branch??e.branch??"main"})]}),!l&&x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Cloud project"}),x.jsx("strong",{children:m?.targetProjectId??e.cloudProjectId??"New on upload"})]})]}),!i&&!l&&x.jsx("div",{className:"cloud-setup-upload-preview",role:"status","aria-live":"polite",children:e.previewLoading?x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Calculating upload preview"}),x.jsx("span",{children:"Checking tracked and unignored files before anything is pushed."})]}):e.previewError?x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Preview unavailable"}),x.jsx("span",{children:"Close and reopen setup to try the preview again."})]}):m?x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:m.initializedEmptyProject?"Will initialize an empty project":`Will upload ${m.fileCount} files`}),x.jsx("span",{children:uy({byteCount:m.byteCount,skippedCount:m.skippedCount,headCommit:m.headCommit,targetProjectName:m.targetProjectName})})]}):x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Upload preview pending"}),x.jsx("span",{children:"File count, byte count, and skipped files will appear here before upload."})]})}),r&&x.jsxs("div",{className:"cloud-setup-progress",role:"status","aria-live":"polite",children:[x.jsx(JF,{className:"cloud-setup-spinner",size:16}),x.jsx("span",{children:"Uploading source to OpenPond Git..."})]}),i&&e.upload&&x.jsxs("div",{className:"cloud-setup-upload-result",children:[x.jsx("strong",{children:e.upload.initializedEmptyProject?"Initialized empty project":`Uploaded ${e.upload.fileCount} files`}),x.jsx("span",{children:uy({byteCount:e.upload.byteCount,skippedCount:e.upload.skippedCount,headCommit:e.upload.headCommit,targetProjectName:e.upload.branch})})]}),i&&e.setupUrl&&x.jsxs("div",{className:"cloud-setup-next",children:[e.projectUrl?x.jsxs("span",{children:["Your repo is ready here:"," ",x.jsxs("a",{href:e.projectUrl,target:"_blank",rel:"noreferrer",onClick:u=>rp(u,e.projectUrl,n,{newTab:!0}),children:["Project page",x.jsx(Ym,{size:13})]})]}):x.jsx("span",{children:"Your repo is ready. Next step:"}),x.jsxs("a",{href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>rp(u,e.setupUrl,n),children:["Setup the Cloud sandbox",x.jsx(Ym,{size:13})]})]}),x.jsxs("div",{className:"git-dialog-footer",children:[x.jsx("button",{className:"git-dialog-secondary",disabled:r,type:"button",onClick:t,children:i?"Done":"Cancel"}),i?e.setupUrl?x.jsxs("a",{className:"git-dialog-primary cloud-setup-primary-link",href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>rp(u,e.setupUrl,n),children:["Open setup",x.jsx(Ym,{size:13})]}):null:x.jsx("button",{className:"git-dialog-primary",disabled:r,type:"button",onClick:a,children:r?"Uploading":s?"Try again":l?"Show setup link":"Upload source"})]})]})})}function rp(e,t,n,a={}){!t||!n||(e.preventDefault(),n(t,a))}function T3(e){return!Number.isFinite(e)||e<=0?"0 B":e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function uy({byteCount:e,skippedCount:t,headCommit:n,targetProjectName:a}){const r=[T3(e),`${t} skipped`],i=E3(n);return i&&r.push(`local ${i}`),r.push(a),r.join(" · ")}function E3(e){const t=e?.trim();return t?t.slice(0,7):null}const M3=g.lazy(()=>Nr(()=>import("./CommandMenu-DLe1d-iP.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(e=>({default:e.CommandMenu}))),j3=g.lazy(()=>Nr(()=>import("./SettingsView-Bjf1bZOw.js"),__vite__mapDeps([4,1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]),import.meta.url).then(e=>({default:e.SettingsView}))),O3=g.lazy(()=>Nr(()=>import("./NewProjectDialog-DFAGQHU5.js"),__vite__mapDeps([26,1,2,8,15]),import.meta.url).then(e=>({default:e.NewProjectDialog}))),$3=g.lazy(()=>Nr(()=>import("./WorkspaceGitDialogs-WpfoEpEk.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.CommitDialog}))),N3=g.lazy(()=>Nr(()=>import("./WorkspaceGitDialogs-WpfoEpEk.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.BranchDialog})));function D3({payload:e,connection:t,diagnostics:n,initialSection:a,onPayload:r,onError:i,onToast:s,onBack:l,onOpenSourceSession:m,onStartRefinerAuthoring:u,onAcceptEvaluationReview:h,onOpenSkill:b,onOpenExtension:y,teamChatCurrentUserId:w,teamChatEnabled:_,teamChatNotificationMode:E,teamChatThreads:j,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:O,diffPanelExpanded:k,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A}){return x.jsx(g.Suspense,{fallback:null,children:x.jsx(j3,{payload:e,connection:t,diagnostics:n,initialSection:a,onPayload:r,onError:i,onToast:s,onBack:l,onOpenSourceSession:m,onStartRefinerAuthoring:u,onAcceptEvaluationReview:h,onOpenSkill:b,onOpenExtension:y,teamChatCurrentUserId:w,teamChatEnabled:_,teamChatNotificationMode:E,teamChatThreads:j,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:O,diffPanelExpanded:k,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A})})}function L3({activeSessions:e,branchDialogName:t,branchDialogOpen:n,commitDialogOpen:a,commitDraft:r,commitIncludeUnstaged:i,commitMessage:s,commitNextStep:l,canPublishOpenPondProject:m,expandProject:u,newProjectBusy:h,newProjectDialogOpen:b,newProjectDirectory:y,newProjectMode:w,newProjectName:_,newProjectPath:E,projectRows:j,query:P,searchOpen:L,visibleWorkspaceDiff:$,visibleWorkspaceState:O,workspaceBusy:k,appDispatch:C,beginNewChat:A,openDefaultsSettingsFromBranchDialog:z,setBranchDialogName:B,setBranchDialogOpen:N,setCommitDialogOpen:K,setCommitDraft:de,setCommitIncludeUnstaged:te,setCommitMessage:Ie,setCommitNextStep:xe,setNewProjectDialogOpen:Z,setNewProjectName:Ae,setNewProjectPath:he,setQuery:ue,setSearchOpen:be,submitCommitDialog:ne,submitCreateWorkspaceBranch:ge,submitNewProjectDialog:ke}){return x.jsxs(x.Fragment,{children:[L&&x.jsx(g.Suspense,{fallback:null,children:x.jsx(M3,{open:L,query:P,projects:j,sessions:e,onQueryChange:ue,onClose:()=>{be(!1),ue("")},onNewChat:()=>{be(!1),ue(""),A()},onOpenProject:qe=>{C({type:"selectProject",projectId:qe.id}),C({type:"patch",patch:{searchOpen:!1,query:""}}),u(qe.id)},onOpenSession:qe=>{C({type:"selectSession",sessionId:qe.id,appId:qe.appId,projectId:qe.workspaceKind==="local_project"&&qe.workspaceId?vt("local",qe.workspaceId):null}),C({type:"patch",patch:{searchOpen:!1,query:""}})}})}),b&&x.jsx(g.Suspense,{fallback:null,children:x.jsx(O3,{open:b,mode:w,name:_,path:E,directory:y,busy:h,onNameChange:Ae,onPathChange:he,onClose:()=>{h||Z(!1)},onSubmit:ke})}),a&&x.jsx(g.Suspense,{fallback:null,children:x.jsx($3,{open:a,branch:O?.currentBranch??null,filesChanged:$?.filesChanged??O?.changedFilesCount??0,additions:$?.additions??0,deletions:$?.deletions??0,message:s,includeUnstaged:i,nextStep:l,draft:r,busy:k,canPush:!!O?.remoteUrl,canPublish:m,onMessageChange:Ie,onIncludeUnstagedChange:te,onNextStepChange:xe,onDraftChange:de,onClose:()=>{k||K(!1)},onSubmit:ne})}),n&&x.jsx(g.Suspense,{fallback:null,children:x.jsx(N3,{open:n,branchName:t,busy:k,onBranchNameChange:B,onSetPrefix:z,onClose:()=>{k||N(!1)},onSubmit:ge})})]})}function cI({toast:e,onDismiss:t}){if(!e)return null;const n=!!(e.actionLabel&&e.onAction),a=!!(e.persistent||e.dismissible);return x.jsxs("div",{className:`app-toast ${e.tone} ${e.placement??"bottom-right"}`,role:e.tone==="error"?"alert":"status","aria-live":"polite",children:[x.jsx("span",{className:"app-toast-message",children:e.message}),(n||a)&&x.jsxs("div",{className:"app-toast-actions",children:[n&&x.jsx("button",{type:"button",className:e.actionIcon?"app-toast-icon-action":void 0,"aria-label":e.actionLabel,title:e.actionIcon?e.actionLabel:void 0,onClick:()=>{t(),e.onAction?.()},children:e.actionIcon==="settings"?x.jsx(og,{size:15}):e.actionLabel}),a&&x.jsx("button",{type:"button",className:"app-toast-close","aria-label":"Dismiss notification",onClick:t,children:x.jsx(os,{size:14})})]})]})}const Gl=g.createContext(null);function U3({children:e}){const[t,n]=g.useState(null),[a,r]=g.useState(null),i=g.useMemo(()=>({title:t,actions:a,setTitle:n,setActions:r}),[t,a]);return x.jsx(Gl.Provider,{value:i,children:e})}function xJ({children:e}){return x.jsx(Gl.Provider,{value:null,children:e})}function z3({children:e,className:t=""}){const n=g.useContext(Gl);return x.jsx("div",{ref:n?.setTitle,className:`page-chrome-title-target ${t}`,children:e?x.jsx("div",{className:"page-chrome-fallback",children:e}):null})}function H3({className:e=""}){const t=g.useContext(Gl);return x.jsx("div",{ref:t?.setActions,className:e})}function kJ({title:e,actions:t,fallback:n,children:a}){const r=g.useContext(Gl);return r?x.jsxs(x.Fragment,{children:[r.title?pf.createPortal(x.jsx("div",{className:"page-chrome-title",children:e}),r.title):null,r.actions&&t?pf.createPortal(t,r.actions):null,a]}):n??x.jsxs("header",{children:[e,t]})}async function q3(e){if(!e)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard write failed",t)}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-1000px",t.style.top="-1000px",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return t.remove(),n}catch(t){return console.warn("Clipboard fallback failed",t),!1}}function B3({activeView:e,onDiscoverCommunities:t,onOpenTeamChat:n}){return x.jsxs("div",{className:"titlebar-collaboration-actions",children:[x.jsx("button",{type:"button",className:`titlebar-icon${e==="team"?" active":""}`,"aria-label":"Team chat",title:"Team chat",onClick:n,children:x.jsx(Yd,{size:16})}),x.jsx("button",{type:"button",className:`titlebar-icon${e==="community"?" active":""}`,"aria-label":"Discover communities",title:"Discover communities",onClick:t,children:x.jsx(C1,{size:16})})]})}const F3=g.lazy(()=>Nr(()=>import("./WorkspaceEnvironmentMenu-sgYQj7uK.js"),__vite__mapDeps([29,1,2,21,10,14,5,30,28,31]),import.meta.url).then(e=>({default:e.WorkspaceEnvironmentMenu})));function V3({sidebarOpen:e,title:t,conversationId:n,breadcrumbs:a,backAction:r,workspaceName:i,workspaceId:s,busy:l,workspaceState:m,workspaceKind:u,selectedApp:h,selectedProject:b,workspaceDiff:y,managedWorkspace:w,workspaceBusy:_,defaultTeamId:E,showDiffControls:j,diffPanelOpen:P,terminalOpen:L,rightSidebarAvailable:$=!1,rightSidebarOpen:O=!1,onToggleDiffPanel:k,onToggleRightSidebar:C,onOpenSearch:A,onToggleTerminal:z,onRunTerminalCommand:B,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:xe,onOpenSandboxWorkspace:Z,onShowSidebar:Ae,onOpenTeamChat:he,onDiscoverCommunities:ue,collaborationView:be=null,platform:ne,showWorkspaceControls:ge=!0}){const ke=y?.filesChanged??0,qe=eu()&&!rg(ne),Se=!!(he||ue)||ge||$||qe,[ie,we]=g.useState(null);g.useEffect(()=>{if(!ie)return;const Ge=()=>we(null);return window.addEventListener("pointerdown",Ge),window.addEventListener("blur",Ge),window.addEventListener("resize",Ge),()=>{window.removeEventListener("pointerdown",Ge),window.removeEventListener("blur",Ge),window.removeEventListener("resize",Ge)}},[ie]);const Oe=Ge=>{Ge.preventDefault(),Ge.stopPropagation();const st=190,Le=n?76:42;we({x:Math.min(Ge.clientX,window.innerWidth-st-8),y:Math.min(Ge.clientY,window.innerHeight-Le-8)})},Qe=Ge=>{q3(Ge),we(null)};return x.jsxs("header",{className:"app-titlebar",children:[x.jsxs("div",{className:"titlebar-left",children:[!e&&x.jsx("button",{className:"titlebar-icon",title:"Show sidebar",onClick:Ae,children:x.jsx(R1,{size:16})}),r?x.jsx("button",{className:"titlebar-icon",type:"button","aria-label":r.label,title:r.label,onClick:r.onSelect,children:x.jsx(hF,{size:16})}):null,x.jsx(z3,{children:a?.length?x.jsx("nav",{className:"titlebar-breadcrumbs","aria-label":"Breadcrumb",children:a.map((Ge,st)=>{const Le=st===a.length-1;return x.jsxs("div",{className:"titlebar-breadcrumb-item",children:[Ge.onSelect&&!Le?x.jsx("button",{type:"button",onClick:Ge.onSelect,children:Ge.label}):x.jsx("strong",{children:Ge.label}),!Le&&x.jsx($r,{size:14})]},`${Ge.label}-${st}`)})}):x.jsxs("div",{className:"titlebar-title",children:[x.jsx("strong",{className:"titlebar-copy-target",title:"Double-click to select; right-click for copy options",onContextMenu:Oe,children:t}),i&&x.jsx("span",{children:i})]})})]}),Se&&x.jsxs("div",{className:"titlebar-right",children:[x.jsx(H3,{className:"page-chrome-actions"}),x.jsx(B3,{activeView:be,onDiscoverCommunities:ue,onOpenTeamChat:he}),ge&&x.jsxs("div",{className:"titlebar-actions",children:[x.jsx(g.Suspense,{fallback:null,children:x.jsx(F3,{mode:"topbar",busy:l,workspaceState:m,workspaceId:s,workspaceKind:u,selectedApp:h,selectedProject:b,workspaceBusy:_,defaultTeamId:E,workspaceDiff:y,managedWorkspace:w,showDiffControls:j,diffPanelOpen:P,onToggleDiffPanel:k,onRunTerminalCommand:B,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:xe,onOpenSandboxWorkspace:Z})}),x.jsx("button",{type:"button",className:"titlebar-icon",title:"Search chats and projects","aria-label":"Search chats and projects",onClick:A,children:x.jsx(d4,{size:16})}),x.jsx("button",{type:"button",className:`titlebar-icon ${L?"active":""}`,title:`${L?"Hide":"Show"} terminal`,"aria-label":`${L?"Hide":"Show"} terminal`,"aria-pressed":L,onClick:z,children:x.jsx(A1,{size:16})}),j&&x.jsx("button",{type:"button",className:`topbar-diff-button ${O?"active":""}`,title:`${O?"Hide":"Show"} sidebar${ke?`, ${ke} changed files`:""}`,"aria-label":`${O?"Hide":"Show"} sidebar`,"aria-pressed":O,onClick:k,children:x.jsx(nf,{size:16})})]}),$&&C&&!j?x.jsx("div",{className:"titlebar-actions",children:x.jsx("button",{type:"button",className:`topbar-diff-button ${O?"active":""}`,title:`${O?"Hide":"Show"} sidebar`,"aria-label":`${O?"Hide":"Show"} sidebar`,"aria-pressed":O,onClick:C,children:x.jsx(nf,{size:16})})}):null,x.jsx(y4,{platform:ne})]}),ie&&x.jsxs("div",{className:"titlebar-copy-menu",role:"menu","aria-label":"Conversation title actions",style:{left:ie.x,top:ie.y},onPointerDown:Ge=>Ge.stopPropagation(),children:[x.jsx("button",{type:"button",role:"menuitem",onClick:()=>Qe(t),children:"Copy title"}),n&&x.jsx("button",{type:"button",role:"menuitem",onClick:()=>Qe(n),children:"Copy conversation ID"})]})]})}function K3(){const[e,t]=g.useState(null),n=g.useRef(null),a=g.useCallback(i=>new Promise(s=>{n.current?.resolve(!1);const l={...i,cancelLabel:i.cancelLabel??"Cancel",tone:i.tone??"default",resolve:s};n.current=l,t(l)}),[]),r=g.useCallback(i=>{const s=n.current;n.current=null,t(null),s?.resolve(i)},[]);return{confirmAction:a,confirmDialog:e,resolveConfirmDialog:r}}function W3({state:e,onResolve:t}){const n=g.useId(),a=g.useId();if(g.useEffect(()=>{if(!e)return;function i(s){s.key==="Escape"&&t(!1)}return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t,e]),!e)return null;const r=e.tone==="danger"?"git-dialog-primary danger":"git-dialog-primary";return x.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:()=>t(!1),children:x.jsxs("section",{className:"git-dialog project-confirm-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":a,onMouseDown:i=>i.stopPropagation(),children:[x.jsx("h2",{id:n,children:e.title}),x.jsx("p",{id:a,children:e.body}),x.jsxs("div",{className:"git-dialog-footer",children:[x.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:()=>t(!1),children:e.cancelLabel}),x.jsx("button",{type:"button",className:r,autoFocus:!0,onClick:()=>t(!0),children:e.confirmLabel})]})]})})}function G3(){const{confirmAction:e,confirmDialog:t,resolveConfirmDialog:n}=K3();return{confirmProjectAction:g.useCallback(r=>e({tone:"danger",...r}),[e]),projectConfirmDialog:t,resolveProjectConfirmDialog:n}}function Z3({state:e,onResolve:t}){return x.jsx(W3,{state:e,onResolve:t})}const md=new Map,J3=(e,t,n)=>{const a=md.get(e)??{commits:0,maxActualDurationMs:0,totalActualDurationMs:0};a.commits+=1,a.maxActualDurationMs=Math.max(a.maxActualDurationMs,n),a.totalActualDurationMs+=n,md.set(e,a)};function Y3({children:e,id:t}){return x.jsx(g.Profiler,{id:t,onRender:J3,children:e})}typeof window<"u"&&(window.__OPENPOND_RENDER_COMMITS__={get:()=>Object.fromEntries([...md.entries()].map(([e,t])=>[e,{...t}])),reset:()=>md.clear()});const Q3=g.lazy(()=>Nr(()=>import("./MainPane-BT58d6eG.js").then(e=>e.M),__vite__mapDeps([32,1,2,13,33,6,30]),import.meta.url).then(e=>({default:e.MainPane})));function X3({className:e,style:t,sidebar:n,topBar:a,mainPane:r,cloudSetup:i,projectConfirm:s,lazyPanels:l,toast:m}){return x.jsx(U3,{children:x.jsxs("div",{className:e,style:t,children:[x.jsx(Y3,{id:"sidebar",children:x.jsx(_3,{...n})}),x.jsxs("div",{className:"content-shell",children:[x.jsx(V3,{...a}),x.jsx(g.Suspense,{fallback:x.jsx("main",{className:"main-pane","aria-busy":"true","aria-label":"Loading workspace"}),children:x.jsx(Q3,{...r})})]}),x.jsx(A3,{...i}),x.jsx(Z3,{...s}),x.jsx(L3,{...l}),x.jsx(cI,{...m})]})})}function e6({settings:e,toast:t}){return x.jsxs(x.Fragment,{children:[x.jsx(D3,{...e}),x.jsx(cI,{...t})]})}const Fc="OpenPond".split("");function t6({visibleLetterCount:e=Fc.length}){const t=Fc.slice(0,Math.max(0,Math.min(e,Fc.length)));return x.jsxs("div",{className:"app-splash-lockup",children:[x.jsx("div",{className:"app-splash-mark",children:x.jsx("img",{alt:"OpenPond",className:"app-splash-logo",decoding:"async",src:d3})}),x.jsx("span",{"aria-hidden":"true",className:`app-splash-wordmark${t.length>0?" is-visible":""}`,children:t.map((n,a)=>x.jsx("span",{className:"app-splash-letter",children:n},`${n}-${a}`))})]})}const ip=Fc.length,n6=520,a6=240;function my(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function o6({startup:e}){const[t,n]=g.useState(()=>my()?ip:0);return g.useEffect(()=>{if(my()){n(ip);return}const a=Array.from({length:ip},(r,i)=>window.setTimeout(()=>n(i+1),n6+a6*i));return()=>{a.forEach(r=>window.clearTimeout(r))}},[]),x.jsxs("main",{className:"app-splash","aria-busy":"true","aria-label":e.label,role:"status",children:[x.jsx(t6,{visibleLetterCount:t}),x.jsx("span",{className:"app-splash-status",children:e.label})]})}const xg=5e3;function Co(e,t){if(e.length===0)return t;if(t.length===0)return e;const n=new Set,a=[];for(const r of[...e,...t])n.has(r.id)||(n.add(r.id),a.push(r));return a}function Io(e,t,n=xg){return Vc(Co(e,t),n)}function Vc(e,t=xg){return e.length<=t?e:e.slice(e.length-t)}function r6(e,t,n){return n.length===0?e:{...e,[t]:Co(e[t]??[],n)}}function i6(e,t){if(t.length===0)return Vc(e);if(e.length===0)return Vc(t);const n=new Map;let a=0;for(const r of[...e,...t])n.has(r.id)||n.set(r.id,{event:r,index:a}),a+=1;return Vc([...n.values()].sort((r,i)=>l6(r,i)).map(({event:r})=>r))}function pd(e){let t=null;for(const n of e)typeof n.sequence=="number"&&(t=t===null?n.sequence:Math.max(t,n.sequence));return t}function s6(e){let t=null;for(const n of e)n.sequence!==void 0&&(t===null||n.sequence<t)&&(t=n.sequence);return t}function l6(e,t){const n=e.event.sequence,a=t.event.sequence;if(typeof n=="number"&&typeof a=="number"){const s=n-a;if(s!==0)return s}const r=Date.parse(e.event.timestamp),i=Date.parse(t.event.timestamp);if(Number.isFinite(r)&&Number.isFinite(i)){const s=r-i;if(s!==0)return s}return e.index-t.index}function py(e){if(e<1e3)return String(e);const t=e/1e3;return t>=10||Number.isInteger(t)?`${Math.round(t)}k`:`${t.toFixed(1)}k`}function c6(e){return e===null?"unknown":e>=85?"high":e>=65?"medium":"low"}function fy(e,t){const n=e?.triggerPercent??85;return e?.autoEnabled===!1?t>=n?"Auto compaction is off. Start a new chat or turn it on before the provider limit is reached.":"Auto compaction is off.":`Auto compacts at ${n}% context when supported.`}function d6(e){return e==="codex"}function u6(e){return e==="openpond"}function dI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="session.context.updated")continue;const a=xj.safeParse(n.data);if(a.success)return a.data}return null}function uI(e){if(e.snapshot&&e.snapshot.provider===e.provider){const n=e.snapshot.usedTokens,a=e.snapshot.maxContextTokens,r=Math.min(100,Math.round(e.snapshot.percentFull)),i=`${r}% full`,s=`${py(n)} / ${py(a)} tokens used`;return{usedTokens:n,maxTokens:a,percent:r,summary:i,tokensLabel:s,detail:fy(e.preferences,r),tooltip:`Context window: ${i} ${s}. ${fy(e.preferences,r)}`,tone:c6(r)}}if(d6(e.provider)){const n="Context is managed by Codex app-server.";return{usedTokens:0,maxTokens:null,percent:null,summary:"Managed externally",tokensLabel:"Codex app-server",detail:n,tooltip:`Context window: ${n}`,tone:"unknown"}}if(!u6(e.provider)){const n="Context pressure is unavailable until this provider has model context metadata.";return{usedTokens:0,maxTokens:null,percent:null,summary:"Limit unknown",tokensLabel:"Provider metadata unavailable",detail:n,tooltip:`Context window: ${n}`,tone:"unknown"}}const t="Send a message to measure hosted context.";return{usedTokens:0,maxTokens:null,percent:null,summary:"Not measured yet",tokensLabel:"Hosted context",detail:t,tooltip:`Context window: ${t}`,tone:"unknown"}}function kg(e){let t=!1;const n=mI(e);for(let a=e.length-1;a>=0;a-=1){const r=e[a];if(m6(r)){t=!0;continue}const i=Wi(r?.data);if(!(r?.name!=="diagnostic"||!i)){if(i.kind==="thread_goal_cleared")return null;if(i.kind==="thread_goal"){const s=wg(Wi(i.goal),Wn(i.provider),n);if(s){const l=Cl(s);return t&&l.tone==="active"?null:l}}if(i.kind==="goal_context"){const s=fI(r.output??"",Wn(i.provider)??"codex",n);if(s){const l=Cl(s);return t&&l.tone==="active"?null:l}}}}return null}function fd(e){const t=mI(e);for(let n=e.length-1;n>=0;n-=1){const a=e[n],r=Wi(a?.data);if(!(a?.name!=="diagnostic"||!r)){if(r.kind==="thread_goal_cleared"&&r.synthetic!==!0)return null;if(r.kind==="thread_goal"){const i=wg(Wi(r.goal),Wn(r.provider),t);if(!i)continue;const s=Cl(i);return s.tone==="active"?s:null}if(r.kind==="goal_context"){const i=fI(a.output??"",Wn(r.provider)??"codex",t);if(!i)continue;const s=Cl(i);return s.tone==="active"?s:null}}}return null}function sp(e){const t=Wi(Wi(e)?.codexGoalRuntime),n=wg(t,Wn(t?.provider)??"codex");if(!n)return null;const a=Cl(n);return a.tone==="active"?a:null}function m6(e){return e?.name==="turn.completed"||e?.name==="turn.interrupted"||e?.name==="turn.failed"}function Cl(e){const t=hI(e.status),n=bI(e.timeUsedSeconds),a=`Goal ${n}`,r=e.tokensUsed===null?null:e.tokenBudget===null?`${lp(e.tokensUsed)} tokens`:`${lp(e.tokensUsed)} / ${lp(e.tokenBudget)} tokens`,i=r?`${e.statusLabel} · ${r}`:e.statusLabel;return{objective:e.objective,status:e.status,timeUsedSeconds:e.timeUsedSeconds,tokensUsed:e.tokensUsed,tokenBudget:e.tokenBudget,actionLabel:t.actionLabel,timeLabel:n,label:a,detail:i,tooltip:`Goal runtime: ${yI(e.timeUsedSeconds)}. ${i}. ${e.objective}`,tone:t.tone,observedAt:e.observedAt}}function p6(e,t){if(!e||e.tone!=="active"||!e.observedAt)return e;const n=pI(e.observedAt,t);if(n<=0)return e;const a=e.timeUsedSeconds+n,r=bI(a);return{...e,timeUsedSeconds:a,timeLabel:r,label:`Goal ${r}`,tooltip:`Goal runtime: ${yI(a)}. ${e.detail}. ${e.objective}`,observedAt:t}}function wg(e,t=null,n=null){if(!e)return null;const a=Wn(e.objective)??"Active goal",r=Wn(e.status)??"active";if((ff(t)??ff(Wn(e.provider)))!=="codex")return null;const s=n??Wn(e.updatedAt)??Wn(e.updated_at)??null,l=vi(e.timeUsedSeconds)??vi(e.time_used_seconds)??0,m=Wn(e.activeSinceAt)??Wn(e.active_since_at),u=hI(r).tone==="active"?pI(m??Wn(e.createdAt)??Wn(e.created_at),s):0,h=m?l+u:Math.max(l,u),b=vi(e.tokensUsed)??vi(e.tokens_used),y=vi(e.tokenBudget)??vi(e.token_budget);return{objective:a,status:r,statusLabel:vI(r),timeUsedSeconds:Math.max(0,Math.floor(h)),tokensUsed:b===null?null:Math.max(0,Math.floor(b)),tokenBudget:y===null?null:Math.max(0,Math.floor(y)),observedAt:s}}function mI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]?.timestamp;if(n&&Number.isFinite(Date.parse(n)))return n}return null}function pI(e,t){if(!e||!t)return 0;const n=Date.parse(e),a=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(a)||a<=n?0:Math.floor((a-n)/1e3)}function fI(e,t=null,n=null){if(!e.trim()||ff(t)!=="codex")return null;const a=gI(e,"Status")??"active",r=Ks(e,"Tokens used"),i=Ks(e,"Token budget"),s=Ks(e,"Time used seconds")??Ks(e,"Time spent pursuing goal")??Ks(e,"Elapsed seconds")??0;return{objective:hy(e,"objective")??hy(e,"untrusted_objective")??"Active goal",status:a,statusLabel:vI(a),timeUsedSeconds:Math.max(0,Math.floor(s)),tokensUsed:r,tokenBudget:i,observedAt:n}}function hI(e){switch(f6(e)){case"active":case"running":return{tone:"active",actionLabel:"Pursuing goal"};case"paused":return{tone:"paused",actionLabel:"Goal paused"};case"blocked":return{tone:"limited",actionLabel:"Goal blocked"};case"complete":case"completed":case"achieved":return{tone:"done",actionLabel:"Goal achieved"};case"failed":return{tone:"limited",actionLabel:"Goal failed"};case"cancelled":case"canceled":case"stopped":return{tone:"limited",actionLabel:"Goal cancelled"};case"budget_limited":return{tone:"limited",actionLabel:"Goal budget limited"};default:return{tone:"active",actionLabel:"Goal status unknown"}}}function f6(e){return e.trim().toLowerCase().replace(/[-\s]+/g,"_")}function gI(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^\\s*-?\\s*${n}:\\s*(.+?)\\s*$`,"im").exec(e)?.[1]?.trim()||null}function Ks(e,t){const n=gI(e,t);if(!n)return null;const a=n.replace(/,/g,""),r=/-?\d+(?:\.\d+)?/.exec(a);if(!r)return null;const i=Number(r[0]);return Number.isFinite(i)?i:null}function hy(e,t){return new RegExp(`<${t}>\\s*([\\s\\S]*?)\\s*<\\/${t}>`,"i").exec(e)?.[1]?.trim()||null}function vI(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function bI(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m`:`${n}h`}function yI(e){if(e<60)return`${e} ${e===1?"second":"seconds"}`;const t=Math.floor(e/60);if(t<60)return`${t} ${t===1?"minute":"minutes"}`;const n=Math.floor(t/60),a=t%60;return a===0?`${n} ${n===1?"hour":"hours"}`:`${n}h ${a}m`}function lp(e){if(e<1e3)return String(e);if(e>=1e6){const n=e/1e6;return n<10?`${gy(n,2)}M`:n<100?`${gy(n,1)}M`:`${Math.round(n)}M`}const t=e/1e3;return t>=10||Number.isInteger(t)?`${Math.round(t)}k`:`${t.toFixed(1)}k`}function gy(e,t){return e.toFixed(t).replace(/\.?0+$/,"")}function Wi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Wn(e){return typeof e=="string"&&e.trim()?e.trim():null}function ff(e){return e?.trim().toLowerCase()||null}function vi(e){return typeof e=="number"&&Number.isFinite(e)?e:null}const h6=new Set(["planning","applying_source","running_checks","evaluating","pushing_hosted","running_hosted_checks"]),g6=new Set(["awaiting_questions","awaiting_plan_approval","paused"]);function hf(e){const t=SI(e);return t?S6(t):null}function SI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="create_improve.updated")continue;const a=y6(_6(n.data));if(a)return a}return null}function v6(e){if(e.events)return SI(e.events);const t=e.messages??[];for(let n=t.length-1;n>=0;n-=1){const a=t[n]?.createImproveRun??null;if(a)return a}return null}function b6(e,t){const n=e?.target.displayName?.trim()??"",a=n.toLowerCase().replace(/[^a-z0-9]+/g," ").trim();return n&&!/^(?:create|creating|improve|improving|new) (?:an )?agent$/.test(a)?n:t}function y6(e){const t=Ol.safeParse(e?.createImproveRun);return t.success?t.data:null}function S6(e){const t=x6(e);if(!t)return null;const n=k6(e.createdAt,e.updatedAt),a=e.blockedReason??w6(e.state);return{objective:e.objective,status:e.state,timeUsedSeconds:n,tokensUsed:null,tokenBudget:null,actionLabel:t.actionLabel,timeLabel:I6(n),label:t.actionLabel,detail:a,tooltip:`${t.actionLabel}: ${a}. ${e.objective}`,tone:t.tone}}function x6(e){const t=e.state,n=e.target.kind==="agent"?"Agent":"Work";return h6.has(t)?{tone:"active",actionLabel:`${n} running`}:g6.has(t)?{tone:"active",actionLabel:`${n} awaiting input`}:t==="blocked"?{tone:"limited",actionLabel:`${n} blocked`}:t==="failed"?{tone:"limited",actionLabel:`${n} failed`}:t==="cancelled"?{tone:"limited",actionLabel:`${n} cancelled`}:t==="ready"||t==="ready_local"?{tone:"done",actionLabel:e.target.kind==="agent"?"Agent ready":"Workproduct ready"}:t==="published_hosted"?{tone:"done",actionLabel:e.target.kind==="agent"?"Agent published":"Workproduct published"}:null}function k6(e,t){const n=Date.parse(e),a=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(a)||a<n?0:Math.floor((a-n)/1e3)}function w6(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function I6(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m`:`${n}h`}function _6(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function xI(e,t){if(!t)return null;const n=new Map,a=[];for(const O of e){if(!O.name.startsWith("subagent."))continue;const k=P6(O);k&&a.push(k);const C=R6(O);C?.parentSessionId===t&&n.set(C.id,C)}if(n.size===0)return null;const r=[...n.values()].sort((O,k)=>yi(k).localeCompare(yi(O))),i=r.filter(O=>O.status==="queued"||O.status==="running"),s=r.filter(O=>O.status==="completed"),l=r.filter(O=>O.status==="failed"),m=r.filter(O=>O.status==="cancelled"),u=r.filter(O=>O.status==="needs_resume"),h=[...s,...l,...m].sort((O,k)=>yi(k).localeCompare(yi(O))),b=r.reduce((O,k)=>{const C=Gi(k.metadata?.usage);return O.totalTokens+=Rc(C?.totalTokens),O.promptTokens+=Rc(C?.promptTokens),O.completionTokens+=Rc(C?.completionTokens),O.requestCount+=Rc(C?.requestCount),O},{totalTokens:0,promptTokens:0,completionTokens:0,requestCount:0}),y=r.flatMap(O=>kI([...O.report?.blockers??[],O.error,O.progress.currentBlocker]).map(k=>({runId:O.id,roleId:O.roleId,status:O.status,message:k}))),w=r.flatMap(O=>wI([...O.report?.artifacts??[],O.report?.patchRef,O.report?.diffRef,...O.progress.patchRefs]).map(k=>({...k,runId:O.id,roleId:O.roleId}))),_=h.map(O=>C6(O,a)),E=r[0]??null,j=E?{runId:E.id,roleId:E.roleId,status:E.status,message:E.progress.latestMeaningfulActivity||E.report?.summary||E.objective,updatedAt:yi(E)}:null,P=i.length>0?`${i.length} ${i.length===1?"child":"children"} running`:`${h.length} ${h.length===1?"child":"children"} finished`,L=[i.length?`${i.length} active`:null,s.length?`${s.length} completed`:null,l.length?`${l.length} failed`:null,m.length?`${m.length} cancelled`:null,u.length?`${u.length} paused`:null].filter(Boolean).join(" · "),$=j?`${E6(j.roleId)}: ${j.message}`:"";return{sessionId:t,runs:r,activeRuns:i,completedRuns:s,failedRuns:l,cancelledRuns:m,needsResumeRuns:u,terminalRuns:h,latestRun:E,latestMeaningfulUpdate:j,activeCount:i.length,completedCount:s.length,failedCount:l.length,cancelledCount:m.length,needsResumeCount:u.length,terminalCount:h.length,usage:b,blockers:y,evidenceRefs:w,finalResults:_,testsRunCount:r.reduce((O,k)=>O+k.progress.validationAttempts.length,0),label:P,tooltip:[L,$].filter(Boolean).join(". ")}}function C6(e,t){return{runId:e.id,roleId:e.roleId,status:e.status,objective:e.objective,summary:e.report?.summary||e.error||"Child conversation finished.",findings:e.report?.findings??[],changedFiles:e.progress.changedFiles,refs:wI([...e.report?.artifacts??[],e.report?.patchRef,e.report?.diffRef]),testsRun:e.report?.testsRun??[],validationAttempts:e.progress.validationAttempts.map(n=>n.command),blockers:kI([...e.report?.blockers??[],e.error]),confidence:e.report?.confidence??null,importantMessages:t.filter(n=>n.fromRunId===e.id).map(n=>({id:n.id,runId:e.id,fromRunId:n.fromRunId,kind:n.kind,body:n.body,createdAt:n.createdAt})),workspaceRetention:A6(e),updatedAt:yi(e)}}function R6(e){const t=Gi(e.data),n=[t?.run,Gi(t?.message)?.run];for(const a of n){const r=PS.safeParse(a);if(r.success)return r.data}return null}function P6(e){const t=HE.safeParse(Gi(e.data)?.message);return t.success?t.data:null}function A6(e){const t=Gi(Gi(e.metadata?.workspaceHandoff)?.workspaceRetention);return t?.status!=="retained"?null:{status:"retained",reason:Cc(t.reason),retainedAt:Cc(t.retainedAt),expiresAt:Cc(t.expiresAt),retentionDays:T6(t.retentionDays),trigger:Cc(t.trigger),cleanupAfterExpiry:t.cleanupAfterExpiry===!0}}function yi(e){return e.updatedAt??e.completedAt??e.startedAt??e.createdAt}function kI(e){return[...new Set(e.map(t=>t?.trim()).filter(t=>!!t))]}function wI(e){const t=new Map;for(const n of e)n&&t.set(`${n.kind}:${n.id}`,n);return[...t.values()]}function Gi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Cc(e){return typeof e=="string"&&e.trim()?e.trim():null}function Rc(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function T6(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function E6(e){return e.slice(0,1).toUpperCase()+e.slice(1).replace(/[-_]+/g," ")}const gf=[];function vf(e,t){return II(e,t,null)}function II(e,t,n){const a=n&&N6(n.events,e)?j6(n.indexes,n.events.length,e):M6(e),r=$6(t);return{...a,...r}}function M6(e){const t=new Map;for(const n of e){if(!n.sessionId)continue;const a=t.get(n.sessionId);a?a.push(n):t.set(n.sessionId,[n])}return O6(t)}function j6(e,t,n){const a=new Map(e.eventsBySessionId),r=new Map(e.latestContextUsageBySessionId),i=new Map(e.latestGoalRuntimeBySessionId),s=new Map(e.latestSubagentRuntimeBySessionId),l=new Set(e.activeGoalSessionIds),m=new Set(e.activeSubagentSessionIds),u=new Set;for(let h=t;h<n.length;h+=1){const b=n[h];if(!b.sessionId)continue;if(u.has(b.sessionId)){a.get(b.sessionId).push(b);continue}const y=a.get(b.sessionId);a.set(b.sessionId,y?[...y,b]:[b]),u.add(b.sessionId)}for(const h of u){const b=a.get(h)??gf,y=dI(b);y?r.set(h,y):r.delete(h);const w=CI(b);w?(i.set(h,w),w.tone==="active"?l.add(h):l.delete(h)):(i.delete(h),l.delete(h));const _=xI(b,h);_?(s.set(h,_),_I({sessionEvents:b,sessionId:h,latestGoalRuntimeBySessionId:i,activeGoalSessionIds:l}),_.activeCount>0?m.add(h):m.delete(h)):(s.delete(h),m.delete(h))}return{eventsBySessionId:a,latestContextUsageBySessionId:r,latestGoalRuntimeBySessionId:i,latestSubagentRuntimeBySessionId:s,activeGoalSessionIds:l,activeSubagentSessionIds:m}}function O6(e){const t=new Map,n=new Map,a=new Map,r=new Set,i=new Set;for(const[s,l]of e){const m=dI(l);m&&t.set(s,m);const u=CI(l);u&&(n.set(s,u),u.tone==="active"&&r.add(s))}for(const[s,l]of e){const m=xI(l,s);m&&(a.set(s,m),_I({sessionEvents:l,sessionId:s,latestGoalRuntimeBySessionId:n,activeGoalSessionIds:r}),m.activeCount>0&&i.add(s))}return{eventsBySessionId:e,latestContextUsageBySessionId:t,latestGoalRuntimeBySessionId:n,latestSubagentRuntimeBySessionId:a,activeGoalSessionIds:r,activeSubagentSessionIds:i}}function _I(e){if(e.latestGoalRuntimeBySessionId.has(e.sessionId))return;const t=fd(e.sessionEvents);t&&(e.latestGoalRuntimeBySessionId.set(e.sessionId,t),t.tone==="active"&&e.activeGoalSessionIds.add(e.sessionId))}function CI(e){return hf(e)??kg(e)??fd(e)}function $6(e){const t=new Map,n=new Map,a=new Map,r=new Map;for(const i of e){t.set(i.id,i);const s=n.get(i.status);if(s?s.push(i):n.set(i.status,[i]),i.status!=="pending")continue;const l=a.get(i.sessionId);l?l.push(i):a.set(i.sessionId,[i]);const m=r.get(i.sessionId);(!m||vy(i.createdAt)>vy(m.createdAt))&&r.set(i.sessionId,i)}return{approvalsById:t,approvalsByStatus:n,pendingApprovalsBySessionId:a,latestPendingApprovalBySessionId:r}}function N6(e,t){return e===t?!0:e.length>t.length||e.length===t.length?!1:e.length===0?!0:e[0]===t[0]&&e[e.length-1]===t[e.length-1]}function Zl(e,t){return t?e.eventsBySessionId.get(t)??gf:gf}function RI(e,t){return t?e.latestContextUsageBySessionId.get(t)??null:null}function PI(e,t){return t?e.latestGoalRuntimeBySessionId.get(t)??null:null}function D6(e,t){return t?e.latestSubagentRuntimeBySessionId.get(t)??null:null}function L6(e,t){return t?e.latestPendingApprovalBySessionId.get(t)??null:null}function vy(e){const t=Date.parse(e);return Number.isFinite(t)?t:Number.NEGATIVE_INFINITY}function U6(e,t){return e?.conversationId===t}function z6(e,t){return e?.id===t?null:e}function H6(e){const t=new Set;if(e.readmePath){const n=e.readmePath.replaceAll("\\","/").split("/").at(-1);n&&t.add(n)}for(const n of e.skills){t.add(n.relativePath);const a=n.relativePath.lastIndexOf("/"),r=a>=0?n.relativePath.slice(0,a):"";for(const i of n.resourceFiles)t.add(r?`${r}/${i}`:i)}return{name:`${e.owner}/${e.repo}`,description:`${e.skills.length} installed skill${e.skills.length===1?"":"s"} from GitHub.`,scope:"extension",packagePath:e.sourcePath,files:[...t]}}function q6(e){return JSON.stringify([e.source,e.repositoryId,e.profileId])}function wJ(e,t){return e.profiles.find(n=>q6(n.ref)===t)?.ref??null}function B6(e,t){return!!(e&&t&&e.source===t.source&&e.repositoryId===t.repositoryId&&e.profileId===t.profileId)}function IJ(e,t){return e.profiles.find(n=>B6(n.ref,t))?.state??null}function F6(e,t){const n=new Map(F2.map(a=>[a.name,{...a,validationMessages:[...a.validationMessages],resourceFiles:[...a.resourceFiles]}]));for(const a of e?.skills??[])n.has(a.name)||n.set(a.name,a);for(const a of t?.extensions??[])if(a.validationStatus==="valid")for(const r of a.skills)r.validationStatus!=="valid"||n.has(r.name)||n.set(r.name,{name:r.name,description:r.description,path:r.relativePath,scope:"profile",enabled:!0,sourcePath:a.sourcePath,charCount:r.charCount,sourceHash:r.sourceHash,validationStatus:"valid",validationMessages:[],resourceFiles:r.resourceFiles});return[...n.values()].sort((a,r)=>a.name.localeCompare(r.name))}function V6(e){return{sourceTaskId:e.sourceTaskId,sourceExperience:e.sourceExperience,targetExperience:e.targetExperience,sourceMessageIds:[...e.sourceMessageIds??[]],sourceContext:e.sourceContext?.trim()||null,outputId:e.output?.id??null,outputRevision:e.output?.revision??null,createdAt:e.createdAt??new Date().toISOString(),checkoutMutation:"none"}}function _J(e,t){const n=`Continue from the attached Work output "${e.title}" (revision ${e.revision}).`;return t==="work"?`${n} Choose a Project or repository before making source changes; do not mutate a checkout until I choose it.`:n}const AI="openpond:last-chat-task-mode";function K6(e,t){return e==="labs"?"models":"chat"}function W6(e){try{return e.getItem(AI)==="work"?"work":"chat"}catch{return"chat"}}function Ig(){if(typeof window>"u")return"chat";try{return W6(Wl)}catch{return"chat"}}function G6(e,t){try{e.setItem(AI,t==="chat"?"chat":"work")}catch{}}function Z6(e){if(!(typeof window>"u"))try{G6(Wl,e)}catch{}}const J6="uploaded to a different account";function TI(e,t){const n=e?.linkedSandboxProject??null;if(!n?.projectId||!n.teamId)return{state:"none",linked:null,cloudProject:null};const a=t?.find(r=>r.id===n.projectId&&r.teamId===n.teamId)??null;return a?{state:"confirmed",linked:n,cloudProject:a}:{state:"different_account",linked:n,cloudProject:null}}function Sa(e,t){const n=TI(e,t);return n.state==="confirmed"?n.cloudProject:null}function Y6(e,t){return TI(e,t).state==="different_account"?J6:null}function lo(e){return e==="sandbox"||e==="sandbox_template"||e==="sandbox_app"}function EI(e={}){return{...e,workspaceTarget:"hybrid"}}function Q6(e={}){return{...e,workspaceTarget:"local"}}function co(e){return e?.metadata?.workspaceTarget==="hybrid"}function X6(e){return!!(e&&e.provider==="openpond"&&e.workspaceKind==="local_project"&&e.cloudProjectId&&e.title.trim().endsWith(" Cloud"))}function MI({cloudProjects:e,selectedCloudProject:t,selectedProject:n}){const a=n?.linkedSandboxProject??null,r=e?Sa(n,e):null,i=t?.id??r?.id??(e?null:a?.projectId??null),s=t?.teamId??r?.teamId??(e?null:a?.teamId??null);return!i||!s?{kind:"missing_cloud_project",message:"Upload/sync this Project to Cloud before using Hybrid."}:{kind:"ready",cloudProjectId:i,cloudTeamId:s,cwd:n?.workspacePath??null,localProjectId:n?.id??null,workspaceName:t?.name??r?.name??a?.projectName??n?.name??"Hybrid workspace"}}function jI({modelRef:e,provider:t,target:n,title:a}){return{provider:t,...e?{modelRef:e}:{},appId:null,appName:null,workspaceKind:"sandbox",workspaceId:null,workspaceName:n.workspaceName,localProjectId:n.localProjectId,cloudProjectId:n.cloudProjectId,cloudTeamId:n.cloudTeamId,metadata:EI(),cwd:n.cwd,title:a}}function eV(e){return g.useEffect(()=>{const t=F1(e.selectedSession);!t||e.composerDraftStore.getSnapshot()||e.composerDraftStore.set(t)},[e.composerDraftStore,e.selectedSession?.id]),g.useCallback(async t=>{const n=t.trim();if(!e.connection||!n||e.activeExperience==="chat")return!1;const a=Z4(n);try{let r;const i=e.selectedSession;if(i&&Il(i))r=await J.patchSession(e.connection,i.id,{title:a,metadata:ap(i.metadata,n)}),e.setSessions(s=>s.map(l=>l.id===r.id?r:l));else{const s=i?.metadata?.workspaceTarget==="hybrid"?"hybrid":i?.metadata?.workspaceTarget==="local"?"local":null,l=i?.provider??(e.selectedCloudProject?"openpond":e.activeProvider),m=i?.modelRef??(l==="openpond"?{providerId:"openpond",modelId:Ui}:{providerId:l,modelId:e.activeModel}),u=s?{workspaceTarget:s}:!i&&e.workspaceTarget==="local"?{workspaceTarget:"local"}:{};let h;if(!i&&e.workspaceTarget==="hybrid"){const b=MI({cloudProjects:e.cloudProjects,selectedCloudProject:e.selectedCloudProject,selectedProject:e.selectedProject});if(b.kind!=="ready")throw new Error(b.message);const y=jI({modelRef:m,provider:l,target:b,title:a});h={...y,experience:"work",metadata:ap(y.metadata,n)}}else h={experience:"work",provider:l,modelRef:m,openPondCommandAccessMode:i?.openPondCommandAccessMode??e.activeOpenPondCommandAccessMode,appId:i?.appId??null,appName:i?.appName??null,workspaceKind:i?.workspaceKind??(e.selectedCloudProject?"sandbox":e.selectedProject?"local_project":void 0),workspaceId:i?.workspaceId??e.selectedCloudProject?.id??e.selectedProject?.id??null,workspaceName:i?.workspaceName??e.selectedCloudProject?.name??e.selectedProject?.name??null,localProjectId:i?.localProjectId??e.selectedProject?.id??null,cloudProjectId:i?.cloudProjectId??e.selectedCloudProject?.id??null,cloudTeamId:i?.cloudTeamId??e.selectedCloudProject?.teamId??null,cwd:i?.cwd??e.selectedProject?.workspacePath??null,metadata:ap(u,n),title:a};r=await J.createSession(e.connection,h),e.setSessions(b=>[r,...b])}return e.composerDraftStore.set(""),e.setMentionedAppId(null),e.setSelectedSessionId(null),e.setView("chat"),e.requestComposerFocus(),e.showToast("Task draft saved.","success"),!0}catch(r){return e.showToast(r instanceof Error?r.message:"Could not save task draft.","error"),!1}},[e.activeExperience,e.activeModel,e.activeOpenPondCommandAccessMode,e.activeProvider,e.cloudProjects,e.composerDraftStore,e.connection,e.requestComposerFocus,e.selectedCloudProject,e.selectedProject,e.selectedSession,e.setMentionedAppId,e.setSelectedSessionId,e.setSessions,e.setView,e.showToast,e.workspaceTarget])}const tV=[];function nV({primary:e,secondary:t}){const[n,a]=g.useState(!1),r=M4(),{composerDraftStore:i,appDispatch:s,pendingTerminalCommand:l,setPendingTerminalCommand:m,terminalTabs:u,setTerminalTabs:h,trainingDetailTasksetId:b,setTrainingDetailTasksetId:y,mentionedAppId:w,setMentionedAppId:_,cloudSetupDialog:E,setCloudSetupDialog:j,rightPanelTabRequest:P,workspaceDiffPanelViewState:L,mainComposerFocusRequestId:$,requestMainComposerFocus:O,projectConfirmDialog:k,resolveProjectConfirmDialog:C,query:A,searchOpen:z,archivedChatsOpen:B,sectionMenuOpen:N,cloudProjectsExpanded:K,sidebarOpen:de,view:te,selectedAppId:Ie,selectedProjectId:xe,selectedSessionId:Z,codexPermissionMode:Ae,codexReasoningEffort:he,busy:ue,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:ge,activeExperience:ke,changeNewExperience:qe,terminalOpen:Se,settingsSection:ie,newProjectDialogOpen:we,newProjectMode:Oe,newProjectName:Qe,newProjectPath:Ge,newProjectBusy:st,commitDialogOpen:Le,commitMessage:Fe,commitIncludeUnstaged:De,commitNextStep:D,commitDraft:M,branchDialogOpen:H,branchDialogName:Q,toast:me,labDetailNavigation:_e,setQuery:$e,setSearchOpen:Xe,setArchivedChatsOpen:et,setSectionMenuOpen:rt,setCloudProjectsExpanded:it,setChatRowsVisibleCount:Me,setSidebarOpen:Be,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setPrompt:re,setDraftProvider:F,setDraftModel:I,setDraftExperience:W,setDiffPanelOpen:X,setDiffPanelExpanded:oe,setRightPanelMode:G,setTerminalOpen:pe,setSettingsSection:fe,setNewProjectDialogOpen:je,setNewProjectName:Ee,setNewProjectPath:Ne,setCommitDialogOpen:Ve,setCommitMessage:Ue,setCommitIncludeUnstaged:ut,setCommitNextStep:Qt,setCommitDraft:Lt,setBranchDialogOpen:An,setBranchDialogName:Sn,setError:nn,showToast:bt,applyBootstrapPayload:rn,bootstrap:Nt,connection:yt,startup:sn,training:Ut,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Da,sidebarWidth:ia,sidebarResizing:qt,diffPanelWidth:qn,diffPanelResizing:ot,togglePinnedCollapsed:xn,toggleCloudProjectsCollapsed:La,toggleChatsCollapsed:Ua,toggleSavedForLaterCollapsed:sa,startSidebarResize:za,startDiffPanelResize:ae,selectedApp:Ke,selectedCloudProject:ze,selectedProject:Ze,selectedProjectLinkedApp:xt,selectedSession:gt,sidebarSessions:lt,runtimeIndexes:Ct,runtimeEventStore:la,chatMentionApps:Bn,connectedAppMentions:tt,pendingApproval:_n,pendingChatUserMessages:St,account:kn,activeModel:$n,activeProvider:Tn,appDefaults:Ha,startMessage:wa,organizations:uo,teamChatOrganization:qa,teamChatTeamId:ea,teamChat:kt,publishTeamProfileAgent:Ba,communitySidebar:ca,communityView:Vr,teamAiThreadId:ur,toggleTeamAiSidebar:mr,activeOpenPondCommandAccessMode:mo,viewWorkspaceAppId:Kr,viewWorkspaceId:Wr,viewWorkspaceKind:Gr,viewWorkspaceName:Zr,selectedActionCatalog:rs,expandedProjectIds:is,expandProject:Fa,toggleProjectExpanded:ss,changeCodexPermissionMode:Jr,changeCodexReasoningEffort:Yr,changeOpenPondCommandAccessMode:Qr,resolveApproval:ls,beginNewChat:ta,beginNewChatWithTrainingModel:cs,dismissTrainingChatHandoff:ds,trainingChatHandoff:us,selectTrainingChatTaskForComposer:Xr,chatHistoryLoadStates:ei,loadMoreSelectedChatHistory:ti,selectedPagedSessionEvents:ms,activeSessions:Va,archivedSessions:po,pinnedSessions:Fn,savedForLaterSessions:ps,savedForLaterFiles:fs,sidebarFileBookmarks:vn,setSidebarFileStatus:ni,setSessions:Vn,projectRows:Ia,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:hs,childSessionRowsByParentId:gs,sidebarProjectIdBySessionId:ho,chatRows:pr,visibleChatRows:ai,chatRowsVisibleCount:fr,sessionEvents:oi,goalRuntime:hr,subagentRuntime:ri,visibleChatMessages:da,activeTerminalScope:Fo,terminalSummaries:gr,runningSessionIds:go,selectedSessionRunning:ii,sidebarGoalRuntimeBySessionId:Wa,sidebarSubagentRuntimeBySessionId:si,taskDragSessionId:vs,taskPreviewSessionIds:vr,startTaskDrag:li,clearTaskDrag:ci,previewTaskDrop:di,commitTaskDrop:bs,commitTaskPreviewDrop:br,dragItem:ui,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:ys,commitPinnedDrop:Ss,commitPinnedPreviewDrop:xs,commandProjectRows:ks,contextWindowStatus:_a,pinnedRows:mi,workspaceBusy:yr,diffBusy:ws,visibleWorkspaceState:vo,visibleWorkspaceDiff:Nn,refreshVisibleWorkspaceDiff:Is,managedWorkspace:_s,canSyncActiveWorkspace:Cs,canPublishOpenPondProject:Rs,projectTarget:mt,workspaceTarget:Bt}=e,{title:Kn,browserConversationId:pn,handleWorkspaceDiffPanelViewStateChange:na,openSessionInChat:En,changeProjectTarget:du,submitNewProjectDialog:uu,changeWorkspaceBranch:mu,openCommitDialog:Ps,openCreateWorkspaceBranchDialog:Yl,openDefaultsSettingsFromBranchDialog:pu,runWorkspaceTool:fu,submitCommitDialog:hu,submitCreateWorkspaceBranch:gu,syncWorkspaceLocally:vu,answerCreateImproveQuestion:bu,applyCreateImproveCandidate:yu,approveCreateImproveRun:Su,cancelCreateImproveRun:xu,changeDraftProvider:Ql,openCreateImprovePullRequest:ku,reconcileCreateImprovePullRequest:Xl,rejectCreateImproveCandidate:wu,pauseCreateImproveRun:Iu,resumeCreateImproveRun:_u,reviseCreateImproveRun:ec,stopTurn:As,archiveSession:Cu,restoreSession:Ru,renameSession:tc,toggleSessionPinned:nc,toggleProjectPinned:ac,toggleSessionSavedForLater:Ts,moveProjectToCloud:Pu,startCloudSetupUpload:oc,changeWorkspaceTarget:Au,sendPromptFromMainComposer:Es,openSandboxWorkspace:Tu,openCloudProjectDialog:rc,openUrlInBrowserPanel:Eu,showBrowserPanel:ic,showChangesPanel:Mu,showGoalSidebarTab:ju,rightChatTrainingLaunchRequest:sc,setRightChatTrainingLaunchRequest:Ou,closeRightChatPanel:$u,openRightChatPanel:Ms,rightChatPanelViews:Nu,showRightChatPanel:Du,showRightPanelDiffTab:Ko,submitRightChatPrompt:lc,activateRightChatPanel:Lu,updateRightChatModel:Uu,updateRightChatPrompt:zu,updateRightChatProvider:Hu,updateRightChatScrollState:qu,openProfileSettings:Bu,diagnosticEvents:Fu,toggleRightSidebar:cc,removeProject:Vu}=t,pi=g.useCallback(Te=>{U(null),V(Te),le(null),p("chat"),Fa(Te),O()},[Fa,O,U,V,le,p]),Ku=g.useCallback((Te=null)=>{const ct=Z?ho[Z]??null:null;if(!Te&&ct){pi(ct);return}ta(Te)},[ta,pi,Z,ho]),Wu=g.useCallback(async Te=>{if(!(!yt||!Nt))try{const ct=await J.savePreferences(yt,{defaultTeamId:Te});rn({...Nt,preferences:ct.preferences})}catch(ct){const Mt=ct instanceof Error?ct.message:String(ct);throw nn(Mt),bt("Could not switch teams","error"),ct}},[rn,Nt,yt,nn,bt]),Gu=g.useCallback(async()=>{if(yt)try{const Te=await J.signOutOpenPondAccount(yt);rn(Te);const ct=await J.savePreferences(yt,{defaultTeamId:null});rn({...Te,preferences:ct.preferences}),bt("Logged out","success")}catch(Te){const ct=Te instanceof Error?Te.message:String(Te);throw nn(ct),bt("Could not log out","error"),Te}},[rn,yt,nn,bt]),js=ea??Ha.defaultTeamId??null,Zu=g.useMemo(()=>Ia.filter(Te=>Te.kind==="local"||js!==null&&Te.project.teamId===js),[Ia,js]),Ju=g.useMemo(()=>{const Te={};for(const ct of Va){const Mt=ho[ct.id];Mt&&(Te[Mt]=(Te[Mt]??0)+1)}for(const ct of fo){if(ct.kind!=="local")continue;const Mt=ct.project.linkedSandboxProject?.projectId;if(!Mt||!ct.cloudLinkTrusted)continue;const ua=vt("cloud",Mt);Te[ct.id]=(Te[ct.id]??0)+(Te[ua]??0)}return Te},[Va,fo,ho]),[Os,$s]=g.useState(null),[Ns,Ds]=g.useState(null),Yu=F6(Nt?.profile,Nt?.extensionCatalog),[Ls,Us]=g.useState(null),[zs,dc]=g.useState(null),[Za,Hs]=g.useState(null),uc=g.useCallback(()=>{U(null),V(null),le(null),rt(null),p("team")},[rt,U,V,le,p]),Qu=g.useCallback(()=>{U(null),V(null),le(null),rt(null),ca.discoverCommunities()},[ca.discoverCommunities,rt,U,V,le]),qs=eV({activeExperience:ke,activeModel:$n,activeOpenPondCommandAccessMode:mo,activeProvider:Tn,cloudProjects:Nt?.cloudProjects??tV,composerDraftStore:i,connection:yt,requestComposerFocus:O,selectedCloudProject:ze,selectedProject:Ze,selectedSession:gt,setMentionedAppId:_,setSelectedSessionId:le,setSessions:Vn,setView:p,showToast:bt,workspaceTarget:Bt.value}),Xu=g.useCallback(async Te=>{if(!yt)throw new Error("OpenPond is not connected.");let ct=Tn,Mt=$n;ct==="codex"&&(ct=mf(Nt?.providers,{enabledOnly:!0}).find(bn=>bn.value!=="codex")?.value??Mr,Mt=dd(ct,Nt?.providers)??pl);const ua=lt.find(bn=>bn.id===Te.sourceSessionId),bo=await J.createSession(yt,{experience:Te.target,provider:ct,modelRef:{providerId:ct,modelId:Mt},openPondCommandAccessMode:mo,appId:null,appName:null,workspaceId:null,workspaceName:null,localProjectId:null,cloudProjectId:null,cloudTeamId:null,cwd:null,title:`Continue ${ua?.title??"task"}`.slice(0,120),metadata:{experienceHandoff:V6({sourceTaskId:Te.sourceSessionId,sourceExperience:ua?.experience??null,targetExperience:Te.target,sourceMessageIds:Te.sourceMessageIds??[],sourceContext:Te.sourceContext,output:Te.output})}});return Vn(bn=>[bo,...bn]),W(Te.target),F(ct),I(Mt),i.set(Te.prompt),ln({kind:"chat",sessionId:bo.id}),s({type:"selectSession",sessionId:bo.id,appId:null,projectId:null}),U(null),V(null),pe(!1),p("chat"),G("home"),X(Te.target==="work"),oe(!1),bo},[$n,mo,Tn,s,Nt?.providers,i,yt,oe,X,W,I,F,G,U,V,Vn,pe,p,lt]),mc=g.useCallback(Te=>{Us(Te),dc(null),ta(null),Be(!0)},[ta,Be]),em=g.useCallback(Te=>{ta(null),W("work"),i.set(`$openpond-refiner-authoring ${Te}`),p("chat"),Be(!0)},[ta,i,W,Be,p]),Sr=g.useCallback(Te=>{dc(H6(Te)),Us(null),ta(null),Be(!0)},[ta,Be]);g.useEffect(()=>{!Ls&&!zs||te!=="chat"||Z||xe||Ie||($s(Ls),Ds(zs),Us(null),dc(null),G("home"),oe(!1),X(!0))},[Ls,zs,Ie,xe,Z,oe,X,G,te]),g.useEffect(()=>{!Os&&!Ns||te==="chat"&&be&&ge==="home"||($s(null),Ds(null))},[be,Ns,Os,ge,te]);const tm=g.useCallback(()=>{$s(null),Ds(null),oe(!1),X(!1)},[oe,X]),nm=g.useCallback(Te=>{let ct;if(Te.workspaceKind==="local"){const Mt=vt("local",Te.workspaceId);ct=`draft:${Mt}`,U(null),V(Mt),le(null),Fa(Mt),p("chat")}else{const Mt=lt.find(ua=>ua.id===Te.sourceSessionId||ua.workspaceId===Te.workspaceId);if(!Mt){bt("This saved file's cloud chat is no longer available.","error");return}ct=Mt.id,En(Mt.id)}G("changes"),X(!0),Hs({id:Date.now(),conversationId:ct,file:Te}),Te.available||bt(`File unavailable: ${Te.path}`,"error")},[Fa,En,X,G,U,V,le,p,bt,lt]);g.useEffect(()=>{if(!U6(Za,pn))return;const Te=window.setTimeout(()=>{G("changes"),X(!0),Hs(ct=>z6(ct,Za.id))},0);return()=>window.clearTimeout(Te)},[pn,X,G,Za]);const am=K6(te);g.useEffect(()=>{if(r){if(r.kind==="models"||r.kind==="models_unavailable"){te!=="labs"&&p("labs");return}if(r.kind==="settings"){U(null),V(null),le(null),fe(r.section),te!=="settings"&&p("settings");return}if(r.kind==="view"){U(null),V(null),le(null),te!==r.view&&p(r.view);return}r.sessionId!==null&&(U(null),V(null)),le(r.sessionId),te!=="chat"&&p("chat")}},[r,U,V,le,fe,p,te]);const om=g.useCallback(Te=>{if(rt(null),U(null),V(null),le(null),Te==="models"){ji(ro()),p("labs");return}Te==="chat"&&ln({kind:"chat",sessionId:null}),qe(Ig())},[qe,ln,rt,U,V,le,p]),rm=g.useCallback(async(Te,ct)=>{const Mt=await Ut.actions.acceptHarnessReview(Te,ct,{providerId:Tn,modelId:$n},he);return Mt?(y(Mt.materializedTasksetId??null),ji(ro()),p("labs"),!0):(bt("Taskset review could not be opened.","error"),!1)},[$n,Tn,he,ji,ro,y,p,bt,Ut.actions]);if(!sn.ready)return x.jsx(o6,{startup:sn});if(te==="settings")return x.jsx(cy,{showToast:bt,children:x.jsx(e6,{settings:{payload:Nt,connection:yt,diagnostics:Fu,initialSection:ie,onPayload:rn,onError:nn,onToast:bt,onOpenSourceSession:En,onStartRefinerAuthoring:em,onAcceptEvaluationReview:rm,onOpenSkill:mc,onOpenExtension:Sr,teamChatCurrentUserId:kt.currentUserId,teamChatEnabled:ea!==null,teamChatNotificationMode:kt.notificationMode,teamChatThreads:kt.threads,onTeamChatNotificationModeChange:kt.setNotificationMode,onTeamChatThreadMuteChange:kt.setThreadMuted,diffPanelWidth:qn,diffPanelResizing:ot,diffPanelExpanded:ne,onDiffPanelResizeStart:ae,onDiffPanelExpandedChange:oe,onBack:()=>{const Te=A4(r);ln(Te),p(Te.kind==="models"?"labs":"chat"),Be(!0)}},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})});const im=eu(),Bs=yt?.platform??navigator.platform,pc=im&&rg(Bs),Fs=Fo,sm=vo?.initialized?vo.repoPath:gt?.cwd??null,lm={"--sidebar-width":`${ia}px`,"--diff-panel-width":`${qn}px`},cm=te==="chat"&&ke!=="chat"||te==="labs"||te==="scheduled"&&n||te==="team"&&!!ur,dm=["app-shell",pc?"platform-macos":"",de?"sidebar-open":"sidebar-closed",qt?"sidebar-resizing":"",ot?"diff-panel-resizing":""].filter(Boolean).join(" "),at=Z?ei[Z]:null,Xt=Z?at?.cursorSequence??s6(Io(ms,Zl(Ct,Z))):null,Gt=!!Z&&!!yt&&(Ht(Z)?!0:!!Nt?.eventWindow?.hasMoreBefore&&!!Xt)&&(at?.hasMore??!0),Ca=!!at?.loading,um=(()=>{const Te=Ut.payload;if(!Te)return{};const ct=new Map(Te.plans.map(bn=>[bn.id,bn])),Mt=new Set(["queued","starting","running","cancelling","reconciling"]),ua={queued:"Queued",starting:"Starting",running:"Running",cancelling:"Cancelling",reconciling:"Reconciling"},bo={};for(const bn of[...Te.modelRuns].sort((Ra,fi)=>fi.updatedAt.localeCompare(Ra.updatedAt))){if(bn.kind==="evaluation"||!["prepared","running"].includes(bn.status))continue;const Ra=Te.jobs.filter(mm=>mm.metadata.modelRunId===bn.id).sort((mm,D_)=>D_.updatedAt.localeCompare(mm.updatedAt))[0];if(Ra&&!Mt.has(Ra.status))continue;const fi=Ra?.status??(bn.status==="prepared"?"starting":"running");bo[bn.modelId]={label:ua[fi]??"Running",status:fi}}for(const bn of[...Te.jobs].sort((Ra,fi)=>fi.updatedAt.localeCompare(Ra.updatedAt))){if(!Mt.has(bn.status))continue;const Ra=ct.get(bn.planId)?.modelId;!Ra||bo[Ra]||(bo[Ra]={label:ua[bn.status]??"Active",status:bn.status})}return bo})();return x.jsx(cy,{showToast:bt,children:x.jsx(X3,{className:dm,style:lm,sidebar:{productArea:am,modelProjects:(Ut.payload?.modelProjects??[]).filter(Te=>Te.hosted===null||Te.hosted.teamId===(Ha.defaultTeamId?.trim()??null)),modelTrainingActivityByProjectId:um,onProductAreaChange:om,experience:ke,view:te,selectedAppId:Ie,selectedProjectId:xe,selectedSessionId:Z,selectedTeamThreadId:kt.selectedThreadId,teamChatEnabled:ea!==null,organizations:uo,teamChatOrganization:qa,teamChatLoading:kt.loading,currentUserId:kt.currentUserId,teamMembers:kt.members,teamThreads:kt.threads,...ca,account:kn,connection:yt,profile:Nt?.profile,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Da,archivedChatsOpen:B,cloudProjectsExpanded:K,sectionMenuOpen:N,dragItem:ui,taskDragSessionId:vs,taskPreviewSessionIds:vr,activeSessions:Va,archivedSessions:po,pinnedRows:mi,pinnedSessions:Fn,savedForLaterSessions:ps,savedForLaterFiles:fs,projectRows:Ia,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:hs,childSessionRowsByParentId:gs,sidebarProjectIdBySessionId:ho,terminalSummaries:gr,runningSessionIds:go,goalRuntimeBySessionId:Wa,subagentRuntimeBySessionId:si,visibleChatRows:ai,chatRows:pr,chatRowsVisibleCount:fr,expandedProjectIds:is,currentVersion:Nt?.server.version??null,platform:Bs,arch:yt?.arch??null,onSidebarResizeStart:za,setSidebarOpen:Be,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setSearchOpen:Xe,setSectionMenuOpen:rt,setSettingsSection:fe,onSelectTeam:Wu,onLogOut:Gu,onTogglePinnedCollapsed:xn,onToggleCloudProjectsCollapsed:La,onToggleChatsCollapsed:Ua,onToggleSavedForLaterCollapsed:sa,setArchivedChatsOpen:et,setCloudProjectsExpanded:it,setChatRowsVisibleCount:Me,beginNewChat:Ku,beginProjectChat:pi,dockSessionRight:Ms,selectTeamThread:Te=>{p("team"),kt.selectThread(Te)},openTeamDm:Te=>{p("team"),kt.openDm(Te)},toggleSessionPinned:nc,toggleProjectPinned:ac,toggleSessionSavedForLater:Ts,openSidebarFile:nm,setSidebarFileStatus:(Te,ct)=>{ni(Te,ct)},archiveSession:Cu,restoreSession:Ru,renameSession:tc,removeProject:Vu,expandProject:Fa,toggleProjectExpanded:ss,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:ys,commitPinnedDrop:Ss,commitPinnedPreviewDrop:xs,startTaskDrag:li,clearTaskDrag:ci,previewTaskDrop:di,commitTaskDrop:bs,commitTaskPreviewDrop:br},topBar:{sidebarOpen:de,title:Kn,backAction:_e.backAction,breadcrumbs:_e.breadcrumbs,conversationId:te==="chat"?Z:null,workspaceName:Zr,workspaceId:Wr,busy:ue,workspaceState:vo,workspaceKind:Gr,selectedApp:xt??Ke,selectedProject:Ze,workspaceDiff:Nn,managedWorkspace:_s,workspaceBusy:yr,defaultTeamId:Ha.defaultTeamId,showDiffControls:te==="chat"&&ke==="development",diffPanelOpen:be,terminalOpen:Se,rightSidebarAvailable:cm,rightSidebarOpen:te==="scheduled"?n:be,onToggleDiffPanel:cc,onToggleRightSidebar:te==="scheduled"?()=>a(Te=>!Te):te==="team"&&ur?mr:cc,onOpenSearch:()=>{rt(null),Xe(!0)},onToggleTerminal:()=>pe(Te=>!Te),onRunTerminalCommand:Te=>{m({id:Date.now(),scope:Fs,command:Te}),pe(!0)},onWorkspaceToolAction:fu,onOpenCommitDialog:Ps,onWorkspaceBranchChange:mu,onWorkspaceBranchCreate:Yl,connection:yt,onBootstrap:rn,onOpenSandboxWorkspace:Tu,onShowSidebar:()=>Be(!0),onOpenTeamChat:uc,onDiscoverCommunities:Qu,collaborationView:te==="team"||te==="community"?te:null,platform:Bs,showWorkspaceControls:te!=="team"&&te!=="community"&&te!=="labs"&&te!=="scheduled"&&te!=="outputs"&&te!=="projects"&&(ke==="development"||ke==="work"&&!!(Ze||gt?.localProjectId||gt?.cloudProjectId||gt?.workspaceKind==="local_project"))},mainPane:{experience:ke,onNewExperienceChange:qe,view:te,teamChat:{currentUserId:kt.currentUserId,members:kt.members,agents:kt.agents,profile:Nt?.profile??null,teamId:ea,teamName:qa?.displayName??null,detail:kt.detail,aiThread:kt.aiThread,agentConversation:kt.agentConversation,loading:kt.loading,busy:kt.busy,error:kt.error,connection:yt,providerSettings:Nt?.providers??null,provider:Tn,model:$n,codexPermissionMode:Ae,codexReasoningEffort:he,openPondCommandAccessMode:mo,contextWindowStatus:_a,showToast:bt,onProviderChange:Ql,onModelChange:I,onCodexPermissionModeChange:Jr,onCodexReasoningEffortChange:Yr,onOpenPondCommandAccessModeChange:Qr,onOpenProviderSettings:()=>{fe("providers"),p("settings"),ln({kind:"settings",section:"providers"})},onSendMessage:kt.sendMessage,onPublishProfileAgent:Ba,onOpenAiThread:async Te=>{await kt.openAiThread(Te),G("chat"),X(!0)},onOpenAgentConversation:async Te=>{await kt.openAgentConversation(Te),G("chat"),X(!0)},onCloseAiThread:()=>X(!1),onCloseAgentConversation:()=>{kt.closeAgentConversation(),X(!1)},onSendAgentTurn:kt.sendAgentTurn,onSendAiTurn:kt.sendAiTurn,onStopAiTurn:kt.stopAiTurn,onEditMessage:kt.editMessage,onDeleteMessage:kt.deleteMessage,onRetryMessage:kt.retryMessage,onDismissFailedMessage:kt.dismissFailedMessage,onLoadMoreMessages:kt.loadMoreMessages,onRetryLoad:kt.refresh},community:Vr,bootstrap:Nt,runtimeEvents:oi,chatMessages:da,pendingUserMessage:Z?St[Z]??null:null,contextWindowStatus:_a,goalRuntime:hr,subagentRuntime:ri,selectedSessionId:Z,composerDraftStore:i,mainComposerFocusRequestId:$,labCloseDetailRequestId:_e.closeDetailRequestId,labCloseDetailKind:_e.closeDetailKind,sideChatTrainingLaunchRequest:sc,onSideChatTrainingLaunchHandled:Te=>Ou(ct=>ct?.id===Te?null:ct),mentionApps:Bn,connectedAppMentions:tt,profileSkills:Yu,selectedMentionAppId:w,busy:ue,turnRunning:ii,activeProvider:Tn,activeModel:$n,codexPermissionMode:Ae,codexReasoningEffort:he,openPondCommandAccessMode:mo,pendingApproval:_n,activeWorkspaceAppId:Kr,activeWorkspaceId:Wr,activeWorkspaceKind:Gr,projectTarget:mt,actionCatalog:rs,workspaceTarget:Bt,connection:yt,workspaceName:Zr,workspaceState:vo,workspaceDiff:Nn,workspaceBusy:yr,diffBusy:ws,forceChatThread:!!Z,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:ge,rightPanelTabRequest:P,rightChatPanels:Nu,runtimeEventStore:la,nativeSkillSidebar:Os,extensionSkillSidebar:Ns,workspaceDiffPanelViewState:L,sidebarFileOpenRequest:Za,sidebarFileBookmarks:vn,onSetSidebarFileStatus:(Te,ct)=>{ni(Te,ct)},browserConversationId:pn,terminalScope:Fs,terminalTabs:u,terminalCwd:sm,pendingTerminalCommand:l,terminalOpen:Se,onToggleTerminal:()=>pe(Te=>!Te),onWorkspaceDiffPanelViewStateChange:na,training:Ut,trainingSessions:lt,trainingChatHandoff:us,trainingDetailTasksetId:b,onTrainingDetailTasksetIdChange:y,onTrainingChatTaskSelect:Xr,onTrainingChatHandoffDismiss:ds,onOpenSession:En,onExperienceHandoff:Xu,cloudProjects:Nt?.cloudProjects??[],projects:Zu,projectsAccountBaseUrl:kn?.baseUrl??kn?.activeProfile?.baseUrl??null,projectsTeamName:qa?.displayName??null,projectTaskCounts:Ju,onNewCloudProject:rc,onNewProjectTask:Te=>pi(Te.id),onToggleProjectPinned:ac,onUploadLocalProject:Pu,chatHistoryHasMore:Gt,chatHistoryLoading:Ca,onDiffPanelResizeStart:ae,onToggleDiffPanelExpanded:()=>oe(Te=>!Te),onShowDiffPanel:Mu,onShowBrowserPanel:ic,onShowFilesPanel:()=>Ko("files"),onShowGoalSidebarTab:ju,onShowTrainingDraftPanel:()=>{G("training"),X(!0)},onShowRightChatPanel:Du,onAddRightChat:()=>Ms(null),onOpenRightChatForSession:(Te,ct)=>{const Mt=ct??lt.find(ua=>ua.id===Te)??null;Mt&&Ms(Mt,{preserveView:!0})},onLabDetailOpenChange:_e.onDetailOpenChange,scheduledDetailOpen:n,onScheduledDetailOpenChange:a,onTerminalTabsChange:h,onCloseRightChatPanel:$u,onCloseNativeSkillSidebar:tm,onActivateRightChatPanel:Lu,onRightChatModelChange:Uu,onRightChatPromptChange:zu,onRightChatScrollStateChange:qu,onRightChatProviderChange:Hu,onSubmitRightChat:lc,onStopRightChat:Te=>As(Te),onCloseTerminal:()=>pe(!1),onLoadMoreChatHistory:ti,canSyncWorkspace:Cs,startMessage:wa,onPayload:rn,onError:nn,setView:p,onOpenProfileSettings:Bu,onOpenProviderSettings:()=>{ln({kind:"settings",section:"providers"})},onOpenTrainingSettings:()=>{ln({kind:"settings",section:"training"})},onOpenDatasetStorageSettings:()=>{ln({kind:"settings",section:"dataset-storage"})},changeDraftProvider:Ql,changeProjectTarget:du,changeWorkspaceTarget:Au,setDraftProvider:F,setDraftModel:I,onBeginNewChatWithModel:cs,changeCodexPermissionMode:Jr,changeCodexReasoningEffort:Yr,changeOpenPondCommandAccessMode:Qr,resolveApproval:ls,answerCreateImproveQuestion:bu,applyCreateImproveCandidate:yu,approveCreateImproveRun:Su,cancelCreateImproveRun:xu,openCreateImprovePullRequest:ku,reconcileCreateImprovePullRequest:Xl,rejectCreateImproveCandidate:wu,pauseCreateImproveRun:Iu,resumeCreateImproveRun:_u,reviseCreateImproveRun:ec,setMentionedAppId:_,showToast:bt,onSaveTaskDraft:qs,sendPrompt:Es,stopTurn:Te=>As(void 0,Te),syncWorkspaceLocally:vu,refreshWorkspaceDiff:Is},cloudSetup:{state:E,onClose:()=>j(null),onOpenBrowserUrl:Eu,onStart:()=>{oc()}},projectConfirm:{state:k,onResolve:C},lazyPanels:{activeSessions:Va,branchDialogName:Q,branchDialogOpen:H,commitDialogOpen:Le,commitDraft:M,commitIncludeUnstaged:De,commitMessage:Fe,commitNextStep:D,canPublishOpenPondProject:Rs,connection:yt,expandProject:Fa,newProjectBusy:st,newProjectDialogOpen:we,newProjectDirectory:Ha.defaultNewProjectDirectory,newProjectMode:Oe,newProjectName:Qe,newProjectPath:Ge,projectRows:ks,query:A,searchOpen:z,visibleWorkspaceDiff:Nn,visibleWorkspaceState:vo,workspaceBusy:yr,appDispatch:s,beginNewChat:()=>ta(null),openDefaultsSettingsFromBranchDialog:pu,setBranchDialogName:Sn,setBranchDialogOpen:An,setCommitDialogOpen:Ve,setCommitDraft:Lt,setCommitIncludeUnstaged:ut,setCommitMessage:Ue,setCommitNextStep:Qt,setNewProjectDialogOpen:je,setNewProjectName:Ee,setNewProjectPath:Ne,setPrompt:re,setQuery:$e,setSearchOpen:Xe,submitCommitDialog:hu,submitCreateWorkspaceBranch:gu,submitNewProjectDialog:uu},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})})}const Ci=new Map,Kc=new Map;function bf(e){if(!e||e.state!=="signed_in")return null;const t=e.accounts.find(r=>r.isActive)??null,n=e.activeProfile?.handle?.trim()||t?.handle?.trim()||e.label.trim()||"signed_in",a=e.activeProfile?.baseUrl??t?.baseUrl??e.baseUrl??"";return[n,a,e.apiBaseUrl??"",e.chatApiBaseUrl??""].join("|")}function aV(e){const t=e?.trim();if(!t)return null;const n=Ci.get(t);return n?.updatedAt?n.organizations:null}function oV(e,t){const n=e?.trim();if(n){Ci.set(n,{organizations:t,promise:null,updatedAt:Date.now()});for(const a of Kc.get(n)??[])a()}}function rV(e,t){const n=e?.trim();if(!n)return()=>{};const a=Kc.get(n)??new Set;return a.add(t),Kc.set(n,a),()=>{a.delete(t),a.size===0&&Kc.delete(n)}}function by(e){const t=e.accountKey?.trim();if(!t)return Promise.resolve([]);const n=Ci.get(t);if(!e.force){if(n?.updatedAt)return Promise.resolve(n.organizations);if(n?.promise)return n.promise}const a=e.fetchOrganizations().then(r=>(oV(t,r),r)).catch(r=>{const i=Ci.get(t);throw i?.promise===a&&Ci.set(t,{organizations:i.organizations,promise:null,updatedAt:i.updatedAt}),r});return Ci.set(t,{organizations:n?.organizations??[],promise:a,updatedAt:n?.updatedAt??0}),a}const CJ="openpond.config.json";function RJ(e,t,n){return t<=0?-1:n==="Home"?0:n==="End"?t-1:n==="ArrowRight"?(e+1)%t:(e-1+t)%t}function OI(){return{activeTab:"files",openFilePaths:[],selectedPath:null}}function cp(e){return{activeTab:e.activeTab,openFilePaths:[...e.openFilePaths],selectedPath:e.selectedPath}}function PJ(e,t=null){const n=sV(e.openFilePaths.map(r=>Sy(r,t)).filter(Boolean)),a=e.selectedPath&&Sy(e.selectedPath,t)||null;return{activeTab:e.activeTab==="file"&&!a?"files":e.activeTab,openFilePaths:n,selectedPath:a}}function yy(e,t){return e.activeTab===t.activeTab&&e.selectedPath===t.selectedPath&&e.openFilePaths.length===t.openFilePaths.length&&e.openFilePaths.every((n,a)=>n===t.openFilePaths[a])}function Sy(e,t=null){let n=iV(e);const a=t?.trim().replace(/\\/g,"/").replace(/\/+$/,"");if(!a)return n;if(n===a)return"";n.startsWith(`${a}/`)&&(n=n.slice(a.length+1));const r=a.split("/").filter(Boolean).at(-1);return r&&n.startsWith(`${r}/`)&&(n=n.slice(r.length+1)),n}function AJ(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function TJ(e){return{path:e,status:"unchanged",additions:0,deletions:0,patch:"",content:null}}function EJ(e,t){const n=xy(e.path);return!n||e.path.endsWith("/")||e.content==null&&/Could not access .+\/null['"]?/.test(e.patch)?!0:t.some(a=>{const r=xy(a);return!!(r&&r.startsWith(`${n}/`))})}function MJ(e){return/\.(?:md|markdown|mdx)$/i.test(e)||/(?:^|\/)readme$/i.test(e)}function jJ(e){return/\.(?:doc|docx|pdf)$/i.test(e)}function iV(e){let t=e.trim().replace(/^['"`]+|['"`]+$/g,"");if(/^file:\/\//i.test(t))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.replace(/^file:\/\//i,"")}return t.replace(/\\/g,"/").replace(/^\.\/+/,"")}function sV(e){return Array.from(new Set(e))}function xy(e){const n=e.replace(/\\/g,"/").replace(/^\.\/+/,"").split("/").filter(Boolean);return n.length===0?null:n.join("/")}function lV(e){if(!e||e.state!=="signed_in")return null;const t=e.accounts.find(l=>l.isActive)??null,n=e.profile?.id?.trim()??"",a=e.activeProfile?.handle?.trim()||t?.handle?.trim()||e.label.trim()||"signed_in",r=e.activeProfile?.baseUrl??t?.baseUrl??e.baseUrl??"",i=e.apiBaseUrl??t?.apiBaseUrl??"",s=e.chatApiBaseUrl??t?.chatApiBaseUrl??"";return[n?`profile:${n}`:"profile:unknown",a,r,i,s].join("|")}function $I(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"cloud-project"}function cV(e){const t=new TextEncoder().encode(e);let n="";for(const a of t)n+=String.fromCharCode(a);return btoa(n)}function au(e){const t=e,n=t.teamId||t.id||"";if(!n)return null;const a=t.displayName||t.name||n,r=t.workspaceKind==="personal"||t.isPersonalDefault===!0||t.kind==="personal_default"||t.name?.trim().toLowerCase()==="personal";return{teamId:n,slug:t.slug||$I(a),name:t.name||a,displayName:a,role:t.role==="owner"||t.role==="admin"||t.role==="member"?t.role:"member",workspaceKind:t.workspaceKind==="personal"||t.workspaceKind==="shared"?t.workspaceKind:r?"personal":"shared",status:t.status==="disabled"||t.status==="archived"?t.status:"active",kind:t.kind==="personal_default"||t.kind==="managed_client"||t.kind==="team"?t.kind:void 0,isPersonalDefault:r,isManagedClient:t.isManagedClient===!0||t.kind==="managed_client",primaryContactEmail:t.primaryContactEmail??null,customDomain:t.customDomain??null,planKey:typeof t.planKey=="string"?t.planKey:null,effectiveAccessState:t.effectiveAccessState==="checkout_pending"||t.effectiveAccessState==="active"||t.effectiveAccessState==="grace"||t.effectiveAccessState==="suspended"||t.effectiveAccessState==="cancelling"||t.effectiveAccessState==="cancelled"?t.effectiveAccessState:null,canManageBilling:t.canManageBilling===!0||t.role==="owner",createdAt:t.createdAt??"",updatedAt:t.updatedAt??""}}function dV(e){return e.find(t=>t.workspaceKind==="personal"||t.isPersonalDefault===!0||t.kind==="personal_default")??e.find(t=>t.name.trim().toLowerCase()==="default")??e.find(t=>t.isManagedClient!==!0&&t.kind!=="managed_client")??e[0]??null}function uV(e,t){const n=e.filter(r=>r.status==="active"&&r.workspaceKind==="shared"),a=t?.trim()??"";if(a){const r=n.find(i=>i.teamId===a);if(r)return r}return n.find(r=>r.role==="owner")??n.find(r=>r.role==="admin")??n[0]??null}function mV(...e){for(const t of e){const n=t?.trim();if(n)return n}return""}function pV({draftProvider:e,hasSelectedCloudProject:t,selectedSessionHybridWorkspace:n}){return t&&!n?"openpond":e}const fV=[{value:"action:new-local-project",label:"New local project",detail:"Create a new project folder on this machine",kind:"action"},{value:"action:add-local-project",label:"Use existing folder",detail:"Choose a folder on this machine",kind:"action"},{value:"action:add-local-project-path",label:"Use existing folder path",detail:"Enter a local folder path manually",kind:"action"},{value:"action:new-cloud-project",label:"New cloud project",detail:"Create a project in OpenPond Cloud",kind:"action"},{value:"action:create-cloud-environment",label:"Create cloud environment",detail:"Set up compute for a cloud project",kind:"action"}];function hV(...e){return mV(...e.map(t=>{const n=t?.trim();return n&&!n.includes("@")?n:null}))}function gV(e){if(e?.state!=="signed_in")return"";const t=e.accounts.find(n=>n.isActive)??null;return hV(e.profile?.name,e.label,t?.displayLabel,e.profile?.handle,t?.handle,e.activeProfile?.handle)}function vV({bootstrap:e,draftModel:t,draftProvider:n,selectedApp:a,selectedAppId:r,selectedCloudProject:i,selectedProject:s,selectedSession:l,selectedSessionId:m,selectedSessionLinkedProject:u}){const h=l?.workspaceKind==="local_project"?l.workspaceId??null:u?.id??null,b=Ht(m)&&!l,y=l?lo(l.workspaceKind):!1,w=co(l),_=l?X6(l):!1,E=l?.cwd&&(!y||w)?tx(l.cwd):null,j=e?.providers??null,P=Sa(s,e?.cloudProjects??[]),L=pV({draftProvider:n,hasSelectedCloudProject:!!i,selectedSessionHybridWorkspace:w}),$=cr(L,t,j),O=pa(e?.preferences),k=b?null:l?y?l.workspaceKind??"sandbox":_?"sandbox":h?"local_project":l.workspaceKind??(l.appId?"sandbox_app":E?"local_project":null):i?"sandbox":s?"local_project":r?"sandbox_app":null,C=b?null:l?y&&!w||_?null:h||(l.workspaceId??l.appId??E):i?null:s?.id??r,A=b?null:l?y?l.workspaceId??null:_?null:h??l.workspaceId??l.appId??E:i?null:s?.id??r,z=e?.account??null,B=!e||z?.state==="loading"||z?.state==="switching",N=!B&&z?.state==="signed_out",K=B?null:N?"Sign in":z?.label??z?.activeProfile?.handle??"Account",de=gV(z),te=de?`Welcome, ${de}`:"Welcome",Ie=l?.workspaceName??l?.appName??i?.name??s?.name??a?.name??null,xe=lo(k)?"cloud":"local",Z=s?.name??u?.name??(l?.workspaceKind==="local_project"?l.workspaceName:null)??"Local workspace",Ae=(xe==="cloud"?Ie:null)??i?.name??P?.name??s?.name??"Cloud workspace",he=!!(i?.id||P?.id||l?.cloudProjectId||xe==="cloud");return{account:z,accountLabel:K,accountPending:B,accountSignedOut:N,activeModel:$,activeProvider:L,activeWorkspaceAppId:C,activeWorkspaceId:A,activeWorkspaceKind:k,activeWorkspaceLocation:xe,appDefaults:O,cloudLinked:he,cloudTargetName:Ae,localTargetName:Z,selectedCodexHistoryPending:b,selectedSessionCloudWorkspace:y,selectedSessionLocalPathWorkspaceId:E,selectedSessionPendingCloudStart:_,selectedSessionProjectId:h,startMessage:te,workspaceName:Ie}}function bV({accountPending:e,accountSignedOut:t,activeWorkspaceLocation:n,bootstrap:a,busy:r,cloudLinked:i,selectedCloudProject:s,selectedProject:l,selectedSession:m,pendingWorkspaceTarget:u,workspaceStates:h,workspaceBusy:b}){const y=Sa(l,a?.cloudProjects??[]),_=!!!l?.linkedSandboxProject?.projectId||!!y,E=g.useMemo(()=>{const A=(a?.localProjects??[]).map(K=>({value:`local:${K.id}`,label:K.name,detail:K.workspacePath,kind:"local"})),z=(a?.cloudProjects??[]).map(K=>({value:`cloud:${K.id}`,label:K.name,detail:K.organizationName??K.sourceLabel??"OpenPond Cloud",kind:"cloud"})),B=l?`local:${l.id}`:s?`cloud:${s.id}`:"none",N=[...A,...z].find(K=>K.value===B)??null;return{value:B,label:N?.label??"Select Project",detail:N?.detail??"Choose a project for local or cloud work",busy:b||r,options:[...A,...z,...fV,{value:"none",label:"Don't work in a project",detail:"General chat without project files",kind:"none"}]}},[a?.cloudProjects,a?.localProjects,r,s,l,b]),j=!!(i||l),P=!!(s?.id||y?.id||m?.cloudProjectId||co(m)),L=l?h[l.id]??null:null,$=Y1(L,{branch:l?.linkedSandboxProject?.defaultBranch??null,path:l?.workspacePath??m?.cwd??null,linkedCloudSourceKnown:l?.linkedSandboxProject?.projectId&&_?!!l.linkedSandboxProject.lastUploadedCommit||!L?.headCommit:!0}),O=Q1(l,s??y,L,{cloudLinkTrusted:_}),k=u5(l,L,{cloudLinkTrusted:_}),C=g.useMemo(()=>{const A={value:"local",label:l?"Local checkout":"Local",detail:l?"Use the selected checkout on this machine.":"Use an app-managed task workspace on this machine.",stateNote:l?$:"App-managed local task workspace",disabled:!1,disabledReason:null},z={value:"hybrid",label:"Hybrid",detail:"Use your selected model with hosted sandbox edits.",stateNote:P?O:"upload required",disabled:e||t||!P,disabledReason:t?"Add an OpenPond account before using Hybrid.":"Upload/sync this Project to Cloud before using Hybrid."},B={value:"cloud",label:"Hosted",detail:"Run with hosted compute, with or without a Project.",stateNote:l||s?O:"Projectless hosted task",disabled:e||t,disabledReason:t?"Add an OpenPond account before using Cloud.":e?"Checking OpenPond account.":null},N={value:"upload_cloud",label:"Upload/sync to cloud",detail:"Push local source to OpenPond Git before cloud work.",stateNote:k,disabled:e||t||!l,disabledReason:t?"Add an OpenPond account before uploading source.":"Select a local Project before uploading source."},K=n==="cloud"?"local":"cloud",de=K==="local"?A:B;let te=n==="cloud"?B:A;return u==="cloud"?te=B:u==="local"?te=A:(co(m)||u==="hybrid")&&(te=z),{value:te.value,label:te.label,detail:te.stateNote||te.detail,busy:b,action:{...de,label:K==="cloud"?"Hosted":l?"Local checkout":"Check out locally"},uploadAction:l?N:null,options:[A,z,B]}},[n,e,t,i,j,O,P,$,u,l,m,k,b]);return{projectTarget:E,workspaceTarget:C}}function jn(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function NI(e){return jn(e.name||e.gitRepo||e.id)}function OJ(e){return`@${NI(e)}`}function DI(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function yV(e,t){const n=DI(e);if(n.length===0)return!1;const a=new Set([jn(t.id),NI(t),t.gitRepo?jn(t.gitRepo):""].filter(Boolean));return n.some(r=>a.has(r))}function LI(e){return e.filter(t=>t.sandbox)}function SV(e,t){const n=DI(e);if(n.length===0)return null;const a=new Map;for(const r of n){const i=t.find(s=>{const l=jn(s.id),m=jn(s.name),u=s.gitRepo?jn(s.gitRepo):"";return r===l||r===m||r===u});i&&a.set(i.id,i)}return a.size===1?Array.from(a.values())[0]??null:null}function $J(e,t){const n=e.slice(0,t),a=n.match(/(?:^|\s)@([A-Za-z0-9_-]*)$/);if(!a||typeof a.index!="number")return null;const r=n.slice(a.index).indexOf("@");return r<0?null:{query:jn(a[1]??""),start:a.index+r}}function xV(e){return new Set(e.map(t=>t.id))}function ky(e,t){const n=e?.linkedOpenPondApp??null;return n?.appId&&t.has(n.appId)?n:null}function kV({bootstrap:e,codexHistorySessions:t,selectedProjectId:n,selectedSessionId:a,selectedAppId:r,sessions:i}){const s=g.useMemo(()=>e?.apps.find(N=>N.id===r)??null,[e?.apps,r]),l=g.useMemo(()=>new Map((e?.localProjects??[]).map(N=>[N.id,N])),[e?.localProjects]),m=g.useMemo(()=>new Map((e?.cloudProjects??[]).map(N=>[N.id,N])),[e?.cloudProjects]),u=g.useMemo(()=>U1(n),[n]),h=g.useMemo(()=>u?.kind==="local"?l.get(u.id)??null:null,[l,u]),b=g.useMemo(()=>u?.kind==="cloud"?m.get(u.id)??null:null,[m,u]),y=g.useMemo(()=>xV(e?.apps??[]),[e?.apps]),w=g.useMemo(()=>LI(e?.apps??[]),[e?.apps]),_=g.useMemo(()=>{const N=[];for(const K of e?.localProjects??[]){const de=ky(K,y);de&&N.push([de.appId,K.id])}return new Map(N)},[e?.localProjects,y]),E=g.useMemo(()=>new Set((e?.localProjects??[]).map(N=>N.id)),[e?.localProjects]),j=g.useMemo(()=>V1(e?.localProjects??[]),[e?.localProjects]),P=g.useRef([]),L=g.useMemo(()=>wV(i,t,P.current),[t,i]),$=g.useMemo(()=>L.find(N=>N.id===a)??null,[L,a]),O=g.useMemo(()=>{if(!$)return null;if($.localProjectId)return l.get($.localProjectId)??null;if($.workspaceKind==="local_project")return $.workspaceId?l.get($.workspaceId)??null:null;const N=X4($,E,j);if(N)return l.get(N)??null;if(!$.appId)return null;const K=_.get($.appId);return K?l.get(K)??null:null},[_,l,E,j,$]),k=g.useMemo(()=>$?.cloudProjectId?m.get($.cloudProjectId)??null:null,[m,$]),C=h??O,A=b??k,z=g.useMemo(()=>ky(C,y),[y,C]),B=g.useMemo(()=>z?e?.apps.find(N=>N.id===z.appId)??null:null,[e?.apps,z]);return{cloudProjectById:m,currentAppIds:y,linkedProjectByAppId:_,localProjectById:l,mentionableSandboxApps:w,selectedApp:s,selectedCloudProject:A,selectedProject:C,selectedProjectLinkedApp:B,selectedProjectLinkedOpenPondApp:z,selectedSession:$,selectedSessionLinkedProject:O,sidebarSessions:L}}function wV(e,t,n){const a=new Map;for(const u of e){const h=wy(u);a.set(h,u)}for(const u of t){const h=wy(u),b=a.get(h);a.set(h,b?IV(b,u):u)}const r=Array.from(a.entries());if(!n)return r.sort((u,h)=>Iy(u[1],h[1])).map(u=>u[1]);const i=[],s=new Set;for(const u of n){const h=a.get(u);h&&(i.push([u,h]),s.add(u))}const m=[...r.filter(([u])=>!s.has(u)).sort((u,h)=>Iy(u[1],h[1])),...i];return n.splice(0,n.length,...m.map(([u])=>u)),m.map(u=>u[1])}function IV(e,t){return{...e,metadata:_V(e.metadata,t.metadata),status:e.status==="active"||t.status==="active"?"active":e.status,updatedAt:CV(e.updatedAt,t.updatedAt)}}function wy(e){return e.codexThreadId?`codex:${e.codexThreadId}`:`session:${e.id}`}function Iy(e,t){const n=_y(t)-_y(e);return n!==0?n:e.title.localeCompare(t.title)}function _V(e,t){const n={...e??{},...t??{}};return Object.keys(n).length>0?n:void 0}function CV(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return t;const a=Date.parse(t);return Number.isFinite(a)&&a>n?t:e}function _y(e){const t=Date.parse(e.updatedAt);if(Number.isFinite(t))return t;const n=Date.parse(e.createdAt);return Number.isFinite(n)?n:0}function RV(e){return!!(e&&lo(e.workspaceKind)&&!co(e)&&e.provider!=="openpond")}function PV(e,t){const n=q1(e,t);return`${e.id}\0${n.provider}\0${n.model}`}function AV({activeWorkspaceId:e,activeWorkspaceKind:t,appDispatch:n,connection:a,expandProject:r,linkedProjectByAppId:i,providerSettings:s,selectedAppId:l,selectedSession:m,selectedSessionId:u,selectedSessionProjectId:h,setDiffPanelExpanded:b,setDraftModel:y,setDraftProvider:w,setError:_,setSelectedAppId:E,setSelectedProjectId:j,setSessions:P,setTerminalOpen:L,toast:$}){const O=g.useRef(null);g.useEffect(()=>{if(!l)return;const k=h??(u?null:i.get(l)??null);if(!k)return;const C=vt("local",k);E(null),j(C),r(C)},[r,i,l,u,h,E,j]),g.useEffect(()=>{if(!$||$.persistent)return;const k=window.setTimeout(()=>{n({type:"clearToast",toastId:$.id})},$.durationMs??($.tone==="error"?7e3:3500));return()=>window.clearTimeout(k)},[n,$]),g.useEffect(()=>{function k(C){(C.metaKey||C.ctrlKey)&&C.key==="`"&&(C.preventDefault(),L(A=>!A))}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[L]),g.useEffect(()=>{b(!1)},[e,t,b]),g.useEffect(()=>{if(!u){O.current=null;return}if(!m||m.id!==u)return;const k=PV(m,s);if(O.current===k)return;O.current=k;const C=q1(m,s);w(C.provider),y(C.model)},[s,m,u,y,w]),g.useEffect(()=>{!a||!m||!RV(m)||J.patchSession(a,m.id,{provider:"openpond"}).then(k=>{P(C=>C.map(A=>A.id===k.id?k:A)),w("openpond"),y(C=>cr("openpond",C))}).catch(k=>{_(k instanceof Error?k.message:String(k))})},[a,m,y,w,_,P])}function TV({connection:e,setError:t}){return g.useCallback(async(n,a)=>{if(!e){const r=new Error("OpenPond App server is not connected.");throw t(r.message),r}t(null);try{await J.resolveApproval(e,n,{decision:a})}catch(r){const i=r instanceof Error?r.message:String(r);throw t(i),r}},[e,t])}function EV({activeProvider:e,contextCompaction:t,contextUsage:n,pinnedItems:a,pinnedPreviewKeys:r,pinnedProjects:i,projectRows:s,visibleProjectRows:l}){const m=g.useMemo(()=>q4(a,r),[a,r]),u=g.useMemo(()=>uI({provider:e,snapshot:n,preferences:t}),[e,t,n]),h=g.useMemo(()=>Array.from(new Set([...i,...l].filter(hg).map(y=>y.project.id))),[i,l]);return{commandProjectRows:g.useMemo(()=>s,[s]),contextWindowStatus:u,pinnedRows:m,sidebarWorkspaceAppIds:h}}function MV({appDispatch:e,expandProject:t,linkedProjectByAppId:n,requestComposerFocus:a,onBeginNewChat:r,setMentionedAppId:i}){return g.useCallback((s=null)=>{r?.();const l=s?.id?n.get(s.id)??null:null;if(l){const m=vt("local",l);i(null),e({type:"selectProject",projectId:m}),t(m),a();return}i(null),e({type:"beginNewChat",appId:s?.id??null}),a()},[e,t,n,r,a,i])}const UI={slack:["slack"],microsoft_teams:["teams","microsoft-teams","microsoft_teams"],github:["github","gh"],google:["google","drive","google-drive","docs"],turnkey:["turnkey","agent-wallet","agent_wallet","wallet"],x:["x","twitter"],mcp:["mcp","openpond-mcp"]};function NJ(e){return`@${e.token}`}function jV(e){return`@${LV(e)}`}function OV(e){const t=new Map;for(const n of e){if(!n.connected||n.statusSource!=="integration_connection")continue;const a=t.get(n.providerFamily)??[];a.push(n),t.set(n.providerFamily,a)}return Array.from(t.entries()).map(([n,a])=>{const r=a[0],i=Si(a.flatMap(b=>b.capabilities.map(y=>y.id))),s=Si(a.flatMap(b=>b.capabilityLabels)),l=Si(a.flatMap(b=>b.connections.map(y=>y.id).filter(zV))),m=Si(a.map(b=>b.id)),u=Si(a.map(b=>b.setupSurface)),h=DV(n);return{provider:n,label:r.providerLabel,detail:s.length>0?s.slice(0,4).join(", "):r.description,token:h,tokens:NV(a),ref:{kind:"integration",provider:n,appIds:m,setupSurfaces:u,...l.length>0?{connectionIds:l}:{},...i.length>0?{capabilities:i}:{}}}})}function DJ(e,t){const n=jn(t);return e.filter(a=>n?a.tokens.some(r=>r.includes(n)):!0).slice(0,8)}function $V(e,t){const n=UV(e);if(n.length===0)return[];const a=new Map;for(const r of n){const i=t.find(s=>s.tokens.includes(r));i&&a.set(i.provider,i)}return Array.from(a.values())}function LJ(e,t){if(t.length===0)return[];const n=[];for(const a of e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)){const r=a[1]??"",i=jn(r);if(!i)continue;const s=t.find(b=>b.tokens.includes(i));if(!s)continue;const m=(a[0]??"").indexOf("@");if(m<0||typeof a.index!="number")continue;const u=a.index+m,h=`@${r}`;n.push({detail:s.detail,displayText:jV(s),end:u+h.length,label:s.label,provider:s.provider,start:u,text:h})}return n}function NV(e){return Si(e.flatMap(t=>[...UI[t.providerFamily],t.providerFamily,t.id,t.label,t.shortLabel]).map(jn).filter(Boolean))}function DV(e){return jn(UI[e][0]??e)}function LV(e){return e.provider==="github"?"GitHub":e.provider==="x"?"X":e.provider==="mcp"?"MCP":e.label}function UV(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function Si(e){return Array.from(new Set(e))}function zV(e){return typeof e=="string"&&e.length>0}function HV({bootstrap:e,connectedAppRows:t,mentionableSandboxApps:n,runtimeIndexes:a,selectedApp:r,selectedCloudProject:i,selectedProject:s,selectedSession:l,selectedSessionId:m}){const u=g.useMemo(()=>{const _=new Map;for(const E of e?.cloudProjects??[]){const j=_.get(E.teamId)??[];j.push(E.id),_.set(E.teamId,j)}return _},[e?.cloudProjects]),b=!!(l||r||s||i)?[]:n,y=g.useMemo(()=>OV(t),[t]),w=g.useMemo(()=>L6(a,m),[a,m]);return{chatMentionApps:b,cloudProjectIdsByTeam:u,connectedAppMentions:y,pendingApproval:w}}function qV({connection:e,setBootstrap:t,setCodexPermissionMode:n,setCodexReasoningEffort:a,setError:r}){const i=g.useCallback(l=>{if(!e){r("Connect to OpenPond before saving preferences.");return}J.savePreferences(e,{codexPermissionMode:l}).then(m=>{n(m.preferences.codexPermissionMode),a(m.preferences.codexReasoningEffort),t(u=>u&&{...u,preferences:m.preferences})}).catch(m=>{r(m instanceof Error?m.message:String(m))})},[e,t,n,a,r]),s=g.useCallback(l=>{if(!e){r("Connect to OpenPond before saving preferences.");return}J.savePreferences(e,{codexReasoningEffort:l}).then(m=>{n(m.preferences.codexPermissionMode),a(m.preferences.codexReasoningEffort),t(u=>u&&{...u,preferences:m.preferences})}).catch(m=>{r(m instanceof Error?m.message:String(m))})},[e,t,n,a,r]);return{changeCodexPermissionMode:i,changeCodexReasoningEffort:s}}const BV=6e4;function _g(e,t){if(!e)return t;const n=VV(e.updatedAt,t.updatedAt)?{...t,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order,status:e.status,updatedAt:e.updatedAt}:t;return HI(e,n)?e:n}function FV(e,t){const n=_g(e,t),a=e?{...n,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order,updatedAt:e.updatedAt}:n;return e&&HI(e,a)?e:a}function tl(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=_g(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function ou(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=FV(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function yf(e,t,n,a=Date.now()){const r=new Map(e.map(i=>[i.id,i]));return t.map(i=>{const s=r.get(i.id);if(s&&n){const l=WV(s,i,n,a);if(l)return l}return _g(s,i)})}function Cy(e,t,n,a=Date.now()){const r=new Map(e.map(u=>[u.id,u])),i=new Map(yf(e,t,n,a).map(u=>[u.id,u])),s=new Set(r.keys()),l=t.filter(u=>!s.has(u.id)).map(u=>i.get(u.id)??u),m=e.map(u=>{const h=i.get(u.id);return h||(zI(u,t)?u:null)}).filter(u=>!!u);return[...l,...m]}function zI(e,t){const n=Date.parse(e.updatedAt);if(!Number.isFinite(n))return!1;const a=KV(t);return a===null||n>=a}function Ry(e,t,n,a=Date.now()){const r=new Map(t.map(i=>[i.id,i]));for(const i of n){const s=r.get(i.id);s&&(qI(s,i)||(e[i.id]=a))}}function VV(e,t){const n=Date.parse(e),a=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(a)&&n>a}function HI(e,t){return JSON.stringify(e)===JSON.stringify(t)}function KV(e){let t=null;for(const n of e){const a=Date.parse(n.updatedAt);Number.isFinite(a)&&(t=t===null?a:Math.max(t,a))}return t}function WV(e,t,n,a){const r=n[t.id];return r===void 0?null:a-r>BV||qI(e,t)?(delete n[t.id],null):{...t,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order}}function qI(e,t){return e.pinned===t.pinned&&e.savedForLater===t.savedForLater&&e.archived===t.archived&&e.order===t.order}const BI=800,GV=5e3,Py=5e4,ZV=16,JV=3e4,Zn=new Map;function YV(e,t){return Zn.get(VI(e,t))?.payload??null}async function FI(e,t,n={}){const a=VI(e,t),r=Zn.get(a),i=n.limit??BI,s=n.tail??!0;if(r?.promise)return r.promise;if(!n.force&&s&&r?.payload&&Date.now()-r.fetchedAt<=JV)return Ay(a,r),r.payload;const l=!!(n.force&&s&&r?.payload),m=l?r?.payload?.events.at(-1)?.id:void 0,u=J.codexHistoryThreadIncremental(e,t,{afterEventId:m,limit:i,revision:l?r?.revision:void 0,tail:s}).then(h=>{const b=Zn.get(a)?.payload??r?.payload;if(h.unchanged){if(!b)throw new Error("Codex history revision matched without a cached thread.");return Zn.set(a,{fetchedAt:Date.now(),payload:b,revision:h.revision}),Ay(a,Zn.get(a)),b}const y={session:h.session,events:h.events},w=s&&b&&!h.reset?{...y,events:QV(b.events,y.events)}:y;return Zn.set(a,{fetchedAt:Date.now(),payload:w,revision:h.revision}),Ty(),w}).catch(h=>{throw Zn.get(a)?.promise===u&&Zn.delete(a),h});return Zn.set(a,{fetchedAt:r?.fetchedAt??0,payload:r?.payload,promise:u,revision:r?.revision}),Ty(),u}function VI(e,t){return`${e.serverUrl}
134
+ `)))}catch{}}async function DB(e,t){e<=0||t.aborted||await new Promise(n=>{const a=globalThis.setTimeout(n,e);t.addEventListener("abort",()=>{globalThis.clearTimeout(a),n()},{once:!0})})}class LB extends Error{constructor(t,n){super(t),this.status=n,this.name="ApiRequestError"}status}function $b(e={}){const t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),t}const Nb=new WeakMap,Db=new WeakMap,kc=new WeakMap;let UB=0;async function q(e,t,n){if(t==="/v1/preferences"&&typeof n?.body=="string"){const r=(kc.get(e)??Promise.resolve()).catch(()=>{}).then(()=>Lb(e,t,n));kc.set(e,r);try{return await r}finally{kc.get(e)===r&&kc.delete(e)}}return Lb(e,t,n)}async function Lb(e,t,n){const a=++UB;if(t==="/v1/preferences"&&typeof n?.body=="string"){const m=Nb.get(e);if(!m)throw new Error("Reload settings before saving so changes can be checked against the current file.");n={...n,body:JSON.stringify({expectedRevision:m,...JSON.parse(n.body)})}}const r=new Headers(n?.headers);r.set("Content-Type","application/json"),r.set("Authorization",`Bearer ${e.token}`);const i=await fetch(`${e.serverUrl}${t}`,{...n,headers:r});if(!i.ok){const m=await i.json().catch(()=>({})),u=m&&typeof m=="object"&&"error"in m?String(m.error):i.statusText;throw new LB(u,i.status)}const s=await i.json(),l=s?.configuration?.rawRevision??(t==="/v1/preferences"?s?.rawRevision:void 0);return typeof l=="string"&&a>=(Db.get(e)??0)&&(Nb.set(e,l),Db.set(e,a)),s}function JZ(e){const t=new URL("/v1/terminal",e.serverUrl);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.toString()}function YZ(e){return["openpond-terminal",`openpond-token.${HB(e.token)}`]}function zB(e){const t=new TextEncoder().encode(e);let n="";for(let a=0;a<t.length;a+=32768){const r=t.subarray(a,a+32768);n+=String.fromCharCode(...r)}return btoa(n)}function HB(e){return zB(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function qB(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return new TextDecoder().decode(n)}const BB={teamInvitations:e=>q(e,"/v1/team-invitations"),decideTeamInvitation:(e,t,n)=>q(e,`/v1/team-invitations/${t}`,{method:"POST",body:JSON.stringify({token:n})}),organizations:e=>q(e,"/v1/organizations"),createOrganization:(e,t)=>q(e,"/v1/organizations",{method:"POST",body:JSON.stringify(t)}),updateOrganization:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),organizationMembers:(e,t)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/members`),upsertOrganizationMember:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify(n)}),organizationMcpServer:(e,t)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`),generateOrganizationMcpServer:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`,{method:"POST",body:JSON.stringify(n)}),setOrganizationMcpServerStatus:(e,t,n)=>q(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server/${n}`,{method:"POST"})},FB={taskInbox:(e,t)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/inbox`),steerTurn:(e,t,n)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/turns/steer`,{method:"POST",body:JSON.stringify(n)}),queueTaskInput:(e,t,n,a)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/inbox`,{method:"POST",body:JSON.stringify({input:n,idempotencyKey:a})}),updateTaskInput:(e,t,n,a)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/inbox/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)}),sendTurn:(e,t,n)=>q(e,`/v1/sessions/${t}/turns`,{method:"POST",body:JSON.stringify(n)}),runSessionCommand:(e,t,n)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/commands`,{method:"POST",body:JSON.stringify(n)}),recordPreflightTurnFailure:(e,t,n)=>q(e,`/v1/sessions/${t}/preflight-turns/failure`,{method:"POST",body:JSON.stringify(n)}),listCreateImproveRuns:(e,t={})=>q(e,`/v1/create-improve-runs?${VB(t).toString()}`),getCreateImproveRun:(e,t)=>q(e,`/v1/create-improve-runs/${encodeURIComponent(t)}`),getCreateImproveCandidateDiff:(e,t,n)=>q(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/candidates/${encodeURIComponent(n)}/diff`),applyCreateImproveAction:(e,t,n)=>q(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/actions`,{method:"POST",body:JSON.stringify(n)}),interruptTurn:(e,t,n)=>q(e,`/v1/sessions/${t}/turns/interrupt`,{method:"POST",body:JSON.stringify({reason:n})}),compactSession:(e,t,n={reason:"manual"})=>q(e,`/v1/sessions/${t}/compact`,{method:"POST",body:JSON.stringify(n)}),workspaceTool:(e,t,n)=>q(e,`/v1/sessions/${t}/workspace-tools`,{method:"POST",body:JSON.stringify(n)}),ensureCloudWorkspaceReady:(e,t,n)=>q(e,`/v1/sessions/${encodeURIComponent(t)}/workspace/ensure-ready`,{method:"POST",body:JSON.stringify(n)})};function VB(e){const t=new URLSearchParams;return e.profileId&&t.set("profileId",e.profileId),e.conversationId&&t.set("conversationId",e.conversationId),e.targetKind&&t.set("targetKind",e.targetKind),e.targetId&&t.set("targetId",e.targetId),e.limit&&t.set("limit",String(e.limit)),t}const KB={sandboxFiles:(e,t,n={})=>{const a=new URLSearchParams({list:"1"});return n.path&&a.set("path",n.path),n.recursive!==void 0&&a.set("recursive",String(n.recursive)),n.maxEntries!==void 0&&a.set("maxEntries",String(n.maxEntries)),q(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${a.toString()}`)},sandboxUploadFile:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/files`,{method:"POST",body:JSON.stringify(n)}),preserveSandboxSource:(e,t,n={})=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/preserve-source`,{method:"POST",body:JSON.stringify(n)}),sandboxDownloadFile:async(e,t,n,a={})=>{const r=new URLSearchParams({path:n});a.offsetBytes!==void 0&&r.set("offsetBytes",String(a.offsetBytes)),a.maxBytes!==void 0&&r.set("maxBytes",String(a.maxBytes));const i=await q(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${r.toString()}`);return{...i,contents:i.file.isBinary?"":qB(i.file.contentsBase64)}}},WB={sandboxGitStatus:(e,t)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/status`),sandboxGitDiff:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/diff`,{method:"POST",body:JSON.stringify(n)})},GB={connectedAppStatus:(e,t={})=>{const n=$b(t);return n.set("status",t.status??"all"),q(e,`/v1/connected-apps/status${n.size>0?`?${n.toString()}`:""}`)},integrationConnections:(e,t={})=>{const n=$b(t);return t.status&&n.set("status",t.status),q(e,`/v1/integrations/connections${n.size>0?`?${n.toString()}`:""}`)},sandboxIntegrationLeases:(e,t)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`),attachSandboxIntegrationConnection:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"POST",body:JSON.stringify(n)}),removeSandboxIntegrationLease:(e,t,n)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:n})})},ZB={listSandboxProjects:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return q(e,`/v1/sandbox-projects?${n.toString()}`)},getSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`)},getSandboxProjectWorkspace:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/workspace?${a.toString()}`)},upsertSandboxProject:(e,t)=>q(e,"/v1/sandbox-projects",{method:"POST",body:JSON.stringify(t)}),syncSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/sync?${a.toString()}`,{method:"POST"})},uploadSandboxProjectSource:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId}),{teamId:r,...i}=n;return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/source?${a.toString()}`,{method:"POST",body:JSON.stringify(i)})},archiveSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return q(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`,{method:"DELETE"})},listSandboxAgents:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return q(e,`/v1/sandbox-agents?${n.toString()}`)},upsertSandboxAgent:(e,t)=>q(e,"/v1/sandbox-agents",{method:"POST",body:JSON.stringify(t)}),runSandboxAgent:(e,t,n)=>q(e,`/v1/sandbox-agents/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n)}),runProfileAction:(e,t)=>q(e,"/v1/profile/run",{method:"POST",body:JSON.stringify(t)})},JB={sandbox:(e,t)=>q(e,`/v1/sandboxes/${encodeURIComponent(t)}`)},YB={...GB,...ZB,...JB,...WB,...KB},QB={communities:(e,t)=>{const n=new URLSearchParams;return t&&n.set("cursor",t),q(e,`/v1/communities${n.size?`?${n}`:""}`)},communityPreview:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/preview`),communityRules:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/rules/current`),joinCommunity:(e,t,n)=>q(e,`/v1/communities/${encodeURIComponent(t)}/join`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),acceptCommunityRules:(e,t,n)=>q(e,`/v1/communities/${encodeURIComponent(t)}/rules/accept`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),leaveCommunity:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/leave`,{method:"POST",body:"{}"}),communityChannels:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels`),communityMessages:(e,t,n,a={})=>{const r=new URLSearchParams;return a.beforeSequence!=null&&r.set("beforeSequence",String(a.beforeSequence)),a.limit!=null&&r.set("limit",String(a.limit)),q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages${r.size?`?${r}`:""}`)},sendCommunityMessage:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify(a)}),editCommunityMessage:(e,t,n,a,r)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({body:r})}),deleteCommunityMessage:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"DELETE",body:"{}"}),markCommunityRead:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/read`,{method:"POST",body:JSON.stringify({sequence:a})}),setCommunityChannelMuted:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/mute`,{method:"POST",body:JSON.stringify({muted:a})}),searchCommunityMembers:(e,t,n={})=>{const a=new URLSearchParams;return n.query&&a.set("query",n.query),n.cursor&&a.set("cursor",n.cursor),n.limit!=null&&a.set("limit",String(n.limit)),q(e,`/v1/communities/${encodeURIComponent(t)}/members/search${a.size?`?${a}`:""}`)},updateCommunityNotifications:(e,t,n)=>q(e,`/v1/communities/${encodeURIComponent(t)}/notifications`,{method:"POST",body:JSON.stringify({mode:n})}),communityEvents:(e,t,n={})=>{const a=new URLSearchParams;return n.after!=null&&a.set("after",String(n.after)),n.limit!=null&&a.set("limit",String(n.limit)),q(e,`/v1/communities/${encodeURIComponent(t)}/events${a.size?`?${a}`:""}`)},communityRealtimeSession:(e,t)=>q(e,`/v1/communities/${encodeURIComponent(t)}/realtime-session`),uploadCommunityAttachment:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/upload`,{method:"POST",body:JSON.stringify({attachment:a})}),communityAttachmentDownload:(e,t,n,a)=>q(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/${encodeURIComponent(a)}/download`)},eg="openpond-app-server-url",Sl="openpond-app-token",XB=750;function y1(){return window.location.protocol!=="http:"&&window.location.protocol!=="https:"?null:window.location.origin&&window.location.origin!=="null"?window.location.origin:null}function ef(e){const t=e.getItem(eg)?.trim(),n=e.getItem(Sl)?.trim();return t&&n?{serverUrl:t,token:n}:null}function id(e){if(!e)return null;try{const t="__openpond_storage_probe__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}function gi(e,t){e.setItem(eg,t.serverUrl),e.setItem(Sl,t.token)}function Ub(e,t){const n=ef(e);n?.serverUrl!==t.serverUrl||n.token!==t.token||(e.removeItem(eg),e.removeItem(Sl))}function eF(){const e=window.__OPENPOND_WEB_CONNECTION__,t=e?.serverUrl?.trim(),n=e?.token?.trim();return t&&n?{serverUrl:t,token:n}:null}function tF(){const e=window.location.hash.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!e)return null;const t=new URLSearchParams(e),n=t.get("openpondToken")?.trim(),a=t.get("openpondServerUrl")?.trim()||y1();return!a||!n?null:{serverUrl:a,token:n}}function nF(){window.location.hash&&window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`)}function wc(e,t){t&&(e.some(n=>n.serverUrl===t.serverUrl&&n.token===t.token)||e.push(t))}function aF(){const e=[],t=id(window.sessionStorage),n=id(window.localStorage),a=y1(),r=t?.getItem(Sl)??n?.getItem(Sl);return wc(e,null),wc(e,a&&r?{serverUrl:a,token:r.trim()}:null),wc(e,t?ef(t):null),wc(e,n?ef(n):null),e}async function Zm(e){const t=new AbortController,n=window.setTimeout(()=>t.abort(),XB);try{const a=await fetch(`${e}/health`,{signal:t.signal}),r=await a.json().catch(()=>null);return a.ok&&r?.server==="openpond-app-server"}catch{return!1}finally{window.clearTimeout(n)}}async function oF(){if(window.openpond)return window.openpond.getConnection();const e=id(window.sessionStorage),t=id(window.localStorage),n=tF();if(n&&await Zm(n.serverUrl))return t&&gi(t,n),e&&gi(e,n),nF(),{...n,platform:navigator.platform};const a=eF();if(a&&await Zm(a.serverUrl))return t&&gi(t,a),e&&gi(e,a),{...a,platform:navigator.platform};const r=aF();for(const i of r){if(await Zm(i.serverUrl))return t&&gi(t,i),e&&gi(e,i),{...i,platform:navigator.platform};e&&Ub(e,i),t&&Ub(t,i)}throw new Error("No reachable OpenPond app server. Start `openpond ui` again and open the full printed URL.")}const J={...QB,bootstrap:e=>q(e,"/v1/bootstrap?refreshCodex=1"),localProjectActions:(e,t)=>q(e,`/v1/projects/${encodeURIComponent(t)}/actions`),extensionCatalog:e=>q(e,"/v1/extensions"),extensionPreview:(e,t)=>q(e,"/v1/extensions/preview",{method:"POST",body:JSON.stringify(t)}),extensionAdd:(e,t)=>q(e,"/v1/extensions",{method:"POST",body:JSON.stringify(t)}),extensionUpdate:(e,t,n={})=>q(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}/update`,{method:"POST",body:JSON.stringify(n)}),extensionUpdateAll:e=>q(e,"/v1/extensions/update-all",{method:"POST"}),extensionRemove:(e,t)=>q(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}`,{method:"DELETE"}),skillSourceFile:(e,t,n,a)=>q(e,`/v1/skills/${t}/${encodeURIComponent(n)}/source?path=${encodeURIComponent(a)}`),teamChatMembers:(e,t)=>q(e,`/v1/team-chat/members?teamId=${encodeURIComponent(t)}`),teamChatAgents:(e,t)=>q(e,`/v1/team-chat/agents?teamId=${encodeURIComponent(t)}`),teamChatThreads:(e,t)=>q(e,`/v1/team-chat/threads?teamId=${encodeURIComponent(t)}`),teamChatRealtimeSession:(e,t)=>q(e,`/v1/team-chat/realtime-session?teamId=${encodeURIComponent(t)}`),teamChatEvents:(e,t,n={})=>{const a=new URLSearchParams({teamId:t});return n.after!=null&&a.set("after",String(n.after)),n.limit!=null&&a.set("limit",String(n.limit)),q(e,`/v1/team-chat/events?${a.toString()}`)},teamChatGeneral:(e,t)=>q(e,"/v1/team-chat/threads/general",{method:"POST",body:JSON.stringify({teamId:t})}),teamChatDm:(e,t,n)=>q(e,"/v1/team-chat/threads/dm",{method:"POST",body:JSON.stringify({teamId:t,otherUserId:n})}),teamChatThread:(e,t,n,a={})=>{const r=new URLSearchParams({teamId:t});return a.beforeSequence!=null&&r.set("beforeSequence",String(a.beforeSequence)),a.limit!=null&&r.set("limit",String(a.limit)),q(e,`/v1/team-chat/threads/${encodeURIComponent(n)}?${r.toString()}`)},uploadTeamChatAttachment:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/attachments/upload`,{method:"POST",body:JSON.stringify(n)}),teamChatAttachmentDownload:(e,t,n)=>q(e,`/v1/team-chat/attachments/${encodeURIComponent(n)}/download?teamId=${encodeURIComponent(t)}`),sendTeamChatMessage:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:JSON.stringify(n)}),createTeamChatAgentRun:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/agent-runs`,{method:"POST",body:JSON.stringify(n)}),teamChatAgentConversation:(e,t,n)=>q(e,`/v1/team-chat/agent-runs/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),editTeamChatMessage:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)}),deleteTeamChatMessage:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"DELETE",body:JSON.stringify({teamId:a})}),markTeamChatRead:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/read`,{method:"POST",body:JSON.stringify({teamId:n,sequence:a})}),setTeamChatThreadMuted:(e,t,n,a)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/mute`,{method:"POST",body:JSON.stringify({teamId:n,muted:a})}),createTeamChatAiThread:(e,t,n)=>q(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/ai-threads`,{method:"POST",body:JSON.stringify(n)}),teamChatAiThread:(e,t,n)=>q(e,`/v1/team-chat/ai-threads/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),sendTeamChatAiTurn:(e,t,n)=>q(e,`/v1/team-chat/ai-threads/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),executeTeamChatAiTurn:(e,t,n)=>q(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute`,{method:"POST",body:JSON.stringify({teamId:n})}),cancelTeamChatAiTurnExecution:(e,t,n)=>q(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute/cancel`,{method:"POST",body:JSON.stringify({teamId:n})}),usage:(e,t={})=>{const n=zb(t),a=n.size?`?${n.toString()}`:"";return q(e,`/v1/usage${a}`)},usageRecords:(e,t={})=>{const n=zb(t);t.sessionId&&n.set("sessionId",t.sessionId),t.turnId&&n.set("turnId",t.turnId),t.limit!==void 0&&n.set("limit",String(t.limit));const a=n.size?`?${n.toString()}`:"";return q(e,`/v1/usage/records${a}`)},usageTurnCache:(e,t)=>q(e,`/v1/usage/turn-cache?sessionId=${encodeURIComponent(t)}`),runtimeEventsPage:(e,t={})=>{const n=new URLSearchParams;t.sessionId&&n.set("sessionId",t.sessionId),t.afterSequence!==void 0&&n.set("afterSequence",String(t.afterSequence)),t.beforeSequence!==void 0&&t.beforeSequence!==null&&n.set("beforeSequence",String(t.beforeSequence)),t.limit!==void 0&&n.set("limit",String(t.limit));const a=n.size?`?${n.toString()}`:"";return q(e,`/v1/events/page${a}`)},workOutputs:e=>q(e,"/v1/work/outputs"),harnessHistory:e=>q(e,"/v1/harness"),refinerHistory:e=>q(e,"/v1/refiner"),updateRefinerProfile:(e,t)=>q(e,"/v1/refiner/update",{method:"POST",body:JSON.stringify(t)}),activateRefinerRelease:(e,t)=>q(e,"/v1/refiner/activate",{method:"POST",body:JSON.stringify(t)}),rollbackRefinerRelease:(e,t)=>q(e,"/v1/refiner/rollback",{method:"POST",body:JSON.stringify(t)}),updateHarnessBackgroundReview:(e,t)=>q(e,"/v1/harness/background-review",{method:"POST",body:JSON.stringify(t)}),reviewHarnessEvaluation:(e,t)=>q(e,"/v1/harness/evaluation-review",{method:"POST",body:JSON.stringify(t)}),updateHarnessEvaluationReviewSchedule:(e,t)=>q(e,"/v1/harness/evaluation-review/settings",{method:"POST",body:JSON.stringify(t)}),harnessReleaseDiff:(e,t)=>q(e,"/v1/harness/diff",{method:"POST",body:JSON.stringify(t)}),rollbackHarness:(e,t)=>q(e,"/v1/harness/rollback",{method:"POST",body:JSON.stringify(t)}),reviewHarnessProposal:(e,t)=>q(e,"/v1/harness/review",{method:"POST",body:JSON.stringify(t)}),runSubagentLifecycleAction:(e,t,n)=>q(e,`/v1/subagents/${encodeURIComponent(t)}/lifecycle`,{method:"POST",body:JSON.stringify(n)}),trainingState:(e,t)=>q(e,`/v1/training?profileId=${encodeURIComponent(t)}`),trainingActivity:(e,t)=>q(e,`/v1/training/activity?profileId=${encodeURIComponent(t)}`),portableTrainingCatalog:(e,t="",n)=>{const a=new URLSearchParams;return t.trim()&&a.set("query",t.trim()),n&&a.set("method",n),q(e,`/v1/training/catalog${a.size?`?${a.toString()}`:""}`)},datasetCatalog:(e,t)=>q(e,`/v1/training/datasets?profileId=${encodeURIComponent(t)}`),trainingRunDetail:(e,t,n={})=>q(e,`/v1/training/jobs/${encodeURIComponent(t)}/detail?evaluation=${n.includeEvaluation===!1?"false":"true"}`),candidateReview:(e,t,n=!1,a="models")=>q(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision?refresh=${n}`),recordCandidateReview:(e,t,n,a="models")=>q(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision`,{method:"POST",body:JSON.stringify(n)}),candidateReviewHistory:(e,t,n,a="models")=>q(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision-history?decisionId=${encodeURIComponent(n.id)}&decisionHash=${n.contentHash}`),trainingEvaluationTasks:async(e,t,n,a)=>{const r=new URLSearchParams({limit:"25"});return a&&r.set("cursor",a),q(e,`/v1/training/jobs/${encodeURIComponent(t)}/evaluations/${encodeURIComponent(n.id)}/tasks?${r}`)},trainingRequest:(e,t,n,a="POST")=>q(e,`/v1/training${t}`,{method:a,body:a==="GET"||a==="DELETE"?void 0:JSON.stringify(n)}),datasetStorageState:e=>q(e,"/v1/settings/dataset-storage"),updateDatasetStorage:(e,t)=>q(e,"/v1/settings/dataset-storage",{method:"PATCH",body:JSON.stringify({datasetStorePath:t})}),hostedSavedWork:e=>q(e,"/v1/saved-work"),createHostedSavedWork:(e,t)=>q(e,"/v1/saved-work",{method:"POST",body:JSON.stringify(t)}),updateHostedSavedWork:(e,t,n)=>q(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteHostedSavedWork:(e,t)=>q(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"DELETE"}),runHostedSavedWork:(e,t,n)=>q(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({clientRequestId:n})}),chatWorkflows:(e,t)=>{const n=t?`?sessionId=${encodeURIComponent(t)}`:"";return q(e,`/v1/chat-workflows${n}`)},createChatWorkflow:(e,t)=>q(e,"/v1/chat-workflows",{method:"POST",body:JSON.stringify(t)}),updateChatWorkflow:(e,t,n)=>q(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteChatWorkflow:(e,t)=>q(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),runChatWorkflow:(e,t)=>q(e,`/v1/chat-workflows/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({})}),localAgentSchedules:(e,t={})=>{const n=new URLSearchParams;t.localProjectId&&n.set("localProjectId",t.localProjectId);const a=n.size?`?${n.toString()}`:"";return q(e,`/v1/local-agent-schedules${a}`)},syncLocalAgentSchedules:e=>q(e,"/v1/local-agent-schedules/sync",{method:"POST",body:JSON.stringify({})}),patchLocalAgentSchedule:(e,t,n)=>q(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),runLocalAgentSchedule:(e,t,n={})=>q(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n)}),localAgentScheduleRuns:(e,t,n={})=>{const a=new URLSearchParams;n.limit!==void 0&&a.set("limit",String(n.limit));const r=a.size?`?${a.toString()}`:"";return q(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}/runs${r}`)},refreshOpenPondAccounts:e=>q(e,"/v1/openpond/accounts/refresh",{method:"POST",body:JSON.stringify({})}),refreshOpenPondAccount:e=>q(e,"/v1/openpond/account?refresh=1"),loadMoreOpenPondApps:(e,t)=>q(e,`/v1/openpond/apps/more?offset=${encodeURIComponent(String(t.offset))}&limit=${encodeURIComponent(String(t.limit))}`),switchOpenPondAccount:(e,t)=>q(e,"/v1/openpond/accounts/switch",{method:"POST",body:JSON.stringify(t)}),removeOpenPondAccount:(e,t)=>q(e,"/v1/openpond/accounts",{method:"DELETE",body:JSON.stringify(t)}),signOutOpenPondAccount:e=>q(e,"/v1/openpond/accounts/logout",{method:"POST",body:JSON.stringify({})}),saveOpenPondAccount:(e,t)=>q(e,"/v1/openpond/accounts/login",{method:"POST",body:JSON.stringify(t)}),updateOpenPondAccountConfig:(e,t)=>q(e,"/v1/openpond/accounts/config",{method:"PATCH",body:JSON.stringify(t)}),savePreferences:(e,t)=>q(e,"/v1/preferences",{method:"PATCH",body:JSON.stringify(t)}),saveProviderSettings:(e,t)=>q(e,"/v1/providers",{method:"PATCH",body:JSON.stringify(t)}),providerSettings:e=>q(e,"/v1/providers"),loadProviderModels:(e,t,n={})=>{const a=new URLSearchParams;n.query?.trim()&&a.set("query",n.query.trim()),n.limit&&a.set("limit",String(n.limit));const r=a.size?`?${a.toString()}`:"";return q(e,`/v1/providers/${encodeURIComponent(t)}/models${r}`)},refreshProviderModels:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/models`,{method:"POST",body:JSON.stringify(n)}),saveProviderCredential:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"PUT",body:JSON.stringify(n)}),deleteProviderCredential:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"DELETE",body:JSON.stringify(n)}),startOpenAiSubscriptionAuth:(e,t)=>q(e,"/v1/providers/openai/subscription-auth",{method:"POST",body:JSON.stringify(t)}),validateProviderCredential:(e,t,n)=>q(e,`/v1/providers/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(n)}),savePersonalization:(e,t)=>q(e,"/v1/personalization",{method:"PATCH",body:JSON.stringify(t)}),recordClientDiagnostic:(e,t)=>q(e,"/v1/diagnostics/client",{method:"POST",body:JSON.stringify(t)}),profileCurrent:e=>q(e,"/v1/profile"),profileCatalog:e=>q(e,"/v1/profile/catalog"),profileWorkflows:e=>q(e,"/v1/profile/workflows"),profileEvaluations:e=>q(e,"/v1/profile/evaluations"),profileEvaluationPrepare:(e,t)=>q(e,"/v1/profile/evaluations/prepare",{method:"POST",body:JSON.stringify(t)}),profileEvaluationRun:(e,t)=>q(e,"/v1/profile/evaluations/run",{method:"POST",body:JSON.stringify(t)}),profileEvaluationRunSuite:(e,t)=>q(e,"/v1/profile/evaluations/run-suite",{method:"POST",body:JSON.stringify(t)}),profileEvaluationCompare:(e,t)=>q(e,"/v1/profile/evaluations/compare",{method:"POST",body:JSON.stringify({id:`comparison-${crypto.randomUUID()}`,runIds:t})}),profileSelect:(e,t)=>q(e,"/v1/profile/select",{method:"POST",body:JSON.stringify({ref:t})}),profileRemove:(e,t)=>q(e,"/v1/profile/remove",{method:"POST",body:JSON.stringify({ref:t})}),profilePublicationPreview:(e,t)=>q(e,"/v1/profile/publication/preview",{method:"POST",body:JSON.stringify(t)}),profilePublicationPublish:(e,t)=>q(e,"/v1/profile/publication/publish",{method:"POST",body:JSON.stringify(t)}),profileInstall:(e,t)=>q(e,"/v1/profile/install",{method:"POST",body:JSON.stringify(t)}),profileUpdate:(e,t)=>q(e,"/v1/profile/update",{method:"POST",body:JSON.stringify({ref:t})}),profileInit:(e,t)=>q(e,"/v1/profile/init",{method:"POST",body:JSON.stringify(t)}),profileLoad:(e,t)=>q(e,"/v1/profile/load",{method:"POST",body:JSON.stringify(t)}),profileCheck:(e,t)=>q(e,"/v1/profile/check",{method:"POST",body:JSON.stringify(t)}),profileAgentRename:(e,t,n)=>q(e,`/v1/profile/agents/${encodeURIComponent(t)}/name`,{method:"PATCH",body:JSON.stringify(n)}),profileCommit:(e,t)=>q(e,"/v1/profile/commit",{method:"POST",body:JSON.stringify(t)}),profilePush:(e,t)=>q(e,"/v1/profile/push",{method:"POST",body:JSON.stringify(t)}),workspaceLspSettingsStatus:e=>q(e,"/v1/lsp/settings-status"),workspaceLspRuntimeStatus:e=>q(e,"/v1/lsp/status"),restartWorkspaceLsp:e=>q(e,"/v1/lsp/restart",{method:"POST"}),remoteAccess:e=>q(e,"/v1/remote-access"),enableRemoteAccess:e=>q(e,"/v1/remote-access/enable",{method:"POST"}),disableRemoteAccess:e=>q(e,"/v1/remote-access/disable",{method:"POST"}),voiceTranscriptionStatus:(e,t={})=>q(e,"/v1/audio/transcriptions/status",{signal:t.signal}),transcribeVoice:(e,t,n={})=>q(e,"/v1/audio/transcriptions",{method:"POST",body:JSON.stringify(t),signal:n.signal}),createSession:(e,t)=>q(e,"/v1/sessions",{method:"POST",body:JSON.stringify(t)}),patchSession:(e,t,n)=>q(e,`/v1/sessions/${t}`,{method:"PATCH",body:JSON.stringify(n)}),codexHistoryThread:(e,t,n={})=>{const a=new URLSearchParams;n.limit!==void 0&&a.set("limit",String(n.limit)),n.tail&&a.set("tail","1");const r=a.size?`?${a.toString()}`:"";return q(e,`/v1/codex-history/${encodeURIComponent(t)}${r}`)},codexHistoryThreadIncremental:(e,t,n={})=>{const a=new URLSearchParams({incremental:"1"});return n.afterEventId&&a.set("afterEventId",n.afterEventId),n.limit!==void 0&&a.set("limit",String(n.limit)),n.revision&&a.set("revision",n.revision),n.tail&&a.set("tail","1"),q(e,`/v1/codex-history/${encodeURIComponent(t)}?${a.toString()}`)},sendCodexHistoryTurn:(e,t,n)=>q(e,`/v1/codex-history/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),interruptCodexHistoryTurn:(e,t)=>q(e,`/v1/codex-history/${encodeURIComponent(t)}/turns/interrupt`,{method:"POST"}),patchSidebarAppPreference:(e,t,n)=>q(e,`/v1/sidebar/apps/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),reorderSidebarApps:(e,t)=>q(e,"/v1/sidebar/apps/reorder",{method:"POST",body:JSON.stringify(t)}),sidebarFiles:e=>q(e,"/v1/sidebar/files"),patchSidebarFile:(e,t)=>q(e,"/v1/sidebar/files",{method:"PATCH",body:JSON.stringify(t)}),workspaceStatus:(e,t,n=!1,a={})=>q(e,`/v1/workspaces/${encodeURIComponent(t)}${n?"?ensure=1":""}`,{signal:a.signal}),createWorkspaceBranch:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/branches`,{method:"POST",body:JSON.stringify(n)}),checkoutWorkspaceBranch:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/branch`,{method:"PATCH",body:JSON.stringify(n)}),workspaceDiff:(e,t,n={})=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/diff`,{signal:n.signal}),workspaceFile:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`),saveWorkspaceFile:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/file`,{method:"PATCH",body:JSON.stringify(n)}),signWorkspaceImageUrl:(e,t)=>q(e,"/v1/assets/workspace-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalImageUrl:(e,t)=>q(e,"/v1/assets/local-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalVideoUrl:(e,t)=>q(e,"/v1/assets/local-video-url",{method:"POST",body:JSON.stringify(t)}),signChatAttachmentImageUrl:(e,t)=>q(e,"/v1/assets/chat-attachment-image-url",{method:"POST",body:JSON.stringify(t)}),chatAttachmentFile:(e,t)=>q(e,"/v1/assets/chat-attachment-file",{method:"POST",body:JSON.stringify(t)}),workspaceLspTouch:(e,t,n,a={})=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/touch`,{method:"POST",body:JSON.stringify(n),signal:a.signal}),workspaceLspAction:(e,t,n)=>q(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/action`,{method:"POST",body:JSON.stringify(n)}),workspaceTemplateConfig:(e,t)=>q(e,`/v1/openpond/apps/${encodeURIComponent(t)}/template-config`),...BB,...YB,createLocalProject:(e,t)=>q(e,"/v1/projects",{method:"POST",body:JSON.stringify(t)}),updateLocalProjectAgentSetup:(e,t,n)=>q(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),uploadLocalProjectCloudSource:(e,t,n)=>q(e,`/v1/projects/${encodeURIComponent(t)}/cloud-source`,{method:"POST",body:JSON.stringify(n)}),previewLocalProjectCloudSource:(e,t,n={})=>{const a=new URLSearchParams;n.branch?.trim()&&a.set("branch",n.branch.trim());const r=a.toString()?`?${a.toString()}`:"";return q(e,`/v1/projects/${encodeURIComponent(t)}/cloud-source/preview${r}`)},deleteLocalProject:(e,t)=>q(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"DELETE"}),gitAvailability:e=>q(e,"/v1/system/git"),installMacOSCommandLineTools:e=>q(e,"/v1/system/git/install-command-line-tools",{method:"POST",body:JSON.stringify({})}),...FB,resolveApproval:(e,t,n)=>q(e,`/v1/approvals/${t}`,{method:"POST",body:JSON.stringify(n)})};function zb(e){const t=new URLSearchParams;return e.range&&t.set("range",e.range),e.visibility&&t.set("visibility",e.visibility),e.status&&t.set("status",e.status),e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),t}const rF=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),iF=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),Hb=e=>{const t=iF(e);return t.charAt(0).toUpperCase()+t.slice(1)},S1=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),sF=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var lF={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const cF=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...l},m)=>g.createElement("svg",{ref:m,...lF,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:S1("lucide",r),...!i&&!sF(l)&&{"aria-hidden":"true"},...l},[...s.map(([u,h])=>g.createElement(u,h)),...Array.isArray(i)?i:[i]]));const dt=(e,t)=>{const n=g.forwardRef(({className:a,...r},i)=>g.createElement(cF,{ref:i,iconNode:t,className:S1(`lucide-${rF(Hb(e))}`,`lucide-${e}`,a),...r}));return n.displayName=Hb(e),n};const dF=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],uF=dt("activity",dF);const mF=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],pF=dt("archive-restore",mF);const fF=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],hF=dt("arrow-left",fF);const gF=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],x1=dt("bookmark",gF);const vF=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]],k1=dt("bookmark-x",vF);const bF=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]],qb=dt("book-open-text",bF);const yF=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],Jm=dt("boxes",yF);const SF=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],xF=dt("calendar-clock",SF);const kF=[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]],w1=dt("chart-column-stacked",kF);const wF=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wo=dt("check",wF);const IF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],tf=dt("circle-check",IF);const _F=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],zo=dt("chevron-down",_F);const CF=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$r=dt("chevron-right",CF);const RF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],PF=dt("circle-alert",RF);const AF=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Jd=dt("cloud",AF);const TF=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],EF=dt("credit-card",TF);const MF=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],jF=dt("download",MF);const OF=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ym=dt("external-link",OF);const $F=[["path",{d:"M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127",key:"wfxp4w"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],NF=dt("file-output",$F);const DF=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],tg=dt("file-text",DF);const LF=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],I1=dt("folder",LF);const UF=[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],_1=dt("folder-git-2",UF);const zF=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],HF=dt("git-branch",zF);const qF=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],BF=dt("github",qF);const FF=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],C1=dt("earth",FF);const VF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],KF=dt("circle-question-mark",VF);const WF=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],GF=dt("list-filter",WF);const ZF=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],JF=dt("loader-circle",ZF);const YF=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],QF=dt("maximize-2",YF);const XF=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Yd=dt("message-square",XF);const e4=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Qd=dt("ellipsis",e4);const t4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],R1=dt("panel-left",t4);const n4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],nf=dt("panel-right",n4);const a4=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],ng=dt("pin",a4);const o4=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],ag=dt("pin-off",o4);const r4=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],i4=dt("plus",r4);const s4=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],l4=dt("power",s4);const c4=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],d4=dt("search",c4);const u4=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],og=dt("settings",u4);const m4=[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]],P1=dt("shapes",m4);const p4=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],f4=dt("shield",p4);const h4=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Xd=dt("square-pen",h4);const g4=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],A1=dt("square-terminal",g4);const v4=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],Bb=dt("user-round",v4);const b4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],os=dt("x",b4);function y4({platform:e}){return!eu()||rg(e)?null:x.jsxs("div",{className:"window-controls","aria-label":"Window controls",children:[x.jsx("button",{type:"button",className:"window-control minimize",title:"Minimize",onClick:()=>{Qm("minimize")},children:x.jsx(zo,{size:14})}),x.jsx("button",{type:"button",className:"window-control maximize",title:"Maximize",onClick:()=>{Qm("toggleMaximize")},children:x.jsx(QF,{size:12})}),x.jsx("button",{type:"button",className:"window-control close",title:"Close",onClick:()=>{Qm("close")},children:x.jsx(os,{size:13})})]})}function rg(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")}function eu(){if(typeof window>"u")return!1;const e=window.openpond;return!!(e?.minimizeWindow||e?.toggleMaximizeWindow||e?.closeWindow)}async function Qm(e){const t=window.openpond;if(!(t&&(e==="minimize"?await t.minimizeWindow?.():e==="toggleMaximize"?await t.toggleMaximizeWindow?.():await t.closeWindow?.())!==!1)){if(e==="toggleMaximize"&&document.fullscreenEnabled){document.fullscreenElement?await document.exitFullscreen():await document.documentElement.requestFullscreen();return}if(e==="close"){window.close();return}console.warn("Window controls require the Electron desktop shell.")}}function S4({value:e,options:t,disabled:n,compact:a,className:r,icon:i,placement:s="bottom",label:l,tooltip:m,searchable:u=!1,floating:h=!1,onChange:b}){const[y,w]=g.useState(!1),[_,E]=g.useState(""),j=g.useRef(null),[P,L]=g.useState();g.useLayoutEffect(()=>{if(!y||!h)return;function C(){const A=j.current?.getBoundingClientRect();if(!A)return;const z=window.innerHeight-A.bottom-12,B=A.top-12,N=z<180&&B>z;L({position:"fixed",left:Math.max(12,A.left),width:Math.min(A.width,window.innerWidth-24),minWidth:0,maxWidth:"calc(100vw - 24px)",right:"auto",top:N?"auto":A.bottom+5,bottom:N?window.innerHeight-A.top+5:"auto",maxHeight:Math.max(80,Math.min(320,N?B-5:z-5)),overflowY:"auto",zIndex:1e3})}return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[y,h]);const $=t.find(C=>C.value===e)??t[0],O=_.trim().toLowerCase(),k=O?t.filter(C=>[C.label,C.shortLabel,C.description].some(A=>A?.toLowerCase().includes(O))):t;return g.useEffect(()=>{if(!y){E("");return}function C(z){j.current?.contains(z.target)||w(!1)}function A(z){z.key==="Escape"&&w(!1)}return document.addEventListener("pointerdown",C),document.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",C),document.removeEventListener("keydown",A)}},[y]),x.jsxs("div",{className:`dropdown-select ${r??""} ${a?"compact":""} ${s==="top"?"open-up":""}`,"data-tooltip":m,ref:j,children:[x.jsxs("button",{type:"button",className:`dropdown-trigger ${y?"active":""}`,disabled:n,"aria-label":l,"aria-haspopup":"menu","aria-expanded":y,onClick:()=>w(C=>!C),children:[i,x.jsx("span",{children:$?.shortLabel??$?.label??e}),x.jsx(zo,{size:14})]}),y&&x.jsxs("div",{className:"dropdown-menu",role:"menu",style:h?P:void 0,children:[u?x.jsxs("label",{className:"dropdown-search",onClick:C=>C.stopPropagation(),children:[x.jsxs("span",{className:"sr-only",children:["Search ",l]}),x.jsx("input",{autoFocus:!0,placeholder:`Search ${l.toLowerCase()}`,value:_,onChange:C=>E(C.target.value)})]}):null,k.map(C=>x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":C.value===e,disabled:C.disabled,className:[C.value===e?"selected":"",C.separatorBefore?"separator-before":"",C.icon?"with-icon":""].filter(Boolean).join(" "),onClick:()=>{C.disabled||(b(C.value),E(""),w(!1))},children:[x.jsxs("span",{children:[C.icon==="plus"?x.jsx(i4,{size:13}):null,x.jsx("span",{children:C.label})]}),C.description&&x.jsx("small",{children:C.description})]},C.value)),k.length?null:x.jsx("div",{className:"dropdown-empty",children:"No matches"})]})]})}const x4=[{destination:"walkthroughs",icon:qb,label:"Walkthroughs"},{destination:"external",icon:qb,label:"Docs",url:"https://openpond.ai/docs"},{destination:"external",icon:tg,label:"Blog",url:"https://openpond.ai/blog"},{destination:"external",icon:EF,label:"Pricing",url:"https://openpond.ai/pricing"},{destination:"external",icon:C1,label:"Web app",url:"https://openpond.ai/sandboxes"},{destination:"external",icon:BF,label:"GitHub",url:"https://github.com/openpond/openpond"},{destination:"external",icon:Yd,label:"Submit issue",url:"https://github.com/openpond/openpond/issues/new/choose"}];function k4({onOpenWalkthroughs:e,walkthroughsActive:t}){const[n,a]=g.useState(!1),r=g.useRef(null);return g.useEffect(()=>{if(!n)return;function i(l){r.current?.contains(l.target)||a(!1)}function s(l){l.key==="Escape"&&a(!1)}return document.addEventListener("pointerdown",i),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",s)}},[n]),x.jsxs("div",{className:"sidebar-help-menu",ref:r,children:[x.jsx("button",{"aria-expanded":n,"aria-haspopup":"menu","aria-label":"Open docs and help menu",className:`sidebar-icon sidebar-help-trigger ${t?"active":""}`,"data-tooltip":"Help",onClick:()=>a(i=>!i),type:"button",children:x.jsx(KF,{size:17})}),n?x.jsx("div",{className:"sidebar-help-popover",role:"menu","aria-label":"Help",children:x4.map(i=>{const s=i.icon,l=x.jsxs(x.Fragment,{children:[x.jsx(s,{size:15}),x.jsx("span",{children:i.label})]});return i.destination==="walkthroughs"?x.jsx("button",{"aria-current":t?"page":void 0,className:"sidebar-help-item",onClick:()=>{a(!1),e()},role:"menuitem",type:"button",children:l},i.label):x.jsx("a",{className:"sidebar-help-item",href:i.url,onClick:m=>{m.preventDefault(),a(!1),w4(i.url)},rel:"noreferrer",role:"menuitem",target:"_blank",children:l},i.label)})}):null]})}async function w4(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-help",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const QZ=[{value:"chat",label:"Chat"},{value:"work",label:"Work"}],Xm=[{value:"chat",label:"Work",description:"Chat and complete tasks"},{value:"models",label:"Models",description:"Evaluate, train, and serve models"}];function T1(e){return e==="chat"?"New chat":"New task"}const af=["get-started","models","tasks","tasksets","labeling","rewards","evaluations","runs","versions","serving"],I4={"get-started":"Get started",models:"Models",tasks:"Tasks",tasksets:"Tasksets",labeling:"Labeling",rewards:"Rewards",evaluations:"Runs",runs:"Runs",versions:"Versions",serving:"Serving"},_4={tasks:["drafts"],tasksets:["drafts","formats","batches"],rewards:["scorers","combined"],evaluations:["results","review","comparisons"],runs:["series","new"]},C4={tasksets:["overview","tasks","reward","attempts","releases"],rewards:["definition","usage","evidence"],evaluations:["overview","comparison","activity"],runs:["details","metrics","evaluation","rollouts","activity","artifacts"],versions:["overview","metrics","evaluation","rollouts","activity","artifacts"]};function ro(e="models",t=null,n={}){return e==="evaluations"&&n.collection==="review"?ro("labeling",t,{...n,collection:"default"}):{page:e,modelId:e==="get-started"?null:t,collection:e==="evaluations"?"results":"default",resourceId:null,detailTab:null,query:"",after:null,...n}}function ig(e){const t=e.pathname.split("/").filter(Boolean);if(t[0]!=="models")return null;let n;try{n=t.slice(1).map(decodeURIComponent)}catch{return null}if(n.some(E=>!E.trim()||E.length>2e3||E.includes("\0")))return null;const a=n[0]&&!af.includes(n[0])?n.shift():null;if(a&&(a.length>500||["projects","scorers"].includes(a)))return null;n[0]==="runs"&&n[1]==="evaluations"&&n.splice(0,2,"evaluations","results"),n[0]==="runs"&&n[1]==="comparisons"&&n.splice(0,2,"evaluations","comparisons");const r=n.shift(),i=r??"models";if(!af.includes(i)||r==="models"||a&&i==="get-started")return null;let s=i==="evaluations"?"results":"default";if(_4[i]?.includes(n[0]))s=n.shift();else if(i==="evaluations"&&n.length)return null;const l=n.shift()??null,m=n.shift()??null;if(n.length||m&&!l||(i==="models"||i==="get-started")&&l)return null;if(s==="drafts"||s==="new"){if(!l||m)return null}else if(s!=="series"){if(["review","formats","batches","comparisons","scorers","combined"].includes(s)){if(m)return null}else if(m&&!C4[i]?.includes(m))return null}if(i==="serving"&&m)return null;const u=new URLSearchParams(e.search??"");if([...u.keys()].some(E=>!["model","q","after","source"].includes(E))||[...u.keys()].some(E=>u.getAll(E).length!==1))return null;const h=u.get("source");if(h!==null&&(i!=="labeling"&&(i!=="evaluations"||s!=="review")||!h.trim()||h.length>500))return null;const b=u.get("model");if(a&&b&&a!==b)return null;const y=a??b;if(i==="get-started"&&u.size!==0)return null;const w=u.get("q")??"",_=u.get("after");return y!==null&&(!y.trim()||y.length>500)||w.length>1e3||_!==null&&(!_.trim()||_.length>2e3)?null:ro(i,y,{collection:s,resourceId:l,detailTab:m,query:w,after:_,...h!==null?{sourceId:h}:{}})}function tu(e){const t=["/models"];if(e.modelId&&t.push(encodeURIComponent(e.modelId)),e.page==="evaluations"&&e.collection==="review")return tu(ro("labeling",e.modelId,{collection:"default",resourceId:e.resourceId,sourceId:e.sourceId,query:e.query,after:e.after}));e.page==="evaluations"?t.push("runs",e.collection==="comparisons"?"comparisons":"evaluations"):(e.page!=="models"&&t.push(e.page),e.collection!=="default"&&t.push(e.collection)),e.resourceId&&t.push(encodeURIComponent(e.resourceId)),e.resourceId&&e.detailTab&&t.push(encodeURIComponent(e.detailTab));const n=new URLSearchParams;return e.query&&n.set("q",e.query),e.after&&n.set("after",e.after),(e.page==="labeling"||e.page==="evaluations"&&e.collection==="review")&&e.sourceId&&n.set("source",e.sourceId),`${t.join("/")}${n.size?`?${n}`:""}`}function R4(e,t){return ro(e.page,t,{collection:e.collection==="new"||e.collection==="drafts"?"default":e.collection})}function XZ(e,t,n=null){return{...e,resourceId:t,detailTab:n,after:null}}const sd=new Set,of=new Set,P4=new Set(["account","notifications","harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases","profile","skills","configuration","context","training","subagents","editor","providers","dataset-storage","remote","usage","personalization","diagnostics"]),rf={apps:"/apps",outputs:"/outputs",projects:"/projects",scheduled:"/workflows","get-started":"/get-started"};let sf=!1,lf="",zc=null,E1=null,xl="",Ta=0,Vs=null,rl=!1,ep=null,Hc=!1;function sg(e){const t=ig(e);if(t)return{kind:"models",route:t};const n=e.pathname.split("/").filter(Boolean);if(n[0]==="models")return{kind:"models_unavailable",pathname:e.pathname,search:e.search??""};if(n[0]==="settings"&&n.length===2&&P4.has(n[1])){const r=lg(new URLSearchParams(e.search??"").get("returnTo"));return{kind:"settings",section:n[1],...r?{returnTo:r}:{}}}if(n[0]==="chat"&&n.length<=2)try{return{kind:"chat",sessionId:n[1]&&n[1]!=="new"?decodeURIComponent(n[1]):null}}catch{return null}const a=Object.keys(rf).find(r=>rf[r]===e.pathname);return a?{kind:"view",view:a}:null}function M1(e){if(e.kind==="models")return tu(e.route);if(e.kind==="models_unavailable")return`${e.pathname}${e.search}`;if(e.kind==="settings"){const t=lg(e.returnTo??null);return`/settings/${e.section}${t?`?${new URLSearchParams({returnTo:t})}`:""}`}return e.kind==="chat"?e.sessionId?`/chat/${encodeURIComponent(e.sessionId)}`:"/chat/new":rf[e.view]}function A4(e){const t=e?.kind==="settings"?lg(e.returnTo??null):null;if(t){const n=new URL(t,"https://local.openpond.invalid"),a=ig(n);if(a)return{kind:"models",route:a}}return{kind:"chat",sessionId:null}}function lg(e){if(!e||e.length>6e3||!e.startsWith("/models")||e.startsWith("//"))return null;const t=new URL(e,"https://local.openpond.invalid");if(t.origin!=="https://local.openpond.invalid"||t.hash)return null;const n=ig(t);return n?tu(n):null}function Vl(){return`${window.location.pathname}${window.location.search}`}function cg(){if(typeof window>"u")return;const e=sf?xl:Vl();e!==lf&&(lf=e,zc=sg(new URL(e,window.location.origin)),E1=zc?.kind==="models"?zc.route:null)}function j1(){lf="",cg();for(const e of of)e()}async function dg(e){if(Hc)return!1;Hc=!0;try{for(const t of[...sd].reverse())if(!await t(e))return!1;return!0}finally{Hc=!1}}function ug(e){return{...window.history.state,openpondNavigationIndex:e}}async function T4(){const e=Vl(),t=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:Ta-1;if(Vs&&t===Ta){const a=Vs;Vs=null,a();return}if(ep===t||sd.size===0){ep=null,xl=e,Ta=t,window.history.replaceState(ug(Ta),"",e),j1();return}if(t===Ta)return;if(rl||Hc){Vs??=()=>{},window.history.go(Ta-t);return}rl=!0;const n=t-Ta;try{await new Promise(a=>{Vs=a,window.history.go(-n)}),await dg(e)&&(ep=t,window.history.go(n))}finally{rl=!1}}function mg(){if(sf||typeof window>"u")return;const e=sg(window.location);xl=e?M1(e):Vl(),Ta=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:0,window.history.replaceState(ug(Ta),"",xl),window.addEventListener("popstate",T4),sf=!0}function O1(e){return of.add(e),mg(),()=>{of.delete(e)}}function eJ(e){return sd.add(e),mg(),()=>{sd.delete(e)}}async function tJ(e){!rl&&await dg(Vl())&&e()}function E4(){return g.useSyncExternalStore(O1,()=>(cg(),E1),()=>null)}function M4(){return g.useSyncExternalStore(O1,()=>(cg(),zc),()=>null)}async function ln(e,t="push"){if(typeof window>"u"||(mg(),rl))return!1;if(e.kind==="settings"&&!e.returnTo){const a=sg(window.location),r=a?.kind==="models"?tu(a.route):a?.kind==="settings"?a.returnTo:void 0;r&&(e={...e,returnTo:r})}const n=M1(e);return Vl()===n?!0:await dg(n)?(t==="push"&&Ta++,window.history[t==="replace"?"replaceState":"pushState"](ug(Ta),"",n),xl=n,j1(),!0):!1}function ji(e,t="push"){return ln({kind:"models",route:e},t)}function j4({experience:e="work",productArea:t="chat",beginNewChat:n,setSectionMenuOpen:a,setSelectedAppId:r,setSelectedProjectId:i,setSelectedSessionId:s,setView:l,view:m,modelProjects:u=[],modelTrainingActivityByProjectId:h={}}){const b=E4(),y=b?.modelId??null,w=b?.page??"models";function _(){r(null),i(null),s(null),a(null)}async function E($){await ji(ro($,y))&&(_(),l("labs"))}async function j($){await ji(R4(b??ro(),$||null))&&(_(),l("labs"))}async function P($){await ln({kind:"view",view:$})&&(_(),l($))}const L=y?h[y]??null:null;return x.jsxs("nav",{className:"sidebar-nav","aria-label":"Primary",children:[t==="models"?null:x.jsxs("button",{className:"nav-command nav-command-new-task",type:"button",onClick:()=>{ln({kind:"chat",sessionId:null}),n(null)},children:[x.jsx(Xd,{size:18}),x.jsx("span",{children:T1(e)})]}),t==="models"?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"sidebar-model-project-picker",children:[x.jsx("span",{className:"sidebar-nav-group-label",children:"Model"}),x.jsx(S4,{label:"Model",searchable:u.length>8,value:y??"",options:[{value:"",label:"All models"},...y&&!u.some($=>$.id===y)?[{value:y,label:"Unavailable model",disabled:!0}]:[],...u.map($=>({value:$.id,label:$.name}))],onChange:$=>{j($)}})]}),af.filter($=>$!=="tasksets"&&$!=="evaluations").map($=>{const O={"get-started":Jm,models:uF,tasks:Jm,tasksets:Jm,labeling:tf,rewards:f4,evaluations:tf,runs:w1,versions:HF,serving:Jd}[$];return x.jsxs("button",{className:`nav-command ${m==="labs"&&(w===$||$==="runs"&&w==="evaluations")?"active":""}`,"aria-current":m==="labs"&&(w===$||$==="runs"&&w==="evaluations")?"page":void 0,type:"button",onClick:()=>{E($)},children:[x.jsx(O,{size:16}),x.jsx("span",{children:I4[$]}),$==="runs"&&L?x.jsx("span",{className:"sidebar-running-dot","aria-label":L.label}):null]},$)})]}):null,t==="chat"?x.jsxs(x.Fragment,{children:[x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="scheduled"?"active":""}`,"aria-label":"Workflows",type:"button",onClick:()=>{P("scheduled")},children:[x.jsx(xF,{size:18}),x.jsx("span",{children:"Workflows"})]}),x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="outputs"?"active":""}`,"aria-label":"Outputs",type:"button",onClick:()=>{P("outputs")},children:[x.jsx(NF,{size:18}),x.jsx("span",{children:"Outputs"})]}),x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="apps"?"active":""}`,"aria-label":"Apps",type:"button",onClick:()=>{P("apps")},children:[x.jsx(P1,{size:18}),x.jsx("span",{children:"Apps"})]}),x.jsxs("button",{className:`nav-command nav-command-prominent ${m==="projects"?"active":""}`,"aria-label":"Projects",type:"button",onClick:()=>{P("projects")},children:[x.jsx(_1,{size:18}),x.jsx("span",{children:"Projects"})]})]}):null]})}function O4({setSectionMenuOpen:e,setSelectedAppId:t,setSelectedProjectId:n,setSelectedSessionId:a,setView:r,view:i}){function s(){t(null),n(null),a(null),e(null),r("get-started"),ln({kind:"view",view:"get-started"})}return x.jsx("nav",{className:"sidebar-utility-nav","aria-label":"Resources",children:x.jsx(k4,{onOpenWalkthroughs:s,walkthroughsActive:i==="get-started"})})}const $1=gm({chatMode:v(["chat","work"]).optional(),notificationMode:v(["all","direct_mentions","none"]).optional(),learningNoticeDismissed:R().optional(),sidebarVisibility:gm({showCodexChats:R(),onlyRunningTasks:R()}).optional(),scheduledWorkView:v(["calendar","list"]).optional(),editorControlsVisible:R().optional(),voiceNoticeAcknowledged:R().optional(),lessonProgress:se(o().min(1).max(200),gm({completed:R(),currentTime:d().finite().nonnegative(),duration:d().finite().positive(),updatedAt:d().finite().nonnegative()})).refine(e=>Object.keys(e).length<=200,"Too many lessons").optional()}),cf={"openpond:last-chat-task-mode":"chatMode","openpond.team-chat.notification-mode":"notificationMode","openpond.sidebar.continuous-learning.dismissed.v1":"learningNoticeDismissed","openpond.sidebar-task-visibility.v1":"sidebarVisibility","openpond.scheduled-work.view.v1":"scheduledWorkView","openpond.workspace.editorControlsVisible":"editorControlsVisible","openpond.voice.setupNoticeAcknowledged":"voiceNoticeAcknowledged","openpond.post-training-progress.v1":"lessonProgress"},df=new Set;let il=null,No=null,Ma={},kl={},tp=!1,qc=0,Oi=null,Fb=0;const $4="openpond-client-choices-changed";function pg(){df.forEach(e=>e()),typeof window<"u"&&window.dispatchEvent(new Event($4))}function N4(){return Oi}function D4(e){return df.add(e),()=>{df.delete(e)}}function Kl(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>D4(()=>t.current()),[])}async function Vb(e){const t=++Fb,n=await q(e,"/v1/configuration");if(n.clientState?.revision===null){const r=L4();if(Object.keys(r.patch).length){n.clientState=await q(e,"/v1/configuration",{method:"POST",body:JSON.stringify({action:"client-state",owner:n.clientState.owner,patch:r.patch,importOnly:!0})});for(const i of r.keys)try{window.localStorage.removeItem(i)}catch{}}}if(t!==Fb)return;const a=il?.serverUrl!==e.serverUrl||il?.token!==e.token||No?.owner!==n.clientState?.owner;a&&(qc++,Ma={},kl={},Oi=null),il=e,(a||(n.clientState?.revision??0)>=(No?.revision??0))&&(No=n.clientState),pg()}async function fg(){if(tp||!il||!No||!Object.keys(Ma).length)return;tp=!0;const e=Ma,t=il,n=No.owner,a=qc;Ma={},kl=e;try{const r=await q(t,"/v1/configuration",{method:"POST",body:JSON.stringify({action:"client-state",owner:n,patch:e})});a===qc&&(No=r,Oi=null)}catch(r){a===qc&&(Ma={...e,...Ma},Oi=`Preference changes have not been saved. ${r instanceof Error?r.message:String(r)}`)}finally{kl={},tp=!1,pg(),!Oi&&Object.keys(Ma).length&&fg()}}function nJ(){Oi=null,fg()}const Wl={getItem(e){const t=cf[e];if(!t)return null;const n={...No?.value,...kl,...Ma}[t];return n===void 0?null:typeof n=="string"?n:JSON.stringify(n)},setItem(e,t){if(!No)return;const n=cf[e];if(!n)throw new Error("Unregistered client preference.");let a;try{a=JSON.parse(t)}catch{a=t}const r=$1.parse({[n]:a});JSON.stringify({...No.value,...kl,...Ma}[n])!==JSON.stringify(r[n])&&(Ma={...Ma,...r},pg(),fg())}};function L4(){const e={},t=[];if(typeof window>"u")return{patch:e,keys:t};for(const[n,a]of Object.entries(cf))try{const r=window.localStorage.getItem(n);if(r===null)continue;let i;try{i=JSON.parse(r)}catch{i=r}const s=$1.safeParse({[a]:i});s.success&&(Object.assign(e,s.data),t.push(n))}catch{}return{patch:e,keys:t}}const Bc=5,Cn=15,uf=10,Et={defaultChatProvider:Mr,subagents:qE(),codexPermissionMode:oh,codexReasoningEffort:rh,openPondCommandAccessMode:Rd,defaultBranchPrefix:"feat/",defaultNewProjectDirectory:"",advancedWorkspaceControls:!1,steerActiveResponses:!0,contextCompaction:{autoEnabled:!0,triggerPercent:85,summaryModel:"same_model"},training:{defaultModelRef:null,creationMode:"customize",autoApproveEvidence:!1},sidebarWidth:332,diffPanelWidth:560,sidebarSectionsCollapsed:{pinned:!1,projects:!1,cloudProjects:!1,chats:!1,savedForLater:!0},editor:{languageServers:"auto",diagnosticsWhileEditing:!0,checkOnSave:!0,languages:{typescript:{mode:"auto",customCommand:""},python:{mode:"auto",customCommand:""},rust:{mode:"auto",customCommand:""}}}},aJ={activeTemplateId:"default",customized:!1,soul:"",soulPath:null,updatedAt:null,templates:[]},N1=[{value:"accounts/fireworks/models/deepseek-v4-pro",label:"DeepSeek V4 Pro",description:"reasoning"},{value:"accounts/fireworks/models/kimi-k3",label:"Kimi K3",description:"reasoning"},{value:"accounts/fireworks/models/glm-5p3",label:"GLM-5.3",description:"reasoning"},{value:"accounts/fireworks/models/deepseek-v4-flash",label:"DeepSeek V4 Flash",description:"reasoning"},{value:"accounts/fireworks/models/nemotron-lightning-3p5-30b-a3b",label:"Nemotron Lightning 3.5 30B A3B",description:"reasoning"},{value:"accounts/fireworks/models/minimax-m3",label:"MiniMax M3",description:"reasoning"}],np=[{value:"openpond",label:"OpenPond Chat"},{value:"codex",label:"OpenAI Codex",description:"Codex login"}],U4=["openai","xai","openrouter","deepseek","zai","moonshot","together","groq","custom-openai-compatible"],z4=["openpond","codex",...U4],D1=new Set(z4),L1=[{value:ah,label:"GPT-5.6 Sol"},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra"},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna"},{value:"gpt-5.5",label:"GPT-5.5"},{value:"gpt-5.4",label:"GPT-5.4"},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark"},{value:"gpt-5.2",label:"GPT-5.2"}],oJ=[{value:"default",label:"Default permissions",shortLabel:"Default",description:"Workspace sandbox; asks before crossing boundaries."},{value:"auto-review",label:"Auto-review",description:"Workspace sandbox; reviewer handles eligible approvals."},{value:"full-access",label:"Full access",description:"No sandbox or approval prompts."}],rJ=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High",shortLabel:"Extra High"}],iJ=[{value:"ask",label:"Ask",description:"Ask before running shell commands."},{value:"full-access",label:"Full access",description:"Run shell commands without approval prompts."}],sJ=[{value:"auto",label:"Auto",description:"Use installed language servers when available."},{value:"off",label:"Off",description:"Disable editor language servers."}],lJ=[{value:"auto",label:"Auto",description:"Find the local executable automatically."},{value:"disabled",label:"Disabled",description:"Do not start this language server."},{value:"custom",label:"Custom",description:"Use a specific executable path or command name."}];function hg(e){return e.kind==="local"}function H4(e){return e.kind==="cloud"}function vt(e,t){return`${e}:${t}`}function U1(e){const t=e?.trim();if(!t)return null;const n=t.indexOf(":");if(n<=0)return{kind:"local",id:t};const a=t.slice(0,n),r=t.slice(n+1);return(a==="local"||a==="cloud")&&r?{kind:a,id:r}:{kind:"local",id:t}}function Pr(e){return`${e.type}:${e.id}`}function ld(e){const t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?"before":"after"}function cd(e,t,n,a="before"){if(t===n)return e;const r=e.filter(s=>s!==t),i=r.indexOf(n);return i===-1?e:(r.splice(a==="after"?i+1:i,0,t),r)}function Kb(e,t){return e.length===t.length&&e.every((n,a)=>n===t[a])}function q4(e,t){if(!t)return e;const n=new Map(e.map(i=>[i.key,i])),a=t.map(i=>n.get(i)).filter(i=>!!i),r=new Set(a.map(i=>i.key));return[...a,...e.filter(i=>!r.has(i.key))]}function gg(e,t){return e?.statuses?.[t]??null}function z1(e,t){return e?.providers?.[t]??null}function H1(e,t){return e?.modelCaches?.[t]??null}function B4(e){const t=[e.contextWindow?`${Math.round(e.contextWindow/1e3)}K context`:"",e.capabilities.reasoning?"reasoning":"",e.source].filter(Boolean);return{value:e.id,label:e.displayName||e.id,description:t.join(" · ")||void 0}}function F4(e){return e==="openpond"?N1:e==="codex"||e==="openai"?L1:[]}function V4(e){const t=new Set,n=[];for(const a of e)!a.value||t.has(a.value)||(t.add(a.value),n.push(a));return n}function cJ(e){return D1.has(e)}function mf(e,t={}){if(!e)return t.localOnly,np;const n=t.includeUnavailable??!1,a=t.enabledOnly??!1,r=[];for(const i of Kf){if(!D1.has(i)||t.localOnly&&i==="openpond")continue;const s=gg(e,i);s&&(!n&&(i==="codex"&&!s.available&&!s.credential.connected||i!=="openpond"&&i!=="codex"&&!s.enabled)||a&&i!=="openpond"&&!s.enabled||a&&i==="codex"&&!s.available&&!s.credential.connected||r.push({value:i,label:i==="openpond"?"OpenPond Chat":s.displayName,description:i==="openpond"?void 0:s.available?"Connected":s.credential.connected?"Configured":s.routing.localByok?"Set up key":s.enabled?"Enabled":void 0}))}return r.length>0?r:np}function wl(e,t){const a=(H1(t,e)?.models??[]).filter(s=>e!=="openpond"||s.id!==Ui).map(B4),r=z1(t,e),i=[...r?.modelOverrides??[],r?.defaultModel].filter(s=>!!s?.trim()&&(e!=="openpond"||s!==Ui)).map(s=>({value:s,label:s}));return V4([...a,...i,...F4(e)])}function K4(e,t,n){if(e==="codex"||e==="openai")return!0;const a=t.trim();if(!a)return!1;const r=H1(n,e)?.models.find(i=>i.id===a);return r?!!r.capabilities.reasoning:wl(e,n).some(i=>i.value===a&&/\breasoning\b/i.test(i.description??""))}function dd(e,t){const n=z1(t,e)?.defaultModel?.trim();if(n)return n;const a=gg(t,e)?.defaultModel?.trim();if(a)return a;const r=wl(e,t)[0]?.value?.trim();return r||(e==="codex"?ah:e==="openpond"?Ui:"")}function cr(e,t,n){const a=t?.trim();if(e==="codex"&&(a==="codex-default"||a==="gpt-5.5"))return ah;const r=wl(e,n);return a&&r.some(i=>i.value===a)||a&&e!=="codex"&&r.length===0&&!n?a:dd(e,n)}function q1(e,t){const n=e.modelRef?.providerId??e.provider;return{provider:n,model:cr(n,e.modelRef?.modelId,t)}}function vg(e,t,n){return cr(e,t,n)||void 0}function Pa(e,t,n){const a=vg(e,t,n);return a?{providerId:e,modelId:a}:void 0}function Wb(e){return e==="full-access"?{approvalPolicy:"never",sandbox:"danger-full-access"}:{approvalPolicy:"on-request",sandbox:"workspace-write"}}function pa(e){const t=e?.defaultChatProvider??Et.defaultChatProvider;return{defaultChatProvider:t,defaultChatModel:cr(t,e?.defaultChatModel),subagents:ul.parse(e?.subagents??Et.subagents),codexPermissionMode:e?.codexPermissionMode??Et.codexPermissionMode,codexReasoningEffort:e?.codexReasoningEffort??Et.codexReasoningEffort,openPondCommandAccessMode:e?.openPondCommandAccessMode??Et.openPondCommandAccessMode,defaultBranchPrefix:B1(e?.defaultBranchPrefix),defaultNewProjectDirectory:e?.defaultNewProjectDirectory??Et.defaultNewProjectDirectory,defaultTeamId:e?.defaultTeamId?.trim()||null,advancedWorkspaceControls:e?.advancedWorkspaceControls??Et.advancedWorkspaceControls,steerActiveResponses:e?.steerActiveResponses??Et.steerActiveResponses,contextCompaction:{autoEnabled:e?.contextCompaction?.autoEnabled??Et.contextCompaction.autoEnabled,triggerPercent:e?.contextCompaction?.triggerPercent??Et.contextCompaction.triggerPercent,summaryModel:e?.contextCompaction?.summaryModel??Et.contextCompaction.summaryModel},training:{defaultModelRef:e?.training?.defaultModelRef??Et.training.defaultModelRef,creationMode:e?.training?.creationMode??Et.training.creationMode,autoApproveEvidence:e?.training?.autoApproveEvidence??Et.training.autoApproveEvidence},sidebarWidth:e?.sidebarWidth??Et.sidebarWidth,diffPanelWidth:e?.diffPanelWidth??Et.diffPanelWidth,sidebarSectionsCollapsed:{pinned:e?.sidebarSectionsCollapsed?.pinned??Et.sidebarSectionsCollapsed.pinned,projects:e?.sidebarSectionsCollapsed?.projects??Et.sidebarSectionsCollapsed.projects,cloudProjects:e?.sidebarSectionsCollapsed?.cloudProjects??Et.sidebarSectionsCollapsed.cloudProjects,chats:e?.sidebarSectionsCollapsed?.chats??Et.sidebarSectionsCollapsed.chats,savedForLater:e?.sidebarSectionsCollapsed?.savedForLater??Et.sidebarSectionsCollapsed.savedForLater},editor:{languageServers:e?.editor?.languageServers??Et.editor.languageServers,diagnosticsWhileEditing:e?.editor?.diagnosticsWhileEditing??Et.editor.diagnosticsWhileEditing,checkOnSave:e?.editor?.checkOnSave??Et.editor.checkOnSave,languages:{typescript:{mode:e?.editor?.languages?.typescript?.mode??Et.editor.languages.typescript.mode,customCommand:e?.editor?.languages?.typescript?.customCommand??Et.editor.languages.typescript.customCommand},python:{mode:e?.editor?.languages?.python?.mode??Et.editor.languages.python.mode,customCommand:e?.editor?.languages?.python?.customCommand??Et.editor.languages.python.customCommand},rust:{mode:e?.editor?.languages?.rust?.mode??Et.editor.languages.rust.mode,customCommand:e?.editor?.languages?.rust?.customCommand??Et.editor.languages.rust.customCommand}}}}}function B1(e){const t=e?.trim()??Et.defaultBranchPrefix;if(!t)return"";const a=t.toLowerCase().replace(/[^a-z0-9._/-]+/g,"-").replace(/\/{2,}/g,"/").replace(/^-+/,"").slice(0,48).split("/").map(r=>r.replace(/^-+|-+$/g,"")).filter(Boolean).join("/");return a?`${a}/`:""}function dJ(e,t){return e==="openpond"?"OpenPond Chat":gg(t,e)?.displayName??(e==="codex"?"OpenAI Codex":e)}function uJ(e,t,n){if(n){const a=wl(n,t).find(r=>r.value===e);if(a)return a.label}if(t)for(const a of Kf){const r=wl(a,t).find(i=>i.value===e);if(r)return r.label}return[...N1,...L1].find(a=>a.value===e)?.label??e}function W4(e,t){return t==="chat"?e.filter(n=>n.experience==="chat"):e.filter(n=>n.experience==="work"||n.experience==="development")}function G4(e){return e.experience==="chat"?"Chat":"Work"}const bg="taskDraft";function F1(e){if(e?.experience!=="work")return null;const t=e.metadata?.[bg];if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.prompt;return typeof n=="string"&&n.trim()?n:null}function Il(e){return F1(e)!==null}function Z4(e){return(e.split(/\r?\n/u).map(n=>n.trim()).find(Boolean)||"Task draft").slice(0,64)}function ap(e,t,n=new Date().toISOString()){const a={version:1,prompt:t,savedAt:n};return{...e??{},[bg]:a}}function J4(e){const t={...e??{}};return delete t[bg],t}function tr(e){const t=Ic(e.metadata?.trainingTasksetId)??Ic(e.metadata?.tasksetId);return t?{id:t,name:Ic(e.metadata?.trainingTasksetName)??Ic(e.metadata?.tasksetName)??Y4(t)}:null}function Y4(e){const n=e.replace(/[-_][a-f0-9]{8,}$/i,"").replace(/^(?:benchmark[-_])?taskset[-_]/i,"").replace(/^benchmark[-_]/i,"").split(/[-_]+/).filter(Boolean);return n.length===0?"Taskset":n.map(a=>/^[A-Z0-9]{2,}$/.test(a)?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join(" ")}function Ic(e){return typeof e=="string"&&e.trim()?e.trim():null}const Q4="codex_history_";function Ht(e){return!!e?.startsWith(Q4)}function V1(e){const t=[],n=new Set;for(const a of e)for(const r of[a.workspacePath,a.path]){const i=nu(r);if(!i)continue;const s=`${a.id}:${i}`;n.has(s)||(n.add(s),t.push({projectId:a.id,path:i}))}return t.sort((a,r)=>r.path.length-a.path.length)}function X4(e,t,n,a=new Set){if(e.localProjectId&&t.has(e.localProjectId))return e.localProjectId;if(e.workspaceKind==="local_project"&&e.workspaceId&&t.has(e.workspaceId))return e.workspaceId;if(e.metadata?.workspaceTarget==="hybrid"&&e.cwd){const i=K1(e.cwd,n);if(i)return i}if(e.cloudProjectId&&a.has(e.cloudProjectId))return e.cloudProjectId;if(!e.cwd||e.workspaceKind==="sandbox"||e.workspaceKind==="sandbox_template"||e.workspaceKind==="sandbox_app"||!W1(e))return null;const r=nu(e.cwd);if(!r)return null;for(const i of n)if(yg(r,i.path))return i.projectId;return null}function Gb(e,t,n,a=new Set){if(e.localProjectId&&t.has(e.localProjectId))return vt("local",e.localProjectId);if(e.workspaceKind==="local_project"&&e.workspaceId&&t.has(e.workspaceId))return vt("local",e.workspaceId);if(e.metadata?.workspaceTarget==="hybrid"&&e.cwd){const i=K1(e.cwd,n);if(i)return vt("local",i)}if(e.cloudProjectId&&a.has(e.cloudProjectId))return vt("cloud",e.cloudProjectId);if(!e.cwd||e.workspaceKind==="sandbox"||e.workspaceKind==="sandbox_template"||e.workspaceKind==="sandbox_app"||!W1(e))return null;const r=nu(e.cwd);if(!r)return null;for(const i of n)if(yg(r,i.path))return vt("local",i.projectId);return null}function K1(e,t){const n=nu(e);if(!n)return null;for(const a of t)if(yg(n,a.path))return a.projectId;return null}function W1(e){return e.workspaceKind==="local_project"||e.provider==="codex"||Ht(e.id)}function nu(e){const t=e?.trim();if(!t)return null;let n=t.replace(/^file:\/\/+/i,"/").replace(/\\/g,"/").replace(/\/+/g,"/");return/^[a-z]:/i.test(n)&&(n=n[0].toUpperCase()+n.slice(1)),n=n.replace(/\/+$/g,""),n||"/"}function yg(e,t){const n=Zb(e),a=Zb(t);return n===a||n.startsWith(`${a}/`)}function Zb(e){return/^[A-Z]:\//.test(e)?e.toLowerCase():e}const Jb=[{value:"active",label:"Active"},{value:"in_progress",label:"In progress"},{value:"pinned",label:"Pinned"},{value:"saved_for_later",label:"Save for later"},{value:"tasksets",label:"Tasksets"},{value:"done",label:"Done"},{value:"all",label:"All"}],e5=[{value:"recent",label:"Recent first"},{value:"manual",label:"Manual order"}];function Yb(e){const t=[];if(e.filter==="done")t.push(...e.doneSessions.filter(r=>!tr(r)));else if(e.filter==="all")t.push(...e.activeSessions.filter(r=>!tr(r)),...e.doneSessions.filter(r=>!tr(r)));else if(e.filter==="tasksets")t.push(...e.activeSessions.filter(r=>Qb(r,e.selectedTasksetId)),...e.doneSessions.filter(r=>Qb(r,e.selectedTasksetId)));else for(const r of e.activeSessions)tr(r)||(e.filter==="active"?r.savedForLater||t.push(r):e.filter==="in_progress"?!r.savedForLater&&e.inProgressSessionIds.has(r.id)&&t.push(r):e.filter==="pinned"?r.pinned&&!r.savedForLater&&t.push(r):e.filter==="saved_for_later"&&r.savedForLater&&t.push(r));const n=t.filter(r=>bi(r,{inProgressSessionIds:e.inProgressSessionIds,onlyRunningTasks:e.onlyRunningTasks,showCodexChats:e.showCodexChats})),a=e.previewSessionIds?new Map(e.previewSessionIds.map((r,i)=>[r,i])):null;return e.sort==="recent"?n.sort((r,i)=>ey(r,i,a)):n.sort((r,i)=>{const s=a?.get(r.id),l=a?.get(i.id);if(s!==void 0||l!==void 0){if(s===void 0)return 1;if(l===void 0)return-1;if(s!==l)return s-l}return r.order!==i.order?r.order-i.order:ey(r,i)})}function bi(e,t){return t.showCodexChats===!1&&(e.provider==="codex"||Ht(e.id))?!1:!t.onlyRunningTasks||t.inProgressSessionIds.has(e.id)}function Qb(e,t){const n=tr(e);return!!(n&&(!t||n.id===t))}function t5(e){return e.filter==="saved_for_later"||e.filter==="tasksets"?{count:Math.max(0,e.activeCount),label:"In Progress",targetFilter:"active",targetLabel:"active"}:{count:Math.max(0,e.savedForLaterCount),label:"Later",targetFilter:"saved_for_later",targetLabel:"saved for later"}}function n5(e,t){switch(e){case"active":return`No active ${t}`;case"in_progress":return"No work in progress";case"pinned":return`No pinned ${t}`;case"saved_for_later":return"Nothing saved for later";case"tasksets":return"No Taskset chats yet";case"done":return`No done ${t}`;case"all":return`No ${t}`}}function Xb(e,t,n){const a=new Set(t);let r=0;return e.map(i=>{if(!a.has(i))return i;const s=n[r];return r+=1,s??i})}function ey(e,t,n=null){const a=sl(e),r=sl(t);if(a!==r)return a?-1:1;if(a&&r){const s=n?.get(e.id),l=n?.get(t.id);if(s!==void 0||l!==void 0){if(s===void 0)return 1;if(l===void 0)return-1;if(s!==l)return s-l}if(e.order!==t.order)return e.order-t.order}const i=Date.parse(t.updatedAt)-Date.parse(e.updatedAt);return i!==0?i:e.title.localeCompare(t.title)}function sl(e){return e.pinned&&!e.savedForLater&&!e.archived}const _c={showCodexChats:!0,onlyRunningTasks:!1},G1="openpond.sidebar-task-visibility.v1";function ty(e=Z1()){try{const t=e?.getItem(G1);if(!t)return _c;const n=JSON.parse(t);return{showCodexChats:typeof n.showCodexChats=="boolean"?n.showCodexChats:_c.showCodexChats,onlyRunningTasks:typeof n.onlyRunningTasks=="boolean"?n.onlyRunningTasks:_c.onlyRunningTasks}}catch{return _c}}function ny(e,t=Z1()){try{t?.setItem(G1,JSON.stringify(e))}catch{}}function Z1(){return typeof window>"u"?null:Wl}function J1(e){return`${e.kind}:${e.id}`}function _l(e,t){return!!(e&&t&&e.kind===t.kind&&e.id===t.id)}function a5(e){return{kind:"session",id:e}}function o5(e){return{kind:"project",id:e}}function r5(e){return{kind:"draft",id:e}}function i5(e){return e.selectedSessionId?a5(e.selectedSessionId):e.selectedProjectId?o5(e.selectedProjectId):r5(e.selectedAppId?`app:${e.selectedAppId}`:"new-chat")}function s5(e){if(!e.previousScope||e.previousScope.kind!=="draft"||e.activeScope.kind!=="session")return[...e.tabs];if(_l(e.previousScope,e.activeScope))return[...e.tabs];const t=e.now??Date.now();return e.tabs.map(n=>_l(n.scope,e.previousScope)?{...n,scope:e.activeScope,updatedAt:t}:n)}function mJ(e,t){return e.filter(n=>_l(n.scope,t))}function pJ(e,t){return!!(e&&_l(e.scope,t))}function l5(e){const t={};for(const n of e){const a=J1(n.scope),r=t[a]??{scope:n.scope,tabCount:0,runningCount:0,failedCount:0,lastExitCode:null,status:"none"};r.tabCount+=1,n.commandStatus==="running"&&(r.runningCount+=1),(n.commandStatus==="failed"||n.status==="error")&&(r.failedCount+=1),n.lastExitCode!==null&&(r.lastExitCode=n.lastExitCode),r.status=d5(r.status,n.status,n.commandStatus),t[a]=r}return t}function c5(e){return!e||e.status==="none"||e.tabCount===0?null:e.status==="running"?{status:"running",label:"Terminal running"}:e.status==="failed"?{status:"failed",label:"Terminal last command failed"}:e.status==="success"?{status:"success",label:"Terminal last command succeeded"}:e.status==="idle"?{status:"idle",label:"Terminal idle"}:{status:"unknown",label:"Terminal open"}}function d5(e,t,n){return n==="running"?"running":e==="running"?e:n==="failed"||t==="error"?"failed":e==="failed"?e:n==="success"?e==="none"||e==="unknown"||e==="idle"?"success":e:n==="idle"?e==="none"||e==="unknown"?"idle":e:e==="none"?"unknown":e}function Y1(e,t){if(!e)return t?.path??"Use files on this machine";if(e.error)return"status unavailable";if(!e.initialized)return"not checked out";const a=[e.currentBranch??t?.branch??e.defaultBranch??"no branch"],r=m5(e),i=t?.linkedCloudSourceKnown===!1&&!!e.headCommit;return r?a.push(r):i?a.push("upload required"):e.diverged?(e.ahead>0&&a.push(nr("ahead",e.ahead)),e.behind>0&&a.push(nr("behind",e.behind)),a.push("diverged")):(e.ahead>0&&a.push(nr("ahead",e.ahead)),e.behind>0&&a.push(nr("behind",e.behind))),e.changedFilesCount>0?a.push(`${e.changedFilesCount} changed`):e.dirty&&a.push("dirty"),e.untrackedFilesCount>0&&a.push(`${e.untrackedFilesCount} untracked`),a.length===1&&a.push("synced"),a.join(" / ")}function Q1(e,t,n,a={}){const r=e?.linkedSandboxProject??null;if(!r?.projectId&&!t)return"upload required";if(r?.projectId&&a.cloudLinkTrusted===!1)return"uploaded to a different account";const i=r?.defaultBranch??t?.defaultBranch??"main",s=r?.manifestHash??null,l=e?.sandboxTemplate?.manifestHash??null,m=r?.syncedAt??t?.syncedAt??null,u=!!(s&&l&&s!==l),h=!!(r?.projectId&&n?.headCommit&&!r.lastUploadedCommit),b=p5(n);return b?`${i} / ${b}`:h?`${i} / upload required`:`${i} / ${u||!m?"needs sync":"setup ready"}`}function u5(e,t,n={}){if(!e)return"select a local project";if(e.linkedSandboxProject?.projectId&&n.cloudLinkTrusted===!1)return"sync to this account";if(!t)return e.linkedSandboxProject?"sync source to cloud":"push local source to cloud";if(t.error)return"repo status unavailable";if(!t.initialized)return"local repo unavailable";const a=[],r=t.aheadOfLinkedSource>0?t.aheadOfLinkedSource:t.ahead;return e.linkedSandboxProject?.projectId||a.push("upload required"),e.linkedSandboxProject?.projectId&&t.headCommit&&!e.linkedSandboxProject.lastUploadedCommit&&a.push("upload required"),r>0&&a.push(X1(r)),t.linkedSourceHeadCommit&&t.headCommit&&t.linkedSourceHeadCommit!==t.headCommit&&t.linkedSourceComparisonError&&r===0&&a.push("source changed"),t.changedFilesCount>0&&a.push(`${t.changedFilesCount} changed file${t.changedFilesCount===1?"":"s"}`),t.untrackedFilesCount>0&&a.push(`${t.untrackedFilesCount} untracked skipped`),a.length>0?a.join(" / "):"nothing to upload"}function m5(e){return e.linkedSourceHeadCommit?e.divergedFromLinkedSource?"diverged":e.aheadOfLinkedSource>0?nr("local ahead",e.aheadOfLinkedSource):e.behindLinkedSource>0?nr("cloud ahead",e.behindLinkedSource):e.linkedSourceComparisonError&&e.headCommit&&e.linkedSourceHeadCommit!==e.headCommit?"sync unknown":null:null}function p5(e){return e?.linkedSourceHeadCommit?e.dirty?"local dirty files not in cloud":e.divergedFromLinkedSource?"diverged from local":e.aheadOfLinkedSource>0?nr("cloud behind local",e.aheadOfLinkedSource):e.behindLinkedSource>0?nr("cloud ahead local",e.behindLinkedSource):e.linkedSourceComparisonError&&e.headCommit&&e.linkedSourceHeadCommit!==e.headCommit?"source check unavailable":"synced":null}function nr(e,t){return`${e} by ${X1(t)}`}function X1(e){return`${e} commit${e===1?"":"s"}`}function f5({size:e=14,className:t}){return x.jsxs("svg",{className:["lucide lucide-cloud-upload",t??""].filter(Boolean).join(" "),xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[x.jsx("path",{d:"M12 13v8"}),x.jsx("path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"}),x.jsx("path",{d:"m8 17 4-4 4 4"})]})}function eI({kind:e,linkedCloud:t=!1,open:n=!1,className:a,baseSize:r=15}){const i=e==="cloud"?"cloud":n?"folder-open":"folder";return x.jsx("span",{className:["project-kind-icon",e,t?"linked-cloud":"",a??""].filter(Boolean).join(" "),"aria-hidden":"true",children:x.jsxs("svg",{className:`lucide lucide-${i} project-kind-icon-svg`,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e==="cloud"?x.jsx(v5,{}):n?x.jsx(g5,{}):x.jsx(h5,{}),t&&e==="local"?x.jsx(b5,{}):null]})})}function h5(){return x.jsx("path",{className:"project-kind-icon-base",d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}function g5(){return x.jsx("path",{className:"project-kind-icon-base",d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"})}function v5(){return x.jsx("path",{className:"project-kind-icon-base",d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"})}function b5(){return x.jsxs("g",{className:"project-kind-icon-cloud-badge",children:[x.jsx("circle",{cx:"18",cy:"17",r:"5"}),x.jsx("path",{d:"M20.4 18.6h-4.2a2.2 2.2 0 1 1 2.08-2.9h.88a1.45 1.45 0 1 1 1.24 2.9Z"})]})}var pf=L_();function y5({title:e,pinned:t,savedForLater:n,archived:a,onRename:r,onTogglePin:i,onToggleSaveForLater:s,onDockRight:l,onArchive:m}){const u=g.useRef(null),h=g.useRef(null),[b,y]=g.useState(null),w=[...r?[{label:"Rename",Icon:Xd,action:r}]:[],{label:t?"Unpin":"Pin",Icon:t?ag:ng,action:i},...s?[{label:n?"Return to active":"Save for later",Icon:n?k1:x1,action:s}]:[],...l?[{label:"Open in right panel",Icon:nf,action:l}]:[],{label:a?"Reopen":"Mark done",Icon:a?pF:wo,action:m}];function _(E=!1){y(null),E&&u.current?.focus()}return g.useEffect(()=>{if(!b)return;h.current?.querySelector("button")?.focus();const E=P=>{!h.current?.contains(P.target)&&!u.current?.contains(P.target)&&y(null)},j=()=>y(null);return document.addEventListener("pointerdown",E),window.addEventListener("resize",j),()=>{document.removeEventListener("pointerdown",E),window.removeEventListener("resize",j)}},[b]),x.jsxs(x.Fragment,{children:[x.jsx("div",{className:`sidebar-row-actions sidebar-task-menu-trigger${b?" is-open":""}`,children:x.jsx("button",{ref:u,type:"button",className:"sidebar-row-action","aria-label":`More actions for task ${e}`,"aria-haspopup":"menu","aria-expanded":!!b,draggable:!1,onDoubleClick:E=>E.stopPropagation(),onClick:E=>{if(E.stopPropagation(),b){_(!0);return}const j=E.currentTarget.getBoundingClientRect();y({left:Math.max(8,Math.min(j.right-192,window.innerWidth-200)),top:Math.max(8,Math.min(j.bottom+4,window.innerHeight-(w.length*32+17)))})},children:x.jsx(Qd,{size:16})})}),b&&pf.createPortal(x.jsx("div",{ref:h,role:"menu","aria-label":`Actions for ${e}`,className:"sidebar-task-menu",style:b,onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),onBlur:E=>{E.currentTarget.contains(E.relatedTarget)||_()},onKeyDown:E=>{E.stopPropagation();const j=Array.from(E.currentTarget.querySelectorAll("button")),P=j.indexOf(document.activeElement);if(E.key==="Escape"&&(E.preventDefault(),_(!0)),["ArrowDown","ArrowUp","Home","End"].includes(E.key)){E.preventDefault();const L=E.key==="Home"?0:E.key==="End"?j.length-1:(P+(E.key==="ArrowDown"?1:-1)+j.length)%j.length;j[L]?.focus()}},children:w.map(({label:E,Icon:j,action:P},L)=>x.jsxs("button",{type:"button",role:"menuitem",className:L===w.length-1?"task-menu-done":void 0,onClick:()=>{_(!0),P()},children:[x.jsx(j,{size:15}),E]},E))}),document.body)]})}function S5({session:e,onSave:t,onClose:n}){const[a,r]=g.useState(e.title),i=g.useRef(null);g.useEffect(()=>{const m=i.current;m&&(m.focus(),m.select())},[]),g.useEffect(()=>{function m(u){u.key==="Escape"&&n()}return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n]);function s(){const m=a.trim();m&&(t(m),n())}function l(m){m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),s())}return x.jsx("div",{className:"git-dialog-backdrop rename-chat-backdrop",role:"presentation",onMouseDown:n,children:x.jsxs("section",{className:"git-dialog rename-chat-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rename-chat-title",onMouseDown:m=>m.stopPropagation(),children:[x.jsx("h2",{id:"rename-chat-title",children:"Rename chat"}),x.jsx("textarea",{ref:i,className:"rename-chat-input",value:a,rows:1,maxLength:200,onChange:m=>r(m.target.value),onKeyDown:l,"aria-label":"Chat title"}),x.jsxs("div",{className:"git-dialog-footer",children:[x.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:n,children:"Cancel"}),x.jsx("button",{type:"button",className:"git-dialog-primary",autoFocus:!0,onClick:s,disabled:!a.trim(),children:"Save"})]})]})})}const x5=24;function k5({title:e}){const t=g.useRef(e),[n,a]=g.useState(e);return g.useEffect(()=>{const r=t.current;if(t.current=e,!e){a("");return}if(r||window.matchMedia("(prefers-reduced-motion: reduce)").matches){a(e);return}const i=Array.from(e);let s=0;a("");const l=window.setInterval(()=>{s+=1,a(i.slice(0,s).join("")),s>=i.length&&window.clearInterval(l)},x5);return()=>window.clearInterval(l)},[e]),x.jsx("span",{className:"sidebar-task-title-text","aria-label":e||"New task",children:n||"New task"})}const w5=2650,I5=304,_5=260,C5=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}),R5=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit"}),P5=new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"});function A5(){return{animationDelay:`${-(Date.now()%w5)}ms`}}function T5(e){const t=e.currentTarget,n=t.firstElementChild;if(!(n instanceof HTMLElement))return;const a=Math.max(0,n.scrollWidth-t.clientWidth),r=a>2;t.dataset.overflowing=String(r),t.style.setProperty("--sidebar-title-ticker-distance",`${-a}px`),t.style.setProperty("--sidebar-title-ticker-duration",`${Math.min(6.5,Math.max(2.8,a/42+2.4))}s`)}function ay({label:e,actions:t,actionsVisible:n=!1,className:a,titleAccessory:r,children:i,collapsed:s=!1,titleActive:l=!1,onTitleClick:m,onToggleCollapsed:u}){return x.jsxs("section",{className:["sidebar-section",a,n?"actions-visible":""].filter(Boolean).join(" "),children:[x.jsxs("div",{className:"section-header",children:[x.jsxs("div",{className:"section-title-row",children:[m?x.jsxs("div",{className:"section-title-combo",children:[x.jsx("button",{type:"button",className:`section-title-link${l?" active":""}`,onClick:m,children:x.jsx("span",{children:e})}),u&&x.jsx("button",{type:"button",className:"section-chevron-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:s?x.jsx($r,{size:13}):x.jsx(zo,{size:13})})]}):u?x.jsxs("button",{type:"button",className:"section-title-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:[x.jsx("span",{children:e}),s?x.jsx($r,{size:13}):x.jsx(zo,{size:13})]}):x.jsx("span",{children:e}),r]}),t&&x.jsx("div",{className:"section-actions",children:t})]}),!s&&x.jsx("div",{className:"sidebar-section-body",children:i})]})}function oy({children:e,expanded:t=!1,onClick:n}){return x.jsx("button",{type:"button",className:"sidebar-show-more",onClick:n,children:e??(t?"Show less":"Show more")})}function op({session:e,selected:t,icon:n,archived:a=!1,hideIcon:r=!1,nested:i=!1,dragging:s,placeholder:l,running:m,goalRuntime:u,subagentRuntime:h,terminalIndicator:b,projectLabel:y,ariaDescribedBy:w,childSessionCount:_=0,childSessionsExpanded:E=!1,onSelect:j,onToggleChildSessions:P,onTogglePin:L,onToggleSaveForLater:$,onDockRight:O,onArchive:k,onDragStart:C,onDragEnd:A,onDragOver:z,onDrop:B,onRename:N}){const[K,de]=g.useState(!1),te=u?.status==="queued",Ie=u?.tone==="active"&&!te,xe=(h?.activeCount??0)>0,Z=_>0&&!!P,Ae=r&&!Z,he=xe||Ie||!te&&(m??e.status==="active"),ue=xe&&h?h.label:Ie&&u?M5(u):"Running",be=["sidebar-task-row",Il(e)?"is-draft":"",he?"has-running-dot":""].filter(Boolean).join(" "),ne=g.useMemo(A5,[]),ge=x.jsx(y5,{title:e.title,pinned:!!e.pinned,savedForLater:!!e.savedForLater,archived:a,onRename:N?()=>de(!0):void 0,onTogglePin:L,onToggleSaveForLater:$,onDockRight:O,onArchive:k}),ke=x.jsxs(Sg,{selected:t,dataSessionId:e.id,dragging:s,iconless:Ae,nested:i,placeholder:l,className:be||void 0,ariaExpanded:Z?E:void 0,ariaDescribedBy:w,onSelect:j,onDragStart:C,onDragEnd:A,onDragOver:z,onDrop:B,onDoubleClick:N?()=>de(!0):void 0,children:[Ae?null:Z?x.jsx("button",{type:"button",className:"sidebar-child-toggle","data-tooltip":E?"Hide subagent conversations":"Show subagent conversations","aria-label":`${E?"Hide":"Show"} ${_} subagent ${_===1?"conversation":"conversations"}`,"aria-expanded":E,onClick:Se=>{Se.stopPropagation(),P?.()},children:E?x.jsx(zo,{size:13}):x.jsx($r,{size:13})}):n??x.jsx(Yd,{size:15}),x.jsx("span",{className:"row-label-shell",title:y||void 0,children:x.jsx("span",{className:"sidebar-session-title-line",children:x.jsx("span",{className:"row-label sidebar-task-title","data-overflowing":"false",onPointerEnter:T5,children:x.jsx(k5,{title:e.title})})})}),x.jsxs("div",{className:"row-meta",children:[x.jsxs("span",{className:"row-meta-status",children:[b?x.jsx(tI,{indicator:b}):null,he?x.jsx("span",{className:`sidebar-running-dot${xe?" subagent":Ie?" goal":""}`,style:ne,"aria-label":ue}):null]}),ge]})]}),qe=K&&N?x.jsx(S5,{session:e,onSave:Se=>N(e,Se),onClose:()=>de(!1)}):null;return x.jsxs(x.Fragment,{children:[ke,qe]})}function E5({file:e,selected:t=!1,placeholder:n,onSelect:a,onTogglePin:r,onToggleSaveForLater:i,onDragStart:s,onDragEnd:l,onDragOver:m,onDrop:u}){const h=e.path.split("/").at(-1)??e.path,b=`${e.workspaceName} · ${e.path}`;return x.jsxs(Sg,{selected:t,placeholder:n,className:`sidebar-file-row actions-2${e.available?"":" unavailable"}`,onSelect:a,onDragStart:s,onDragEnd:l,onDragOver:m,onDrop:u,children:[e.available?x.jsx(tg,{size:15}):x.jsx(PF,{size:15}),x.jsx("span",{className:"row-label-shell",title:b,children:x.jsx("span",{className:"row-label",children:h})}),x.jsx("div",{className:"row-meta",children:x.jsxs("div",{className:"sidebar-row-actions",children:[x.jsx(ud,{label:e.status==="pinned"?"Unpin file":"Pin file",onClick:r,children:e.status==="pinned"?x.jsx(ag,{size:13}):x.jsx(ng,{size:13})}),x.jsx(ud,{label:e.status==="saved_for_later"?"Remove from Save for later":"Save file for later",onClick:i,children:e.status==="saved_for_later"?x.jsx(k1,{size:13}):x.jsx(x1,{size:13})})]})})]})}function M5(e){return e.actionLabel}function j5({kind:e="local",project:t,pinned:n=!1,selected:a,expanded:r=!1,disclosure:i=!0,workspaceState:s,cloudLinkTrusted:l=!0,cloudLinkWarning:m=null,placeholder:u,terminalIndicator:h,onSelect:b,onNewChat:y,onMoveToCloud:w,onWorkspaceTargetSelect:_,onTogglePin:E,onRemove:j,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:O}){const[k,C]=g.useState(!1),A=g.useRef(null),[z,B]=g.useState({}),N=!!w||!!j,K=e==="local"&&l!==!1&&!!t.linkedSandboxProject?.projectId,de=g.useCallback(()=>{if(typeof window>"u")return;const xe=A.current?.getBoundingClientRect();if(!xe)return;const Z=Math.max(12,window.innerWidth-I5-12),Ae=Math.max(12,window.innerHeight-_5),he=Math.max(12,Math.min(xe.right+10,Z)),ue=Math.max(12,Math.min(xe.top-4,Ae)),be={"--sidebar-project-locations-left":`${Math.round(he)}px`,"--sidebar-project-locations-top":`${Math.round(ue)}px`};B(ne=>ne["--sidebar-project-locations-left"]===be["--sidebar-project-locations-left"]&&ne["--sidebar-project-locations-top"]===be["--sidebar-project-locations-top"]?ne:be)},[]),te=g.useCallback(()=>{de(),b()},[b,de]);function Ie(){C(!1)}return x.jsxs("div",{ref:A,className:["sidebar-project-row-shell",k?"project-menu-open":""].filter(Boolean).join(" "),onFocusCapture:de,onPointerEnter:de,children:[x.jsxs(Sg,{selected:a,placeholder:u,className:["sidebar-project-row",k?"project-menu-open":""].filter(Boolean).join(" "),ariaExpanded:i?r:void 0,onSelect:te,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:O,children:[x.jsx(eI,{kind:e,linkedCloud:K,open:e==="local"&&r,className:"sidebar-row-icon",baseSize:15}),x.jsx("span",{className:"row-label-shell",children:x.jsxs("span",{className:"sidebar-project-title-line",children:[x.jsx("span",{className:"row-label",children:t.name}),x.jsx(O5,{value:t.updatedAt}),i?x.jsx("span",{className:"sidebar-project-caret","aria-hidden":"true",children:r?x.jsx(zo,{size:13}):x.jsx($r,{size:13})}):null]})}),x.jsxs("div",{className:"row-meta",children:[x.jsx("span",{className:"row-meta-status",children:h?x.jsx(tI,{indicator:h}):null}),x.jsxs("div",{className:"sidebar-row-actions",children:[x.jsx(ud,{label:n?"Unpin project":"Pin project",onClick:E,children:n?x.jsx(ag,{size:13}):x.jsx(ng,{size:13})}),N&&x.jsx(G5,{open:k,onToggleOpen:()=>C(xe=>!xe)}),x.jsx(ud,{label:"New task",onClick:y,children:x.jsx(Xd,{size:13})})]})]})]}),x.jsx(N5,{kind:e,project:t,workspaceState:s,cloudLinkTrusted:l,cloudLinkWarning:m,onWorkspaceTargetSelect:_,style:z}),k&&x.jsx(Z5,{onClose:Ie,onMoveToCloud:w?()=>{Ie(),w()}:void 0,onRemove:()=>{Ie(),j()}})]})}function O5({value:e}){const t=$5(e);if(!t||!e)return null;const n=new Date(e);return x.jsx("time",{className:"sidebar-row-updated-at",dateTime:e,title:`Last updated ${P5.format(n)}`,children:t})}function $5(e,t=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const a=R5.format(n);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?a:`${C5.format(n)} ${a}`}function tI({indicator:e}){return x.jsx("span",{className:`sidebar-terminal-indicator ${e.status}`,"data-tooltip":e.label,"aria-label":e.label,title:e.label,children:x.jsx(A1,{size:13})})}function N5({kind:e,project:t,workspaceState:n,cloudLinkTrusted:a,cloudLinkWarning:r,onWorkspaceTargetSelect:i,style:s}){const l=U5(e,t,n,a,r);return x.jsxs("aside",{className:"sidebar-project-locations-popover","aria-label":`${t.name} status`,style:s,children:[x.jsx("div",{className:"sidebar-project-locations-title",children:t.name}),x.jsx("div",{className:"sidebar-project-location-list",children:l.map(m=>{const u=["sidebar-project-location-row",m.tone??"",m.actionTarget?"clickable":""].filter(Boolean).join(" "),h=x.jsxs(x.Fragment,{children:[x.jsx("span",{className:["sidebar-project-location-icon",m.key].filter(Boolean).join(" "),"aria-hidden":"true",children:m.icon}),x.jsx("span",{className:"sidebar-project-location-copy",children:x.jsx(D5,{value:m.value})})]});return m.actionTarget?x.jsx("button",{type:"button",className:u,"data-workspace-target":m.actionTarget,disabled:m.disabled||!i,title:m.disabledReason??void 0,onClick:b=>{b.stopPropagation(),!m.disabled&&i?.(m.actionTarget)},children:h},m.key):x.jsx("div",{className:u,children:h},m.key)})})]})}function D5({value:e}){const t=L5(e);return x.jsxs("span",{className:"sidebar-project-location-value","aria-label":e,children:[t.branch?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"sidebar-project-location-branch",children:t.branch}),x.jsx("span",{className:"sidebar-project-location-separator","aria-hidden":"true",children:"/"})]}):null,x.jsx("span",{className:"sidebar-project-location-status",children:t.status})]})}function L5(e){const n=e.indexOf(" / ");return n===-1?{branch:null,status:e}:{branch:e.slice(0,n),status:e.slice(n+3)}}function U5(e,t,n,a=!0,r=null){return e==="cloud"?H5(t):z5(t,n,a,r)}function z5(e,t,n=!0,a=null){const r=q5(e,t,n),i=B5(t),s=V5(e,n),l=n===!1&&a;return[{key:"local",value:r,tone:i?"attention":"local",icon:e.source==="git"?x.jsx(_1,{size:13}):x.jsx(I1,{size:13}),actionTarget:"local"},{key:"cloud",value:l||(s?K5(e,t,n):"not in cloud"),tone:l?"attention":"cloud",icon:x.jsx(Jd,{size:13}),actionTarget:s?"cloud":"upload_cloud"}]}function H5(e){return[{key:"cloud",value:W5(e),tone:e.syncedAt?"cloud":"attention",icon:x.jsx(Jd,{size:13}),actionTarget:"cloud"}]}function q5(e,t,n){const a=F5(e,t);return t?t.error?`${a} / status unavailable`:t.initialized?Y1(t,{branch:e.linkedSandboxProject?.defaultBranch??null,linkedCloudSourceKnown:e.linkedSandboxProject?.projectId&&n?!!e.linkedSandboxProject.lastUploadedCommit||!t.headCommit:!0}):`${a} / not checked out`:`${a} / available`}function B5(e){return!!(e?.dirty||(e?.changedFilesCount??0)>0||(e?.untrackedFilesCount??0)>0)}function F5(e,t){return t?.currentBranch??t?.defaultBranch??e.linkedSandboxProject?.defaultBranch??"local"}function V5(e,t=!0){return!!(t&&e.linkedSandboxProject?.projectId||e.linkedOpenPondApp?.appId)}function K5(e,t,n){return Q1(e,null,t,{cloudLinkTrusted:n})}function W5(e){const t=e.defaultBranch??"main",n=e.syncedAt?"setup ready":"needs setup";return`${t} / ${n}`}function G5({open:e,onToggleOpen:t}){return x.jsx("button",{type:"button",className:`sidebar-row-action ${e?"active":""}`,"data-tooltip":"More project actions","aria-label":"More project actions","aria-haspopup":"menu","aria-expanded":e,onClick:n=>{n.stopPropagation(),t()},children:x.jsx(Qd,{size:13})})}function Z5({onClose:e,onMoveToCloud:t,onRemove:n}){return x.jsxs(x.Fragment,{children:[x.jsx("button",{type:"button",className:"sidebar-project-menu-backdrop","aria-label":"Close project actions",onClick:a=>{a.stopPropagation(),e()}}),x.jsxs("div",{className:"section-menu-popover sidebar-project-row-popover",role:"menu",children:[t&&x.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),t()},children:[x.jsx(f5,{size:13}),x.jsx("span",{children:"Move to Cloud"})]}),x.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),n()},children:[x.jsx(os,{size:13}),x.jsx("span",{children:"Remove from Projects"})]})]})]})}function Sg({children:e,className:t,dataSessionId:n,dragging:a,iconless:r=!1,nested:i=!1,placeholder:s=!1,selected:l,ariaExpanded:m,ariaDescribedBy:u,onSelect:h,onDragStart:b,onDragEnd:y,onDragOver:w,onDrop:_,onDoubleClick:E}){const j=!!b;return x.jsx("div",{className:["sidebar-row",t??"",l?"selected":"",a?"dragging":"",r?"iconless":"",i?"nested":"",s?"placeholder":""].filter(Boolean).join(" "),draggable:j,"data-session-id":n,role:"button",tabIndex:0,"aria-expanded":m,"aria-describedby":u,onClick:h,onDoubleClick:E,onKeyDown:P=>{P.target===P.currentTarget&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),h())},onDragStart:b,onDragEnd:y,onDragEnter:P=>{w&&(P.preventDefault(),P.dataTransfer.dropEffect="move",w(P))},onDragOver:P=>{w&&(P.preventDefault(),P.dataTransfer.dropEffect="move",w(P))},onDrop:P=>{_&&(P.preventDefault(),_(P))},children:e})}function ud({children:e,label:t,onClick:n}){return x.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":t,"aria-label":t,onClick:a=>{a.stopPropagation(),n()},children:e})}function J5({filter:e,groupByProject:t,noun:n,onFilterChange:a,onGroupByProjectChange:r,onOnlyRunningTasksChange:i,onShowCodexChatsChange:s,onTasksetChange:l,onSortChange:m,onlyRunningTasks:u,openMenu:h,setOpenMenu:b,showCodexChats:y,sort:w,selectedTasksetId:_,tasksets:E}){const j=g.useRef(null),[P,L]=g.useState(!1),O=E.find(A=>A.id===_)?.name??Jb.find(A=>A.value===e)?.label??"Active",k=h==="tasks-filter",C=h==="chats";return g.useEffect(()=>{if(!k&&!C)return;function A(z){j.current?.contains(z.target)||b(null)}return document.addEventListener("pointerdown",A),()=>document.removeEventListener("pointerdown",A)},[k,b,C]),x.jsxs("div",{className:"sidebar-task-list-controls",ref:j,children:[x.jsxs("div",{className:"section-menu",children:[x.jsx("button",{type:"button",className:`section-icon ${C?"active":""}`,"aria-label":`${n==="tasks"?"Task":"Chat"} list options`,"aria-haspopup":"menu","aria-expanded":C,onClick:()=>b(A=>A==="chats"?null:"chats"),children:x.jsx(Qd,{size:14})}),C?x.jsxs("div",{className:"section-menu-popover",role:"menu","aria-label":`${n==="tasks"?"Task":"Chat"} list options`,children:[x.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":y,onClick:()=>s(!y),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:y?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"Show Codex chats"})]}),x.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":u,onClick:()=>i(!u),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:u?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"Only running tasks"})]}),n==="tasks"?x.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":t,onClick:()=>r(!t),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:t?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"Group by project"})]}):null,e5.map(A=>x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w===A.value,onClick:()=>{m(A.value),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:w===A.value?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:A.label})]},A.value))]}):null]}),x.jsxs("div",{className:"section-menu",children:[x.jsx("button",{type:"button",className:`section-icon ${k?"active":""}`,"aria-label":`Filter ${n}: ${O}`,"aria-haspopup":"menu","aria-expanded":k,onClick:()=>b(A=>A==="tasks-filter"?null:"tasks-filter"),children:x.jsx(GF,{size:14})}),k?x.jsx("div",{className:"section-menu-popover",role:"menu","aria-label":`Filter ${n}`,children:Jb.map(A=>x.jsxs(g.Fragment,{children:[A.value==="tasksets"?x.jsxs("button",{type:"button",role:"menuitem","aria-expanded":P,onClick:()=>L(z=>!z),children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:P?x.jsx(zo,{size:13}):x.jsx($r,{size:13})}),x.jsx("span",{children:A.label})]}):x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":e===A.value,onClick:()=>{a(A.value),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e===A.value?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:A.label})]}),A.value==="tasksets"&&P?x.jsxs(x.Fragment,{children:[x.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&!_,onClick:()=>{l(null),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&!_?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:"All Tasksets"})]}),E.map(z=>x.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&_===z.id,onClick:()=>{l(z.id),b(null)},children:[x.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&_===z.id?x.jsx(wo,{size:13}):null}),x.jsx("span",{children:z.name}),x.jsx("span",{className:"section-menu-option-count","aria-hidden":"true",children:z.chatCount})]},z.id))]}):null]},A.value))}):null]})]})}const Y5=240,Q5=36;function X5(e,t,n=!1){const a=Math.max(12,t.width-Y5-12),r=Math.max(12,t.height-Q5-(n?22:0)-12);return{"--sidebar-task-detail-left":`${Math.round(Math.max(12,Math.min(e.right+10,a)))}px`,"--sidebar-task-detail-top":`${Math.round(Math.max(12,Math.min(e.top-4,r)))}px`}}function e3({detail:e,onClose:t}){if(g.useEffect(()=>{if(!e||typeof window>"u")return;const r=l=>{l.key==="Escape"&&t()};let i=!1;const s=window.requestAnimationFrame(()=>{window.addEventListener("scroll",t,!0),i=!0});return window.addEventListener("keydown",r),()=>{window.cancelAnimationFrame(s),window.removeEventListener("keydown",r),i&&window.removeEventListener("scroll",t,!0)}},[e,t]),!e)return null;const n=new Date(e.updatedAt),a=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(n);return x.jsxs("aside",{id:e.descriptionId,className:"sidebar-task-detail-popover",style:e.style,role:"tooltip","aria-label":`Last updated for ${e.title}`,children:[x.jsx("time",{dateTime:e.updatedAt,children:a}),e.folderName?x.jsxs("div",{className:"sidebar-task-detail-folder",children:[x.jsx(I1,{size:13,"aria-hidden":"true"}),x.jsx("span",{children:e.folderName})]}):null]})}function t3({children:e,expanded:t,groupKey:n,kind:a,label:r,onToggle:i,onNewTask:s,onOpenProject:l,onRemoveProject:m,project:u}){const h=`sidebar-task-group-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,b=a==="draft"?tg:Yd,[y,w]=g.useState(!1),_=!!(s||l||m);return x.jsxs("section",{className:"sidebar-task-project-group",children:[x.jsxs("div",{className:`sidebar-task-project-group-header-shell${y?" menu-open":""}`,children:[x.jsxs("button",{type:"button",className:"sidebar-task-project-group-header","aria-controls":h,"aria-expanded":t,onClick:()=>{w(!1),i()},children:[u?x.jsx(eI,{kind:u.kind,linkedCloud:!!(u.kind==="local"&&u.project.linkedSandboxProject?.projectId),open:u.kind==="local"&&t,className:"sidebar-task-project-group-icon",baseSize:14}):x.jsx(b,{className:"sidebar-task-project-group-icon",size:14,"aria-hidden":"true"}),x.jsx("span",{className:"sidebar-task-project-group-name",children:r}),x.jsx("span",{className:"sidebar-task-project-group-caret","aria-hidden":"true",children:t?x.jsx(zo,{size:13}):x.jsx($r,{size:13})})]}),u&&_?x.jsxs("div",{className:"sidebar-task-project-group-actions",children:[l||m?x.jsx("button",{type:"button",className:`sidebar-row-action${y?" active":""}`,"data-tooltip":"More project actions","aria-label":"More project actions","aria-expanded":y,"aria-haspopup":"menu",onClick:()=>w(E=>!E),children:x.jsx(Qd,{size:13})}):null,s?x.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":"New task","aria-label":"New task",onClick:s,children:x.jsx(Xd,{size:13})}):null]}):null,y?x.jsxs(x.Fragment,{children:[x.jsx("button",{type:"button",className:"sidebar-task-project-group-menu-backdrop","aria-label":"Close project actions",onClick:()=>w(!1)}),x.jsxs("div",{className:"section-menu-popover sidebar-task-project-group-menu",role:"menu",children:[l?x.jsx("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),l()},children:x.jsx("span",{children:"Open project"})}):null,m?x.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),m()},children:[x.jsx(os,{size:13}),x.jsx("span",{children:"Remove from Projects"})]}):null]})]}):null]}),t?x.jsx("div",{id:h,className:"sidebar-task-project-group-content",children:e}):null]})}const n3={},a3=new Map,o3=new Map;function r3(e,t){return Math.min(Math.max(e,Cn)+uf,t)}function i3(e,t){const n=Math.max(Cn,Math.min(e,t));if(n<=Cn)return Cn;const a=Math.ceil((n-Cn)/uf);return Math.max(Cn,Cn+(a-1)*uf)}function s3(e,t){const n=new Map;for(const a of e){const r=t(a),i=n.get(r.key);i?i.sessions.push(a):n.set(r.key,{...r,sessions:[a]})}return[...n.values()]}function l3({activeSessions:e,archiveSession:t,archivedSessions:n,chatRowsVisibleCount:a,childSessionRowsByParentId:r={},cloudProjectRows:i,beginProjectChat:s,commitTaskDrop:l,commitTaskPreviewDrop:m,dockSessionRight:u,experience:h="work",goalRuntimeBySessionId:b=a3,localProjectRows:y,openSidebarFile:w,pinnedCollapsed:_,pinnedRows:E,previewTaskDrop:j,previewPinnedDrop:P,projectRows:L,renameSession:$,restoreSession:O,runningSessionIds:k,savedForLaterSessions:C,sectionMenuOpen:A,selectedProjectId:z,selectedSessionId:B,setChatRowsVisibleCount:N,setSectionMenuOpen:K,setSelectedAppId:de,setSelectedProjectId:te,setSelectedSessionId:Ie,setView:xe,sidebarProjectIdBySessionId:Z,startTaskDrag:Ae,startPinnedDrag:he,subagentRuntimeBySessionId:ue=o3,taskDragSessionId:be,taskPreviewSessionIds:ne,terminalSummaries:ge=n3,toggleSessionPinned:ke,toggleSessionSavedForLater:qe,view:Se,clearTaskDrag:ie,removeProject:we,toggleProjectPinned:Oe,onTogglePinnedCollapsed:Qe,setSidebarFileStatus:Ge,commitPinnedDrop:st,commitPinnedPreviewDrop:Le,clearSidebarDrag:Fe,dragItem:De}){const[D,M]=g.useState("active"),[H,Q]=g.useState("manual"),[me,_e]=g.useState(h!=="chat"),[$e,Xe]=g.useState(ty);Kl(()=>Xe(ty()));const{onlyRunningTasks:et,showCodexChats:rt}=$e,[it,Me]=g.useState(null),[Be,p]=g.useState(()=>new Set),[U,V]=g.useState(()=>new Map),[le,re]=g.useState(null),F=h==="chat"?"chats":"tasks",I=h==="chat"?"Chats":"Tasks",W=L??[...y,...i],X=g.useMemo(()=>new Map(W.map(ae=>[ae.id,ae.project.name])),[W]),oe=g.useMemo(()=>new Map(W.map(ae=>[ae.id,ae])),[W]),G=g.useMemo(()=>{const ae=new Set(k);for(const Ke of e){const ze=b.get(Ke.id),Ze=ue.get(Ke.id);(ze?.tone==="active"&&ze.status!=="queued"||(Ze?.activeCount??0)>0||yt(Ke.id)?.status==="running")&&ae.add(Ke.id)}return ae},[e,b,k,ue,ge]),pe=g.useMemo(()=>e.filter(ae=>tr(ae)===null&&bi(ae,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[e,G,et,rt]),fe=g.useMemo(()=>C.filter(ae=>tr(ae)===null&&bi(ae,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,C,rt]),je=Math.max(0,pe.length-fe.length),Ee=t5({activeCount:je,filter:D,savedForLaterCount:fe.length}),Ne=g.useMemo(()=>Yb({activeSessions:e,doneSessions:n,filter:"all",inProgressSessionIds:G,sort:"manual"}),[e,n,G]),Ve=g.useMemo(()=>Yb({activeSessions:e,doneSessions:n,filter:D,inProgressSessionIds:G,onlyRunningTasks:et,selectedTasksetId:it,previewSessionIds:ne,showCodexChats:rt,sort:H}),[e,n,G,et,it,rt,D,ne,H]),Ue=g.useMemo(()=>{const ae=new Map;for(const Ke of[...e,...n]){if(!bi(Ke,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))continue;const ze=tr(Ke);if(!ze)continue;const Ze=ae.get(ze.id);Ze?Ze.chatCount+=1:ae.set(ze.id,{...ze,chatCount:1})}return[...ae.values()].sort((Ke,ze)=>Ke.name.localeCompare(ze.name))},[e,n,G,et,rt]),ut=g.useMemo(()=>E.filter(ae=>ae.type!=="session"||bi(ae.session,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,E,rt]),Qt=g.useMemo(()=>Ve.filter(ae=>!sl(ae)).slice(0,Math.max(Cn,a)),[a,Ve]),Lt=g.useMemo(()=>s3(Qt,ae=>{if(Il(ae))return{key:"draft",label:"Drafts",projectId:null,project:null,kind:"draft"};const Ke=Z[ae.id],ze=sn(ae)??"No project";return{key:Ke?`project:${Ke}`:`projectless:${ze}`,label:ze,projectId:Ke??null,project:Ke?oe.get(Ke)??null:null,kind:Ke?"project":"projectless"}}),[X,oe,Z,Qt]),An=Qt.length<Ve.length,Sn=Qt.length>Cn,nn=g.useMemo(()=>new Set(Lt.filter(ae=>ae.sessions.some(Ke=>Ke.id===B||G.has(Ke.id))).map(ae=>ae.key)),[Lt,G,B]),bt=Ne.filter(ae=>!sl(ae)).map(ae=>ae.id),rn=Qt.map(ae=>ae.id),Nt=JSON.stringify(Object.entries(r).filter(([ae,Ke])=>Ke.length>0&&(ue.get(ae)?.activeCount??0)>0).flatMap(([ae,Ke])=>Ke.map(ze=>[ae,ze.id])).sort(([ae,Ke],[ze,Ze])=>ae.localeCompare(ze)||Ke.localeCompare(Ze)));g.useEffect(()=>{const ae=JSON.parse(Nt);if(ae.length===0)return;const Ke=new Set(ae.map(([ze])=>ze));p(ze=>[...Ke].every(Ze=>ze.has(Ze))?ze:new Set([...ze,...Ke]))},[Nt]);function yt(ae){return c5(ge[J1({kind:"session",id:ae})])}function sn(ae){if(Il(ae))return"Draft";const Ke=Z[ae.id];return Ke?X.get(Ke)??ae.workspaceName??"Project":G4(ae)}function Ut(ae){ln({kind:"chat",sessionId:ae.id}),Ie(ae.id);const Ke=Z[ae.id]??null;de(Ke?null:ae.appId),te(Ke),xe("chat")}function mn(ae){return(r[ae.id]??[]).filter(Ke=>bi(Ke,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))}function On(ae,Ke){return Be.has(ae.id)||Ke.some(ze=>ze.id===B)}function gn(ae){p(Ke=>{const ze=new Set(Ke);return ze.has(ae)?ze.delete(ae):ze.add(ae),ze})}function Da(ae){const Ke=mn(ae);return Ke.length===0||!On(ae,Ke)?null:x.jsx("div",{className:"sidebar-child-session-group",children:Ke.map(ze=>x.jsx(op,{session:ze,selected:Se==="chat"&&B===ze.id,hideIcon:!0,nested:!0,running:G.has(ze.id),goalRuntime:b.get(ze.id)??null,subagentRuntime:ue.get(ze.id)??null,terminalIndicator:yt(ze.id),projectLabel:sn(ae),onSelect:()=>Ut(ze),onTogglePin:()=>ke(ze),onToggleSaveForLater:()=>qe(ze),onDockRight:()=>u(ze),onArchive:()=>ze.archived?O(ze):t(ze),onRename:$},ze.id))})}function ia(ae,Ke){if(typeof window>"u")return;const ze=sl(ae)?sn(ae):null;re({descriptionId:`sidebar-task-detail-${ae.id}`,sessionId:ae.id,title:ae.title,updatedAt:ae.updatedAt,folderName:ze,style:X5(Ke.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight},!!ze)})}function qt(ae,Ke={}){const ze=ae.archived,Ze=be===ae.id,xt=mn(ae),gt="sidebar-session-group",lt=H==="manual"?{onDragStart:Ct=>Ae(Ct,{allSessionIds:bt,visibleSessionIds:rn,sessionId:ae.id}),onDragEnd:ie,onDragOver:Ct=>{Ze||j(Ct,ae.id)},onDrop:Ct=>{Ze?m():l(Ct,ae.id)}}:{};return x.jsxs("div",{className:gt,onPointerEnter:Ct=>ia(ae,Ct.currentTarget),onPointerLeave:()=>re(null),onFocusCapture:Ct=>ia(ae,Ct.currentTarget),onBlurCapture:Ct=>{Ct.currentTarget.contains(Ct.relatedTarget)||re(null)},children:[x.jsx(op,{session:ae,selected:!ze&&Se==="chat"&&B===ae.id,archived:ze,hideIcon:!0,placeholder:Ze,running:G.has(ae.id),goalRuntime:b.get(ae.id)??null,subagentRuntime:ue.get(ae.id)??null,terminalIndicator:yt(ae.id),projectLabel:Ke.projectLabel===void 0?sn(ae):Ke.projectLabel,metadataPresentation:Ke.metadataPresentation,ariaDescribedBy:le?.sessionId===ae.id?le.descriptionId:void 0,childSessionCount:xt.length,childSessionsExpanded:On(ae,xt),onToggleChildSessions:()=>gn(ae.id),onSelect:()=>{re(null),ze&&O(ae),Ut(ae)},onTogglePin:()=>ke(ae),onToggleSaveForLater:()=>qe(ae),onDockRight:()=>u(ae),onArchive:()=>ze?O(ae):t(ae),onRename:$,...lt}),Ze?null:Da(ae)]},ae.id)}function qn(ae){ae!=="tasksets"&&Me(null),M(ae),N(Cn)}function ot(ae){Me(ae),M("tasksets"),N(Cn)}function xn(ae){Q(ae),N(Cn)}function La(){N(ae=>r3(ae,Ve.length))}function Ua(){N(ae=>i3(ae,Ve.length))}function sa(ae){const Ke={id:ae.id,type:ae.type};return{onDragStart:ze=>he(ze,Ke),onDragEnd:Fe,onDragOver:ze=>P(ze,Ke),onDrop:ze=>{De?.id===ae.id&&De.type===ae.type?Le():st(ze,Ke)}}}function za(ae){const Ke=sa(ae),ze=De?.id===ae.id&&De.type===ae.type;if(ae.type==="project"){const xt=ae.item;return x.jsx(j5,{kind:xt.kind,project:xt.project,pinned:!0,selected:Se==="chat"&&z===xt.id,expanded:!1,disclosure:!1,placeholder:ze,onSelect:()=>{de(null),te(xt.id),Ie(null),xe("chat")},onNewChat:()=>s(xt.id),onTogglePin:()=>Oe(xt),onRemove:()=>we(xt),...Ke},ae.key)}if(ae.type==="file")return x.jsx(E5,{file:ae.file,placeholder:ze,onSelect:()=>w(ae.file),onTogglePin:()=>Ge(ae.file,"none"),onToggleSaveForLater:()=>Ge(ae.file,"saved_for_later"),...Ke},ae.key);const Ze=ae.session;return x.jsx("div",{onPointerEnter:xt=>ia(Ze,xt.currentTarget),onPointerLeave:()=>re(null),onFocusCapture:xt=>ia(Ze,xt.currentTarget),onBlurCapture:xt=>{xt.currentTarget.contains(xt.relatedTarget)||re(null)},children:x.jsx(op,{ariaDescribedBy:le?.sessionId===Ze.id?le.descriptionId:void 0,session:Ze,selected:Se==="chat"&&B===Ze.id,hideIcon:!0,placeholder:ze,running:G.has(Ze.id),goalRuntime:b.get(Ze.id)??null,subagentRuntime:ue.get(Ze.id)??null,terminalIndicator:yt(Ze.id),projectLabel:sn(Ze),metadataPresentation:"flyout",onSelect:()=>{re(null),Ut(Ze)},onTogglePin:()=>ke(Ze),onToggleSaveForLater:()=>qe(Ze),onDockRight:()=>u(Ze),onArchive:()=>t(Ze),onRename:$,...Ke})},ae.key)}return x.jsxs("div",{className:"sidebar-scroll",children:[x.jsxs(ay,{label:I,className:`sidebar-task-section${h!=="chat"?" development":""}`,titleAccessory:h!=="chat"?x.jsx("div",{className:"sidebar-task-mode-buttons",children:x.jsxs("button",{type:"button",className:`section-icon sidebar-task-count-bubble${D==="saved_for_later"?" active":""}`,"aria-label":`Show ${Ee.count} ${Ee.targetLabel} ${Ee.count===1?"task":"tasks"}`,onClick:()=>qn(Ee.targetFilter),children:[x.jsx("span",{children:Ee.label}),x.jsx("span",{className:"sidebar-task-count-badge","aria-hidden":"true",children:Ee.count>99?"99+":Ee.count})]})}):null,actionsVisible:A==="chats"||A==="tasks-filter",actions:x.jsx(J5,{filter:D,groupByProject:me,noun:F,onFilterChange:qn,onGroupByProjectChange:_e,onOnlyRunningTasksChange:ae=>{Xe(Ke=>{const ze={...Ke,onlyRunningTasks:ae};return ny(ze),ze}),N(Cn)},onShowCodexChatsChange:ae=>{Xe(Ke=>{const ze={...Ke,showCodexChats:ae};return ny(ze),ze}),N(Cn)},onTasksetChange:ot,onSortChange:xn,onlyRunningTasks:et,openMenu:A,setOpenMenu:K,showCodexChats:rt,sort:H,selectedTasksetId:it,tasksets:Ue}),children:[ut.length>0?x.jsx(ay,{label:"Pinned",className:"sidebar-pinned-section",collapsed:_,onToggleCollapsed:Qe,children:ut.map(za)}):null,me&&h!=="chat"?Lt.map(ae=>{const Ke=nn.has(ae.key)||U.get(ae.key)!==!1;return x.jsx(t3,{expanded:Ke,groupKey:ae.key,kind:ae.kind,label:ae.label,onToggle:()=>{V(ze=>{const Ze=new Map(ze);return Ze.set(ae.key,!Ke),Ze})},onNewTask:ae.project?()=>s(ae.project.id):void 0,onOpenProject:ae.project?()=>{de(null),te(ae.project.id),Ie(null),xe("chat")}:void 0,onRemoveProject:ae.project?()=>we(ae.project):void 0,project:ae.project,children:ae.sessions.map(ze=>qt(ze,{metadataPresentation:"flyout",projectLabel:ae.label}))},ae.key)}):Qt.map(ae=>qt(ae)),Ve.length===0?x.jsx("div",{className:"empty-row",children:n5(D,F)}):null,Ve.length>Cn&&(An||Sn)?x.jsxs("div",{className:"sidebar-pagination-controls","aria-label":`Showing ${Qt.length} of ${Ve.length} ${F}`,children:[An?x.jsx(oy,{onClick:La,children:"Show more"}):null,Sn?x.jsx(oy,{onClick:Ua,children:"Show less"}):null]}):null]}),x.jsx(e3,{detail:le,onClose:()=>re(null)})]})}const c3="/";function Jn(e){return`${c3}${e.replace(/^\.?\//,"")}`}const d3=Jn("openpond-icon.png"),u3=Jn("openpond-wordlogo-white.png"),fJ=Jn("tutorials/what-is-an-openpond-agent-poster.png"),hJ=Jn("tutorials/what-is-an-openpond-agent.vtt"),gJ=Jn("tutorials/how-to-make-an-agent-poster.png"),vJ=Jn("tutorials/how-to-make-an-agent.vtt");function bJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}-poster.png`)}function yJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}.vtt`)}const ry={github:Jn("connected-apps/github.svg"),google:Jn("connected-apps/google.svg"),microsoft_teams:Jn("connected-apps/microsoft.svg"),mcp:Jn("connected-apps/openpond-mcp.svg"),slack:Jn("connected-apps/slack.svg"),x:Jn("connected-apps/x.svg")};function SJ(e){return ry[e]??ry.mcp}function m3({value:e,onChange:t}){const[n,a]=g.useState(!1),r=g.useRef(null),i=g.useRef(null),s=g.useRef(null),l=g.useRef(null),m=Xm.find(y=>y.value===e)??Xm[0];g.useEffect(()=>{if(!n)return;const y=_=>{_.target instanceof Node&&!r.current?.contains(_.target)&&a(!1)},w=()=>a(!1);return window.addEventListener("pointerdown",y),window.addEventListener("blur",w),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("blur",w)}},[n]),g.useLayoutEffect(()=>{n&&l.current&&iy(s.current,l.current),l.current=null},[n]);const u=y=>{if(n){iy(s.current,y);return}l.current=y,a(!0)},h=y=>{y.key==="ArrowDown"?(y.preventDefault(),u("first")):y.key==="ArrowUp"&&(y.preventDefault(),u("last"))},b=y=>{const w=nI(s.current),_=w.findIndex(P=>P===document.activeElement);if(y.key==="Escape"){y.preventDefault(),a(!1),i.current?.focus();return}if(y.key==="Home"||y.key==="End"){y.preventDefault(),w[y.key==="Home"?0:w.length-1]?.focus();return}if(y.key!=="ArrowDown"&&y.key!=="ArrowUp")return;y.preventDefault();const E=y.key==="ArrowDown"?1:-1,j=_<0?0:(_+E+w.length)%w.length;w[j]?.focus()};return x.jsxs("div",{className:"sidebar-experience-menu",ref:r,children:[x.jsxs("button",{ref:i,type:"button",className:"sidebar-wordmark-button sidebar-experience-trigger","aria-label":`OpenPond product: ${m.label}`,"aria-haspopup":"menu","aria-expanded":n,onClick:()=>{l.current=null,a(y=>!y)},onKeyDown:h,children:[x.jsx("img",{className:"sidebar-wordmark",src:u3,alt:""}),x.jsx("span",{className:"sidebar-experience-label",children:m.label}),x.jsx(zo,{size:13,"aria-hidden":"true"})]}),n?x.jsx("div",{ref:s,className:"sidebar-experience-popover",role:"menu","aria-label":"Choose product",onKeyDown:b,children:Xm.map(y=>{const w=y.value===e;return x.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w,className:w?"active":"","data-product-area":y.value,onClick:()=>{a(!1),w||t(y.value)},children:[x.jsxs("span",{children:[x.jsx("strong",{children:y.label}),x.jsx("small",{children:y.description})]}),w?x.jsx(wo,{size:14,"aria-hidden":"true"}):null]},y.value)})}):null]})}function nI(e){return e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[]}function iy(e,t){const n=nI(e);(t==="first"?n[0]:n.at(-1))?.focus()}function p3(...e){for(const t of e){const n=t?.trim();if(n)return n}return null}function f3(e){const t=e?.accounts.find(s=>s.isActive)??null,n=e?.profile??null,a=e?.activeProfile?.handle??null;return{label:(e?.state==="signed_in"?p3(e?.label,n?.handle,n?.name,n?.email,t?.displayLabel,t?.handle,a,e?.email,"Signed in"):e?.state==="loading"||e?.state==="switching"?"Loading account":"Sign in")??"Account",image:e?.avatarUrl??n?.image??t?.avatarUrl??null}}function h3({account:e,open:t,organizations:n,selectedTeamId:a,onOpenActivity:r,onOpenChange:i,onOpenSettings:s,onSelectTeam:l,onLogOut:m}){const[u,h]=g.useState(null),[b,y]=g.useState(!1),w=g.useRef(null),_=g.useMemo(()=>f3(e),[e]),E=_.label.trim().slice(0,1).toUpperCase(),j=n.find(P=>P.teamId===a)??n[0]??null;return g.useEffect(()=>{if(!t)return;function P($){w.current?.contains($.target)||i(!1)}function L($){$.key==="Escape"&&i(!1)}return document.addEventListener("pointerdown",P),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",L)}},[i,t]),x.jsxs("div",{className:"user-auth-footer",ref:w,children:[x.jsxs("button",{type:"button",className:`user-auth-trigger ${t?"active":""}`,"aria-haspopup":"menu","aria-expanded":t,"aria-label":`${_.label} account menu`,onClick:()=>i(!t),children:[x.jsx("span",{className:"user-auth-avatar","aria-hidden":"true",children:_.image?x.jsx("img",{src:_.image,alt:""}):E?x.jsx("span",{children:E}):x.jsx(Bb,{size:16})}),x.jsx("span",{className:"user-auth-name",children:_.label})]}),t?x.jsxs("div",{className:"user-auth-menu",role:"menu","aria-label":"Account",children:[x.jsxs("div",{className:"user-auth-menu-header",children:[x.jsx("span",{className:"user-auth-menu-avatar","aria-hidden":"true",children:_.image?x.jsx("img",{src:_.image,alt:""}):E?x.jsx("span",{children:E}):x.jsx(Bb,{size:17})}),x.jsx("span",{className:"user-auth-menu-identity",children:x.jsx("strong",{children:_.label})})]}),n.length>0&&l?x.jsxs("label",{className:"user-auth-team-picker",children:[x.jsx(P1,{size:15,"aria-hidden":"true"}),x.jsx("span",{className:"user-auth-team-picker-label",children:"Team"}),x.jsx("select",{"aria-label":"Active team",disabled:u!==null,value:j?.teamId??"",onChange:async P=>{const L=P.currentTarget.value;h(L);try{await l(L)}catch{}finally{h(null)}},children:n.map(P=>x.jsx("option",{value:P.teamId,children:P.displayName},P.teamId))})]}):null,x.jsx("div",{className:"user-auth-menu-divider"}),r?x.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),r()},children:[x.jsx(w1,{size:15}),x.jsx("span",{children:"Activity"})]}):null,x.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),s()},children:[x.jsx(og,{size:15}),x.jsx("span",{children:"Settings"})]}),e?.state==="signed_in"&&m?x.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",disabled:b,onClick:async()=>{y(!0);try{await m(),i(!1)}catch{}finally{y(!1)}},children:[x.jsx(l4,{size:15}),x.jsx("span",{children:b?"Logging out…":"Log out"})]}):null]}):null]})}function sy(e){const t=/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e?.trim()??"");return t?[Number.parseInt(t[1],10),Number.parseInt(t[2],10),Number.parseInt(t[3],10)]:null}function g3(e,t){const n=sy(e),a=sy(t);if(!n||!a)return!1;for(let r=0;r<a.length;r+=1){if(a[r]>n[r])return!0;if(a[r]<n[r])return!1}return!1}function aI(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")?"mac":t==="linux"||t.includes("linux")?"linux":null}function v3(e){const t=e?.toLowerCase()??"";return t==="arm64"||t==="aarch64"?"arm64":t==="x64"||t==="x86_64"||t==="amd64"?"x64":null}function b3(e,t,n){const a=aI(t),r=v3(n);if(a==="mac"){const i=e.filter(s=>/-mac-.*\.zip$/i.test(s.name));return r==="arm64"?i.find(s=>/-mac-arm64\.zip$/i.test(s.name))??null:r==="x64"?i.find(s=>/-mac-x64\.zip$/i.test(s.name))??i.find(s=>/-mac-universal\.zip$/i.test(s.name))??null:i.find(s=>/-mac-universal\.zip$/i.test(s.name))??i.find(s=>/-mac-arm64\.zip$/i.test(s.name))??i[0]??null}if(a==="linux"){const i=e.filter(s=>/\.AppImage$/i.test(s.name));return r==="arm64"?i.find(s=>/(?:arm64|aarch64).*\.AppImage$/i.test(s.name))??null:r==="x64"?i.find(s=>/(?:x86_64|x64|amd64).*\.AppImage$/i.test(s.name))??i[0]??null:i[0]??null}return null}function y3(e){if(!e.payload||typeof e.payload!="object")return null;const t=e.payload,a=(typeof t.tag_name=="string"?t.tag_name.trim():"").replace(/^v/,"");if(!g3(e.currentVersion,a))return null;const r=typeof t.html_url=="string"?t.html_url:"",s=(Array.isArray(t.assets)?t.assets:[]).flatMap(m=>{if(!m||typeof m!="object")return[];const u=m;return typeof u.name!="string"||typeof u.browser_download_url!="string"?[]:[{name:u.name,downloadUrl:u.browser_download_url}]}),l=b3(s,e.platform,e.arch);return!l||!r?null:{version:a,releaseUrl:r,assetName:l.name,downloadUrl:l.downloadUrl}}const S3=3600*1e3,x3="https://api.github.com/repos/openpond/openpond/releases/latest";function k3(e){const[t,n]=g.useState({status:"idle",update:null,lastCheckedAt:null}),a=e.currentVersion?.trim()??"",r=e.platform??"",i=e.arch??"",s=e.enabled&&!!a&&!!aI(r);return g.useEffect(()=>{if(!s){n({status:"idle",update:null,lastCheckedAt:null});return}let l=!1;async function m(){n(h=>({...h,status:h.update?"available":"checking"}));try{const h=await fetch(x3,{headers:{Accept:"application/vnd.github+json"}});if(!h.ok)throw new Error(`GitHub release check failed: ${h.status}`);const b=await h.json(),y=y3({payload:b,currentVersion:a,platform:r,arch:i});if(l)return;n({status:y?"available":"current",update:y,lastCheckedAt:Date.now()})}catch{if(l)return;n(h=>({status:h.update?"available":"error",update:h.update,lastCheckedAt:Date.now()}))}}m();const u=window.setInterval(()=>{m()},S3);return()=>{l=!0,window.clearInterval(u)}},[i,a,s,r]),t}const oI="openpond.sidebar.continuous-learning.dismissed.v1";function ly(e=rI()){if(!e)return!1;try{return e.getItem(oI)==="true"}catch{return!1}}function w3(e=rI()){if(e)try{e.setItem(oI,"true")}catch{}}function rI(){return typeof window>"u"?null:Wl}function I3({connection:e,onOpenSettings:t}){const[n,a]=g.useState(null),[r,i]=g.useState(ly);Kl(()=>i(ly()));const s=g.useCallback(async()=>{if(!e){a(null);return}try{a(await J.harnessHistory(e))}catch{a(null)}},[e]);if(g.useEffect(()=>{s()},[s]),r||!e||!n?.workspace)return null;const l=n.evaluationReviewSchedule,m=l.activityEnabled?`${l.activityBatchSize} outcomes${l.enabled?` + ${l.cadence}`:""}`:l.enabled?l.cadence:"Manual";return x.jsxs("section",{className:"sidebar-learning-notice","aria-label":"Continuous learning",children:[x.jsxs("header",{children:[x.jsx("strong",{children:"Continuous learning"}),x.jsxs("div",{className:"sidebar-learning-notice-actions",children:[x.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Open Continuous learning settings",onClick:t,type:"button",children:x.jsx(og,{size:14})}),x.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Close continuous learning",onClick:()=>{i(!0),w3()},type:"button",children:x.jsx(os,{size:14})})]})]}),x.jsxs("div",{className:"sidebar-learning-status",children:[x.jsx("strong",{children:"Refiner"}),x.jsx("span",{children:n.backgroundReview.enabled?"On":"Off"})]}),x.jsxs("div",{className:"sidebar-learning-status",children:[x.jsx("strong",{children:"Continuous Review"}),x.jsx("span",{children:m})]})]})}function _3(e){const[t,n]=g.useState(!1),{beginNewChat:a,arch:r,currentVersion:i,experience:s,productArea:l,onProductAreaChange:m,onSidebarResizeStart:u,platform:h,setSectionMenuOpen:b,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setSidebarOpen:E,setView:j,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}=e,O=g.useCallback(z=>{n(!1),b(z)},[b]),k=g.useCallback(z=>{n(z),z&&b(null)},[b]),C=k3({currentVersion:i,platform:h,arch:r,enabled:eu()}),A=C.status==="available"?C.update:null;return x.jsxs("aside",{className:"sidebar",children:[x.jsxs("div",{className:"sidebar-toolbar",children:[x.jsx("button",{className:"sidebar-icon","aria-label":"Hide sidebar",onClick:()=>E(!1),children:x.jsx(R1,{size:16})}),x.jsx(m3,{value:l,onChange:m}),A&&x.jsxs("button",{type:"button",className:"sidebar-update-pill",title:`Download OpenPond ${A.version}: ${A.assetName}`,"aria-label":`Download OpenPond ${A.version}`,onClick:()=>{C3(A.downloadUrl)},children:[x.jsx(jF,{size:14}),x.jsx("span",{children:"Update"})]})]}),x.jsx(j4,{productArea:l,experience:s,beginNewChat:a,setSectionMenuOpen:O,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:j,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}),l==="models"?null:x.jsx(l3,{...e,setSectionMenuOpen:O}),x.jsxs("div",{className:"sidebar-bottom-stack",children:[l==="models"?null:x.jsx(I3,{connection:e.connection,onOpenSettings:()=>{b(null),ln({kind:"settings",section:"harness"})}}),x.jsxs("div",{className:"sidebar-footer-row",children:[x.jsx(h3,{account:e.account,open:t,organizations:e.organizations,selectedTeamId:e.teamChatOrganization?.teamId??null,onOpenChange:k,onOpenActivity:()=>{b(null),ln({kind:"settings",section:"usage"})},onOpenSettings:()=>{b(null),ln({kind:"settings",section:"account"})},onSelectTeam:e.onSelectTeam,onLogOut:e.onLogOut}),x.jsx(O4,{setSectionMenuOpen:O,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:j,view:P})]})]}),x.jsx("div",{className:"sidebar-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:u})]})}async function C3(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-update",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const R3=[/^(?:(?:type)?error:\s*)?failed to fetch\.?$/i,/^networkerror when attempting to fetch resource\.?$/i,/^load failed\.?$/i];function iI(e,t="Something went wrong."){const a=(e instanceof Error?e.message:String(e??"")).trim();return a?sI(a)?"Couldn’t connect to OpenPond.":a:t}function sI(e){const t=e.trim();return R3.some(n=>n.test(t))}const lI=g.createContext(null);function cy({children:e,showToast:t}){return x.jsx(lI.Provider,{value:t,children:e})}function P3(){return g.useContext(lI)}function dy(e,t={}){const n=P3(),a=g.useRef(null),r=t.enabled??!0,i=t.fallback??"Something went wrong.",s=t.prefix?.trim()??"",l=e==null||e===""?null:`${s}${s?": ":""}${iI(e,i)}`;g.useEffect(()=>{if(!r||!l){a.current=null;return}a.current!==l&&(a.current=l,n?.(l,"error",{dismissible:!0}))},[r,l,n])}function A3({state:e,onClose:t,onOpenBrowserUrl:n,onStart:a}){if(dy(e?.previewError,{prefix:"Upload preview"}),dy(e?.error,{prefix:"Cloud setup"}),!e)return null;const r=e.status==="uploading",i=e.status==="ready",s=e.status==="error",l=e.projectKind==="cloud",m=e.preview??null;return x.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:x.jsxs("section",{className:"git-dialog cloud-setup-dialog",role:"dialog","aria-modal":"true","aria-label":"Set up Cloud coding",children:[x.jsx("button",{className:"git-dialog-close",disabled:r,type:"button",onClick:t,"aria-label":"Close Cloud setup",title:"Close",children:x.jsx(os,{size:14})}),x.jsx("div",{className:"git-dialog-icon",children:i?x.jsx(tf,{size:18}):x.jsx(Jd,{size:18})}),x.jsx("h2",{children:i?"Cloud repo ready":"Set up Cloud coding"}),x.jsx("p",{children:i?"Your source is ready in OpenPond Git. Finish by creating the Cloud sandbox environment.":l?"This Cloud Project is ready for a sandbox environment.":"OpenPond will upload tracked and unignored files into OpenPond Git, then send you to the Cloud sandbox setup page."}),x.jsxs("div",{className:"cloud-setup-summary",children:[x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Project"}),x.jsx("strong",{children:e.projectName})]}),x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Source"}),x.jsx("strong",{children:l?"OpenPond Git":"Local project upload"})]}),x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Branch"}),x.jsx("strong",{children:m?.branch??e.branch??"main"})]}),!l&&x.jsxs("div",{className:"git-dialog-row",children:[x.jsx("span",{children:"Cloud project"}),x.jsx("strong",{children:m?.targetProjectId??e.cloudProjectId??"New on upload"})]})]}),!i&&!l&&x.jsx("div",{className:"cloud-setup-upload-preview",role:"status","aria-live":"polite",children:e.previewLoading?x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Calculating upload preview"}),x.jsx("span",{children:"Checking tracked and unignored files before anything is pushed."})]}):e.previewError?x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Preview unavailable"}),x.jsx("span",{children:"Close and reopen setup to try the preview again."})]}):m?x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:m.initializedEmptyProject?"Will initialize an empty project":`Will upload ${m.fileCount} files`}),x.jsx("span",{children:uy({byteCount:m.byteCount,skippedCount:m.skippedCount,headCommit:m.headCommit,targetProjectName:m.targetProjectName})})]}):x.jsxs(x.Fragment,{children:[x.jsx("strong",{children:"Upload preview pending"}),x.jsx("span",{children:"File count, byte count, and skipped files will appear here before upload."})]})}),r&&x.jsxs("div",{className:"cloud-setup-progress",role:"status","aria-live":"polite",children:[x.jsx(JF,{className:"cloud-setup-spinner",size:16}),x.jsx("span",{children:"Uploading source to OpenPond Git..."})]}),i&&e.upload&&x.jsxs("div",{className:"cloud-setup-upload-result",children:[x.jsx("strong",{children:e.upload.initializedEmptyProject?"Initialized empty project":`Uploaded ${e.upload.fileCount} files`}),x.jsx("span",{children:uy({byteCount:e.upload.byteCount,skippedCount:e.upload.skippedCount,headCommit:e.upload.headCommit,targetProjectName:e.upload.branch})})]}),i&&e.setupUrl&&x.jsxs("div",{className:"cloud-setup-next",children:[e.projectUrl?x.jsxs("span",{children:["Your repo is ready here:"," ",x.jsxs("a",{href:e.projectUrl,target:"_blank",rel:"noreferrer",onClick:u=>rp(u,e.projectUrl,n,{newTab:!0}),children:["Project page",x.jsx(Ym,{size:13})]})]}):x.jsx("span",{children:"Your repo is ready. Next step:"}),x.jsxs("a",{href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>rp(u,e.setupUrl,n),children:["Setup the Cloud sandbox",x.jsx(Ym,{size:13})]})]}),x.jsxs("div",{className:"git-dialog-footer",children:[x.jsx("button",{className:"git-dialog-secondary",disabled:r,type:"button",onClick:t,children:i?"Done":"Cancel"}),i?e.setupUrl?x.jsxs("a",{className:"git-dialog-primary cloud-setup-primary-link",href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>rp(u,e.setupUrl,n),children:["Open setup",x.jsx(Ym,{size:13})]}):null:x.jsx("button",{className:"git-dialog-primary",disabled:r,type:"button",onClick:a,children:r?"Uploading":s?"Try again":l?"Show setup link":"Upload source"})]})]})})}function rp(e,t,n,a={}){!t||!n||(e.preventDefault(),n(t,a))}function T3(e){return!Number.isFinite(e)||e<=0?"0 B":e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function uy({byteCount:e,skippedCount:t,headCommit:n,targetProjectName:a}){const r=[T3(e),`${t} skipped`],i=E3(n);return i&&r.push(`local ${i}`),r.push(a),r.join(" · ")}function E3(e){const t=e?.trim();return t?t.slice(0,7):null}const M3=g.lazy(()=>Nr(()=>import("./CommandMenu-Deqzk3u9.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(e=>({default:e.CommandMenu}))),j3=g.lazy(()=>Nr(()=>import("./SettingsView-BIwO8elm.js"),__vite__mapDeps([4,1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]),import.meta.url).then(e=>({default:e.SettingsView}))),O3=g.lazy(()=>Nr(()=>import("./NewProjectDialog-B-7dHoT6.js"),__vite__mapDeps([26,1,2,8,15]),import.meta.url).then(e=>({default:e.NewProjectDialog}))),$3=g.lazy(()=>Nr(()=>import("./WorkspaceGitDialogs-BC45mifk.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.CommitDialog}))),N3=g.lazy(()=>Nr(()=>import("./WorkspaceGitDialogs-BC45mifk.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.BranchDialog})));function D3({payload:e,connection:t,diagnostics:n,initialSection:a,onPayload:r,onError:i,onToast:s,onBack:l,onOpenSourceSession:m,onStartRefinerAuthoring:u,onAcceptEvaluationReview:h,onOpenSkill:b,onOpenExtension:y,teamChatCurrentUserId:w,teamChatEnabled:_,teamChatNotificationMode:E,teamChatThreads:j,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:O,diffPanelExpanded:k,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A}){return x.jsx(g.Suspense,{fallback:null,children:x.jsx(j3,{payload:e,connection:t,diagnostics:n,initialSection:a,onPayload:r,onError:i,onToast:s,onBack:l,onOpenSourceSession:m,onStartRefinerAuthoring:u,onAcceptEvaluationReview:h,onOpenSkill:b,onOpenExtension:y,teamChatCurrentUserId:w,teamChatEnabled:_,teamChatNotificationMode:E,teamChatThreads:j,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:O,diffPanelExpanded:k,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A})})}function L3({activeSessions:e,branchDialogName:t,branchDialogOpen:n,commitDialogOpen:a,commitDraft:r,commitIncludeUnstaged:i,commitMessage:s,commitNextStep:l,canPublishOpenPondProject:m,expandProject:u,newProjectBusy:h,newProjectDialogOpen:b,newProjectDirectory:y,newProjectMode:w,newProjectName:_,newProjectPath:E,projectRows:j,query:P,searchOpen:L,visibleWorkspaceDiff:$,visibleWorkspaceState:O,workspaceBusy:k,appDispatch:C,beginNewChat:A,openDefaultsSettingsFromBranchDialog:z,setBranchDialogName:B,setBranchDialogOpen:N,setCommitDialogOpen:K,setCommitDraft:de,setCommitIncludeUnstaged:te,setCommitMessage:Ie,setCommitNextStep:xe,setNewProjectDialogOpen:Z,setNewProjectName:Ae,setNewProjectPath:he,setQuery:ue,setSearchOpen:be,submitCommitDialog:ne,submitCreateWorkspaceBranch:ge,submitNewProjectDialog:ke}){return x.jsxs(x.Fragment,{children:[L&&x.jsx(g.Suspense,{fallback:null,children:x.jsx(M3,{open:L,query:P,projects:j,sessions:e,onQueryChange:ue,onClose:()=>{be(!1),ue("")},onNewChat:()=>{be(!1),ue(""),A()},onOpenProject:qe=>{C({type:"selectProject",projectId:qe.id}),C({type:"patch",patch:{searchOpen:!1,query:""}}),u(qe.id)},onOpenSession:qe=>{C({type:"selectSession",sessionId:qe.id,appId:qe.appId,projectId:qe.workspaceKind==="local_project"&&qe.workspaceId?vt("local",qe.workspaceId):null}),C({type:"patch",patch:{searchOpen:!1,query:""}})}})}),b&&x.jsx(g.Suspense,{fallback:null,children:x.jsx(O3,{open:b,mode:w,name:_,path:E,directory:y,busy:h,onNameChange:Ae,onPathChange:he,onClose:()=>{h||Z(!1)},onSubmit:ke})}),a&&x.jsx(g.Suspense,{fallback:null,children:x.jsx($3,{open:a,branch:O?.currentBranch??null,filesChanged:$?.filesChanged??O?.changedFilesCount??0,additions:$?.additions??0,deletions:$?.deletions??0,message:s,includeUnstaged:i,nextStep:l,draft:r,busy:k,canPush:!!O?.remoteUrl,canPublish:m,onMessageChange:Ie,onIncludeUnstagedChange:te,onNextStepChange:xe,onDraftChange:de,onClose:()=>{k||K(!1)},onSubmit:ne})}),n&&x.jsx(g.Suspense,{fallback:null,children:x.jsx(N3,{open:n,branchName:t,busy:k,onBranchNameChange:B,onSetPrefix:z,onClose:()=>{k||N(!1)},onSubmit:ge})})]})}function cI({toast:e,onDismiss:t}){if(!e)return null;const n=!!(e.actionLabel&&e.onAction),a=!!(e.persistent||e.dismissible);return x.jsxs("div",{className:`app-toast ${e.tone} ${e.placement??"bottom-right"}`,role:e.tone==="error"?"alert":"status","aria-live":"polite",children:[x.jsx("span",{className:"app-toast-message",children:e.message}),(n||a)&&x.jsxs("div",{className:"app-toast-actions",children:[n&&x.jsx("button",{type:"button",className:e.actionIcon?"app-toast-icon-action":void 0,"aria-label":e.actionLabel,title:e.actionIcon?e.actionLabel:void 0,onClick:()=>{t(),e.onAction?.()},children:e.actionIcon==="settings"?x.jsx(og,{size:15}):e.actionLabel}),a&&x.jsx("button",{type:"button",className:"app-toast-close","aria-label":"Dismiss notification",onClick:t,children:x.jsx(os,{size:14})})]})]})}const Gl=g.createContext(null);function U3({children:e}){const[t,n]=g.useState(null),[a,r]=g.useState(null),i=g.useMemo(()=>({title:t,actions:a,setTitle:n,setActions:r}),[t,a]);return x.jsx(Gl.Provider,{value:i,children:e})}function xJ({children:e}){return x.jsx(Gl.Provider,{value:null,children:e})}function z3({children:e,className:t=""}){const n=g.useContext(Gl);return x.jsx("div",{ref:n?.setTitle,className:`page-chrome-title-target ${t}`,children:e?x.jsx("div",{className:"page-chrome-fallback",children:e}):null})}function H3({className:e=""}){const t=g.useContext(Gl);return x.jsx("div",{ref:t?.setActions,className:e})}function kJ({title:e,actions:t,fallback:n,children:a}){const r=g.useContext(Gl);return r?x.jsxs(x.Fragment,{children:[r.title?pf.createPortal(x.jsx("div",{className:"page-chrome-title",children:e}),r.title):null,r.actions&&t?pf.createPortal(t,r.actions):null,a]}):n??x.jsxs("header",{children:[e,t]})}async function q3(e){if(!e)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard write failed",t)}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-1000px",t.style.top="-1000px",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return t.remove(),n}catch(t){return console.warn("Clipboard fallback failed",t),!1}}function B3({activeView:e,onDiscoverCommunities:t,onOpenTeamChat:n}){return x.jsxs("div",{className:"titlebar-collaboration-actions",children:[x.jsx("button",{type:"button",className:`titlebar-icon${e==="team"?" active":""}`,"aria-label":"Team chat",title:"Team chat",onClick:n,children:x.jsx(Yd,{size:16})}),x.jsx("button",{type:"button",className:`titlebar-icon${e==="community"?" active":""}`,"aria-label":"Discover communities",title:"Discover communities",onClick:t,children:x.jsx(C1,{size:16})})]})}const F3=g.lazy(()=>Nr(()=>import("./WorkspaceEnvironmentMenu-Dvqy2NJP.js"),__vite__mapDeps([29,1,2,21,10,14,5,30,28,31]),import.meta.url).then(e=>({default:e.WorkspaceEnvironmentMenu})));function V3({sidebarOpen:e,title:t,conversationId:n,breadcrumbs:a,backAction:r,workspaceName:i,workspaceId:s,busy:l,workspaceState:m,workspaceKind:u,selectedApp:h,selectedProject:b,workspaceDiff:y,managedWorkspace:w,workspaceBusy:_,defaultTeamId:E,showDiffControls:j,diffPanelOpen:P,terminalOpen:L,rightSidebarAvailable:$=!1,rightSidebarOpen:O=!1,onToggleDiffPanel:k,onToggleRightSidebar:C,onOpenSearch:A,onToggleTerminal:z,onRunTerminalCommand:B,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:xe,onOpenSandboxWorkspace:Z,onShowSidebar:Ae,onOpenTeamChat:he,onDiscoverCommunities:ue,collaborationView:be=null,platform:ne,showWorkspaceControls:ge=!0}){const ke=y?.filesChanged??0,qe=eu()&&!rg(ne),Se=!!(he||ue)||ge||$||qe,[ie,we]=g.useState(null);g.useEffect(()=>{if(!ie)return;const Ge=()=>we(null);return window.addEventListener("pointerdown",Ge),window.addEventListener("blur",Ge),window.addEventListener("resize",Ge),()=>{window.removeEventListener("pointerdown",Ge),window.removeEventListener("blur",Ge),window.removeEventListener("resize",Ge)}},[ie]);const Oe=Ge=>{Ge.preventDefault(),Ge.stopPropagation();const st=190,Le=n?76:42;we({x:Math.min(Ge.clientX,window.innerWidth-st-8),y:Math.min(Ge.clientY,window.innerHeight-Le-8)})},Qe=Ge=>{q3(Ge),we(null)};return x.jsxs("header",{className:"app-titlebar",children:[x.jsxs("div",{className:"titlebar-left",children:[!e&&x.jsx("button",{className:"titlebar-icon",title:"Show sidebar",onClick:Ae,children:x.jsx(R1,{size:16})}),r?x.jsx("button",{className:"titlebar-icon",type:"button","aria-label":r.label,title:r.label,onClick:r.onSelect,children:x.jsx(hF,{size:16})}):null,x.jsx(z3,{children:a?.length?x.jsx("nav",{className:"titlebar-breadcrumbs","aria-label":"Breadcrumb",children:a.map((Ge,st)=>{const Le=st===a.length-1;return x.jsxs("div",{className:"titlebar-breadcrumb-item",children:[Ge.onSelect&&!Le?x.jsx("button",{type:"button",onClick:Ge.onSelect,children:Ge.label}):x.jsx("strong",{children:Ge.label}),!Le&&x.jsx($r,{size:14})]},`${Ge.label}-${st}`)})}):x.jsxs("div",{className:"titlebar-title",children:[x.jsx("strong",{className:"titlebar-copy-target",title:"Double-click to select; right-click for copy options",onContextMenu:Oe,children:t}),i&&x.jsx("span",{children:i})]})})]}),Se&&x.jsxs("div",{className:"titlebar-right",children:[x.jsx(H3,{className:"page-chrome-actions"}),x.jsx(B3,{activeView:be,onDiscoverCommunities:ue,onOpenTeamChat:he}),ge&&x.jsxs("div",{className:"titlebar-actions",children:[x.jsx(g.Suspense,{fallback:null,children:x.jsx(F3,{mode:"topbar",busy:l,workspaceState:m,workspaceId:s,workspaceKind:u,selectedApp:h,selectedProject:b,workspaceBusy:_,defaultTeamId:E,workspaceDiff:y,managedWorkspace:w,showDiffControls:j,diffPanelOpen:P,onToggleDiffPanel:k,onRunTerminalCommand:B,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:xe,onOpenSandboxWorkspace:Z})}),x.jsx("button",{type:"button",className:"titlebar-icon",title:"Search chats and projects","aria-label":"Search chats and projects",onClick:A,children:x.jsx(d4,{size:16})}),x.jsx("button",{type:"button",className:`titlebar-icon ${L?"active":""}`,title:`${L?"Hide":"Show"} terminal`,"aria-label":`${L?"Hide":"Show"} terminal`,"aria-pressed":L,onClick:z,children:x.jsx(A1,{size:16})}),j&&x.jsx("button",{type:"button",className:`topbar-diff-button ${O?"active":""}`,title:`${O?"Hide":"Show"} sidebar${ke?`, ${ke} changed files`:""}`,"aria-label":`${O?"Hide":"Show"} sidebar`,"aria-pressed":O,onClick:k,children:x.jsx(nf,{size:16})})]}),$&&C&&!j?x.jsx("div",{className:"titlebar-actions",children:x.jsx("button",{type:"button",className:`topbar-diff-button ${O?"active":""}`,title:`${O?"Hide":"Show"} sidebar`,"aria-label":`${O?"Hide":"Show"} sidebar`,"aria-pressed":O,onClick:C,children:x.jsx(nf,{size:16})})}):null,x.jsx(y4,{platform:ne})]}),ie&&x.jsxs("div",{className:"titlebar-copy-menu",role:"menu","aria-label":"Conversation title actions",style:{left:ie.x,top:ie.y},onPointerDown:Ge=>Ge.stopPropagation(),children:[x.jsx("button",{type:"button",role:"menuitem",onClick:()=>Qe(t),children:"Copy title"}),n&&x.jsx("button",{type:"button",role:"menuitem",onClick:()=>Qe(n),children:"Copy conversation ID"})]})]})}function K3(){const[e,t]=g.useState(null),n=g.useRef(null),a=g.useCallback(i=>new Promise(s=>{n.current?.resolve(!1);const l={...i,cancelLabel:i.cancelLabel??"Cancel",tone:i.tone??"default",resolve:s};n.current=l,t(l)}),[]),r=g.useCallback(i=>{const s=n.current;n.current=null,t(null),s?.resolve(i)},[]);return{confirmAction:a,confirmDialog:e,resolveConfirmDialog:r}}function W3({state:e,onResolve:t}){const n=g.useId(),a=g.useId();if(g.useEffect(()=>{if(!e)return;function i(s){s.key==="Escape"&&t(!1)}return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t,e]),!e)return null;const r=e.tone==="danger"?"git-dialog-primary danger":"git-dialog-primary";return x.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:()=>t(!1),children:x.jsxs("section",{className:"git-dialog project-confirm-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":a,onMouseDown:i=>i.stopPropagation(),children:[x.jsx("h2",{id:n,children:e.title}),x.jsx("p",{id:a,children:e.body}),x.jsxs("div",{className:"git-dialog-footer",children:[x.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:()=>t(!1),children:e.cancelLabel}),x.jsx("button",{type:"button",className:r,autoFocus:!0,onClick:()=>t(!0),children:e.confirmLabel})]})]})})}function G3(){const{confirmAction:e,confirmDialog:t,resolveConfirmDialog:n}=K3();return{confirmProjectAction:g.useCallback(r=>e({tone:"danger",...r}),[e]),projectConfirmDialog:t,resolveProjectConfirmDialog:n}}function Z3({state:e,onResolve:t}){return x.jsx(W3,{state:e,onResolve:t})}const md=new Map,J3=(e,t,n)=>{const a=md.get(e)??{commits:0,maxActualDurationMs:0,totalActualDurationMs:0};a.commits+=1,a.maxActualDurationMs=Math.max(a.maxActualDurationMs,n),a.totalActualDurationMs+=n,md.set(e,a)};function Y3({children:e,id:t}){return x.jsx(g.Profiler,{id:t,onRender:J3,children:e})}typeof window<"u"&&(window.__OPENPOND_RENDER_COMMITS__={get:()=>Object.fromEntries([...md.entries()].map(([e,t])=>[e,{...t}])),reset:()=>md.clear()});const Q3=g.lazy(()=>Nr(()=>import("./MainPane-Dv5USGqR.js").then(e=>e.M),__vite__mapDeps([32,1,2,13,33,6,30]),import.meta.url).then(e=>({default:e.MainPane})));function X3({className:e,style:t,sidebar:n,topBar:a,mainPane:r,cloudSetup:i,projectConfirm:s,lazyPanels:l,toast:m}){return x.jsx(U3,{children:x.jsxs("div",{className:e,style:t,children:[x.jsx(Y3,{id:"sidebar",children:x.jsx(_3,{...n})}),x.jsxs("div",{className:"content-shell",children:[x.jsx(V3,{...a}),x.jsx(g.Suspense,{fallback:x.jsx("main",{className:"main-pane","aria-busy":"true","aria-label":"Loading workspace"}),children:x.jsx(Q3,{...r})})]}),x.jsx(A3,{...i}),x.jsx(Z3,{...s}),x.jsx(L3,{...l}),x.jsx(cI,{...m})]})})}function e6({settings:e,toast:t}){return x.jsxs(x.Fragment,{children:[x.jsx(D3,{...e}),x.jsx(cI,{...t})]})}const Fc="OpenPond".split("");function t6({visibleLetterCount:e=Fc.length}){const t=Fc.slice(0,Math.max(0,Math.min(e,Fc.length)));return x.jsxs("div",{className:"app-splash-lockup",children:[x.jsx("div",{className:"app-splash-mark",children:x.jsx("img",{alt:"OpenPond",className:"app-splash-logo",decoding:"async",src:d3})}),x.jsx("span",{"aria-hidden":"true",className:`app-splash-wordmark${t.length>0?" is-visible":""}`,children:t.map((n,a)=>x.jsx("span",{className:"app-splash-letter",children:n},`${n}-${a}`))})]})}const ip=Fc.length,n6=520,a6=240;function my(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function o6({startup:e}){const[t,n]=g.useState(()=>my()?ip:0);return g.useEffect(()=>{if(my()){n(ip);return}const a=Array.from({length:ip},(r,i)=>window.setTimeout(()=>n(i+1),n6+a6*i));return()=>{a.forEach(r=>window.clearTimeout(r))}},[]),x.jsxs("main",{className:"app-splash","aria-busy":"true","aria-label":e.label,role:"status",children:[x.jsx(t6,{visibleLetterCount:t}),x.jsx("span",{className:"app-splash-status",children:e.label})]})}const xg=5e3;function Co(e,t){if(e.length===0)return t;if(t.length===0)return e;const n=new Set,a=[];for(const r of[...e,...t])n.has(r.id)||(n.add(r.id),a.push(r));return a}function Io(e,t,n=xg){return Vc(Co(e,t),n)}function Vc(e,t=xg){return e.length<=t?e:e.slice(e.length-t)}function r6(e,t,n){return n.length===0?e:{...e,[t]:Co(e[t]??[],n)}}function i6(e,t){if(t.length===0)return Vc(e);if(e.length===0)return Vc(t);const n=new Map;let a=0;for(const r of[...e,...t])n.has(r.id)||n.set(r.id,{event:r,index:a}),a+=1;return Vc([...n.values()].sort((r,i)=>l6(r,i)).map(({event:r})=>r))}function pd(e){let t=null;for(const n of e)typeof n.sequence=="number"&&(t=t===null?n.sequence:Math.max(t,n.sequence));return t}function s6(e){let t=null;for(const n of e)n.sequence!==void 0&&(t===null||n.sequence<t)&&(t=n.sequence);return t}function l6(e,t){const n=e.event.sequence,a=t.event.sequence;if(typeof n=="number"&&typeof a=="number"){const s=n-a;if(s!==0)return s}const r=Date.parse(e.event.timestamp),i=Date.parse(t.event.timestamp);if(Number.isFinite(r)&&Number.isFinite(i)){const s=r-i;if(s!==0)return s}return e.index-t.index}function py(e){if(e<1e3)return String(e);const t=e/1e3;return t>=10||Number.isInteger(t)?`${Math.round(t)}k`:`${t.toFixed(1)}k`}function c6(e){return e===null?"unknown":e>=85?"high":e>=65?"medium":"low"}function fy(e,t){const n=e?.triggerPercent??85;return e?.autoEnabled===!1?t>=n?"Auto compaction is off. Start a new chat or turn it on before the provider limit is reached.":"Auto compaction is off.":`Auto compacts at ${n}% context when supported.`}function d6(e){return e==="codex"}function u6(e){return e==="openpond"}function dI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="session.context.updated")continue;const a=xj.safeParse(n.data);if(a.success)return a.data}return null}function uI(e){if(e.snapshot&&e.snapshot.provider===e.provider){const n=e.snapshot.usedTokens,a=e.snapshot.maxContextTokens,r=Math.min(100,Math.round(e.snapshot.percentFull)),i=`${r}% full`,s=`${py(n)} / ${py(a)} tokens used`;return{usedTokens:n,maxTokens:a,percent:r,summary:i,tokensLabel:s,detail:fy(e.preferences,r),tooltip:`Context window: ${i} ${s}. ${fy(e.preferences,r)}`,tone:c6(r)}}if(d6(e.provider)){const n="Context is managed by Codex app-server.";return{usedTokens:0,maxTokens:null,percent:null,summary:"Managed externally",tokensLabel:"Codex app-server",detail:n,tooltip:`Context window: ${n}`,tone:"unknown"}}if(!u6(e.provider)){const n="Context pressure is unavailable until this provider has model context metadata.";return{usedTokens:0,maxTokens:null,percent:null,summary:"Limit unknown",tokensLabel:"Provider metadata unavailable",detail:n,tooltip:`Context window: ${n}`,tone:"unknown"}}const t="Send a message to measure hosted context.";return{usedTokens:0,maxTokens:null,percent:null,summary:"Not measured yet",tokensLabel:"Hosted context",detail:t,tooltip:`Context window: ${t}`,tone:"unknown"}}function kg(e){let t=!1;const n=mI(e);for(let a=e.length-1;a>=0;a-=1){const r=e[a];if(m6(r)){t=!0;continue}const i=Wi(r?.data);if(!(r?.name!=="diagnostic"||!i)){if(i.kind==="thread_goal_cleared")return null;if(i.kind==="thread_goal"){const s=wg(Wi(i.goal),Wn(i.provider),n);if(s){const l=Cl(s);return t&&l.tone==="active"?null:l}}if(i.kind==="goal_context"){const s=fI(r.output??"",Wn(i.provider)??"codex",n);if(s){const l=Cl(s);return t&&l.tone==="active"?null:l}}}}return null}function fd(e){const t=mI(e);for(let n=e.length-1;n>=0;n-=1){const a=e[n],r=Wi(a?.data);if(!(a?.name!=="diagnostic"||!r)){if(r.kind==="thread_goal_cleared"&&r.synthetic!==!0)return null;if(r.kind==="thread_goal"){const i=wg(Wi(r.goal),Wn(r.provider),t);if(!i)continue;const s=Cl(i);return s.tone==="active"?s:null}if(r.kind==="goal_context"){const i=fI(a.output??"",Wn(r.provider)??"codex",t);if(!i)continue;const s=Cl(i);return s.tone==="active"?s:null}}}return null}function sp(e){const t=Wi(Wi(e)?.codexGoalRuntime),n=wg(t,Wn(t?.provider)??"codex");if(!n)return null;const a=Cl(n);return a.tone==="active"?a:null}function m6(e){return e?.name==="turn.completed"||e?.name==="turn.interrupted"||e?.name==="turn.failed"}function Cl(e){const t=hI(e.status),n=bI(e.timeUsedSeconds),a=`Goal ${n}`,r=e.tokensUsed===null?null:e.tokenBudget===null?`${lp(e.tokensUsed)} tokens`:`${lp(e.tokensUsed)} / ${lp(e.tokenBudget)} tokens`,i=r?`${e.statusLabel} · ${r}`:e.statusLabel;return{objective:e.objective,status:e.status,timeUsedSeconds:e.timeUsedSeconds,tokensUsed:e.tokensUsed,tokenBudget:e.tokenBudget,actionLabel:t.actionLabel,timeLabel:n,label:a,detail:i,tooltip:`Goal runtime: ${yI(e.timeUsedSeconds)}. ${i}. ${e.objective}`,tone:t.tone,observedAt:e.observedAt}}function p6(e,t){if(!e||e.tone!=="active"||!e.observedAt)return e;const n=pI(e.observedAt,t);if(n<=0)return e;const a=e.timeUsedSeconds+n,r=bI(a);return{...e,timeUsedSeconds:a,timeLabel:r,label:`Goal ${r}`,tooltip:`Goal runtime: ${yI(a)}. ${e.detail}. ${e.objective}`,observedAt:t}}function wg(e,t=null,n=null){if(!e)return null;const a=Wn(e.objective)??"Active goal",r=Wn(e.status)??"active";if((ff(t)??ff(Wn(e.provider)))!=="codex")return null;const s=n??Wn(e.updatedAt)??Wn(e.updated_at)??null,l=vi(e.timeUsedSeconds)??vi(e.time_used_seconds)??0,m=Wn(e.activeSinceAt)??Wn(e.active_since_at),u=hI(r).tone==="active"?pI(m??Wn(e.createdAt)??Wn(e.created_at),s):0,h=m?l+u:Math.max(l,u),b=vi(e.tokensUsed)??vi(e.tokens_used),y=vi(e.tokenBudget)??vi(e.token_budget);return{objective:a,status:r,statusLabel:vI(r),timeUsedSeconds:Math.max(0,Math.floor(h)),tokensUsed:b===null?null:Math.max(0,Math.floor(b)),tokenBudget:y===null?null:Math.max(0,Math.floor(y)),observedAt:s}}function mI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]?.timestamp;if(n&&Number.isFinite(Date.parse(n)))return n}return null}function pI(e,t){if(!e||!t)return 0;const n=Date.parse(e),a=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(a)||a<=n?0:Math.floor((a-n)/1e3)}function fI(e,t=null,n=null){if(!e.trim()||ff(t)!=="codex")return null;const a=gI(e,"Status")??"active",r=Ks(e,"Tokens used"),i=Ks(e,"Token budget"),s=Ks(e,"Time used seconds")??Ks(e,"Time spent pursuing goal")??Ks(e,"Elapsed seconds")??0;return{objective:hy(e,"objective")??hy(e,"untrusted_objective")??"Active goal",status:a,statusLabel:vI(a),timeUsedSeconds:Math.max(0,Math.floor(s)),tokensUsed:r,tokenBudget:i,observedAt:n}}function hI(e){switch(f6(e)){case"active":case"running":return{tone:"active",actionLabel:"Pursuing goal"};case"paused":return{tone:"paused",actionLabel:"Goal paused"};case"blocked":return{tone:"limited",actionLabel:"Goal blocked"};case"complete":case"completed":case"achieved":return{tone:"done",actionLabel:"Goal achieved"};case"failed":return{tone:"limited",actionLabel:"Goal failed"};case"cancelled":case"canceled":case"stopped":return{tone:"limited",actionLabel:"Goal cancelled"};case"budget_limited":return{tone:"limited",actionLabel:"Goal budget limited"};default:return{tone:"active",actionLabel:"Goal status unknown"}}}function f6(e){return e.trim().toLowerCase().replace(/[-\s]+/g,"_")}function gI(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^\\s*-?\\s*${n}:\\s*(.+?)\\s*$`,"im").exec(e)?.[1]?.trim()||null}function Ks(e,t){const n=gI(e,t);if(!n)return null;const a=n.replace(/,/g,""),r=/-?\d+(?:\.\d+)?/.exec(a);if(!r)return null;const i=Number(r[0]);return Number.isFinite(i)?i:null}function hy(e,t){return new RegExp(`<${t}>\\s*([\\s\\S]*?)\\s*<\\/${t}>`,"i").exec(e)?.[1]?.trim()||null}function vI(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function bI(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m`:`${n}h`}function yI(e){if(e<60)return`${e} ${e===1?"second":"seconds"}`;const t=Math.floor(e/60);if(t<60)return`${t} ${t===1?"minute":"minutes"}`;const n=Math.floor(t/60),a=t%60;return a===0?`${n} ${n===1?"hour":"hours"}`:`${n}h ${a}m`}function lp(e){if(e<1e3)return String(e);if(e>=1e6){const n=e/1e6;return n<10?`${gy(n,2)}M`:n<100?`${gy(n,1)}M`:`${Math.round(n)}M`}const t=e/1e3;return t>=10||Number.isInteger(t)?`${Math.round(t)}k`:`${t.toFixed(1)}k`}function gy(e,t){return e.toFixed(t).replace(/\.?0+$/,"")}function Wi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Wn(e){return typeof e=="string"&&e.trim()?e.trim():null}function ff(e){return e?.trim().toLowerCase()||null}function vi(e){return typeof e=="number"&&Number.isFinite(e)?e:null}const h6=new Set(["planning","applying_source","running_checks","evaluating","pushing_hosted","running_hosted_checks"]),g6=new Set(["awaiting_questions","awaiting_plan_approval","paused"]);function hf(e){const t=SI(e);return t?S6(t):null}function SI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="create_improve.updated")continue;const a=y6(_6(n.data));if(a)return a}return null}function v6(e){if(e.events)return SI(e.events);const t=e.messages??[];for(let n=t.length-1;n>=0;n-=1){const a=t[n]?.createImproveRun??null;if(a)return a}return null}function b6(e,t){const n=e?.target.displayName?.trim()??"",a=n.toLowerCase().replace(/[^a-z0-9]+/g," ").trim();return n&&!/^(?:create|creating|improve|improving|new) (?:an )?agent$/.test(a)?n:t}function y6(e){const t=Ol.safeParse(e?.createImproveRun);return t.success?t.data:null}function S6(e){const t=x6(e);if(!t)return null;const n=k6(e.createdAt,e.updatedAt),a=e.blockedReason??w6(e.state);return{objective:e.objective,status:e.state,timeUsedSeconds:n,tokensUsed:null,tokenBudget:null,actionLabel:t.actionLabel,timeLabel:I6(n),label:t.actionLabel,detail:a,tooltip:`${t.actionLabel}: ${a}. ${e.objective}`,tone:t.tone}}function x6(e){const t=e.state,n=e.target.kind==="agent"?"Agent":"Work";return h6.has(t)?{tone:"active",actionLabel:`${n} running`}:g6.has(t)?{tone:"active",actionLabel:`${n} awaiting input`}:t==="blocked"?{tone:"limited",actionLabel:`${n} blocked`}:t==="failed"?{tone:"limited",actionLabel:`${n} failed`}:t==="cancelled"?{tone:"limited",actionLabel:`${n} cancelled`}:t==="ready"||t==="ready_local"?{tone:"done",actionLabel:e.target.kind==="agent"?"Agent ready":"Workproduct ready"}:t==="published_hosted"?{tone:"done",actionLabel:e.target.kind==="agent"?"Agent published":"Workproduct published"}:null}function k6(e,t){const n=Date.parse(e),a=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(a)||a<n?0:Math.floor((a-n)/1e3)}function w6(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function I6(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m`:`${n}h`}function _6(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function xI(e,t){if(!t)return null;const n=new Map,a=[];for(const O of e){if(!O.name.startsWith("subagent."))continue;const k=P6(O);k&&a.push(k);const C=R6(O);C?.parentSessionId===t&&n.set(C.id,C)}if(n.size===0)return null;const r=[...n.values()].sort((O,k)=>yi(k).localeCompare(yi(O))),i=r.filter(O=>O.status==="queued"||O.status==="running"),s=r.filter(O=>O.status==="completed"),l=r.filter(O=>O.status==="failed"),m=r.filter(O=>O.status==="cancelled"),u=r.filter(O=>O.status==="needs_resume"),h=[...s,...l,...m].sort((O,k)=>yi(k).localeCompare(yi(O))),b=r.reduce((O,k)=>{const C=Gi(k.metadata?.usage);return O.totalTokens+=Rc(C?.totalTokens),O.promptTokens+=Rc(C?.promptTokens),O.completionTokens+=Rc(C?.completionTokens),O.requestCount+=Rc(C?.requestCount),O},{totalTokens:0,promptTokens:0,completionTokens:0,requestCount:0}),y=r.flatMap(O=>kI([...O.report?.blockers??[],O.error,O.progress.currentBlocker]).map(k=>({runId:O.id,roleId:O.roleId,status:O.status,message:k}))),w=r.flatMap(O=>wI([...O.report?.artifacts??[],O.report?.patchRef,O.report?.diffRef,...O.progress.patchRefs]).map(k=>({...k,runId:O.id,roleId:O.roleId}))),_=h.map(O=>C6(O,a)),E=r[0]??null,j=E?{runId:E.id,roleId:E.roleId,status:E.status,message:E.progress.latestMeaningfulActivity||E.report?.summary||E.objective,updatedAt:yi(E)}:null,P=i.length>0?`${i.length} ${i.length===1?"child":"children"} running`:`${h.length} ${h.length===1?"child":"children"} finished`,L=[i.length?`${i.length} active`:null,s.length?`${s.length} completed`:null,l.length?`${l.length} failed`:null,m.length?`${m.length} cancelled`:null,u.length?`${u.length} paused`:null].filter(Boolean).join(" · "),$=j?`${E6(j.roleId)}: ${j.message}`:"";return{sessionId:t,runs:r,activeRuns:i,completedRuns:s,failedRuns:l,cancelledRuns:m,needsResumeRuns:u,terminalRuns:h,latestRun:E,latestMeaningfulUpdate:j,activeCount:i.length,completedCount:s.length,failedCount:l.length,cancelledCount:m.length,needsResumeCount:u.length,terminalCount:h.length,usage:b,blockers:y,evidenceRefs:w,finalResults:_,testsRunCount:r.reduce((O,k)=>O+k.progress.validationAttempts.length,0),label:P,tooltip:[L,$].filter(Boolean).join(". ")}}function C6(e,t){return{runId:e.id,roleId:e.roleId,status:e.status,objective:e.objective,summary:e.report?.summary||e.error||"Child conversation finished.",findings:e.report?.findings??[],changedFiles:e.progress.changedFiles,refs:wI([...e.report?.artifacts??[],e.report?.patchRef,e.report?.diffRef]),testsRun:e.report?.testsRun??[],validationAttempts:e.progress.validationAttempts.map(n=>n.command),blockers:kI([...e.report?.blockers??[],e.error]),confidence:e.report?.confidence??null,importantMessages:t.filter(n=>n.fromRunId===e.id).map(n=>({id:n.id,runId:e.id,fromRunId:n.fromRunId,kind:n.kind,body:n.body,createdAt:n.createdAt})),workspaceRetention:A6(e),updatedAt:yi(e)}}function R6(e){const t=Gi(e.data),n=[t?.run,Gi(t?.message)?.run];for(const a of n){const r=PS.safeParse(a);if(r.success)return r.data}return null}function P6(e){const t=HE.safeParse(Gi(e.data)?.message);return t.success?t.data:null}function A6(e){const t=Gi(Gi(e.metadata?.workspaceHandoff)?.workspaceRetention);return t?.status!=="retained"?null:{status:"retained",reason:Cc(t.reason),retainedAt:Cc(t.retainedAt),expiresAt:Cc(t.expiresAt),retentionDays:T6(t.retentionDays),trigger:Cc(t.trigger),cleanupAfterExpiry:t.cleanupAfterExpiry===!0}}function yi(e){return e.updatedAt??e.completedAt??e.startedAt??e.createdAt}function kI(e){return[...new Set(e.map(t=>t?.trim()).filter(t=>!!t))]}function wI(e){const t=new Map;for(const n of e)n&&t.set(`${n.kind}:${n.id}`,n);return[...t.values()]}function Gi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Cc(e){return typeof e=="string"&&e.trim()?e.trim():null}function Rc(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function T6(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function E6(e){return e.slice(0,1).toUpperCase()+e.slice(1).replace(/[-_]+/g," ")}const gf=[];function vf(e,t){return II(e,t,null)}function II(e,t,n){const a=n&&N6(n.events,e)?j6(n.indexes,n.events.length,e):M6(e),r=$6(t);return{...a,...r}}function M6(e){const t=new Map;for(const n of e){if(!n.sessionId)continue;const a=t.get(n.sessionId);a?a.push(n):t.set(n.sessionId,[n])}return O6(t)}function j6(e,t,n){const a=new Map(e.eventsBySessionId),r=new Map(e.latestContextUsageBySessionId),i=new Map(e.latestGoalRuntimeBySessionId),s=new Map(e.latestSubagentRuntimeBySessionId),l=new Set(e.activeGoalSessionIds),m=new Set(e.activeSubagentSessionIds),u=new Set;for(let h=t;h<n.length;h+=1){const b=n[h];if(!b.sessionId)continue;if(u.has(b.sessionId)){a.get(b.sessionId).push(b);continue}const y=a.get(b.sessionId);a.set(b.sessionId,y?[...y,b]:[b]),u.add(b.sessionId)}for(const h of u){const b=a.get(h)??gf,y=dI(b);y?r.set(h,y):r.delete(h);const w=CI(b);w?(i.set(h,w),w.tone==="active"?l.add(h):l.delete(h)):(i.delete(h),l.delete(h));const _=xI(b,h);_?(s.set(h,_),_I({sessionEvents:b,sessionId:h,latestGoalRuntimeBySessionId:i,activeGoalSessionIds:l}),_.activeCount>0?m.add(h):m.delete(h)):(s.delete(h),m.delete(h))}return{eventsBySessionId:a,latestContextUsageBySessionId:r,latestGoalRuntimeBySessionId:i,latestSubagentRuntimeBySessionId:s,activeGoalSessionIds:l,activeSubagentSessionIds:m}}function O6(e){const t=new Map,n=new Map,a=new Map,r=new Set,i=new Set;for(const[s,l]of e){const m=dI(l);m&&t.set(s,m);const u=CI(l);u&&(n.set(s,u),u.tone==="active"&&r.add(s))}for(const[s,l]of e){const m=xI(l,s);m&&(a.set(s,m),_I({sessionEvents:l,sessionId:s,latestGoalRuntimeBySessionId:n,activeGoalSessionIds:r}),m.activeCount>0&&i.add(s))}return{eventsBySessionId:e,latestContextUsageBySessionId:t,latestGoalRuntimeBySessionId:n,latestSubagentRuntimeBySessionId:a,activeGoalSessionIds:r,activeSubagentSessionIds:i}}function _I(e){if(e.latestGoalRuntimeBySessionId.has(e.sessionId))return;const t=fd(e.sessionEvents);t&&(e.latestGoalRuntimeBySessionId.set(e.sessionId,t),t.tone==="active"&&e.activeGoalSessionIds.add(e.sessionId))}function CI(e){return hf(e)??kg(e)??fd(e)}function $6(e){const t=new Map,n=new Map,a=new Map,r=new Map;for(const i of e){t.set(i.id,i);const s=n.get(i.status);if(s?s.push(i):n.set(i.status,[i]),i.status!=="pending")continue;const l=a.get(i.sessionId);l?l.push(i):a.set(i.sessionId,[i]);const m=r.get(i.sessionId);(!m||vy(i.createdAt)>vy(m.createdAt))&&r.set(i.sessionId,i)}return{approvalsById:t,approvalsByStatus:n,pendingApprovalsBySessionId:a,latestPendingApprovalBySessionId:r}}function N6(e,t){return e===t?!0:e.length>t.length||e.length===t.length?!1:e.length===0?!0:e[0]===t[0]&&e[e.length-1]===t[e.length-1]}function Zl(e,t){return t?e.eventsBySessionId.get(t)??gf:gf}function RI(e,t){return t?e.latestContextUsageBySessionId.get(t)??null:null}function PI(e,t){return t?e.latestGoalRuntimeBySessionId.get(t)??null:null}function D6(e,t){return t?e.latestSubagentRuntimeBySessionId.get(t)??null:null}function L6(e,t){return t?e.latestPendingApprovalBySessionId.get(t)??null:null}function vy(e){const t=Date.parse(e);return Number.isFinite(t)?t:Number.NEGATIVE_INFINITY}function U6(e,t){return e?.conversationId===t}function z6(e,t){return e?.id===t?null:e}function H6(e){const t=new Set;if(e.readmePath){const n=e.readmePath.replaceAll("\\","/").split("/").at(-1);n&&t.add(n)}for(const n of e.skills){t.add(n.relativePath);const a=n.relativePath.lastIndexOf("/"),r=a>=0?n.relativePath.slice(0,a):"";for(const i of n.resourceFiles)t.add(r?`${r}/${i}`:i)}return{name:`${e.owner}/${e.repo}`,description:`${e.skills.length} installed skill${e.skills.length===1?"":"s"} from GitHub.`,scope:"extension",packagePath:e.sourcePath,files:[...t]}}function q6(e){return JSON.stringify([e.source,e.repositoryId,e.profileId])}function wJ(e,t){return e.profiles.find(n=>q6(n.ref)===t)?.ref??null}function B6(e,t){return!!(e&&t&&e.source===t.source&&e.repositoryId===t.repositoryId&&e.profileId===t.profileId)}function IJ(e,t){return e.profiles.find(n=>B6(n.ref,t))?.state??null}function F6(e,t){const n=new Map(F2.map(a=>[a.name,{...a,validationMessages:[...a.validationMessages],resourceFiles:[...a.resourceFiles]}]));for(const a of e?.skills??[])n.has(a.name)||n.set(a.name,a);for(const a of t?.extensions??[])if(a.validationStatus==="valid")for(const r of a.skills)r.validationStatus!=="valid"||n.has(r.name)||n.set(r.name,{name:r.name,description:r.description,path:r.relativePath,scope:"profile",enabled:!0,sourcePath:a.sourcePath,charCount:r.charCount,sourceHash:r.sourceHash,validationStatus:"valid",validationMessages:[],resourceFiles:r.resourceFiles});return[...n.values()].sort((a,r)=>a.name.localeCompare(r.name))}function V6(e){return{sourceTaskId:e.sourceTaskId,sourceExperience:e.sourceExperience,targetExperience:e.targetExperience,sourceMessageIds:[...e.sourceMessageIds??[]],sourceContext:e.sourceContext?.trim()||null,outputId:e.output?.id??null,outputRevision:e.output?.revision??null,createdAt:e.createdAt??new Date().toISOString(),checkoutMutation:"none"}}function _J(e,t){const n=`Continue from the attached Work output "${e.title}" (revision ${e.revision}).`;return t==="work"?`${n} Choose a Project or repository before making source changes; do not mutate a checkout until I choose it.`:n}const AI="openpond:last-chat-task-mode";function K6(e,t){return e==="labs"?"models":"chat"}function W6(e){try{return e.getItem(AI)==="work"?"work":"chat"}catch{return"chat"}}function Ig(){if(typeof window>"u")return"chat";try{return W6(Wl)}catch{return"chat"}}function G6(e,t){try{e.setItem(AI,t==="chat"?"chat":"work")}catch{}}function Z6(e){if(!(typeof window>"u"))try{G6(Wl,e)}catch{}}const J6="uploaded to a different account";function TI(e,t){const n=e?.linkedSandboxProject??null;if(!n?.projectId||!n.teamId)return{state:"none",linked:null,cloudProject:null};const a=t?.find(r=>r.id===n.projectId&&r.teamId===n.teamId)??null;return a?{state:"confirmed",linked:n,cloudProject:a}:{state:"different_account",linked:n,cloudProject:null}}function Sa(e,t){const n=TI(e,t);return n.state==="confirmed"?n.cloudProject:null}function Y6(e,t){return TI(e,t).state==="different_account"?J6:null}function lo(e){return e==="sandbox"||e==="sandbox_template"||e==="sandbox_app"}function EI(e={}){return{...e,workspaceTarget:"hybrid"}}function Q6(e={}){return{...e,workspaceTarget:"local"}}function co(e){return e?.metadata?.workspaceTarget==="hybrid"}function X6(e){return!!(e&&e.provider==="openpond"&&e.workspaceKind==="local_project"&&e.cloudProjectId&&e.title.trim().endsWith(" Cloud"))}function MI({cloudProjects:e,selectedCloudProject:t,selectedProject:n}){const a=n?.linkedSandboxProject??null,r=e?Sa(n,e):null,i=t?.id??r?.id??(e?null:a?.projectId??null),s=t?.teamId??r?.teamId??(e?null:a?.teamId??null);return!i||!s?{kind:"missing_cloud_project",message:"Upload/sync this Project to Cloud before using Hybrid."}:{kind:"ready",cloudProjectId:i,cloudTeamId:s,cwd:n?.workspacePath??null,localProjectId:n?.id??null,workspaceName:t?.name??r?.name??a?.projectName??n?.name??"Hybrid workspace"}}function jI({modelRef:e,provider:t,target:n,title:a}){return{provider:t,...e?{modelRef:e}:{},appId:null,appName:null,workspaceKind:"sandbox",workspaceId:null,workspaceName:n.workspaceName,localProjectId:n.localProjectId,cloudProjectId:n.cloudProjectId,cloudTeamId:n.cloudTeamId,metadata:EI(),cwd:n.cwd,title:a}}function eV(e){return g.useEffect(()=>{const t=F1(e.selectedSession);!t||e.composerDraftStore.getSnapshot()||e.composerDraftStore.set(t)},[e.composerDraftStore,e.selectedSession?.id]),g.useCallback(async t=>{const n=t.trim();if(!e.connection||!n||e.activeExperience==="chat")return!1;const a=Z4(n);try{let r;const i=e.selectedSession;if(i&&Il(i))r=await J.patchSession(e.connection,i.id,{title:a,metadata:ap(i.metadata,n)}),e.setSessions(s=>s.map(l=>l.id===r.id?r:l));else{const s=i?.metadata?.workspaceTarget==="hybrid"?"hybrid":i?.metadata?.workspaceTarget==="local"?"local":null,l=i?.provider??(e.selectedCloudProject?"openpond":e.activeProvider),m=i?.modelRef??(l==="openpond"?{providerId:"openpond",modelId:Ui}:{providerId:l,modelId:e.activeModel}),u=s?{workspaceTarget:s}:!i&&e.workspaceTarget==="local"?{workspaceTarget:"local"}:{};let h;if(!i&&e.workspaceTarget==="hybrid"){const b=MI({cloudProjects:e.cloudProjects,selectedCloudProject:e.selectedCloudProject,selectedProject:e.selectedProject});if(b.kind!=="ready")throw new Error(b.message);const y=jI({modelRef:m,provider:l,target:b,title:a});h={...y,experience:"work",metadata:ap(y.metadata,n)}}else h={experience:"work",provider:l,modelRef:m,openPondCommandAccessMode:i?.openPondCommandAccessMode??e.activeOpenPondCommandAccessMode,appId:i?.appId??null,appName:i?.appName??null,workspaceKind:i?.workspaceKind??(e.selectedCloudProject?"sandbox":e.selectedProject?"local_project":void 0),workspaceId:i?.workspaceId??e.selectedCloudProject?.id??e.selectedProject?.id??null,workspaceName:i?.workspaceName??e.selectedCloudProject?.name??e.selectedProject?.name??null,localProjectId:i?.localProjectId??e.selectedProject?.id??null,cloudProjectId:i?.cloudProjectId??e.selectedCloudProject?.id??null,cloudTeamId:i?.cloudTeamId??e.selectedCloudProject?.teamId??null,cwd:i?.cwd??e.selectedProject?.workspacePath??null,metadata:ap(u,n),title:a};r=await J.createSession(e.connection,h),e.setSessions(b=>[r,...b])}return e.composerDraftStore.set(""),e.setMentionedAppId(null),e.setSelectedSessionId(null),e.setView("chat"),e.requestComposerFocus(),e.showToast("Task draft saved.","success"),!0}catch(r){return e.showToast(r instanceof Error?r.message:"Could not save task draft.","error"),!1}},[e.activeExperience,e.activeModel,e.activeOpenPondCommandAccessMode,e.activeProvider,e.cloudProjects,e.composerDraftStore,e.connection,e.requestComposerFocus,e.selectedCloudProject,e.selectedProject,e.selectedSession,e.setMentionedAppId,e.setSelectedSessionId,e.setSessions,e.setView,e.showToast,e.workspaceTarget])}const tV=[];function nV({primary:e,secondary:t}){const[n,a]=g.useState(!1),r=M4(),{composerDraftStore:i,appDispatch:s,pendingTerminalCommand:l,setPendingTerminalCommand:m,terminalTabs:u,setTerminalTabs:h,trainingDetailTasksetId:b,setTrainingDetailTasksetId:y,mentionedAppId:w,setMentionedAppId:_,cloudSetupDialog:E,setCloudSetupDialog:j,rightPanelTabRequest:P,workspaceDiffPanelViewState:L,mainComposerFocusRequestId:$,requestMainComposerFocus:O,projectConfirmDialog:k,resolveProjectConfirmDialog:C,query:A,searchOpen:z,archivedChatsOpen:B,sectionMenuOpen:N,cloudProjectsExpanded:K,sidebarOpen:de,view:te,selectedAppId:Ie,selectedProjectId:xe,selectedSessionId:Z,codexPermissionMode:Ae,codexReasoningEffort:he,busy:ue,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:ge,activeExperience:ke,changeNewExperience:qe,terminalOpen:Se,settingsSection:ie,newProjectDialogOpen:we,newProjectMode:Oe,newProjectName:Qe,newProjectPath:Ge,newProjectBusy:st,commitDialogOpen:Le,commitMessage:Fe,commitIncludeUnstaged:De,commitNextStep:D,commitDraft:M,branchDialogOpen:H,branchDialogName:Q,toast:me,labDetailNavigation:_e,setQuery:$e,setSearchOpen:Xe,setArchivedChatsOpen:et,setSectionMenuOpen:rt,setCloudProjectsExpanded:it,setChatRowsVisibleCount:Me,setSidebarOpen:Be,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setPrompt:re,setDraftProvider:F,setDraftModel:I,setDraftExperience:W,setDiffPanelOpen:X,setDiffPanelExpanded:oe,setRightPanelMode:G,setTerminalOpen:pe,setSettingsSection:fe,setNewProjectDialogOpen:je,setNewProjectName:Ee,setNewProjectPath:Ne,setCommitDialogOpen:Ve,setCommitMessage:Ue,setCommitIncludeUnstaged:ut,setCommitNextStep:Qt,setCommitDraft:Lt,setBranchDialogOpen:An,setBranchDialogName:Sn,setError:nn,showToast:bt,applyBootstrapPayload:rn,bootstrap:Nt,connection:yt,startup:sn,training:Ut,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Da,sidebarWidth:ia,sidebarResizing:qt,diffPanelWidth:qn,diffPanelResizing:ot,togglePinnedCollapsed:xn,toggleCloudProjectsCollapsed:La,toggleChatsCollapsed:Ua,toggleSavedForLaterCollapsed:sa,startSidebarResize:za,startDiffPanelResize:ae,selectedApp:Ke,selectedCloudProject:ze,selectedProject:Ze,selectedProjectLinkedApp:xt,selectedSession:gt,sidebarSessions:lt,runtimeIndexes:Ct,runtimeEventStore:la,chatMentionApps:Bn,connectedAppMentions:tt,pendingApproval:_n,pendingChatUserMessages:St,account:kn,activeModel:$n,activeProvider:Tn,appDefaults:Ha,startMessage:wa,organizations:uo,teamChatOrganization:qa,teamChatTeamId:ea,teamChat:kt,publishTeamProfileAgent:Ba,communitySidebar:ca,communityView:Vr,teamAiThreadId:ur,toggleTeamAiSidebar:mr,activeOpenPondCommandAccessMode:mo,viewWorkspaceAppId:Kr,viewWorkspaceId:Wr,viewWorkspaceKind:Gr,viewWorkspaceName:Zr,selectedActionCatalog:rs,expandedProjectIds:is,expandProject:Fa,toggleProjectExpanded:ss,changeCodexPermissionMode:Jr,changeCodexReasoningEffort:Yr,changeOpenPondCommandAccessMode:Qr,resolveApproval:ls,beginNewChat:ta,beginNewChatWithTrainingModel:cs,dismissTrainingChatHandoff:ds,trainingChatHandoff:us,selectTrainingChatTaskForComposer:Xr,chatHistoryLoadStates:ei,loadMoreSelectedChatHistory:ti,selectedPagedSessionEvents:ms,activeSessions:Va,archivedSessions:po,pinnedSessions:Fn,savedForLaterSessions:ps,savedForLaterFiles:fs,sidebarFileBookmarks:vn,setSidebarFileStatus:ni,setSessions:Vn,projectRows:Ia,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:hs,childSessionRowsByParentId:gs,sidebarProjectIdBySessionId:ho,chatRows:pr,visibleChatRows:ai,chatRowsVisibleCount:fr,sessionEvents:oi,goalRuntime:hr,subagentRuntime:ri,visibleChatMessages:da,activeTerminalScope:Fo,terminalSummaries:gr,runningSessionIds:go,selectedSessionRunning:ii,sidebarGoalRuntimeBySessionId:Wa,sidebarSubagentRuntimeBySessionId:si,taskDragSessionId:vs,taskPreviewSessionIds:vr,startTaskDrag:li,clearTaskDrag:ci,previewTaskDrop:di,commitTaskDrop:bs,commitTaskPreviewDrop:br,dragItem:ui,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:ys,commitPinnedDrop:Ss,commitPinnedPreviewDrop:xs,commandProjectRows:ks,contextWindowStatus:_a,pinnedRows:mi,workspaceBusy:yr,diffBusy:ws,visibleWorkspaceState:vo,visibleWorkspaceDiff:Nn,refreshVisibleWorkspaceDiff:Is,managedWorkspace:_s,canSyncActiveWorkspace:Cs,canPublishOpenPondProject:Rs,projectTarget:mt,workspaceTarget:Bt}=e,{title:Kn,browserConversationId:pn,handleWorkspaceDiffPanelViewStateChange:na,openSessionInChat:En,changeProjectTarget:du,submitNewProjectDialog:uu,changeWorkspaceBranch:mu,openCommitDialog:Ps,openCreateWorkspaceBranchDialog:Yl,openDefaultsSettingsFromBranchDialog:pu,runWorkspaceTool:fu,submitCommitDialog:hu,submitCreateWorkspaceBranch:gu,syncWorkspaceLocally:vu,answerCreateImproveQuestion:bu,applyCreateImproveCandidate:yu,approveCreateImproveRun:Su,cancelCreateImproveRun:xu,changeDraftProvider:Ql,openCreateImprovePullRequest:ku,reconcileCreateImprovePullRequest:Xl,rejectCreateImproveCandidate:wu,pauseCreateImproveRun:Iu,resumeCreateImproveRun:_u,reviseCreateImproveRun:ec,stopTurn:As,archiveSession:Cu,restoreSession:Ru,renameSession:tc,toggleSessionPinned:nc,toggleProjectPinned:ac,toggleSessionSavedForLater:Ts,moveProjectToCloud:Pu,startCloudSetupUpload:oc,changeWorkspaceTarget:Au,sendPromptFromMainComposer:Es,openSandboxWorkspace:Tu,openCloudProjectDialog:rc,openUrlInBrowserPanel:Eu,showBrowserPanel:ic,showChangesPanel:Mu,showGoalSidebarTab:ju,rightChatTrainingLaunchRequest:sc,setRightChatTrainingLaunchRequest:Ou,closeRightChatPanel:$u,openRightChatPanel:Ms,rightChatPanelViews:Nu,showRightChatPanel:Du,showRightPanelDiffTab:Ko,submitRightChatPrompt:lc,activateRightChatPanel:Lu,updateRightChatModel:Uu,updateRightChatPrompt:zu,updateRightChatProvider:Hu,updateRightChatScrollState:qu,openProfileSettings:Bu,diagnosticEvents:Fu,toggleRightSidebar:cc,removeProject:Vu}=t,pi=g.useCallback(Te=>{U(null),V(Te),le(null),p("chat"),Fa(Te),O()},[Fa,O,U,V,le,p]),Ku=g.useCallback((Te=null)=>{const ct=Z?ho[Z]??null:null;if(!Te&&ct){pi(ct);return}ta(Te)},[ta,pi,Z,ho]),Wu=g.useCallback(async Te=>{if(!(!yt||!Nt))try{const ct=await J.savePreferences(yt,{defaultTeamId:Te});rn({...Nt,preferences:ct.preferences})}catch(ct){const Mt=ct instanceof Error?ct.message:String(ct);throw nn(Mt),bt("Could not switch teams","error"),ct}},[rn,Nt,yt,nn,bt]),Gu=g.useCallback(async()=>{if(yt)try{const Te=await J.signOutOpenPondAccount(yt);rn(Te);const ct=await J.savePreferences(yt,{defaultTeamId:null});rn({...Te,preferences:ct.preferences}),bt("Logged out","success")}catch(Te){const ct=Te instanceof Error?Te.message:String(Te);throw nn(ct),bt("Could not log out","error"),Te}},[rn,yt,nn,bt]),js=ea??Ha.defaultTeamId??null,Zu=g.useMemo(()=>Ia.filter(Te=>Te.kind==="local"||js!==null&&Te.project.teamId===js),[Ia,js]),Ju=g.useMemo(()=>{const Te={};for(const ct of Va){const Mt=ho[ct.id];Mt&&(Te[Mt]=(Te[Mt]??0)+1)}for(const ct of fo){if(ct.kind!=="local")continue;const Mt=ct.project.linkedSandboxProject?.projectId;if(!Mt||!ct.cloudLinkTrusted)continue;const ua=vt("cloud",Mt);Te[ct.id]=(Te[ct.id]??0)+(Te[ua]??0)}return Te},[Va,fo,ho]),[Os,$s]=g.useState(null),[Ns,Ds]=g.useState(null),Yu=F6(Nt?.profile,Nt?.extensionCatalog),[Ls,Us]=g.useState(null),[zs,dc]=g.useState(null),[Za,Hs]=g.useState(null),uc=g.useCallback(()=>{U(null),V(null),le(null),rt(null),p("team")},[rt,U,V,le,p]),Qu=g.useCallback(()=>{U(null),V(null),le(null),rt(null),ca.discoverCommunities()},[ca.discoverCommunities,rt,U,V,le]),qs=eV({activeExperience:ke,activeModel:$n,activeOpenPondCommandAccessMode:mo,activeProvider:Tn,cloudProjects:Nt?.cloudProjects??tV,composerDraftStore:i,connection:yt,requestComposerFocus:O,selectedCloudProject:ze,selectedProject:Ze,selectedSession:gt,setMentionedAppId:_,setSelectedSessionId:le,setSessions:Vn,setView:p,showToast:bt,workspaceTarget:Bt.value}),Xu=g.useCallback(async Te=>{if(!yt)throw new Error("OpenPond is not connected.");let ct=Tn,Mt=$n;ct==="codex"&&(ct=mf(Nt?.providers,{enabledOnly:!0}).find(bn=>bn.value!=="codex")?.value??Mr,Mt=dd(ct,Nt?.providers)??pl);const ua=lt.find(bn=>bn.id===Te.sourceSessionId),bo=await J.createSession(yt,{experience:Te.target,provider:ct,modelRef:{providerId:ct,modelId:Mt},openPondCommandAccessMode:mo,appId:null,appName:null,workspaceId:null,workspaceName:null,localProjectId:null,cloudProjectId:null,cloudTeamId:null,cwd:null,title:`Continue ${ua?.title??"task"}`.slice(0,120),metadata:{experienceHandoff:V6({sourceTaskId:Te.sourceSessionId,sourceExperience:ua?.experience??null,targetExperience:Te.target,sourceMessageIds:Te.sourceMessageIds??[],sourceContext:Te.sourceContext,output:Te.output})}});return Vn(bn=>[bo,...bn]),W(Te.target),F(ct),I(Mt),i.set(Te.prompt),ln({kind:"chat",sessionId:bo.id}),s({type:"selectSession",sessionId:bo.id,appId:null,projectId:null}),U(null),V(null),pe(!1),p("chat"),G("home"),X(Te.target==="work"),oe(!1),bo},[$n,mo,Tn,s,Nt?.providers,i,yt,oe,X,W,I,F,G,U,V,Vn,pe,p,lt]),mc=g.useCallback(Te=>{Us(Te),dc(null),ta(null),Be(!0)},[ta,Be]),em=g.useCallback(Te=>{ta(null),W("work"),i.set(`$openpond-refiner-authoring ${Te}`),p("chat"),Be(!0)},[ta,i,W,Be,p]),Sr=g.useCallback(Te=>{dc(H6(Te)),Us(null),ta(null),Be(!0)},[ta,Be]);g.useEffect(()=>{!Ls&&!zs||te!=="chat"||Z||xe||Ie||($s(Ls),Ds(zs),Us(null),dc(null),G("home"),oe(!1),X(!0))},[Ls,zs,Ie,xe,Z,oe,X,G,te]),g.useEffect(()=>{!Os&&!Ns||te==="chat"&&be&&ge==="home"||($s(null),Ds(null))},[be,Ns,Os,ge,te]);const tm=g.useCallback(()=>{$s(null),Ds(null),oe(!1),X(!1)},[oe,X]),nm=g.useCallback(Te=>{let ct;if(Te.workspaceKind==="local"){const Mt=vt("local",Te.workspaceId);ct=`draft:${Mt}`,U(null),V(Mt),le(null),Fa(Mt),p("chat")}else{const Mt=lt.find(ua=>ua.id===Te.sourceSessionId||ua.workspaceId===Te.workspaceId);if(!Mt){bt("This saved file's cloud chat is no longer available.","error");return}ct=Mt.id,En(Mt.id)}G("changes"),X(!0),Hs({id:Date.now(),conversationId:ct,file:Te}),Te.available||bt(`File unavailable: ${Te.path}`,"error")},[Fa,En,X,G,U,V,le,p,bt,lt]);g.useEffect(()=>{if(!U6(Za,pn))return;const Te=window.setTimeout(()=>{G("changes"),X(!0),Hs(ct=>z6(ct,Za.id))},0);return()=>window.clearTimeout(Te)},[pn,X,G,Za]);const am=K6(te);g.useEffect(()=>{if(r){if(r.kind==="models"||r.kind==="models_unavailable"){te!=="labs"&&p("labs");return}if(r.kind==="settings"){U(null),V(null),le(null),fe(r.section),te!=="settings"&&p("settings");return}if(r.kind==="view"){U(null),V(null),le(null),te!==r.view&&p(r.view);return}r.sessionId!==null&&(U(null),V(null)),le(r.sessionId),te!=="chat"&&p("chat")}},[r,U,V,le,fe,p,te]);const om=g.useCallback(Te=>{if(rt(null),U(null),V(null),le(null),Te==="models"){ji(ro()),p("labs");return}Te==="chat"&&ln({kind:"chat",sessionId:null}),qe(Ig())},[qe,ln,rt,U,V,le,p]),rm=g.useCallback(async(Te,ct)=>{const Mt=await Ut.actions.acceptHarnessReview(Te,ct,{providerId:Tn,modelId:$n},he);return Mt?(y(Mt.materializedTasksetId??null),ji(ro()),p("labs"),!0):(bt("Taskset review could not be opened.","error"),!1)},[$n,Tn,he,ji,ro,y,p,bt,Ut.actions]);if(!sn.ready)return x.jsx(o6,{startup:sn});if(te==="settings")return x.jsx(cy,{showToast:bt,children:x.jsx(e6,{settings:{payload:Nt,connection:yt,diagnostics:Fu,initialSection:ie,onPayload:rn,onError:nn,onToast:bt,onOpenSourceSession:En,onStartRefinerAuthoring:em,onAcceptEvaluationReview:rm,onOpenSkill:mc,onOpenExtension:Sr,teamChatCurrentUserId:kt.currentUserId,teamChatEnabled:ea!==null,teamChatNotificationMode:kt.notificationMode,teamChatThreads:kt.threads,onTeamChatNotificationModeChange:kt.setNotificationMode,onTeamChatThreadMuteChange:kt.setThreadMuted,diffPanelWidth:qn,diffPanelResizing:ot,diffPanelExpanded:ne,onDiffPanelResizeStart:ae,onDiffPanelExpandedChange:oe,onBack:()=>{const Te=A4(r);ln(Te),p(Te.kind==="models"?"labs":"chat"),Be(!0)}},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})});const im=eu(),Bs=yt?.platform??navigator.platform,pc=im&&rg(Bs),Fs=Fo,sm=vo?.initialized?vo.repoPath:gt?.cwd??null,lm={"--sidebar-width":`${ia}px`,"--diff-panel-width":`${qn}px`},cm=te==="chat"&&ke!=="chat"||te==="labs"||te==="scheduled"&&n||te==="team"&&!!ur,dm=["app-shell",pc?"platform-macos":"",de?"sidebar-open":"sidebar-closed",qt?"sidebar-resizing":"",ot?"diff-panel-resizing":""].filter(Boolean).join(" "),at=Z?ei[Z]:null,Xt=Z?at?.cursorSequence??s6(Io(ms,Zl(Ct,Z))):null,Gt=!!Z&&!!yt&&(Ht(Z)?!0:!!Nt?.eventWindow?.hasMoreBefore&&!!Xt)&&(at?.hasMore??!0),Ca=!!at?.loading,um=(()=>{const Te=Ut.payload;if(!Te)return{};const ct=new Map(Te.plans.map(bn=>[bn.id,bn])),Mt=new Set(["queued","starting","running","cancelling","reconciling"]),ua={queued:"Queued",starting:"Starting",running:"Running",cancelling:"Cancelling",reconciling:"Reconciling"},bo={};for(const bn of[...Te.modelRuns].sort((Ra,fi)=>fi.updatedAt.localeCompare(Ra.updatedAt))){if(bn.kind==="evaluation"||!["prepared","running"].includes(bn.status))continue;const Ra=Te.jobs.filter(mm=>mm.metadata.modelRunId===bn.id).sort((mm,D_)=>D_.updatedAt.localeCompare(mm.updatedAt))[0];if(Ra&&!Mt.has(Ra.status))continue;const fi=Ra?.status??(bn.status==="prepared"?"starting":"running");bo[bn.modelId]={label:ua[fi]??"Running",status:fi}}for(const bn of[...Te.jobs].sort((Ra,fi)=>fi.updatedAt.localeCompare(Ra.updatedAt))){if(!Mt.has(bn.status))continue;const Ra=ct.get(bn.planId)?.modelId;!Ra||bo[Ra]||(bo[Ra]={label:ua[bn.status]??"Active",status:bn.status})}return bo})();return x.jsx(cy,{showToast:bt,children:x.jsx(X3,{className:dm,style:lm,sidebar:{productArea:am,modelProjects:(Ut.payload?.modelProjects??[]).filter(Te=>Te.hosted===null||Te.hosted.teamId===(Ha.defaultTeamId?.trim()??null)),modelTrainingActivityByProjectId:um,onProductAreaChange:om,experience:ke,view:te,selectedAppId:Ie,selectedProjectId:xe,selectedSessionId:Z,selectedTeamThreadId:kt.selectedThreadId,teamChatEnabled:ea!==null,organizations:uo,teamChatOrganization:qa,teamChatLoading:kt.loading,currentUserId:kt.currentUserId,teamMembers:kt.members,teamThreads:kt.threads,...ca,account:kn,connection:yt,profile:Nt?.profile,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Da,archivedChatsOpen:B,cloudProjectsExpanded:K,sectionMenuOpen:N,dragItem:ui,taskDragSessionId:vs,taskPreviewSessionIds:vr,activeSessions:Va,archivedSessions:po,pinnedRows:mi,pinnedSessions:Fn,savedForLaterSessions:ps,savedForLaterFiles:fs,projectRows:Ia,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:hs,childSessionRowsByParentId:gs,sidebarProjectIdBySessionId:ho,terminalSummaries:gr,runningSessionIds:go,goalRuntimeBySessionId:Wa,subagentRuntimeBySessionId:si,visibleChatRows:ai,chatRows:pr,chatRowsVisibleCount:fr,expandedProjectIds:is,currentVersion:Nt?.server.version??null,platform:Bs,arch:yt?.arch??null,onSidebarResizeStart:za,setSidebarOpen:Be,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setSearchOpen:Xe,setSectionMenuOpen:rt,setSettingsSection:fe,onSelectTeam:Wu,onLogOut:Gu,onTogglePinnedCollapsed:xn,onToggleCloudProjectsCollapsed:La,onToggleChatsCollapsed:Ua,onToggleSavedForLaterCollapsed:sa,setArchivedChatsOpen:et,setCloudProjectsExpanded:it,setChatRowsVisibleCount:Me,beginNewChat:Ku,beginProjectChat:pi,dockSessionRight:Ms,selectTeamThread:Te=>{p("team"),kt.selectThread(Te)},openTeamDm:Te=>{p("team"),kt.openDm(Te)},toggleSessionPinned:nc,toggleProjectPinned:ac,toggleSessionSavedForLater:Ts,openSidebarFile:nm,setSidebarFileStatus:(Te,ct)=>{ni(Te,ct)},archiveSession:Cu,restoreSession:Ru,renameSession:tc,removeProject:Vu,expandProject:Fa,toggleProjectExpanded:ss,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:ys,commitPinnedDrop:Ss,commitPinnedPreviewDrop:xs,startTaskDrag:li,clearTaskDrag:ci,previewTaskDrop:di,commitTaskDrop:bs,commitTaskPreviewDrop:br},topBar:{sidebarOpen:de,title:Kn,backAction:_e.backAction,breadcrumbs:_e.breadcrumbs,conversationId:te==="chat"?Z:null,workspaceName:Zr,workspaceId:Wr,busy:ue,workspaceState:vo,workspaceKind:Gr,selectedApp:xt??Ke,selectedProject:Ze,workspaceDiff:Nn,managedWorkspace:_s,workspaceBusy:yr,defaultTeamId:Ha.defaultTeamId,showDiffControls:te==="chat"&&ke==="development",diffPanelOpen:be,terminalOpen:Se,rightSidebarAvailable:cm,rightSidebarOpen:te==="scheduled"?n:be,onToggleDiffPanel:cc,onToggleRightSidebar:te==="scheduled"?()=>a(Te=>!Te):te==="team"&&ur?mr:cc,onOpenSearch:()=>{rt(null),Xe(!0)},onToggleTerminal:()=>pe(Te=>!Te),onRunTerminalCommand:Te=>{m({id:Date.now(),scope:Fs,command:Te}),pe(!0)},onWorkspaceToolAction:fu,onOpenCommitDialog:Ps,onWorkspaceBranchChange:mu,onWorkspaceBranchCreate:Yl,connection:yt,onBootstrap:rn,onOpenSandboxWorkspace:Tu,onShowSidebar:()=>Be(!0),onOpenTeamChat:uc,onDiscoverCommunities:Qu,collaborationView:te==="team"||te==="community"?te:null,platform:Bs,showWorkspaceControls:te!=="team"&&te!=="community"&&te!=="labs"&&te!=="scheduled"&&te!=="outputs"&&te!=="projects"&&(ke==="development"||ke==="work"&&!!(Ze||gt?.localProjectId||gt?.cloudProjectId||gt?.workspaceKind==="local_project"))},mainPane:{experience:ke,onNewExperienceChange:qe,view:te,teamChat:{currentUserId:kt.currentUserId,members:kt.members,agents:kt.agents,profile:Nt?.profile??null,teamId:ea,teamName:qa?.displayName??null,detail:kt.detail,aiThread:kt.aiThread,agentConversation:kt.agentConversation,loading:kt.loading,busy:kt.busy,error:kt.error,connection:yt,providerSettings:Nt?.providers??null,provider:Tn,model:$n,codexPermissionMode:Ae,codexReasoningEffort:he,openPondCommandAccessMode:mo,contextWindowStatus:_a,showToast:bt,onProviderChange:Ql,onModelChange:I,onCodexPermissionModeChange:Jr,onCodexReasoningEffortChange:Yr,onOpenPondCommandAccessModeChange:Qr,onOpenProviderSettings:()=>{fe("providers"),p("settings"),ln({kind:"settings",section:"providers"})},onSendMessage:kt.sendMessage,onPublishProfileAgent:Ba,onOpenAiThread:async Te=>{await kt.openAiThread(Te),G("chat"),X(!0)},onOpenAgentConversation:async Te=>{await kt.openAgentConversation(Te),G("chat"),X(!0)},onCloseAiThread:()=>X(!1),onCloseAgentConversation:()=>{kt.closeAgentConversation(),X(!1)},onSendAgentTurn:kt.sendAgentTurn,onSendAiTurn:kt.sendAiTurn,onStopAiTurn:kt.stopAiTurn,onEditMessage:kt.editMessage,onDeleteMessage:kt.deleteMessage,onRetryMessage:kt.retryMessage,onDismissFailedMessage:kt.dismissFailedMessage,onLoadMoreMessages:kt.loadMoreMessages,onRetryLoad:kt.refresh},community:Vr,bootstrap:Nt,runtimeEvents:oi,chatMessages:da,pendingUserMessage:Z?St[Z]??null:null,contextWindowStatus:_a,goalRuntime:hr,subagentRuntime:ri,selectedSessionId:Z,composerDraftStore:i,mainComposerFocusRequestId:$,labCloseDetailRequestId:_e.closeDetailRequestId,labCloseDetailKind:_e.closeDetailKind,sideChatTrainingLaunchRequest:sc,onSideChatTrainingLaunchHandled:Te=>Ou(ct=>ct?.id===Te?null:ct),mentionApps:Bn,connectedAppMentions:tt,profileSkills:Yu,selectedMentionAppId:w,busy:ue,turnRunning:ii,activeProvider:Tn,activeModel:$n,codexPermissionMode:Ae,codexReasoningEffort:he,openPondCommandAccessMode:mo,pendingApproval:_n,activeWorkspaceAppId:Kr,activeWorkspaceId:Wr,activeWorkspaceKind:Gr,projectTarget:mt,actionCatalog:rs,workspaceTarget:Bt,connection:yt,workspaceName:Zr,workspaceState:vo,workspaceDiff:Nn,workspaceBusy:yr,diffBusy:ws,forceChatThread:!!Z,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:ge,rightPanelTabRequest:P,rightChatPanels:Nu,runtimeEventStore:la,nativeSkillSidebar:Os,extensionSkillSidebar:Ns,workspaceDiffPanelViewState:L,sidebarFileOpenRequest:Za,sidebarFileBookmarks:vn,onSetSidebarFileStatus:(Te,ct)=>{ni(Te,ct)},browserConversationId:pn,terminalScope:Fs,terminalTabs:u,terminalCwd:sm,pendingTerminalCommand:l,terminalOpen:Se,onToggleTerminal:()=>pe(Te=>!Te),onWorkspaceDiffPanelViewStateChange:na,training:Ut,trainingSessions:lt,trainingChatHandoff:us,trainingDetailTasksetId:b,onTrainingDetailTasksetIdChange:y,onTrainingChatTaskSelect:Xr,onTrainingChatHandoffDismiss:ds,onOpenSession:En,onExperienceHandoff:Xu,cloudProjects:Nt?.cloudProjects??[],projects:Zu,projectsAccountBaseUrl:kn?.baseUrl??kn?.activeProfile?.baseUrl??null,projectsTeamName:qa?.displayName??null,projectTaskCounts:Ju,onNewCloudProject:rc,onNewProjectTask:Te=>pi(Te.id),onToggleProjectPinned:ac,onUploadLocalProject:Pu,chatHistoryHasMore:Gt,chatHistoryLoading:Ca,onDiffPanelResizeStart:ae,onToggleDiffPanelExpanded:()=>oe(Te=>!Te),onShowDiffPanel:Mu,onShowBrowserPanel:ic,onShowFilesPanel:()=>Ko("files"),onShowGoalSidebarTab:ju,onShowTrainingDraftPanel:()=>{G("training"),X(!0)},onShowRightChatPanel:Du,onAddRightChat:()=>Ms(null),onOpenRightChatForSession:(Te,ct)=>{const Mt=ct??lt.find(ua=>ua.id===Te)??null;Mt&&Ms(Mt,{preserveView:!0})},onLabDetailOpenChange:_e.onDetailOpenChange,scheduledDetailOpen:n,onScheduledDetailOpenChange:a,onTerminalTabsChange:h,onCloseRightChatPanel:$u,onCloseNativeSkillSidebar:tm,onActivateRightChatPanel:Lu,onRightChatModelChange:Uu,onRightChatPromptChange:zu,onRightChatScrollStateChange:qu,onRightChatProviderChange:Hu,onSubmitRightChat:lc,onStopRightChat:Te=>As(Te),onCloseTerminal:()=>pe(!1),onLoadMoreChatHistory:ti,canSyncWorkspace:Cs,startMessage:wa,onPayload:rn,onError:nn,setView:p,onOpenProfileSettings:Bu,onOpenProviderSettings:()=>{ln({kind:"settings",section:"providers"})},onOpenTrainingSettings:()=>{ln({kind:"settings",section:"training"})},onOpenDatasetStorageSettings:()=>{ln({kind:"settings",section:"dataset-storage"})},changeDraftProvider:Ql,changeProjectTarget:du,changeWorkspaceTarget:Au,setDraftProvider:F,setDraftModel:I,onBeginNewChatWithModel:cs,changeCodexPermissionMode:Jr,changeCodexReasoningEffort:Yr,changeOpenPondCommandAccessMode:Qr,resolveApproval:ls,answerCreateImproveQuestion:bu,applyCreateImproveCandidate:yu,approveCreateImproveRun:Su,cancelCreateImproveRun:xu,openCreateImprovePullRequest:ku,reconcileCreateImprovePullRequest:Xl,rejectCreateImproveCandidate:wu,pauseCreateImproveRun:Iu,resumeCreateImproveRun:_u,reviseCreateImproveRun:ec,setMentionedAppId:_,showToast:bt,onSaveTaskDraft:qs,sendPrompt:Es,stopTurn:Te=>As(void 0,Te),syncWorkspaceLocally:vu,refreshWorkspaceDiff:Is},cloudSetup:{state:E,onClose:()=>j(null),onOpenBrowserUrl:Eu,onStart:()=>{oc()}},projectConfirm:{state:k,onResolve:C},lazyPanels:{activeSessions:Va,branchDialogName:Q,branchDialogOpen:H,commitDialogOpen:Le,commitDraft:M,commitIncludeUnstaged:De,commitMessage:Fe,commitNextStep:D,canPublishOpenPondProject:Rs,connection:yt,expandProject:Fa,newProjectBusy:st,newProjectDialogOpen:we,newProjectDirectory:Ha.defaultNewProjectDirectory,newProjectMode:Oe,newProjectName:Qe,newProjectPath:Ge,projectRows:ks,query:A,searchOpen:z,visibleWorkspaceDiff:Nn,visibleWorkspaceState:vo,workspaceBusy:yr,appDispatch:s,beginNewChat:()=>ta(null),openDefaultsSettingsFromBranchDialog:pu,setBranchDialogName:Sn,setBranchDialogOpen:An,setCommitDialogOpen:Ve,setCommitDraft:Lt,setCommitIncludeUnstaged:ut,setCommitMessage:Ue,setCommitNextStep:Qt,setNewProjectDialogOpen:je,setNewProjectName:Ee,setNewProjectPath:Ne,setPrompt:re,setQuery:$e,setSearchOpen:Xe,submitCommitDialog:hu,submitCreateWorkspaceBranch:gu,submitNewProjectDialog:uu},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})})}const Ci=new Map,Kc=new Map;function bf(e){if(!e||e.state!=="signed_in")return null;const t=e.accounts.find(r=>r.isActive)??null,n=e.activeProfile?.handle?.trim()||t?.handle?.trim()||e.label.trim()||"signed_in",a=e.activeProfile?.baseUrl??t?.baseUrl??e.baseUrl??"";return[n,a,e.apiBaseUrl??"",e.chatApiBaseUrl??""].join("|")}function aV(e){const t=e?.trim();if(!t)return null;const n=Ci.get(t);return n?.updatedAt?n.organizations:null}function oV(e,t){const n=e?.trim();if(n){Ci.set(n,{organizations:t,promise:null,updatedAt:Date.now()});for(const a of Kc.get(n)??[])a()}}function rV(e,t){const n=e?.trim();if(!n)return()=>{};const a=Kc.get(n)??new Set;return a.add(t),Kc.set(n,a),()=>{a.delete(t),a.size===0&&Kc.delete(n)}}function by(e){const t=e.accountKey?.trim();if(!t)return Promise.resolve([]);const n=Ci.get(t);if(!e.force){if(n?.updatedAt)return Promise.resolve(n.organizations);if(n?.promise)return n.promise}const a=e.fetchOrganizations().then(r=>(oV(t,r),r)).catch(r=>{const i=Ci.get(t);throw i?.promise===a&&Ci.set(t,{organizations:i.organizations,promise:null,updatedAt:i.updatedAt}),r});return Ci.set(t,{organizations:n?.organizations??[],promise:a,updatedAt:n?.updatedAt??0}),a}const CJ="openpond.config.json";function RJ(e,t,n){return t<=0?-1:n==="Home"?0:n==="End"?t-1:n==="ArrowRight"?(e+1)%t:(e-1+t)%t}function OI(){return{activeTab:"files",openFilePaths:[],selectedPath:null}}function cp(e){return{activeTab:e.activeTab,openFilePaths:[...e.openFilePaths],selectedPath:e.selectedPath}}function PJ(e,t=null){const n=sV(e.openFilePaths.map(r=>Sy(r,t)).filter(Boolean)),a=e.selectedPath&&Sy(e.selectedPath,t)||null;return{activeTab:e.activeTab==="file"&&!a?"files":e.activeTab,openFilePaths:n,selectedPath:a}}function yy(e,t){return e.activeTab===t.activeTab&&e.selectedPath===t.selectedPath&&e.openFilePaths.length===t.openFilePaths.length&&e.openFilePaths.every((n,a)=>n===t.openFilePaths[a])}function Sy(e,t=null){let n=iV(e);const a=t?.trim().replace(/\\/g,"/").replace(/\/+$/,"");if(!a)return n;if(n===a)return"";n.startsWith(`${a}/`)&&(n=n.slice(a.length+1));const r=a.split("/").filter(Boolean).at(-1);return r&&n.startsWith(`${r}/`)&&(n=n.slice(r.length+1)),n}function AJ(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function TJ(e){return{path:e,status:"unchanged",additions:0,deletions:0,patch:"",content:null}}function EJ(e,t){const n=xy(e.path);return!n||e.path.endsWith("/")||e.content==null&&/Could not access .+\/null['"]?/.test(e.patch)?!0:t.some(a=>{const r=xy(a);return!!(r&&r.startsWith(`${n}/`))})}function MJ(e){return/\.(?:md|markdown|mdx)$/i.test(e)||/(?:^|\/)readme$/i.test(e)}function jJ(e){return/\.(?:doc|docx|pdf)$/i.test(e)}function iV(e){let t=e.trim().replace(/^['"`]+|['"`]+$/g,"");if(/^file:\/\//i.test(t))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.replace(/^file:\/\//i,"")}return t.replace(/\\/g,"/").replace(/^\.\/+/,"")}function sV(e){return Array.from(new Set(e))}function xy(e){const n=e.replace(/\\/g,"/").replace(/^\.\/+/,"").split("/").filter(Boolean);return n.length===0?null:n.join("/")}function lV(e){if(!e||e.state!=="signed_in")return null;const t=e.accounts.find(l=>l.isActive)??null,n=e.profile?.id?.trim()??"",a=e.activeProfile?.handle?.trim()||t?.handle?.trim()||e.label.trim()||"signed_in",r=e.activeProfile?.baseUrl??t?.baseUrl??e.baseUrl??"",i=e.apiBaseUrl??t?.apiBaseUrl??"",s=e.chatApiBaseUrl??t?.chatApiBaseUrl??"";return[n?`profile:${n}`:"profile:unknown",a,r,i,s].join("|")}function $I(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"cloud-project"}function cV(e){const t=new TextEncoder().encode(e);let n="";for(const a of t)n+=String.fromCharCode(a);return btoa(n)}function au(e){const t=e,n=t.teamId||t.id||"";if(!n)return null;const a=t.displayName||t.name||n,r=t.workspaceKind==="personal"||t.isPersonalDefault===!0||t.kind==="personal_default"||t.name?.trim().toLowerCase()==="personal";return{teamId:n,slug:t.slug||$I(a),name:t.name||a,displayName:a,role:t.role==="owner"||t.role==="admin"||t.role==="member"?t.role:"member",workspaceKind:t.workspaceKind==="personal"||t.workspaceKind==="shared"?t.workspaceKind:r?"personal":"shared",status:t.status==="disabled"||t.status==="archived"?t.status:"active",kind:t.kind==="personal_default"||t.kind==="managed_client"||t.kind==="team"?t.kind:void 0,isPersonalDefault:r,isManagedClient:t.isManagedClient===!0||t.kind==="managed_client",primaryContactEmail:t.primaryContactEmail??null,customDomain:t.customDomain??null,planKey:typeof t.planKey=="string"?t.planKey:null,effectiveAccessState:t.effectiveAccessState==="checkout_pending"||t.effectiveAccessState==="active"||t.effectiveAccessState==="grace"||t.effectiveAccessState==="suspended"||t.effectiveAccessState==="cancelling"||t.effectiveAccessState==="cancelled"?t.effectiveAccessState:null,canManageBilling:t.canManageBilling===!0||t.role==="owner",createdAt:t.createdAt??"",updatedAt:t.updatedAt??""}}function dV(e){return e.find(t=>t.workspaceKind==="personal"||t.isPersonalDefault===!0||t.kind==="personal_default")??e.find(t=>t.name.trim().toLowerCase()==="default")??e.find(t=>t.isManagedClient!==!0&&t.kind!=="managed_client")??e[0]??null}function uV(e,t){const n=e.filter(r=>r.status==="active"&&r.workspaceKind==="shared"),a=t?.trim()??"";if(a){const r=n.find(i=>i.teamId===a);if(r)return r}return n.find(r=>r.role==="owner")??n.find(r=>r.role==="admin")??n[0]??null}function mV(...e){for(const t of e){const n=t?.trim();if(n)return n}return""}function pV({draftProvider:e,hasSelectedCloudProject:t,selectedSessionHybridWorkspace:n}){return t&&!n?"openpond":e}const fV=[{value:"action:new-local-project",label:"New local project",detail:"Create a new project folder on this machine",kind:"action"},{value:"action:add-local-project",label:"Use existing folder",detail:"Choose a folder on this machine",kind:"action"},{value:"action:add-local-project-path",label:"Use existing folder path",detail:"Enter a local folder path manually",kind:"action"},{value:"action:new-cloud-project",label:"New cloud project",detail:"Create a project in OpenPond Cloud",kind:"action"},{value:"action:create-cloud-environment",label:"Create cloud environment",detail:"Set up compute for a cloud project",kind:"action"}];function hV(...e){return mV(...e.map(t=>{const n=t?.trim();return n&&!n.includes("@")?n:null}))}function gV(e){if(e?.state!=="signed_in")return"";const t=e.accounts.find(n=>n.isActive)??null;return hV(e.profile?.name,e.label,t?.displayLabel,e.profile?.handle,t?.handle,e.activeProfile?.handle)}function vV({bootstrap:e,draftModel:t,draftProvider:n,selectedApp:a,selectedAppId:r,selectedCloudProject:i,selectedProject:s,selectedSession:l,selectedSessionId:m,selectedSessionLinkedProject:u}){const h=l?.workspaceKind==="local_project"?l.workspaceId??null:u?.id??null,b=Ht(m)&&!l,y=l?lo(l.workspaceKind):!1,w=co(l),_=l?X6(l):!1,E=l?.cwd&&(!y||w)?tx(l.cwd):null,j=e?.providers??null,P=Sa(s,e?.cloudProjects??[]),L=pV({draftProvider:n,hasSelectedCloudProject:!!i,selectedSessionHybridWorkspace:w}),$=cr(L,t,j),O=pa(e?.preferences),k=b?null:l?y?l.workspaceKind??"sandbox":_?"sandbox":h?"local_project":l.workspaceKind??(l.appId?"sandbox_app":E?"local_project":null):i?"sandbox":s?"local_project":r?"sandbox_app":null,C=b?null:l?y&&!w||_?null:h||(l.workspaceId??l.appId??E):i?null:s?.id??r,A=b?null:l?y?l.workspaceId??null:_?null:h??l.workspaceId??l.appId??E:i?null:s?.id??r,z=e?.account??null,B=!e||z?.state==="loading"||z?.state==="switching",N=!B&&z?.state==="signed_out",K=B?null:N?"Sign in":z?.label??z?.activeProfile?.handle??"Account",de=gV(z),te=de?`Welcome, ${de}`:"Welcome",Ie=l?.workspaceName??l?.appName??i?.name??s?.name??a?.name??null,xe=lo(k)?"cloud":"local",Z=s?.name??u?.name??(l?.workspaceKind==="local_project"?l.workspaceName:null)??"Local workspace",Ae=(xe==="cloud"?Ie:null)??i?.name??P?.name??s?.name??"Cloud workspace",he=!!(i?.id||P?.id||l?.cloudProjectId||xe==="cloud");return{account:z,accountLabel:K,accountPending:B,accountSignedOut:N,activeModel:$,activeProvider:L,activeWorkspaceAppId:C,activeWorkspaceId:A,activeWorkspaceKind:k,activeWorkspaceLocation:xe,appDefaults:O,cloudLinked:he,cloudTargetName:Ae,localTargetName:Z,selectedCodexHistoryPending:b,selectedSessionCloudWorkspace:y,selectedSessionLocalPathWorkspaceId:E,selectedSessionPendingCloudStart:_,selectedSessionProjectId:h,startMessage:te,workspaceName:Ie}}function bV({accountPending:e,accountSignedOut:t,activeWorkspaceLocation:n,bootstrap:a,busy:r,cloudLinked:i,selectedCloudProject:s,selectedProject:l,selectedSession:m,pendingWorkspaceTarget:u,workspaceStates:h,workspaceBusy:b}){const y=Sa(l,a?.cloudProjects??[]),_=!!!l?.linkedSandboxProject?.projectId||!!y,E=g.useMemo(()=>{const A=(a?.localProjects??[]).map(K=>({value:`local:${K.id}`,label:K.name,detail:K.workspacePath,kind:"local"})),z=(a?.cloudProjects??[]).map(K=>({value:`cloud:${K.id}`,label:K.name,detail:K.organizationName??K.sourceLabel??"OpenPond Cloud",kind:"cloud"})),B=l?`local:${l.id}`:s?`cloud:${s.id}`:"none",N=[...A,...z].find(K=>K.value===B)??null;return{value:B,label:N?.label??"Select Project",detail:N?.detail??"Choose a project for local or cloud work",busy:b||r,options:[...A,...z,...fV,{value:"none",label:"Don't work in a project",detail:"General chat without project files",kind:"none"}]}},[a?.cloudProjects,a?.localProjects,r,s,l,b]),j=!!(i||l),P=!!(s?.id||y?.id||m?.cloudProjectId||co(m)),L=l?h[l.id]??null:null,$=Y1(L,{branch:l?.linkedSandboxProject?.defaultBranch??null,path:l?.workspacePath??m?.cwd??null,linkedCloudSourceKnown:l?.linkedSandboxProject?.projectId&&_?!!l.linkedSandboxProject.lastUploadedCommit||!L?.headCommit:!0}),O=Q1(l,s??y,L,{cloudLinkTrusted:_}),k=u5(l,L,{cloudLinkTrusted:_}),C=g.useMemo(()=>{const A={value:"local",label:l?"Local checkout":"Local",detail:l?"Use the selected checkout on this machine.":"Use an app-managed task workspace on this machine.",stateNote:l?$:"App-managed local task workspace",disabled:!1,disabledReason:null},z={value:"hybrid",label:"Hybrid",detail:"Use your selected model with hosted sandbox edits.",stateNote:P?O:"upload required",disabled:e||t||!P,disabledReason:t?"Add an OpenPond account before using Hybrid.":"Upload/sync this Project to Cloud before using Hybrid."},B={value:"cloud",label:"Hosted",detail:"Run with hosted compute, with or without a Project.",stateNote:l||s?O:"Projectless hosted task",disabled:e||t,disabledReason:t?"Add an OpenPond account before using Cloud.":e?"Checking OpenPond account.":null},N={value:"upload_cloud",label:"Upload/sync to cloud",detail:"Push local source to OpenPond Git before cloud work.",stateNote:k,disabled:e||t||!l,disabledReason:t?"Add an OpenPond account before uploading source.":"Select a local Project before uploading source."},K=n==="cloud"?"local":"cloud",de=K==="local"?A:B;let te=n==="cloud"?B:A;return u==="cloud"?te=B:u==="local"?te=A:(co(m)||u==="hybrid")&&(te=z),{value:te.value,label:te.label,detail:te.stateNote||te.detail,busy:b,action:{...de,label:K==="cloud"?"Hosted":l?"Local checkout":"Check out locally"},uploadAction:l?N:null,options:[A,z,B]}},[n,e,t,i,j,O,P,$,u,l,m,k,b]);return{projectTarget:E,workspaceTarget:C}}function jn(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function NI(e){return jn(e.name||e.gitRepo||e.id)}function OJ(e){return`@${NI(e)}`}function DI(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function yV(e,t){const n=DI(e);if(n.length===0)return!1;const a=new Set([jn(t.id),NI(t),t.gitRepo?jn(t.gitRepo):""].filter(Boolean));return n.some(r=>a.has(r))}function LI(e){return e.filter(t=>t.sandbox)}function SV(e,t){const n=DI(e);if(n.length===0)return null;const a=new Map;for(const r of n){const i=t.find(s=>{const l=jn(s.id),m=jn(s.name),u=s.gitRepo?jn(s.gitRepo):"";return r===l||r===m||r===u});i&&a.set(i.id,i)}return a.size===1?Array.from(a.values())[0]??null:null}function $J(e,t){const n=e.slice(0,t),a=n.match(/(?:^|\s)@([A-Za-z0-9_-]*)$/);if(!a||typeof a.index!="number")return null;const r=n.slice(a.index).indexOf("@");return r<0?null:{query:jn(a[1]??""),start:a.index+r}}function xV(e){return new Set(e.map(t=>t.id))}function ky(e,t){const n=e?.linkedOpenPondApp??null;return n?.appId&&t.has(n.appId)?n:null}function kV({bootstrap:e,codexHistorySessions:t,selectedProjectId:n,selectedSessionId:a,selectedAppId:r,sessions:i}){const s=g.useMemo(()=>e?.apps.find(N=>N.id===r)??null,[e?.apps,r]),l=g.useMemo(()=>new Map((e?.localProjects??[]).map(N=>[N.id,N])),[e?.localProjects]),m=g.useMemo(()=>new Map((e?.cloudProjects??[]).map(N=>[N.id,N])),[e?.cloudProjects]),u=g.useMemo(()=>U1(n),[n]),h=g.useMemo(()=>u?.kind==="local"?l.get(u.id)??null:null,[l,u]),b=g.useMemo(()=>u?.kind==="cloud"?m.get(u.id)??null:null,[m,u]),y=g.useMemo(()=>xV(e?.apps??[]),[e?.apps]),w=g.useMemo(()=>LI(e?.apps??[]),[e?.apps]),_=g.useMemo(()=>{const N=[];for(const K of e?.localProjects??[]){const de=ky(K,y);de&&N.push([de.appId,K.id])}return new Map(N)},[e?.localProjects,y]),E=g.useMemo(()=>new Set((e?.localProjects??[]).map(N=>N.id)),[e?.localProjects]),j=g.useMemo(()=>V1(e?.localProjects??[]),[e?.localProjects]),P=g.useRef([]),L=g.useMemo(()=>wV(i,t,P.current),[t,i]),$=g.useMemo(()=>L.find(N=>N.id===a)??null,[L,a]),O=g.useMemo(()=>{if(!$)return null;if($.localProjectId)return l.get($.localProjectId)??null;if($.workspaceKind==="local_project")return $.workspaceId?l.get($.workspaceId)??null:null;const N=X4($,E,j);if(N)return l.get(N)??null;if(!$.appId)return null;const K=_.get($.appId);return K?l.get(K)??null:null},[_,l,E,j,$]),k=g.useMemo(()=>$?.cloudProjectId?m.get($.cloudProjectId)??null:null,[m,$]),C=h??O,A=b??k,z=g.useMemo(()=>ky(C,y),[y,C]),B=g.useMemo(()=>z?e?.apps.find(N=>N.id===z.appId)??null:null,[e?.apps,z]);return{cloudProjectById:m,currentAppIds:y,linkedProjectByAppId:_,localProjectById:l,mentionableSandboxApps:w,selectedApp:s,selectedCloudProject:A,selectedProject:C,selectedProjectLinkedApp:B,selectedProjectLinkedOpenPondApp:z,selectedSession:$,selectedSessionLinkedProject:O,sidebarSessions:L}}function wV(e,t,n){const a=new Map;for(const u of e){const h=wy(u);a.set(h,u)}for(const u of t){const h=wy(u),b=a.get(h);a.set(h,b?IV(b,u):u)}const r=Array.from(a.entries());if(!n)return r.sort((u,h)=>Iy(u[1],h[1])).map(u=>u[1]);const i=[],s=new Set;for(const u of n){const h=a.get(u);h&&(i.push([u,h]),s.add(u))}const m=[...r.filter(([u])=>!s.has(u)).sort((u,h)=>Iy(u[1],h[1])),...i];return n.splice(0,n.length,...m.map(([u])=>u)),m.map(u=>u[1])}function IV(e,t){return{...e,metadata:_V(e.metadata,t.metadata),status:e.status==="active"||t.status==="active"?"active":e.status,updatedAt:CV(e.updatedAt,t.updatedAt)}}function wy(e){return e.codexThreadId?`codex:${e.codexThreadId}`:`session:${e.id}`}function Iy(e,t){const n=_y(t)-_y(e);return n!==0?n:e.title.localeCompare(t.title)}function _V(e,t){const n={...e??{},...t??{}};return Object.keys(n).length>0?n:void 0}function CV(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return t;const a=Date.parse(t);return Number.isFinite(a)&&a>n?t:e}function _y(e){const t=Date.parse(e.updatedAt);if(Number.isFinite(t))return t;const n=Date.parse(e.createdAt);return Number.isFinite(n)?n:0}function RV(e){return!!(e&&lo(e.workspaceKind)&&!co(e)&&e.provider!=="openpond")}function PV(e,t){const n=q1(e,t);return`${e.id}\0${n.provider}\0${n.model}`}function AV({activeWorkspaceId:e,activeWorkspaceKind:t,appDispatch:n,connection:a,expandProject:r,linkedProjectByAppId:i,providerSettings:s,selectedAppId:l,selectedSession:m,selectedSessionId:u,selectedSessionProjectId:h,setDiffPanelExpanded:b,setDraftModel:y,setDraftProvider:w,setError:_,setSelectedAppId:E,setSelectedProjectId:j,setSessions:P,setTerminalOpen:L,toast:$}){const O=g.useRef(null);g.useEffect(()=>{if(!l)return;const k=h??(u?null:i.get(l)??null);if(!k)return;const C=vt("local",k);E(null),j(C),r(C)},[r,i,l,u,h,E,j]),g.useEffect(()=>{if(!$||$.persistent)return;const k=window.setTimeout(()=>{n({type:"clearToast",toastId:$.id})},$.durationMs??($.tone==="error"?7e3:3500));return()=>window.clearTimeout(k)},[n,$]),g.useEffect(()=>{function k(C){(C.metaKey||C.ctrlKey)&&C.key==="`"&&(C.preventDefault(),L(A=>!A))}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[L]),g.useEffect(()=>{b(!1)},[e,t,b]),g.useEffect(()=>{if(!u){O.current=null;return}if(!m||m.id!==u)return;const k=PV(m,s);if(O.current===k)return;O.current=k;const C=q1(m,s);w(C.provider),y(C.model)},[s,m,u,y,w]),g.useEffect(()=>{!a||!m||!RV(m)||J.patchSession(a,m.id,{provider:"openpond"}).then(k=>{P(C=>C.map(A=>A.id===k.id?k:A)),w("openpond"),y(C=>cr("openpond",C))}).catch(k=>{_(k instanceof Error?k.message:String(k))})},[a,m,y,w,_,P])}function TV({connection:e,setError:t}){return g.useCallback(async(n,a)=>{if(!e){const r=new Error("OpenPond App server is not connected.");throw t(r.message),r}t(null);try{await J.resolveApproval(e,n,{decision:a})}catch(r){const i=r instanceof Error?r.message:String(r);throw t(i),r}},[e,t])}function EV({activeProvider:e,contextCompaction:t,contextUsage:n,pinnedItems:a,pinnedPreviewKeys:r,pinnedProjects:i,projectRows:s,visibleProjectRows:l}){const m=g.useMemo(()=>q4(a,r),[a,r]),u=g.useMemo(()=>uI({provider:e,snapshot:n,preferences:t}),[e,t,n]),h=g.useMemo(()=>Array.from(new Set([...i,...l].filter(hg).map(y=>y.project.id))),[i,l]);return{commandProjectRows:g.useMemo(()=>s,[s]),contextWindowStatus:u,pinnedRows:m,sidebarWorkspaceAppIds:h}}function MV({appDispatch:e,expandProject:t,linkedProjectByAppId:n,requestComposerFocus:a,onBeginNewChat:r,setMentionedAppId:i}){return g.useCallback((s=null)=>{r?.();const l=s?.id?n.get(s.id)??null:null;if(l){const m=vt("local",l);i(null),e({type:"selectProject",projectId:m}),t(m),a();return}i(null),e({type:"beginNewChat",appId:s?.id??null}),a()},[e,t,n,r,a,i])}const UI={slack:["slack"],microsoft_teams:["teams","microsoft-teams","microsoft_teams"],github:["github","gh"],google:["google","drive","google-drive","docs"],turnkey:["turnkey","agent-wallet","agent_wallet","wallet"],x:["x","twitter"],mcp:["mcp","openpond-mcp"]};function NJ(e){return`@${e.token}`}function jV(e){return`@${LV(e)}`}function OV(e){const t=new Map;for(const n of e){if(!n.connected||n.statusSource!=="integration_connection")continue;const a=t.get(n.providerFamily)??[];a.push(n),t.set(n.providerFamily,a)}return Array.from(t.entries()).map(([n,a])=>{const r=a[0],i=Si(a.flatMap(b=>b.capabilities.map(y=>y.id))),s=Si(a.flatMap(b=>b.capabilityLabels)),l=Si(a.flatMap(b=>b.connections.map(y=>y.id).filter(zV))),m=Si(a.map(b=>b.id)),u=Si(a.map(b=>b.setupSurface)),h=DV(n);return{provider:n,label:r.providerLabel,detail:s.length>0?s.slice(0,4).join(", "):r.description,token:h,tokens:NV(a),ref:{kind:"integration",provider:n,appIds:m,setupSurfaces:u,...l.length>0?{connectionIds:l}:{},...i.length>0?{capabilities:i}:{}}}})}function DJ(e,t){const n=jn(t);return e.filter(a=>n?a.tokens.some(r=>r.includes(n)):!0).slice(0,8)}function $V(e,t){const n=UV(e);if(n.length===0)return[];const a=new Map;for(const r of n){const i=t.find(s=>s.tokens.includes(r));i&&a.set(i.provider,i)}return Array.from(a.values())}function LJ(e,t){if(t.length===0)return[];const n=[];for(const a of e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)){const r=a[1]??"",i=jn(r);if(!i)continue;const s=t.find(b=>b.tokens.includes(i));if(!s)continue;const m=(a[0]??"").indexOf("@");if(m<0||typeof a.index!="number")continue;const u=a.index+m,h=`@${r}`;n.push({detail:s.detail,displayText:jV(s),end:u+h.length,label:s.label,provider:s.provider,start:u,text:h})}return n}function NV(e){return Si(e.flatMap(t=>[...UI[t.providerFamily],t.providerFamily,t.id,t.label,t.shortLabel]).map(jn).filter(Boolean))}function DV(e){return jn(UI[e][0]??e)}function LV(e){return e.provider==="github"?"GitHub":e.provider==="x"?"X":e.provider==="mcp"?"MCP":e.label}function UV(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function Si(e){return Array.from(new Set(e))}function zV(e){return typeof e=="string"&&e.length>0}function HV({bootstrap:e,connectedAppRows:t,mentionableSandboxApps:n,runtimeIndexes:a,selectedApp:r,selectedCloudProject:i,selectedProject:s,selectedSession:l,selectedSessionId:m}){const u=g.useMemo(()=>{const _=new Map;for(const E of e?.cloudProjects??[]){const j=_.get(E.teamId)??[];j.push(E.id),_.set(E.teamId,j)}return _},[e?.cloudProjects]),b=!!(l||r||s||i)?[]:n,y=g.useMemo(()=>OV(t),[t]),w=g.useMemo(()=>L6(a,m),[a,m]);return{chatMentionApps:b,cloudProjectIdsByTeam:u,connectedAppMentions:y,pendingApproval:w}}function qV({connection:e,setBootstrap:t,setCodexPermissionMode:n,setCodexReasoningEffort:a,setError:r}){const i=g.useCallback(l=>{if(!e){r("Connect to OpenPond before saving preferences.");return}J.savePreferences(e,{codexPermissionMode:l}).then(m=>{n(m.preferences.codexPermissionMode),a(m.preferences.codexReasoningEffort),t(u=>u&&{...u,preferences:m.preferences})}).catch(m=>{r(m instanceof Error?m.message:String(m))})},[e,t,n,a,r]),s=g.useCallback(l=>{if(!e){r("Connect to OpenPond before saving preferences.");return}J.savePreferences(e,{codexReasoningEffort:l}).then(m=>{n(m.preferences.codexPermissionMode),a(m.preferences.codexReasoningEffort),t(u=>u&&{...u,preferences:m.preferences})}).catch(m=>{r(m instanceof Error?m.message:String(m))})},[e,t,n,a,r]);return{changeCodexPermissionMode:i,changeCodexReasoningEffort:s}}const BV=6e4;function _g(e,t){if(!e)return t;const n=VV(e.updatedAt,t.updatedAt)?{...t,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order,status:e.status,updatedAt:e.updatedAt}:t;return HI(e,n)?e:n}function FV(e,t){const n=_g(e,t),a=e?{...n,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order,updatedAt:e.updatedAt}:n;return e&&HI(e,a)?e:a}function tl(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=_g(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function ou(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=FV(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function yf(e,t,n,a=Date.now()){const r=new Map(e.map(i=>[i.id,i]));return t.map(i=>{const s=r.get(i.id);if(s&&n){const l=WV(s,i,n,a);if(l)return l}return _g(s,i)})}function Cy(e,t,n,a=Date.now()){const r=new Map(e.map(u=>[u.id,u])),i=new Map(yf(e,t,n,a).map(u=>[u.id,u])),s=new Set(r.keys()),l=t.filter(u=>!s.has(u.id)).map(u=>i.get(u.id)??u),m=e.map(u=>{const h=i.get(u.id);return h||(zI(u,t)?u:null)}).filter(u=>!!u);return[...l,...m]}function zI(e,t){const n=Date.parse(e.updatedAt);if(!Number.isFinite(n))return!1;const a=KV(t);return a===null||n>=a}function Ry(e,t,n,a=Date.now()){const r=new Map(t.map(i=>[i.id,i]));for(const i of n){const s=r.get(i.id);s&&(qI(s,i)||(e[i.id]=a))}}function VV(e,t){const n=Date.parse(e),a=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(a)&&n>a}function HI(e,t){return JSON.stringify(e)===JSON.stringify(t)}function KV(e){let t=null;for(const n of e){const a=Date.parse(n.updatedAt);Number.isFinite(a)&&(t=t===null?a:Math.max(t,a))}return t}function WV(e,t,n,a){const r=n[t.id];return r===void 0?null:a-r>BV||qI(e,t)?(delete n[t.id],null):{...t,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order}}function qI(e,t){return e.pinned===t.pinned&&e.savedForLater===t.savedForLater&&e.archived===t.archived&&e.order===t.order}const BI=800,GV=5e3,Py=5e4,ZV=16,JV=3e4,Zn=new Map;function YV(e,t){return Zn.get(VI(e,t))?.payload??null}async function FI(e,t,n={}){const a=VI(e,t),r=Zn.get(a),i=n.limit??BI,s=n.tail??!0;if(r?.promise)return r.promise;if(!n.force&&s&&r?.payload&&Date.now()-r.fetchedAt<=JV)return Ay(a,r),r.payload;const l=!!(n.force&&s&&r?.payload),m=l?r?.payload?.events.at(-1)?.id:void 0,u=J.codexHistoryThreadIncremental(e,t,{afterEventId:m,limit:i,revision:l?r?.revision:void 0,tail:s}).then(h=>{const b=Zn.get(a)?.payload??r?.payload;if(h.unchanged){if(!b)throw new Error("Codex history revision matched without a cached thread.");return Zn.set(a,{fetchedAt:Date.now(),payload:b,revision:h.revision}),Ay(a,Zn.get(a)),b}const y={session:h.session,events:h.events},w=s&&b&&!h.reset?{...y,events:QV(b.events,y.events)}:y;return Zn.set(a,{fetchedAt:Date.now(),payload:w,revision:h.revision}),Ty(),w}).catch(h=>{throw Zn.get(a)?.promise===u&&Zn.delete(a),h});return Zn.set(a,{fetchedAt:r?.fetchedAt??0,payload:r?.payload,promise:u,revision:r?.revision}),Ty(),u}function VI(e,t){return`${e.serverUrl}
135
135
  ${e.token}
136
136
  ${t}`}function Ay(e,t){Zn.delete(e),Zn.set(e,t)}function Ty(){for(;Zn.size>ZV;){const e=Zn.keys().next().value;if(!e)return;Zn.delete(e)}}function QV(e,t){const n=new Map;for(const a of e)n.set(a.id,a);for(const a of t)n.set(a.id,a);return Array.from(n.values())}const XV=500,e9=2500,t9=15e3;function n9(e){return e.active?XV:e.surface==="thread"?e9:t9}function Cg(e,t){return!t||e.session.status==="active"?e:{...e,session:{...e.session,status:"active"}}}function a9(e={}){const t={cachedPayload:e.cachedPayload??YV,clearTimer:e.clearTimer??(u=>globalThis.clearTimeout(u)),loadPayload:e.loadPayload??FI,now:e.now??Date.now,setTimer:e.setTimer??((u,h)=>globalThis.setTimeout(u,h))},n=new Map;let a=1;function r(u){const h=r9(u.connection,u.sessionId);let b=n.get(h);b||(b={connection:u.connection,disposed:!1,inFlight:null,latestPayload:t.cachedPayload(u.connection,u.sessionId),nextRefreshAt:null,sessionId:u.sessionId,subscribers:new Map,timer:null},n.set(h,b));const y=a++;return b.subscribers.set(y,u),b.latestPayload&&u.onPayload(b.latestPayload),i(b,0),()=>{const w=n.get(h);if(w){if(w.subscribers.delete(y),w.subscribers.size>0){i(w,l(w));return}w.disposed=!0,m(w),n.delete(h)}}}function i(u,h){if(u.disposed||u.subscribers.size===0||u.inFlight)return;const b=t.now()+Math.max(0,h);u.timer&&u.nextRefreshAt!==null&&u.nextRefreshAt<=b||(m(u),u.nextRefreshAt=b,u.timer=t.setTimer(()=>{u.timer=null,u.nextRefreshAt=null,s(u)},Math.max(0,h)))}async function s(u){if(u.disposed||u.subscribers.size===0||u.inFlight)return;const h=t.loadPayload(u.connection,u.sessionId,{force:!!u.latestPayload});u.inFlight=h;try{const b=await h;if(u.disposed||b===u.latestPayload)return;u.latestPayload=b;for(const y of u.subscribers.values())y.onPayload(b)}catch(b){if(u.disposed)return;for(const y of u.subscribers.values())y.onError?.(b)}finally{u.inFlight===h&&(u.inFlight=null),u.disposed||i(u,l(u))}}function l(u){const h=[...u.subscribers.values()],b=h.some(w=>w.locallyActive||w.reportedActive)||u.latestPayload?.session.status==="active"||kg(u.latestPayload?.events??[])?.tone==="active",y=h.some(w=>w.surface==="thread")?"thread":"sidebar";return n9({active:b,surface:y})}function m(u){u.timer&&t.clearTimer(u.timer),u.timer=null,u.nextRefreshAt=null}return{subscribe:r}}const o9=a9();function Rg(e){return o9.subscribe(e)}function r9(e,t){return`${e.serverUrl}
137
137
  ${e.token}