openpond 0.2.5 → 0.2.6

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 (84) hide show
  1. package/dist/chunks/{app-server-runtime-UNMFD3Z5.js → app-server-runtime-FV4KHBTY.js} +1 -1
  2. package/dist/chunks/{chunk-BIJQ463W.js → chunk-37V5TT45.js} +1 -1
  3. package/dist/chunks/{chunk-PQR3LQIR.js → chunk-3ZEV5UKA.js} +1 -1
  4. package/dist/chunks/{chunk-YCQF5YHM.js → chunk-EESJULVS.js} +1 -1
  5. package/dist/chunks/{chunk-H2HOMO5E.js → chunk-FESS4IR4.js} +2 -2
  6. package/dist/chunks/{cli-RYI23OKH.js → cli-ZZTJVJRT.js} +1 -1
  7. package/dist/chunks/{src-FP3FHNZL.js → src-4QYE5G3N.js} +2 -2
  8. package/dist/chunks/{workspaces-DTHCW6YL.js → workspaces-UB2HJGNE.js} +1 -1
  9. package/dist/cli.js +1 -1
  10. package/dist/web/assets/{App-Cjw_JZFW.js → App-DNZ5VhFd.js} +3 -3
  11. package/dist/web/assets/{AppDialog-DRYgC3vE.js → AppDialog-CtqbY289.js} +1 -1
  12. package/dist/web/assets/{AppTerminalPanel-DCNrNxPp.js → AppTerminalPanel-C1U1RKU6.js} +2 -2
  13. package/dist/web/assets/{AppsView-BRDqxAbq.js → AppsView-BeGbrJkU.js} +1 -1
  14. package/dist/web/assets/{BrowserSidebar-CIU2EM3v.js → BrowserSidebar-XgQLeXw1.js} +1 -1
  15. package/dist/web/assets/{CartesianChart-G4W6FFB5.js → CartesianChart-Cp_-LaJY.js} +1 -1
  16. package/dist/web/assets/{CollaborationTabs-BijyS2Db.js → CollaborationTabs-BL6guh-3.js} +1 -1
  17. package/dist/web/assets/{CommandMenu-Diux_-o-.js → CommandMenu-B-DEtpTp.js} +1 -1
  18. package/dist/web/assets/{CommunityView-DsjboWx2.js → CommunityView-DcEhEMm_.js} +1 -1
  19. package/dist/web/assets/{ComposerCreateImproveStrip-BksVOpGH.js → ComposerCreateImproveStrip-C4mCZcKl.js} +1 -1
  20. package/dist/web/assets/{GetStartedView-CFED3DLv.js → GetStartedView-BUlaCO6a.js} +1 -1
  21. package/dist/web/assets/HostedModelLearningReview-CZyb95R_.js +1 -0
  22. package/dist/web/assets/{HostedModelLearningSettings-C_y21pXP.js → HostedModelLearningSettings-D2o7rh0w.js} +1 -1
  23. package/dist/web/assets/{LabModelVersionDetailPage-DUYkKu-5.js → LabModelVersionDetailPage-Bb1XRvo_.js} +1 -1
  24. package/dist/web/assets/{LabSkillSidebar-DaqOGS0o.js → LabSkillSidebar-CPucMztm.js} +1 -1
  25. package/dist/web/assets/LabsRoute-C_HDADl0.js +32 -0
  26. package/dist/web/assets/{MainChatThread-C6tX_WAH.js → MainChatThread-CnXHxCy3.js} +2 -2
  27. package/dist/web/assets/{MainPane-DcQhWQSs.js → MainPane-DjnT-kvm.js} +4 -4
  28. package/dist/web/assets/{MarkdownText-CbBt1s0N.js → MarkdownText-_zVYW4pN.js} +1 -1
  29. package/dist/web/assets/{Messages-DRf_x1fe.js → Messages-DxctstDI.js} +1 -1
  30. package/dist/web/assets/{NativeSkillSidebar-B9b5d329.js → NativeSkillSidebar-DV4AGiCD.js} +1 -1
  31. package/dist/web/assets/{NewExperienceSwitcher-BoM3OGfF.js → NewExperienceSwitcher-CZCLJj99.js} +1 -1
  32. package/dist/web/assets/{NewProjectDialog-BjXl7sr_.js → NewProjectDialog-CQSipZ5d.js} +1 -1
  33. package/dist/web/assets/{OutputsPage-d4AGrNgn.js → OutputsPage-aPJP4mTV.js} +1 -1
  34. package/dist/web/assets/{ProjectsPage-B4ssHEqU.js → ProjectsPage-CyThuXQv.js} +1 -1
  35. package/dist/web/assets/{RightChatPanelStack-R976LPhJ.js → RightChatPanelStack-jsP9CukH.js} +1 -1
  36. package/dist/web/assets/{RightSidebarHomePanel-Bsnu1dQI.js → RightSidebarHomePanel-CtH0vZ36.js} +1 -1
  37. package/dist/web/assets/{ScheduledWorkPage-Bko3em_c.js → ScheduledWorkPage-BY_4jFm7.js} +1 -1
  38. package/dist/web/assets/{SettingsView-CUMVR2Dz.js → SettingsView-ZPnupcpg.js} +3 -3
  39. package/dist/web/assets/{TeamChatView-BsfG5Ll0.js → TeamChatView-DWjwVxMp.js} +1 -1
  40. package/dist/web/assets/{TerminalOverlay-CK-ZY1xU.js → TerminalOverlay-DxuUGKYH.js} +1 -1
  41. package/dist/web/assets/{TrainingCreationPanel-Idvc6eNj.js → TrainingCreationPanel-CjIPEoTX.js} +1 -1
  42. package/dist/web/assets/{TrainingDraftPanel-u9jHbdmI.js → TrainingDraftPanel-CxevAlkr.js} +1 -1
  43. package/dist/web/assets/{UsageSettingsSection-BXCn7cva.js → UsageSettingsSection-CY1lQB_g.js} +1 -1
  44. package/dist/web/assets/{WorkSidebarPanel-WmQ4zb-I.js → WorkSidebarPanel-DMsiwOSi.js} +1 -1
  45. package/dist/web/assets/{WorkspaceDiffPanel-BmCJO9Lv.js → WorkspaceDiffPanel-HdfItqu2.js} +3 -3
  46. package/dist/web/assets/{WorkspaceEnvironmentMenu-CGaDd3lr.js → WorkspaceEnvironmentMenu-7DSF_BpI.js} +1 -1
  47. package/dist/web/assets/{WorkspaceGitDialogs-ZTVPqFoS.js → WorkspaceGitDialogs-Ck8BzH11.js} +1 -1
  48. package/dist/web/assets/{WorkspaceMonacoEditor-CSdYqVeQ.js → WorkspaceMonacoEditor-gsEP4W37.js} +3 -3
  49. package/dist/web/assets/{arrow-up-right-CB090JWc.js → arrow-up-right-BK6EpHpC.js} +1 -1
  50. package/dist/web/assets/{chat-file-links-Cd2RKX15.js → chat-file-links-BQe708gU.js} +1 -1
  51. package/dist/web/assets/chevron-up-CHxYR4AX.js +1 -0
  52. package/dist/web/assets/{clipboard-CYcWT93J.js → clipboard-DOmCP7eR.js} +1 -1
  53. package/dist/web/assets/{cloud-upload-BMhYGfBt.js → cloud-upload-DLtawDYW.js} +1 -1
  54. package/dist/web/assets/{cssMode-BUYqUtWD.js → cssMode-C0Qw8i_8.js} +1 -1
  55. package/dist/web/assets/{folder-open-Cy_aXbnH.js → folder-open-B_Ayxxo8.js} +1 -1
  56. package/dist/web/assets/{folder-plus-BMc48EOp.js → folder-plus-CPgtt3pN.js} +1 -1
  57. package/dist/web/assets/{git-commit-horizontal-D0HaJs5L.js → git-commit-horizontal-23xCJjd8.js} +1 -1
  58. package/dist/web/assets/{htmlMode-BVYGXxwC.js → htmlMode-DuQ7zaau.js} +1 -1
  59. package/dist/web/assets/{index-CgetlYmK.js → index-BoaTQ0Rb.js} +1 -1
  60. package/dist/web/assets/{info-CaBm3olK.js → info-CQ2kJJ5E.js} +1 -1
  61. package/dist/web/assets/{jsonMode-Bnd9NtOw.js → jsonMode-DVQSEPUy.js} +1 -1
  62. package/dist/web/assets/{lspLanguageFeatures-DER0Y8Vl.js → lspLanguageFeatures-DWKH3min.js} +1 -1
  63. package/dist/web/assets/{minimize-2-CCIxR_67.js → minimize-2-1M-fFBeP.js} +1 -1
  64. package/dist/web/assets/{monaco.contribution-fqbVBGVc.js → monaco.contribution-B5Jz7f4W.js} +2 -2
  65. package/dist/web/assets/{monaco.contribution-Cz1AyVJT.js → monaco.contribution-DB7pp5Y-.js} +2 -2
  66. package/dist/web/assets/{monaco.contribution-B1mfOJXO.js → monaco.contribution-jXX7-l5p.js} +2 -2
  67. package/dist/web/assets/{monaco.contribution-C38lYR1k.js → monaco.contribution-ytVV-s22.js} +2 -2
  68. package/dist/web/assets/{play-Co1ibfid.js → play-D9jaK5MP.js} +1 -1
  69. package/dist/web/assets/{python-BUnxL2L0.js → python-_yRitN2I.js} +1 -1
  70. package/dist/web/assets/{refresh-cw-BGtotVPs.js → refresh-cw-DZHqZGos.js} +1 -1
  71. package/dist/web/assets/{save-CzH1UZYn.js → save-DOT3oYfU.js} +1 -1
  72. package/dist/web/assets/{square-B3zP4tzp.js → square-D_1V6onE.js} +1 -1
  73. package/dist/web/assets/{toggleHighContrast-C24MXd1Z.js → toggleHighContrast-C06C-luq.js} +1 -1
  74. package/dist/web/assets/{tsMode-CGxMoW8n.js → tsMode-CTMYvh-R.js} +1 -1
  75. package/dist/web/assets/{upload-N6fvqnJK.js → upload-EAAHd0Nx.js} +1 -1
  76. package/dist/web/assets/{useLocalAgentSchedules-Bg-SlDx_.js → useLocalAgentSchedules-DBsx4aIY.js} +1 -1
  77. package/dist/web/assets/{wifi-off-Bv0ok5z3.js → wifi-off-DYRTrfYa.js} +1 -1
  78. package/dist/web/assets/{workers-BqOPzABV.js → workers-DAytqxd3.js} +1 -1
  79. package/dist/web/assets/{yaml-DGWza9x2.js → yaml-iZnWWABr.js} +1 -1
  80. package/dist/web/index.html +1 -1
  81. package/package.json +1 -1
  82. package/dist/web/assets/HostedModelLearningReview-D_XoRU_T.js +0 -1
  83. package/dist/web/assets/LabsRoute-DIS9Jaj2.js +0 -32
  84. package/dist/web/assets/chevron-up-Dg6fzlWE.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CommandMenu-Diux_-o-.js","./index-CgetlYmK.js","./index-BGMzUaup.css","./CommandMenu-hNQCm8mw.css","./SettingsView-CUMVR2Dz.js","./refresh-cw-BGtotVPs.js","./chat-file-links-Cd2RKX15.js","./save-CzH1UZYn.js","./folder-open-Cy_aXbnH.js","./chevron-up-Dg6fzlWE.js","./play-Co1ibfid.js","./wifi-off-Bv0ok5z3.js","./useLocalAgentSchedules-Bg-SlDx_.js","./cloud-upload-BMhYGfBt.js","./git-commit-horizontal-D0HaJs5L.js","./folder-plus-BMc48EOp.js","./AppDialog-DRYgC3vE.js","./WorkspaceDiffPanel-BmCJO9Lv.js","./MarkdownText-CbBt1s0N.js","./desktop-files-BQj1J-ob.js","./training-model-data-CKOkpBBL.js","./info-CaBm3olK.js","./minimize-2-CCIxR_67.js","./clipboard-CYcWT93J.js","./SettingsView-CAH0vreE.css","./git-dialogs-BZDqS1eT.css","./NewProjectDialog-BjXl7sr_.js","./WorkspaceGitDialogs-ZTVPqFoS.js","./upload-N6fvqnJK.js","./WorkspaceEnvironmentMenu-CGaDd3lr.js","./square-B3zP4tzp.js","./WorkspaceEnvironmentMenu-DGIFdG3o.css","./MainPane-DcQhWQSs.js","./arrow-up-right-CB090JWc.js"])))=>i.map(i=>d[i]);
2
- import{r as g,j as S,_ as Dr,a as M_}from"./index-CgetlYmK.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},j_=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),S.jsx(C0.Provider,{value:e,children:t})),O_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var $_=class{#e=O_;#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 _r=new $_;function N_(e){setTimeout(e,0)}const D_=typeof window>"u"||"Deno"in globalThis;function Gn(){}function L_(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 Dg(e,t){const{type:n="all",exact:a,fetchStatus:r,predicate:i,queryKey:s,stale:l}=e;if(s){if(a){if(t.queryHash!==Tf(s,t.options))return!1}else if(!Di(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 Lg(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(!Di(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||r&&!r(t))}function Tf(e,t){return(t?.queryKeyHashFn||ll)(e)}function ll(e){return JSON.stringify(e,(t,n)=>Ip(n)?Object.keys(n).sort().reduce((a,r)=>(a[r]=n[r],a),{}):n)}function Di(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(!Di(e[a],t[a]))return!1;return!0}const n=Object.keys(t);for(const a of n)if(!Di(e[a],t[a]))return!1;return!0}return!1}const U_=Object.prototype.hasOwnProperty;function T0(e,t,n=0){if(e===t)return e;if(n>500)return t;const a=Ug(e)&&Ug(t);if(!a&&!(Ip(e)&&Ip(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:U_.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 dm(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 Ug(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ip(e){if(!zg(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!zg(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function zg(e){return Object.prototype.toString.call(e)==="[object Object]"}function z_(e){return new Promise(t=>{_r.setTimeout(t,e)})}function _p(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?T0(e,t):t}function H_(e,t,n=0){const a=[...e,t];return n&&a.length>n?a.slice(1):a}function q_(e,t,n=0){const a=[t,...e];return n&&a.length>n?a.slice(0,-1):a}const Ef=Symbol();function E0(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ef?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function M0(e,t){return typeof e=="function"?e(...t):!!e}function B_(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 F_=()=>D_;const Mf=()=>F_();var Cl=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(){}},V_=class extends Cl{#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 jf=new V_,K_=N_;function W_(){let e=[],t=0,n=l=>{l()},a=l=>{l()},r=K_;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=W_();var G_=class extends Cl{#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 Gc=new G_;function Z_(e){return Math.min(1e3*2**e,3e4)}function j0(e){return(e??"online")==="online"?Gc.isOnline():!0}var Cp=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 Cp(L);E($),e.onCancel?.($)}},h=()=>{t=!0},b=()=>{t=!1},y=()=>jf.isFocused()&&(e.networkMode==="always"||Gc.isOnline())&&e.canRun(),w=()=>j0(e.networkMode)&&e.canRun(),_=L=>{m()||(a?.(),r="resolved",i(L))},E=L=>{m()||(a?.(),r="rejected",s(L))},O=()=>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(j){L=Promise.reject(j)}Promise.resolve(L).then(_).catch(j=>{if(m())return;const x=e.retry??(Mf()?0:3),C=e.retryDelay??Z_,A=typeof C=="function"?C(n,j):C,z=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,j);if(t||!z){E(j);return}n++,e.onFail?.(n,j),z_(A).then(()=>y()?void 0:O()).then(()=>{t?E(j):P()})})};return{promise:l,status:()=>r,cancel:u,continue:()=>(a?.(),l),cancelRetry:h,continueRetry:b,canStart:w,start:()=>(w()?P():O().then(P),l)}}var $0=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),P0(this.gcTime)&&(this.#e=_r.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Mf()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(_r.clearTimeout(this.#e),this.#e=void 0)}};function J_(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=_=>{B_(_,()=>t.signal,()=>h=!0)},y=E0(t.options,t.fetchOptions),w=async(_,E,O)=>{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:O?"backward":"forward",meta:t.options.meta};return b(C),C})(),$=await y(L),{maxPages:j}=t.options,x=O?q_:H_;return{pages:x(_.pages,$,j),pageParams:x(_.pageParams,E,j)}};if(r&&i.length){const _=r==="backward",E=_?Y_:Hg,O={pages:i,pageParams:s};l=await w(O,E(a,O),_)}else{const _=e??i.length;do{const E=m===0?s[0]??a.initialPageParam:Hg(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 Hg(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 Y_(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Q_=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=Bg(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=Bg(this.options);t.data!==void 0&&(this.setState(qg(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(e,t){const n=_p(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===Ef||!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"?J_(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 Cp&&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 Cp){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,...qg(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 qg(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Bg(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 X_=class extends Cl{#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),Fg(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Rp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Rp(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&&!dm(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const a=this.hasListeners();a&&Vg(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 dm(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!Mf()&&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=_r.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=_r.setInterval(()=>{(this.options.refetchIntervalInBackground||jf.isFocused())&&this.#m()},this.#c))}#y(){this.#g(),this.#b(this.#v())}#S(){this.#d!==void 0&&(_r.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#u!==void 0&&(_r.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 x=this.hasListeners(),C=!x&&Fg(e,t),A=x&&Vg(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 x;r?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(x=r.data,E=!0):x=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,x!==void 0&&(_="success",b=_p(r?.data,x,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=_p(r?.data,b,t),this.#s=b,this.#i=null}catch(x){this.#i=x}else b===void 0&&(this.#i=null);this.#i&&(y=this.#i,b=this.#s,w=Date.now(),_="error",h=!1);const O=u.fetchStatus==="fetching",P=_==="pending",L=_==="error",$=P&&O,j=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:O,isRefetching:O&&!P,isLoadingError:L&&!j,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:L&&j,isStale:Of(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),dm(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 eC(e,t){return an(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&an(t.retryOnMount,e)===!1)}function Fg(e,t){return eC(e,t)||e.state.data!==void 0&&Rp(e,t,t.refetchOnMount)}function Rp(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&&Of(e,t)}return!1}function Vg(e,t,n,a){return(e!==t||an(a.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Of(e,n)}function Of(e,t){return an(t.enabled,e)!==!1&&e.isStaleByTime(an(t.staleTime,e))}var tC=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||nC(),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 nC(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var aC=class extends Cl{#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 tC({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=pc(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=pc(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=pc(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=pc(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=>Lg(t,n))}findAll(e={}){return this.getAll().filter(t=>Lg(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 pc(e){return e.options.scope?.id}var oC=class extends Cl{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const a=t.queryKey,r=t.queryHash??Tf(a,t);let i=this.get(r);return i||(i=new Q_({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=>Dg(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Dg(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()})})}},rC=class{#e;#t;#n;#a;#r;#o;#i;#l;constructor(e={}){this.#e=e.queryCache||new oC,this.#t=e.mutationCache||new aC,this.#n=e.defaultOptions||{},this.#a=new Map,this.#r=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=jf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#l=Gc.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=L_(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 Gc.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=>{Di(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=>{Di(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=Tf(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===Ef&&(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),iC=()=>g.useContext(D0);D0.Provider;function sC(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const lC=g.createContext(sC()),cC=()=>g.useContext(lC),dC=(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))},uC=e=>{g.useEffect(()=>{e.clearReset()},[e])},mC=({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])),pC=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))}},fC=(e,t)=>e?.suspense&&t.isPending,hC=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gC(e,t,n){const a=iC(),r=cC(),i=R0(),s=i.defaultQueryOptions(e),l=i.getQueryCache().get(s.queryHash),m=e.subscribed!==!1;s._optimisticResults=a?"isRestoring":m?"optimistic":void 0,pC(s),dC(s,r,l),uC(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]),fC(s,h))throw hC(s,u,r);if(mC({result:h,errorResetBoundary:r,throwOnError:s.throwOnError,query:l,suspense:s.suspense}))throw h.error;return s.notifyOnChangeProps?h:u.trackResult(h)}function vC(e,t){return gC(e,X_)}function bC(){return new rC({defaultOptions:{queries:{staleTime:6e4,gcTime:15*6e4,retry:1,refetchOnWindowFocus:!1}}})}var Kg;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 Mi 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"}}(Kg=globalThis).__zod_globalConfig??(Kg.__zod_globalConfig={});const $f=globalThis.__zod_globalConfig;function Lo(e){return $f}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 Pp(e,t){return typeof t=="bigint"?t.toString():t}function vd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Nf(e){return e==null}function Df(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function yC(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 Wg=Symbol("evaluating");function Ct(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Wg)return a===void 0&&(a=Wg,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Lr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ir(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Gg(e){return JSON.stringify(e)}function SC(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 xC=vd(()=>{if($f.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Li(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 Li(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const kC=new Set(["string","number","symbol"]);function Ui(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sr(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 wC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const IC={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 _C(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=ir(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 Lr(this,"shape",s),s},checks:[]});return sr(e,i)}function CC(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=ir(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 Lr(this,"shape",s),s},checks:[]});return sr(e,i)}function RC(e,t){if(!Li(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=ir(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Lr(this,"shape",i),i}});return sr(e,r)}function PC(e,t){if(!Li(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ir(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Lr(this,"shape",a),a}});return sr(e,n)}function AC(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=ir(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Lr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return sr(e,n)}function TC(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=ir(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 Lr(this,"shape",m),m},checks:[]});return sr(t,s)}function EC(e,t,n){const a=ir(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 Lr(this,"shape",i),i}});return sr(t,a)}function wi(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 MC(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 Ii(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function fc(e){return typeof e=="string"?e:e?.message}function Uo(e,t,n){const a=e.message?e.message:fc(e.inst?._zod.def?.error?.(e))??fc(t?.error?.(e))??fc(n.customError?.(e))??fc(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 Lf(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,Pp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},B0=ve("$ZodError",q0),F0=ve("$ZodError",q0,{Parent:Error});function jC(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 OC(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 Uf=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 Mi;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},zf=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},bd=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 Mi;return i.issues.length?{success:!1,error:new(e??B0)(i.issues.map(s=>Uo(s,r,Lo())))}:{success:!0,data:i.value}},$C=bd(F0),yd=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}},NC=yd(F0),DC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return Uf(e)(t,n,r)},LC=e=>(t,n,a)=>Uf(e)(t,n,a),UC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return zf(e)(t,n,r)},zC=e=>async(t,n,a)=>zf(e)(t,n,a),HC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return bd(e)(t,n,r)},qC=e=>(t,n,a)=>bd(e)(t,n,a),BC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return yd(e)(t,n,r)},FC=e=>async(t,n,a)=>yd(e)(t,n,a),VC=/^[cC][0-9a-z]{6,}$/,KC=/^[0-9a-z]+$/,WC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,GC=/^[0-9a-vA-V]{20}$/,ZC=/^[A-Za-z0-9]{27}$/,JC=/^[a-zA-Z0-9_-]{21}$/,YC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,QC=/^([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})$/,Zg=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)$/,XC=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function tR(){return new RegExp(eR,"u")}const nR=/^(?:(?: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])$/,aR=/^(([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}|:))$/,oR=/^((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])$/,rR=/^(([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])$/,iR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,V0=/^[A-Za-z0-9_-]*$/,sR=/^https?$/,lR=/^\+[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])))",cR=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 dR(e){return new RegExp(`^${W0(e)}$`)}function uR(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 mR=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pR=/^-?\d+$/,G0=/^-?\d+(?:\.\d+)?$/,fR=/^(?:true|false)$/i,hR=/^null$/i,gR=/^[^A-Z]*$/,vR=/^[^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})}}),bR=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):yC(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})}}),yR=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]=IC[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=pR)}),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})}}),SR=ve("$ZodCheckMaxLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Nf(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=Lf(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xR=ve("$ZodCheckMinLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Nf(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=Lf(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kR=ve("$ZodCheckLengthEquals",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Nf(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=Lf(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})}}),Sd=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=()=>{})}),wR=ve("$ZodCheckRegex",(e,t)=>{Sd.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})}}),IR=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=gR),Sd.init(e,t)}),_R=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=vR),Sd.init(e,t)}),CR=ve("$ZodCheckIncludes",(e,t)=>{Xn.init(e,t);const n=Ui(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})}}),RR=ve("$ZodCheckStartsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`^${Ui(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})}}),PR=ve("$ZodCheckEndsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`.*${Ui(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})}}),AR=ve("$ZodCheckOverwrite",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class TR{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-B-DEtpTp.js","./index-BoaTQ0Rb.js","./index-BGMzUaup.css","./CommandMenu-hNQCm8mw.css","./SettingsView-ZPnupcpg.js","./refresh-cw-DZHqZGos.js","./chat-file-links-BQe708gU.js","./save-DOT3oYfU.js","./folder-open-B_Ayxxo8.js","./chevron-up-CHxYR4AX.js","./play-D9jaK5MP.js","./wifi-off-DYRTrfYa.js","./useLocalAgentSchedules-DBsx4aIY.js","./cloud-upload-DLtawDYW.js","./git-commit-horizontal-23xCJjd8.js","./folder-plus-CPgtt3pN.js","./AppDialog-CtqbY289.js","./WorkspaceDiffPanel-HdfItqu2.js","./MarkdownText-_zVYW4pN.js","./desktop-files-BQj1J-ob.js","./training-model-data-CKOkpBBL.js","./info-CQ2kJJ5E.js","./minimize-2-1M-fFBeP.js","./clipboard-DOmCP7eR.js","./SettingsView-CAH0vreE.css","./git-dialogs-BZDqS1eT.css","./NewProjectDialog-CQSipZ5d.js","./WorkspaceGitDialogs-Ck8BzH11.js","./upload-EAAHd0Nx.js","./WorkspaceEnvironmentMenu-7DSF_BpI.js","./square-D_1V6onE.js","./WorkspaceEnvironmentMenu-DGIFdG3o.css","./MainPane-DjnT-kvm.js","./arrow-up-right-BK6EpHpC.js"])))=>i.map(i=>d[i]);
2
+ import{r as g,j as S,_ as Dr,a as M_}from"./index-BoaTQ0Rb.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},j_=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),S.jsx(C0.Provider,{value:e,children:t})),O_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var $_=class{#e=O_;#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 _r=new $_;function N_(e){setTimeout(e,0)}const D_=typeof window>"u"||"Deno"in globalThis;function Gn(){}function L_(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 Dg(e,t){const{type:n="all",exact:a,fetchStatus:r,predicate:i,queryKey:s,stale:l}=e;if(s){if(a){if(t.queryHash!==Tf(s,t.options))return!1}else if(!Di(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 Lg(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(!Di(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||r&&!r(t))}function Tf(e,t){return(t?.queryKeyHashFn||ll)(e)}function ll(e){return JSON.stringify(e,(t,n)=>Ip(n)?Object.keys(n).sort().reduce((a,r)=>(a[r]=n[r],a),{}):n)}function Di(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(!Di(e[a],t[a]))return!1;return!0}const n=Object.keys(t);for(const a of n)if(!Di(e[a],t[a]))return!1;return!0}return!1}const U_=Object.prototype.hasOwnProperty;function T0(e,t,n=0){if(e===t)return e;if(n>500)return t;const a=Ug(e)&&Ug(t);if(!a&&!(Ip(e)&&Ip(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:U_.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 dm(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 Ug(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ip(e){if(!zg(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!zg(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function zg(e){return Object.prototype.toString.call(e)==="[object Object]"}function z_(e){return new Promise(t=>{_r.setTimeout(t,e)})}function _p(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?T0(e,t):t}function H_(e,t,n=0){const a=[...e,t];return n&&a.length>n?a.slice(1):a}function q_(e,t,n=0){const a=[t,...e];return n&&a.length>n?a.slice(0,-1):a}const Ef=Symbol();function E0(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ef?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function M0(e,t){return typeof e=="function"?e(...t):!!e}function B_(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 F_=()=>D_;const Mf=()=>F_();var Cl=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(){}},V_=class extends Cl{#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 jf=new V_,K_=N_;function W_(){let e=[],t=0,n=l=>{l()},a=l=>{l()},r=K_;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=W_();var G_=class extends Cl{#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 Gc=new G_;function Z_(e){return Math.min(1e3*2**e,3e4)}function j0(e){return(e??"online")==="online"?Gc.isOnline():!0}var Cp=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 Cp(L);E($),e.onCancel?.($)}},h=()=>{t=!0},b=()=>{t=!1},y=()=>jf.isFocused()&&(e.networkMode==="always"||Gc.isOnline())&&e.canRun(),w=()=>j0(e.networkMode)&&e.canRun(),_=L=>{m()||(a?.(),r="resolved",i(L))},E=L=>{m()||(a?.(),r="rejected",s(L))},O=()=>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(j){L=Promise.reject(j)}Promise.resolve(L).then(_).catch(j=>{if(m())return;const x=e.retry??(Mf()?0:3),C=e.retryDelay??Z_,A=typeof C=="function"?C(n,j):C,z=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,j);if(t||!z){E(j);return}n++,e.onFail?.(n,j),z_(A).then(()=>y()?void 0:O()).then(()=>{t?E(j):P()})})};return{promise:l,status:()=>r,cancel:u,continue:()=>(a?.(),l),cancelRetry:h,continueRetry:b,canStart:w,start:()=>(w()?P():O().then(P),l)}}var $0=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),P0(this.gcTime)&&(this.#e=_r.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Mf()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(_r.clearTimeout(this.#e),this.#e=void 0)}};function J_(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=_=>{B_(_,()=>t.signal,()=>h=!0)},y=E0(t.options,t.fetchOptions),w=async(_,E,O)=>{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:O?"backward":"forward",meta:t.options.meta};return b(C),C})(),$=await y(L),{maxPages:j}=t.options,x=O?q_:H_;return{pages:x(_.pages,$,j),pageParams:x(_.pageParams,E,j)}};if(r&&i.length){const _=r==="backward",E=_?Y_:Hg,O={pages:i,pageParams:s};l=await w(O,E(a,O),_)}else{const _=e??i.length;do{const E=m===0?s[0]??a.initialPageParam:Hg(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 Hg(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 Y_(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Q_=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=Bg(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=Bg(this.options);t.data!==void 0&&(this.setState(qg(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(e,t){const n=_p(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===Ef||!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"?J_(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 Cp&&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 Cp){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,...qg(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 qg(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Bg(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 X_=class extends Cl{#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),Fg(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Rp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Rp(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&&!dm(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const a=this.hasListeners();a&&Vg(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 dm(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!Mf()&&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=_r.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=_r.setInterval(()=>{(this.options.refetchIntervalInBackground||jf.isFocused())&&this.#m()},this.#c))}#y(){this.#g(),this.#b(this.#v())}#S(){this.#d!==void 0&&(_r.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#u!==void 0&&(_r.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 x=this.hasListeners(),C=!x&&Fg(e,t),A=x&&Vg(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 x;r?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(x=r.data,E=!0):x=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,x!==void 0&&(_="success",b=_p(r?.data,x,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=_p(r?.data,b,t),this.#s=b,this.#i=null}catch(x){this.#i=x}else b===void 0&&(this.#i=null);this.#i&&(y=this.#i,b=this.#s,w=Date.now(),_="error",h=!1);const O=u.fetchStatus==="fetching",P=_==="pending",L=_==="error",$=P&&O,j=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:O,isRefetching:O&&!P,isLoadingError:L&&!j,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:L&&j,isStale:Of(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),dm(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 eC(e,t){return an(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&an(t.retryOnMount,e)===!1)}function Fg(e,t){return eC(e,t)||e.state.data!==void 0&&Rp(e,t,t.refetchOnMount)}function Rp(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&&Of(e,t)}return!1}function Vg(e,t,n,a){return(e!==t||an(a.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Of(e,n)}function Of(e,t){return an(t.enabled,e)!==!1&&e.isStaleByTime(an(t.staleTime,e))}var tC=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||nC(),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 nC(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var aC=class extends Cl{#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 tC({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=pc(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=pc(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=pc(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=pc(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=>Lg(t,n))}findAll(e={}){return this.getAll().filter(t=>Lg(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 pc(e){return e.options.scope?.id}var oC=class extends Cl{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const a=t.queryKey,r=t.queryHash??Tf(a,t);let i=this.get(r);return i||(i=new Q_({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=>Dg(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Dg(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()})})}},rC=class{#e;#t;#n;#a;#r;#o;#i;#l;constructor(e={}){this.#e=e.queryCache||new oC,this.#t=e.mutationCache||new aC,this.#n=e.defaultOptions||{},this.#a=new Map,this.#r=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=jf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#l=Gc.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=L_(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 Gc.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=>{Di(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=>{Di(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=Tf(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===Ef&&(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),iC=()=>g.useContext(D0);D0.Provider;function sC(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const lC=g.createContext(sC()),cC=()=>g.useContext(lC),dC=(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))},uC=e=>{g.useEffect(()=>{e.clearReset()},[e])},mC=({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])),pC=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))}},fC=(e,t)=>e?.suspense&&t.isPending,hC=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gC(e,t,n){const a=iC(),r=cC(),i=R0(),s=i.defaultQueryOptions(e),l=i.getQueryCache().get(s.queryHash),m=e.subscribed!==!1;s._optimisticResults=a?"isRestoring":m?"optimistic":void 0,pC(s),dC(s,r,l),uC(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]),fC(s,h))throw hC(s,u,r);if(mC({result:h,errorResetBoundary:r,throwOnError:s.throwOnError,query:l,suspense:s.suspense}))throw h.error;return s.notifyOnChangeProps?h:u.trackResult(h)}function vC(e,t){return gC(e,X_)}function bC(){return new rC({defaultOptions:{queries:{staleTime:6e4,gcTime:15*6e4,retry:1,refetchOnWindowFocus:!1}}})}var Kg;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 Mi 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"}}(Kg=globalThis).__zod_globalConfig??(Kg.__zod_globalConfig={});const $f=globalThis.__zod_globalConfig;function Lo(e){return $f}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 Pp(e,t){return typeof t=="bigint"?t.toString():t}function vd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Nf(e){return e==null}function Df(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function yC(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 Wg=Symbol("evaluating");function Ct(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Wg)return a===void 0&&(a=Wg,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Lr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ir(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Gg(e){return JSON.stringify(e)}function SC(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 xC=vd(()=>{if($f.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Li(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 Li(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const kC=new Set(["string","number","symbol"]);function Ui(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sr(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 wC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const IC={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 _C(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=ir(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 Lr(this,"shape",s),s},checks:[]});return sr(e,i)}function CC(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=ir(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 Lr(this,"shape",s),s},checks:[]});return sr(e,i)}function RC(e,t){if(!Li(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=ir(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Lr(this,"shape",i),i}});return sr(e,r)}function PC(e,t){if(!Li(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ir(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Lr(this,"shape",a),a}});return sr(e,n)}function AC(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=ir(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Lr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return sr(e,n)}function TC(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=ir(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 Lr(this,"shape",m),m},checks:[]});return sr(t,s)}function EC(e,t,n){const a=ir(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 Lr(this,"shape",i),i}});return sr(t,a)}function wi(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 MC(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 Ii(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function fc(e){return typeof e=="string"?e:e?.message}function Uo(e,t,n){const a=e.message?e.message:fc(e.inst?._zod.def?.error?.(e))??fc(t?.error?.(e))??fc(n.customError?.(e))??fc(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 Lf(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,Pp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},B0=ve("$ZodError",q0),F0=ve("$ZodError",q0,{Parent:Error});function jC(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 OC(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 Uf=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 Mi;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},zf=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},bd=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 Mi;return i.issues.length?{success:!1,error:new(e??B0)(i.issues.map(s=>Uo(s,r,Lo())))}:{success:!0,data:i.value}},$C=bd(F0),yd=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}},NC=yd(F0),DC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return Uf(e)(t,n,r)},LC=e=>(t,n,a)=>Uf(e)(t,n,a),UC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return zf(e)(t,n,r)},zC=e=>async(t,n,a)=>zf(e)(t,n,a),HC=e=>(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return bd(e)(t,n,r)},qC=e=>(t,n,a)=>bd(e)(t,n,a),BC=e=>async(t,n,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return yd(e)(t,n,r)},FC=e=>async(t,n,a)=>yd(e)(t,n,a),VC=/^[cC][0-9a-z]{6,}$/,KC=/^[0-9a-z]+$/,WC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,GC=/^[0-9a-vA-V]{20}$/,ZC=/^[A-Za-z0-9]{27}$/,JC=/^[a-zA-Z0-9_-]{21}$/,YC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,QC=/^([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})$/,Zg=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)$/,XC=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function tR(){return new RegExp(eR,"u")}const nR=/^(?:(?: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])$/,aR=/^(([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}|:))$/,oR=/^((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])$/,rR=/^(([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])$/,iR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,V0=/^[A-Za-z0-9_-]*$/,sR=/^https?$/,lR=/^\+[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])))",cR=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 dR(e){return new RegExp(`^${W0(e)}$`)}function uR(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 mR=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pR=/^-?\d+$/,G0=/^-?\d+(?:\.\d+)?$/,fR=/^(?:true|false)$/i,hR=/^null$/i,gR=/^[^A-Z]*$/,vR=/^[^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})}}),bR=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):yC(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})}}),yR=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]=IC[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=pR)}),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})}}),SR=ve("$ZodCheckMaxLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Nf(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=Lf(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xR=ve("$ZodCheckMinLength",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Nf(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=Lf(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kR=ve("$ZodCheckLengthEquals",(e,t)=>{var n;Xn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Nf(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=Lf(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})}}),Sd=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=()=>{})}),wR=ve("$ZodCheckRegex",(e,t)=>{Sd.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})}}),IR=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=gR),Sd.init(e,t)}),_R=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=vR),Sd.init(e,t)}),CR=ve("$ZodCheckIncludes",(e,t)=>{Xn.init(e,t);const n=Ui(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})}}),RR=ve("$ZodCheckStartsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`^${Ui(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})}}),PR=ve("$ZodCheckEndsWith",(e,t)=>{Xn.init(e,t);const n=new RegExp(`.*${Ui(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})}}),AR=ve("$ZodCheckOverwrite",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class TR{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 ER={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=ER;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=wi(s),h;for(const b of l){if(b._zod.def.when){if(MC(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 Mi;if(h||w instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await w,s.issues.length!==y&&(u||(u=wi(s,y)))});else{if(s.issues.length===y)continue;u||(u=wi(s,y))}}return h?h.then(()=>s):s},i=(s,l,m)=>{if(wi(s))return s.aborted=!0,s;const u=r(l,a,m);if(u instanceof Promise){if(m.async===!1)throw new Mi;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 Mi;return m.then(u=>r(u,a,l))}return r(m,a,l)}}Ct(e,"~standard",()=>({validate:r=>{try{const i=$C(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return NC(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Hf=ve("$ZodString",(e,t)=>{Jt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??mR(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)=>{Sd.init(e,t),Hf.init(e,t)}),MR=ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=QC),en.init(e,t)}),jR=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=Zg(a))}else t.pattern??(t.pattern=Zg());en.init(e,t)}),OR=ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=XC),en.init(e,t)}),$R=ve("$ZodURL",(e,t)=>{en.init(e,t),e._zod.check=n=>{try{const a=n.value.trim();if(!t.normalize&&t.protocol?.source===sR.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})}}}),NR=ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=tR()),en.init(e,t)}),DR=ve("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=JC),en.init(e,t)}),LR=ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=VC),en.init(e,t)}),UR=ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=KC),en.init(e,t)}),zR=ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=WC),en.init(e,t)}),HR=ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=GC),en.init(e,t)}),qR=ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ZC),en.init(e,t)}),BR=ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=uR(t)),en.init(e,t)}),FR=ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=cR),en.init(e,t)}),VR=ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=dR(t)),en.init(e,t)}),KR=ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=YC),en.init(e,t)}),WR=ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=nR),en.init(e,t),e._zod.bag.format="ipv4"}),GR=ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=aR),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})}}}),ZR=ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=oR),en.init(e,t)}),JR=ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=rR),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 YR=ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=iR),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 QR(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 XR=ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=V0),en.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{QR(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),eP=ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=lR),en.init(e,t)});function tP(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 nP=ve("$ZodJWT",(e,t)=>{en.init(e,t),e._zod.check=n=>{tP(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}}),aP=ve("$ZodNumberFormat",(e,t)=>{yR.init(e,t),X0.init(e,t)}),oP=ve("$ZodBoolean",(e,t)=>{Jt.init(e,t),e._zod.pattern=fR,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}}),rP=ve("$ZodNull",(e,t)=>{Jt.init(e,t),e._zod.pattern=hR,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}}),iP=ve("$ZodUnknown",(e,t)=>{Jt.init(e,t),e._zod.parse=n=>n}),sP=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 Jg(e,t,n){e.issues.length&&t.issues.push(...Ii(n,e.issues)),t.value[n]=e.value}const lP=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=>Jg(u,n,s))):Jg(m,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function Zc(e,t,n,a,r,i){const s=n in a;if(e.issues.length){if(r&&i&&!s)return;t.issues.push(...Ii(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=wC(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(_=>Zc(_,n,y,t,h,b))):Zc(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 cP=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=vd(()=>eS(t));Ct(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",O=w._zod.run({value:u[y],issues:[]},m);O instanceof Promise?h.push(O.then(P=>Zc(P,l,y,u,_,E))):Zc(O,l,y,u,_,E)}return i?tS(h,u,l,m,a.value,e):h.length?Promise.all(h).then(()=>l):l}}),dP=ve("$ZodObjectJIT",(e,t)=>{cP.init(e,t);const n=e._zod.parse,a=vd(()=>eS(t)),r=y=>{const w=new TR(["shape","payload","ctx"]),_=a.value,E=$=>{const j=Gg($);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};w.write("const input = payload.value;");const O=Object.create(null);let P=0;for(const $ of _.keys)O[$]=`key_${P++}`;w.write("const newResult = {};");for(const $ of _.keys){const j=O[$],x=Gg($),C=y[$],A=C?._zod?.optin==="optional",z=C?._zod?.optout==="optional";w.write(`const ${j} = ${E($)};`),A&&z?w.write(`
5
5
  if (${j}.issues.length) {
@@ -131,7 +131,7 @@ Surface risks, constraints, and verification steps.`}],rh=o().trim().min(1).max(
131
131
 
132
132
  `)}}!a?.aborted&&s.trim()&&jb(s,t,n)}function p1(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 xB(e,t,n,a,r={}){const i=new AbortController,s=r.fetchImpl??fetch,l=r.reconnectDelayMs??yB;let m=Mb(r.afterSequence),u=!1;return(async()=>{let h=0;for(;!i.signal.aborted;)try{const b=bB(e,i.signal,m),y=await s(b.url,b.init);if(p1(y),u=!0,h=0,await SB(y,w=>{const _=Mb(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 kB(l(h),i.signal),h+=1}})().catch(()=>{}),{close(){i.abort()},isOpen(){return u}}}function Mb(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?e:0}function jb(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 kB(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 wB extends Error{constructor(t,n){super(t),this.status=n,this.name="ApiRequestError"}status}function Ob(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 $b=new WeakMap,Nb=new WeakMap,xc=new WeakMap;let IB=0;async function B(e,t,n){if(t==="/v1/preferences"&&typeof n?.body=="string"){const r=(xc.get(e)??Promise.resolve()).catch(()=>{}).then(()=>Db(e,t,n));xc.set(e,r);try{return await r}finally{xc.get(e)===r&&xc.delete(e)}}return Db(e,t,n)}async function Db(e,t,n){const a=++IB;if(t==="/v1/preferences"&&typeof n?.body=="string"){const m=$b.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 wB(u,i.status)}const s=await i.json(),l=s?.configuration?.rawRevision??(t==="/v1/preferences"?s?.rawRevision:void 0);return typeof l=="string"&&a>=(Nb.get(e)??0)&&($b.set(e,l),Nb.set(e,a)),s}function OZ(e){const t=new URL("/v1/terminal",e.serverUrl);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.toString()}function $Z(e){return["openpond-terminal",`openpond-token.${CB(e.token)}`]}function _B(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 CB(e){return _B(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function RB(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 PB={teamInvitations:e=>B(e,"/v1/team-invitations"),decideTeamInvitation:(e,t,n)=>B(e,`/v1/team-invitations/${t}`,{method:"POST",body:JSON.stringify({token:n})}),organizations:e=>B(e,"/v1/organizations"),createOrganization:(e,t)=>B(e,"/v1/organizations",{method:"POST",body:JSON.stringify(t)}),updateOrganization:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),organizationMembers:(e,t)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/members`),upsertOrganizationMember:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify(n)}),organizationMcpServer:(e,t)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`),generateOrganizationMcpServer:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`,{method:"POST",body:JSON.stringify(n)}),setOrganizationMcpServerStatus:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server/${n}`,{method:"POST"})},AB={sendTurn:(e,t,n)=>B(e,`/v1/sessions/${t}/turns`,{method:"POST",body:JSON.stringify(n)}),runSessionCommand:(e,t,n)=>B(e,`/v1/sessions/${encodeURIComponent(t)}/commands`,{method:"POST",body:JSON.stringify(n)}),recordPreflightTurnFailure:(e,t,n)=>B(e,`/v1/sessions/${t}/preflight-turns/failure`,{method:"POST",body:JSON.stringify(n)}),listCreateImproveRuns:(e,t={})=>B(e,`/v1/create-improve-runs?${TB(t).toString()}`),getCreateImproveRun:(e,t)=>B(e,`/v1/create-improve-runs/${encodeURIComponent(t)}`),getCreateImproveCandidateDiff:(e,t,n)=>B(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/candidates/${encodeURIComponent(n)}/diff`),applyCreateImproveAction:(e,t,n)=>B(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/actions`,{method:"POST",body:JSON.stringify(n)}),interruptTurn:(e,t,n)=>B(e,`/v1/sessions/${t}/turns/interrupt`,{method:"POST",body:JSON.stringify({reason:n})}),compactSession:(e,t,n={reason:"manual"})=>B(e,`/v1/sessions/${t}/compact`,{method:"POST",body:JSON.stringify(n)}),workspaceTool:(e,t,n)=>B(e,`/v1/sessions/${t}/workspace-tools`,{method:"POST",body:JSON.stringify(n)}),ensureCloudWorkspaceReady:(e,t,n)=>B(e,`/v1/sessions/${encodeURIComponent(t)}/workspace/ensure-ready`,{method:"POST",body:JSON.stringify(n)})};function TB(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 EB={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)),B(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${a.toString()}`)},sandboxUploadFile:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/files`,{method:"POST",body:JSON.stringify(n)}),preserveSandboxSource:(e,t,n={})=>B(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 B(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${r.toString()}`);return{...i,contents:i.file.isBinary?"":RB(i.file.contentsBase64)}}},MB={sandboxGitStatus:(e,t)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/status`),sandboxGitDiff:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/diff`,{method:"POST",body:JSON.stringify(n)})},jB={connectedAppStatus:(e,t={})=>{const n=Ob(t);return n.set("status",t.status??"all"),B(e,`/v1/connected-apps/status${n.size>0?`?${n.toString()}`:""}`)},integrationConnections:(e,t={})=>{const n=Ob(t);return t.status&&n.set("status",t.status),B(e,`/v1/integrations/connections${n.size>0?`?${n.toString()}`:""}`)},sandboxIntegrationLeases:(e,t)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`),attachSandboxIntegrationConnection:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"POST",body:JSON.stringify(n)}),removeSandboxIntegrationLease:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:n})})},OB={listSandboxProjects:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return B(e,`/v1/sandbox-projects?${n.toString()}`)},getSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return B(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`)},getSandboxProjectWorkspace:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return B(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/workspace?${a.toString()}`)},upsertSandboxProject:(e,t)=>B(e,"/v1/sandbox-projects",{method:"POST",body:JSON.stringify(t)}),syncSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return B(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 B(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 B(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`,{method:"DELETE"})},listSandboxAgents:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return B(e,`/v1/sandbox-agents?${n.toString()}`)},upsertSandboxAgent:(e,t)=>B(e,"/v1/sandbox-agents",{method:"POST",body:JSON.stringify(t)}),runSandboxAgent:(e,t,n)=>B(e,`/v1/sandbox-agents/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n)}),runProfileAction:(e,t)=>B(e,"/v1/profile/run",{method:"POST",body:JSON.stringify(t)})},$B={sandbox:(e,t)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}`)},NB={...jB,...OB,...$B,...MB,...EB},DB={communities:(e,t)=>{const n=new URLSearchParams;return t&&n.set("cursor",t),B(e,`/v1/communities${n.size?`?${n}`:""}`)},communityPreview:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/preview`),communityRules:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/rules/current`),joinCommunity:(e,t,n)=>B(e,`/v1/communities/${encodeURIComponent(t)}/join`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),acceptCommunityRules:(e,t,n)=>B(e,`/v1/communities/${encodeURIComponent(t)}/rules/accept`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),leaveCommunity:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/leave`,{method:"POST",body:"{}"}),communityChannels:(e,t)=>B(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)),B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages${r.size?`?${r}`:""}`)},sendCommunityMessage:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify(a)}),editCommunityMessage:(e,t,n,a,r)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({body:r})}),deleteCommunityMessage:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"DELETE",body:"{}"}),markCommunityRead:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/read`,{method:"POST",body:JSON.stringify({sequence:a})}),setCommunityChannelMuted:(e,t,n,a)=>B(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)),B(e,`/v1/communities/${encodeURIComponent(t)}/members/search${a.size?`?${a}`:""}`)},updateCommunityNotifications:(e,t,n)=>B(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)),B(e,`/v1/communities/${encodeURIComponent(t)}/events${a.size?`?${a}`:""}`)},communityRealtimeSession:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/realtime-session`),uploadCommunityAttachment:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/upload`,{method:"POST",body:JSON.stringify({attachment:a})}),communityAttachmentDownload:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/${encodeURIComponent(a)}/download`)},Yh="openpond-app-server-url",yl="openpond-app-token",LB=750;function f1(){return window.location.protocol!=="http:"&&window.location.protocol!=="https:"?null:window.location.origin&&window.location.origin!=="null"?window.location.origin:null}function Qp(e){const t=e.getItem(Yh)?.trim(),n=e.getItem(yl)?.trim();return t&&n?{serverUrl:t,token:n}:null}function rd(e){if(!e)return null;try{const t="__openpond_storage_probe__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}function vi(e,t){e.setItem(Yh,t.serverUrl),e.setItem(yl,t.token)}function Lb(e,t){const n=Qp(e);n?.serverUrl!==t.serverUrl||n.token!==t.token||(e.removeItem(Yh),e.removeItem(yl))}function UB(){const e=window.__OPENPOND_WEB_CONNECTION__,t=e?.serverUrl?.trim(),n=e?.token?.trim();return t&&n?{serverUrl:t,token:n}:null}function zB(){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()||f1();return!a||!n?null:{serverUrl:a,token:n}}function HB(){window.location.hash&&window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`)}function kc(e,t){t&&(e.some(n=>n.serverUrl===t.serverUrl&&n.token===t.token)||e.push(t))}function qB(){const e=[],t=rd(window.sessionStorage),n=rd(window.localStorage),a=f1(),r=t?.getItem(yl)??n?.getItem(yl);return kc(e,null),kc(e,a&&r?{serverUrl:a,token:r.trim()}:null),kc(e,t?Qp(t):null),kc(e,n?Qp(n):null),e}async function Km(e){const t=new AbortController,n=window.setTimeout(()=>t.abort(),LB);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 BB(){if(window.openpond)return window.openpond.getConnection();const e=rd(window.sessionStorage),t=rd(window.localStorage),n=zB();if(n&&await Km(n.serverUrl))return t&&vi(t,n),e&&vi(e,n),HB(),{...n,platform:navigator.platform};const a=UB();if(a&&await Km(a.serverUrl))return t&&vi(t,a),e&&vi(e,a),{...a,platform:navigator.platform};const r=qB();for(const i of r){if(await Km(i.serverUrl))return t&&vi(t,i),e&&vi(e,i),{...i,platform:navigator.platform};e&&Lb(e,i),t&&Lb(t,i)}throw new Error("No reachable OpenPond app server. Start `openpond ui` again and open the full printed URL.")}const J={...DB,bootstrap:e=>B(e,"/v1/bootstrap?refreshCodex=1"),localProjectActions:(e,t)=>B(e,`/v1/projects/${encodeURIComponent(t)}/actions`),extensionCatalog:e=>B(e,"/v1/extensions"),extensionPreview:(e,t)=>B(e,"/v1/extensions/preview",{method:"POST",body:JSON.stringify(t)}),extensionAdd:(e,t)=>B(e,"/v1/extensions",{method:"POST",body:JSON.stringify(t)}),extensionUpdate:(e,t,n={})=>B(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}/update`,{method:"POST",body:JSON.stringify(n)}),extensionUpdateAll:e=>B(e,"/v1/extensions/update-all",{method:"POST"}),extensionRemove:(e,t)=>B(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}`,{method:"DELETE"}),skillSourceFile:(e,t,n,a)=>B(e,`/v1/skills/${t}/${encodeURIComponent(n)}/source?path=${encodeURIComponent(a)}`),teamChatMembers:(e,t)=>B(e,`/v1/team-chat/members?teamId=${encodeURIComponent(t)}`),teamChatAgents:(e,t)=>B(e,`/v1/team-chat/agents?teamId=${encodeURIComponent(t)}`),teamChatThreads:(e,t)=>B(e,`/v1/team-chat/threads?teamId=${encodeURIComponent(t)}`),teamChatRealtimeSession:(e,t)=>B(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)),B(e,`/v1/team-chat/events?${a.toString()}`)},teamChatGeneral:(e,t)=>B(e,"/v1/team-chat/threads/general",{method:"POST",body:JSON.stringify({teamId:t})}),teamChatDm:(e,t,n)=>B(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)),B(e,`/v1/team-chat/threads/${encodeURIComponent(n)}?${r.toString()}`)},uploadTeamChatAttachment:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/attachments/upload`,{method:"POST",body:JSON.stringify(n)}),teamChatAttachmentDownload:(e,t,n)=>B(e,`/v1/team-chat/attachments/${encodeURIComponent(n)}/download?teamId=${encodeURIComponent(t)}`),sendTeamChatMessage:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:JSON.stringify(n)}),createTeamChatAgentRun:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/agent-runs`,{method:"POST",body:JSON.stringify(n)}),teamChatAgentConversation:(e,t,n)=>B(e,`/v1/team-chat/agent-runs/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),editTeamChatMessage:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)}),deleteTeamChatMessage:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"DELETE",body:JSON.stringify({teamId:a})}),markTeamChatRead:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/read`,{method:"POST",body:JSON.stringify({teamId:n,sequence:a})}),setTeamChatThreadMuted:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/mute`,{method:"POST",body:JSON.stringify({teamId:n,muted:a})}),createTeamChatAiThread:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/ai-threads`,{method:"POST",body:JSON.stringify(n)}),teamChatAiThread:(e,t,n)=>B(e,`/v1/team-chat/ai-threads/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),sendTeamChatAiTurn:(e,t,n)=>B(e,`/v1/team-chat/ai-threads/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),executeTeamChatAiTurn:(e,t,n)=>B(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute`,{method:"POST",body:JSON.stringify({teamId:n})}),cancelTeamChatAiTurnExecution:(e,t,n)=>B(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute/cancel`,{method:"POST",body:JSON.stringify({teamId:n})}),usage:(e,t={})=>{const n=Ub(t),a=n.size?`?${n.toString()}`:"";return B(e,`/v1/usage${a}`)},usageRecords:(e,t={})=>{const n=Ub(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 B(e,`/v1/usage/records${a}`)},usageTurnCache:(e,t)=>B(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 B(e,`/v1/events/page${a}`)},workOutputs:e=>B(e,"/v1/work/outputs"),harnessHistory:e=>B(e,"/v1/harness"),refinerHistory:e=>B(e,"/v1/refiner"),updateRefinerProfile:(e,t)=>B(e,"/v1/refiner/update",{method:"POST",body:JSON.stringify(t)}),activateRefinerRelease:(e,t)=>B(e,"/v1/refiner/activate",{method:"POST",body:JSON.stringify(t)}),rollbackRefinerRelease:(e,t)=>B(e,"/v1/refiner/rollback",{method:"POST",body:JSON.stringify(t)}),updateHarnessBackgroundReview:(e,t)=>B(e,"/v1/harness/background-review",{method:"POST",body:JSON.stringify(t)}),reviewHarnessEvaluation:(e,t)=>B(e,"/v1/harness/evaluation-review",{method:"POST",body:JSON.stringify(t)}),updateHarnessEvaluationReviewSchedule:(e,t)=>B(e,"/v1/harness/evaluation-review/settings",{method:"POST",body:JSON.stringify(t)}),harnessReleaseDiff:(e,t)=>B(e,"/v1/harness/diff",{method:"POST",body:JSON.stringify(t)}),rollbackHarness:(e,t)=>B(e,"/v1/harness/rollback",{method:"POST",body:JSON.stringify(t)}),reviewHarnessProposal:(e,t)=>B(e,"/v1/harness/review",{method:"POST",body:JSON.stringify(t)}),runSubagentLifecycleAction:(e,t,n)=>B(e,`/v1/subagents/${encodeURIComponent(t)}/lifecycle`,{method:"POST",body:JSON.stringify(n)}),trainingState:(e,t)=>B(e,`/v1/training?profileId=${encodeURIComponent(t)}`),trainingActivity:(e,t)=>B(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),B(e,`/v1/training/catalog${a.size?`?${a.toString()}`:""}`)},datasetCatalog:(e,t)=>B(e,`/v1/training/datasets?profileId=${encodeURIComponent(t)}`),trainingRunDetail:(e,t,n={})=>B(e,`/v1/training/jobs/${encodeURIComponent(t)}/detail?evaluation=${n.includeEvaluation===!1?"false":"true"}`),candidateReview:(e,t,n=!1,a="models")=>B(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision?refresh=${n}`),recordCandidateReview:(e,t,n,a="models")=>B(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision`,{method:"POST",body:JSON.stringify(n)}),candidateReviewHistory:(e,t,n,a="models")=>B(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),B(e,`/v1/training/jobs/${encodeURIComponent(t)}/evaluations/${encodeURIComponent(n.id)}/tasks?${r}`)},trainingRequest:(e,t,n,a="POST")=>B(e,`/v1/training${t}`,{method:a,body:a==="GET"||a==="DELETE"?void 0:JSON.stringify(n)}),datasetStorageState:e=>B(e,"/v1/settings/dataset-storage"),updateDatasetStorage:(e,t)=>B(e,"/v1/settings/dataset-storage",{method:"PATCH",body:JSON.stringify({datasetStorePath:t})}),hostedSavedWork:e=>B(e,"/v1/saved-work"),createHostedSavedWork:(e,t)=>B(e,"/v1/saved-work",{method:"POST",body:JSON.stringify(t)}),updateHostedSavedWork:(e,t,n)=>B(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteHostedSavedWork:(e,t)=>B(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"DELETE"}),runHostedSavedWork:(e,t,n)=>B(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 B(e,`/v1/chat-workflows${n}`)},createChatWorkflow:(e,t)=>B(e,"/v1/chat-workflows",{method:"POST",body:JSON.stringify(t)}),updateChatWorkflow:(e,t,n)=>B(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteChatWorkflow:(e,t)=>B(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),runChatWorkflow:(e,t)=>B(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 B(e,`/v1/local-agent-schedules${a}`)},syncLocalAgentSchedules:e=>B(e,"/v1/local-agent-schedules/sync",{method:"POST",body:JSON.stringify({})}),patchLocalAgentSchedule:(e,t,n)=>B(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),runLocalAgentSchedule:(e,t,n={})=>B(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 B(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}/runs${r}`)},refreshOpenPondAccounts:e=>B(e,"/v1/openpond/accounts/refresh",{method:"POST",body:JSON.stringify({})}),refreshOpenPondAccount:e=>B(e,"/v1/openpond/account?refresh=1"),loadMoreOpenPondApps:(e,t)=>B(e,`/v1/openpond/apps/more?offset=${encodeURIComponent(String(t.offset))}&limit=${encodeURIComponent(String(t.limit))}`),switchOpenPondAccount:(e,t)=>B(e,"/v1/openpond/accounts/switch",{method:"POST",body:JSON.stringify(t)}),removeOpenPondAccount:(e,t)=>B(e,"/v1/openpond/accounts",{method:"DELETE",body:JSON.stringify(t)}),signOutOpenPondAccount:e=>B(e,"/v1/openpond/accounts/logout",{method:"POST",body:JSON.stringify({})}),saveOpenPondAccount:(e,t)=>B(e,"/v1/openpond/accounts/login",{method:"POST",body:JSON.stringify(t)}),updateOpenPondAccountConfig:(e,t)=>B(e,"/v1/openpond/accounts/config",{method:"PATCH",body:JSON.stringify(t)}),savePreferences:(e,t)=>B(e,"/v1/preferences",{method:"PATCH",body:JSON.stringify(t)}),saveProviderSettings:(e,t)=>B(e,"/v1/providers",{method:"PATCH",body:JSON.stringify(t)}),providerSettings:e=>B(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 B(e,`/v1/providers/${encodeURIComponent(t)}/models${r}`)},refreshProviderModels:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/models`,{method:"POST",body:JSON.stringify(n)}),saveProviderCredential:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"PUT",body:JSON.stringify(n)}),deleteProviderCredential:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"DELETE",body:JSON.stringify(n)}),startOpenAiSubscriptionAuth:(e,t)=>B(e,"/v1/providers/openai/subscription-auth",{method:"POST",body:JSON.stringify(t)}),validateProviderCredential:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(n)}),savePersonalization:(e,t)=>B(e,"/v1/personalization",{method:"PATCH",body:JSON.stringify(t)}),recordClientDiagnostic:(e,t)=>B(e,"/v1/diagnostics/client",{method:"POST",body:JSON.stringify(t)}),profileCurrent:e=>B(e,"/v1/profile"),profileCatalog:e=>B(e,"/v1/profile/catalog"),profileSelect:(e,t)=>B(e,"/v1/profile/select",{method:"POST",body:JSON.stringify({ref:t})}),profileRemove:(e,t)=>B(e,"/v1/profile/remove",{method:"POST",body:JSON.stringify({ref:t})}),profilePublicationPreview:(e,t)=>B(e,"/v1/profile/publication/preview",{method:"POST",body:JSON.stringify(t)}),profilePublicationPublish:(e,t)=>B(e,"/v1/profile/publication/publish",{method:"POST",body:JSON.stringify(t)}),profileInstall:(e,t)=>B(e,"/v1/profile/install",{method:"POST",body:JSON.stringify(t)}),profileUpdate:(e,t)=>B(e,"/v1/profile/update",{method:"POST",body:JSON.stringify({ref:t})}),profileInit:(e,t)=>B(e,"/v1/profile/init",{method:"POST",body:JSON.stringify(t)}),profileLoad:(e,t)=>B(e,"/v1/profile/load",{method:"POST",body:JSON.stringify(t)}),profileCheck:(e,t)=>B(e,"/v1/profile/check",{method:"POST",body:JSON.stringify(t)}),profileAgentRename:(e,t,n)=>B(e,`/v1/profile/agents/${encodeURIComponent(t)}/name`,{method:"PATCH",body:JSON.stringify(n)}),profileCommit:(e,t)=>B(e,"/v1/profile/commit",{method:"POST",body:JSON.stringify(t)}),profilePush:(e,t)=>B(e,"/v1/profile/push",{method:"POST",body:JSON.stringify(t)}),workspaceLspSettingsStatus:e=>B(e,"/v1/lsp/settings-status"),workspaceLspRuntimeStatus:e=>B(e,"/v1/lsp/status"),restartWorkspaceLsp:e=>B(e,"/v1/lsp/restart",{method:"POST"}),remoteAccess:e=>B(e,"/v1/remote-access"),enableRemoteAccess:e=>B(e,"/v1/remote-access/enable",{method:"POST"}),disableRemoteAccess:e=>B(e,"/v1/remote-access/disable",{method:"POST"}),voiceTranscriptionStatus:(e,t={})=>B(e,"/v1/audio/transcriptions/status",{signal:t.signal}),transcribeVoice:(e,t,n={})=>B(e,"/v1/audio/transcriptions",{method:"POST",body:JSON.stringify(t),signal:n.signal}),createSession:(e,t)=>B(e,"/v1/sessions",{method:"POST",body:JSON.stringify(t)}),patchSession:(e,t,n)=>B(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 B(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"),B(e,`/v1/codex-history/${encodeURIComponent(t)}?${a.toString()}`)},sendCodexHistoryTurn:(e,t,n)=>B(e,`/v1/codex-history/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),interruptCodexHistoryTurn:(e,t)=>B(e,`/v1/codex-history/${encodeURIComponent(t)}/turns/interrupt`,{method:"POST"}),patchSidebarAppPreference:(e,t,n)=>B(e,`/v1/sidebar/apps/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),reorderSidebarApps:(e,t)=>B(e,"/v1/sidebar/apps/reorder",{method:"POST",body:JSON.stringify(t)}),sidebarFiles:e=>B(e,"/v1/sidebar/files"),patchSidebarFile:(e,t)=>B(e,"/v1/sidebar/files",{method:"PATCH",body:JSON.stringify(t)}),workspaceStatus:(e,t,n=!1,a={})=>B(e,`/v1/workspaces/${encodeURIComponent(t)}${n?"?ensure=1":""}`,{signal:a.signal}),createWorkspaceBranch:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/branches`,{method:"POST",body:JSON.stringify(n)}),checkoutWorkspaceBranch:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/branch`,{method:"PATCH",body:JSON.stringify(n)}),workspaceDiff:(e,t,n={})=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/diff`,{signal:n.signal}),workspaceFile:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`),saveWorkspaceFile:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/file`,{method:"PATCH",body:JSON.stringify(n)}),signWorkspaceImageUrl:(e,t)=>B(e,"/v1/assets/workspace-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalImageUrl:(e,t)=>B(e,"/v1/assets/local-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalVideoUrl:(e,t)=>B(e,"/v1/assets/local-video-url",{method:"POST",body:JSON.stringify(t)}),signChatAttachmentImageUrl:(e,t)=>B(e,"/v1/assets/chat-attachment-image-url",{method:"POST",body:JSON.stringify(t)}),chatAttachmentFile:(e,t)=>B(e,"/v1/assets/chat-attachment-file",{method:"POST",body:JSON.stringify(t)}),workspaceLspTouch:(e,t,n,a={})=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/touch`,{method:"POST",body:JSON.stringify(n),signal:a.signal}),workspaceLspAction:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/action`,{method:"POST",body:JSON.stringify(n)}),workspaceTemplateConfig:(e,t)=>B(e,`/v1/openpond/apps/${encodeURIComponent(t)}/template-config`),...PB,...NB,createLocalProject:(e,t)=>B(e,"/v1/projects",{method:"POST",body:JSON.stringify(t)}),updateLocalProjectAgentSetup:(e,t,n)=>B(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),uploadLocalProjectCloudSource:(e,t,n)=>B(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 B(e,`/v1/projects/${encodeURIComponent(t)}/cloud-source/preview${r}`)},deleteLocalProject:(e,t)=>B(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"DELETE"}),gitAvailability:e=>B(e,"/v1/system/git"),installMacOSCommandLineTools:e=>B(e,"/v1/system/git/install-command-line-tools",{method:"POST",body:JSON.stringify({})}),...AB,resolveApproval:(e,t,n)=>B(e,`/v1/approvals/${t}`,{method:"POST",body:JSON.stringify(n)})};function Ub(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 FB=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),VB=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),zb=e=>{const t=VB(e);return t.charAt(0).toUpperCase()+t.slice(1)},h1=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),KB=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var WB={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 GB=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,...WB,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:h1("lucide",r),...!i&&!KB(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(GB,{ref:i,iconNode:t,className:h1(`lucide-${FB(zb(e))}`,`lucide-${e}`,a),...r}));return n.displayName=zb(e),n};const ZB=[["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"}]],JB=dt("activity",ZB);const YB=[["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"}]],QB=dt("archive-restore",YB);const XB=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],eF=dt("arrow-left",XB);const tF=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],g1=dt("bookmark",tF);const nF=[["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"}]],v1=dt("bookmark-x",nF);const aF=[["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"}]],Hb=dt("book-open-text",aF);const oF=[["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"}]],Wm=dt("boxes",oF);const rF=[["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"}]],iF=dt("calendar-clock",rF);const sF=[["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"}]],b1=dt("chart-column-stacked",sF);const lF=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wo=dt("check",lF);const cF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Xp=dt("circle-check",cF);const dF=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],zo=dt("chevron-down",dF);const uF=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Nr=dt("chevron-right",uF);const mF=[["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",mF);const fF=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Zd=dt("cloud",fF);const hF=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],gF=dt("credit-card",hF);const vF=[["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"}]],bF=dt("download",vF);const yF=[["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"}]],Gm=dt("external-link",yF);const SF=[["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"}]],xF=dt("file-output",SF);const kF=[["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"}]],Qh=dt("file-text",kF);const wF=[["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"}]],IF=dt("folder",wF);const _F=[["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"}]],y1=dt("folder-git-2",_F);const CF=[["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"}]],RF=dt("git-branch",CF);const PF=[["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"}]],AF=dt("github",PF);const TF=[["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"}]],S1=dt("earth",TF);const EF=[["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"}]],MF=dt("circle-question-mark",EF);const jF=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],OF=dt("list-filter",jF);const $F=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],NF=dt("loader-circle",$F);const DF=[["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"}]],LF=dt("maximize-2",DF);const UF=[["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"}]],Jd=dt("message-square",UF);const zF=[["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"}]],Xh=dt("ellipsis",zF);const HF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],x1=dt("panel-left",HF);const qF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],ef=dt("panel-right",qF);const BF=[["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"}]],eg=dt("pin",BF);const FF=[["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"}]],tg=dt("pin-off",FF);const VF=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],KF=dt("plus",VF);const WF=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],GF=dt("power",WF);const ZF=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],JF=dt("search",ZF);const YF=[["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"}]],ng=dt("settings",YF);const QF=[["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"}]],k1=dt("shapes",QF);const XF=[["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"}]],e5=dt("shield",XF);const t5=[["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"}]],ag=dt("square-pen",t5);const n5=[["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"}]],w1=dt("square-terminal",n5);const a5=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],qb=dt("user-round",a5);const o5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rs=dt("x",o5);function r5({platform:e}){return!Yd()||og(e)?null:S.jsxs("div",{className:"window-controls","aria-label":"Window controls",children:[S.jsx("button",{type:"button",className:"window-control minimize",title:"Minimize",onClick:()=>{Zm("minimize")},children:S.jsx(zo,{size:14})}),S.jsx("button",{type:"button",className:"window-control maximize",title:"Maximize",onClick:()=>{Zm("toggleMaximize")},children:S.jsx(LF,{size:12})}),S.jsx("button",{type:"button",className:"window-control close",title:"Close",onClick:()=>{Zm("close")},children:S.jsx(rs,{size:13})})]})}function og(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")}function Yd(){if(typeof window>"u")return!1;const e=window.openpond;return!!(e?.minimizeWindow||e?.toggleMaximizeWindow||e?.closeWindow)}async function Zm(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 i5({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(""),O=g.useRef(null),[P,L]=g.useState();g.useLayoutEffect(()=>{if(!y||!h)return;function C(){const A=O.current?.getBoundingClientRect();if(!A)return;const z=window.innerHeight-A.bottom-12,q=A.top-12,N=z<180&&q>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?q-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],j=_.trim().toLowerCase(),x=j?t.filter(C=>[C.label,C.shortLabel,C.description].some(A=>A?.toLowerCase().includes(j))):t;return g.useEffect(()=>{if(!y){E("");return}function C(z){O.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]),S.jsxs("div",{className:`dropdown-select ${r??""} ${a?"compact":""} ${s==="top"?"open-up":""}`,"data-tooltip":m,ref:O,children:[S.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,S.jsx("span",{children:$?.shortLabel??$?.label??e}),S.jsx(zo,{size:14})]}),y&&S.jsxs("div",{className:"dropdown-menu",role:"menu",style:h?P:void 0,children:[u?S.jsxs("label",{className:"dropdown-search",onClick:C=>C.stopPropagation(),children:[S.jsxs("span",{className:"sr-only",children:["Search ",l]}),S.jsx("input",{autoFocus:!0,placeholder:`Search ${l.toLowerCase()}`,value:_,onChange:C=>E(C.target.value)})]}):null,x.map(C=>S.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:[S.jsxs("span",{children:[C.icon==="plus"?S.jsx(KF,{size:13}):null,S.jsx("span",{children:C.label})]}),C.description&&S.jsx("small",{children:C.description})]},C.value)),x.length?null:S.jsx("div",{className:"dropdown-empty",children:"No matches"})]})]})}const s5=[{destination:"walkthroughs",icon:Hb,label:"Walkthroughs"},{destination:"external",icon:Hb,label:"Docs",url:"https://openpond.ai/docs"},{destination:"external",icon:Qh,label:"Blog",url:"https://openpond.ai/blog"},{destination:"external",icon:gF,label:"Pricing",url:"https://openpond.ai/pricing"},{destination:"external",icon:S1,label:"Web app",url:"https://openpond.ai/sandboxes"},{destination:"external",icon:AF,label:"GitHub",url:"https://github.com/openpond/openpond"},{destination:"external",icon:Jd,label:"Submit issue",url:"https://github.com/openpond/openpond/issues/new/choose"}];function l5({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]),S.jsxs("div",{className:"sidebar-help-menu",ref:r,children:[S.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:S.jsx(MF,{size:17})}),n?S.jsx("div",{className:"sidebar-help-popover",role:"menu","aria-label":"Help",children:s5.map(i=>{const s=i.icon,l=S.jsxs(S.Fragment,{children:[S.jsx(s,{size:15}),S.jsx("span",{children:i.label})]});return i.destination==="walkthroughs"?S.jsx("button",{"aria-current":t?"page":void 0,className:"sidebar-help-item",onClick:()=>{a(!1),e()},role:"menuitem",type:"button",children:l},i.label):S.jsx("a",{className:"sidebar-help-item",href:i.url,onClick:m=>{m.preventDefault(),a(!1),c5(i.url)},rel:"noreferrer",role:"menuitem",target:"_blank",children:l},i.label)})}):null]})}async function c5(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-help",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const NZ=[{value:"chat",label:"Chat"},{value:"work",label:"Work"}],Jm=[{value:"chat",label:"Work",description:"Chat and complete tasks"},{value:"models",label:"Models",description:"Evaluate, train, and serve models"}];function I1(e){return e==="chat"?"New chat":"New task"}const tf=["get-started","models","tasks","tasksets","labeling","rewards","evaluations","runs","versions","serving"],d5={"get-started":"Get started",models:"Models",tasks:"Tasks",tasksets:"Tasksets",labeling:"Labeling",rewards:"Rewards",evaluations:"Runs",runs:"Runs",versions:"Versions",serving:"Serving"},u5={tasks:["drafts"],tasksets:["drafts","formats","batches"],rewards:["scorers","combined"],evaluations:["results","review","comparisons"],runs:["series","new"]},m5={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 rg(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]&&!tf.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(!tf.includes(i)||r==="models"||a&&i==="get-started")return null;let s=i==="evaluations"?"results":"default";if(u5[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&&!m5[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 Qd(e){const t=["/models"];if(e.modelId&&t.push(encodeURIComponent(e.modelId)),e.page==="evaluations"&&e.collection==="review")return Qd(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 p5(e,t){return ro(e.page,t,{collection:e.collection==="new"||e.collection==="drafts"?"default":e.collection})}function DZ(e,t,n=null){return{...e,resourceId:t,detailTab:n,after:null}}const id=new Set,nf=new Set,f5=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"]),af={apps:"/apps",outputs:"/outputs",projects:"/projects",scheduled:"/workflows","get-started":"/get-started"};let of=!1,rf="",Uc=null,_1=null,Sl="",Aa=0,Ks=null,il=!1,Ym=null,zc=!1;function ig(e){const t=rg(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&&f5.has(n[1])){const r=sg(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(af).find(r=>af[r]===e.pathname);return a?{kind:"view",view:a}:null}function C1(e){if(e.kind==="models")return Qd(e.route);if(e.kind==="models_unavailable")return`${e.pathname}${e.search}`;if(e.kind==="settings"){const t=sg(e.returnTo??null);return`/settings/${e.section}${t?`?${new URLSearchParams({returnTo:t})}`:""}`}return e.kind==="chat"?e.sessionId?`/chat/${encodeURIComponent(e.sessionId)}`:"/chat/new":af[e.view]}function h5(e){const t=e?.kind==="settings"?sg(e.returnTo??null):null;if(t){const n=new URL(t,"https://local.openpond.invalid"),a=rg(n);if(a)return{kind:"models",route:a}}return{kind:"chat",sessionId:null}}function sg(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=rg(t);return n?Qd(n):null}function Fl(){return`${window.location.pathname}${window.location.search}`}function lg(){if(typeof window>"u")return;const e=of?Sl:Fl();e!==rf&&(rf=e,Uc=ig(new URL(e,window.location.origin)),_1=Uc?.kind==="models"?Uc.route:null)}function R1(){rf="",lg();for(const e of nf)e()}async function cg(e){if(zc)return!1;zc=!0;try{for(const t of[...id].reverse())if(!await t(e))return!1;return!0}finally{zc=!1}}function dg(e){return{...window.history.state,openpondNavigationIndex:e}}async function g5(){const e=Fl(),t=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:Aa-1;if(Ks&&t===Aa){const a=Ks;Ks=null,a();return}if(Ym===t||id.size===0){Ym=null,Sl=e,Aa=t,window.history.replaceState(dg(Aa),"",e),R1();return}if(t===Aa)return;if(il||zc){Ks??=()=>{},window.history.go(Aa-t);return}il=!0;const n=t-Aa;try{await new Promise(a=>{Ks=a,window.history.go(-n)}),await cg(e)&&(Ym=t,window.history.go(n))}finally{il=!1}}function ug(){if(of||typeof window>"u")return;const e=ig(window.location);Sl=e?C1(e):Fl(),Aa=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:0,window.history.replaceState(dg(Aa),"",Sl),window.addEventListener("popstate",g5),of=!0}function P1(e){return nf.add(e),ug(),()=>{nf.delete(e)}}function LZ(e){return id.add(e),ug(),()=>{id.delete(e)}}async function UZ(e){!il&&await cg(Fl())&&e()}function v5(){return g.useSyncExternalStore(P1,()=>(lg(),_1),()=>null)}function b5(){return g.useSyncExternalStore(P1,()=>(lg(),Uc),()=>null)}async function sn(e,t="push"){if(typeof window>"u"||(ug(),il))return!1;if(e.kind==="settings"&&!e.returnTo){const a=ig(window.location),r=a?.kind==="models"?Qd(a.route):a?.kind==="settings"?a.returnTo:void 0;r&&(e={...e,returnTo:r})}const n=C1(e);return Fl()===n?!0:await cg(n)?(t==="push"&&Aa++,window.history[t==="replace"?"replaceState":"pushState"](dg(Aa),"",n),Sl=n,R1(),!0):!1}function Oi(e,t="push"){return sn({kind:"models",route:e},t)}function y5({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=v5(),y=b?.modelId??null,w=b?.page??"models";function _(){r(null),i(null),s(null),a(null)}async function E($){await Oi(ro($,y))&&(_(),l("labs"))}async function O($){await Oi(p5(b??ro(),$||null))&&(_(),l("labs"))}async function P($){await sn({kind:"view",view:$})&&(_(),l($))}const L=y?h[y]??null:null;return S.jsxs("nav",{className:"sidebar-nav","aria-label":"Primary",children:[t==="models"?null:S.jsxs("button",{className:"nav-command nav-command-new-task",type:"button",onClick:()=>{sn({kind:"chat",sessionId:null}),n(null)},children:[S.jsx(ag,{size:18}),S.jsx("span",{children:I1(e)})]}),t==="models"?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"sidebar-model-project-picker",children:[S.jsx("span",{className:"sidebar-nav-group-label",children:"Model"}),S.jsx(i5,{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:$=>{O($)}})]}),tf.filter($=>$!=="tasksets"&&$!=="evaluations").map($=>{const j={"get-started":Wm,models:JB,tasks:Wm,tasksets:Wm,labeling:Xp,rewards:e5,evaluations:Xp,runs:b1,versions:RF,serving:Zd}[$];return S.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:[S.jsx(j,{size:16}),S.jsx("span",{children:d5[$]}),$==="runs"&&L?S.jsx("span",{className:"sidebar-running-dot","aria-label":L.label}):null]},$)})]}):null,t==="chat"?S.jsxs(S.Fragment,{children:[S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="scheduled"?"active":""}`,"aria-label":"Workflows",type:"button",onClick:()=>{P("scheduled")},children:[S.jsx(iF,{size:18}),S.jsx("span",{children:"Workflows"})]}),S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="outputs"?"active":""}`,"aria-label":"Outputs",type:"button",onClick:()=>{P("outputs")},children:[S.jsx(xF,{size:18}),S.jsx("span",{children:"Outputs"})]}),S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="apps"?"active":""}`,"aria-label":"Apps",type:"button",onClick:()=>{P("apps")},children:[S.jsx(k1,{size:18}),S.jsx("span",{children:"Apps"})]}),S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="projects"?"active":""}`,"aria-label":"Projects",type:"button",onClick:()=>{P("projects")},children:[S.jsx(y1,{size:18}),S.jsx("span",{children:"Projects"})]})]}):null]})}function S5({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"),sn({kind:"view",view:"get-started"})}return S.jsx("nav",{className:"sidebar-utility-nav","aria-label":"Resources",children:S.jsx(l5,{onOpenWalkthroughs:s,walkthroughsActive:i==="get-started"})})}const A1=pm({chatMode:v(["chat","work"]).optional(),notificationMode:v(["all","direct_mentions","none"]).optional(),learningNoticeDismissed:R().optional(),sidebarVisibility:pm({showCodexChats:R(),onlyRunningTasks:R()}).optional(),scheduledWorkView:v(["calendar","list"]).optional(),editorControlsVisible:R().optional(),voiceNoticeAcknowledged:R().optional(),lessonProgress:se(o().min(1).max(200),pm({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()}),sf={"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"},lf=new Set;let sl=null,No=null,Ea={},xl={},Qm=!1,Hc=0,$i=null,Bb=0;const x5="openpond-client-choices-changed";function mg(){lf.forEach(e=>e()),typeof window<"u"&&window.dispatchEvent(new Event(x5))}function k5(){return $i}function w5(e){return lf.add(e),()=>{lf.delete(e)}}function Vl(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>w5(()=>t.current()),[])}async function Fb(e){const t=++Bb,n=await B(e,"/v1/configuration");if(n.clientState?.revision===null){const r=I5();if(Object.keys(r.patch).length){n.clientState=await B(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!==Bb)return;const a=sl?.serverUrl!==e.serverUrl||sl?.token!==e.token||No?.owner!==n.clientState?.owner;a&&(Hc++,Ea={},xl={},$i=null),sl=e,(a||(n.clientState?.revision??0)>=(No?.revision??0))&&(No=n.clientState),mg()}async function pg(){if(Qm||!sl||!No||!Object.keys(Ea).length)return;Qm=!0;const e=Ea,t=sl,n=No.owner,a=Hc;Ea={},xl=e;try{const r=await B(t,"/v1/configuration",{method:"POST",body:JSON.stringify({action:"client-state",owner:n,patch:e})});a===Hc&&(No=r,$i=null)}catch(r){a===Hc&&(Ea={...e,...Ea},$i=`Preference changes have not been saved. ${r instanceof Error?r.message:String(r)}`)}finally{xl={},Qm=!1,mg(),!$i&&Object.keys(Ea).length&&pg()}}function zZ(){$i=null,pg()}const Kl={getItem(e){const t=sf[e];if(!t)return null;const n={...No?.value,...xl,...Ea}[t];return n===void 0?null:typeof n=="string"?n:JSON.stringify(n)},setItem(e,t){if(!No)return;const n=sf[e];if(!n)throw new Error("Unregistered client preference.");let a;try{a=JSON.parse(t)}catch{a=t}const r=A1.parse({[n]:a});JSON.stringify({...No.value,...xl,...Ea}[n])!==JSON.stringify(r[n])&&(Ea={...Ea,...r},mg(),pg())}};function I5(){const e={},t=[];if(typeof window>"u")return{patch:e,keys:t};for(const[n,a]of Object.entries(sf))try{const r=window.localStorage.getItem(n);if(r===null)continue;let i;try{i=JSON.parse(r)}catch{i=r}const s=A1.safeParse({[a]:i});s.success&&(Object.assign(e,s.data),t.push(n))}catch{}return{patch:e,keys:t}}const qc=5,Cn=15,cf=10,Tt={defaultChatProvider:jr,subagents:NE(),codexPermissionMode:nh,codexReasoningEffort:ah,openPondCommandAccessMode:Cd,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:""}}}},HZ={activeTemplateId:"default",customized:!1,soul:"",soulPath:null,updatedAt:null,templates:[]},T1=[{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"}],Xm=[{value:"openpond",label:"OpenPond Chat"},{value:"codex",label:"OpenAI Codex",description:"Codex login"}],_5=["openai","xai","openrouter","deepseek","zai","moonshot","together","groq","custom-openai-compatible"],C5=["openpond","codex",..._5],E1=new Set(C5),M1=[{value:th,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"}],qZ=[{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."}],BZ=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High",shortLabel:"Extra High"}],FZ=[{value:"ask",label:"Ask",description:"Ask before running shell commands."},{value:"full-access",label:"Full access",description:"Run shell commands without approval prompts."}],VZ=[{value:"auto",label:"Auto",description:"Use installed language servers when available."},{value:"off",label:"Off",description:"Disable editor language servers."}],KZ=[{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 fg(e){return e.kind==="local"}function R5(e){return e.kind==="cloud"}function vt(e,t){return`${e}:${t}`}function j1(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 Ar(e){return`${e.type}:${e.id}`}function sd(e){const t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?"before":"after"}function ld(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 Vb(e,t){return e.length===t.length&&e.every((n,a)=>n===t[a])}function P5(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 hg(e,t){return e?.statuses?.[t]??null}function O1(e,t){return e?.providers?.[t]??null}function $1(e,t){return e?.modelCaches?.[t]??null}function A5(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 T5(e){return e==="openpond"?T1:e==="codex"||e==="openai"?M1:[]}function E5(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 WZ(e){return E1.has(e)}function df(e,t={}){if(!e)return t.localOnly,Xm;const n=t.includeUnavailable??!1,a=t.enabledOnly??!1,r=[];for(const i of Ff){if(!E1.has(i)||t.localOnly&&i==="openpond")continue;const s=hg(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:Xm}function kl(e,t){const a=($1(t,e)?.models??[]).filter(s=>e!=="openpond"||s.id!==zi).map(A5),r=O1(t,e),i=[...r?.modelOverrides??[],r?.defaultModel].filter(s=>!!s?.trim()&&(e!=="openpond"||s!==zi)).map(s=>({value:s,label:s}));return E5([...a,...i,...T5(e)])}function M5(e,t,n){if(e==="codex"||e==="openai")return!0;const a=t.trim();if(!a)return!1;const r=$1(n,e)?.models.find(i=>i.id===a);return r?!!r.capabilities.reasoning:kl(e,n).some(i=>i.value===a&&/\breasoning\b/i.test(i.description??""))}function cd(e,t){const n=O1(t,e)?.defaultModel?.trim();if(n)return n;const a=hg(t,e)?.defaultModel?.trim();if(a)return a;const r=kl(e,t)[0]?.value?.trim();return r||(e==="codex"?th:e==="openpond"?zi:"")}function dr(e,t,n){const a=t?.trim();if(e==="codex"&&(a==="codex-default"||a==="gpt-5.5"))return th;const r=kl(e,n);return a&&r.some(i=>i.value===a)||a&&e!=="codex"&&r.length===0&&!n?a:cd(e,n)}function N1(e,t){const n=e.modelRef?.providerId??e.provider;return{provider:n,model:dr(n,e.modelRef?.modelId,t)}}function gg(e,t,n){return dr(e,t,n)||void 0}function Ra(e,t,n){const a=gg(e,t,n);return a?{providerId:e,modelId:a}:void 0}function Kb(e){return e==="full-access"?{approvalPolicy:"never",sandbox:"danger-full-access"}:{approvalPolicy:"on-request",sandbox:"workspace-write"}}function ma(e){const t=e?.defaultChatProvider??Tt.defaultChatProvider;return{defaultChatProvider:t,defaultChatModel:dr(t,e?.defaultChatModel),subagents:ul.parse(e?.subagents??Tt.subagents),codexPermissionMode:e?.codexPermissionMode??Tt.codexPermissionMode,codexReasoningEffort:e?.codexReasoningEffort??Tt.codexReasoningEffort,openPondCommandAccessMode:e?.openPondCommandAccessMode??Tt.openPondCommandAccessMode,defaultBranchPrefix:D1(e?.defaultBranchPrefix),defaultNewProjectDirectory:e?.defaultNewProjectDirectory??Tt.defaultNewProjectDirectory,defaultTeamId:e?.defaultTeamId?.trim()||null,advancedWorkspaceControls:e?.advancedWorkspaceControls??Tt.advancedWorkspaceControls,steerActiveResponses:e?.steerActiveResponses??Tt.steerActiveResponses,contextCompaction:{autoEnabled:e?.contextCompaction?.autoEnabled??Tt.contextCompaction.autoEnabled,triggerPercent:e?.contextCompaction?.triggerPercent??Tt.contextCompaction.triggerPercent,summaryModel:e?.contextCompaction?.summaryModel??Tt.contextCompaction.summaryModel},training:{defaultModelRef:e?.training?.defaultModelRef??Tt.training.defaultModelRef,creationMode:e?.training?.creationMode??Tt.training.creationMode,autoApproveEvidence:e?.training?.autoApproveEvidence??Tt.training.autoApproveEvidence},sidebarWidth:e?.sidebarWidth??Tt.sidebarWidth,diffPanelWidth:e?.diffPanelWidth??Tt.diffPanelWidth,sidebarSectionsCollapsed:{pinned:e?.sidebarSectionsCollapsed?.pinned??Tt.sidebarSectionsCollapsed.pinned,projects:e?.sidebarSectionsCollapsed?.projects??Tt.sidebarSectionsCollapsed.projects,cloudProjects:e?.sidebarSectionsCollapsed?.cloudProjects??Tt.sidebarSectionsCollapsed.cloudProjects,chats:e?.sidebarSectionsCollapsed?.chats??Tt.sidebarSectionsCollapsed.chats,savedForLater:e?.sidebarSectionsCollapsed?.savedForLater??Tt.sidebarSectionsCollapsed.savedForLater},editor:{languageServers:e?.editor?.languageServers??Tt.editor.languageServers,diagnosticsWhileEditing:e?.editor?.diagnosticsWhileEditing??Tt.editor.diagnosticsWhileEditing,checkOnSave:e?.editor?.checkOnSave??Tt.editor.checkOnSave,languages:{typescript:{mode:e?.editor?.languages?.typescript?.mode??Tt.editor.languages.typescript.mode,customCommand:e?.editor?.languages?.typescript?.customCommand??Tt.editor.languages.typescript.customCommand},python:{mode:e?.editor?.languages?.python?.mode??Tt.editor.languages.python.mode,customCommand:e?.editor?.languages?.python?.customCommand??Tt.editor.languages.python.customCommand},rust:{mode:e?.editor?.languages?.rust?.mode??Tt.editor.languages.rust.mode,customCommand:e?.editor?.languages?.rust?.customCommand??Tt.editor.languages.rust.customCommand}}}}}function D1(e){const t=e?.trim()??Tt.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 GZ(e,t){return e==="openpond"?"OpenPond Chat":hg(t,e)?.displayName??(e==="codex"?"OpenAI Codex":e)}function ZZ(e,t,n){if(n){const a=kl(n,t).find(r=>r.value===e);if(a)return a.label}if(t)for(const a of Ff){const r=kl(a,t).find(i=>i.value===e);if(r)return r.label}return[...T1,...M1].find(a=>a.value===e)?.label??e}function j5(e,t){return t==="chat"?e.filter(n=>n.experience==="chat"):e.filter(n=>n.experience==="work"||n.experience==="development")}function O5(e){return e.experience==="chat"?"Chat":"Work"}const vg="taskDraft";function L1(e){if(e?.experience!=="work")return null;const t=e.metadata?.[vg];if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.prompt;return typeof n=="string"&&n.trim()?n:null}function wl(e){return L1(e)!==null}function $5(e){return(e.split(/\r?\n/u).map(n=>n.trim()).find(Boolean)||"Task draft").slice(0,64)}function ep(e,t,n=new Date().toISOString()){const a={version:1,prompt:t,savedAt:n};return{...e??{},[vg]:a}}function N5(e){const t={...e??{}};return delete t[vg],t}function tr(e){const t=wc(e.metadata?.trainingTasksetId)??wc(e.metadata?.tasksetId);return t?{id:t,name:wc(e.metadata?.trainingTasksetName)??wc(e.metadata?.tasksetName)??D5(t)}:null}function D5(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 wc(e){return typeof e=="string"&&e.trim()?e.trim():null}const L5="codex_history_";function Ht(e){return!!e?.startsWith(L5)}function U1(e){const t=[],n=new Set;for(const a of e)for(const r of[a.workspacePath,a.path]){const i=Xd(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 U5(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=z1(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"||!H1(e))return null;const r=Xd(e.cwd);if(!r)return null;for(const i of n)if(bg(r,i.path))return i.projectId;return null}function Wb(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=z1(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"||!H1(e))return null;const r=Xd(e.cwd);if(!r)return null;for(const i of n)if(bg(r,i.path))return vt("local",i.projectId);return null}function z1(e,t){const n=Xd(e);if(!n)return null;for(const a of t)if(bg(n,a.path))return a.projectId;return null}function H1(e){return e.workspaceKind==="local_project"||e.provider==="codex"||Ht(e.id)}function Xd(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 bg(e,t){const n=Gb(e),a=Gb(t);return n===a||n.startsWith(`${a}/`)}function Gb(e){return/^[A-Z]:\//.test(e)?e.toLowerCase():e}const Zb=[{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"}],z5=[{value:"recent",label:"Recent first"},{value:"manual",label:"Manual order"}];function Jb(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=>Yb(r,e.selectedTasksetId)),...e.doneSessions.filter(r=>Yb(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=>yi(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)=>Xb(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:Xb(r,i)})}function yi(e,t){return t.showCodexChats===!1&&(e.provider==="codex"||Ht(e.id))?!1:!t.onlyRunningTasks||t.inProgressSessionIds.has(e.id)}function Yb(e,t){const n=tr(e);return!!(n&&(!t||n.id===t))}function H5(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 q5(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 Qb(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 Xb(e,t,n=null){const a=dd(e),r=dd(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 dd(e){return e.pinned&&!e.savedForLater&&!e.archived}const Ic={showCodexChats:!0,onlyRunningTasks:!1},q1="openpond.sidebar-task-visibility.v1";function ey(e=B1()){try{const t=e?.getItem(q1);if(!t)return Ic;const n=JSON.parse(t);return{showCodexChats:typeof n.showCodexChats=="boolean"?n.showCodexChats:Ic.showCodexChats,onlyRunningTasks:typeof n.onlyRunningTasks=="boolean"?n.onlyRunningTasks:Ic.onlyRunningTasks}}catch{return Ic}}function ty(e,t=B1()){try{t?.setItem(q1,JSON.stringify(e))}catch{}}function B1(){return typeof window>"u"?null:Kl}function F1(e){return`${e.kind}:${e.id}`}function Il(e,t){return!!(e&&t&&e.kind===t.kind&&e.id===t.id)}function B5(e){return{kind:"session",id:e}}function F5(e){return{kind:"project",id:e}}function V5(e){return{kind:"draft",id:e}}function K5(e){return e.selectedSessionId?B5(e.selectedSessionId):e.selectedProjectId?F5(e.selectedProjectId):V5(e.selectedAppId?`app:${e.selectedAppId}`:"new-chat")}function W5(e){if(!e.previousScope||e.previousScope.kind!=="draft"||e.activeScope.kind!=="session")return[...e.tabs];if(Il(e.previousScope,e.activeScope))return[...e.tabs];const t=e.now??Date.now();return e.tabs.map(n=>Il(n.scope,e.previousScope)?{...n,scope:e.activeScope,updatedAt:t}:n)}function JZ(e,t){return e.filter(n=>Il(n.scope,t))}function YZ(e,t){return!!(e&&Il(e.scope,t))}function G5(e){const t={};for(const n of e){const a=F1(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=J5(r.status,n.status,n.commandStatus),t[a]=r}return t}function Z5(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 J5(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 V1(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=Q5(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 K1(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=X5(n);return b?`${i} / ${b}`:h?`${i} / upload required`:`${i} / ${u||!m?"needs sync":"setup ready"}`}function Y5(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(W1(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 Q5(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 X5(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 ${W1(t)}`}function W1(e){return`${e} commit${e===1?"":"s"}`}function e4({size:e=14,className:t}){return S.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:[S.jsx("path",{d:"M12 13v8"}),S.jsx("path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"}),S.jsx("path",{d:"m8 17 4-4 4 4"})]})}function G1({kind:e,linkedCloud:t=!1,open:n=!1,className:a,baseSize:r=15}){const i=e==="cloud"?"cloud":n?"folder-open":"folder";return S.jsx("span",{className:["project-kind-icon",e,t?"linked-cloud":"",a??""].filter(Boolean).join(" "),"aria-hidden":"true",children:S.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"?S.jsx(a4,{}):n?S.jsx(n4,{}):S.jsx(t4,{}),t&&e==="local"?S.jsx(o4,{}):null]})})}function t4(){return S.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 n4(){return S.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 a4(){return S.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 o4(){return S.jsxs("g",{className:"project-kind-icon-cloud-badge",children:[S.jsx("circle",{cx:"18",cy:"17",r:"5"}),S.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"})]})}function r4({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 S.jsx("div",{className:"git-dialog-backdrop rename-chat-backdrop",role:"presentation",onMouseDown:n,children:S.jsxs("section",{className:"git-dialog rename-chat-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rename-chat-title",onMouseDown:m=>m.stopPropagation(),children:[S.jsx("h2",{id:"rename-chat-title",children:"Rename chat"}),S.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"}),S.jsxs("div",{className:"git-dialog-footer",children:[S.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:n,children:"Cancel"}),S.jsx("button",{type:"button",className:"git-dialog-primary",autoFocus:!0,onClick:s,disabled:!a.trim(),children:"Save"})]})]})})}const i4=24;function s4({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)},i4);return()=>window.clearInterval(l)},[e]),S.jsx("span",{className:"sidebar-task-title-text","aria-label":e||"New task",children:n||"New task"})}const l4=2650,c4=304,d4=260,u4=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}),m4=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit"}),p4=new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"});function f4(){return{animationDelay:`${-(Date.now()%l4)}ms`}}function h4(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 ny({label:e,actions:t,actionsVisible:n=!1,className:a,titleAccessory:r,children:i,collapsed:s=!1,titleActive:l=!1,onTitleClick:m,onToggleCollapsed:u}){return S.jsxs("section",{className:["sidebar-section",a,n?"actions-visible":""].filter(Boolean).join(" "),children:[S.jsxs("div",{className:"section-header",children:[S.jsxs("div",{className:"section-title-row",children:[m?S.jsxs("div",{className:"section-title-combo",children:[S.jsx("button",{type:"button",className:`section-title-link${l?" active":""}`,onClick:m,children:S.jsx("span",{children:e})}),u&&S.jsx("button",{type:"button",className:"section-chevron-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:s?S.jsx(Nr,{size:13}):S.jsx(zo,{size:13})})]}):u?S.jsxs("button",{type:"button",className:"section-title-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:[S.jsx("span",{children:e}),s?S.jsx(Nr,{size:13}):S.jsx(zo,{size:13})]}):S.jsx("span",{children:e}),r]}),t&&S.jsx("div",{className:"section-actions",children:t})]}),!s&&S.jsx("div",{className:"sidebar-section-body",children:i})]})}function ay({children:e,expanded:t=!1,onClick:n}){return S.jsx("button",{type:"button",className:"sidebar-show-more",onClick:n,children:e??(t?"Show less":"Show more")})}function tp({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,metadataPresentation:w,ariaDescribedBy:_,childSessionCount:E=0,childSessionsExpanded:O=!1,onSelect:P,onToggleChildSessions:L,onTogglePin:$,onToggleSaveForLater:j,onDockRight:x,onArchive:C,onDragStart:A,onDragEnd:z,onDragOver:q,onDrop:N,onRename:K}){const[de,te]=g.useState(!1),Ie=u?.status==="queued",Se=u?.tone==="active"&&!Ie,Z=(h?.activeCount??0)>0,Pe=E>0&&!!L,ge=r&&!Pe,ce=Z||Se||!Ie&&(m??e.status==="active"),be=Z&&h?h.label:Se&&u?v4(u):"Running",ne=w??(y?"hover-detail":"inline"),he=ne==="hover-detail",ke=ne==="inline",qe=["sidebar-task-row",wl(e)?"is-draft":"",x?"actions-4":j?"actions-3":"",ce?"has-running-dot":"",he?"has-project-detail":""].filter(Boolean).join(" "),xe=g.useMemo(f4,[]),re=S.jsxs("div",{className:`sidebar-row-actions${he?" sidebar-task-inline-actions":""}`,children:[x?S.jsx(ar,{label:"Open in right panel",onClick:x,children:S.jsx(ef,{size:13})}):null,S.jsx(ar,{label:e.pinned?"Unpin chat":"Pin chat",onClick:$,children:e.pinned?S.jsx(tg,{size:13}):S.jsx(eg,{size:13})}),j?S.jsx(ar,{label:e.savedForLater?"Return to active":"Save for later",onClick:j,children:e.savedForLater?S.jsx(v1,{size:13}):S.jsx(g1,{size:13})}):null,S.jsx(ar,{label:a?"Reopen":"Mark done",onClick:C,children:a?S.jsx(QB,{size:13}):S.jsx(wo,{size:13})})]}),we=S.jsxs(yg,{selected:t,dataSessionId:e.id,dragging:s,iconless:ge,nested:i,placeholder:l,className:qe||void 0,ariaExpanded:Pe?O:void 0,ariaDescribedBy:_,onSelect:P,onDragStart:A,onDragEnd:z,onDragOver:q,onDrop:N,onDoubleClick:K?()=>te(!0):void 0,children:[ge?null:Pe?S.jsx("button",{type:"button",className:"sidebar-child-toggle","data-tooltip":O?"Hide subagent conversations":"Show subagent conversations","aria-label":`${O?"Hide":"Show"} ${E} subagent ${E===1?"conversation":"conversations"}`,"aria-expanded":O,onClick:Ze=>{Ze.stopPropagation(),L?.()},children:O?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})}):n??S.jsx(Jd,{size:15}),S.jsxs("span",{className:`row-label-shell${he?" has-detail":""}`,children:[S.jsxs("span",{className:"sidebar-session-title-line",children:[S.jsx("span",{className:"row-label sidebar-task-title","data-overflowing":"false",onPointerEnter:h4,children:S.jsx(s4,{title:e.title})}),ke?S.jsx(uf,{value:e.updatedAt}):null]}),he?S.jsxs("span",{className:"sidebar-session-detail-line",children:[S.jsx("span",{className:"sidebar-session-project-label",children:y}),re,S.jsx(uf,{value:e.updatedAt})]}):null]}),S.jsxs("div",{className:"row-meta",children:[S.jsxs("span",{className:"row-meta-status",children:[b?S.jsx(Z1,{indicator:b}):null,ce?S.jsx("span",{className:`sidebar-running-dot${Z?" subagent":Se?" goal":""}`,style:xe,"aria-label":be}):null]}),he?null:re]})]}),je=de&&K?S.jsx(r4,{session:e,onSave:Ze=>K(e,Ze),onClose:()=>te(!1)}):null;return S.jsxs(S.Fragment,{children:[we,je]})}function g4({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 S.jsxs(yg,{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?S.jsx(Qh,{size:15}):S.jsx(pF,{size:15}),S.jsx("span",{className:"row-label-shell",title:b,children:S.jsx("span",{className:"row-label",children:h})}),S.jsx("div",{className:"row-meta",children:S.jsxs("div",{className:"sidebar-row-actions",children:[S.jsx(ar,{label:e.status==="pinned"?"Unpin file":"Pin file",onClick:r,children:e.status==="pinned"?S.jsx(tg,{size:13}):S.jsx(eg,{size:13})}),S.jsx(ar,{label:e.status==="saved_for_later"?"Remove from Save for later":"Save file for later",onClick:i,children:e.status==="saved_for_later"?S.jsx(v1,{size:13}):S.jsx(g1,{size:13})})]})})]})}function v4(e){return e.actionLabel}function b4({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:O,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:j}){const[x,C]=g.useState(!1),A=g.useRef(null),[z,q]=g.useState({}),N=!!w||!!O,K=e==="local"&&l!==!1&&!!t.linkedSandboxProject?.projectId,de=g.useCallback(()=>{if(typeof window>"u")return;const Se=A.current?.getBoundingClientRect();if(!Se)return;const Z=Math.max(12,window.innerWidth-c4-12),Pe=Math.max(12,window.innerHeight-d4),ge=Math.max(12,Math.min(Se.right+10,Z)),ce=Math.max(12,Math.min(Se.top-4,Pe)),be={"--sidebar-project-locations-left":`${Math.round(ge)}px`,"--sidebar-project-locations-top":`${Math.round(ce)}px`};q(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 S.jsxs("div",{ref:A,className:["sidebar-project-row-shell",x?"project-menu-open":""].filter(Boolean).join(" "),onFocusCapture:de,onPointerEnter:de,children:[S.jsxs(yg,{selected:a,placeholder:u,className:["sidebar-project-row",x?"project-menu-open":""].filter(Boolean).join(" "),ariaExpanded:i?r:void 0,onSelect:te,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:j,children:[S.jsx(G1,{kind:e,linkedCloud:K,open:e==="local"&&r,className:"sidebar-row-icon",baseSize:15}),S.jsx("span",{className:"row-label-shell",children:S.jsxs("span",{className:"sidebar-project-title-line",children:[S.jsx("span",{className:"row-label",children:t.name}),S.jsx(uf,{value:t.updatedAt}),i?S.jsx("span",{className:"sidebar-project-caret","aria-hidden":"true",children:r?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})}):null]})}),S.jsxs("div",{className:"row-meta",children:[S.jsx("span",{className:"row-meta-status",children:h?S.jsx(Z1,{indicator:h}):null}),S.jsxs("div",{className:"sidebar-row-actions",children:[S.jsx(ar,{label:n?"Unpin project":"Pin project",onClick:E,children:n?S.jsx(tg,{size:13}):S.jsx(eg,{size:13})}),N&&S.jsx(M4,{open:x,onToggleOpen:()=>C(Se=>!Se)}),S.jsx(ar,{label:"New task",onClick:y,children:S.jsx(ag,{size:13})})]})]})]}),S.jsx(S4,{kind:e,project:t,workspaceState:s,cloudLinkTrusted:l,cloudLinkWarning:m,onWorkspaceTargetSelect:_,style:z}),x&&S.jsx(j4,{onClose:Ie,onMoveToCloud:w?()=>{Ie(),w()}:void 0,onRemove:()=>{Ie(),O()}})]})}function uf({value:e}){const t=y4(e);if(!t||!e)return null;const n=new Date(e);return S.jsx("time",{className:"sidebar-row-updated-at",dateTime:e,title:`Last updated ${p4.format(n)}`,children:t})}function y4(e,t=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const a=m4.format(n);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?a:`${u4.format(n)} ${a}`}function Z1({indicator:e}){return S.jsx("span",{className:`sidebar-terminal-indicator ${e.status}`,"data-tooltip":e.label,"aria-label":e.label,title:e.label,children:S.jsx(w1,{size:13})})}function S4({kind:e,project:t,workspaceState:n,cloudLinkTrusted:a,cloudLinkWarning:r,onWorkspaceTargetSelect:i,style:s}){const l=w4(e,t,n,a,r);return S.jsxs("aside",{className:"sidebar-project-locations-popover","aria-label":`${t.name} status`,style:s,children:[S.jsx("div",{className:"sidebar-project-locations-title",children:t.name}),S.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=S.jsxs(S.Fragment,{children:[S.jsx("span",{className:["sidebar-project-location-icon",m.key].filter(Boolean).join(" "),"aria-hidden":"true",children:m.icon}),S.jsx("span",{className:"sidebar-project-location-copy",children:S.jsx(x4,{value:m.value})})]});return m.actionTarget?S.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):S.jsx("div",{className:u,children:h},m.key)})})]})}function x4({value:e}){const t=k4(e);return S.jsxs("span",{className:"sidebar-project-location-value","aria-label":e,children:[t.branch?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"sidebar-project-location-branch",children:t.branch}),S.jsx("span",{className:"sidebar-project-location-separator","aria-hidden":"true",children:"/"})]}):null,S.jsx("span",{className:"sidebar-project-location-status",children:t.status})]})}function k4(e){const n=e.indexOf(" / ");return n===-1?{branch:null,status:e}:{branch:e.slice(0,n),status:e.slice(n+3)}}function w4(e,t,n,a=!0,r=null){return e==="cloud"?_4(t):I4(t,n,a,r)}function I4(e,t,n=!0,a=null){const r=C4(e,t,n),i=R4(t),s=A4(e,n),l=n===!1&&a;return[{key:"local",value:r,tone:i?"attention":"local",icon:e.source==="git"?S.jsx(y1,{size:13}):S.jsx(IF,{size:13}),actionTarget:"local"},{key:"cloud",value:l||(s?T4(e,t,n):"not in cloud"),tone:l?"attention":"cloud",icon:S.jsx(Zd,{size:13}),actionTarget:s?"cloud":"upload_cloud"}]}function _4(e){return[{key:"cloud",value:E4(e),tone:e.syncedAt?"cloud":"attention",icon:S.jsx(Zd,{size:13}),actionTarget:"cloud"}]}function C4(e,t,n){const a=P4(e,t);return t?t.error?`${a} / status unavailable`:t.initialized?V1(t,{branch:e.linkedSandboxProject?.defaultBranch??null,linkedCloudSourceKnown:e.linkedSandboxProject?.projectId&&n?!!e.linkedSandboxProject.lastUploadedCommit||!t.headCommit:!0}):`${a} / not checked out`:`${a} / available`}function R4(e){return!!(e?.dirty||(e?.changedFilesCount??0)>0||(e?.untrackedFilesCount??0)>0)}function P4(e,t){return t?.currentBranch??t?.defaultBranch??e.linkedSandboxProject?.defaultBranch??"local"}function A4(e,t=!0){return!!(t&&e.linkedSandboxProject?.projectId||e.linkedOpenPondApp?.appId)}function T4(e,t,n){return K1(e,null,t,{cloudLinkTrusted:n})}function E4(e){const t=e.defaultBranch??"main",n=e.syncedAt?"setup ready":"needs setup";return`${t} / ${n}`}function M4({open:e,onToggleOpen:t}){return S.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:S.jsx(Xh,{size:13})})}function j4({onClose:e,onMoveToCloud:t,onRemove:n}){return S.jsxs(S.Fragment,{children:[S.jsx("button",{type:"button",className:"sidebar-project-menu-backdrop","aria-label":"Close project actions",onClick:a=>{a.stopPropagation(),e()}}),S.jsxs("div",{className:"section-menu-popover sidebar-project-row-popover",role:"menu",children:[t&&S.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),t()},children:[S.jsx(e4,{size:13}),S.jsx("span",{children:"Move to Cloud"})]}),S.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),n()},children:[S.jsx(rs,{size:13}),S.jsx("span",{children:"Remove from Projects"})]})]})]})}function yg({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 O=!!b;return S.jsx("div",{className:["sidebar-row",t??"",l?"selected":"",a?"dragging":"",r?"iconless":"",i?"nested":"",s?"placeholder":""].filter(Boolean).join(" "),draggable:O,"data-session-id":n,role:"button",tabIndex:0,"aria-expanded":m,"aria-describedby":u,onClick:h,onDoubleClick:E,onKeyDown:P=>{(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 ar({children:e,label:t,onClick:n}){return S.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":t,"aria-label":t,onClick:a=>{a.stopPropagation(),n()},children:e})}function O4({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 O=g.useRef(null),[P,L]=g.useState(!1),j=E.find(A=>A.id===_)?.name??Zb.find(A=>A.value===e)?.label??"Active",x=h==="tasks-filter",C=h==="chats";return g.useEffect(()=>{if(!x&&!C)return;function A(z){O.current?.contains(z.target)||b(null)}return document.addEventListener("pointerdown",A),()=>document.removeEventListener("pointerdown",A)},[x,b,C]),S.jsxs("div",{className:"sidebar-task-list-controls",ref:O,children:[S.jsxs("div",{className:"section-menu",children:[S.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:S.jsx(Xh,{size:14})}),C?S.jsxs("div",{className:"section-menu-popover",role:"menu","aria-label":`${n==="tasks"?"Task":"Chat"} list options`,children:[S.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":y,onClick:()=>s(!y),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:y?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"Show Codex chats"})]}),S.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":u,onClick:()=>i(!u),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:u?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"Only running tasks"})]}),n==="tasks"?S.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":t,onClick:()=>r(!t),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:t?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"Group by project"})]}):null,z5.map(A=>S.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w===A.value,onClick:()=>{m(A.value),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:w===A.value?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:A.label})]},A.value))]}):null]}),S.jsxs("div",{className:"section-menu",children:[S.jsx("button",{type:"button",className:`section-icon ${x?"active":""}`,"aria-label":`Filter ${n}: ${j}`,"aria-haspopup":"menu","aria-expanded":x,onClick:()=>b(A=>A==="tasks-filter"?null:"tasks-filter"),children:S.jsx(OF,{size:14})}),x?S.jsx("div",{className:"section-menu-popover",role:"menu","aria-label":`Filter ${n}`,children:Zb.map(A=>S.jsxs(g.Fragment,{children:[A.value==="tasksets"?S.jsxs("button",{type:"button",role:"menuitem","aria-expanded":P,onClick:()=>L(z=>!z),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:P?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})}),S.jsx("span",{children:A.label})]}):S.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":e===A.value,onClick:()=>{a(A.value),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e===A.value?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:A.label})]}),A.value==="tasksets"&&P?S.jsxs(S.Fragment,{children:[S.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&!_,onClick:()=>{l(null),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&!_?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"All Tasksets"})]}),E.map(z=>S.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&_===z.id,onClick:()=>{l(z.id),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&_===z.id?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:z.name}),S.jsx("span",{className:"section-menu-option-count","aria-hidden":"true",children:z.chatCount})]},z.id))]}):null]},A.value))}):null]})]})}const $4=288,N4=112;function D4(e,t){const n=Math.max(12,t.width-$4-12),a=Math.max(12,t.height-N4-12);return{"--sidebar-task-detail-left":`${Math.round(Math.max(12,Math.min(e.right+10,n)))}px`,"--sidebar-task-detail-top":`${Math.round(Math.max(12,Math.min(e.top-4,a)))}px`}}function L4({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:"full",timeStyle:"short"}).format(n);return S.jsxs("aside",{id:e.descriptionId,className:"sidebar-task-detail-popover",style:e.style,"aria-label":`${e.title} details`,children:[S.jsx("div",{className:"sidebar-task-detail-title",children:e.title}),S.jsx("div",{className:"sidebar-task-detail-project",children:e.projectLabel}),S.jsx("time",{dateTime:e.updatedAt,children:a})]})}function U4({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"?Qh:Jd,[y,w]=g.useState(!1),_=!!(s||l||m);return S.jsxs("section",{className:"sidebar-task-project-group",children:[S.jsxs("div",{className:`sidebar-task-project-group-header-shell${y?" menu-open":""}`,children:[S.jsxs("button",{type:"button",className:"sidebar-task-project-group-header","aria-controls":h,"aria-expanded":t,onClick:()=>{w(!1),i()},children:[u?S.jsx(G1,{kind:u.kind,linkedCloud:!!(u.kind==="local"&&u.project.linkedSandboxProject?.projectId),open:u.kind==="local"&&t,className:"sidebar-task-project-group-icon",baseSize:14}):S.jsx(b,{className:"sidebar-task-project-group-icon",size:14,"aria-hidden":"true"}),S.jsx("span",{className:"sidebar-task-project-group-name",children:r}),S.jsx("span",{className:"sidebar-task-project-group-caret","aria-hidden":"true",children:t?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})})]}),u&&_?S.jsxs("div",{className:"sidebar-task-project-group-actions",children:[l||m?S.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:S.jsx(Xh,{size:13})}):null,s?S.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":"New task","aria-label":"New task",onClick:s,children:S.jsx(ag,{size:13})}):null]}):null,y?S.jsxs(S.Fragment,{children:[S.jsx("button",{type:"button",className:"sidebar-task-project-group-menu-backdrop","aria-label":"Close project actions",onClick:()=>w(!1)}),S.jsxs("div",{className:"section-menu-popover sidebar-task-project-group-menu",role:"menu",children:[l?S.jsx("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),l()},children:S.jsx("span",{children:"Open project"})}):null,m?S.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),m()},children:[S.jsx(rs,{size:13}),S.jsx("span",{children:"Remove from Projects"})]}):null]})]}):null]}),t?S.jsx("div",{id:h,className:"sidebar-task-project-group-content",children:e}):null]})}const z4={},H4=new Map,q4=new Map;function B4(e,t){return Math.min(Math.max(e,Cn)+cf,t)}function F4(e,t){const n=Math.max(Cn,Math.min(e,t));if(n<=Cn)return Cn;const a=Math.ceil((n-Cn)/cf);return Math.max(Cn,Cn+(a-1)*cf)}function V4(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 K4({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=H4,localProjectRows:y,openSidebarFile:w,pinnedCollapsed:_,pinnedRows:E,previewTaskDrop:O,previewPinnedDrop:P,projectRows:L,renameSession:$,restoreSession:j,runningSessionIds:x,savedForLaterSessions:C,sectionMenuOpen:A,selectedProjectId:z,selectedSessionId:q,setChatRowsVisibleCount:N,setSectionMenuOpen:K,setSelectedAppId:de,setSelectedProjectId:te,setSelectedSessionId:Ie,setView:Se,sidebarProjectIdBySessionId:Z,startTaskDrag:Pe,startPinnedDrag:ge,subagentRuntimeBySessionId:ce=q4,taskDragSessionId:be,taskPreviewSessionIds:ne,terminalSummaries:he=z4,toggleSessionPinned:ke,toggleSessionSavedForLater:qe,view:xe,clearTaskDrag:re,removeProject:we,toggleProjectPinned:je,onTogglePinnedCollapsed:Ze,setSidebarFileStatus:Ge,commitPinnedDrop:st,commitPinnedPreviewDrop:Ue,clearSidebarDrag:Ve,dragItem:Le}){const[D,M]=g.useState("active"),[H,Q]=g.useState("manual"),[me,_e]=g.useState(h!=="chat"),[$e,Xe]=g.useState(ey);Vl(()=>Xe(ey()));const{onlyRunningTasks:et,showCodexChats:rt}=$e,[it,Me]=g.useState(null),[Fe,p]=g.useState(()=>new Set),[U,V]=g.useState(()=>new Map),[le,ie]=g.useState(null),F=h==="chat"?"chats":"tasks",I=h==="chat"?"Chats":"Tasks",W=L??[...y,...i],X=g.useMemo(()=>new Map(W.map(oe=>[oe.id,oe.project.name])),[W]),ae=g.useMemo(()=>new Map(W.map(oe=>[oe.id,oe])),[W]),G=g.useMemo(()=>{const oe=new Set(x);for(const De of e){const Be=b.get(De.id),Je=ce.get(De.id);(Be?.tone==="active"&&Be.status!=="queued"||(Je?.activeCount??0)>0||yt(De.id)?.status==="running")&&oe.add(De.id)}return oe},[e,b,x,ce,he]),pe=g.useMemo(()=>e.filter(oe=>tr(oe)===null&&yi(oe,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[e,G,et,rt]),fe=g.useMemo(()=>C.filter(oe=>tr(oe)===null&&yi(oe,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,C,rt]),Oe=Math.max(0,pe.length-fe.length),Ee=H5({activeCount:Oe,filter:D,savedForLaterCount:fe.length}),Ne=g.useMemo(()=>Jb({activeSessions:e,doneSessions:n,filter:"all",inProgressSessionIds:G,sort:"manual"}),[e,n,G]),Ke=g.useMemo(()=>Jb({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]),ze=g.useMemo(()=>{const oe=new Map;for(const De of[...e,...n]){if(!yi(De,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))continue;const Be=tr(De);if(!Be)continue;const Je=oe.get(Be.id);Je?Je.chatCount+=1:oe.set(Be.id,{...Be,chatCount:1})}return[...oe.values()].sort((De,Be)=>De.name.localeCompare(Be.name))},[e,n,G,et,rt]),ut=g.useMemo(()=>E.filter(oe=>oe.type!=="session"||yi(oe.session,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,E,rt]),Qt=g.useMemo(()=>Ke.filter(oe=>!dd(oe)).slice(0,Math.max(Cn,a)),[a,Ke]),Lt=g.useMemo(()=>V4(Qt,oe=>{if(wl(oe))return{key:"draft",label:"Drafts",projectId:null,project:null,kind:"draft"};const De=Z[oe.id],Be=un(oe)??"No project";return{key:De?`project:${De}`:`projectless:${Be}`,label:Be,projectId:De??null,project:De?ae.get(De)??null:null,kind:De?"project":"projectless"}}),[X,ae,Z,Qt]),An=Qt.length<Ke.length,Sn=Qt.length>Cn,nn=g.useMemo(()=>new Set(Lt.filter(oe=>oe.sessions.some(De=>De.id===q||G.has(De.id))).map(oe=>oe.key)),[Lt,G,q]),bt=Ne.filter(oe=>!dd(oe)).map(oe=>oe.id),rn=Qt.map(oe=>oe.id),Nt=JSON.stringify(Object.entries(r).filter(([oe,De])=>De.length>0&&(ce.get(oe)?.activeCount??0)>0).flatMap(([oe,De])=>De.map(Be=>[oe,Be.id])).sort(([oe,De],[Be,Je])=>oe.localeCompare(Be)||De.localeCompare(Je)));g.useEffect(()=>{const oe=JSON.parse(Nt);if(oe.length===0)return;const De=new Set(oe.map(([Be])=>Be));p(Be=>[...De].every(Je=>Be.has(Je))?Be:new Set([...Be,...De]))},[Nt]);function yt(oe){return Z5(he[F1({kind:"session",id:oe})])}function un(oe){if(wl(oe))return"Draft";const De=Z[oe.id];return De?X.get(De)??oe.workspaceName??"Project":O5(oe)}function Ut(oe){sn({kind:"chat",sessionId:oe.id}),Ie(oe.id);const De=Z[oe.id]??null;de(De?null:oe.appId),te(De),Se("chat")}function mn(oe){return(r[oe.id]??[]).filter(De=>yi(De,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))}function On(oe,De){return Fe.has(oe.id)||De.some(Be=>Be.id===q)}function gn(oe){p(De=>{const Be=new Set(De);return Be.has(oe)?Be.delete(oe):Be.add(oe),Be})}function Na(oe){const De=mn(oe);return De.length===0||!On(oe,De)?null:S.jsx("div",{className:"sidebar-child-session-group",children:De.map(Be=>S.jsx(tp,{session:Be,selected:xe==="chat"&&q===Be.id,hideIcon:!0,nested:!0,running:G.has(Be.id),goalRuntime:b.get(Be.id)??null,subagentRuntime:ce.get(Be.id)??null,terminalIndicator:yt(Be.id),projectLabel:un(oe),onSelect:()=>Ut(Be),onTogglePin:()=>ke(Be),onToggleSaveForLater:()=>qe(Be),onDockRight:()=>u(Be),onArchive:()=>Be.archived?j(Be):t(Be),onRename:$},Be.id))})}function Da(oe,De,Be){typeof window>"u"||ie({descriptionId:`sidebar-task-detail-${oe.id}`,projectLabel:De,sessionId:oe.id,title:oe.title,updatedAt:oe.updatedAt,style:D4(Be.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight})})}function qt(oe,De={}){const Be=oe.archived,Je=be===oe.id,At=mn(oe),gt="sidebar-session-group",lt=H==="manual"?{onDragStart:_t=>Pe(_t,{allSessionIds:bt,visibleSessionIds:rn,sessionId:oe.id}),onDragEnd:re,onDragOver:_t=>{Je||O(_t,oe.id)},onDrop:_t=>{Je?m():l(_t,oe.id)}}:{};return S.jsxs("div",{className:gt,onPointerEnter:De.metadataPresentation==="flyout"&&De.projectLabel?_t=>Da(oe,De.projectLabel,_t.currentTarget):void 0,onPointerLeave:De.metadataPresentation==="flyout"?()=>ie(null):void 0,onFocusCapture:De.metadataPresentation==="flyout"&&De.projectLabel?_t=>Da(oe,De.projectLabel,_t.currentTarget):void 0,onBlurCapture:De.metadataPresentation==="flyout"?_t=>{_t.currentTarget.contains(_t.relatedTarget)||ie(null)}:void 0,children:[S.jsx(tp,{session:oe,selected:!Be&&xe==="chat"&&q===oe.id,archived:Be,hideIcon:!0,placeholder:Je,running:G.has(oe.id),goalRuntime:b.get(oe.id)??null,subagentRuntime:ce.get(oe.id)??null,terminalIndicator:yt(oe.id),projectLabel:De.projectLabel===void 0?un(oe):De.projectLabel,metadataPresentation:De.metadataPresentation,ariaDescribedBy:De.metadataPresentation==="flyout"&&le?.sessionId===oe.id?le.descriptionId:void 0,childSessionCount:At.length,childSessionsExpanded:On(oe,At),onToggleChildSessions:()=>gn(oe.id),onSelect:()=>{ie(null),Be&&j(oe),Ut(oe)},onTogglePin:()=>ke(oe),onToggleSaveForLater:()=>qe(oe),onDockRight:()=>u(oe),onArchive:()=>Be?j(oe):t(oe),onRename:$,...lt}),Je?null:Na(oe)]},oe.id)}function qn(oe){oe!=="tasksets"&&Me(null),M(oe),N(Cn)}function ot(oe){Me(oe),M("tasksets"),N(Cn)}function xn(oe){Q(oe),N(Cn)}function La(){N(oe=>B4(oe,Ke.length))}function Ua(){N(oe=>F4(oe,Ke.length))}function ia(oe){const De={id:oe.id,type:oe.type};return{onDragStart:Be=>ge(Be,De),onDragEnd:Ve,onDragOver:Be=>P(Be,De),onDrop:Be=>{Le?.id===oe.id&&Le.type===oe.type?Ue():st(Be,De)}}}function za(oe){const De=ia(oe),Be=Le?.id===oe.id&&Le.type===oe.type;if(oe.type==="project"){const At=oe.item;return S.jsx(b4,{kind:At.kind,project:At.project,pinned:!0,selected:xe==="chat"&&z===At.id,expanded:!1,disclosure:!1,placeholder:Be,onSelect:()=>{de(null),te(At.id),Ie(null),Se("chat")},onNewChat:()=>s(At.id),onTogglePin:()=>je(At),onRemove:()=>we(At),...De},oe.key)}if(oe.type==="file")return S.jsx(g4,{file:oe.file,placeholder:Be,onSelect:()=>w(oe.file),onTogglePin:()=>Ge(oe.file,"none"),onToggleSaveForLater:()=>Ge(oe.file,"saved_for_later"),...De},oe.key);const Je=oe.session;return S.jsx(tp,{session:Je,selected:xe==="chat"&&q===Je.id,hideIcon:!0,placeholder:Be,running:G.has(Je.id),goalRuntime:b.get(Je.id)??null,subagentRuntime:ce.get(Je.id)??null,terminalIndicator:yt(Je.id),projectLabel:un(Je),metadataPresentation:"flyout",onSelect:()=>Ut(Je),onTogglePin:()=>ke(Je),onToggleSaveForLater:()=>qe(Je),onDockRight:()=>u(Je),onArchive:()=>t(Je),onRename:$,...De},oe.key)}return S.jsxs("div",{className:"sidebar-scroll",children:[S.jsxs(ny,{label:I,className:`sidebar-task-section${h!=="chat"?" development":""}`,titleAccessory:h!=="chat"?S.jsx("div",{className:"sidebar-task-mode-buttons",children:S.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:[S.jsx("span",{children:Ee.label}),S.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:S.jsx(O4,{filter:D,groupByProject:me,noun:F,onFilterChange:qn,onGroupByProjectChange:_e,onOnlyRunningTasksChange:oe=>{Xe(De=>{const Be={...De,onlyRunningTasks:oe};return ty(Be),Be}),N(Cn)},onShowCodexChatsChange:oe=>{Xe(De=>{const Be={...De,showCodexChats:oe};return ty(Be),Be}),N(Cn)},onTasksetChange:ot,onSortChange:xn,onlyRunningTasks:et,openMenu:A,setOpenMenu:K,showCodexChats:rt,sort:H,selectedTasksetId:it,tasksets:ze}),children:[ut.length>0?S.jsx(ny,{label:"Pinned",className:"sidebar-pinned-section",collapsed:_,onToggleCollapsed:Ze,children:ut.map(za)}):null,me&&h!=="chat"?Lt.map(oe=>{const De=nn.has(oe.key)||U.get(oe.key)!==!1;return S.jsx(U4,{expanded:De,groupKey:oe.key,kind:oe.kind,label:oe.label,onToggle:()=>{V(Be=>{const Je=new Map(Be);return Je.set(oe.key,!De),Je})},onNewTask:oe.project?()=>s(oe.project.id):void 0,onOpenProject:oe.project?()=>{de(null),te(oe.project.id),Ie(null),Se("chat")}:void 0,onRemoveProject:oe.project?()=>we(oe.project):void 0,project:oe.project,children:oe.sessions.map(Be=>qt(Be,{metadataPresentation:"flyout",projectLabel:oe.label}))},oe.key)}):Qt.map(oe=>qt(oe)),Ke.length===0?S.jsx("div",{className:"empty-row",children:q5(D,F)}):null,Ke.length>Cn&&(An||Sn)?S.jsxs("div",{className:"sidebar-pagination-controls","aria-label":`Showing ${Qt.length} of ${Ke.length} ${F}`,children:[An?S.jsx(ay,{onClick:La,children:"Show more"}):null,Sn?S.jsx(ay,{onClick:Ua,children:"Show less"}):null]}):null]}),S.jsx(L4,{detail:le,onClose:()=>ie(null)})]})}const W4="/";function Jn(e){return`${W4}${e.replace(/^\.?\//,"")}`}const G4=Jn("openpond-icon.png"),Z4=Jn("openpond-wordlogo-white.png"),QZ=Jn("tutorials/what-is-an-openpond-agent-poster.png"),XZ=Jn("tutorials/what-is-an-openpond-agent.vtt"),eJ=Jn("tutorials/how-to-make-an-agent-poster.png"),tJ=Jn("tutorials/how-to-make-an-agent.vtt");function nJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}-poster.png`)}function aJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}.vtt`)}const oy={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 oJ(e){return oy[e]??oy.mcp}function J4({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=Jm.find(y=>y.value===e)??Jm[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&&ry(s.current,l.current),l.current=null},[n]);const u=y=>{if(n){ry(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=J1(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,O=_<0?0:(_+E+w.length)%w.length;w[O]?.focus()};return S.jsxs("div",{className:"sidebar-experience-menu",ref:r,children:[S.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:[S.jsx("img",{className:"sidebar-wordmark",src:Z4,alt:""}),S.jsx("span",{className:"sidebar-experience-label",children:m.label}),S.jsx(zo,{size:13,"aria-hidden":"true"})]}),n?S.jsx("div",{ref:s,className:"sidebar-experience-popover",role:"menu","aria-label":"Choose product",onKeyDown:b,children:Jm.map(y=>{const w=y.value===e;return S.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:[S.jsxs("span",{children:[S.jsx("strong",{children:y.label}),S.jsx("small",{children:y.description})]}),w?S.jsx(wo,{size:14,"aria-hidden":"true"}):null]},y.value)})}):null]})}function J1(e){return e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[]}function ry(e,t){const n=J1(e);(t==="first"?n[0]:n.at(-1))?.focus()}function Y4(...e){for(const t of e){const n=t?.trim();if(n)return n}return null}function Q4(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"?Y4(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 X4({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(()=>Q4(e),[e]),E=_.label.trim().slice(0,1).toUpperCase(),O=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]),S.jsxs("div",{className:"user-auth-footer",ref:w,children:[S.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:[S.jsx("span",{className:"user-auth-avatar","aria-hidden":"true",children:_.image?S.jsx("img",{src:_.image,alt:""}):E?S.jsx("span",{children:E}):S.jsx(qb,{size:16})}),S.jsx("span",{className:"user-auth-name",children:_.label})]}),t?S.jsxs("div",{className:"user-auth-menu",role:"menu","aria-label":"Account",children:[S.jsxs("div",{className:"user-auth-menu-header",children:[S.jsx("span",{className:"user-auth-menu-avatar","aria-hidden":"true",children:_.image?S.jsx("img",{src:_.image,alt:""}):E?S.jsx("span",{children:E}):S.jsx(qb,{size:17})}),S.jsx("span",{className:"user-auth-menu-identity",children:S.jsx("strong",{children:_.label})})]}),n.length>0&&l?S.jsxs("label",{className:"user-auth-team-picker",children:[S.jsx(k1,{size:15,"aria-hidden":"true"}),S.jsx("span",{className:"user-auth-team-picker-label",children:"Team"}),S.jsx("select",{"aria-label":"Active team",disabled:u!==null,value:O?.teamId??"",onChange:async P=>{const L=P.currentTarget.value;h(L);try{await l(L)}catch{}finally{h(null)}},children:n.map(P=>S.jsx("option",{value:P.teamId,children:P.displayName},P.teamId))})]}):null,S.jsx("div",{className:"user-auth-menu-divider"}),r?S.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),r()},children:[S.jsx(b1,{size:15}),S.jsx("span",{children:"Activity"})]}):null,S.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),s()},children:[S.jsx(ng,{size:15}),S.jsx("span",{children:"Settings"})]}),e?.state==="signed_in"&&m?S.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:[S.jsx(GF,{size:15}),S.jsx("span",{children:b?"Logging out…":"Log out"})]}):null]}):null]})}function iy(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 e3(e,t){const n=iy(e),a=iy(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 Y1(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")?"mac":t==="linux"||t.includes("linux")?"linux":null}function t3(e){const t=e?.toLowerCase()??"";return t==="arm64"||t==="aarch64"?"arm64":t==="x64"||t==="x86_64"||t==="amd64"?"x64":null}function n3(e,t,n){const a=Y1(t),r=t3(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 a3(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(!e3(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=n3(s,e.platform,e.arch);return!l||!r?null:{version:a,releaseUrl:r,assetName:l.name,downloadUrl:l.downloadUrl}}const o3=3600*1e3,r3="https://api.github.com/repos/openpond/openpond/releases/latest";function i3(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&&!!Y1(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(r3,{headers:{Accept:"application/vnd.github+json"}});if(!h.ok)throw new Error(`GitHub release check failed: ${h.status}`);const b=await h.json(),y=a3({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()},o3);return()=>{l=!0,window.clearInterval(u)}},[i,a,s,r]),t}const Q1="openpond.sidebar.continuous-learning.dismissed.v1";function sy(e=X1()){if(!e)return!1;try{return e.getItem(Q1)==="true"}catch{return!1}}function s3(e=X1()){if(e)try{e.setItem(Q1,"true")}catch{}}function X1(){return typeof window>"u"?null:Kl}function l3({connection:e,onOpenSettings:t}){const[n,a]=g.useState(null),[r,i]=g.useState(sy);Vl(()=>i(sy()));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 S.jsxs("section",{className:"sidebar-learning-notice","aria-label":"Continuous learning",children:[S.jsxs("header",{children:[S.jsx("strong",{children:"Continuous learning"}),S.jsxs("div",{className:"sidebar-learning-notice-actions",children:[S.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Open Continuous learning settings",onClick:t,type:"button",children:S.jsx(ng,{size:14})}),S.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Close continuous learning",onClick:()=>{i(!0),s3()},type:"button",children:S.jsx(rs,{size:14})})]})]}),S.jsxs("div",{className:"sidebar-learning-status",children:[S.jsx("strong",{children:"Refiner"}),S.jsx("span",{children:n.backgroundReview.enabled?"On":"Off"})]}),S.jsxs("div",{className:"sidebar-learning-status",children:[S.jsx("strong",{children:"Continuous Review"}),S.jsx("span",{children:m})]})]})}function c3(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:O,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}=e,j=g.useCallback(z=>{n(!1),b(z)},[b]),x=g.useCallback(z=>{n(z),z&&b(null)},[b]),C=i3({currentVersion:i,platform:h,arch:r,enabled:Yd()}),A=C.status==="available"?C.update:null;return S.jsxs("aside",{className:"sidebar",children:[S.jsxs("div",{className:"sidebar-toolbar",children:[S.jsx("button",{className:"sidebar-icon","aria-label":"Hide sidebar",onClick:()=>E(!1),children:S.jsx(x1,{size:16})}),S.jsx(J4,{value:l,onChange:m}),A&&S.jsxs("button",{type:"button",className:"sidebar-update-pill",title:`Download OpenPond ${A.version}: ${A.assetName}`,"aria-label":`Download OpenPond ${A.version}`,onClick:()=>{d3(A.downloadUrl)},children:[S.jsx(bF,{size:14}),S.jsx("span",{children:"Update"})]})]}),S.jsx(y5,{productArea:l,experience:s,beginNewChat:a,setSectionMenuOpen:j,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:O,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}),l==="models"?null:S.jsx(K4,{...e,setSectionMenuOpen:j}),S.jsxs("div",{className:"sidebar-bottom-stack",children:[l==="models"?null:S.jsx(l3,{connection:e.connection,onOpenSettings:()=>{b(null),sn({kind:"settings",section:"harness"})}}),S.jsxs("div",{className:"sidebar-footer-row",children:[S.jsx(X4,{account:e.account,open:t,organizations:e.organizations,selectedTeamId:e.teamChatOrganization?.teamId??null,onOpenChange:x,onOpenActivity:()=>{b(null),sn({kind:"settings",section:"usage"})},onOpenSettings:()=>{b(null),sn({kind:"settings",section:"account"})},onSelectTeam:e.onSelectTeam,onLogOut:e.onLogOut}),S.jsx(S5,{setSectionMenuOpen:j,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:O,view:P})]})]}),S.jsx("div",{className:"sidebar-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:u})]})}async function d3(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-update",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const u3=[/^(?:(?:type)?error:\s*)?failed to fetch\.?$/i,/^networkerror when attempting to fetch resource\.?$/i,/^load failed\.?$/i];function eI(e,t="Something went wrong."){const a=(e instanceof Error?e.message:String(e??"")).trim();return a?tI(a)?"Couldn’t connect to OpenPond.":a:t}function tI(e){const t=e.trim();return u3.some(n=>n.test(t))}const nI=g.createContext(null);function ly({children:e,showToast:t}){return S.jsx(nI.Provider,{value:t,children:e})}function m3(){return g.useContext(nI)}function cy(e,t={}){const n=m3(),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?": ":""}${eI(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 p3({state:e,onClose:t,onOpenBrowserUrl:n,onStart:a}){if(cy(e?.previewError,{prefix:"Upload preview"}),cy(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 S.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:S.jsxs("section",{className:"git-dialog cloud-setup-dialog",role:"dialog","aria-modal":"true","aria-label":"Set up Cloud coding",children:[S.jsx("button",{className:"git-dialog-close",disabled:r,type:"button",onClick:t,"aria-label":"Close Cloud setup",title:"Close",children:S.jsx(rs,{size:14})}),S.jsx("div",{className:"git-dialog-icon",children:i?S.jsx(Xp,{size:18}):S.jsx(Zd,{size:18})}),S.jsx("h2",{children:i?"Cloud repo ready":"Set up Cloud coding"}),S.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."}),S.jsxs("div",{className:"cloud-setup-summary",children:[S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Project"}),S.jsx("strong",{children:e.projectName})]}),S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Source"}),S.jsx("strong",{children:l?"OpenPond Git":"Local project upload"})]}),S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Branch"}),S.jsx("strong",{children:m?.branch??e.branch??"main"})]}),!l&&S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Cloud project"}),S.jsx("strong",{children:m?.targetProjectId??e.cloudProjectId??"New on upload"})]})]}),!i&&!l&&S.jsx("div",{className:"cloud-setup-upload-preview",role:"status","aria-live":"polite",children:e.previewLoading?S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:"Calculating upload preview"}),S.jsx("span",{children:"Checking tracked and unignored files before anything is pushed."})]}):e.previewError?S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:"Preview unavailable"}),S.jsx("span",{children:"Close and reopen setup to try the preview again."})]}):m?S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:m.initializedEmptyProject?"Will initialize an empty project":`Will upload ${m.fileCount} files`}),S.jsx("span",{children:dy({byteCount:m.byteCount,skippedCount:m.skippedCount,headCommit:m.headCommit,targetProjectName:m.targetProjectName})})]}):S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:"Upload preview pending"}),S.jsx("span",{children:"File count, byte count, and skipped files will appear here before upload."})]})}),r&&S.jsxs("div",{className:"cloud-setup-progress",role:"status","aria-live":"polite",children:[S.jsx(NF,{className:"cloud-setup-spinner",size:16}),S.jsx("span",{children:"Uploading source to OpenPond Git..."})]}),i&&e.upload&&S.jsxs("div",{className:"cloud-setup-upload-result",children:[S.jsx("strong",{children:e.upload.initializedEmptyProject?"Initialized empty project":`Uploaded ${e.upload.fileCount} files`}),S.jsx("span",{children:dy({byteCount:e.upload.byteCount,skippedCount:e.upload.skippedCount,headCommit:e.upload.headCommit,targetProjectName:e.upload.branch})})]}),i&&e.setupUrl&&S.jsxs("div",{className:"cloud-setup-next",children:[e.projectUrl?S.jsxs("span",{children:["Your repo is ready here:"," ",S.jsxs("a",{href:e.projectUrl,target:"_blank",rel:"noreferrer",onClick:u=>np(u,e.projectUrl,n,{newTab:!0}),children:["Project page",S.jsx(Gm,{size:13})]})]}):S.jsx("span",{children:"Your repo is ready. Next step:"}),S.jsxs("a",{href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>np(u,e.setupUrl,n),children:["Setup the Cloud sandbox",S.jsx(Gm,{size:13})]})]}),S.jsxs("div",{className:"git-dialog-footer",children:[S.jsx("button",{className:"git-dialog-secondary",disabled:r,type:"button",onClick:t,children:i?"Done":"Cancel"}),i?e.setupUrl?S.jsxs("a",{className:"git-dialog-primary cloud-setup-primary-link",href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>np(u,e.setupUrl,n),children:["Open setup",S.jsx(Gm,{size:13})]}):null:S.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 np(e,t,n,a={}){!t||!n||(e.preventDefault(),n(t,a))}function f3(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 dy({byteCount:e,skippedCount:t,headCommit:n,targetProjectName:a}){const r=[f3(e),`${t} skipped`],i=h3(n);return i&&r.push(`local ${i}`),r.push(a),r.join(" · ")}function h3(e){const t=e?.trim();return t?t.slice(0,7):null}const g3=g.lazy(()=>Dr(()=>import("./CommandMenu-Diux_-o-.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(e=>({default:e.CommandMenu}))),v3=g.lazy(()=>Dr(()=>import("./SettingsView-CUMVR2Dz.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}))),b3=g.lazy(()=>Dr(()=>import("./NewProjectDialog-BjXl7sr_.js"),__vite__mapDeps([26,1,2,8,15]),import.meta.url).then(e=>({default:e.NewProjectDialog}))),y3=g.lazy(()=>Dr(()=>import("./WorkspaceGitDialogs-ZTVPqFoS.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.CommitDialog}))),S3=g.lazy(()=>Dr(()=>import("./WorkspaceGitDialogs-ZTVPqFoS.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.BranchDialog})));function x3({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:O,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:j,diffPanelExpanded:x,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A}){return S.jsx(g.Suspense,{fallback:null,children:S.jsx(v3,{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:O,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:j,diffPanelExpanded:x,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A})})}function k3({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:O,query:P,searchOpen:L,visibleWorkspaceDiff:$,visibleWorkspaceState:j,workspaceBusy:x,appDispatch:C,beginNewChat:A,openDefaultsSettingsFromBranchDialog:z,setBranchDialogName:q,setBranchDialogOpen:N,setCommitDialogOpen:K,setCommitDraft:de,setCommitIncludeUnstaged:te,setCommitMessage:Ie,setCommitNextStep:Se,setNewProjectDialogOpen:Z,setNewProjectName:Pe,setNewProjectPath:ge,setQuery:ce,setSearchOpen:be,submitCommitDialog:ne,submitCreateWorkspaceBranch:he,submitNewProjectDialog:ke}){return S.jsxs(S.Fragment,{children:[L&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(g3,{open:L,query:P,projects:O,sessions:e,onQueryChange:ce,onClose:()=>{be(!1),ce("")},onNewChat:()=>{be(!1),ce(""),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&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(b3,{open:b,mode:w,name:_,path:E,directory:y,busy:h,onNameChange:Pe,onPathChange:ge,onClose:()=>{h||Z(!1)},onSubmit:ke})}),a&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(y3,{open:a,branch:j?.currentBranch??null,filesChanged:$?.filesChanged??j?.changedFilesCount??0,additions:$?.additions??0,deletions:$?.deletions??0,message:s,includeUnstaged:i,nextStep:l,draft:r,busy:x,canPush:!!j?.remoteUrl,canPublish:m,onMessageChange:Ie,onIncludeUnstagedChange:te,onNextStepChange:Se,onDraftChange:de,onClose:()=>{x||K(!1)},onSubmit:ne})}),n&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(S3,{open:n,branchName:t,busy:x,onBranchNameChange:q,onSetPrefix:z,onClose:()=>{x||N(!1)},onSubmit:he})})]})}function aI({toast:e,onDismiss:t}){if(!e)return null;const n=!!(e.actionLabel&&e.onAction),a=!!(e.persistent||e.dismissible);return S.jsxs("div",{className:`app-toast ${e.tone} ${e.placement??"bottom-right"}`,role:e.tone==="error"?"alert":"status","aria-live":"polite",children:[S.jsx("span",{className:"app-toast-message",children:e.message}),(n||a)&&S.jsxs("div",{className:"app-toast-actions",children:[n&&S.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"?S.jsx(ng,{size:15}):e.actionLabel}),a&&S.jsx("button",{type:"button",className:"app-toast-close","aria-label":"Dismiss notification",onClick:t,children:S.jsx(rs,{size:14})})]})]})}var uy=M_();const Wl=g.createContext(null);function w3({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 S.jsx(Wl.Provider,{value:i,children:e})}function rJ({children:e}){return S.jsx(Wl.Provider,{value:null,children:e})}function I3({children:e,className:t=""}){const n=g.useContext(Wl);return S.jsx("div",{ref:n?.setTitle,className:`page-chrome-title-target ${t}`,children:e?S.jsx("div",{className:"page-chrome-fallback",children:e}):null})}function _3({className:e=""}){const t=g.useContext(Wl);return S.jsx("div",{ref:t?.setActions,className:e})}function iJ({title:e,actions:t,fallback:n,children:a}){const r=g.useContext(Wl);return r?S.jsxs(S.Fragment,{children:[r.title?uy.createPortal(S.jsx("div",{className:"page-chrome-title",children:e}),r.title):null,r.actions&&t?uy.createPortal(t,r.actions):null,a]}):n??S.jsxs("header",{children:[e,t]})}async function C3(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 R3({activeView:e,onDiscoverCommunities:t,onOpenTeamChat:n}){return S.jsxs("div",{className:"titlebar-collaboration-actions",children:[S.jsx("button",{type:"button",className:`titlebar-icon${e==="team"?" active":""}`,"aria-label":"Team chat",title:"Team chat",onClick:n,children:S.jsx(Jd,{size:16})}),S.jsx("button",{type:"button",className:`titlebar-icon${e==="community"?" active":""}`,"aria-label":"Discover communities",title:"Discover communities",onClick:t,children:S.jsx(S1,{size:16})})]})}const P3=g.lazy(()=>Dr(()=>import("./WorkspaceEnvironmentMenu-CGaDd3lr.js"),__vite__mapDeps([29,1,2,21,10,14,5,30,28,31]),import.meta.url).then(e=>({default:e.WorkspaceEnvironmentMenu})));function A3({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:O,diffPanelOpen:P,terminalOpen:L,rightSidebarAvailable:$=!1,rightSidebarOpen:j=!1,onToggleDiffPanel:x,onToggleRightSidebar:C,onOpenSearch:A,onToggleTerminal:z,onRunTerminalCommand:q,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:Se,onOpenSandboxWorkspace:Z,onShowSidebar:Pe,onOpenTeamChat:ge,onDiscoverCommunities:ce,collaborationView:be=null,platform:ne,showWorkspaceControls:he=!0}){const ke=y?.filesChanged??0,qe=Yd()&&!og(ne),xe=!!(ge||ce)||he||$||qe,[re,we]=g.useState(null);g.useEffect(()=>{if(!re)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)}},[re]);const je=Ge=>{Ge.preventDefault(),Ge.stopPropagation();const st=190,Ue=n?76:42;we({x:Math.min(Ge.clientX,window.innerWidth-st-8),y:Math.min(Ge.clientY,window.innerHeight-Ue-8)})},Ze=Ge=>{C3(Ge),we(null)};return S.jsxs("header",{className:"app-titlebar",children:[S.jsxs("div",{className:"titlebar-left",children:[!e&&S.jsx("button",{className:"titlebar-icon",title:"Show sidebar",onClick:Pe,children:S.jsx(x1,{size:16})}),r?S.jsx("button",{className:"titlebar-icon",type:"button","aria-label":r.label,title:r.label,onClick:r.onSelect,children:S.jsx(eF,{size:16})}):null,S.jsx(I3,{children:a?.length?S.jsx("nav",{className:"titlebar-breadcrumbs","aria-label":"Breadcrumb",children:a.map((Ge,st)=>{const Ue=st===a.length-1;return S.jsxs("div",{className:"titlebar-breadcrumb-item",children:[Ge.onSelect&&!Ue?S.jsx("button",{type:"button",onClick:Ge.onSelect,children:Ge.label}):S.jsx("strong",{children:Ge.label}),!Ue&&S.jsx(Nr,{size:14})]},`${Ge.label}-${st}`)})}):S.jsxs("div",{className:"titlebar-title",children:[S.jsx("strong",{className:"titlebar-copy-target",title:"Double-click to select; right-click for copy options",onContextMenu:je,children:t}),i&&S.jsx("span",{children:i})]})})]}),xe&&S.jsxs("div",{className:"titlebar-right",children:[S.jsx(_3,{className:"page-chrome-actions"}),S.jsx(R3,{activeView:be,onDiscoverCommunities:ce,onOpenTeamChat:ge}),he&&S.jsxs("div",{className:"titlebar-actions",children:[S.jsx(g.Suspense,{fallback:null,children:S.jsx(P3,{mode:"topbar",busy:l,workspaceState:m,workspaceId:s,workspaceKind:u,selectedApp:h,selectedProject:b,workspaceBusy:_,defaultTeamId:E,workspaceDiff:y,managedWorkspace:w,showDiffControls:O,diffPanelOpen:P,onToggleDiffPanel:x,onRunTerminalCommand:q,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:Se,onOpenSandboxWorkspace:Z})}),S.jsx("button",{type:"button",className:"titlebar-icon",title:"Search chats and projects","aria-label":"Search chats and projects",onClick:A,children:S.jsx(JF,{size:16})}),S.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:S.jsx(w1,{size:16})}),O&&S.jsx("button",{type:"button",className:`topbar-diff-button ${j?"active":""}`,title:`${j?"Hide":"Show"} sidebar${ke?`, ${ke} changed files`:""}`,"aria-label":`${j?"Hide":"Show"} sidebar`,"aria-pressed":j,onClick:x,children:S.jsx(ef,{size:16})})]}),$&&C&&!O?S.jsx("div",{className:"titlebar-actions",children:S.jsx("button",{type:"button",className:`topbar-diff-button ${j?"active":""}`,title:`${j?"Hide":"Show"} sidebar`,"aria-label":`${j?"Hide":"Show"} sidebar`,"aria-pressed":j,onClick:C,children:S.jsx(ef,{size:16})})}):null,S.jsx(r5,{platform:ne})]}),re&&S.jsxs("div",{className:"titlebar-copy-menu",role:"menu","aria-label":"Conversation title actions",style:{left:re.x,top:re.y},onPointerDown:Ge=>Ge.stopPropagation(),children:[S.jsx("button",{type:"button",role:"menuitem",onClick:()=>Ze(t),children:"Copy title"}),n&&S.jsx("button",{type:"button",role:"menuitem",onClick:()=>Ze(n),children:"Copy conversation ID"})]})]})}function T3(){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 E3({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 S.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:()=>t(!1),children:S.jsxs("section",{className:"git-dialog project-confirm-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":a,onMouseDown:i=>i.stopPropagation(),children:[S.jsx("h2",{id:n,children:e.title}),S.jsx("p",{id:a,children:e.body}),S.jsxs("div",{className:"git-dialog-footer",children:[S.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:()=>t(!1),children:e.cancelLabel}),S.jsx("button",{type:"button",className:r,autoFocus:!0,onClick:()=>t(!0),children:e.confirmLabel})]})]})})}function M3(){const{confirmAction:e,confirmDialog:t,resolveConfirmDialog:n}=T3();return{confirmProjectAction:g.useCallback(r=>e({tone:"danger",...r}),[e]),projectConfirmDialog:t,resolveProjectConfirmDialog:n}}function j3({state:e,onResolve:t}){return S.jsx(E3,{state:e,onResolve:t})}const ud=new Map,O3=(e,t,n)=>{const a=ud.get(e)??{commits:0,maxActualDurationMs:0,totalActualDurationMs:0};a.commits+=1,a.maxActualDurationMs=Math.max(a.maxActualDurationMs,n),a.totalActualDurationMs+=n,ud.set(e,a)};function $3({children:e,id:t}){return S.jsx(g.Profiler,{id:t,onRender:O3,children:e})}typeof window<"u"&&(window.__OPENPOND_RENDER_COMMITS__={get:()=>Object.fromEntries([...ud.entries()].map(([e,t])=>[e,{...t}])),reset:()=>ud.clear()});const N3=g.lazy(()=>Dr(()=>import("./MainPane-DcQhWQSs.js").then(e=>e.M),__vite__mapDeps([32,1,2,13,33,6,30]),import.meta.url).then(e=>({default:e.MainPane})));function D3({className:e,style:t,sidebar:n,topBar:a,mainPane:r,cloudSetup:i,projectConfirm:s,lazyPanels:l,toast:m}){return S.jsx(w3,{children:S.jsxs("div",{className:e,style:t,children:[S.jsx($3,{id:"sidebar",children:S.jsx(c3,{...n})}),S.jsxs("div",{className:"content-shell",children:[S.jsx(A3,{...a}),S.jsx(g.Suspense,{fallback:S.jsx("main",{className:"main-pane","aria-busy":"true","aria-label":"Loading workspace"}),children:S.jsx(N3,{...r})})]}),S.jsx(p3,{...i}),S.jsx(j3,{...s}),S.jsx(k3,{...l}),S.jsx(aI,{...m})]})})}function L3({settings:e,toast:t}){return S.jsxs(S.Fragment,{children:[S.jsx(x3,{...e}),S.jsx(aI,{...t})]})}const Bc="OpenPond".split("");function U3({visibleLetterCount:e=Bc.length}){const t=Bc.slice(0,Math.max(0,Math.min(e,Bc.length)));return S.jsxs("div",{className:"app-splash-lockup",children:[S.jsx("div",{className:"app-splash-mark",children:S.jsx("img",{alt:"OpenPond",className:"app-splash-logo",decoding:"async",src:G4})}),S.jsx("span",{"aria-hidden":"true",className:`app-splash-wordmark${t.length>0?" is-visible":""}`,children:t.map((n,a)=>S.jsx("span",{className:"app-splash-letter",children:n},`${n}-${a}`))})]})}const ap=Bc.length,z3=520,H3=240;function my(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function q3({startup:e}){const[t,n]=g.useState(()=>my()?ap:0);return g.useEffect(()=>{if(my()){n(ap);return}const a=Array.from({length:ap},(r,i)=>window.setTimeout(()=>n(i+1),z3+H3*i));return()=>{a.forEach(r=>window.clearTimeout(r))}},[]),S.jsxs("main",{className:"app-splash","aria-busy":"true","aria-label":e.label,role:"status",children:[S.jsx(U3,{visibleLetterCount:t}),S.jsx("span",{className:"app-splash-status",children:e.label})]})}const Sg=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=Sg){return Fc(Co(e,t),n)}function Fc(e,t=Sg){return e.length<=t?e:e.slice(e.length-t)}function B3(e,t,n){return n.length===0?e:{...e,[t]:Co(e[t]??[],n)}}function F3(e,t){if(t.length===0)return Fc(e);if(e.length===0)return Fc(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 Fc([...n.values()].sort((r,i)=>K3(r,i)).map(({event:r})=>r))}function md(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 V3(e){let t=null;for(const n of e)n.sequence!==void 0&&(t===null||n.sequence<t)&&(t=n.sequence);return t}function K3(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 W3(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 G3(e){return e==="codex"}function Z3(e){return e==="openpond"}function oI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="session.context.updated")continue;const a=hj.safeParse(n.data);if(a.success)return a.data}return null}function rI(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:W3(r)}}if(G3(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(!Z3(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 xg(e){let t=!1;const n=iI(e);for(let a=e.length-1;a>=0;a-=1){const r=e[a];if(J3(r)){t=!0;continue}const i=Gi(r?.data);if(!(r?.name!=="diagnostic"||!i)){if(i.kind==="thread_goal_cleared")return null;if(i.kind==="thread_goal"){const s=kg(Gi(i.goal),Wn(i.provider),n);if(s){const l=_l(s);return t&&l.tone==="active"?null:l}}if(i.kind==="goal_context"){const s=lI(r.output??"",Wn(i.provider)??"codex",n);if(s){const l=_l(s);return t&&l.tone==="active"?null:l}}}}return null}function pd(e){const t=iI(e);for(let n=e.length-1;n>=0;n-=1){const a=e[n],r=Gi(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=kg(Gi(r.goal),Wn(r.provider),t);if(!i)continue;const s=_l(i);return s.tone==="active"?s:null}if(r.kind==="goal_context"){const i=lI(a.output??"",Wn(r.provider)??"codex",t);if(!i)continue;const s=_l(i);return s.tone==="active"?s:null}}}return null}function op(e){const t=Gi(Gi(e)?.codexGoalRuntime),n=kg(t,Wn(t?.provider)??"codex");if(!n)return null;const a=_l(n);return a.tone==="active"?a:null}function J3(e){return e?.name==="turn.completed"||e?.name==="turn.interrupted"||e?.name==="turn.failed"}function _l(e){const t=cI(e.status),n=mI(e.timeUsedSeconds),a=`Goal ${n}`,r=e.tokensUsed===null?null:e.tokenBudget===null?`${rp(e.tokensUsed)} tokens`:`${rp(e.tokensUsed)} / ${rp(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: ${pI(e.timeUsedSeconds)}. ${i}. ${e.objective}`,tone:t.tone,observedAt:e.observedAt}}function Y3(e,t){if(!e||e.tone!=="active"||!e.observedAt)return e;const n=sI(e.observedAt,t);if(n<=0)return e;const a=e.timeUsedSeconds+n,r=mI(a);return{...e,timeUsedSeconds:a,timeLabel:r,label:`Goal ${r}`,tooltip:`Goal runtime: ${pI(a)}. ${e.detail}. ${e.objective}`,observedAt:t}}function kg(e,t=null,n=null){if(!e)return null;const a=Wn(e.objective)??"Active goal",r=Wn(e.status)??"active";if((mf(t)??mf(Wn(e.provider)))!=="codex")return null;const s=n??Wn(e.updatedAt)??Wn(e.updated_at)??null,l=bi(e.timeUsedSeconds)??bi(e.time_used_seconds)??0,m=Wn(e.activeSinceAt)??Wn(e.active_since_at),u=cI(r).tone==="active"?sI(m??Wn(e.createdAt)??Wn(e.created_at),s):0,h=m?l+u:Math.max(l,u),b=bi(e.tokensUsed)??bi(e.tokens_used),y=bi(e.tokenBudget)??bi(e.token_budget);return{objective:a,status:r,statusLabel:uI(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 iI(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 sI(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 lI(e,t=null,n=null){if(!e.trim()||mf(t)!=="codex")return null;const a=dI(e,"Status")??"active",r=Ws(e,"Tokens used"),i=Ws(e,"Token budget"),s=Ws(e,"Time used seconds")??Ws(e,"Time spent pursuing goal")??Ws(e,"Elapsed seconds")??0;return{objective:hy(e,"objective")??hy(e,"untrusted_objective")??"Active goal",status:a,statusLabel:uI(a),timeUsedSeconds:Math.max(0,Math.floor(s)),tokensUsed:r,tokenBudget:i,observedAt:n}}function cI(e){switch(Q3(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 Q3(e){return e.trim().toLowerCase().replace(/[-\s]+/g,"_")}function dI(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^\\s*-?\\s*${n}:\\s*(.+?)\\s*$`,"im").exec(e)?.[1]?.trim()||null}function Ws(e,t){const n=dI(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 uI(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function mI(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 pI(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 rp(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 Gi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Wn(e){return typeof e=="string"&&e.trim()?e.trim():null}function mf(e){return e?.trim().toLowerCase()||null}function bi(e){return typeof e=="number"&&Number.isFinite(e)?e:null}const X3=new Set(["planning","applying_source","running_checks","evaluating","pushing_hosted","running_hosted_checks"]),e6=new Set(["awaiting_questions","awaiting_plan_approval","paused"]);function pf(e){const t=fI(e);return t?o6(t):null}function fI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="create_improve.updated")continue;const a=a6(c6(n.data));if(a)return a}return null}function t6(e){if(e.events)return fI(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 n6(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 a6(e){const t=jl.safeParse(e?.createImproveRun);return t.success?t.data:null}function o6(e){const t=r6(e);if(!t)return null;const n=i6(e.createdAt,e.updatedAt),a=e.blockedReason??s6(e.state);return{objective:e.objective,status:e.state,timeUsedSeconds:n,tokensUsed:null,tokenBudget:null,actionLabel:t.actionLabel,timeLabel:l6(n),label:t.actionLabel,detail:a,tooltip:`${t.actionLabel}: ${a}. ${e.objective}`,tone:t.tone}}function r6(e){const t=e.state,n=e.target.kind==="agent"?"Agent":"Work";return X3.has(t)?{tone:"active",actionLabel:`${n} running`}:e6.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 i6(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 s6(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function l6(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 c6(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hI(e,t){if(!t)return null;const n=new Map,a=[];for(const j of e){if(!j.name.startsWith("subagent."))continue;const x=m6(j);x&&a.push(x);const C=u6(j);C?.parentSessionId===t&&n.set(C.id,C)}if(n.size===0)return null;const r=[...n.values()].sort((j,x)=>Si(x).localeCompare(Si(j))),i=r.filter(j=>j.status==="queued"||j.status==="running"),s=r.filter(j=>j.status==="completed"),l=r.filter(j=>j.status==="failed"),m=r.filter(j=>j.status==="cancelled"),u=r.filter(j=>j.status==="needs_resume"),h=[...s,...l,...m].sort((j,x)=>Si(x).localeCompare(Si(j))),b=r.reduce((j,x)=>{const C=Zi(x.metadata?.usage);return j.totalTokens+=Cc(C?.totalTokens),j.promptTokens+=Cc(C?.promptTokens),j.completionTokens+=Cc(C?.completionTokens),j.requestCount+=Cc(C?.requestCount),j},{totalTokens:0,promptTokens:0,completionTokens:0,requestCount:0}),y=r.flatMap(j=>gI([...j.report?.blockers??[],j.error,j.progress.currentBlocker]).map(x=>({runId:j.id,roleId:j.roleId,status:j.status,message:x}))),w=r.flatMap(j=>vI([...j.report?.artifacts??[],j.report?.patchRef,j.report?.diffRef,...j.progress.patchRefs]).map(x=>({...x,runId:j.id,roleId:j.roleId}))),_=h.map(j=>d6(j,a)),E=r[0]??null,O=E?{runId:E.id,roleId:E.roleId,status:E.status,message:E.progress.latestMeaningfulActivity||E.report?.summary||E.objective,updatedAt:Si(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(" · "),$=O?`${h6(O.roleId)}: ${O.message}`:"";return{sessionId:t,runs:r,activeRuns:i,completedRuns:s,failedRuns:l,cancelledRuns:m,needsResumeRuns:u,terminalRuns:h,latestRun:E,latestMeaningfulUpdate:O,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((j,x)=>j+x.progress.validationAttempts.length,0),label:P,tooltip:[L,$].filter(Boolean).join(". ")}}function d6(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:vI([...e.report?.artifacts??[],e.report?.patchRef,e.report?.diffRef]),testsRun:e.report?.testsRun??[],validationAttempts:e.progress.validationAttempts.map(n=>n.command),blockers:gI([...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:p6(e),updatedAt:Si(e)}}function u6(e){const t=Zi(e.data),n=[t?.run,Zi(t?.message)?.run];for(const a of n){const r=PS.safeParse(a);if(r.success)return r.data}return null}function m6(e){const t=$E.safeParse(Zi(e.data)?.message);return t.success?t.data:null}function p6(e){const t=Zi(Zi(e.metadata?.workspaceHandoff)?.workspaceRetention);return t?.status!=="retained"?null:{status:"retained",reason:_c(t.reason),retainedAt:_c(t.retainedAt),expiresAt:_c(t.expiresAt),retentionDays:f6(t.retentionDays),trigger:_c(t.trigger),cleanupAfterExpiry:t.cleanupAfterExpiry===!0}}function Si(e){return e.updatedAt??e.completedAt??e.startedAt??e.createdAt}function gI(e){return[...new Set(e.map(t=>t?.trim()).filter(t=>!!t))]}function vI(e){const t=new Map;for(const n of e)n&&t.set(`${n.kind}:${n.id}`,n);return[...t.values()]}function Zi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function _c(e){return typeof e=="string"&&e.trim()?e.trim():null}function Cc(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function f6(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function h6(e){return e.slice(0,1).toUpperCase()+e.slice(1).replace(/[-_]+/g," ")}const ff=[];function hf(e,t){return bI(e,t,null)}function bI(e,t,n){const a=n&&S6(n.events,e)?v6(n.indexes,n.events.length,e):g6(e),r=y6(t);return{...a,...r}}function g6(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 b6(t)}function v6(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)??ff,y=oI(b);y?r.set(h,y):r.delete(h);const w=SI(b);w?(i.set(h,w),w.tone==="active"?l.add(h):l.delete(h)):(i.delete(h),l.delete(h));const _=hI(b,h);_?(s.set(h,_),yI({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 b6(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=oI(l);m&&t.set(s,m);const u=SI(l);u&&(n.set(s,u),u.tone==="active"&&r.add(s))}for(const[s,l]of e){const m=hI(l,s);m&&(a.set(s,m),yI({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 yI(e){if(e.latestGoalRuntimeBySessionId.has(e.sessionId))return;const t=pd(e.sessionEvents);t&&(e.latestGoalRuntimeBySessionId.set(e.sessionId,t),t.tone==="active"&&e.activeGoalSessionIds.add(e.sessionId))}function SI(e){return pf(e)??xg(e)??pd(e)}function y6(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 S6(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 Gl(e,t){return t?e.eventsBySessionId.get(t)??ff:ff}function xI(e,t){return t?e.latestContextUsageBySessionId.get(t)??null:null}function kI(e,t){return t?e.latestGoalRuntimeBySessionId.get(t)??null:null}function x6(e,t){return t?e.latestSubagentRuntimeBySessionId.get(t)??null:null}function k6(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 w6(e,t){return e?.conversationId===t}function I6(e,t){return e?.id===t?null:e}function _6(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 C6(e){return JSON.stringify([e.source,e.repositoryId,e.profileId])}function sJ(e,t){return e.profiles.find(n=>C6(n.ref)===t)?.ref??null}function R6(e,t){return!!(e&&t&&e.source===t.source&&e.repositoryId===t.repositoryId&&e.profileId===t.profileId)}function lJ(e,t){return e.profiles.find(n=>R6(n.ref,t))?.state??null}function P6(e,t){const n=new Map(wO.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 A6(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 cJ(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 wI="openpond:last-chat-task-mode";function T6(e,t){return e==="labs"?"models":"chat"}function E6(e){try{return e.getItem(wI)==="work"?"work":"chat"}catch{return"chat"}}function wg(){if(typeof window>"u")return"chat";try{return E6(Kl)}catch{return"chat"}}function M6(e,t){try{e.setItem(wI,t==="chat"?"chat":"work")}catch{}}function j6(e){if(!(typeof window>"u"))try{M6(Kl,e)}catch{}}const O6="uploaded to a different account";function II(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 ya(e,t){const n=II(e,t);return n.state==="confirmed"?n.cloudProject:null}function $6(e,t){return II(e,t).state==="different_account"?O6:null}function lo(e){return e==="sandbox"||e==="sandbox_template"||e==="sandbox_app"}function _I(e={}){return{...e,workspaceTarget:"hybrid"}}function N6(e={}){return{...e,workspaceTarget:"local"}}function co(e){return e?.metadata?.workspaceTarget==="hybrid"}function D6(e){return!!(e&&e.provider==="openpond"&&e.workspaceKind==="local_project"&&e.cloudProjectId&&e.title.trim().endsWith(" Cloud"))}function CI({cloudProjects:e,selectedCloudProject:t,selectedProject:n}){const a=n?.linkedSandboxProject??null,r=e?ya(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 RI({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:_I(),cwd:n.cwd,title:a}}function L6(e){return g.useEffect(()=>{const t=L1(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=$5(n);try{let r;const i=e.selectedSession;if(i&&wl(i))r=await J.patchSession(e.connection,i.id,{title:a,metadata:ep(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:zi}:{providerId:l,modelId:e.activeModel}),u=s?{workspaceTarget:s}:!i&&e.workspaceTarget==="local"?{workspaceTarget:"local"}:{};let h;if(!i&&e.workspaceTarget==="hybrid"){const b=CI({cloudProjects:e.cloudProjects,selectedCloudProject:e.selectedCloudProject,selectedProject:e.selectedProject});if(b.kind!=="ready")throw new Error(b.message);const y=RI({modelRef:m,provider:l,target:b,title:a});h={...y,experience:"work",metadata:ep(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:ep(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 U6=[];function z6({primary:e,secondary:t}){const[n,a]=g.useState(!1),r=b5(),{composerDraftStore:i,appDispatch:s,pendingTerminalCommand:l,setPendingTerminalCommand:m,terminalTabs:u,setTerminalTabs:h,trainingDetailTasksetId:b,setTrainingDetailTasksetId:y,mentionedAppId:w,setMentionedAppId:_,cloudSetupDialog:E,setCloudSetupDialog:O,rightPanelTabRequest:P,workspaceDiffPanelViewState:L,mainComposerFocusRequestId:$,requestMainComposerFocus:j,projectConfirmDialog:x,resolveProjectConfirmDialog:C,query:A,searchOpen:z,archivedChatsOpen:q,sectionMenuOpen:N,cloudProjectsExpanded:K,sidebarOpen:de,view:te,selectedAppId:Ie,selectedProjectId:Se,selectedSessionId:Z,codexPermissionMode:Pe,codexReasoningEffort:ge,busy:ce,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:he,activeExperience:ke,changeNewExperience:qe,terminalOpen:xe,settingsSection:re,newProjectDialogOpen:we,newProjectMode:je,newProjectName:Ze,newProjectPath:Ge,newProjectBusy:st,commitDialogOpen:Ue,commitMessage:Ve,commitIncludeUnstaged:Le,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:Fe,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setPrompt:ie,setDraftProvider:F,setDraftModel:I,setDraftExperience:W,setDiffPanelOpen:X,setDiffPanelExpanded:ae,setRightPanelMode:G,setTerminalOpen:pe,setSettingsSection:fe,setNewProjectDialogOpen:Oe,setNewProjectName:Ee,setNewProjectPath:Ne,setCommitDialogOpen:Ke,setCommitMessage:ze,setCommitIncludeUnstaged:ut,setCommitNextStep:Qt,setCommitDraft:Lt,setBranchDialogOpen:An,setBranchDialogName:Sn,setError:nn,showToast:bt,applyBootstrapPayload:rn,bootstrap:Nt,connection:yt,startup:un,training:Ut,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Na,sidebarWidth:Da,sidebarResizing:qt,diffPanelWidth:qn,diffPanelResizing:ot,togglePinnedCollapsed:xn,toggleCloudProjectsCollapsed:La,toggleChatsCollapsed:Ua,toggleSavedForLaterCollapsed:ia,startSidebarResize:za,startDiffPanelResize:oe,selectedApp:De,selectedCloudProject:Be,selectedProject:Je,selectedProjectLinkedApp:At,selectedSession:gt,sidebarSessions:lt,runtimeIndexes:_t,runtimeEventStore:sa,chatMentionApps:Bn,connectedAppMentions:tt,pendingApproval:_n,pendingChatUserMessages:St,account:kn,activeModel:$n,activeProvider:Tn,appDefaults:Ha,startMessage:ka,organizations:uo,teamChatOrganization:qa,teamChatTeamId:ea,teamChat:xt,publishTeamProfileAgent:Ba,communitySidebar:la,communityView:Kr,teamAiThreadId:mr,toggleTeamAiSidebar:pr,activeOpenPondCommandAccessMode:mo,viewWorkspaceAppId:Wr,viewWorkspaceId:Gr,viewWorkspaceKind:Zr,viewWorkspaceName:Jr,selectedActionCatalog:is,expandedProjectIds:ss,expandProject:Fa,toggleProjectExpanded:ls,changeCodexPermissionMode:Yr,changeCodexReasoningEffort:Qr,changeOpenPondCommandAccessMode:Xr,resolveApproval:cs,beginNewChat:ta,beginNewChatWithTrainingModel:ds,dismissTrainingChatHandoff:us,trainingChatHandoff:ms,selectTrainingChatTaskForComposer:ei,chatHistoryLoadStates:ti,loadMoreSelectedChatHistory:ni,selectedPagedSessionEvents:ps,activeSessions:Va,archivedSessions:po,pinnedSessions:Fn,savedForLaterSessions:fs,savedForLaterFiles:hs,sidebarFileBookmarks:vn,setSidebarFileStatus:ai,setSessions:Vn,projectRows:wa,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:gs,childSessionRowsByParentId:vs,sidebarProjectIdBySessionId:ho,chatRows:fr,visibleChatRows:oi,chatRowsVisibleCount:hr,sessionEvents:ri,goalRuntime:gr,subagentRuntime:ii,visibleChatMessages:ca,activeTerminalScope:Fo,terminalSummaries:vr,runningSessionIds:go,selectedSessionRunning:si,sidebarGoalRuntimeBySessionId:Wa,sidebarSubagentRuntimeBySessionId:li,taskDragSessionId:bs,taskPreviewSessionIds:br,startTaskDrag:ci,clearTaskDrag:di,previewTaskDrop:ui,commitTaskDrop:ys,commitTaskPreviewDrop:yr,dragItem:mi,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:Ss,commitPinnedDrop:xs,commitPinnedPreviewDrop:ks,commandProjectRows:ws,contextWindowStatus:Ia,pinnedRows:pi,workspaceBusy:Sr,diffBusy:Is,visibleWorkspaceState:vo,visibleWorkspaceDiff:Nn,refreshVisibleWorkspaceDiff:_s,managedWorkspace:Cs,canSyncActiveWorkspace:Rs,canPublishOpenPondProject:Ps,projectTarget:mt,workspaceTarget:Bt}=e,{title:Kn,browserConversationId:pn,handleWorkspaceDiffPanelViewStateChange:na,openSessionInChat:En,changeProjectTarget:su,submitNewProjectDialog:lu,changeWorkspaceBranch:cu,openCommitDialog:As,openCreateWorkspaceBranchDialog:Jl,openDefaultsSettingsFromBranchDialog:du,runWorkspaceTool:uu,submitCommitDialog:mu,submitCreateWorkspaceBranch:pu,syncWorkspaceLocally:fu,answerCreateImproveQuestion:hu,applyCreateImproveCandidate:gu,approveCreateImproveRun:vu,cancelCreateImproveRun:bu,changeDraftProvider:Yl,openCreateImprovePullRequest:yu,reconcileCreateImprovePullRequest:Ql,rejectCreateImproveCandidate:Su,pauseCreateImproveRun:xu,resumeCreateImproveRun:ku,reviseCreateImproveRun:Xl,stopTurn:Ts,archiveSession:wu,restoreSession:Iu,renameSession:ec,toggleSessionPinned:tc,toggleProjectPinned:nc,toggleSessionSavedForLater:Es,moveProjectToCloud:_u,startCloudSetupUpload:ac,changeWorkspaceTarget:Cu,sendPromptFromMainComposer:Ms,openSandboxWorkspace:Ru,openCloudProjectDialog:oc,openUrlInBrowserPanel:Pu,showBrowserPanel:rc,showChangesPanel:Au,showGoalSidebarTab:Tu,rightChatTrainingLaunchRequest:ic,setRightChatTrainingLaunchRequest:Eu,closeRightChatPanel:Mu,openRightChatPanel:js,rightChatPanelViews:ju,showRightChatPanel:Ou,showRightPanelDiffTab:Ko,submitRightChatPrompt:sc,activateRightChatPanel:$u,updateRightChatModel:Nu,updateRightChatPrompt:Du,updateRightChatProvider:Lu,updateRightChatScrollState:Uu,openProfileSettings:zu,diagnosticEvents:Hu,toggleRightSidebar:lc,removeProject:qu}=t,fi=g.useCallback(Te=>{U(null),V(Te),le(null),p("chat"),Fa(Te),j()},[Fa,j,U,V,le,p]),Bu=g.useCallback((Te=null)=>{const ct=Z?ho[Z]??null:null;if(!Te&&ct){fi(ct);return}ta(Te)},[ta,fi,Z,ho]),Fu=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]),Vu=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]),Os=ea??Ha.defaultTeamId??null,Ku=g.useMemo(()=>wa.filter(Te=>Te.kind==="local"||Os!==null&&Te.project.teamId===Os),[wa,Os]),Wu=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 da=vt("cloud",Mt);Te[ct.id]=(Te[ct.id]??0)+(Te[da]??0)}return Te},[Va,fo,ho]),[$s,Ns]=g.useState(null),[Ds,Ls]=g.useState(null),Gu=P6(Nt?.profile,Nt?.extensionCatalog),[Us,zs]=g.useState(null),[Hs,cc]=g.useState(null),[Za,qs]=g.useState(null),dc=g.useCallback(()=>{U(null),V(null),le(null),rt(null),p("team")},[rt,U,V,le,p]),Zu=g.useCallback(()=>{U(null),V(null),le(null),rt(null),la.discoverCommunities()},[la.discoverCommunities,rt,U,V,le]),Bs=L6({activeExperience:ke,activeModel:$n,activeOpenPondCommandAccessMode:mo,activeProvider:Tn,cloudProjects:Nt?.cloudProjects??U6,composerDraftStore:i,connection:yt,requestComposerFocus:j,selectedCloudProject:Be,selectedProject:Je,selectedSession:gt,setMentionedAppId:_,setSelectedSessionId:le,setSessions:Vn,setView:p,showToast:bt,workspaceTarget:Bt.value}),Ju=g.useCallback(async Te=>{if(!yt)throw new Error("OpenPond is not connected.");let ct=Tn,Mt=$n;ct==="codex"&&(ct=df(Nt?.providers,{enabledOnly:!0}).find(bn=>bn.value!=="codex")?.value??jr,Mt=cd(ct,Nt?.providers)??pl);const da=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 ${da?.title??"task"}`.slice(0,120),metadata:{experienceHandoff:A6({sourceTaskId:Te.sourceSessionId,sourceExperience:da?.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),sn({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"),ae(!1),bo},[$n,mo,Tn,s,Nt?.providers,i,yt,ae,X,W,I,F,G,U,V,Vn,pe,p,lt]),uc=g.useCallback(Te=>{zs(Te),cc(null),ta(null),Fe(!0)},[ta,Fe]),Yu=g.useCallback(Te=>{ta(null),W("work"),i.set(`$openpond-refiner-authoring ${Te}`),p("chat"),Fe(!0)},[ta,i,W,Fe,p]),xr=g.useCallback(Te=>{cc(_6(Te)),zs(null),ta(null),Fe(!0)},[ta,Fe]);g.useEffect(()=>{!Us&&!Hs||te!=="chat"||Z||Se||Ie||(Ns(Us),Ls(Hs),zs(null),cc(null),G("home"),ae(!1),X(!0))},[Us,Hs,Ie,Se,Z,ae,X,G,te]),g.useEffect(()=>{!$s&&!Ds||te==="chat"&&be&&he==="home"||(Ns(null),Ls(null))},[be,Ds,$s,he,te]);const Qu=g.useCallback(()=>{Ns(null),Ls(null),ae(!1),X(!1)},[ae,X]),Xu=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(da=>da.id===Te.sourceSessionId||da.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),qs({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(!w6(Za,pn))return;const Te=window.setTimeout(()=>{G("changes"),X(!0),qs(ct=>I6(ct,Za.id))},0);return()=>window.clearTimeout(Te)},[pn,X,G,Za]);const em=T6(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 tm=g.useCallback(Te=>{if(rt(null),U(null),V(null),le(null),Te==="models"){Oi(ro()),p("labs");return}Te==="chat"&&sn({kind:"chat",sessionId:null}),qe(wg())},[qe,sn,rt,U,V,le,p]),nm=g.useCallback(async(Te,ct)=>{const Mt=await Ut.actions.acceptHarnessReview(Te,ct,{providerId:Tn,modelId:$n},ge);return Mt?(y(Mt.materializedTasksetId??null),Oi(ro()),p("labs"),!0):(bt("Taskset review could not be opened.","error"),!1)},[$n,Tn,ge,Oi,ro,y,p,bt,Ut.actions]);if(!un.ready)return S.jsx(q3,{startup:un});if(te==="settings")return S.jsx(ly,{showToast:bt,children:S.jsx(L3,{settings:{payload:Nt,connection:yt,diagnostics:Hu,initialSection:re,onPayload:rn,onError:nn,onToast:bt,onOpenSourceSession:En,onStartRefinerAuthoring:Yu,onAcceptEvaluationReview:nm,onOpenSkill:uc,onOpenExtension:xr,teamChatCurrentUserId:xt.currentUserId,teamChatEnabled:ea!==null,teamChatNotificationMode:xt.notificationMode,teamChatThreads:xt.threads,onTeamChatNotificationModeChange:xt.setNotificationMode,onTeamChatThreadMuteChange:xt.setThreadMuted,diffPanelWidth:qn,diffPanelResizing:ot,diffPanelExpanded:ne,onDiffPanelResizeStart:oe,onDiffPanelExpandedChange:ae,onBack:()=>{const Te=h5(r);sn(Te),p(Te.kind==="models"?"labs":"chat"),Fe(!0)}},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})});const am=Yd(),Fs=yt?.platform??navigator.platform,mc=am&&og(Fs),Vs=Fo,om=vo?.initialized?vo.repoPath:gt?.cwd??null,rm={"--sidebar-width":`${Da}px`,"--diff-panel-width":`${qn}px`},im=te==="chat"&&ke!=="chat"||te==="labs"||te==="scheduled"&&n||te==="team"&&!!mr,sm=["app-shell",mc?"platform-macos":"",de?"sidebar-open":"sidebar-closed",qt?"sidebar-resizing":"",ot?"diff-panel-resizing":""].filter(Boolean).join(" "),at=Z?ti[Z]:null,Xt=Z?at?.cursorSequence??V3(Io(ps,Gl(_t,Z))):null,Gt=!!Z&&!!yt&&(Ht(Z)?!0:!!Nt?.eventWindow?.hasMoreBefore&&!!Xt)&&(at?.hasMore??!0),_a=!!at?.loading,lm=(()=>{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"]),da={queued:"Queued",starting:"Starting",running:"Running",cancelling:"Cancelling",reconciling:"Reconciling"},bo={};for(const bn of[...Te.modelRuns].sort((Ca,hi)=>hi.updatedAt.localeCompare(Ca.updatedAt))){if(bn.kind==="evaluation"||!["prepared","running"].includes(bn.status))continue;const Ca=Te.jobs.filter(cm=>cm.metadata.modelRunId===bn.id).sort((cm,E_)=>E_.updatedAt.localeCompare(cm.updatedAt))[0];if(Ca&&!Mt.has(Ca.status))continue;const hi=Ca?.status??(bn.status==="prepared"?"starting":"running");bo[bn.modelId]={label:da[hi]??"Running",status:hi}}for(const bn of[...Te.jobs].sort((Ca,hi)=>hi.updatedAt.localeCompare(Ca.updatedAt))){if(!Mt.has(bn.status))continue;const Ca=ct.get(bn.planId)?.modelId;!Ca||bo[Ca]||(bo[Ca]={label:da[bn.status]??"Active",status:bn.status})}return bo})();return S.jsx(ly,{showToast:bt,children:S.jsx(D3,{className:sm,style:rm,sidebar:{productArea:em,modelProjects:(Ut.payload?.modelProjects??[]).filter(Te=>Te.hosted===null||Te.hosted.teamId===(Ha.defaultTeamId?.trim()??null)),modelTrainingActivityByProjectId:lm,onProductAreaChange:tm,experience:ke,view:te,selectedAppId:Ie,selectedProjectId:Se,selectedSessionId:Z,selectedTeamThreadId:xt.selectedThreadId,teamChatEnabled:ea!==null,organizations:uo,teamChatOrganization:qa,teamChatLoading:xt.loading,currentUserId:xt.currentUserId,teamMembers:xt.members,teamThreads:xt.threads,...la,account:kn,connection:yt,profile:Nt?.profile,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Na,archivedChatsOpen:q,cloudProjectsExpanded:K,sectionMenuOpen:N,dragItem:mi,taskDragSessionId:bs,taskPreviewSessionIds:br,activeSessions:Va,archivedSessions:po,pinnedRows:pi,pinnedSessions:Fn,savedForLaterSessions:fs,savedForLaterFiles:hs,projectRows:wa,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:gs,childSessionRowsByParentId:vs,sidebarProjectIdBySessionId:ho,terminalSummaries:vr,runningSessionIds:go,goalRuntimeBySessionId:Wa,subagentRuntimeBySessionId:li,visibleChatRows:oi,chatRows:fr,chatRowsVisibleCount:hr,expandedProjectIds:ss,currentVersion:Nt?.server.version??null,platform:Fs,arch:yt?.arch??null,onSidebarResizeStart:za,setSidebarOpen:Fe,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setSearchOpen:Xe,setSectionMenuOpen:rt,setSettingsSection:fe,onSelectTeam:Fu,onLogOut:Vu,onTogglePinnedCollapsed:xn,onToggleCloudProjectsCollapsed:La,onToggleChatsCollapsed:Ua,onToggleSavedForLaterCollapsed:ia,setArchivedChatsOpen:et,setCloudProjectsExpanded:it,setChatRowsVisibleCount:Me,beginNewChat:Bu,beginProjectChat:fi,dockSessionRight:js,selectTeamThread:Te=>{p("team"),xt.selectThread(Te)},openTeamDm:Te=>{p("team"),xt.openDm(Te)},toggleSessionPinned:tc,toggleProjectPinned:nc,toggleSessionSavedForLater:Es,openSidebarFile:Xu,setSidebarFileStatus:(Te,ct)=>{ai(Te,ct)},archiveSession:wu,restoreSession:Iu,renameSession:ec,removeProject:qu,expandProject:Fa,toggleProjectExpanded:ls,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:Ss,commitPinnedDrop:xs,commitPinnedPreviewDrop:ks,startTaskDrag:ci,clearTaskDrag:di,previewTaskDrop:ui,commitTaskDrop:ys,commitTaskPreviewDrop:yr},topBar:{sidebarOpen:de,title:Kn,backAction:_e.backAction,breadcrumbs:_e.breadcrumbs,conversationId:te==="chat"?Z:null,workspaceName:Jr,workspaceId:Gr,busy:ce,workspaceState:vo,workspaceKind:Zr,selectedApp:At??De,selectedProject:Je,workspaceDiff:Nn,managedWorkspace:Cs,workspaceBusy:Sr,defaultTeamId:Ha.defaultTeamId,showDiffControls:te==="chat"&&ke==="development",diffPanelOpen:be,terminalOpen:xe,rightSidebarAvailable:im,rightSidebarOpen:te==="scheduled"?n:be,onToggleDiffPanel:lc,onToggleRightSidebar:te==="scheduled"?()=>a(Te=>!Te):te==="team"&&mr?pr:lc,onOpenSearch:()=>{rt(null),Xe(!0)},onToggleTerminal:()=>pe(Te=>!Te),onRunTerminalCommand:Te=>{m({id:Date.now(),scope:Vs,command:Te}),pe(!0)},onWorkspaceToolAction:uu,onOpenCommitDialog:As,onWorkspaceBranchChange:cu,onWorkspaceBranchCreate:Jl,connection:yt,onBootstrap:rn,onOpenSandboxWorkspace:Ru,onShowSidebar:()=>Fe(!0),onOpenTeamChat:dc,onDiscoverCommunities:Zu,collaborationView:te==="team"||te==="community"?te:null,platform:Fs,showWorkspaceControls:te!=="team"&&te!=="community"&&te!=="labs"&&te!=="scheduled"&&te!=="outputs"&&te!=="projects"&&(ke==="development"||ke==="work"&&!!(Je||gt?.localProjectId||gt?.cloudProjectId||gt?.workspaceKind==="local_project"))},mainPane:{experience:ke,onNewExperienceChange:qe,view:te,teamChat:{currentUserId:xt.currentUserId,members:xt.members,agents:xt.agents,profile:Nt?.profile??null,teamId:ea,teamName:qa?.displayName??null,detail:xt.detail,aiThread:xt.aiThread,agentConversation:xt.agentConversation,loading:xt.loading,busy:xt.busy,error:xt.error,connection:yt,providerSettings:Nt?.providers??null,provider:Tn,model:$n,codexPermissionMode:Pe,codexReasoningEffort:ge,openPondCommandAccessMode:mo,contextWindowStatus:Ia,showToast:bt,onProviderChange:Yl,onModelChange:I,onCodexPermissionModeChange:Yr,onCodexReasoningEffortChange:Qr,onOpenPondCommandAccessModeChange:Xr,onOpenProviderSettings:()=>{fe("providers"),p("settings"),sn({kind:"settings",section:"providers"})},onSendMessage:xt.sendMessage,onPublishProfileAgent:Ba,onOpenAiThread:async Te=>{await xt.openAiThread(Te),G("chat"),X(!0)},onOpenAgentConversation:async Te=>{await xt.openAgentConversation(Te),G("chat"),X(!0)},onCloseAiThread:()=>X(!1),onCloseAgentConversation:()=>{xt.closeAgentConversation(),X(!1)},onSendAgentTurn:xt.sendAgentTurn,onSendAiTurn:xt.sendAiTurn,onStopAiTurn:xt.stopAiTurn,onEditMessage:xt.editMessage,onDeleteMessage:xt.deleteMessage,onRetryMessage:xt.retryMessage,onDismissFailedMessage:xt.dismissFailedMessage,onLoadMoreMessages:xt.loadMoreMessages,onRetryLoad:xt.refresh},community:Kr,bootstrap:Nt,runtimeEvents:ri,chatMessages:ca,pendingUserMessage:Z?St[Z]??null:null,contextWindowStatus:Ia,goalRuntime:gr,subagentRuntime:ii,selectedSessionId:Z,composerDraftStore:i,mainComposerFocusRequestId:$,labCloseDetailRequestId:_e.closeDetailRequestId,labCloseDetailKind:_e.closeDetailKind,sideChatTrainingLaunchRequest:ic,onSideChatTrainingLaunchHandled:Te=>Eu(ct=>ct?.id===Te?null:ct),mentionApps:Bn,connectedAppMentions:tt,profileSkills:Gu,selectedMentionAppId:w,busy:ce,turnRunning:si,activeProvider:Tn,activeModel:$n,codexPermissionMode:Pe,codexReasoningEffort:ge,openPondCommandAccessMode:mo,pendingApproval:_n,activeWorkspaceAppId:Wr,activeWorkspaceId:Gr,activeWorkspaceKind:Zr,projectTarget:mt,actionCatalog:is,workspaceTarget:Bt,connection:yt,workspaceName:Jr,workspaceState:vo,workspaceDiff:Nn,workspaceBusy:Sr,diffBusy:Is,forceChatThread:!!Z,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:he,rightPanelTabRequest:P,rightChatPanels:ju,runtimeEventStore:sa,nativeSkillSidebar:$s,extensionSkillSidebar:Ds,workspaceDiffPanelViewState:L,sidebarFileOpenRequest:Za,sidebarFileBookmarks:vn,onSetSidebarFileStatus:(Te,ct)=>{ai(Te,ct)},browserConversationId:pn,terminalScope:Vs,terminalTabs:u,terminalCwd:om,pendingTerminalCommand:l,terminalOpen:xe,onToggleTerminal:()=>pe(Te=>!Te),onWorkspaceDiffPanelViewStateChange:na,training:Ut,trainingSessions:lt,trainingChatHandoff:ms,trainingDetailTasksetId:b,onTrainingDetailTasksetIdChange:y,onTrainingChatTaskSelect:ei,onTrainingChatHandoffDismiss:us,onOpenSession:En,onExperienceHandoff:Ju,cloudProjects:Nt?.cloudProjects??[],projects:Ku,projectsAccountBaseUrl:kn?.baseUrl??kn?.activeProfile?.baseUrl??null,projectsTeamName:qa?.displayName??null,projectTaskCounts:Wu,onNewCloudProject:oc,onNewProjectTask:Te=>fi(Te.id),onToggleProjectPinned:nc,onUploadLocalProject:_u,chatHistoryHasMore:Gt,chatHistoryLoading:_a,onDiffPanelResizeStart:oe,onToggleDiffPanelExpanded:()=>ae(Te=>!Te),onShowDiffPanel:Au,onShowBrowserPanel:rc,onShowFilesPanel:()=>Ko("files"),onShowGoalSidebarTab:Tu,onShowTrainingDraftPanel:()=>{G("training"),X(!0)},onShowRightChatPanel:Ou,onAddRightChat:()=>js(null),onOpenRightChatForSession:(Te,ct)=>{const Mt=ct??lt.find(da=>da.id===Te)??null;Mt&&js(Mt,{preserveView:!0})},onLabDetailOpenChange:_e.onDetailOpenChange,scheduledDetailOpen:n,onScheduledDetailOpenChange:a,onTerminalTabsChange:h,onCloseRightChatPanel:Mu,onCloseNativeSkillSidebar:Qu,onActivateRightChatPanel:$u,onRightChatModelChange:Nu,onRightChatPromptChange:Du,onRightChatScrollStateChange:Uu,onRightChatProviderChange:Lu,onSubmitRightChat:sc,onStopRightChat:Te=>Ts(Te),onCloseTerminal:()=>pe(!1),onLoadMoreChatHistory:ni,canSyncWorkspace:Rs,startMessage:ka,onPayload:rn,onError:nn,setView:p,onOpenProfileSettings:zu,onOpenProviderSettings:()=>{sn({kind:"settings",section:"providers"})},onOpenTrainingSettings:()=>{sn({kind:"settings",section:"training"})},onOpenDatasetStorageSettings:()=>{sn({kind:"settings",section:"dataset-storage"})},changeDraftProvider:Yl,changeProjectTarget:su,changeWorkspaceTarget:Cu,setDraftProvider:F,setDraftModel:I,onBeginNewChatWithModel:ds,changeCodexPermissionMode:Yr,changeCodexReasoningEffort:Qr,changeOpenPondCommandAccessMode:Xr,resolveApproval:cs,answerCreateImproveQuestion:hu,applyCreateImproveCandidate:gu,approveCreateImproveRun:vu,cancelCreateImproveRun:bu,openCreateImprovePullRequest:yu,reconcileCreateImprovePullRequest:Ql,rejectCreateImproveCandidate:Su,pauseCreateImproveRun:xu,resumeCreateImproveRun:ku,reviseCreateImproveRun:Xl,setMentionedAppId:_,showToast:bt,onSaveTaskDraft:Bs,sendPrompt:Ms,stopTurn:Te=>Ts(void 0,Te),syncWorkspaceLocally:fu,refreshWorkspaceDiff:_s},cloudSetup:{state:E,onClose:()=>O(null),onOpenBrowserUrl:Pu,onStart:()=>{ac()}},projectConfirm:{state:x,onResolve:C},lazyPanels:{activeSessions:Va,branchDialogName:Q,branchDialogOpen:H,commitDialogOpen:Ue,commitDraft:M,commitIncludeUnstaged:Le,commitMessage:Ve,commitNextStep:D,canPublishOpenPondProject:Ps,connection:yt,expandProject:Fa,newProjectBusy:st,newProjectDialogOpen:we,newProjectDirectory:Ha.defaultNewProjectDirectory,newProjectMode:je,newProjectName:Ze,newProjectPath:Ge,projectRows:ws,query:A,searchOpen:z,visibleWorkspaceDiff:Nn,visibleWorkspaceState:vo,workspaceBusy:Sr,appDispatch:s,beginNewChat:()=>ta(null),openDefaultsSettingsFromBranchDialog:du,setBranchDialogName:Sn,setBranchDialogOpen:An,setCommitDialogOpen:Ke,setCommitDraft:Lt,setCommitIncludeUnstaged:ut,setCommitMessage:ze,setCommitNextStep:Qt,setNewProjectDialogOpen:Oe,setNewProjectName:Ee,setNewProjectPath:Ne,setPrompt:ie,setQuery:$e,setSearchOpen:Xe,submitCommitDialog:mu,submitCreateWorkspaceBranch:pu,submitNewProjectDialog:lu},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})})}const Ri=new Map,Vc=new Map;function gf(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 H6(e){const t=e?.trim();if(!t)return null;const n=Ri.get(t);return n?.updatedAt?n.organizations:null}function q6(e,t){const n=e?.trim();if(n){Ri.set(n,{organizations:t,promise:null,updatedAt:Date.now()});for(const a of Vc.get(n)??[])a()}}function B6(e,t){const n=e?.trim();if(!n)return()=>{};const a=Vc.get(n)??new Set;return a.add(t),Vc.set(n,a),()=>{a.delete(t),a.size===0&&Vc.delete(n)}}function by(e){const t=e.accountKey?.trim();if(!t)return Promise.resolve([]);const n=Ri.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=>(q6(t,r),r)).catch(r=>{const i=Ri.get(t);throw i?.promise===a&&Ri.set(t,{organizations:i.organizations,promise:null,updatedAt:i.updatedAt}),r});return Ri.set(t,{organizations:n?.organizations??[],promise:a,updatedAt:n?.updatedAt??0}),a}const dJ="openpond.config.json";function uJ(e,t,n){return t<=0?-1:n==="Home"?0:n==="End"?t-1:n==="ArrowRight"?(e+1)%t:(e-1+t)%t}function PI(){return{activeTab:"files",openFilePaths:[],selectedPath:null}}function ip(e){return{activeTab:e.activeTab,openFilePaths:[...e.openFilePaths],selectedPath:e.selectedPath}}function mJ(e,t=null){const n=V6(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=F6(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 pJ(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function fJ(e){return{path:e,status:"unchanged",additions:0,deletions:0,patch:"",content:null}}function hJ(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 gJ(e){return/\.(?:md|markdown|mdx)$/i.test(e)||/(?:^|\/)readme$/i.test(e)}function vJ(e){return/\.(?:doc|docx|pdf)$/i.test(e)}function F6(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 V6(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 K6(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 AI(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"cloud-project"}function W6(e){const t=new TextEncoder().encode(e);let n="";for(const a of t)n+=String.fromCharCode(a);return btoa(n)}function eu(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||AI(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 G6(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 Z6(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 J6(...e){for(const t of e){const n=t?.trim();if(n)return n}return""}function Y6({draftProvider:e,hasSelectedCloudProject:t,selectedSessionHybridWorkspace:n}){return t&&!n?"openpond":e}const Q6=[{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 X6(...e){return J6(...e.map(t=>{const n=t?.trim();return n&&!n.includes("@")?n:null}))}function eV(e){if(e?.state!=="signed_in")return"";const t=e.accounts.find(n=>n.isActive)??null;return X6(e.profile?.name,e.label,t?.displayLabel,e.profile?.handle,t?.handle,e.activeProfile?.handle)}function tV({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?D6(l):!1,E=l?.cwd&&(!y||w)?tx(l.cwd):null,O=e?.providers??null,P=ya(s,e?.cloudProjects??[]),L=Y6({draftProvider:n,hasSelectedCloudProject:!!i,selectedSessionHybridWorkspace:w}),$=dr(L,t,O),j=ma(e?.preferences),x=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,q=!e||z?.state==="loading"||z?.state==="switching",N=!q&&z?.state==="signed_out",K=q?null:N?"Sign in":z?.label??z?.activeProfile?.handle??"Account",de=eV(z),te=de?`Welcome, ${de}`:"Welcome",Ie=l?.workspaceName??l?.appName??i?.name??s?.name??a?.name??null,Se=lo(x)?"cloud":"local",Z=s?.name??u?.name??(l?.workspaceKind==="local_project"?l.workspaceName:null)??"Local workspace",Pe=(Se==="cloud"?Ie:null)??i?.name??P?.name??s?.name??"Cloud workspace",ge=!!(i?.id||P?.id||l?.cloudProjectId||Se==="cloud");return{account:z,accountLabel:K,accountPending:q,accountSignedOut:N,activeModel:$,activeProvider:L,activeWorkspaceAppId:C,activeWorkspaceId:A,activeWorkspaceKind:x,activeWorkspaceLocation:Se,appDefaults:j,cloudLinked:ge,cloudTargetName:Pe,localTargetName:Z,selectedCodexHistoryPending:b,selectedSessionCloudWorkspace:y,selectedSessionLocalPathWorkspaceId:E,selectedSessionPendingCloudStart:_,selectedSessionProjectId:h,startMessage:te,workspaceName:Ie}}function nV({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=ya(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"})),q=l?`local:${l.id}`:s?`cloud:${s.id}`:"none",N=[...A,...z].find(K=>K.value===q)??null;return{value:q,label:N?.label??"Select Project",detail:N?.detail??"Choose a project for local or cloud work",busy:b||r,options:[...A,...z,...Q6,{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]),O=!!(i||l),P=!!(s?.id||y?.id||m?.cloudProjectId||co(m)),L=l?h[l.id]??null:null,$=V1(L,{branch:l?.linkedSandboxProject?.defaultBranch??null,path:l?.workspacePath??m?.cwd??null,linkedCloudSourceKnown:l?.linkedSandboxProject?.projectId&&_?!!l.linkedSandboxProject.lastUploadedCommit||!L?.headCommit:!0}),j=K1(l,s??y,L,{cloudLinkTrusted:_}),x=Y5(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?j:"upload required",disabled:e||t||!P,disabledReason:t?"Add an OpenPond account before using Hybrid.":"Upload/sync this Project to Cloud before using Hybrid."},q={value:"cloud",label:"Hosted",detail:"Run with hosted compute, with or without a Project.",stateNote:l||s?j:"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:x,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:q;let te=n==="cloud"?q:A;return u==="cloud"?te=q: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,q]}},[n,e,t,i,O,j,P,$,u,l,m,x,b]);return{projectTarget:E,workspaceTarget:C}}function jn(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function TI(e){return jn(e.name||e.gitRepo||e.id)}function bJ(e){return`@${TI(e)}`}function EI(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function aV(e,t){const n=EI(e);if(n.length===0)return!1;const a=new Set([jn(t.id),TI(t),t.gitRepo?jn(t.gitRepo):""].filter(Boolean));return n.some(r=>a.has(r))}function MI(e){return e.filter(t=>t.sandbox)}function oV(e,t){const n=EI(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 yJ(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 rV(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 iV({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(()=>j1(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(()=>rV(e?.apps??[]),[e?.apps]),w=g.useMemo(()=>MI(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]),O=g.useMemo(()=>U1(e?.localProjects??[]),[e?.localProjects]),P=g.useRef([]),L=g.useMemo(()=>sV(i,t,P.current),[t,i]),$=g.useMemo(()=>L.find(N=>N.id===a)??null,[L,a]),j=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=U5($,E,O);if(N)return l.get(N)??null;if(!$.appId)return null;const K=_.get($.appId);return K?l.get(K)??null:null},[_,l,E,O,$]),x=g.useMemo(()=>$?.cloudProjectId?m.get($.cloudProjectId)??null:null,[m,$]),C=h??j,A=b??x,z=g.useMemo(()=>ky(C,y),[y,C]),q=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:q,selectedProjectLinkedOpenPondApp:z,selectedSession:$,selectedSessionLinkedProject:j,sidebarSessions:L}}function sV(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?lV(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 lV(e,t){return{...e,metadata:cV(e.metadata,t.metadata),status:e.status==="active"||t.status==="active"?"active":e.status,updatedAt:dV(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 cV(e,t){const n={...e??{},...t??{}};return Object.keys(n).length>0?n:void 0}function dV(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 uV(e){return!!(e&&lo(e.workspaceKind)&&!co(e)&&e.provider!=="openpond")}function mV(e,t){const n=N1(e,t);return`${e.id}\0${n.provider}\0${n.model}`}function pV({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:O,setSessions:P,setTerminalOpen:L,toast:$}){const j=g.useRef(null);g.useEffect(()=>{if(!l)return;const x=h??(u?null:i.get(l)??null);if(!x)return;const C=vt("local",x);E(null),O(C),r(C)},[r,i,l,u,h,E,O]),g.useEffect(()=>{if(!$||$.persistent)return;const x=window.setTimeout(()=>{n({type:"clearToast",toastId:$.id})},$.durationMs??($.tone==="error"?7e3:3500));return()=>window.clearTimeout(x)},[n,$]),g.useEffect(()=>{function x(C){(C.metaKey||C.ctrlKey)&&C.key==="`"&&(C.preventDefault(),L(A=>!A))}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[L]),g.useEffect(()=>{b(!1)},[e,t,b]),g.useEffect(()=>{if(!u){j.current=null;return}if(!m||m.id!==u)return;const x=mV(m,s);if(j.current===x)return;j.current=x;const C=N1(m,s);w(C.provider),y(C.model)},[s,m,u,y,w]),g.useEffect(()=>{!a||!m||!uV(m)||J.patchSession(a,m.id,{provider:"openpond"}).then(x=>{P(C=>C.map(A=>A.id===x.id?x:A)),w("openpond"),y(C=>dr("openpond",C))}).catch(x=>{_(x instanceof Error?x.message:String(x))})},[a,m,y,w,_,P])}function fV({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 hV({activeProvider:e,contextCompaction:t,contextUsage:n,pinnedItems:a,pinnedPreviewKeys:r,pinnedProjects:i,projectRows:s,visibleProjectRows:l}){const m=g.useMemo(()=>P5(a,r),[a,r]),u=g.useMemo(()=>rI({provider:e,snapshot:n,preferences:t}),[e,t,n]),h=g.useMemo(()=>Array.from(new Set([...i,...l].filter(fg).map(y=>y.project.id))),[i,l]);return{commandProjectRows:g.useMemo(()=>s,[s]),contextWindowStatus:u,pinnedRows:m,sidebarWorkspaceAppIds:h}}function gV({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 jI={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 SJ(e){return`@${e.token}`}function vV(e){return`@${kV(e)}`}function bV(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=xi(a.flatMap(b=>b.capabilities.map(y=>y.id))),s=xi(a.flatMap(b=>b.capabilityLabels)),l=xi(a.flatMap(b=>b.connections.map(y=>y.id).filter(IV))),m=xi(a.map(b=>b.id)),u=xi(a.map(b=>b.setupSurface)),h=xV(n);return{provider:n,label:r.providerLabel,detail:s.length>0?s.slice(0,4).join(", "):r.description,token:h,tokens:SV(a),ref:{kind:"integration",provider:n,appIds:m,setupSurfaces:u,...l.length>0?{connectionIds:l}:{},...i.length>0?{capabilities:i}:{}}}})}function xJ(e,t){const n=jn(t);return e.filter(a=>n?a.tokens.some(r=>r.includes(n)):!0).slice(0,8)}function yV(e,t){const n=wV(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 kJ(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:vV(s),end:u+h.length,label:s.label,provider:s.provider,start:u,text:h})}return n}function SV(e){return xi(e.flatMap(t=>[...jI[t.providerFamily],t.providerFamily,t.id,t.label,t.shortLabel]).map(jn).filter(Boolean))}function xV(e){return jn(jI[e][0]??e)}function kV(e){return e.provider==="github"?"GitHub":e.provider==="x"?"X":e.provider==="mcp"?"MCP":e.label}function wV(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function xi(e){return Array.from(new Set(e))}function IV(e){return typeof e=="string"&&e.length>0}function _V({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 O=_.get(E.teamId)??[];O.push(E.id),_.set(E.teamId,O)}return _},[e?.cloudProjects]),b=!!(l||r||s||i)?[]:n,y=g.useMemo(()=>bV(t),[t]),w=g.useMemo(()=>k6(a,m),[a,m]);return{chatMentionApps:b,cloudProjectIdsByTeam:u,connectedAppMentions:y,pendingApproval:w}}function CV({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 RV=6e4;function Ig(e,t){if(!e)return t;const n=AV(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 $I(e,n)?e:n}function PV(e,t){const n=Ig(e,t),a=e?{...n,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order,updatedAt:e.updatedAt}:n;return e&&$I(e,a)?e:a}function nl(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=Ig(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function tu(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=PV(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function vf(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=EV(s,i,n,a);if(l)return l}return Ig(s,i)})}function Cy(e,t,n,a=Date.now()){const r=new Map(e.map(u=>[u.id,u])),i=new Map(vf(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||(OI(u,t)?u:null)}).filter(u=>!!u);return[...l,...m]}function OI(e,t){const n=Date.parse(e.updatedAt);if(!Number.isFinite(n))return!1;const a=TV(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&&(NI(s,i)||(e[i.id]=a))}}function AV(e,t){const n=Date.parse(e),a=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(a)&&n>a}function $I(e,t){return JSON.stringify(e)===JSON.stringify(t)}function TV(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 EV(e,t,n,a){const r=n[t.id];return r===void 0?null:a-r>RV||NI(e,t)?(delete n[t.id],null):{...t,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order}}function NI(e,t){return e.pinned===t.pinned&&e.savedForLater===t.savedForLater&&e.archived===t.archived&&e.order===t.order}const DI=800,MV=5e3,Py=5e4,jV=16,OV=3e4,Zn=new Map;function $V(e,t){return Zn.get(UI(e,t))?.payload??null}async function LI(e,t,n={}){const a=UI(e,t),r=Zn.get(a),i=n.limit??DI,s=n.tail??!0;if(r?.promise)return r.promise;if(!n.force&&s&&r?.payload&&Date.now()-r.fetchedAt<=OV)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:NV(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 UI(e,t){return`${e.serverUrl}
134
+ `)))}catch{}}async function kB(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 wB extends Error{constructor(t,n){super(t),this.status=n,this.name="ApiRequestError"}status}function Ob(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 $b=new WeakMap,Nb=new WeakMap,xc=new WeakMap;let IB=0;async function B(e,t,n){if(t==="/v1/preferences"&&typeof n?.body=="string"){const r=(xc.get(e)??Promise.resolve()).catch(()=>{}).then(()=>Db(e,t,n));xc.set(e,r);try{return await r}finally{xc.get(e)===r&&xc.delete(e)}}return Db(e,t,n)}async function Db(e,t,n){const a=++IB;if(t==="/v1/preferences"&&typeof n?.body=="string"){const m=$b.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 wB(u,i.status)}const s=await i.json(),l=s?.configuration?.rawRevision??(t==="/v1/preferences"?s?.rawRevision:void 0);return typeof l=="string"&&a>=(Nb.get(e)??0)&&($b.set(e,l),Nb.set(e,a)),s}function OZ(e){const t=new URL("/v1/terminal",e.serverUrl);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.toString()}function $Z(e){return["openpond-terminal",`openpond-token.${CB(e.token)}`]}function _B(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 CB(e){return _B(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function RB(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 PB={teamInvitations:e=>B(e,"/v1/team-invitations"),decideTeamInvitation:(e,t,n)=>B(e,`/v1/team-invitations/${t}`,{method:"POST",body:JSON.stringify({token:n})}),organizations:e=>B(e,"/v1/organizations"),createOrganization:(e,t)=>B(e,"/v1/organizations",{method:"POST",body:JSON.stringify(t)}),updateOrganization:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),organizationMembers:(e,t)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/members`),upsertOrganizationMember:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify(n)}),organizationMcpServer:(e,t)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`),generateOrganizationMcpServer:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server`,{method:"POST",body:JSON.stringify(n)}),setOrganizationMcpServerStatus:(e,t,n)=>B(e,`/v1/organizations/${encodeURIComponent(t)}/mcp-server/${n}`,{method:"POST"})},AB={sendTurn:(e,t,n)=>B(e,`/v1/sessions/${t}/turns`,{method:"POST",body:JSON.stringify(n)}),runSessionCommand:(e,t,n)=>B(e,`/v1/sessions/${encodeURIComponent(t)}/commands`,{method:"POST",body:JSON.stringify(n)}),recordPreflightTurnFailure:(e,t,n)=>B(e,`/v1/sessions/${t}/preflight-turns/failure`,{method:"POST",body:JSON.stringify(n)}),listCreateImproveRuns:(e,t={})=>B(e,`/v1/create-improve-runs?${TB(t).toString()}`),getCreateImproveRun:(e,t)=>B(e,`/v1/create-improve-runs/${encodeURIComponent(t)}`),getCreateImproveCandidateDiff:(e,t,n)=>B(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/candidates/${encodeURIComponent(n)}/diff`),applyCreateImproveAction:(e,t,n)=>B(e,`/v1/create-improve-runs/${encodeURIComponent(t)}/actions`,{method:"POST",body:JSON.stringify(n)}),interruptTurn:(e,t,n)=>B(e,`/v1/sessions/${t}/turns/interrupt`,{method:"POST",body:JSON.stringify({reason:n})}),compactSession:(e,t,n={reason:"manual"})=>B(e,`/v1/sessions/${t}/compact`,{method:"POST",body:JSON.stringify(n)}),workspaceTool:(e,t,n)=>B(e,`/v1/sessions/${t}/workspace-tools`,{method:"POST",body:JSON.stringify(n)}),ensureCloudWorkspaceReady:(e,t,n)=>B(e,`/v1/sessions/${encodeURIComponent(t)}/workspace/ensure-ready`,{method:"POST",body:JSON.stringify(n)})};function TB(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 EB={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)),B(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${a.toString()}`)},sandboxUploadFile:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/files`,{method:"POST",body:JSON.stringify(n)}),preserveSandboxSource:(e,t,n={})=>B(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 B(e,`/v1/sandboxes/${encodeURIComponent(t)}/files?${r.toString()}`);return{...i,contents:i.file.isBinary?"":RB(i.file.contentsBase64)}}},MB={sandboxGitStatus:(e,t)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/status`),sandboxGitDiff:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/git/diff`,{method:"POST",body:JSON.stringify(n)})},jB={connectedAppStatus:(e,t={})=>{const n=Ob(t);return n.set("status",t.status??"all"),B(e,`/v1/connected-apps/status${n.size>0?`?${n.toString()}`:""}`)},integrationConnections:(e,t={})=>{const n=Ob(t);return t.status&&n.set("status",t.status),B(e,`/v1/integrations/connections${n.size>0?`?${n.toString()}`:""}`)},sandboxIntegrationLeases:(e,t)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`),attachSandboxIntegrationConnection:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"POST",body:JSON.stringify(n)}),removeSandboxIntegrationLease:(e,t,n)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:n})})},OB={listSandboxProjects:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return B(e,`/v1/sandbox-projects?${n.toString()}`)},getSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return B(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`)},getSandboxProjectWorkspace:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return B(e,`/v1/sandbox-projects/${encodeURIComponent(t)}/workspace?${a.toString()}`)},upsertSandboxProject:(e,t)=>B(e,"/v1/sandbox-projects",{method:"POST",body:JSON.stringify(t)}),syncSandboxProject:(e,t,n)=>{const a=new URLSearchParams({teamId:n.teamId});return B(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 B(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 B(e,`/v1/sandbox-projects/${encodeURIComponent(t)}?${a.toString()}`,{method:"DELETE"})},listSandboxAgents:(e,t)=>{const n=new URLSearchParams({teamId:t.teamId});return B(e,`/v1/sandbox-agents?${n.toString()}`)},upsertSandboxAgent:(e,t)=>B(e,"/v1/sandbox-agents",{method:"POST",body:JSON.stringify(t)}),runSandboxAgent:(e,t,n)=>B(e,`/v1/sandbox-agents/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n)}),runProfileAction:(e,t)=>B(e,"/v1/profile/run",{method:"POST",body:JSON.stringify(t)})},$B={sandbox:(e,t)=>B(e,`/v1/sandboxes/${encodeURIComponent(t)}`)},NB={...jB,...OB,...$B,...MB,...EB},DB={communities:(e,t)=>{const n=new URLSearchParams;return t&&n.set("cursor",t),B(e,`/v1/communities${n.size?`?${n}`:""}`)},communityPreview:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/preview`),communityRules:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/rules/current`),joinCommunity:(e,t,n)=>B(e,`/v1/communities/${encodeURIComponent(t)}/join`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),acceptCommunityRules:(e,t,n)=>B(e,`/v1/communities/${encodeURIComponent(t)}/rules/accept`,{method:"POST",body:JSON.stringify({acceptedRulesVersionId:n})}),leaveCommunity:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/leave`,{method:"POST",body:"{}"}),communityChannels:(e,t)=>B(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)),B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages${r.size?`?${r}`:""}`)},sendCommunityMessage:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify(a)}),editCommunityMessage:(e,t,n,a,r)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({body:r})}),deleteCommunityMessage:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(a)}`,{method:"DELETE",body:"{}"}),markCommunityRead:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/read`,{method:"POST",body:JSON.stringify({sequence:a})}),setCommunityChannelMuted:(e,t,n,a)=>B(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)),B(e,`/v1/communities/${encodeURIComponent(t)}/members/search${a.size?`?${a}`:""}`)},updateCommunityNotifications:(e,t,n)=>B(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)),B(e,`/v1/communities/${encodeURIComponent(t)}/events${a.size?`?${a}`:""}`)},communityRealtimeSession:(e,t)=>B(e,`/v1/communities/${encodeURIComponent(t)}/realtime-session`),uploadCommunityAttachment:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/upload`,{method:"POST",body:JSON.stringify({attachment:a})}),communityAttachmentDownload:(e,t,n,a)=>B(e,`/v1/communities/${encodeURIComponent(t)}/channels/${encodeURIComponent(n)}/attachments/${encodeURIComponent(a)}/download`)},Yh="openpond-app-server-url",yl="openpond-app-token",LB=750;function f1(){return window.location.protocol!=="http:"&&window.location.protocol!=="https:"?null:window.location.origin&&window.location.origin!=="null"?window.location.origin:null}function Qp(e){const t=e.getItem(Yh)?.trim(),n=e.getItem(yl)?.trim();return t&&n?{serverUrl:t,token:n}:null}function rd(e){if(!e)return null;try{const t="__openpond_storage_probe__";return e.setItem(t,"1"),e.removeItem(t),e}catch{return null}}function vi(e,t){e.setItem(Yh,t.serverUrl),e.setItem(yl,t.token)}function Lb(e,t){const n=Qp(e);n?.serverUrl!==t.serverUrl||n.token!==t.token||(e.removeItem(Yh),e.removeItem(yl))}function UB(){const e=window.__OPENPOND_WEB_CONNECTION__,t=e?.serverUrl?.trim(),n=e?.token?.trim();return t&&n?{serverUrl:t,token:n}:null}function zB(){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()||f1();return!a||!n?null:{serverUrl:a,token:n}}function HB(){window.location.hash&&window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`)}function kc(e,t){t&&(e.some(n=>n.serverUrl===t.serverUrl&&n.token===t.token)||e.push(t))}function qB(){const e=[],t=rd(window.sessionStorage),n=rd(window.localStorage),a=f1(),r=t?.getItem(yl)??n?.getItem(yl);return kc(e,null),kc(e,a&&r?{serverUrl:a,token:r.trim()}:null),kc(e,t?Qp(t):null),kc(e,n?Qp(n):null),e}async function Km(e){const t=new AbortController,n=window.setTimeout(()=>t.abort(),LB);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 BB(){if(window.openpond)return window.openpond.getConnection();const e=rd(window.sessionStorage),t=rd(window.localStorage),n=zB();if(n&&await Km(n.serverUrl))return t&&vi(t,n),e&&vi(e,n),HB(),{...n,platform:navigator.platform};const a=UB();if(a&&await Km(a.serverUrl))return t&&vi(t,a),e&&vi(e,a),{...a,platform:navigator.platform};const r=qB();for(const i of r){if(await Km(i.serverUrl))return t&&vi(t,i),e&&vi(e,i),{...i,platform:navigator.platform};e&&Lb(e,i),t&&Lb(t,i)}throw new Error("No reachable OpenPond app server. Start `openpond ui` again and open the full printed URL.")}const J={...DB,bootstrap:e=>B(e,"/v1/bootstrap?refreshCodex=1"),localProjectActions:(e,t)=>B(e,`/v1/projects/${encodeURIComponent(t)}/actions`),extensionCatalog:e=>B(e,"/v1/extensions"),extensionPreview:(e,t)=>B(e,"/v1/extensions/preview",{method:"POST",body:JSON.stringify(t)}),extensionAdd:(e,t)=>B(e,"/v1/extensions",{method:"POST",body:JSON.stringify(t)}),extensionUpdate:(e,t,n={})=>B(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}/update`,{method:"POST",body:JSON.stringify(n)}),extensionUpdateAll:e=>B(e,"/v1/extensions/update-all",{method:"POST"}),extensionRemove:(e,t)=>B(e,`/v1/extensions/github/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}`,{method:"DELETE"}),skillSourceFile:(e,t,n,a)=>B(e,`/v1/skills/${t}/${encodeURIComponent(n)}/source?path=${encodeURIComponent(a)}`),teamChatMembers:(e,t)=>B(e,`/v1/team-chat/members?teamId=${encodeURIComponent(t)}`),teamChatAgents:(e,t)=>B(e,`/v1/team-chat/agents?teamId=${encodeURIComponent(t)}`),teamChatThreads:(e,t)=>B(e,`/v1/team-chat/threads?teamId=${encodeURIComponent(t)}`),teamChatRealtimeSession:(e,t)=>B(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)),B(e,`/v1/team-chat/events?${a.toString()}`)},teamChatGeneral:(e,t)=>B(e,"/v1/team-chat/threads/general",{method:"POST",body:JSON.stringify({teamId:t})}),teamChatDm:(e,t,n)=>B(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)),B(e,`/v1/team-chat/threads/${encodeURIComponent(n)}?${r.toString()}`)},uploadTeamChatAttachment:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/attachments/upload`,{method:"POST",body:JSON.stringify(n)}),teamChatAttachmentDownload:(e,t,n)=>B(e,`/v1/team-chat/attachments/${encodeURIComponent(n)}/download?teamId=${encodeURIComponent(t)}`),sendTeamChatMessage:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:JSON.stringify(n)}),createTeamChatAgentRun:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/agent-runs`,{method:"POST",body:JSON.stringify(n)}),teamChatAgentConversation:(e,t,n)=>B(e,`/v1/team-chat/agent-runs/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),editTeamChatMessage:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)}),deleteTeamChatMessage:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}`,{method:"DELETE",body:JSON.stringify({teamId:a})}),markTeamChatRead:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/read`,{method:"POST",body:JSON.stringify({teamId:n,sequence:a})}),setTeamChatThreadMuted:(e,t,n,a)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/mute`,{method:"POST",body:JSON.stringify({teamId:n,muted:a})}),createTeamChatAiThread:(e,t,n)=>B(e,`/v1/team-chat/threads/${encodeURIComponent(t)}/ai-threads`,{method:"POST",body:JSON.stringify(n)}),teamChatAiThread:(e,t,n)=>B(e,`/v1/team-chat/ai-threads/${encodeURIComponent(n)}?teamId=${encodeURIComponent(t)}`),sendTeamChatAiTurn:(e,t,n)=>B(e,`/v1/team-chat/ai-threads/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),executeTeamChatAiTurn:(e,t,n)=>B(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute`,{method:"POST",body:JSON.stringify({teamId:n})}),cancelTeamChatAiTurnExecution:(e,t,n)=>B(e,`/v1/team-chat/ai-turns/${encodeURIComponent(t)}/execute/cancel`,{method:"POST",body:JSON.stringify({teamId:n})}),usage:(e,t={})=>{const n=Ub(t),a=n.size?`?${n.toString()}`:"";return B(e,`/v1/usage${a}`)},usageRecords:(e,t={})=>{const n=Ub(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 B(e,`/v1/usage/records${a}`)},usageTurnCache:(e,t)=>B(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 B(e,`/v1/events/page${a}`)},workOutputs:e=>B(e,"/v1/work/outputs"),harnessHistory:e=>B(e,"/v1/harness"),refinerHistory:e=>B(e,"/v1/refiner"),updateRefinerProfile:(e,t)=>B(e,"/v1/refiner/update",{method:"POST",body:JSON.stringify(t)}),activateRefinerRelease:(e,t)=>B(e,"/v1/refiner/activate",{method:"POST",body:JSON.stringify(t)}),rollbackRefinerRelease:(e,t)=>B(e,"/v1/refiner/rollback",{method:"POST",body:JSON.stringify(t)}),updateHarnessBackgroundReview:(e,t)=>B(e,"/v1/harness/background-review",{method:"POST",body:JSON.stringify(t)}),reviewHarnessEvaluation:(e,t)=>B(e,"/v1/harness/evaluation-review",{method:"POST",body:JSON.stringify(t)}),updateHarnessEvaluationReviewSchedule:(e,t)=>B(e,"/v1/harness/evaluation-review/settings",{method:"POST",body:JSON.stringify(t)}),harnessReleaseDiff:(e,t)=>B(e,"/v1/harness/diff",{method:"POST",body:JSON.stringify(t)}),rollbackHarness:(e,t)=>B(e,"/v1/harness/rollback",{method:"POST",body:JSON.stringify(t)}),reviewHarnessProposal:(e,t)=>B(e,"/v1/harness/review",{method:"POST",body:JSON.stringify(t)}),runSubagentLifecycleAction:(e,t,n)=>B(e,`/v1/subagents/${encodeURIComponent(t)}/lifecycle`,{method:"POST",body:JSON.stringify(n)}),trainingState:(e,t)=>B(e,`/v1/training?profileId=${encodeURIComponent(t)}`),trainingActivity:(e,t)=>B(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),B(e,`/v1/training/catalog${a.size?`?${a.toString()}`:""}`)},datasetCatalog:(e,t)=>B(e,`/v1/training/datasets?profileId=${encodeURIComponent(t)}`),trainingRunDetail:(e,t,n={})=>B(e,`/v1/training/jobs/${encodeURIComponent(t)}/detail?evaluation=${n.includeEvaluation===!1?"false":"true"}`),candidateReview:(e,t,n=!1,a="models")=>B(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision?refresh=${n}`),recordCandidateReview:(e,t,n,a="models")=>B(e,`/v1/training/${a}/${encodeURIComponent(t)}/candidate-decision`,{method:"POST",body:JSON.stringify(n)}),candidateReviewHistory:(e,t,n,a="models")=>B(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),B(e,`/v1/training/jobs/${encodeURIComponent(t)}/evaluations/${encodeURIComponent(n.id)}/tasks?${r}`)},trainingRequest:(e,t,n,a="POST")=>B(e,`/v1/training${t}`,{method:a,body:a==="GET"||a==="DELETE"?void 0:JSON.stringify(n)}),datasetStorageState:e=>B(e,"/v1/settings/dataset-storage"),updateDatasetStorage:(e,t)=>B(e,"/v1/settings/dataset-storage",{method:"PATCH",body:JSON.stringify({datasetStorePath:t})}),hostedSavedWork:e=>B(e,"/v1/saved-work"),createHostedSavedWork:(e,t)=>B(e,"/v1/saved-work",{method:"POST",body:JSON.stringify(t)}),updateHostedSavedWork:(e,t,n)=>B(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteHostedSavedWork:(e,t)=>B(e,`/v1/saved-work/schedules/${encodeURIComponent(t)}`,{method:"DELETE"}),runHostedSavedWork:(e,t,n)=>B(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 B(e,`/v1/chat-workflows${n}`)},createChatWorkflow:(e,t)=>B(e,"/v1/chat-workflows",{method:"POST",body:JSON.stringify(t)}),updateChatWorkflow:(e,t,n)=>B(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),deleteChatWorkflow:(e,t)=>B(e,`/v1/chat-workflows/${encodeURIComponent(t)}`,{method:"DELETE"}),runChatWorkflow:(e,t)=>B(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 B(e,`/v1/local-agent-schedules${a}`)},syncLocalAgentSchedules:e=>B(e,"/v1/local-agent-schedules/sync",{method:"POST",body:JSON.stringify({})}),patchLocalAgentSchedule:(e,t,n)=>B(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),runLocalAgentSchedule:(e,t,n={})=>B(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 B(e,`/v1/local-agent-schedules/${encodeURIComponent(t)}/runs${r}`)},refreshOpenPondAccounts:e=>B(e,"/v1/openpond/accounts/refresh",{method:"POST",body:JSON.stringify({})}),refreshOpenPondAccount:e=>B(e,"/v1/openpond/account?refresh=1"),loadMoreOpenPondApps:(e,t)=>B(e,`/v1/openpond/apps/more?offset=${encodeURIComponent(String(t.offset))}&limit=${encodeURIComponent(String(t.limit))}`),switchOpenPondAccount:(e,t)=>B(e,"/v1/openpond/accounts/switch",{method:"POST",body:JSON.stringify(t)}),removeOpenPondAccount:(e,t)=>B(e,"/v1/openpond/accounts",{method:"DELETE",body:JSON.stringify(t)}),signOutOpenPondAccount:e=>B(e,"/v1/openpond/accounts/logout",{method:"POST",body:JSON.stringify({})}),saveOpenPondAccount:(e,t)=>B(e,"/v1/openpond/accounts/login",{method:"POST",body:JSON.stringify(t)}),updateOpenPondAccountConfig:(e,t)=>B(e,"/v1/openpond/accounts/config",{method:"PATCH",body:JSON.stringify(t)}),savePreferences:(e,t)=>B(e,"/v1/preferences",{method:"PATCH",body:JSON.stringify(t)}),saveProviderSettings:(e,t)=>B(e,"/v1/providers",{method:"PATCH",body:JSON.stringify(t)}),providerSettings:e=>B(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 B(e,`/v1/providers/${encodeURIComponent(t)}/models${r}`)},refreshProviderModels:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/models`,{method:"POST",body:JSON.stringify(n)}),saveProviderCredential:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"PUT",body:JSON.stringify(n)}),deleteProviderCredential:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/credential`,{method:"DELETE",body:JSON.stringify(n)}),startOpenAiSubscriptionAuth:(e,t)=>B(e,"/v1/providers/openai/subscription-auth",{method:"POST",body:JSON.stringify(t)}),validateProviderCredential:(e,t,n)=>B(e,`/v1/providers/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(n)}),savePersonalization:(e,t)=>B(e,"/v1/personalization",{method:"PATCH",body:JSON.stringify(t)}),recordClientDiagnostic:(e,t)=>B(e,"/v1/diagnostics/client",{method:"POST",body:JSON.stringify(t)}),profileCurrent:e=>B(e,"/v1/profile"),profileCatalog:e=>B(e,"/v1/profile/catalog"),profileSelect:(e,t)=>B(e,"/v1/profile/select",{method:"POST",body:JSON.stringify({ref:t})}),profileRemove:(e,t)=>B(e,"/v1/profile/remove",{method:"POST",body:JSON.stringify({ref:t})}),profilePublicationPreview:(e,t)=>B(e,"/v1/profile/publication/preview",{method:"POST",body:JSON.stringify(t)}),profilePublicationPublish:(e,t)=>B(e,"/v1/profile/publication/publish",{method:"POST",body:JSON.stringify(t)}),profileInstall:(e,t)=>B(e,"/v1/profile/install",{method:"POST",body:JSON.stringify(t)}),profileUpdate:(e,t)=>B(e,"/v1/profile/update",{method:"POST",body:JSON.stringify({ref:t})}),profileInit:(e,t)=>B(e,"/v1/profile/init",{method:"POST",body:JSON.stringify(t)}),profileLoad:(e,t)=>B(e,"/v1/profile/load",{method:"POST",body:JSON.stringify(t)}),profileCheck:(e,t)=>B(e,"/v1/profile/check",{method:"POST",body:JSON.stringify(t)}),profileAgentRename:(e,t,n)=>B(e,`/v1/profile/agents/${encodeURIComponent(t)}/name`,{method:"PATCH",body:JSON.stringify(n)}),profileCommit:(e,t)=>B(e,"/v1/profile/commit",{method:"POST",body:JSON.stringify(t)}),profilePush:(e,t)=>B(e,"/v1/profile/push",{method:"POST",body:JSON.stringify(t)}),workspaceLspSettingsStatus:e=>B(e,"/v1/lsp/settings-status"),workspaceLspRuntimeStatus:e=>B(e,"/v1/lsp/status"),restartWorkspaceLsp:e=>B(e,"/v1/lsp/restart",{method:"POST"}),remoteAccess:e=>B(e,"/v1/remote-access"),enableRemoteAccess:e=>B(e,"/v1/remote-access/enable",{method:"POST"}),disableRemoteAccess:e=>B(e,"/v1/remote-access/disable",{method:"POST"}),voiceTranscriptionStatus:(e,t={})=>B(e,"/v1/audio/transcriptions/status",{signal:t.signal}),transcribeVoice:(e,t,n={})=>B(e,"/v1/audio/transcriptions",{method:"POST",body:JSON.stringify(t),signal:n.signal}),createSession:(e,t)=>B(e,"/v1/sessions",{method:"POST",body:JSON.stringify(t)}),patchSession:(e,t,n)=>B(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 B(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"),B(e,`/v1/codex-history/${encodeURIComponent(t)}?${a.toString()}`)},sendCodexHistoryTurn:(e,t,n)=>B(e,`/v1/codex-history/${encodeURIComponent(t)}/turns`,{method:"POST",body:JSON.stringify(n)}),interruptCodexHistoryTurn:(e,t)=>B(e,`/v1/codex-history/${encodeURIComponent(t)}/turns/interrupt`,{method:"POST"}),patchSidebarAppPreference:(e,t,n)=>B(e,`/v1/sidebar/apps/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),reorderSidebarApps:(e,t)=>B(e,"/v1/sidebar/apps/reorder",{method:"POST",body:JSON.stringify(t)}),sidebarFiles:e=>B(e,"/v1/sidebar/files"),patchSidebarFile:(e,t)=>B(e,"/v1/sidebar/files",{method:"PATCH",body:JSON.stringify(t)}),workspaceStatus:(e,t,n=!1,a={})=>B(e,`/v1/workspaces/${encodeURIComponent(t)}${n?"?ensure=1":""}`,{signal:a.signal}),createWorkspaceBranch:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/branches`,{method:"POST",body:JSON.stringify(n)}),checkoutWorkspaceBranch:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/branch`,{method:"PATCH",body:JSON.stringify(n)}),workspaceDiff:(e,t,n={})=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/diff`,{signal:n.signal}),workspaceFile:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`),saveWorkspaceFile:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/file`,{method:"PATCH",body:JSON.stringify(n)}),signWorkspaceImageUrl:(e,t)=>B(e,"/v1/assets/workspace-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalImageUrl:(e,t)=>B(e,"/v1/assets/local-image-url",{method:"POST",body:JSON.stringify(t)}),signLocalVideoUrl:(e,t)=>B(e,"/v1/assets/local-video-url",{method:"POST",body:JSON.stringify(t)}),signChatAttachmentImageUrl:(e,t)=>B(e,"/v1/assets/chat-attachment-image-url",{method:"POST",body:JSON.stringify(t)}),chatAttachmentFile:(e,t)=>B(e,"/v1/assets/chat-attachment-file",{method:"POST",body:JSON.stringify(t)}),workspaceLspTouch:(e,t,n,a={})=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/touch`,{method:"POST",body:JSON.stringify(n),signal:a.signal}),workspaceLspAction:(e,t,n)=>B(e,`/v1/workspaces/${encodeURIComponent(t)}/lsp/action`,{method:"POST",body:JSON.stringify(n)}),workspaceTemplateConfig:(e,t)=>B(e,`/v1/openpond/apps/${encodeURIComponent(t)}/template-config`),...PB,...NB,createLocalProject:(e,t)=>B(e,"/v1/projects",{method:"POST",body:JSON.stringify(t)}),updateLocalProjectAgentSetup:(e,t,n)=>B(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),uploadLocalProjectCloudSource:(e,t,n)=>B(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 B(e,`/v1/projects/${encodeURIComponent(t)}/cloud-source/preview${r}`)},deleteLocalProject:(e,t)=>B(e,`/v1/projects/${encodeURIComponent(t)}`,{method:"DELETE"}),gitAvailability:e=>B(e,"/v1/system/git"),installMacOSCommandLineTools:e=>B(e,"/v1/system/git/install-command-line-tools",{method:"POST",body:JSON.stringify({})}),...AB,resolveApproval:(e,t,n)=>B(e,`/v1/approvals/${t}`,{method:"POST",body:JSON.stringify(n)})};function Ub(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 FB=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),VB=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),zb=e=>{const t=VB(e);return t.charAt(0).toUpperCase()+t.slice(1)},h1=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),KB=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var WB={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 GB=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,...WB,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:h1("lucide",r),...!i&&!KB(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(GB,{ref:i,iconNode:t,className:h1(`lucide-${FB(zb(e))}`,`lucide-${e}`,a),...r}));return n.displayName=zb(e),n};const ZB=[["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"}]],JB=dt("activity",ZB);const YB=[["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"}]],QB=dt("archive-restore",YB);const XB=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],eF=dt("arrow-left",XB);const tF=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],g1=dt("bookmark",tF);const nF=[["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"}]],v1=dt("bookmark-x",nF);const aF=[["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"}]],Hb=dt("book-open-text",aF);const oF=[["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"}]],Wm=dt("boxes",oF);const rF=[["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"}]],iF=dt("calendar-clock",rF);const sF=[["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"}]],b1=dt("chart-column-stacked",sF);const lF=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wo=dt("check",lF);const cF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Xp=dt("circle-check",cF);const dF=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],zo=dt("chevron-down",dF);const uF=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Nr=dt("chevron-right",uF);const mF=[["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",mF);const fF=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Zd=dt("cloud",fF);const hF=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],gF=dt("credit-card",hF);const vF=[["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"}]],bF=dt("download",vF);const yF=[["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"}]],Gm=dt("external-link",yF);const SF=[["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"}]],xF=dt("file-output",SF);const kF=[["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"}]],Qh=dt("file-text",kF);const wF=[["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"}]],IF=dt("folder",wF);const _F=[["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"}]],y1=dt("folder-git-2",_F);const CF=[["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"}]],RF=dt("git-branch",CF);const PF=[["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"}]],AF=dt("github",PF);const TF=[["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"}]],S1=dt("earth",TF);const EF=[["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"}]],MF=dt("circle-question-mark",EF);const jF=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],OF=dt("list-filter",jF);const $F=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],NF=dt("loader-circle",$F);const DF=[["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"}]],LF=dt("maximize-2",DF);const UF=[["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"}]],Jd=dt("message-square",UF);const zF=[["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"}]],Xh=dt("ellipsis",zF);const HF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],x1=dt("panel-left",HF);const qF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],ef=dt("panel-right",qF);const BF=[["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"}]],eg=dt("pin",BF);const FF=[["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"}]],tg=dt("pin-off",FF);const VF=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],KF=dt("plus",VF);const WF=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],GF=dt("power",WF);const ZF=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],JF=dt("search",ZF);const YF=[["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"}]],ng=dt("settings",YF);const QF=[["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"}]],k1=dt("shapes",QF);const XF=[["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"}]],e5=dt("shield",XF);const t5=[["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"}]],ag=dt("square-pen",t5);const n5=[["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"}]],w1=dt("square-terminal",n5);const a5=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],qb=dt("user-round",a5);const o5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rs=dt("x",o5);function r5({platform:e}){return!Yd()||og(e)?null:S.jsxs("div",{className:"window-controls","aria-label":"Window controls",children:[S.jsx("button",{type:"button",className:"window-control minimize",title:"Minimize",onClick:()=>{Zm("minimize")},children:S.jsx(zo,{size:14})}),S.jsx("button",{type:"button",className:"window-control maximize",title:"Maximize",onClick:()=>{Zm("toggleMaximize")},children:S.jsx(LF,{size:12})}),S.jsx("button",{type:"button",className:"window-control close",title:"Close",onClick:()=>{Zm("close")},children:S.jsx(rs,{size:13})})]})}function og(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")}function Yd(){if(typeof window>"u")return!1;const e=window.openpond;return!!(e?.minimizeWindow||e?.toggleMaximizeWindow||e?.closeWindow)}async function Zm(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 i5({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(""),O=g.useRef(null),[P,L]=g.useState();g.useLayoutEffect(()=>{if(!y||!h)return;function C(){const A=O.current?.getBoundingClientRect();if(!A)return;const z=window.innerHeight-A.bottom-12,q=A.top-12,N=z<180&&q>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?q-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],j=_.trim().toLowerCase(),x=j?t.filter(C=>[C.label,C.shortLabel,C.description].some(A=>A?.toLowerCase().includes(j))):t;return g.useEffect(()=>{if(!y){E("");return}function C(z){O.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]),S.jsxs("div",{className:`dropdown-select ${r??""} ${a?"compact":""} ${s==="top"?"open-up":""}`,"data-tooltip":m,ref:O,children:[S.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,S.jsx("span",{children:$?.shortLabel??$?.label??e}),S.jsx(zo,{size:14})]}),y&&S.jsxs("div",{className:"dropdown-menu",role:"menu",style:h?P:void 0,children:[u?S.jsxs("label",{className:"dropdown-search",onClick:C=>C.stopPropagation(),children:[S.jsxs("span",{className:"sr-only",children:["Search ",l]}),S.jsx("input",{autoFocus:!0,placeholder:`Search ${l.toLowerCase()}`,value:_,onChange:C=>E(C.target.value)})]}):null,x.map(C=>S.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:[S.jsxs("span",{children:[C.icon==="plus"?S.jsx(KF,{size:13}):null,S.jsx("span",{children:C.label})]}),C.description&&S.jsx("small",{children:C.description})]},C.value)),x.length?null:S.jsx("div",{className:"dropdown-empty",children:"No matches"})]})]})}const s5=[{destination:"walkthroughs",icon:Hb,label:"Walkthroughs"},{destination:"external",icon:Hb,label:"Docs",url:"https://openpond.ai/docs"},{destination:"external",icon:Qh,label:"Blog",url:"https://openpond.ai/blog"},{destination:"external",icon:gF,label:"Pricing",url:"https://openpond.ai/pricing"},{destination:"external",icon:S1,label:"Web app",url:"https://openpond.ai/sandboxes"},{destination:"external",icon:AF,label:"GitHub",url:"https://github.com/openpond/openpond"},{destination:"external",icon:Jd,label:"Submit issue",url:"https://github.com/openpond/openpond/issues/new/choose"}];function l5({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]),S.jsxs("div",{className:"sidebar-help-menu",ref:r,children:[S.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:S.jsx(MF,{size:17})}),n?S.jsx("div",{className:"sidebar-help-popover",role:"menu","aria-label":"Help",children:s5.map(i=>{const s=i.icon,l=S.jsxs(S.Fragment,{children:[S.jsx(s,{size:15}),S.jsx("span",{children:i.label})]});return i.destination==="walkthroughs"?S.jsx("button",{"aria-current":t?"page":void 0,className:"sidebar-help-item",onClick:()=>{a(!1),e()},role:"menuitem",type:"button",children:l},i.label):S.jsx("a",{className:"sidebar-help-item",href:i.url,onClick:m=>{m.preventDefault(),a(!1),c5(i.url)},rel:"noreferrer",role:"menuitem",target:"_blank",children:l},i.label)})}):null]})}async function c5(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-help",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const NZ=[{value:"chat",label:"Chat"},{value:"work",label:"Work"}],Jm=[{value:"chat",label:"Work",description:"Chat and complete tasks"},{value:"models",label:"Models",description:"Evaluate, train, and serve models"}];function I1(e){return e==="chat"?"New chat":"New task"}const tf=["get-started","models","tasks","tasksets","labeling","rewards","evaluations","runs","versions","serving"],d5={"get-started":"Get started",models:"Models",tasks:"Tasks",tasksets:"Tasksets",labeling:"Labeling",rewards:"Rewards",evaluations:"Runs",runs:"Runs",versions:"Versions",serving:"Serving"},u5={tasks:["drafts"],tasksets:["drafts","formats","batches"],rewards:["scorers","combined"],evaluations:["results","review","comparisons"],runs:["series","new"]},m5={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 rg(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]&&!tf.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(!tf.includes(i)||r==="models"||a&&i==="get-started")return null;let s=i==="evaluations"?"results":"default";if(u5[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&&!m5[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 Qd(e){const t=["/models"];if(e.modelId&&t.push(encodeURIComponent(e.modelId)),e.page==="evaluations"&&e.collection==="review")return Qd(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 p5(e,t){return ro(e.page,t,{collection:e.collection==="new"||e.collection==="drafts"?"default":e.collection})}function DZ(e,t,n=null){return{...e,resourceId:t,detailTab:n,after:null}}const id=new Set,nf=new Set,f5=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"]),af={apps:"/apps",outputs:"/outputs",projects:"/projects",scheduled:"/workflows","get-started":"/get-started"};let of=!1,rf="",Uc=null,_1=null,Sl="",Aa=0,Ks=null,il=!1,Ym=null,zc=!1;function ig(e){const t=rg(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&&f5.has(n[1])){const r=sg(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(af).find(r=>af[r]===e.pathname);return a?{kind:"view",view:a}:null}function C1(e){if(e.kind==="models")return Qd(e.route);if(e.kind==="models_unavailable")return`${e.pathname}${e.search}`;if(e.kind==="settings"){const t=sg(e.returnTo??null);return`/settings/${e.section}${t?`?${new URLSearchParams({returnTo:t})}`:""}`}return e.kind==="chat"?e.sessionId?`/chat/${encodeURIComponent(e.sessionId)}`:"/chat/new":af[e.view]}function h5(e){const t=e?.kind==="settings"?sg(e.returnTo??null):null;if(t){const n=new URL(t,"https://local.openpond.invalid"),a=rg(n);if(a)return{kind:"models",route:a}}return{kind:"chat",sessionId:null}}function sg(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=rg(t);return n?Qd(n):null}function Fl(){return`${window.location.pathname}${window.location.search}`}function lg(){if(typeof window>"u")return;const e=of?Sl:Fl();e!==rf&&(rf=e,Uc=ig(new URL(e,window.location.origin)),_1=Uc?.kind==="models"?Uc.route:null)}function R1(){rf="",lg();for(const e of nf)e()}async function cg(e){if(zc)return!1;zc=!0;try{for(const t of[...id].reverse())if(!await t(e))return!1;return!0}finally{zc=!1}}function dg(e){return{...window.history.state,openpondNavigationIndex:e}}async function g5(){const e=Fl(),t=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:Aa-1;if(Ks&&t===Aa){const a=Ks;Ks=null,a();return}if(Ym===t||id.size===0){Ym=null,Sl=e,Aa=t,window.history.replaceState(dg(Aa),"",e),R1();return}if(t===Aa)return;if(il||zc){Ks??=()=>{},window.history.go(Aa-t);return}il=!0;const n=t-Aa;try{await new Promise(a=>{Ks=a,window.history.go(-n)}),await cg(e)&&(Ym=t,window.history.go(n))}finally{il=!1}}function ug(){if(of||typeof window>"u")return;const e=ig(window.location);Sl=e?C1(e):Fl(),Aa=typeof window.history.state?.openpondNavigationIndex=="number"?window.history.state.openpondNavigationIndex:0,window.history.replaceState(dg(Aa),"",Sl),window.addEventListener("popstate",g5),of=!0}function P1(e){return nf.add(e),ug(),()=>{nf.delete(e)}}function LZ(e){return id.add(e),ug(),()=>{id.delete(e)}}async function UZ(e){!il&&await cg(Fl())&&e()}function v5(){return g.useSyncExternalStore(P1,()=>(lg(),_1),()=>null)}function b5(){return g.useSyncExternalStore(P1,()=>(lg(),Uc),()=>null)}async function sn(e,t="push"){if(typeof window>"u"||(ug(),il))return!1;if(e.kind==="settings"&&!e.returnTo){const a=ig(window.location),r=a?.kind==="models"?Qd(a.route):a?.kind==="settings"?a.returnTo:void 0;r&&(e={...e,returnTo:r})}const n=C1(e);return Fl()===n?!0:await cg(n)?(t==="push"&&Aa++,window.history[t==="replace"?"replaceState":"pushState"](dg(Aa),"",n),Sl=n,R1(),!0):!1}function Oi(e,t="push"){return sn({kind:"models",route:e},t)}function y5({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=v5(),y=b?.modelId??null,w=b?.page??"models";function _(){r(null),i(null),s(null),a(null)}async function E($){await Oi(ro($,y))&&(_(),l("labs"))}async function O($){await Oi(p5(b??ro(),$||null))&&(_(),l("labs"))}async function P($){await sn({kind:"view",view:$})&&(_(),l($))}const L=y?h[y]??null:null;return S.jsxs("nav",{className:"sidebar-nav","aria-label":"Primary",children:[t==="models"?null:S.jsxs("button",{className:"nav-command nav-command-new-task",type:"button",onClick:()=>{sn({kind:"chat",sessionId:null}),n(null)},children:[S.jsx(ag,{size:18}),S.jsx("span",{children:I1(e)})]}),t==="models"?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"sidebar-model-project-picker",children:[S.jsx("span",{className:"sidebar-nav-group-label",children:"Model"}),S.jsx(i5,{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:$=>{O($)}})]}),tf.filter($=>$!=="tasksets"&&$!=="evaluations").map($=>{const j={"get-started":Wm,models:JB,tasks:Wm,tasksets:Wm,labeling:Xp,rewards:e5,evaluations:Xp,runs:b1,versions:RF,serving:Zd}[$];return S.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:[S.jsx(j,{size:16}),S.jsx("span",{children:d5[$]}),$==="runs"&&L?S.jsx("span",{className:"sidebar-running-dot","aria-label":L.label}):null]},$)})]}):null,t==="chat"?S.jsxs(S.Fragment,{children:[S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="scheduled"?"active":""}`,"aria-label":"Workflows",type:"button",onClick:()=>{P("scheduled")},children:[S.jsx(iF,{size:18}),S.jsx("span",{children:"Workflows"})]}),S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="outputs"?"active":""}`,"aria-label":"Outputs",type:"button",onClick:()=>{P("outputs")},children:[S.jsx(xF,{size:18}),S.jsx("span",{children:"Outputs"})]}),S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="apps"?"active":""}`,"aria-label":"Apps",type:"button",onClick:()=>{P("apps")},children:[S.jsx(k1,{size:18}),S.jsx("span",{children:"Apps"})]}),S.jsxs("button",{className:`nav-command nav-command-prominent ${m==="projects"?"active":""}`,"aria-label":"Projects",type:"button",onClick:()=>{P("projects")},children:[S.jsx(y1,{size:18}),S.jsx("span",{children:"Projects"})]})]}):null]})}function S5({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"),sn({kind:"view",view:"get-started"})}return S.jsx("nav",{className:"sidebar-utility-nav","aria-label":"Resources",children:S.jsx(l5,{onOpenWalkthroughs:s,walkthroughsActive:i==="get-started"})})}const A1=pm({chatMode:v(["chat","work"]).optional(),notificationMode:v(["all","direct_mentions","none"]).optional(),learningNoticeDismissed:R().optional(),sidebarVisibility:pm({showCodexChats:R(),onlyRunningTasks:R()}).optional(),scheduledWorkView:v(["calendar","list"]).optional(),editorControlsVisible:R().optional(),voiceNoticeAcknowledged:R().optional(),lessonProgress:se(o().min(1).max(200),pm({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()}),sf={"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"},lf=new Set;let sl=null,No=null,Ea={},xl={},Qm=!1,Hc=0,$i=null,Bb=0;const x5="openpond-client-choices-changed";function mg(){lf.forEach(e=>e()),typeof window<"u"&&window.dispatchEvent(new Event(x5))}function k5(){return $i}function w5(e){return lf.add(e),()=>{lf.delete(e)}}function Vl(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>w5(()=>t.current()),[])}async function Fb(e){const t=++Bb,n=await B(e,"/v1/configuration");if(n.clientState?.revision===null){const r=I5();if(Object.keys(r.patch).length){n.clientState=await B(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!==Bb)return;const a=sl?.serverUrl!==e.serverUrl||sl?.token!==e.token||No?.owner!==n.clientState?.owner;a&&(Hc++,Ea={},xl={},$i=null),sl=e,(a||(n.clientState?.revision??0)>=(No?.revision??0))&&(No=n.clientState),mg()}async function pg(){if(Qm||!sl||!No||!Object.keys(Ea).length)return;Qm=!0;const e=Ea,t=sl,n=No.owner,a=Hc;Ea={},xl=e;try{const r=await B(t,"/v1/configuration",{method:"POST",body:JSON.stringify({action:"client-state",owner:n,patch:e})});a===Hc&&(No=r,$i=null)}catch(r){a===Hc&&(Ea={...e,...Ea},$i=`Preference changes have not been saved. ${r instanceof Error?r.message:String(r)}`)}finally{xl={},Qm=!1,mg(),!$i&&Object.keys(Ea).length&&pg()}}function zZ(){$i=null,pg()}const Kl={getItem(e){const t=sf[e];if(!t)return null;const n={...No?.value,...xl,...Ea}[t];return n===void 0?null:typeof n=="string"?n:JSON.stringify(n)},setItem(e,t){if(!No)return;const n=sf[e];if(!n)throw new Error("Unregistered client preference.");let a;try{a=JSON.parse(t)}catch{a=t}const r=A1.parse({[n]:a});JSON.stringify({...No.value,...xl,...Ea}[n])!==JSON.stringify(r[n])&&(Ea={...Ea,...r},mg(),pg())}};function I5(){const e={},t=[];if(typeof window>"u")return{patch:e,keys:t};for(const[n,a]of Object.entries(sf))try{const r=window.localStorage.getItem(n);if(r===null)continue;let i;try{i=JSON.parse(r)}catch{i=r}const s=A1.safeParse({[a]:i});s.success&&(Object.assign(e,s.data),t.push(n))}catch{}return{patch:e,keys:t}}const qc=5,Cn=15,cf=10,Tt={defaultChatProvider:jr,subagents:NE(),codexPermissionMode:nh,codexReasoningEffort:ah,openPondCommandAccessMode:Cd,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:""}}}},HZ={activeTemplateId:"default",customized:!1,soul:"",soulPath:null,updatedAt:null,templates:[]},T1=[{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"}],Xm=[{value:"openpond",label:"OpenPond Chat"},{value:"codex",label:"OpenAI Codex",description:"Codex login"}],_5=["openai","xai","openrouter","deepseek","zai","moonshot","together","groq","custom-openai-compatible"],C5=["openpond","codex",..._5],E1=new Set(C5),M1=[{value:th,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"}],qZ=[{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."}],BZ=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High",shortLabel:"Extra High"}],FZ=[{value:"ask",label:"Ask",description:"Ask before running shell commands."},{value:"full-access",label:"Full access",description:"Run shell commands without approval prompts."}],VZ=[{value:"auto",label:"Auto",description:"Use installed language servers when available."},{value:"off",label:"Off",description:"Disable editor language servers."}],KZ=[{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 fg(e){return e.kind==="local"}function R5(e){return e.kind==="cloud"}function vt(e,t){return`${e}:${t}`}function j1(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 Ar(e){return`${e.type}:${e.id}`}function sd(e){const t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?"before":"after"}function ld(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 Vb(e,t){return e.length===t.length&&e.every((n,a)=>n===t[a])}function P5(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 hg(e,t){return e?.statuses?.[t]??null}function O1(e,t){return e?.providers?.[t]??null}function $1(e,t){return e?.modelCaches?.[t]??null}function A5(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 T5(e){return e==="openpond"?T1:e==="codex"||e==="openai"?M1:[]}function E5(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 WZ(e){return E1.has(e)}function df(e,t={}){if(!e)return t.localOnly,Xm;const n=t.includeUnavailable??!1,a=t.enabledOnly??!1,r=[];for(const i of Ff){if(!E1.has(i)||t.localOnly&&i==="openpond")continue;const s=hg(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:Xm}function kl(e,t){const a=($1(t,e)?.models??[]).filter(s=>e!=="openpond"||s.id!==zi).map(A5),r=O1(t,e),i=[...r?.modelOverrides??[],r?.defaultModel].filter(s=>!!s?.trim()&&(e!=="openpond"||s!==zi)).map(s=>({value:s,label:s}));return E5([...a,...i,...T5(e)])}function M5(e,t,n){if(e==="codex"||e==="openai")return!0;const a=t.trim();if(!a)return!1;const r=$1(n,e)?.models.find(i=>i.id===a);return r?!!r.capabilities.reasoning:kl(e,n).some(i=>i.value===a&&/\breasoning\b/i.test(i.description??""))}function cd(e,t){const n=O1(t,e)?.defaultModel?.trim();if(n)return n;const a=hg(t,e)?.defaultModel?.trim();if(a)return a;const r=kl(e,t)[0]?.value?.trim();return r||(e==="codex"?th:e==="openpond"?zi:"")}function dr(e,t,n){const a=t?.trim();if(e==="codex"&&(a==="codex-default"||a==="gpt-5.5"))return th;const r=kl(e,n);return a&&r.some(i=>i.value===a)||a&&e!=="codex"&&r.length===0&&!n?a:cd(e,n)}function N1(e,t){const n=e.modelRef?.providerId??e.provider;return{provider:n,model:dr(n,e.modelRef?.modelId,t)}}function gg(e,t,n){return dr(e,t,n)||void 0}function Ra(e,t,n){const a=gg(e,t,n);return a?{providerId:e,modelId:a}:void 0}function Kb(e){return e==="full-access"?{approvalPolicy:"never",sandbox:"danger-full-access"}:{approvalPolicy:"on-request",sandbox:"workspace-write"}}function ma(e){const t=e?.defaultChatProvider??Tt.defaultChatProvider;return{defaultChatProvider:t,defaultChatModel:dr(t,e?.defaultChatModel),subagents:ul.parse(e?.subagents??Tt.subagents),codexPermissionMode:e?.codexPermissionMode??Tt.codexPermissionMode,codexReasoningEffort:e?.codexReasoningEffort??Tt.codexReasoningEffort,openPondCommandAccessMode:e?.openPondCommandAccessMode??Tt.openPondCommandAccessMode,defaultBranchPrefix:D1(e?.defaultBranchPrefix),defaultNewProjectDirectory:e?.defaultNewProjectDirectory??Tt.defaultNewProjectDirectory,defaultTeamId:e?.defaultTeamId?.trim()||null,advancedWorkspaceControls:e?.advancedWorkspaceControls??Tt.advancedWorkspaceControls,steerActiveResponses:e?.steerActiveResponses??Tt.steerActiveResponses,contextCompaction:{autoEnabled:e?.contextCompaction?.autoEnabled??Tt.contextCompaction.autoEnabled,triggerPercent:e?.contextCompaction?.triggerPercent??Tt.contextCompaction.triggerPercent,summaryModel:e?.contextCompaction?.summaryModel??Tt.contextCompaction.summaryModel},training:{defaultModelRef:e?.training?.defaultModelRef??Tt.training.defaultModelRef,creationMode:e?.training?.creationMode??Tt.training.creationMode,autoApproveEvidence:e?.training?.autoApproveEvidence??Tt.training.autoApproveEvidence},sidebarWidth:e?.sidebarWidth??Tt.sidebarWidth,diffPanelWidth:e?.diffPanelWidth??Tt.diffPanelWidth,sidebarSectionsCollapsed:{pinned:e?.sidebarSectionsCollapsed?.pinned??Tt.sidebarSectionsCollapsed.pinned,projects:e?.sidebarSectionsCollapsed?.projects??Tt.sidebarSectionsCollapsed.projects,cloudProjects:e?.sidebarSectionsCollapsed?.cloudProjects??Tt.sidebarSectionsCollapsed.cloudProjects,chats:e?.sidebarSectionsCollapsed?.chats??Tt.sidebarSectionsCollapsed.chats,savedForLater:e?.sidebarSectionsCollapsed?.savedForLater??Tt.sidebarSectionsCollapsed.savedForLater},editor:{languageServers:e?.editor?.languageServers??Tt.editor.languageServers,diagnosticsWhileEditing:e?.editor?.diagnosticsWhileEditing??Tt.editor.diagnosticsWhileEditing,checkOnSave:e?.editor?.checkOnSave??Tt.editor.checkOnSave,languages:{typescript:{mode:e?.editor?.languages?.typescript?.mode??Tt.editor.languages.typescript.mode,customCommand:e?.editor?.languages?.typescript?.customCommand??Tt.editor.languages.typescript.customCommand},python:{mode:e?.editor?.languages?.python?.mode??Tt.editor.languages.python.mode,customCommand:e?.editor?.languages?.python?.customCommand??Tt.editor.languages.python.customCommand},rust:{mode:e?.editor?.languages?.rust?.mode??Tt.editor.languages.rust.mode,customCommand:e?.editor?.languages?.rust?.customCommand??Tt.editor.languages.rust.customCommand}}}}}function D1(e){const t=e?.trim()??Tt.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 GZ(e,t){return e==="openpond"?"OpenPond Chat":hg(t,e)?.displayName??(e==="codex"?"OpenAI Codex":e)}function ZZ(e,t,n){if(n){const a=kl(n,t).find(r=>r.value===e);if(a)return a.label}if(t)for(const a of Ff){const r=kl(a,t).find(i=>i.value===e);if(r)return r.label}return[...T1,...M1].find(a=>a.value===e)?.label??e}function j5(e,t){return t==="chat"?e.filter(n=>n.experience==="chat"):e.filter(n=>n.experience==="work"||n.experience==="development")}function O5(e){return e.experience==="chat"?"Chat":"Work"}const vg="taskDraft";function L1(e){if(e?.experience!=="work")return null;const t=e.metadata?.[vg];if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.prompt;return typeof n=="string"&&n.trim()?n:null}function wl(e){return L1(e)!==null}function $5(e){return(e.split(/\r?\n/u).map(n=>n.trim()).find(Boolean)||"Task draft").slice(0,64)}function ep(e,t,n=new Date().toISOString()){const a={version:1,prompt:t,savedAt:n};return{...e??{},[vg]:a}}function N5(e){const t={...e??{}};return delete t[vg],t}function tr(e){const t=wc(e.metadata?.trainingTasksetId)??wc(e.metadata?.tasksetId);return t?{id:t,name:wc(e.metadata?.trainingTasksetName)??wc(e.metadata?.tasksetName)??D5(t)}:null}function D5(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 wc(e){return typeof e=="string"&&e.trim()?e.trim():null}const L5="codex_history_";function Ht(e){return!!e?.startsWith(L5)}function U1(e){const t=[],n=new Set;for(const a of e)for(const r of[a.workspacePath,a.path]){const i=Xd(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 U5(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=z1(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"||!H1(e))return null;const r=Xd(e.cwd);if(!r)return null;for(const i of n)if(bg(r,i.path))return i.projectId;return null}function Wb(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=z1(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"||!H1(e))return null;const r=Xd(e.cwd);if(!r)return null;for(const i of n)if(bg(r,i.path))return vt("local",i.projectId);return null}function z1(e,t){const n=Xd(e);if(!n)return null;for(const a of t)if(bg(n,a.path))return a.projectId;return null}function H1(e){return e.workspaceKind==="local_project"||e.provider==="codex"||Ht(e.id)}function Xd(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 bg(e,t){const n=Gb(e),a=Gb(t);return n===a||n.startsWith(`${a}/`)}function Gb(e){return/^[A-Z]:\//.test(e)?e.toLowerCase():e}const Zb=[{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"}],z5=[{value:"recent",label:"Recent first"},{value:"manual",label:"Manual order"}];function Jb(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=>Yb(r,e.selectedTasksetId)),...e.doneSessions.filter(r=>Yb(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=>yi(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)=>Xb(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:Xb(r,i)})}function yi(e,t){return t.showCodexChats===!1&&(e.provider==="codex"||Ht(e.id))?!1:!t.onlyRunningTasks||t.inProgressSessionIds.has(e.id)}function Yb(e,t){const n=tr(e);return!!(n&&(!t||n.id===t))}function H5(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 q5(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 Qb(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 Xb(e,t,n=null){const a=dd(e),r=dd(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 dd(e){return e.pinned&&!e.savedForLater&&!e.archived}const Ic={showCodexChats:!0,onlyRunningTasks:!1},q1="openpond.sidebar-task-visibility.v1";function ey(e=B1()){try{const t=e?.getItem(q1);if(!t)return Ic;const n=JSON.parse(t);return{showCodexChats:typeof n.showCodexChats=="boolean"?n.showCodexChats:Ic.showCodexChats,onlyRunningTasks:typeof n.onlyRunningTasks=="boolean"?n.onlyRunningTasks:Ic.onlyRunningTasks}}catch{return Ic}}function ty(e,t=B1()){try{t?.setItem(q1,JSON.stringify(e))}catch{}}function B1(){return typeof window>"u"?null:Kl}function F1(e){return`${e.kind}:${e.id}`}function Il(e,t){return!!(e&&t&&e.kind===t.kind&&e.id===t.id)}function B5(e){return{kind:"session",id:e}}function F5(e){return{kind:"project",id:e}}function V5(e){return{kind:"draft",id:e}}function K5(e){return e.selectedSessionId?B5(e.selectedSessionId):e.selectedProjectId?F5(e.selectedProjectId):V5(e.selectedAppId?`app:${e.selectedAppId}`:"new-chat")}function W5(e){if(!e.previousScope||e.previousScope.kind!=="draft"||e.activeScope.kind!=="session")return[...e.tabs];if(Il(e.previousScope,e.activeScope))return[...e.tabs];const t=e.now??Date.now();return e.tabs.map(n=>Il(n.scope,e.previousScope)?{...n,scope:e.activeScope,updatedAt:t}:n)}function JZ(e,t){return e.filter(n=>Il(n.scope,t))}function YZ(e,t){return!!(e&&Il(e.scope,t))}function G5(e){const t={};for(const n of e){const a=F1(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=J5(r.status,n.status,n.commandStatus),t[a]=r}return t}function Z5(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 J5(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 V1(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=Q5(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 K1(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=X5(n);return b?`${i} / ${b}`:h?`${i} / upload required`:`${i} / ${u||!m?"needs sync":"setup ready"}`}function Y5(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(W1(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 Q5(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 X5(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 ${W1(t)}`}function W1(e){return`${e} commit${e===1?"":"s"}`}function e4({size:e=14,className:t}){return S.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:[S.jsx("path",{d:"M12 13v8"}),S.jsx("path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"}),S.jsx("path",{d:"m8 17 4-4 4 4"})]})}function G1({kind:e,linkedCloud:t=!1,open:n=!1,className:a,baseSize:r=15}){const i=e==="cloud"?"cloud":n?"folder-open":"folder";return S.jsx("span",{className:["project-kind-icon",e,t?"linked-cloud":"",a??""].filter(Boolean).join(" "),"aria-hidden":"true",children:S.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"?S.jsx(a4,{}):n?S.jsx(n4,{}):S.jsx(t4,{}),t&&e==="local"?S.jsx(o4,{}):null]})})}function t4(){return S.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 n4(){return S.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 a4(){return S.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 o4(){return S.jsxs("g",{className:"project-kind-icon-cloud-badge",children:[S.jsx("circle",{cx:"18",cy:"17",r:"5"}),S.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"})]})}function r4({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 S.jsx("div",{className:"git-dialog-backdrop rename-chat-backdrop",role:"presentation",onMouseDown:n,children:S.jsxs("section",{className:"git-dialog rename-chat-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"rename-chat-title",onMouseDown:m=>m.stopPropagation(),children:[S.jsx("h2",{id:"rename-chat-title",children:"Rename chat"}),S.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"}),S.jsxs("div",{className:"git-dialog-footer",children:[S.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:n,children:"Cancel"}),S.jsx("button",{type:"button",className:"git-dialog-primary",autoFocus:!0,onClick:s,disabled:!a.trim(),children:"Save"})]})]})})}const i4=24;function s4({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)},i4);return()=>window.clearInterval(l)},[e]),S.jsx("span",{className:"sidebar-task-title-text","aria-label":e||"New task",children:n||"New task"})}const l4=2650,c4=304,d4=260,u4=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}),m4=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit"}),p4=new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"});function f4(){return{animationDelay:`${-(Date.now()%l4)}ms`}}function h4(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 ny({label:e,actions:t,actionsVisible:n=!1,className:a,titleAccessory:r,children:i,collapsed:s=!1,titleActive:l=!1,onTitleClick:m,onToggleCollapsed:u}){return S.jsxs("section",{className:["sidebar-section",a,n?"actions-visible":""].filter(Boolean).join(" "),children:[S.jsxs("div",{className:"section-header",children:[S.jsxs("div",{className:"section-title-row",children:[m?S.jsxs("div",{className:"section-title-combo",children:[S.jsx("button",{type:"button",className:`section-title-link${l?" active":""}`,onClick:m,children:S.jsx("span",{children:e})}),u&&S.jsx("button",{type:"button",className:"section-chevron-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:s?S.jsx(Nr,{size:13}):S.jsx(zo,{size:13})})]}):u?S.jsxs("button",{type:"button",className:"section-title-button","aria-label":`${s?"Expand":"Collapse"} ${e}`,"aria-expanded":!s,onClick:u,children:[S.jsx("span",{children:e}),s?S.jsx(Nr,{size:13}):S.jsx(zo,{size:13})]}):S.jsx("span",{children:e}),r]}),t&&S.jsx("div",{className:"section-actions",children:t})]}),!s&&S.jsx("div",{className:"sidebar-section-body",children:i})]})}function ay({children:e,expanded:t=!1,onClick:n}){return S.jsx("button",{type:"button",className:"sidebar-show-more",onClick:n,children:e??(t?"Show less":"Show more")})}function tp({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,metadataPresentation:w,ariaDescribedBy:_,childSessionCount:E=0,childSessionsExpanded:O=!1,onSelect:P,onToggleChildSessions:L,onTogglePin:$,onToggleSaveForLater:j,onDockRight:x,onArchive:C,onDragStart:A,onDragEnd:z,onDragOver:q,onDrop:N,onRename:K}){const[de,te]=g.useState(!1),Ie=u?.status==="queued",Se=u?.tone==="active"&&!Ie,Z=(h?.activeCount??0)>0,Pe=E>0&&!!L,ge=r&&!Pe,ce=Z||Se||!Ie&&(m??e.status==="active"),be=Z&&h?h.label:Se&&u?v4(u):"Running",ne=w??(y?"hover-detail":"inline"),he=ne==="hover-detail",ke=ne==="inline",qe=["sidebar-task-row",wl(e)?"is-draft":"",x?"actions-4":j?"actions-3":"",ce?"has-running-dot":"",he?"has-project-detail":""].filter(Boolean).join(" "),xe=g.useMemo(f4,[]),re=S.jsxs("div",{className:`sidebar-row-actions${he?" sidebar-task-inline-actions":""}`,children:[x?S.jsx(ar,{label:"Open in right panel",onClick:x,children:S.jsx(ef,{size:13})}):null,S.jsx(ar,{label:e.pinned?"Unpin chat":"Pin chat",onClick:$,children:e.pinned?S.jsx(tg,{size:13}):S.jsx(eg,{size:13})}),j?S.jsx(ar,{label:e.savedForLater?"Return to active":"Save for later",onClick:j,children:e.savedForLater?S.jsx(v1,{size:13}):S.jsx(g1,{size:13})}):null,S.jsx(ar,{label:a?"Reopen":"Mark done",onClick:C,children:a?S.jsx(QB,{size:13}):S.jsx(wo,{size:13})})]}),we=S.jsxs(yg,{selected:t,dataSessionId:e.id,dragging:s,iconless:ge,nested:i,placeholder:l,className:qe||void 0,ariaExpanded:Pe?O:void 0,ariaDescribedBy:_,onSelect:P,onDragStart:A,onDragEnd:z,onDragOver:q,onDrop:N,onDoubleClick:K?()=>te(!0):void 0,children:[ge?null:Pe?S.jsx("button",{type:"button",className:"sidebar-child-toggle","data-tooltip":O?"Hide subagent conversations":"Show subagent conversations","aria-label":`${O?"Hide":"Show"} ${E} subagent ${E===1?"conversation":"conversations"}`,"aria-expanded":O,onClick:Ze=>{Ze.stopPropagation(),L?.()},children:O?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})}):n??S.jsx(Jd,{size:15}),S.jsxs("span",{className:`row-label-shell${he?" has-detail":""}`,children:[S.jsxs("span",{className:"sidebar-session-title-line",children:[S.jsx("span",{className:"row-label sidebar-task-title","data-overflowing":"false",onPointerEnter:h4,children:S.jsx(s4,{title:e.title})}),ke?S.jsx(uf,{value:e.updatedAt}):null]}),he?S.jsxs("span",{className:"sidebar-session-detail-line",children:[S.jsx("span",{className:"sidebar-session-project-label",children:y}),re,S.jsx(uf,{value:e.updatedAt})]}):null]}),S.jsxs("div",{className:"row-meta",children:[S.jsxs("span",{className:"row-meta-status",children:[b?S.jsx(Z1,{indicator:b}):null,ce?S.jsx("span",{className:`sidebar-running-dot${Z?" subagent":Se?" goal":""}`,style:xe,"aria-label":be}):null]}),he?null:re]})]}),je=de&&K?S.jsx(r4,{session:e,onSave:Ze=>K(e,Ze),onClose:()=>te(!1)}):null;return S.jsxs(S.Fragment,{children:[we,je]})}function g4({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 S.jsxs(yg,{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?S.jsx(Qh,{size:15}):S.jsx(pF,{size:15}),S.jsx("span",{className:"row-label-shell",title:b,children:S.jsx("span",{className:"row-label",children:h})}),S.jsx("div",{className:"row-meta",children:S.jsxs("div",{className:"sidebar-row-actions",children:[S.jsx(ar,{label:e.status==="pinned"?"Unpin file":"Pin file",onClick:r,children:e.status==="pinned"?S.jsx(tg,{size:13}):S.jsx(eg,{size:13})}),S.jsx(ar,{label:e.status==="saved_for_later"?"Remove from Save for later":"Save file for later",onClick:i,children:e.status==="saved_for_later"?S.jsx(v1,{size:13}):S.jsx(g1,{size:13})})]})})]})}function v4(e){return e.actionLabel}function b4({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:O,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:j}){const[x,C]=g.useState(!1),A=g.useRef(null),[z,q]=g.useState({}),N=!!w||!!O,K=e==="local"&&l!==!1&&!!t.linkedSandboxProject?.projectId,de=g.useCallback(()=>{if(typeof window>"u")return;const Se=A.current?.getBoundingClientRect();if(!Se)return;const Z=Math.max(12,window.innerWidth-c4-12),Pe=Math.max(12,window.innerHeight-d4),ge=Math.max(12,Math.min(Se.right+10,Z)),ce=Math.max(12,Math.min(Se.top-4,Pe)),be={"--sidebar-project-locations-left":`${Math.round(ge)}px`,"--sidebar-project-locations-top":`${Math.round(ce)}px`};q(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 S.jsxs("div",{ref:A,className:["sidebar-project-row-shell",x?"project-menu-open":""].filter(Boolean).join(" "),onFocusCapture:de,onPointerEnter:de,children:[S.jsxs(yg,{selected:a,placeholder:u,className:["sidebar-project-row",x?"project-menu-open":""].filter(Boolean).join(" "),ariaExpanded:i?r:void 0,onSelect:te,onDragStart:P,onDragEnd:L,onDragOver:$,onDrop:j,children:[S.jsx(G1,{kind:e,linkedCloud:K,open:e==="local"&&r,className:"sidebar-row-icon",baseSize:15}),S.jsx("span",{className:"row-label-shell",children:S.jsxs("span",{className:"sidebar-project-title-line",children:[S.jsx("span",{className:"row-label",children:t.name}),S.jsx(uf,{value:t.updatedAt}),i?S.jsx("span",{className:"sidebar-project-caret","aria-hidden":"true",children:r?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})}):null]})}),S.jsxs("div",{className:"row-meta",children:[S.jsx("span",{className:"row-meta-status",children:h?S.jsx(Z1,{indicator:h}):null}),S.jsxs("div",{className:"sidebar-row-actions",children:[S.jsx(ar,{label:n?"Unpin project":"Pin project",onClick:E,children:n?S.jsx(tg,{size:13}):S.jsx(eg,{size:13})}),N&&S.jsx(M4,{open:x,onToggleOpen:()=>C(Se=>!Se)}),S.jsx(ar,{label:"New task",onClick:y,children:S.jsx(ag,{size:13})})]})]})]}),S.jsx(S4,{kind:e,project:t,workspaceState:s,cloudLinkTrusted:l,cloudLinkWarning:m,onWorkspaceTargetSelect:_,style:z}),x&&S.jsx(j4,{onClose:Ie,onMoveToCloud:w?()=>{Ie(),w()}:void 0,onRemove:()=>{Ie(),O()}})]})}function uf({value:e}){const t=y4(e);if(!t||!e)return null;const n=new Date(e);return S.jsx("time",{className:"sidebar-row-updated-at",dateTime:e,title:`Last updated ${p4.format(n)}`,children:t})}function y4(e,t=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const a=m4.format(n);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?a:`${u4.format(n)} ${a}`}function Z1({indicator:e}){return S.jsx("span",{className:`sidebar-terminal-indicator ${e.status}`,"data-tooltip":e.label,"aria-label":e.label,title:e.label,children:S.jsx(w1,{size:13})})}function S4({kind:e,project:t,workspaceState:n,cloudLinkTrusted:a,cloudLinkWarning:r,onWorkspaceTargetSelect:i,style:s}){const l=w4(e,t,n,a,r);return S.jsxs("aside",{className:"sidebar-project-locations-popover","aria-label":`${t.name} status`,style:s,children:[S.jsx("div",{className:"sidebar-project-locations-title",children:t.name}),S.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=S.jsxs(S.Fragment,{children:[S.jsx("span",{className:["sidebar-project-location-icon",m.key].filter(Boolean).join(" "),"aria-hidden":"true",children:m.icon}),S.jsx("span",{className:"sidebar-project-location-copy",children:S.jsx(x4,{value:m.value})})]});return m.actionTarget?S.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):S.jsx("div",{className:u,children:h},m.key)})})]})}function x4({value:e}){const t=k4(e);return S.jsxs("span",{className:"sidebar-project-location-value","aria-label":e,children:[t.branch?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"sidebar-project-location-branch",children:t.branch}),S.jsx("span",{className:"sidebar-project-location-separator","aria-hidden":"true",children:"/"})]}):null,S.jsx("span",{className:"sidebar-project-location-status",children:t.status})]})}function k4(e){const n=e.indexOf(" / ");return n===-1?{branch:null,status:e}:{branch:e.slice(0,n),status:e.slice(n+3)}}function w4(e,t,n,a=!0,r=null){return e==="cloud"?_4(t):I4(t,n,a,r)}function I4(e,t,n=!0,a=null){const r=C4(e,t,n),i=R4(t),s=A4(e,n),l=n===!1&&a;return[{key:"local",value:r,tone:i?"attention":"local",icon:e.source==="git"?S.jsx(y1,{size:13}):S.jsx(IF,{size:13}),actionTarget:"local"},{key:"cloud",value:l||(s?T4(e,t,n):"not in cloud"),tone:l?"attention":"cloud",icon:S.jsx(Zd,{size:13}),actionTarget:s?"cloud":"upload_cloud"}]}function _4(e){return[{key:"cloud",value:E4(e),tone:e.syncedAt?"cloud":"attention",icon:S.jsx(Zd,{size:13}),actionTarget:"cloud"}]}function C4(e,t,n){const a=P4(e,t);return t?t.error?`${a} / status unavailable`:t.initialized?V1(t,{branch:e.linkedSandboxProject?.defaultBranch??null,linkedCloudSourceKnown:e.linkedSandboxProject?.projectId&&n?!!e.linkedSandboxProject.lastUploadedCommit||!t.headCommit:!0}):`${a} / not checked out`:`${a} / available`}function R4(e){return!!(e?.dirty||(e?.changedFilesCount??0)>0||(e?.untrackedFilesCount??0)>0)}function P4(e,t){return t?.currentBranch??t?.defaultBranch??e.linkedSandboxProject?.defaultBranch??"local"}function A4(e,t=!0){return!!(t&&e.linkedSandboxProject?.projectId||e.linkedOpenPondApp?.appId)}function T4(e,t,n){return K1(e,null,t,{cloudLinkTrusted:n})}function E4(e){const t=e.defaultBranch??"main",n=e.syncedAt?"setup ready":"needs setup";return`${t} / ${n}`}function M4({open:e,onToggleOpen:t}){return S.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:S.jsx(Xh,{size:13})})}function j4({onClose:e,onMoveToCloud:t,onRemove:n}){return S.jsxs(S.Fragment,{children:[S.jsx("button",{type:"button",className:"sidebar-project-menu-backdrop","aria-label":"Close project actions",onClick:a=>{a.stopPropagation(),e()}}),S.jsxs("div",{className:"section-menu-popover sidebar-project-row-popover",role:"menu",children:[t&&S.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),t()},children:[S.jsx(e4,{size:13}),S.jsx("span",{children:"Move to Cloud"})]}),S.jsxs("button",{type:"button",role:"menuitem",onClick:a=>{a.stopPropagation(),n()},children:[S.jsx(rs,{size:13}),S.jsx("span",{children:"Remove from Projects"})]})]})]})}function yg({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 O=!!b;return S.jsx("div",{className:["sidebar-row",t??"",l?"selected":"",a?"dragging":"",r?"iconless":"",i?"nested":"",s?"placeholder":""].filter(Boolean).join(" "),draggable:O,"data-session-id":n,role:"button",tabIndex:0,"aria-expanded":m,"aria-describedby":u,onClick:h,onDoubleClick:E,onKeyDown:P=>{(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 ar({children:e,label:t,onClick:n}){return S.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":t,"aria-label":t,onClick:a=>{a.stopPropagation(),n()},children:e})}function O4({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 O=g.useRef(null),[P,L]=g.useState(!1),j=E.find(A=>A.id===_)?.name??Zb.find(A=>A.value===e)?.label??"Active",x=h==="tasks-filter",C=h==="chats";return g.useEffect(()=>{if(!x&&!C)return;function A(z){O.current?.contains(z.target)||b(null)}return document.addEventListener("pointerdown",A),()=>document.removeEventListener("pointerdown",A)},[x,b,C]),S.jsxs("div",{className:"sidebar-task-list-controls",ref:O,children:[S.jsxs("div",{className:"section-menu",children:[S.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:S.jsx(Xh,{size:14})}),C?S.jsxs("div",{className:"section-menu-popover",role:"menu","aria-label":`${n==="tasks"?"Task":"Chat"} list options`,children:[S.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":y,onClick:()=>s(!y),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:y?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"Show Codex chats"})]}),S.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":u,onClick:()=>i(!u),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:u?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"Only running tasks"})]}),n==="tasks"?S.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":t,onClick:()=>r(!t),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:t?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"Group by project"})]}):null,z5.map(A=>S.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w===A.value,onClick:()=>{m(A.value),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:w===A.value?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:A.label})]},A.value))]}):null]}),S.jsxs("div",{className:"section-menu",children:[S.jsx("button",{type:"button",className:`section-icon ${x?"active":""}`,"aria-label":`Filter ${n}: ${j}`,"aria-haspopup":"menu","aria-expanded":x,onClick:()=>b(A=>A==="tasks-filter"?null:"tasks-filter"),children:S.jsx(OF,{size:14})}),x?S.jsx("div",{className:"section-menu-popover",role:"menu","aria-label":`Filter ${n}`,children:Zb.map(A=>S.jsxs(g.Fragment,{children:[A.value==="tasksets"?S.jsxs("button",{type:"button",role:"menuitem","aria-expanded":P,onClick:()=>L(z=>!z),children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:P?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})}),S.jsx("span",{children:A.label})]}):S.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":e===A.value,onClick:()=>{a(A.value),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e===A.value?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:A.label})]}),A.value==="tasksets"&&P?S.jsxs(S.Fragment,{children:[S.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&!_,onClick:()=>{l(null),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&!_?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:"All Tasksets"})]}),E.map(z=>S.jsxs("button",{className:"section-menu-taskset-option",type:"button",role:"menuitemradio","aria-checked":e==="tasksets"&&_===z.id,onClick:()=>{l(z.id),b(null)},children:[S.jsx("span",{className:"section-menu-check","aria-hidden":"true",children:e==="tasksets"&&_===z.id?S.jsx(wo,{size:13}):null}),S.jsx("span",{children:z.name}),S.jsx("span",{className:"section-menu-option-count","aria-hidden":"true",children:z.chatCount})]},z.id))]}):null]},A.value))}):null]})]})}const $4=288,N4=112;function D4(e,t){const n=Math.max(12,t.width-$4-12),a=Math.max(12,t.height-N4-12);return{"--sidebar-task-detail-left":`${Math.round(Math.max(12,Math.min(e.right+10,n)))}px`,"--sidebar-task-detail-top":`${Math.round(Math.max(12,Math.min(e.top-4,a)))}px`}}function L4({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:"full",timeStyle:"short"}).format(n);return S.jsxs("aside",{id:e.descriptionId,className:"sidebar-task-detail-popover",style:e.style,"aria-label":`${e.title} details`,children:[S.jsx("div",{className:"sidebar-task-detail-title",children:e.title}),S.jsx("div",{className:"sidebar-task-detail-project",children:e.projectLabel}),S.jsx("time",{dateTime:e.updatedAt,children:a})]})}function U4({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"?Qh:Jd,[y,w]=g.useState(!1),_=!!(s||l||m);return S.jsxs("section",{className:"sidebar-task-project-group",children:[S.jsxs("div",{className:`sidebar-task-project-group-header-shell${y?" menu-open":""}`,children:[S.jsxs("button",{type:"button",className:"sidebar-task-project-group-header","aria-controls":h,"aria-expanded":t,onClick:()=>{w(!1),i()},children:[u?S.jsx(G1,{kind:u.kind,linkedCloud:!!(u.kind==="local"&&u.project.linkedSandboxProject?.projectId),open:u.kind==="local"&&t,className:"sidebar-task-project-group-icon",baseSize:14}):S.jsx(b,{className:"sidebar-task-project-group-icon",size:14,"aria-hidden":"true"}),S.jsx("span",{className:"sidebar-task-project-group-name",children:r}),S.jsx("span",{className:"sidebar-task-project-group-caret","aria-hidden":"true",children:t?S.jsx(zo,{size:13}):S.jsx(Nr,{size:13})})]}),u&&_?S.jsxs("div",{className:"sidebar-task-project-group-actions",children:[l||m?S.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:S.jsx(Xh,{size:13})}):null,s?S.jsx("button",{type:"button",className:"sidebar-row-action","data-tooltip":"New task","aria-label":"New task",onClick:s,children:S.jsx(ag,{size:13})}):null]}):null,y?S.jsxs(S.Fragment,{children:[S.jsx("button",{type:"button",className:"sidebar-task-project-group-menu-backdrop","aria-label":"Close project actions",onClick:()=>w(!1)}),S.jsxs("div",{className:"section-menu-popover sidebar-task-project-group-menu",role:"menu",children:[l?S.jsx("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),l()},children:S.jsx("span",{children:"Open project"})}):null,m?S.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),m()},children:[S.jsx(rs,{size:13}),S.jsx("span",{children:"Remove from Projects"})]}):null]})]}):null]}),t?S.jsx("div",{id:h,className:"sidebar-task-project-group-content",children:e}):null]})}const z4={},H4=new Map,q4=new Map;function B4(e,t){return Math.min(Math.max(e,Cn)+cf,t)}function F4(e,t){const n=Math.max(Cn,Math.min(e,t));if(n<=Cn)return Cn;const a=Math.ceil((n-Cn)/cf);return Math.max(Cn,Cn+(a-1)*cf)}function V4(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 K4({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=H4,localProjectRows:y,openSidebarFile:w,pinnedCollapsed:_,pinnedRows:E,previewTaskDrop:O,previewPinnedDrop:P,projectRows:L,renameSession:$,restoreSession:j,runningSessionIds:x,savedForLaterSessions:C,sectionMenuOpen:A,selectedProjectId:z,selectedSessionId:q,setChatRowsVisibleCount:N,setSectionMenuOpen:K,setSelectedAppId:de,setSelectedProjectId:te,setSelectedSessionId:Ie,setView:Se,sidebarProjectIdBySessionId:Z,startTaskDrag:Pe,startPinnedDrag:ge,subagentRuntimeBySessionId:ce=q4,taskDragSessionId:be,taskPreviewSessionIds:ne,terminalSummaries:he=z4,toggleSessionPinned:ke,toggleSessionSavedForLater:qe,view:xe,clearTaskDrag:re,removeProject:we,toggleProjectPinned:je,onTogglePinnedCollapsed:Ze,setSidebarFileStatus:Ge,commitPinnedDrop:st,commitPinnedPreviewDrop:Ue,clearSidebarDrag:Ve,dragItem:Le}){const[D,M]=g.useState("active"),[H,Q]=g.useState("manual"),[me,_e]=g.useState(h!=="chat"),[$e,Xe]=g.useState(ey);Vl(()=>Xe(ey()));const{onlyRunningTasks:et,showCodexChats:rt}=$e,[it,Me]=g.useState(null),[Fe,p]=g.useState(()=>new Set),[U,V]=g.useState(()=>new Map),[le,ie]=g.useState(null),F=h==="chat"?"chats":"tasks",I=h==="chat"?"Chats":"Tasks",W=L??[...y,...i],X=g.useMemo(()=>new Map(W.map(oe=>[oe.id,oe.project.name])),[W]),ae=g.useMemo(()=>new Map(W.map(oe=>[oe.id,oe])),[W]),G=g.useMemo(()=>{const oe=new Set(x);for(const De of e){const Be=b.get(De.id),Je=ce.get(De.id);(Be?.tone==="active"&&Be.status!=="queued"||(Je?.activeCount??0)>0||yt(De.id)?.status==="running")&&oe.add(De.id)}return oe},[e,b,x,ce,he]),pe=g.useMemo(()=>e.filter(oe=>tr(oe)===null&&yi(oe,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[e,G,et,rt]),fe=g.useMemo(()=>C.filter(oe=>tr(oe)===null&&yi(oe,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,C,rt]),Oe=Math.max(0,pe.length-fe.length),Ee=H5({activeCount:Oe,filter:D,savedForLaterCount:fe.length}),Ne=g.useMemo(()=>Jb({activeSessions:e,doneSessions:n,filter:"all",inProgressSessionIds:G,sort:"manual"}),[e,n,G]),Ke=g.useMemo(()=>Jb({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]),ze=g.useMemo(()=>{const oe=new Map;for(const De of[...e,...n]){if(!yi(De,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))continue;const Be=tr(De);if(!Be)continue;const Je=oe.get(Be.id);Je?Je.chatCount+=1:oe.set(Be.id,{...Be,chatCount:1})}return[...oe.values()].sort((De,Be)=>De.name.localeCompare(Be.name))},[e,n,G,et,rt]),ut=g.useMemo(()=>E.filter(oe=>oe.type!=="session"||yi(oe.session,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt})),[G,et,E,rt]),Qt=g.useMemo(()=>Ke.filter(oe=>!dd(oe)).slice(0,Math.max(Cn,a)),[a,Ke]),Lt=g.useMemo(()=>V4(Qt,oe=>{if(wl(oe))return{key:"draft",label:"Drafts",projectId:null,project:null,kind:"draft"};const De=Z[oe.id],Be=un(oe)??"No project";return{key:De?`project:${De}`:`projectless:${Be}`,label:Be,projectId:De??null,project:De?ae.get(De)??null:null,kind:De?"project":"projectless"}}),[X,ae,Z,Qt]),An=Qt.length<Ke.length,Sn=Qt.length>Cn,nn=g.useMemo(()=>new Set(Lt.filter(oe=>oe.sessions.some(De=>De.id===q||G.has(De.id))).map(oe=>oe.key)),[Lt,G,q]),bt=Ne.filter(oe=>!dd(oe)).map(oe=>oe.id),rn=Qt.map(oe=>oe.id),Nt=JSON.stringify(Object.entries(r).filter(([oe,De])=>De.length>0&&(ce.get(oe)?.activeCount??0)>0).flatMap(([oe,De])=>De.map(Be=>[oe,Be.id])).sort(([oe,De],[Be,Je])=>oe.localeCompare(Be)||De.localeCompare(Je)));g.useEffect(()=>{const oe=JSON.parse(Nt);if(oe.length===0)return;const De=new Set(oe.map(([Be])=>Be));p(Be=>[...De].every(Je=>Be.has(Je))?Be:new Set([...Be,...De]))},[Nt]);function yt(oe){return Z5(he[F1({kind:"session",id:oe})])}function un(oe){if(wl(oe))return"Draft";const De=Z[oe.id];return De?X.get(De)??oe.workspaceName??"Project":O5(oe)}function Ut(oe){sn({kind:"chat",sessionId:oe.id}),Ie(oe.id);const De=Z[oe.id]??null;de(De?null:oe.appId),te(De),Se("chat")}function mn(oe){return(r[oe.id]??[]).filter(De=>yi(De,{inProgressSessionIds:G,onlyRunningTasks:et,showCodexChats:rt}))}function On(oe,De){return Fe.has(oe.id)||De.some(Be=>Be.id===q)}function gn(oe){p(De=>{const Be=new Set(De);return Be.has(oe)?Be.delete(oe):Be.add(oe),Be})}function Na(oe){const De=mn(oe);return De.length===0||!On(oe,De)?null:S.jsx("div",{className:"sidebar-child-session-group",children:De.map(Be=>S.jsx(tp,{session:Be,selected:xe==="chat"&&q===Be.id,hideIcon:!0,nested:!0,running:G.has(Be.id),goalRuntime:b.get(Be.id)??null,subagentRuntime:ce.get(Be.id)??null,terminalIndicator:yt(Be.id),projectLabel:un(oe),onSelect:()=>Ut(Be),onTogglePin:()=>ke(Be),onToggleSaveForLater:()=>qe(Be),onDockRight:()=>u(Be),onArchive:()=>Be.archived?j(Be):t(Be),onRename:$},Be.id))})}function Da(oe,De,Be){typeof window>"u"||ie({descriptionId:`sidebar-task-detail-${oe.id}`,projectLabel:De,sessionId:oe.id,title:oe.title,updatedAt:oe.updatedAt,style:D4(Be.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight})})}function qt(oe,De={}){const Be=oe.archived,Je=be===oe.id,At=mn(oe),gt="sidebar-session-group",lt=H==="manual"?{onDragStart:_t=>Pe(_t,{allSessionIds:bt,visibleSessionIds:rn,sessionId:oe.id}),onDragEnd:re,onDragOver:_t=>{Je||O(_t,oe.id)},onDrop:_t=>{Je?m():l(_t,oe.id)}}:{};return S.jsxs("div",{className:gt,onPointerEnter:De.metadataPresentation==="flyout"&&De.projectLabel?_t=>Da(oe,De.projectLabel,_t.currentTarget):void 0,onPointerLeave:De.metadataPresentation==="flyout"?()=>ie(null):void 0,onFocusCapture:De.metadataPresentation==="flyout"&&De.projectLabel?_t=>Da(oe,De.projectLabel,_t.currentTarget):void 0,onBlurCapture:De.metadataPresentation==="flyout"?_t=>{_t.currentTarget.contains(_t.relatedTarget)||ie(null)}:void 0,children:[S.jsx(tp,{session:oe,selected:!Be&&xe==="chat"&&q===oe.id,archived:Be,hideIcon:!0,placeholder:Je,running:G.has(oe.id),goalRuntime:b.get(oe.id)??null,subagentRuntime:ce.get(oe.id)??null,terminalIndicator:yt(oe.id),projectLabel:De.projectLabel===void 0?un(oe):De.projectLabel,metadataPresentation:De.metadataPresentation,ariaDescribedBy:De.metadataPresentation==="flyout"&&le?.sessionId===oe.id?le.descriptionId:void 0,childSessionCount:At.length,childSessionsExpanded:On(oe,At),onToggleChildSessions:()=>gn(oe.id),onSelect:()=>{ie(null),Be&&j(oe),Ut(oe)},onTogglePin:()=>ke(oe),onToggleSaveForLater:()=>qe(oe),onDockRight:()=>u(oe),onArchive:()=>Be?j(oe):t(oe),onRename:$,...lt}),Je?null:Na(oe)]},oe.id)}function qn(oe){oe!=="tasksets"&&Me(null),M(oe),N(Cn)}function ot(oe){Me(oe),M("tasksets"),N(Cn)}function xn(oe){Q(oe),N(Cn)}function La(){N(oe=>B4(oe,Ke.length))}function Ua(){N(oe=>F4(oe,Ke.length))}function ia(oe){const De={id:oe.id,type:oe.type};return{onDragStart:Be=>ge(Be,De),onDragEnd:Ve,onDragOver:Be=>P(Be,De),onDrop:Be=>{Le?.id===oe.id&&Le.type===oe.type?Ue():st(Be,De)}}}function za(oe){const De=ia(oe),Be=Le?.id===oe.id&&Le.type===oe.type;if(oe.type==="project"){const At=oe.item;return S.jsx(b4,{kind:At.kind,project:At.project,pinned:!0,selected:xe==="chat"&&z===At.id,expanded:!1,disclosure:!1,placeholder:Be,onSelect:()=>{de(null),te(At.id),Ie(null),Se("chat")},onNewChat:()=>s(At.id),onTogglePin:()=>je(At),onRemove:()=>we(At),...De},oe.key)}if(oe.type==="file")return S.jsx(g4,{file:oe.file,placeholder:Be,onSelect:()=>w(oe.file),onTogglePin:()=>Ge(oe.file,"none"),onToggleSaveForLater:()=>Ge(oe.file,"saved_for_later"),...De},oe.key);const Je=oe.session;return S.jsx(tp,{session:Je,selected:xe==="chat"&&q===Je.id,hideIcon:!0,placeholder:Be,running:G.has(Je.id),goalRuntime:b.get(Je.id)??null,subagentRuntime:ce.get(Je.id)??null,terminalIndicator:yt(Je.id),projectLabel:un(Je),metadataPresentation:"flyout",onSelect:()=>Ut(Je),onTogglePin:()=>ke(Je),onToggleSaveForLater:()=>qe(Je),onDockRight:()=>u(Je),onArchive:()=>t(Je),onRename:$,...De},oe.key)}return S.jsxs("div",{className:"sidebar-scroll",children:[S.jsxs(ny,{label:I,className:`sidebar-task-section${h!=="chat"?" development":""}`,titleAccessory:h!=="chat"?S.jsx("div",{className:"sidebar-task-mode-buttons",children:S.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:[S.jsx("span",{children:Ee.label}),S.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:S.jsx(O4,{filter:D,groupByProject:me,noun:F,onFilterChange:qn,onGroupByProjectChange:_e,onOnlyRunningTasksChange:oe=>{Xe(De=>{const Be={...De,onlyRunningTasks:oe};return ty(Be),Be}),N(Cn)},onShowCodexChatsChange:oe=>{Xe(De=>{const Be={...De,showCodexChats:oe};return ty(Be),Be}),N(Cn)},onTasksetChange:ot,onSortChange:xn,onlyRunningTasks:et,openMenu:A,setOpenMenu:K,showCodexChats:rt,sort:H,selectedTasksetId:it,tasksets:ze}),children:[ut.length>0?S.jsx(ny,{label:"Pinned",className:"sidebar-pinned-section",collapsed:_,onToggleCollapsed:Ze,children:ut.map(za)}):null,me&&h!=="chat"?Lt.map(oe=>{const De=nn.has(oe.key)||U.get(oe.key)!==!1;return S.jsx(U4,{expanded:De,groupKey:oe.key,kind:oe.kind,label:oe.label,onToggle:()=>{V(Be=>{const Je=new Map(Be);return Je.set(oe.key,!De),Je})},onNewTask:oe.project?()=>s(oe.project.id):void 0,onOpenProject:oe.project?()=>{de(null),te(oe.project.id),Ie(null),Se("chat")}:void 0,onRemoveProject:oe.project?()=>we(oe.project):void 0,project:oe.project,children:oe.sessions.map(Be=>qt(Be,{metadataPresentation:"flyout",projectLabel:oe.label}))},oe.key)}):Qt.map(oe=>qt(oe)),Ke.length===0?S.jsx("div",{className:"empty-row",children:q5(D,F)}):null,Ke.length>Cn&&(An||Sn)?S.jsxs("div",{className:"sidebar-pagination-controls","aria-label":`Showing ${Qt.length} of ${Ke.length} ${F}`,children:[An?S.jsx(ay,{onClick:La,children:"Show more"}):null,Sn?S.jsx(ay,{onClick:Ua,children:"Show less"}):null]}):null]}),S.jsx(L4,{detail:le,onClose:()=>ie(null)})]})}const W4="/";function Jn(e){return`${W4}${e.replace(/^\.?\//,"")}`}const G4=Jn("openpond-icon.png"),Z4=Jn("openpond-wordlogo-white.png"),QZ=Jn("tutorials/what-is-an-openpond-agent-poster.png"),XZ=Jn("tutorials/what-is-an-openpond-agent.vtt"),eJ=Jn("tutorials/how-to-make-an-agent-poster.png"),tJ=Jn("tutorials/how-to-make-an-agent.vtt");function nJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}-poster.png`)}function aJ(e){return Jn(`tutorials/how-to-make-an-agent-${e}.vtt`)}const oy={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 oJ(e){return oy[e]??oy.mcp}function J4({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=Jm.find(y=>y.value===e)??Jm[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&&ry(s.current,l.current),l.current=null},[n]);const u=y=>{if(n){ry(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=J1(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,O=_<0?0:(_+E+w.length)%w.length;w[O]?.focus()};return S.jsxs("div",{className:"sidebar-experience-menu",ref:r,children:[S.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:[S.jsx("img",{className:"sidebar-wordmark",src:Z4,alt:""}),S.jsx("span",{className:"sidebar-experience-label",children:m.label}),S.jsx(zo,{size:13,"aria-hidden":"true"})]}),n?S.jsx("div",{ref:s,className:"sidebar-experience-popover",role:"menu","aria-label":"Choose product",onKeyDown:b,children:Jm.map(y=>{const w=y.value===e;return S.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:[S.jsxs("span",{children:[S.jsx("strong",{children:y.label}),S.jsx("small",{children:y.description})]}),w?S.jsx(wo,{size:14,"aria-hidden":"true"}):null]},y.value)})}):null]})}function J1(e){return e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[]}function ry(e,t){const n=J1(e);(t==="first"?n[0]:n.at(-1))?.focus()}function Y4(...e){for(const t of e){const n=t?.trim();if(n)return n}return null}function Q4(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"?Y4(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 X4({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(()=>Q4(e),[e]),E=_.label.trim().slice(0,1).toUpperCase(),O=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]),S.jsxs("div",{className:"user-auth-footer",ref:w,children:[S.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:[S.jsx("span",{className:"user-auth-avatar","aria-hidden":"true",children:_.image?S.jsx("img",{src:_.image,alt:""}):E?S.jsx("span",{children:E}):S.jsx(qb,{size:16})}),S.jsx("span",{className:"user-auth-name",children:_.label})]}),t?S.jsxs("div",{className:"user-auth-menu",role:"menu","aria-label":"Account",children:[S.jsxs("div",{className:"user-auth-menu-header",children:[S.jsx("span",{className:"user-auth-menu-avatar","aria-hidden":"true",children:_.image?S.jsx("img",{src:_.image,alt:""}):E?S.jsx("span",{children:E}):S.jsx(qb,{size:17})}),S.jsx("span",{className:"user-auth-menu-identity",children:S.jsx("strong",{children:_.label})})]}),n.length>0&&l?S.jsxs("label",{className:"user-auth-team-picker",children:[S.jsx(k1,{size:15,"aria-hidden":"true"}),S.jsx("span",{className:"user-auth-team-picker-label",children:"Team"}),S.jsx("select",{"aria-label":"Active team",disabled:u!==null,value:O?.teamId??"",onChange:async P=>{const L=P.currentTarget.value;h(L);try{await l(L)}catch{}finally{h(null)}},children:n.map(P=>S.jsx("option",{value:P.teamId,children:P.displayName},P.teamId))})]}):null,S.jsx("div",{className:"user-auth-menu-divider"}),r?S.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),r()},children:[S.jsx(b1,{size:15}),S.jsx("span",{children:"Activity"})]}):null,S.jsxs("button",{type:"button",className:"user-auth-menu-link",role:"menuitem",onClick:()=>{i(!1),s()},children:[S.jsx(ng,{size:15}),S.jsx("span",{children:"Settings"})]}),e?.state==="signed_in"&&m?S.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:[S.jsx(GF,{size:15}),S.jsx("span",{children:b?"Logging out…":"Log out"})]}):null]}):null]})}function iy(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 e3(e,t){const n=iy(e),a=iy(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 Y1(e){const t=e?.toLowerCase()??"";return t==="darwin"||t.includes("mac")?"mac":t==="linux"||t.includes("linux")?"linux":null}function t3(e){const t=e?.toLowerCase()??"";return t==="arm64"||t==="aarch64"?"arm64":t==="x64"||t==="x86_64"||t==="amd64"?"x64":null}function n3(e,t,n){const a=Y1(t),r=t3(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 a3(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(!e3(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=n3(s,e.platform,e.arch);return!l||!r?null:{version:a,releaseUrl:r,assetName:l.name,downloadUrl:l.downloadUrl}}const o3=3600*1e3,r3="https://api.github.com/repos/openpond/openpond/releases/latest";function i3(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&&!!Y1(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(r3,{headers:{Accept:"application/vnd.github+json"}});if(!h.ok)throw new Error(`GitHub release check failed: ${h.status}`);const b=await h.json(),y=a3({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()},o3);return()=>{l=!0,window.clearInterval(u)}},[i,a,s,r]),t}const Q1="openpond.sidebar.continuous-learning.dismissed.v1";function sy(e=X1()){if(!e)return!1;try{return e.getItem(Q1)==="true"}catch{return!1}}function s3(e=X1()){if(e)try{e.setItem(Q1,"true")}catch{}}function X1(){return typeof window>"u"?null:Kl}function l3({connection:e,onOpenSettings:t}){const[n,a]=g.useState(null),[r,i]=g.useState(sy);Vl(()=>i(sy()));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 S.jsxs("section",{className:"sidebar-learning-notice","aria-label":"Continuous learning",children:[S.jsxs("header",{children:[S.jsx("strong",{children:"Continuous learning"}),S.jsxs("div",{className:"sidebar-learning-notice-actions",children:[S.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Open Continuous learning settings",onClick:t,type:"button",children:S.jsx(ng,{size:14})}),S.jsx("button",{className:"sidebar-learning-notice-action","aria-label":"Close continuous learning",onClick:()=>{i(!0),s3()},type:"button",children:S.jsx(rs,{size:14})})]})]}),S.jsxs("div",{className:"sidebar-learning-status",children:[S.jsx("strong",{children:"Refiner"}),S.jsx("span",{children:n.backgroundReview.enabled?"On":"Off"})]}),S.jsxs("div",{className:"sidebar-learning-status",children:[S.jsx("strong",{children:"Continuous Review"}),S.jsx("span",{children:m})]})]})}function c3(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:O,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}=e,j=g.useCallback(z=>{n(!1),b(z)},[b]),x=g.useCallback(z=>{n(z),z&&b(null)},[b]),C=i3({currentVersion:i,platform:h,arch:r,enabled:Yd()}),A=C.status==="available"?C.update:null;return S.jsxs("aside",{className:"sidebar",children:[S.jsxs("div",{className:"sidebar-toolbar",children:[S.jsx("button",{className:"sidebar-icon","aria-label":"Hide sidebar",onClick:()=>E(!1),children:S.jsx(x1,{size:16})}),S.jsx(J4,{value:l,onChange:m}),A&&S.jsxs("button",{type:"button",className:"sidebar-update-pill",title:`Download OpenPond ${A.version}: ${A.assetName}`,"aria-label":`Download OpenPond ${A.version}`,onClick:()=>{d3(A.downloadUrl)},children:[S.jsx(bF,{size:14}),S.jsx("span",{children:"Update"})]})]}),S.jsx(y5,{productArea:l,experience:s,beginNewChat:a,setSectionMenuOpen:j,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:O,view:P,modelProjects:L,modelTrainingActivityByProjectId:$}),l==="models"?null:S.jsx(K4,{...e,setSectionMenuOpen:j}),S.jsxs("div",{className:"sidebar-bottom-stack",children:[l==="models"?null:S.jsx(l3,{connection:e.connection,onOpenSettings:()=>{b(null),sn({kind:"settings",section:"harness"})}}),S.jsxs("div",{className:"sidebar-footer-row",children:[S.jsx(X4,{account:e.account,open:t,organizations:e.organizations,selectedTeamId:e.teamChatOrganization?.teamId??null,onOpenChange:x,onOpenActivity:()=>{b(null),sn({kind:"settings",section:"usage"})},onOpenSettings:()=>{b(null),sn({kind:"settings",section:"account"})},onSelectTeam:e.onSelectTeam,onLogOut:e.onLogOut}),S.jsx(S5,{setSectionMenuOpen:j,setSelectedAppId:y,setSelectedProjectId:w,setSelectedSessionId:_,setView:O,view:P})]})]}),S.jsx("div",{className:"sidebar-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:u})]})}async function d3(e){const t=window.openpond?.browser;t?.openExternal&&(await t.openExternal({conversationId:"openpond-update",url:e})).ok||window.open(e,"_blank","noopener,noreferrer")}const u3=[/^(?:(?:type)?error:\s*)?failed to fetch\.?$/i,/^networkerror when attempting to fetch resource\.?$/i,/^load failed\.?$/i];function eI(e,t="Something went wrong."){const a=(e instanceof Error?e.message:String(e??"")).trim();return a?tI(a)?"Couldn’t connect to OpenPond.":a:t}function tI(e){const t=e.trim();return u3.some(n=>n.test(t))}const nI=g.createContext(null);function ly({children:e,showToast:t}){return S.jsx(nI.Provider,{value:t,children:e})}function m3(){return g.useContext(nI)}function cy(e,t={}){const n=m3(),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?": ":""}${eI(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 p3({state:e,onClose:t,onOpenBrowserUrl:n,onStart:a}){if(cy(e?.previewError,{prefix:"Upload preview"}),cy(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 S.jsx("div",{className:"git-dialog-backdrop",role:"presentation",children:S.jsxs("section",{className:"git-dialog cloud-setup-dialog",role:"dialog","aria-modal":"true","aria-label":"Set up Cloud coding",children:[S.jsx("button",{className:"git-dialog-close",disabled:r,type:"button",onClick:t,"aria-label":"Close Cloud setup",title:"Close",children:S.jsx(rs,{size:14})}),S.jsx("div",{className:"git-dialog-icon",children:i?S.jsx(Xp,{size:18}):S.jsx(Zd,{size:18})}),S.jsx("h2",{children:i?"Cloud repo ready":"Set up Cloud coding"}),S.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."}),S.jsxs("div",{className:"cloud-setup-summary",children:[S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Project"}),S.jsx("strong",{children:e.projectName})]}),S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Source"}),S.jsx("strong",{children:l?"OpenPond Git":"Local project upload"})]}),S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Branch"}),S.jsx("strong",{children:m?.branch??e.branch??"main"})]}),!l&&S.jsxs("div",{className:"git-dialog-row",children:[S.jsx("span",{children:"Cloud project"}),S.jsx("strong",{children:m?.targetProjectId??e.cloudProjectId??"New on upload"})]})]}),!i&&!l&&S.jsx("div",{className:"cloud-setup-upload-preview",role:"status","aria-live":"polite",children:e.previewLoading?S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:"Calculating upload preview"}),S.jsx("span",{children:"Checking tracked and unignored files before anything is pushed."})]}):e.previewError?S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:"Preview unavailable"}),S.jsx("span",{children:"Close and reopen setup to try the preview again."})]}):m?S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:m.initializedEmptyProject?"Will initialize an empty project":`Will upload ${m.fileCount} files`}),S.jsx("span",{children:dy({byteCount:m.byteCount,skippedCount:m.skippedCount,headCommit:m.headCommit,targetProjectName:m.targetProjectName})})]}):S.jsxs(S.Fragment,{children:[S.jsx("strong",{children:"Upload preview pending"}),S.jsx("span",{children:"File count, byte count, and skipped files will appear here before upload."})]})}),r&&S.jsxs("div",{className:"cloud-setup-progress",role:"status","aria-live":"polite",children:[S.jsx(NF,{className:"cloud-setup-spinner",size:16}),S.jsx("span",{children:"Uploading source to OpenPond Git..."})]}),i&&e.upload&&S.jsxs("div",{className:"cloud-setup-upload-result",children:[S.jsx("strong",{children:e.upload.initializedEmptyProject?"Initialized empty project":`Uploaded ${e.upload.fileCount} files`}),S.jsx("span",{children:dy({byteCount:e.upload.byteCount,skippedCount:e.upload.skippedCount,headCommit:e.upload.headCommit,targetProjectName:e.upload.branch})})]}),i&&e.setupUrl&&S.jsxs("div",{className:"cloud-setup-next",children:[e.projectUrl?S.jsxs("span",{children:["Your repo is ready here:"," ",S.jsxs("a",{href:e.projectUrl,target:"_blank",rel:"noreferrer",onClick:u=>np(u,e.projectUrl,n,{newTab:!0}),children:["Project page",S.jsx(Gm,{size:13})]})]}):S.jsx("span",{children:"Your repo is ready. Next step:"}),S.jsxs("a",{href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>np(u,e.setupUrl,n),children:["Setup the Cloud sandbox",S.jsx(Gm,{size:13})]})]}),S.jsxs("div",{className:"git-dialog-footer",children:[S.jsx("button",{className:"git-dialog-secondary",disabled:r,type:"button",onClick:t,children:i?"Done":"Cancel"}),i?e.setupUrl?S.jsxs("a",{className:"git-dialog-primary cloud-setup-primary-link",href:e.setupUrl,target:"_blank",rel:"noreferrer",onClick:u=>np(u,e.setupUrl,n),children:["Open setup",S.jsx(Gm,{size:13})]}):null:S.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 np(e,t,n,a={}){!t||!n||(e.preventDefault(),n(t,a))}function f3(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 dy({byteCount:e,skippedCount:t,headCommit:n,targetProjectName:a}){const r=[f3(e),`${t} skipped`],i=h3(n);return i&&r.push(`local ${i}`),r.push(a),r.join(" · ")}function h3(e){const t=e?.trim();return t?t.slice(0,7):null}const g3=g.lazy(()=>Dr(()=>import("./CommandMenu-B-DEtpTp.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(e=>({default:e.CommandMenu}))),v3=g.lazy(()=>Dr(()=>import("./SettingsView-ZPnupcpg.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}))),b3=g.lazy(()=>Dr(()=>import("./NewProjectDialog-CQSipZ5d.js"),__vite__mapDeps([26,1,2,8,15]),import.meta.url).then(e=>({default:e.NewProjectDialog}))),y3=g.lazy(()=>Dr(()=>import("./WorkspaceGitDialogs-Ck8BzH11.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.CommitDialog}))),S3=g.lazy(()=>Dr(()=>import("./WorkspaceGitDialogs-Ck8BzH11.js"),__vite__mapDeps([27,1,2,13,14,28,25]),import.meta.url).then(e=>({default:e.BranchDialog})));function x3({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:O,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:j,diffPanelExpanded:x,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A}){return S.jsx(g.Suspense,{fallback:null,children:S.jsx(v3,{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:O,onTeamChatNotificationModeChange:P,onTeamChatThreadMuteChange:L,diffPanelWidth:$,diffPanelResizing:j,diffPanelExpanded:x,onDiffPanelResizeStart:C,onDiffPanelExpandedChange:A})})}function k3({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:O,query:P,searchOpen:L,visibleWorkspaceDiff:$,visibleWorkspaceState:j,workspaceBusy:x,appDispatch:C,beginNewChat:A,openDefaultsSettingsFromBranchDialog:z,setBranchDialogName:q,setBranchDialogOpen:N,setCommitDialogOpen:K,setCommitDraft:de,setCommitIncludeUnstaged:te,setCommitMessage:Ie,setCommitNextStep:Se,setNewProjectDialogOpen:Z,setNewProjectName:Pe,setNewProjectPath:ge,setQuery:ce,setSearchOpen:be,submitCommitDialog:ne,submitCreateWorkspaceBranch:he,submitNewProjectDialog:ke}){return S.jsxs(S.Fragment,{children:[L&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(g3,{open:L,query:P,projects:O,sessions:e,onQueryChange:ce,onClose:()=>{be(!1),ce("")},onNewChat:()=>{be(!1),ce(""),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&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(b3,{open:b,mode:w,name:_,path:E,directory:y,busy:h,onNameChange:Pe,onPathChange:ge,onClose:()=>{h||Z(!1)},onSubmit:ke})}),a&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(y3,{open:a,branch:j?.currentBranch??null,filesChanged:$?.filesChanged??j?.changedFilesCount??0,additions:$?.additions??0,deletions:$?.deletions??0,message:s,includeUnstaged:i,nextStep:l,draft:r,busy:x,canPush:!!j?.remoteUrl,canPublish:m,onMessageChange:Ie,onIncludeUnstagedChange:te,onNextStepChange:Se,onDraftChange:de,onClose:()=>{x||K(!1)},onSubmit:ne})}),n&&S.jsx(g.Suspense,{fallback:null,children:S.jsx(S3,{open:n,branchName:t,busy:x,onBranchNameChange:q,onSetPrefix:z,onClose:()=>{x||N(!1)},onSubmit:he})})]})}function aI({toast:e,onDismiss:t}){if(!e)return null;const n=!!(e.actionLabel&&e.onAction),a=!!(e.persistent||e.dismissible);return S.jsxs("div",{className:`app-toast ${e.tone} ${e.placement??"bottom-right"}`,role:e.tone==="error"?"alert":"status","aria-live":"polite",children:[S.jsx("span",{className:"app-toast-message",children:e.message}),(n||a)&&S.jsxs("div",{className:"app-toast-actions",children:[n&&S.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"?S.jsx(ng,{size:15}):e.actionLabel}),a&&S.jsx("button",{type:"button",className:"app-toast-close","aria-label":"Dismiss notification",onClick:t,children:S.jsx(rs,{size:14})})]})]})}var uy=M_();const Wl=g.createContext(null);function w3({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 S.jsx(Wl.Provider,{value:i,children:e})}function rJ({children:e}){return S.jsx(Wl.Provider,{value:null,children:e})}function I3({children:e,className:t=""}){const n=g.useContext(Wl);return S.jsx("div",{ref:n?.setTitle,className:`page-chrome-title-target ${t}`,children:e?S.jsx("div",{className:"page-chrome-fallback",children:e}):null})}function _3({className:e=""}){const t=g.useContext(Wl);return S.jsx("div",{ref:t?.setActions,className:e})}function iJ({title:e,actions:t,fallback:n,children:a}){const r=g.useContext(Wl);return r?S.jsxs(S.Fragment,{children:[r.title?uy.createPortal(S.jsx("div",{className:"page-chrome-title",children:e}),r.title):null,r.actions&&t?uy.createPortal(t,r.actions):null,a]}):n??S.jsxs("header",{children:[e,t]})}async function C3(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 R3({activeView:e,onDiscoverCommunities:t,onOpenTeamChat:n}){return S.jsxs("div",{className:"titlebar-collaboration-actions",children:[S.jsx("button",{type:"button",className:`titlebar-icon${e==="team"?" active":""}`,"aria-label":"Team chat",title:"Team chat",onClick:n,children:S.jsx(Jd,{size:16})}),S.jsx("button",{type:"button",className:`titlebar-icon${e==="community"?" active":""}`,"aria-label":"Discover communities",title:"Discover communities",onClick:t,children:S.jsx(S1,{size:16})})]})}const P3=g.lazy(()=>Dr(()=>import("./WorkspaceEnvironmentMenu-7DSF_BpI.js"),__vite__mapDeps([29,1,2,21,10,14,5,30,28,31]),import.meta.url).then(e=>({default:e.WorkspaceEnvironmentMenu})));function A3({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:O,diffPanelOpen:P,terminalOpen:L,rightSidebarAvailable:$=!1,rightSidebarOpen:j=!1,onToggleDiffPanel:x,onToggleRightSidebar:C,onOpenSearch:A,onToggleTerminal:z,onRunTerminalCommand:q,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:Se,onOpenSandboxWorkspace:Z,onShowSidebar:Pe,onOpenTeamChat:ge,onDiscoverCommunities:ce,collaborationView:be=null,platform:ne,showWorkspaceControls:he=!0}){const ke=y?.filesChanged??0,qe=Yd()&&!og(ne),xe=!!(ge||ce)||he||$||qe,[re,we]=g.useState(null);g.useEffect(()=>{if(!re)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)}},[re]);const je=Ge=>{Ge.preventDefault(),Ge.stopPropagation();const st=190,Ue=n?76:42;we({x:Math.min(Ge.clientX,window.innerWidth-st-8),y:Math.min(Ge.clientY,window.innerHeight-Ue-8)})},Ze=Ge=>{C3(Ge),we(null)};return S.jsxs("header",{className:"app-titlebar",children:[S.jsxs("div",{className:"titlebar-left",children:[!e&&S.jsx("button",{className:"titlebar-icon",title:"Show sidebar",onClick:Pe,children:S.jsx(x1,{size:16})}),r?S.jsx("button",{className:"titlebar-icon",type:"button","aria-label":r.label,title:r.label,onClick:r.onSelect,children:S.jsx(eF,{size:16})}):null,S.jsx(I3,{children:a?.length?S.jsx("nav",{className:"titlebar-breadcrumbs","aria-label":"Breadcrumb",children:a.map((Ge,st)=>{const Ue=st===a.length-1;return S.jsxs("div",{className:"titlebar-breadcrumb-item",children:[Ge.onSelect&&!Ue?S.jsx("button",{type:"button",onClick:Ge.onSelect,children:Ge.label}):S.jsx("strong",{children:Ge.label}),!Ue&&S.jsx(Nr,{size:14})]},`${Ge.label}-${st}`)})}):S.jsxs("div",{className:"titlebar-title",children:[S.jsx("strong",{className:"titlebar-copy-target",title:"Double-click to select; right-click for copy options",onContextMenu:je,children:t}),i&&S.jsx("span",{children:i})]})})]}),xe&&S.jsxs("div",{className:"titlebar-right",children:[S.jsx(_3,{className:"page-chrome-actions"}),S.jsx(R3,{activeView:be,onDiscoverCommunities:ce,onOpenTeamChat:ge}),he&&S.jsxs("div",{className:"titlebar-actions",children:[S.jsx(g.Suspense,{fallback:null,children:S.jsx(P3,{mode:"topbar",busy:l,workspaceState:m,workspaceId:s,workspaceKind:u,selectedApp:h,selectedProject:b,workspaceBusy:_,defaultTeamId:E,workspaceDiff:y,managedWorkspace:w,showDiffControls:O,diffPanelOpen:P,onToggleDiffPanel:x,onRunTerminalCommand:q,onWorkspaceToolAction:N,onOpenCommitDialog:K,onWorkspaceBranchChange:de,onWorkspaceBranchCreate:te,connection:Ie,onBootstrap:Se,onOpenSandboxWorkspace:Z})}),S.jsx("button",{type:"button",className:"titlebar-icon",title:"Search chats and projects","aria-label":"Search chats and projects",onClick:A,children:S.jsx(JF,{size:16})}),S.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:S.jsx(w1,{size:16})}),O&&S.jsx("button",{type:"button",className:`topbar-diff-button ${j?"active":""}`,title:`${j?"Hide":"Show"} sidebar${ke?`, ${ke} changed files`:""}`,"aria-label":`${j?"Hide":"Show"} sidebar`,"aria-pressed":j,onClick:x,children:S.jsx(ef,{size:16})})]}),$&&C&&!O?S.jsx("div",{className:"titlebar-actions",children:S.jsx("button",{type:"button",className:`topbar-diff-button ${j?"active":""}`,title:`${j?"Hide":"Show"} sidebar`,"aria-label":`${j?"Hide":"Show"} sidebar`,"aria-pressed":j,onClick:C,children:S.jsx(ef,{size:16})})}):null,S.jsx(r5,{platform:ne})]}),re&&S.jsxs("div",{className:"titlebar-copy-menu",role:"menu","aria-label":"Conversation title actions",style:{left:re.x,top:re.y},onPointerDown:Ge=>Ge.stopPropagation(),children:[S.jsx("button",{type:"button",role:"menuitem",onClick:()=>Ze(t),children:"Copy title"}),n&&S.jsx("button",{type:"button",role:"menuitem",onClick:()=>Ze(n),children:"Copy conversation ID"})]})]})}function T3(){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 E3({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 S.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:()=>t(!1),children:S.jsxs("section",{className:"git-dialog project-confirm-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":a,onMouseDown:i=>i.stopPropagation(),children:[S.jsx("h2",{id:n,children:e.title}),S.jsx("p",{id:a,children:e.body}),S.jsxs("div",{className:"git-dialog-footer",children:[S.jsx("button",{type:"button",className:"git-dialog-secondary",onClick:()=>t(!1),children:e.cancelLabel}),S.jsx("button",{type:"button",className:r,autoFocus:!0,onClick:()=>t(!0),children:e.confirmLabel})]})]})})}function M3(){const{confirmAction:e,confirmDialog:t,resolveConfirmDialog:n}=T3();return{confirmProjectAction:g.useCallback(r=>e({tone:"danger",...r}),[e]),projectConfirmDialog:t,resolveProjectConfirmDialog:n}}function j3({state:e,onResolve:t}){return S.jsx(E3,{state:e,onResolve:t})}const ud=new Map,O3=(e,t,n)=>{const a=ud.get(e)??{commits:0,maxActualDurationMs:0,totalActualDurationMs:0};a.commits+=1,a.maxActualDurationMs=Math.max(a.maxActualDurationMs,n),a.totalActualDurationMs+=n,ud.set(e,a)};function $3({children:e,id:t}){return S.jsx(g.Profiler,{id:t,onRender:O3,children:e})}typeof window<"u"&&(window.__OPENPOND_RENDER_COMMITS__={get:()=>Object.fromEntries([...ud.entries()].map(([e,t])=>[e,{...t}])),reset:()=>ud.clear()});const N3=g.lazy(()=>Dr(()=>import("./MainPane-DjnT-kvm.js").then(e=>e.M),__vite__mapDeps([32,1,2,13,33,6,30]),import.meta.url).then(e=>({default:e.MainPane})));function D3({className:e,style:t,sidebar:n,topBar:a,mainPane:r,cloudSetup:i,projectConfirm:s,lazyPanels:l,toast:m}){return S.jsx(w3,{children:S.jsxs("div",{className:e,style:t,children:[S.jsx($3,{id:"sidebar",children:S.jsx(c3,{...n})}),S.jsxs("div",{className:"content-shell",children:[S.jsx(A3,{...a}),S.jsx(g.Suspense,{fallback:S.jsx("main",{className:"main-pane","aria-busy":"true","aria-label":"Loading workspace"}),children:S.jsx(N3,{...r})})]}),S.jsx(p3,{...i}),S.jsx(j3,{...s}),S.jsx(k3,{...l}),S.jsx(aI,{...m})]})})}function L3({settings:e,toast:t}){return S.jsxs(S.Fragment,{children:[S.jsx(x3,{...e}),S.jsx(aI,{...t})]})}const Bc="OpenPond".split("");function U3({visibleLetterCount:e=Bc.length}){const t=Bc.slice(0,Math.max(0,Math.min(e,Bc.length)));return S.jsxs("div",{className:"app-splash-lockup",children:[S.jsx("div",{className:"app-splash-mark",children:S.jsx("img",{alt:"OpenPond",className:"app-splash-logo",decoding:"async",src:G4})}),S.jsx("span",{"aria-hidden":"true",className:`app-splash-wordmark${t.length>0?" is-visible":""}`,children:t.map((n,a)=>S.jsx("span",{className:"app-splash-letter",children:n},`${n}-${a}`))})]})}const ap=Bc.length,z3=520,H3=240;function my(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function q3({startup:e}){const[t,n]=g.useState(()=>my()?ap:0);return g.useEffect(()=>{if(my()){n(ap);return}const a=Array.from({length:ap},(r,i)=>window.setTimeout(()=>n(i+1),z3+H3*i));return()=>{a.forEach(r=>window.clearTimeout(r))}},[]),S.jsxs("main",{className:"app-splash","aria-busy":"true","aria-label":e.label,role:"status",children:[S.jsx(U3,{visibleLetterCount:t}),S.jsx("span",{className:"app-splash-status",children:e.label})]})}const Sg=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=Sg){return Fc(Co(e,t),n)}function Fc(e,t=Sg){return e.length<=t?e:e.slice(e.length-t)}function B3(e,t,n){return n.length===0?e:{...e,[t]:Co(e[t]??[],n)}}function F3(e,t){if(t.length===0)return Fc(e);if(e.length===0)return Fc(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 Fc([...n.values()].sort((r,i)=>K3(r,i)).map(({event:r})=>r))}function md(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 V3(e){let t=null;for(const n of e)n.sequence!==void 0&&(t===null||n.sequence<t)&&(t=n.sequence);return t}function K3(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 W3(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 G3(e){return e==="codex"}function Z3(e){return e==="openpond"}function oI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="session.context.updated")continue;const a=hj.safeParse(n.data);if(a.success)return a.data}return null}function rI(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:W3(r)}}if(G3(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(!Z3(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 xg(e){let t=!1;const n=iI(e);for(let a=e.length-1;a>=0;a-=1){const r=e[a];if(J3(r)){t=!0;continue}const i=Gi(r?.data);if(!(r?.name!=="diagnostic"||!i)){if(i.kind==="thread_goal_cleared")return null;if(i.kind==="thread_goal"){const s=kg(Gi(i.goal),Wn(i.provider),n);if(s){const l=_l(s);return t&&l.tone==="active"?null:l}}if(i.kind==="goal_context"){const s=lI(r.output??"",Wn(i.provider)??"codex",n);if(s){const l=_l(s);return t&&l.tone==="active"?null:l}}}}return null}function pd(e){const t=iI(e);for(let n=e.length-1;n>=0;n-=1){const a=e[n],r=Gi(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=kg(Gi(r.goal),Wn(r.provider),t);if(!i)continue;const s=_l(i);return s.tone==="active"?s:null}if(r.kind==="goal_context"){const i=lI(a.output??"",Wn(r.provider)??"codex",t);if(!i)continue;const s=_l(i);return s.tone==="active"?s:null}}}return null}function op(e){const t=Gi(Gi(e)?.codexGoalRuntime),n=kg(t,Wn(t?.provider)??"codex");if(!n)return null;const a=_l(n);return a.tone==="active"?a:null}function J3(e){return e?.name==="turn.completed"||e?.name==="turn.interrupted"||e?.name==="turn.failed"}function _l(e){const t=cI(e.status),n=mI(e.timeUsedSeconds),a=`Goal ${n}`,r=e.tokensUsed===null?null:e.tokenBudget===null?`${rp(e.tokensUsed)} tokens`:`${rp(e.tokensUsed)} / ${rp(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: ${pI(e.timeUsedSeconds)}. ${i}. ${e.objective}`,tone:t.tone,observedAt:e.observedAt}}function Y3(e,t){if(!e||e.tone!=="active"||!e.observedAt)return e;const n=sI(e.observedAt,t);if(n<=0)return e;const a=e.timeUsedSeconds+n,r=mI(a);return{...e,timeUsedSeconds:a,timeLabel:r,label:`Goal ${r}`,tooltip:`Goal runtime: ${pI(a)}. ${e.detail}. ${e.objective}`,observedAt:t}}function kg(e,t=null,n=null){if(!e)return null;const a=Wn(e.objective)??"Active goal",r=Wn(e.status)??"active";if((mf(t)??mf(Wn(e.provider)))!=="codex")return null;const s=n??Wn(e.updatedAt)??Wn(e.updated_at)??null,l=bi(e.timeUsedSeconds)??bi(e.time_used_seconds)??0,m=Wn(e.activeSinceAt)??Wn(e.active_since_at),u=cI(r).tone==="active"?sI(m??Wn(e.createdAt)??Wn(e.created_at),s):0,h=m?l+u:Math.max(l,u),b=bi(e.tokensUsed)??bi(e.tokens_used),y=bi(e.tokenBudget)??bi(e.token_budget);return{objective:a,status:r,statusLabel:uI(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 iI(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 sI(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 lI(e,t=null,n=null){if(!e.trim()||mf(t)!=="codex")return null;const a=dI(e,"Status")??"active",r=Ws(e,"Tokens used"),i=Ws(e,"Token budget"),s=Ws(e,"Time used seconds")??Ws(e,"Time spent pursuing goal")??Ws(e,"Elapsed seconds")??0;return{objective:hy(e,"objective")??hy(e,"untrusted_objective")??"Active goal",status:a,statusLabel:uI(a),timeUsedSeconds:Math.max(0,Math.floor(s)),tokensUsed:r,tokenBudget:i,observedAt:n}}function cI(e){switch(Q3(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 Q3(e){return e.trim().toLowerCase().replace(/[-\s]+/g,"_")}function dI(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^\\s*-?\\s*${n}:\\s*(.+?)\\s*$`,"im").exec(e)?.[1]?.trim()||null}function Ws(e,t){const n=dI(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 uI(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function mI(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 pI(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 rp(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 Gi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Wn(e){return typeof e=="string"&&e.trim()?e.trim():null}function mf(e){return e?.trim().toLowerCase()||null}function bi(e){return typeof e=="number"&&Number.isFinite(e)?e:null}const X3=new Set(["planning","applying_source","running_checks","evaluating","pushing_hosted","running_hosted_checks"]),e6=new Set(["awaiting_questions","awaiting_plan_approval","paused"]);function pf(e){const t=fI(e);return t?o6(t):null}function fI(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n?.name!=="create_improve.updated")continue;const a=a6(c6(n.data));if(a)return a}return null}function t6(e){if(e.events)return fI(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 n6(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 a6(e){const t=jl.safeParse(e?.createImproveRun);return t.success?t.data:null}function o6(e){const t=r6(e);if(!t)return null;const n=i6(e.createdAt,e.updatedAt),a=e.blockedReason??s6(e.state);return{objective:e.objective,status:e.state,timeUsedSeconds:n,tokensUsed:null,tokenBudget:null,actionLabel:t.actionLabel,timeLabel:l6(n),label:t.actionLabel,detail:a,tooltip:`${t.actionLabel}: ${a}. ${e.objective}`,tone:t.tone}}function r6(e){const t=e.state,n=e.target.kind==="agent"?"Agent":"Work";return X3.has(t)?{tone:"active",actionLabel:`${n} running`}:e6.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 i6(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 s6(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function l6(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 c6(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hI(e,t){if(!t)return null;const n=new Map,a=[];for(const j of e){if(!j.name.startsWith("subagent."))continue;const x=m6(j);x&&a.push(x);const C=u6(j);C?.parentSessionId===t&&n.set(C.id,C)}if(n.size===0)return null;const r=[...n.values()].sort((j,x)=>Si(x).localeCompare(Si(j))),i=r.filter(j=>j.status==="queued"||j.status==="running"),s=r.filter(j=>j.status==="completed"),l=r.filter(j=>j.status==="failed"),m=r.filter(j=>j.status==="cancelled"),u=r.filter(j=>j.status==="needs_resume"),h=[...s,...l,...m].sort((j,x)=>Si(x).localeCompare(Si(j))),b=r.reduce((j,x)=>{const C=Zi(x.metadata?.usage);return j.totalTokens+=Cc(C?.totalTokens),j.promptTokens+=Cc(C?.promptTokens),j.completionTokens+=Cc(C?.completionTokens),j.requestCount+=Cc(C?.requestCount),j},{totalTokens:0,promptTokens:0,completionTokens:0,requestCount:0}),y=r.flatMap(j=>gI([...j.report?.blockers??[],j.error,j.progress.currentBlocker]).map(x=>({runId:j.id,roleId:j.roleId,status:j.status,message:x}))),w=r.flatMap(j=>vI([...j.report?.artifacts??[],j.report?.patchRef,j.report?.diffRef,...j.progress.patchRefs]).map(x=>({...x,runId:j.id,roleId:j.roleId}))),_=h.map(j=>d6(j,a)),E=r[0]??null,O=E?{runId:E.id,roleId:E.roleId,status:E.status,message:E.progress.latestMeaningfulActivity||E.report?.summary||E.objective,updatedAt:Si(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(" · "),$=O?`${h6(O.roleId)}: ${O.message}`:"";return{sessionId:t,runs:r,activeRuns:i,completedRuns:s,failedRuns:l,cancelledRuns:m,needsResumeRuns:u,terminalRuns:h,latestRun:E,latestMeaningfulUpdate:O,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((j,x)=>j+x.progress.validationAttempts.length,0),label:P,tooltip:[L,$].filter(Boolean).join(". ")}}function d6(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:vI([...e.report?.artifacts??[],e.report?.patchRef,e.report?.diffRef]),testsRun:e.report?.testsRun??[],validationAttempts:e.progress.validationAttempts.map(n=>n.command),blockers:gI([...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:p6(e),updatedAt:Si(e)}}function u6(e){const t=Zi(e.data),n=[t?.run,Zi(t?.message)?.run];for(const a of n){const r=PS.safeParse(a);if(r.success)return r.data}return null}function m6(e){const t=$E.safeParse(Zi(e.data)?.message);return t.success?t.data:null}function p6(e){const t=Zi(Zi(e.metadata?.workspaceHandoff)?.workspaceRetention);return t?.status!=="retained"?null:{status:"retained",reason:_c(t.reason),retainedAt:_c(t.retainedAt),expiresAt:_c(t.expiresAt),retentionDays:f6(t.retentionDays),trigger:_c(t.trigger),cleanupAfterExpiry:t.cleanupAfterExpiry===!0}}function Si(e){return e.updatedAt??e.completedAt??e.startedAt??e.createdAt}function gI(e){return[...new Set(e.map(t=>t?.trim()).filter(t=>!!t))]}function vI(e){const t=new Map;for(const n of e)n&&t.set(`${n.kind}:${n.id}`,n);return[...t.values()]}function Zi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function _c(e){return typeof e=="string"&&e.trim()?e.trim():null}function Cc(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function f6(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function h6(e){return e.slice(0,1).toUpperCase()+e.slice(1).replace(/[-_]+/g," ")}const ff=[];function hf(e,t){return bI(e,t,null)}function bI(e,t,n){const a=n&&S6(n.events,e)?v6(n.indexes,n.events.length,e):g6(e),r=y6(t);return{...a,...r}}function g6(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 b6(t)}function v6(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)??ff,y=oI(b);y?r.set(h,y):r.delete(h);const w=SI(b);w?(i.set(h,w),w.tone==="active"?l.add(h):l.delete(h)):(i.delete(h),l.delete(h));const _=hI(b,h);_?(s.set(h,_),yI({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 b6(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=oI(l);m&&t.set(s,m);const u=SI(l);u&&(n.set(s,u),u.tone==="active"&&r.add(s))}for(const[s,l]of e){const m=hI(l,s);m&&(a.set(s,m),yI({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 yI(e){if(e.latestGoalRuntimeBySessionId.has(e.sessionId))return;const t=pd(e.sessionEvents);t&&(e.latestGoalRuntimeBySessionId.set(e.sessionId,t),t.tone==="active"&&e.activeGoalSessionIds.add(e.sessionId))}function SI(e){return pf(e)??xg(e)??pd(e)}function y6(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 S6(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 Gl(e,t){return t?e.eventsBySessionId.get(t)??ff:ff}function xI(e,t){return t?e.latestContextUsageBySessionId.get(t)??null:null}function kI(e,t){return t?e.latestGoalRuntimeBySessionId.get(t)??null:null}function x6(e,t){return t?e.latestSubagentRuntimeBySessionId.get(t)??null:null}function k6(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 w6(e,t){return e?.conversationId===t}function I6(e,t){return e?.id===t?null:e}function _6(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 C6(e){return JSON.stringify([e.source,e.repositoryId,e.profileId])}function sJ(e,t){return e.profiles.find(n=>C6(n.ref)===t)?.ref??null}function R6(e,t){return!!(e&&t&&e.source===t.source&&e.repositoryId===t.repositoryId&&e.profileId===t.profileId)}function lJ(e,t){return e.profiles.find(n=>R6(n.ref,t))?.state??null}function P6(e,t){const n=new Map(wO.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 A6(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 cJ(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 wI="openpond:last-chat-task-mode";function T6(e,t){return e==="labs"?"models":"chat"}function E6(e){try{return e.getItem(wI)==="work"?"work":"chat"}catch{return"chat"}}function wg(){if(typeof window>"u")return"chat";try{return E6(Kl)}catch{return"chat"}}function M6(e,t){try{e.setItem(wI,t==="chat"?"chat":"work")}catch{}}function j6(e){if(!(typeof window>"u"))try{M6(Kl,e)}catch{}}const O6="uploaded to a different account";function II(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 ya(e,t){const n=II(e,t);return n.state==="confirmed"?n.cloudProject:null}function $6(e,t){return II(e,t).state==="different_account"?O6:null}function lo(e){return e==="sandbox"||e==="sandbox_template"||e==="sandbox_app"}function _I(e={}){return{...e,workspaceTarget:"hybrid"}}function N6(e={}){return{...e,workspaceTarget:"local"}}function co(e){return e?.metadata?.workspaceTarget==="hybrid"}function D6(e){return!!(e&&e.provider==="openpond"&&e.workspaceKind==="local_project"&&e.cloudProjectId&&e.title.trim().endsWith(" Cloud"))}function CI({cloudProjects:e,selectedCloudProject:t,selectedProject:n}){const a=n?.linkedSandboxProject??null,r=e?ya(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 RI({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:_I(),cwd:n.cwd,title:a}}function L6(e){return g.useEffect(()=>{const t=L1(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=$5(n);try{let r;const i=e.selectedSession;if(i&&wl(i))r=await J.patchSession(e.connection,i.id,{title:a,metadata:ep(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:zi}:{providerId:l,modelId:e.activeModel}),u=s?{workspaceTarget:s}:!i&&e.workspaceTarget==="local"?{workspaceTarget:"local"}:{};let h;if(!i&&e.workspaceTarget==="hybrid"){const b=CI({cloudProjects:e.cloudProjects,selectedCloudProject:e.selectedCloudProject,selectedProject:e.selectedProject});if(b.kind!=="ready")throw new Error(b.message);const y=RI({modelRef:m,provider:l,target:b,title:a});h={...y,experience:"work",metadata:ep(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:ep(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 U6=[];function z6({primary:e,secondary:t}){const[n,a]=g.useState(!1),r=b5(),{composerDraftStore:i,appDispatch:s,pendingTerminalCommand:l,setPendingTerminalCommand:m,terminalTabs:u,setTerminalTabs:h,trainingDetailTasksetId:b,setTrainingDetailTasksetId:y,mentionedAppId:w,setMentionedAppId:_,cloudSetupDialog:E,setCloudSetupDialog:O,rightPanelTabRequest:P,workspaceDiffPanelViewState:L,mainComposerFocusRequestId:$,requestMainComposerFocus:j,projectConfirmDialog:x,resolveProjectConfirmDialog:C,query:A,searchOpen:z,archivedChatsOpen:q,sectionMenuOpen:N,cloudProjectsExpanded:K,sidebarOpen:de,view:te,selectedAppId:Ie,selectedProjectId:Se,selectedSessionId:Z,codexPermissionMode:Pe,codexReasoningEffort:ge,busy:ce,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:he,activeExperience:ke,changeNewExperience:qe,terminalOpen:xe,settingsSection:re,newProjectDialogOpen:we,newProjectMode:je,newProjectName:Ze,newProjectPath:Ge,newProjectBusy:st,commitDialogOpen:Ue,commitMessage:Ve,commitIncludeUnstaged:Le,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:Fe,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setPrompt:ie,setDraftProvider:F,setDraftModel:I,setDraftExperience:W,setDiffPanelOpen:X,setDiffPanelExpanded:ae,setRightPanelMode:G,setTerminalOpen:pe,setSettingsSection:fe,setNewProjectDialogOpen:Oe,setNewProjectName:Ee,setNewProjectPath:Ne,setCommitDialogOpen:Ke,setCommitMessage:ze,setCommitIncludeUnstaged:ut,setCommitNextStep:Qt,setCommitDraft:Lt,setBranchDialogOpen:An,setBranchDialogName:Sn,setError:nn,showToast:bt,applyBootstrapPayload:rn,bootstrap:Nt,connection:yt,startup:un,training:Ut,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Na,sidebarWidth:Da,sidebarResizing:qt,diffPanelWidth:qn,diffPanelResizing:ot,togglePinnedCollapsed:xn,toggleCloudProjectsCollapsed:La,toggleChatsCollapsed:Ua,toggleSavedForLaterCollapsed:ia,startSidebarResize:za,startDiffPanelResize:oe,selectedApp:De,selectedCloudProject:Be,selectedProject:Je,selectedProjectLinkedApp:At,selectedSession:gt,sidebarSessions:lt,runtimeIndexes:_t,runtimeEventStore:sa,chatMentionApps:Bn,connectedAppMentions:tt,pendingApproval:_n,pendingChatUserMessages:St,account:kn,activeModel:$n,activeProvider:Tn,appDefaults:Ha,startMessage:ka,organizations:uo,teamChatOrganization:qa,teamChatTeamId:ea,teamChat:xt,publishTeamProfileAgent:Ba,communitySidebar:la,communityView:Kr,teamAiThreadId:mr,toggleTeamAiSidebar:pr,activeOpenPondCommandAccessMode:mo,viewWorkspaceAppId:Wr,viewWorkspaceId:Gr,viewWorkspaceKind:Zr,viewWorkspaceName:Jr,selectedActionCatalog:is,expandedProjectIds:ss,expandProject:Fa,toggleProjectExpanded:ls,changeCodexPermissionMode:Yr,changeCodexReasoningEffort:Qr,changeOpenPondCommandAccessMode:Xr,resolveApproval:cs,beginNewChat:ta,beginNewChatWithTrainingModel:ds,dismissTrainingChatHandoff:us,trainingChatHandoff:ms,selectTrainingChatTaskForComposer:ei,chatHistoryLoadStates:ti,loadMoreSelectedChatHistory:ni,selectedPagedSessionEvents:ps,activeSessions:Va,archivedSessions:po,pinnedSessions:Fn,savedForLaterSessions:fs,savedForLaterFiles:hs,sidebarFileBookmarks:vn,setSidebarFileStatus:ai,setSessions:Vn,projectRows:wa,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:gs,childSessionRowsByParentId:vs,sidebarProjectIdBySessionId:ho,chatRows:fr,visibleChatRows:oi,chatRowsVisibleCount:hr,sessionEvents:ri,goalRuntime:gr,subagentRuntime:ii,visibleChatMessages:ca,activeTerminalScope:Fo,terminalSummaries:vr,runningSessionIds:go,selectedSessionRunning:si,sidebarGoalRuntimeBySessionId:Wa,sidebarSubagentRuntimeBySessionId:li,taskDragSessionId:bs,taskPreviewSessionIds:br,startTaskDrag:ci,clearTaskDrag:di,previewTaskDrop:ui,commitTaskDrop:ys,commitTaskPreviewDrop:yr,dragItem:mi,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:Ss,commitPinnedDrop:xs,commitPinnedPreviewDrop:ks,commandProjectRows:ws,contextWindowStatus:Ia,pinnedRows:pi,workspaceBusy:Sr,diffBusy:Is,visibleWorkspaceState:vo,visibleWorkspaceDiff:Nn,refreshVisibleWorkspaceDiff:_s,managedWorkspace:Cs,canSyncActiveWorkspace:Rs,canPublishOpenPondProject:Ps,projectTarget:mt,workspaceTarget:Bt}=e,{title:Kn,browserConversationId:pn,handleWorkspaceDiffPanelViewStateChange:na,openSessionInChat:En,changeProjectTarget:su,submitNewProjectDialog:lu,changeWorkspaceBranch:cu,openCommitDialog:As,openCreateWorkspaceBranchDialog:Jl,openDefaultsSettingsFromBranchDialog:du,runWorkspaceTool:uu,submitCommitDialog:mu,submitCreateWorkspaceBranch:pu,syncWorkspaceLocally:fu,answerCreateImproveQuestion:hu,applyCreateImproveCandidate:gu,approveCreateImproveRun:vu,cancelCreateImproveRun:bu,changeDraftProvider:Yl,openCreateImprovePullRequest:yu,reconcileCreateImprovePullRequest:Ql,rejectCreateImproveCandidate:Su,pauseCreateImproveRun:xu,resumeCreateImproveRun:ku,reviseCreateImproveRun:Xl,stopTurn:Ts,archiveSession:wu,restoreSession:Iu,renameSession:ec,toggleSessionPinned:tc,toggleProjectPinned:nc,toggleSessionSavedForLater:Es,moveProjectToCloud:_u,startCloudSetupUpload:ac,changeWorkspaceTarget:Cu,sendPromptFromMainComposer:Ms,openSandboxWorkspace:Ru,openCloudProjectDialog:oc,openUrlInBrowserPanel:Pu,showBrowserPanel:rc,showChangesPanel:Au,showGoalSidebarTab:Tu,rightChatTrainingLaunchRequest:ic,setRightChatTrainingLaunchRequest:Eu,closeRightChatPanel:Mu,openRightChatPanel:js,rightChatPanelViews:ju,showRightChatPanel:Ou,showRightPanelDiffTab:Ko,submitRightChatPrompt:sc,activateRightChatPanel:$u,updateRightChatModel:Nu,updateRightChatPrompt:Du,updateRightChatProvider:Lu,updateRightChatScrollState:Uu,openProfileSettings:zu,diagnosticEvents:Hu,toggleRightSidebar:lc,removeProject:qu}=t,fi=g.useCallback(Te=>{U(null),V(Te),le(null),p("chat"),Fa(Te),j()},[Fa,j,U,V,le,p]),Bu=g.useCallback((Te=null)=>{const ct=Z?ho[Z]??null:null;if(!Te&&ct){fi(ct);return}ta(Te)},[ta,fi,Z,ho]),Fu=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]),Vu=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]),Os=ea??Ha.defaultTeamId??null,Ku=g.useMemo(()=>wa.filter(Te=>Te.kind==="local"||Os!==null&&Te.project.teamId===Os),[wa,Os]),Wu=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 da=vt("cloud",Mt);Te[ct.id]=(Te[ct.id]??0)+(Te[da]??0)}return Te},[Va,fo,ho]),[$s,Ns]=g.useState(null),[Ds,Ls]=g.useState(null),Gu=P6(Nt?.profile,Nt?.extensionCatalog),[Us,zs]=g.useState(null),[Hs,cc]=g.useState(null),[Za,qs]=g.useState(null),dc=g.useCallback(()=>{U(null),V(null),le(null),rt(null),p("team")},[rt,U,V,le,p]),Zu=g.useCallback(()=>{U(null),V(null),le(null),rt(null),la.discoverCommunities()},[la.discoverCommunities,rt,U,V,le]),Bs=L6({activeExperience:ke,activeModel:$n,activeOpenPondCommandAccessMode:mo,activeProvider:Tn,cloudProjects:Nt?.cloudProjects??U6,composerDraftStore:i,connection:yt,requestComposerFocus:j,selectedCloudProject:Be,selectedProject:Je,selectedSession:gt,setMentionedAppId:_,setSelectedSessionId:le,setSessions:Vn,setView:p,showToast:bt,workspaceTarget:Bt.value}),Ju=g.useCallback(async Te=>{if(!yt)throw new Error("OpenPond is not connected.");let ct=Tn,Mt=$n;ct==="codex"&&(ct=df(Nt?.providers,{enabledOnly:!0}).find(bn=>bn.value!=="codex")?.value??jr,Mt=cd(ct,Nt?.providers)??pl);const da=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 ${da?.title??"task"}`.slice(0,120),metadata:{experienceHandoff:A6({sourceTaskId:Te.sourceSessionId,sourceExperience:da?.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),sn({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"),ae(!1),bo},[$n,mo,Tn,s,Nt?.providers,i,yt,ae,X,W,I,F,G,U,V,Vn,pe,p,lt]),uc=g.useCallback(Te=>{zs(Te),cc(null),ta(null),Fe(!0)},[ta,Fe]),Yu=g.useCallback(Te=>{ta(null),W("work"),i.set(`$openpond-refiner-authoring ${Te}`),p("chat"),Fe(!0)},[ta,i,W,Fe,p]),xr=g.useCallback(Te=>{cc(_6(Te)),zs(null),ta(null),Fe(!0)},[ta,Fe]);g.useEffect(()=>{!Us&&!Hs||te!=="chat"||Z||Se||Ie||(Ns(Us),Ls(Hs),zs(null),cc(null),G("home"),ae(!1),X(!0))},[Us,Hs,Ie,Se,Z,ae,X,G,te]),g.useEffect(()=>{!$s&&!Ds||te==="chat"&&be&&he==="home"||(Ns(null),Ls(null))},[be,Ds,$s,he,te]);const Qu=g.useCallback(()=>{Ns(null),Ls(null),ae(!1),X(!1)},[ae,X]),Xu=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(da=>da.id===Te.sourceSessionId||da.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),qs({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(!w6(Za,pn))return;const Te=window.setTimeout(()=>{G("changes"),X(!0),qs(ct=>I6(ct,Za.id))},0);return()=>window.clearTimeout(Te)},[pn,X,G,Za]);const em=T6(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 tm=g.useCallback(Te=>{if(rt(null),U(null),V(null),le(null),Te==="models"){Oi(ro()),p("labs");return}Te==="chat"&&sn({kind:"chat",sessionId:null}),qe(wg())},[qe,sn,rt,U,V,le,p]),nm=g.useCallback(async(Te,ct)=>{const Mt=await Ut.actions.acceptHarnessReview(Te,ct,{providerId:Tn,modelId:$n},ge);return Mt?(y(Mt.materializedTasksetId??null),Oi(ro()),p("labs"),!0):(bt("Taskset review could not be opened.","error"),!1)},[$n,Tn,ge,Oi,ro,y,p,bt,Ut.actions]);if(!un.ready)return S.jsx(q3,{startup:un});if(te==="settings")return S.jsx(ly,{showToast:bt,children:S.jsx(L3,{settings:{payload:Nt,connection:yt,diagnostics:Hu,initialSection:re,onPayload:rn,onError:nn,onToast:bt,onOpenSourceSession:En,onStartRefinerAuthoring:Yu,onAcceptEvaluationReview:nm,onOpenSkill:uc,onOpenExtension:xr,teamChatCurrentUserId:xt.currentUserId,teamChatEnabled:ea!==null,teamChatNotificationMode:xt.notificationMode,teamChatThreads:xt.threads,onTeamChatNotificationModeChange:xt.setNotificationMode,onTeamChatThreadMuteChange:xt.setThreadMuted,diffPanelWidth:qn,diffPanelResizing:ot,diffPanelExpanded:ne,onDiffPanelResizeStart:oe,onDiffPanelExpandedChange:ae,onBack:()=>{const Te=h5(r);sn(Te),p(Te.kind==="models"?"labs":"chat"),Fe(!0)}},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})});const am=Yd(),Fs=yt?.platform??navigator.platform,mc=am&&og(Fs),Vs=Fo,om=vo?.initialized?vo.repoPath:gt?.cwd??null,rm={"--sidebar-width":`${Da}px`,"--diff-panel-width":`${qn}px`},im=te==="chat"&&ke!=="chat"||te==="labs"||te==="scheduled"&&n||te==="team"&&!!mr,sm=["app-shell",mc?"platform-macos":"",de?"sidebar-open":"sidebar-closed",qt?"sidebar-resizing":"",ot?"diff-panel-resizing":""].filter(Boolean).join(" "),at=Z?ti[Z]:null,Xt=Z?at?.cursorSequence??V3(Io(ps,Gl(_t,Z))):null,Gt=!!Z&&!!yt&&(Ht(Z)?!0:!!Nt?.eventWindow?.hasMoreBefore&&!!Xt)&&(at?.hasMore??!0),_a=!!at?.loading,lm=(()=>{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"]),da={queued:"Queued",starting:"Starting",running:"Running",cancelling:"Cancelling",reconciling:"Reconciling"},bo={};for(const bn of[...Te.modelRuns].sort((Ca,hi)=>hi.updatedAt.localeCompare(Ca.updatedAt))){if(bn.kind==="evaluation"||!["prepared","running"].includes(bn.status))continue;const Ca=Te.jobs.filter(cm=>cm.metadata.modelRunId===bn.id).sort((cm,E_)=>E_.updatedAt.localeCompare(cm.updatedAt))[0];if(Ca&&!Mt.has(Ca.status))continue;const hi=Ca?.status??(bn.status==="prepared"?"starting":"running");bo[bn.modelId]={label:da[hi]??"Running",status:hi}}for(const bn of[...Te.jobs].sort((Ca,hi)=>hi.updatedAt.localeCompare(Ca.updatedAt))){if(!Mt.has(bn.status))continue;const Ca=ct.get(bn.planId)?.modelId;!Ca||bo[Ca]||(bo[Ca]={label:da[bn.status]??"Active",status:bn.status})}return bo})();return S.jsx(ly,{showToast:bt,children:S.jsx(D3,{className:sm,style:rm,sidebar:{productArea:em,modelProjects:(Ut.payload?.modelProjects??[]).filter(Te=>Te.hosted===null||Te.hosted.teamId===(Ha.defaultTeamId?.trim()??null)),modelTrainingActivityByProjectId:lm,onProductAreaChange:tm,experience:ke,view:te,selectedAppId:Ie,selectedProjectId:Se,selectedSessionId:Z,selectedTeamThreadId:xt.selectedThreadId,teamChatEnabled:ea!==null,organizations:uo,teamChatOrganization:qa,teamChatLoading:xt.loading,currentUserId:xt.currentUserId,teamMembers:xt.members,teamThreads:xt.threads,...la,account:kn,connection:yt,profile:Nt?.profile,pinnedCollapsed:mn,cloudProjectsCollapsed:On,chatsCollapsed:gn,savedForLaterCollapsed:Na,archivedChatsOpen:q,cloudProjectsExpanded:K,sectionMenuOpen:N,dragItem:mi,taskDragSessionId:bs,taskPreviewSessionIds:br,activeSessions:Va,archivedSessions:po,pinnedRows:pi,pinnedSessions:Fn,savedForLaterSessions:fs,savedForLaterFiles:hs,projectRows:wa,localProjectRows:fo,cloudProjectRows:Ka,projectSessionRowsByProjectId:gs,childSessionRowsByParentId:vs,sidebarProjectIdBySessionId:ho,terminalSummaries:vr,runningSessionIds:go,goalRuntimeBySessionId:Wa,subagentRuntimeBySessionId:li,visibleChatRows:oi,chatRows:fr,chatRowsVisibleCount:hr,expandedProjectIds:ss,currentVersion:Nt?.server.version??null,platform:Fs,arch:yt?.arch??null,onSidebarResizeStart:za,setSidebarOpen:Fe,setView:p,setSelectedAppId:U,setSelectedProjectId:V,setSelectedSessionId:le,setSearchOpen:Xe,setSectionMenuOpen:rt,setSettingsSection:fe,onSelectTeam:Fu,onLogOut:Vu,onTogglePinnedCollapsed:xn,onToggleCloudProjectsCollapsed:La,onToggleChatsCollapsed:Ua,onToggleSavedForLaterCollapsed:ia,setArchivedChatsOpen:et,setCloudProjectsExpanded:it,setChatRowsVisibleCount:Me,beginNewChat:Bu,beginProjectChat:fi,dockSessionRight:js,selectTeamThread:Te=>{p("team"),xt.selectThread(Te)},openTeamDm:Te=>{p("team"),xt.openDm(Te)},toggleSessionPinned:tc,toggleProjectPinned:nc,toggleSessionSavedForLater:Es,openSidebarFile:Xu,setSidebarFileStatus:(Te,ct)=>{ai(Te,ct)},archiveSession:wu,restoreSession:Iu,renameSession:ec,removeProject:qu,expandProject:Fa,toggleProjectExpanded:ls,startPinnedDrag:Vo,clearSidebarDrag:Ga,previewPinnedDrop:Ss,commitPinnedDrop:xs,commitPinnedPreviewDrop:ks,startTaskDrag:ci,clearTaskDrag:di,previewTaskDrop:ui,commitTaskDrop:ys,commitTaskPreviewDrop:yr},topBar:{sidebarOpen:de,title:Kn,backAction:_e.backAction,breadcrumbs:_e.breadcrumbs,conversationId:te==="chat"?Z:null,workspaceName:Jr,workspaceId:Gr,busy:ce,workspaceState:vo,workspaceKind:Zr,selectedApp:At??De,selectedProject:Je,workspaceDiff:Nn,managedWorkspace:Cs,workspaceBusy:Sr,defaultTeamId:Ha.defaultTeamId,showDiffControls:te==="chat"&&ke==="development",diffPanelOpen:be,terminalOpen:xe,rightSidebarAvailable:im,rightSidebarOpen:te==="scheduled"?n:be,onToggleDiffPanel:lc,onToggleRightSidebar:te==="scheduled"?()=>a(Te=>!Te):te==="team"&&mr?pr:lc,onOpenSearch:()=>{rt(null),Xe(!0)},onToggleTerminal:()=>pe(Te=>!Te),onRunTerminalCommand:Te=>{m({id:Date.now(),scope:Vs,command:Te}),pe(!0)},onWorkspaceToolAction:uu,onOpenCommitDialog:As,onWorkspaceBranchChange:cu,onWorkspaceBranchCreate:Jl,connection:yt,onBootstrap:rn,onOpenSandboxWorkspace:Ru,onShowSidebar:()=>Fe(!0),onOpenTeamChat:dc,onDiscoverCommunities:Zu,collaborationView:te==="team"||te==="community"?te:null,platform:Fs,showWorkspaceControls:te!=="team"&&te!=="community"&&te!=="labs"&&te!=="scheduled"&&te!=="outputs"&&te!=="projects"&&(ke==="development"||ke==="work"&&!!(Je||gt?.localProjectId||gt?.cloudProjectId||gt?.workspaceKind==="local_project"))},mainPane:{experience:ke,onNewExperienceChange:qe,view:te,teamChat:{currentUserId:xt.currentUserId,members:xt.members,agents:xt.agents,profile:Nt?.profile??null,teamId:ea,teamName:qa?.displayName??null,detail:xt.detail,aiThread:xt.aiThread,agentConversation:xt.agentConversation,loading:xt.loading,busy:xt.busy,error:xt.error,connection:yt,providerSettings:Nt?.providers??null,provider:Tn,model:$n,codexPermissionMode:Pe,codexReasoningEffort:ge,openPondCommandAccessMode:mo,contextWindowStatus:Ia,showToast:bt,onProviderChange:Yl,onModelChange:I,onCodexPermissionModeChange:Yr,onCodexReasoningEffortChange:Qr,onOpenPondCommandAccessModeChange:Xr,onOpenProviderSettings:()=>{fe("providers"),p("settings"),sn({kind:"settings",section:"providers"})},onSendMessage:xt.sendMessage,onPublishProfileAgent:Ba,onOpenAiThread:async Te=>{await xt.openAiThread(Te),G("chat"),X(!0)},onOpenAgentConversation:async Te=>{await xt.openAgentConversation(Te),G("chat"),X(!0)},onCloseAiThread:()=>X(!1),onCloseAgentConversation:()=>{xt.closeAgentConversation(),X(!1)},onSendAgentTurn:xt.sendAgentTurn,onSendAiTurn:xt.sendAiTurn,onStopAiTurn:xt.stopAiTurn,onEditMessage:xt.editMessage,onDeleteMessage:xt.deleteMessage,onRetryMessage:xt.retryMessage,onDismissFailedMessage:xt.dismissFailedMessage,onLoadMoreMessages:xt.loadMoreMessages,onRetryLoad:xt.refresh},community:Kr,bootstrap:Nt,runtimeEvents:ri,chatMessages:ca,pendingUserMessage:Z?St[Z]??null:null,contextWindowStatus:Ia,goalRuntime:gr,subagentRuntime:ii,selectedSessionId:Z,composerDraftStore:i,mainComposerFocusRequestId:$,labCloseDetailRequestId:_e.closeDetailRequestId,labCloseDetailKind:_e.closeDetailKind,sideChatTrainingLaunchRequest:ic,onSideChatTrainingLaunchHandled:Te=>Eu(ct=>ct?.id===Te?null:ct),mentionApps:Bn,connectedAppMentions:tt,profileSkills:Gu,selectedMentionAppId:w,busy:ce,turnRunning:si,activeProvider:Tn,activeModel:$n,codexPermissionMode:Pe,codexReasoningEffort:ge,openPondCommandAccessMode:mo,pendingApproval:_n,activeWorkspaceAppId:Wr,activeWorkspaceId:Gr,activeWorkspaceKind:Zr,projectTarget:mt,actionCatalog:is,workspaceTarget:Bt,connection:yt,workspaceName:Jr,workspaceState:vo,workspaceDiff:Nn,workspaceBusy:Sr,diffBusy:Is,forceChatThread:!!Z,diffPanelOpen:be,diffPanelExpanded:ne,rightPanelMode:he,rightPanelTabRequest:P,rightChatPanels:ju,runtimeEventStore:sa,nativeSkillSidebar:$s,extensionSkillSidebar:Ds,workspaceDiffPanelViewState:L,sidebarFileOpenRequest:Za,sidebarFileBookmarks:vn,onSetSidebarFileStatus:(Te,ct)=>{ai(Te,ct)},browserConversationId:pn,terminalScope:Vs,terminalTabs:u,terminalCwd:om,pendingTerminalCommand:l,terminalOpen:xe,onToggleTerminal:()=>pe(Te=>!Te),onWorkspaceDiffPanelViewStateChange:na,training:Ut,trainingSessions:lt,trainingChatHandoff:ms,trainingDetailTasksetId:b,onTrainingDetailTasksetIdChange:y,onTrainingChatTaskSelect:ei,onTrainingChatHandoffDismiss:us,onOpenSession:En,onExperienceHandoff:Ju,cloudProjects:Nt?.cloudProjects??[],projects:Ku,projectsAccountBaseUrl:kn?.baseUrl??kn?.activeProfile?.baseUrl??null,projectsTeamName:qa?.displayName??null,projectTaskCounts:Wu,onNewCloudProject:oc,onNewProjectTask:Te=>fi(Te.id),onToggleProjectPinned:nc,onUploadLocalProject:_u,chatHistoryHasMore:Gt,chatHistoryLoading:_a,onDiffPanelResizeStart:oe,onToggleDiffPanelExpanded:()=>ae(Te=>!Te),onShowDiffPanel:Au,onShowBrowserPanel:rc,onShowFilesPanel:()=>Ko("files"),onShowGoalSidebarTab:Tu,onShowTrainingDraftPanel:()=>{G("training"),X(!0)},onShowRightChatPanel:Ou,onAddRightChat:()=>js(null),onOpenRightChatForSession:(Te,ct)=>{const Mt=ct??lt.find(da=>da.id===Te)??null;Mt&&js(Mt,{preserveView:!0})},onLabDetailOpenChange:_e.onDetailOpenChange,scheduledDetailOpen:n,onScheduledDetailOpenChange:a,onTerminalTabsChange:h,onCloseRightChatPanel:Mu,onCloseNativeSkillSidebar:Qu,onActivateRightChatPanel:$u,onRightChatModelChange:Nu,onRightChatPromptChange:Du,onRightChatScrollStateChange:Uu,onRightChatProviderChange:Lu,onSubmitRightChat:sc,onStopRightChat:Te=>Ts(Te),onCloseTerminal:()=>pe(!1),onLoadMoreChatHistory:ni,canSyncWorkspace:Rs,startMessage:ka,onPayload:rn,onError:nn,setView:p,onOpenProfileSettings:zu,onOpenProviderSettings:()=>{sn({kind:"settings",section:"providers"})},onOpenTrainingSettings:()=>{sn({kind:"settings",section:"training"})},onOpenDatasetStorageSettings:()=>{sn({kind:"settings",section:"dataset-storage"})},changeDraftProvider:Yl,changeProjectTarget:su,changeWorkspaceTarget:Cu,setDraftProvider:F,setDraftModel:I,onBeginNewChatWithModel:ds,changeCodexPermissionMode:Yr,changeCodexReasoningEffort:Qr,changeOpenPondCommandAccessMode:Xr,resolveApproval:cs,answerCreateImproveQuestion:hu,applyCreateImproveCandidate:gu,approveCreateImproveRun:vu,cancelCreateImproveRun:bu,openCreateImprovePullRequest:yu,reconcileCreateImprovePullRequest:Ql,rejectCreateImproveCandidate:Su,pauseCreateImproveRun:xu,resumeCreateImproveRun:ku,reviseCreateImproveRun:Xl,setMentionedAppId:_,showToast:bt,onSaveTaskDraft:Bs,sendPrompt:Ms,stopTurn:Te=>Ts(void 0,Te),syncWorkspaceLocally:fu,refreshWorkspaceDiff:_s},cloudSetup:{state:E,onClose:()=>O(null),onOpenBrowserUrl:Pu,onStart:()=>{ac()}},projectConfirm:{state:x,onResolve:C},lazyPanels:{activeSessions:Va,branchDialogName:Q,branchDialogOpen:H,commitDialogOpen:Ue,commitDraft:M,commitIncludeUnstaged:Le,commitMessage:Ve,commitNextStep:D,canPublishOpenPondProject:Ps,connection:yt,expandProject:Fa,newProjectBusy:st,newProjectDialogOpen:we,newProjectDirectory:Ha.defaultNewProjectDirectory,newProjectMode:je,newProjectName:Ze,newProjectPath:Ge,projectRows:ws,query:A,searchOpen:z,visibleWorkspaceDiff:Nn,visibleWorkspaceState:vo,workspaceBusy:Sr,appDispatch:s,beginNewChat:()=>ta(null),openDefaultsSettingsFromBranchDialog:du,setBranchDialogName:Sn,setBranchDialogOpen:An,setCommitDialogOpen:Ke,setCommitDraft:Lt,setCommitIncludeUnstaged:ut,setCommitMessage:ze,setCommitNextStep:Qt,setNewProjectDialogOpen:Oe,setNewProjectName:Ee,setNewProjectPath:Ne,setPrompt:ie,setQuery:$e,setSearchOpen:Xe,submitCommitDialog:mu,submitCreateWorkspaceBranch:pu,submitNewProjectDialog:lu},toast:{toast:me,onDismiss:()=>s({type:"field",key:"toast",value:null})}})})}const Ri=new Map,Vc=new Map;function gf(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 H6(e){const t=e?.trim();if(!t)return null;const n=Ri.get(t);return n?.updatedAt?n.organizations:null}function q6(e,t){const n=e?.trim();if(n){Ri.set(n,{organizations:t,promise:null,updatedAt:Date.now()});for(const a of Vc.get(n)??[])a()}}function B6(e,t){const n=e?.trim();if(!n)return()=>{};const a=Vc.get(n)??new Set;return a.add(t),Vc.set(n,a),()=>{a.delete(t),a.size===0&&Vc.delete(n)}}function by(e){const t=e.accountKey?.trim();if(!t)return Promise.resolve([]);const n=Ri.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=>(q6(t,r),r)).catch(r=>{const i=Ri.get(t);throw i?.promise===a&&Ri.set(t,{organizations:i.organizations,promise:null,updatedAt:i.updatedAt}),r});return Ri.set(t,{organizations:n?.organizations??[],promise:a,updatedAt:n?.updatedAt??0}),a}const dJ="openpond.config.json";function uJ(e,t,n){return t<=0?-1:n==="Home"?0:n==="End"?t-1:n==="ArrowRight"?(e+1)%t:(e-1+t)%t}function PI(){return{activeTab:"files",openFilePaths:[],selectedPath:null}}function ip(e){return{activeTab:e.activeTab,openFilePaths:[...e.openFilePaths],selectedPath:e.selectedPath}}function mJ(e,t=null){const n=V6(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=F6(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 pJ(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function fJ(e){return{path:e,status:"unchanged",additions:0,deletions:0,patch:"",content:null}}function hJ(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 gJ(e){return/\.(?:md|markdown|mdx)$/i.test(e)||/(?:^|\/)readme$/i.test(e)}function vJ(e){return/\.(?:doc|docx|pdf)$/i.test(e)}function F6(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 V6(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 K6(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 AI(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"cloud-project"}function W6(e){const t=new TextEncoder().encode(e);let n="";for(const a of t)n+=String.fromCharCode(a);return btoa(n)}function eu(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||AI(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 G6(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 Z6(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 J6(...e){for(const t of e){const n=t?.trim();if(n)return n}return""}function Y6({draftProvider:e,hasSelectedCloudProject:t,selectedSessionHybridWorkspace:n}){return t&&!n?"openpond":e}const Q6=[{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 X6(...e){return J6(...e.map(t=>{const n=t?.trim();return n&&!n.includes("@")?n:null}))}function eV(e){if(e?.state!=="signed_in")return"";const t=e.accounts.find(n=>n.isActive)??null;return X6(e.profile?.name,e.label,t?.displayLabel,e.profile?.handle,t?.handle,e.activeProfile?.handle)}function tV({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?D6(l):!1,E=l?.cwd&&(!y||w)?tx(l.cwd):null,O=e?.providers??null,P=ya(s,e?.cloudProjects??[]),L=Y6({draftProvider:n,hasSelectedCloudProject:!!i,selectedSessionHybridWorkspace:w}),$=dr(L,t,O),j=ma(e?.preferences),x=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,q=!e||z?.state==="loading"||z?.state==="switching",N=!q&&z?.state==="signed_out",K=q?null:N?"Sign in":z?.label??z?.activeProfile?.handle??"Account",de=eV(z),te=de?`Welcome, ${de}`:"Welcome",Ie=l?.workspaceName??l?.appName??i?.name??s?.name??a?.name??null,Se=lo(x)?"cloud":"local",Z=s?.name??u?.name??(l?.workspaceKind==="local_project"?l.workspaceName:null)??"Local workspace",Pe=(Se==="cloud"?Ie:null)??i?.name??P?.name??s?.name??"Cloud workspace",ge=!!(i?.id||P?.id||l?.cloudProjectId||Se==="cloud");return{account:z,accountLabel:K,accountPending:q,accountSignedOut:N,activeModel:$,activeProvider:L,activeWorkspaceAppId:C,activeWorkspaceId:A,activeWorkspaceKind:x,activeWorkspaceLocation:Se,appDefaults:j,cloudLinked:ge,cloudTargetName:Pe,localTargetName:Z,selectedCodexHistoryPending:b,selectedSessionCloudWorkspace:y,selectedSessionLocalPathWorkspaceId:E,selectedSessionPendingCloudStart:_,selectedSessionProjectId:h,startMessage:te,workspaceName:Ie}}function nV({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=ya(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"})),q=l?`local:${l.id}`:s?`cloud:${s.id}`:"none",N=[...A,...z].find(K=>K.value===q)??null;return{value:q,label:N?.label??"Select Project",detail:N?.detail??"Choose a project for local or cloud work",busy:b||r,options:[...A,...z,...Q6,{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]),O=!!(i||l),P=!!(s?.id||y?.id||m?.cloudProjectId||co(m)),L=l?h[l.id]??null:null,$=V1(L,{branch:l?.linkedSandboxProject?.defaultBranch??null,path:l?.workspacePath??m?.cwd??null,linkedCloudSourceKnown:l?.linkedSandboxProject?.projectId&&_?!!l.linkedSandboxProject.lastUploadedCommit||!L?.headCommit:!0}),j=K1(l,s??y,L,{cloudLinkTrusted:_}),x=Y5(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?j:"upload required",disabled:e||t||!P,disabledReason:t?"Add an OpenPond account before using Hybrid.":"Upload/sync this Project to Cloud before using Hybrid."},q={value:"cloud",label:"Hosted",detail:"Run with hosted compute, with or without a Project.",stateNote:l||s?j:"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:x,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:q;let te=n==="cloud"?q:A;return u==="cloud"?te=q: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,q]}},[n,e,t,i,O,j,P,$,u,l,m,x,b]);return{projectTarget:E,workspaceTarget:C}}function jn(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function TI(e){return jn(e.name||e.gitRepo||e.id)}function bJ(e){return`@${TI(e)}`}function EI(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function aV(e,t){const n=EI(e);if(n.length===0)return!1;const a=new Set([jn(t.id),TI(t),t.gitRepo?jn(t.gitRepo):""].filter(Boolean));return n.some(r=>a.has(r))}function MI(e){return e.filter(t=>t.sandbox)}function oV(e,t){const n=EI(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 yJ(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 rV(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 iV({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(()=>j1(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(()=>rV(e?.apps??[]),[e?.apps]),w=g.useMemo(()=>MI(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]),O=g.useMemo(()=>U1(e?.localProjects??[]),[e?.localProjects]),P=g.useRef([]),L=g.useMemo(()=>sV(i,t,P.current),[t,i]),$=g.useMemo(()=>L.find(N=>N.id===a)??null,[L,a]),j=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=U5($,E,O);if(N)return l.get(N)??null;if(!$.appId)return null;const K=_.get($.appId);return K?l.get(K)??null:null},[_,l,E,O,$]),x=g.useMemo(()=>$?.cloudProjectId?m.get($.cloudProjectId)??null:null,[m,$]),C=h??j,A=b??x,z=g.useMemo(()=>ky(C,y),[y,C]),q=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:q,selectedProjectLinkedOpenPondApp:z,selectedSession:$,selectedSessionLinkedProject:j,sidebarSessions:L}}function sV(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?lV(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 lV(e,t){return{...e,metadata:cV(e.metadata,t.metadata),status:e.status==="active"||t.status==="active"?"active":e.status,updatedAt:dV(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 cV(e,t){const n={...e??{},...t??{}};return Object.keys(n).length>0?n:void 0}function dV(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 uV(e){return!!(e&&lo(e.workspaceKind)&&!co(e)&&e.provider!=="openpond")}function mV(e,t){const n=N1(e,t);return`${e.id}\0${n.provider}\0${n.model}`}function pV({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:O,setSessions:P,setTerminalOpen:L,toast:$}){const j=g.useRef(null);g.useEffect(()=>{if(!l)return;const x=h??(u?null:i.get(l)??null);if(!x)return;const C=vt("local",x);E(null),O(C),r(C)},[r,i,l,u,h,E,O]),g.useEffect(()=>{if(!$||$.persistent)return;const x=window.setTimeout(()=>{n({type:"clearToast",toastId:$.id})},$.durationMs??($.tone==="error"?7e3:3500));return()=>window.clearTimeout(x)},[n,$]),g.useEffect(()=>{function x(C){(C.metaKey||C.ctrlKey)&&C.key==="`"&&(C.preventDefault(),L(A=>!A))}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[L]),g.useEffect(()=>{b(!1)},[e,t,b]),g.useEffect(()=>{if(!u){j.current=null;return}if(!m||m.id!==u)return;const x=mV(m,s);if(j.current===x)return;j.current=x;const C=N1(m,s);w(C.provider),y(C.model)},[s,m,u,y,w]),g.useEffect(()=>{!a||!m||!uV(m)||J.patchSession(a,m.id,{provider:"openpond"}).then(x=>{P(C=>C.map(A=>A.id===x.id?x:A)),w("openpond"),y(C=>dr("openpond",C))}).catch(x=>{_(x instanceof Error?x.message:String(x))})},[a,m,y,w,_,P])}function fV({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 hV({activeProvider:e,contextCompaction:t,contextUsage:n,pinnedItems:a,pinnedPreviewKeys:r,pinnedProjects:i,projectRows:s,visibleProjectRows:l}){const m=g.useMemo(()=>P5(a,r),[a,r]),u=g.useMemo(()=>rI({provider:e,snapshot:n,preferences:t}),[e,t,n]),h=g.useMemo(()=>Array.from(new Set([...i,...l].filter(fg).map(y=>y.project.id))),[i,l]);return{commandProjectRows:g.useMemo(()=>s,[s]),contextWindowStatus:u,pinnedRows:m,sidebarWorkspaceAppIds:h}}function gV({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 jI={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 SJ(e){return`@${e.token}`}function vV(e){return`@${kV(e)}`}function bV(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=xi(a.flatMap(b=>b.capabilities.map(y=>y.id))),s=xi(a.flatMap(b=>b.capabilityLabels)),l=xi(a.flatMap(b=>b.connections.map(y=>y.id).filter(IV))),m=xi(a.map(b=>b.id)),u=xi(a.map(b=>b.setupSurface)),h=xV(n);return{provider:n,label:r.providerLabel,detail:s.length>0?s.slice(0,4).join(", "):r.description,token:h,tokens:SV(a),ref:{kind:"integration",provider:n,appIds:m,setupSurfaces:u,...l.length>0?{connectionIds:l}:{},...i.length>0?{capabilities:i}:{}}}})}function xJ(e,t){const n=jn(t);return e.filter(a=>n?a.tokens.some(r=>r.includes(n)):!0).slice(0,8)}function yV(e,t){const n=wV(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 kJ(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:vV(s),end:u+h.length,label:s.label,provider:s.provider,start:u,text:h})}return n}function SV(e){return xi(e.flatMap(t=>[...jI[t.providerFamily],t.providerFamily,t.id,t.label,t.shortLabel]).map(jn).filter(Boolean))}function xV(e){return jn(jI[e][0]??e)}function kV(e){return e.provider==="github"?"GitHub":e.provider==="x"?"X":e.provider==="mcp"?"MCP":e.label}function wV(e){return Array.from(e.matchAll(/(?:^|\s)@([A-Za-z0-9_-]+)/g)).map(t=>jn(t[1]??"")).filter(Boolean)}function xi(e){return Array.from(new Set(e))}function IV(e){return typeof e=="string"&&e.length>0}function _V({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 O=_.get(E.teamId)??[];O.push(E.id),_.set(E.teamId,O)}return _},[e?.cloudProjects]),b=!!(l||r||s||i)?[]:n,y=g.useMemo(()=>bV(t),[t]),w=g.useMemo(()=>k6(a,m),[a,m]);return{chatMentionApps:b,cloudProjectIdsByTeam:u,connectedAppMentions:y,pendingApproval:w}}function CV({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 RV=6e4;function Ig(e,t){if(!e)return t;const n=AV(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 $I(e,n)?e:n}function PV(e,t){const n=Ig(e,t),a=e?{...n,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order,updatedAt:e.updatedAt}:n;return e&&$I(e,a)?e:a}function nl(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=Ig(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function tu(e,t){let n=!1,a=!1;const r=e.map(i=>{if(i.id!==t.id)return i;n=!0;const s=PV(i,t);return s!==i&&(a=!0),s});return n?a?r:e:[t,...e]}function vf(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=EV(s,i,n,a);if(l)return l}return Ig(s,i)})}function Cy(e,t,n,a=Date.now()){const r=new Map(e.map(u=>[u.id,u])),i=new Map(vf(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||(OI(u,t)?u:null)}).filter(u=>!!u);return[...l,...m]}function OI(e,t){const n=Date.parse(e.updatedAt);if(!Number.isFinite(n))return!1;const a=TV(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&&(NI(s,i)||(e[i.id]=a))}}function AV(e,t){const n=Date.parse(e),a=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(a)&&n>a}function $I(e,t){return JSON.stringify(e)===JSON.stringify(t)}function TV(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 EV(e,t,n,a){const r=n[t.id];return r===void 0?null:a-r>RV||NI(e,t)?(delete n[t.id],null):{...t,pinned:e.pinned,savedForLater:e.savedForLater,archived:e.archived,order:e.order}}function NI(e,t){return e.pinned===t.pinned&&e.savedForLater===t.savedForLater&&e.archived===t.archived&&e.order===t.order}const DI=800,MV=5e3,Py=5e4,jV=16,OV=3e4,Zn=new Map;function $V(e,t){return Zn.get(UI(e,t))?.payload??null}async function LI(e,t,n={}){const a=UI(e,t),r=Zn.get(a),i=n.limit??DI,s=n.tail??!0;if(r?.promise)return r.promise;if(!n.force&&s&&r?.payload&&Date.now()-r.fetchedAt<=OV)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:NV(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 UI(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>jV;){const e=Zn.keys().next().value;if(!e)return;Zn.delete(e)}}function NV(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 DV=500,LV=2500,UV=15e3;function zV(e){return e.active?DV:e.surface==="thread"?LV:UV}function _g(e,t){return!t||e.session.status==="active"?e:{...e,session:{...e.session,status:"active"}}}function HV(e={}){const t={cachedPayload:e.cachedPayload??$V,clearTimer:e.clearTimer??(u=>globalThis.clearTimeout(u)),loadPayload:e.loadPayload??LI,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=BV(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"||xg(u.latestPayload?.events??[])?.tone==="active",y=h.some(w=>w.surface==="thread")?"thread":"sidebar";return zV({active:b,surface:y})}function m(u){u.timer&&t.clearTimer(u.timer),u.timer=null,u.nextRefreshAt=null}return{subscribe:r}}const qV=HV();function Cg(e){return qV.subscribe(e)}function BV(e,t){return`${e.serverUrl}
137
137
  ${e.token}