@open-mercato/cezar 0.16.2 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-origin.d.ts +6 -0
- package/dist/api-origin.js +32 -0
- package/dist/api-origin.js.map +1 -0
- package/dist/automations/schedule-runner.d.ts +1 -0
- package/dist/automations/schedule-runner.js +2 -2
- package/dist/automations/schedule-runner.js.map +1 -1
- package/dist/core/agent-errors.d.ts +5 -0
- package/dist/core/agent-errors.js +49 -0
- package/dist/core/agent-errors.js.map +1 -1
- package/dist/core/claude-cli-runner.d.ts +3 -0
- package/dist/core/claude-cli-runner.js +20 -4
- package/dist/core/claude-cli-runner.js.map +1 -1
- package/dist/core/codex-ui-mapper.js +4 -1
- package/dist/core/codex-ui-mapper.js.map +1 -1
- package/dist/core/copilot-acp-runner.d.ts +1 -1
- package/dist/core/copilot-acp-runner.js +26 -5
- package/dist/core/copilot-acp-runner.js.map +1 -1
- package/dist/core/model-presets.d.ts +11 -0
- package/dist/core/model-presets.js +35 -1
- package/dist/core/model-presets.js.map +1 -1
- package/dist/core/opencode-model-catalog.js +3 -0
- package/dist/core/opencode-model-catalog.js.map +1 -1
- package/dist/core/opencode-server-runner.d.ts +7 -0
- package/dist/core/opencode-server-runner.js +36 -1
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/pi-runner.js +2 -0
- package/dist/core/pi-runner.js.map +1 -1
- package/dist/core/provider-auth.d.ts +6 -0
- package/dist/core/provider-auth.js +59 -13
- package/dist/core/provider-auth.js.map +1 -1
- package/dist/core/usage-limit.js +8 -2
- package/dist/core/usage-limit.js.map +1 -1
- package/dist/index.js +3 -19
- package/dist/index.js.map +1 -1
- package/dist/release/bump.d.ts +1 -1
- package/dist/release/bump.js +1 -1
- package/dist/release/stable.d.ts +21 -4
- package/dist/release/stable.js +48 -15
- package/dist/release/stable.js.map +1 -1
- package/dist/runs/agent-error-telemetry.js +4 -2
- package/dist/runs/agent-error-telemetry.js.map +1 -1
- package/dist/runs/store.d.ts +1 -1
- package/dist/runs/store.js +31 -4
- package/dist/runs/store.js.map +1 -1
- package/dist/server/git-changes.d.ts +22 -0
- package/dist/server/git-changes.js +19 -1
- package/dist/server/git-changes.js.map +1 -1
- package/dist/server/open-in-app.js +14 -3
- package/dist/server/open-in-app.js.map +1 -1
- package/dist/server/preview/location-reporter.d.ts +12 -0
- package/dist/server/preview/location-reporter.js +45 -0
- package/dist/server/preview/location-reporter.js.map +1 -0
- package/dist/server/preview/picker-script.d.ts +0 -22
- package/dist/server/preview/picker-script.js +3 -1
- package/dist/server/preview/picker-script.js.map +1 -1
- package/dist/server/provider-telemetry.d.ts +3 -1
- package/dist/server/provider-telemetry.js +4 -2
- package/dist/server/provider-telemetry.js.map +1 -1
- package/dist/server/repo-sync.js +5 -10
- package/dist/server/repo-sync.js.map +1 -1
- package/dist/server/server.d.ts +1854 -1854
- package/dist/server/server.js +7 -2
- package/dist/server/server.js.map +1 -1
- package/dist/server/worktree-lifecycle.d.ts +8 -8
- package/dist/telemetry.js +3 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/workflows/continuation-context.d.ts +3 -1
- package/dist/workflows/continuation-context.js +22 -3
- package/dist/workflows/continuation-context.js.map +1 -1
- package/dist/workflows/run.d.ts +20 -9
- package/dist/workflows/run.js +49 -11
- package/dist/workflows/run.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mock-copilot-acp.mjs +4 -0
- package/web/dist/assets/{agent-task-pickers-DEW3Vgdv.js → agent-task-pickers-CNuwgeJL.js} +1 -1
- package/web/dist/assets/{automations-route-Cx7mzYhD.js → automations-route-Cs1tsu1W.js} +1 -1
- package/web/dist/assets/{commit-list-xMdmPYbz.js → commit-list-Ti2arrt8.js} +1 -1
- package/web/dist/assets/{compare-variants-B6ja1M4D.js → compare-variants-CdchlJMs.js} +1 -1
- package/web/dist/assets/{dashboard-ClEGBFFq.js → dashboard-wi0EQack.js} +2 -2
- package/web/dist/assets/{file-preview-iucr8WDo.js → file-preview-pS9i9ZDR.js} +1 -1
- package/web/dist/assets/git-tab-loading-BC6WP7W4.js +1 -0
- package/web/dist/assets/{git-toolbar-DU5Ca6RI.js → git-toolbar-Dra1QlHb.js} +1 -1
- package/web/dist/assets/github-DZcdhMzw.js +1 -0
- package/web/dist/assets/{host-usage-DjDYDU0A.js → host-usage-DnkXF0CT.js} +1 -1
- package/web/dist/assets/index-qeFtKZ4e.js +22 -0
- package/web/dist/assets/{layout-cards-Sur4EWtx.js → layout-cards-CXMlrDUf.js} +1 -1
- package/web/dist/assets/{project-router-DZsR9P9C.js → project-router-CZzr7lzN.js} +2 -2
- package/web/dist/assets/queries-Bn7zl9OU.js +1 -0
- package/web/dist/assets/{reference-chip-DnemrSPW.js → reference-chip-CScP5y_O.js} +1 -1
- package/web/dist/assets/repo-git-CV-yXaSx.js +1 -0
- package/web/dist/assets/{run-diff-BPZ85gAE.js → run-diff-GHEaeAio.js} +2 -2
- package/web/dist/assets/{skills-BgCN1gTp.js → skills-DuSNv5op.js} +1 -1
- package/web/dist/assets/{task-commits-W1ZZiEt4.js → task-commits-D_gLpFQo.js} +1 -1
- package/web/dist/assets/{task-graph-DI2fn5M8.js → task-graph-BgHk8Y3v.js} +1 -1
- package/web/dist/assets/{task-notes-lmvd1UM7.js → task-notes-BBp0rdzM.js} +1 -1
- package/web/dist/assets/task-workspace-Cr9AjTxP.js +27 -0
- package/web/dist/assets/{terminal-drawer-DAkquqSe.js → terminal-drawer-CcPOjWwP.js} +2 -2
- package/web/dist/assets/{tracker-Cqdpt9RN.js → tracker-BHwMGsDY.js} +2 -2
- package/web/dist/assets/use-automations-Dh3Wj-79.js +5 -0
- package/web/dist/assets/{use-now-pBdvhv13.js → use-now-BB7W0F--.js} +1 -1
- package/web/dist/assets/{workflow-graph-l7O50dsV.js → workflow-graph-CcOTCItr.js} +3 -3
- package/web/dist/assets/worktree-lifecycle-operation-vTgExKUM.js +18 -0
- package/web/dist/index.html +10 -10
- package/web/dist/assets/git-tab-loading-BfC2ir8N.js +0 -1
- package/web/dist/assets/github-CELdSmld.js +0 -1
- package/web/dist/assets/index-BBND6Sg3.js +0 -22
- package/web/dist/assets/queries-CI0EmEcH.js +0 -1
- package/web/dist/assets/repo-git-Bj0PBOjX.js +0 -1
- package/web/dist/assets/task-workspace-B8Fpho3e.js +0 -27
- package/web/dist/assets/use-automations-v77gHYDG.js +0 -5
- package/web/dist/assets/worktree-lifecycle-operation-DOTiqQFx.js +0 -18
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,Ft as i,Gt as a,I as o,It as s,L as c,R as l,Rt as u,Tt as d,U as f,V as p,Wt as m,bt as h,xt as g,yt as _,z as v}from"./button-Clwd6u4_.js";var ee=/^[\w!#$%&'*.^`|~+-]+$/,te=(e,t,n={})=>{if(!ee.test(e))throw Error(`Invalid cookie name`);let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}for(let e of[`domain`,`path`,`sameSite`,`priority`])if(n[e]&&/[;\r\n]/.test(n[e]))throw Error(`${e} must not contain ";", "\\r", or "\\n"`);if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},y=(e,t,n)=>(t=encodeURIComponent(t),te(e,t,n)),ne=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),re=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??`);e=e.replace(t,r?`/${r}`:``)}return e},ie=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(r!==void 0)if(Array.isArray(r))for(let e of r)t.append(n,e);else t.set(n,r);return t},ae=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},oe=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function se(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ce(e,t){if(!se(e)&&!se(t))return t;let n={...e};for(let e in t){let r=t[e];se(n[e])&&se(r)?n[e]=ce(n[e],r):n[e]=r}return n}var le=(e,t)=>new Proxy(()=>{},{get(n,r){if(!(typeof r!=`string`||r===`then`))return le(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),ue=class{url;method;buildSearchParams;queryParams=void 0;pathParams={};rBody;cType=void 0;constructor(e,t,n){this.url=e,this.method=t,this.buildSearchParams=n.buildSearchParams}fetch=async(e,t)=>{if(e){if(e.query&&(this.queryParams=this.buildSearchParams(e.query)),e.form){let t=new FormData;for(let[n,r]of Object.entries(e.form))if(r!==void 0)if(Array.isArray(r))for(let e of r)t.append(n,e);else t.append(n,r);this.rBody=t}e.json&&(this.rBody=JSON.stringify(e.json),this.cType=`application/json`),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase(),r={...e?.header,...typeof t?.headers==`function`?await t.headers():t?.headers};if(e?.cookie){let t=[];for(let[n,r]of Object.entries(e.cookie))t.push(y(n,r,{path:`/`}));r.Cookie=t.join(`,`)}this.cType&&(r[`Content-Type`]=this.cType);let i=new Headers(r??void 0),a=this.url;a=oe(a),a=re(a,this.pathParams),this.queryParams&&(a=a+`?`+this.queryParams.toString()),n=this.method.toUpperCase();let o=!(n===`GET`||n===`HEAD`);return(t?.fetch||fetch)(a,{body:o?this.rBody:void 0,method:n,headers:i,...t?.init})}},de=(e,t)=>le(function n(r){let i=t?.buildSearchParams??ie,a=[...r.path],o=a.slice(-3).reverse();if(o[0]===`toString`)return o[1]===`name`?o[2]||``:n.toString();if(o[0]===`valueOf`)return o[1]===`name`?o[2]||``:n;let s=``;if(/^\$/.test(o[0])){let e=a.pop();e&&(s=e.replace(/^\$/,``))}let c=ne(e,a.join(`/`));if(s===`url`||s===`path`){let t=c;return r.args[0]&&(r.args[0].param&&(t=re(c,r.args[0].param)),r.args[0].query&&(t=t+`?`+i(r.args[0].query).toString())),t=oe(t),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=ae(r.args[0]&&r.args[0].param?re(c,r.args[0].param):c,`ws`),n=new URL(e),i=r.args[0]?.query;return i&&Object.entries(i).forEach(([e,t])=>{Array.isArray(t)?t.forEach(t=>n.searchParams.append(e,t)):n.searchParams.set(e,t)}),((...e)=>t?.webSocket!==void 0&&typeof t.webSocket==`function`?t.webSocket(...e):new WebSocket(...e))(n.toString())}let l=new ue(c,s,{buildSearchParams:i});if(s){t??={};let e={...r.args[1]},n=t.headers,i=e.headers;n&&i&&(e.headers=async()=>({...typeof n==`function`?await n():n,...typeof i==`function`?await i():i}));let a=ce(t,e);return l.fetch(r.args[0],a)}return l},[]);function fe(e={}){let{baseUrl:t=``,token:n,headers:r,fetch:i}=e;return de(t,{headers:{...n?{Authorization:`Bearer ${n}`}:{},...r},...i?{fetch:i}:{}})}var b=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(){}},pe=new class extends b{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let 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(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},me={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},x=new class{#e=me;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)}};function he(e){setTimeout(e,0)}var ge=typeof window>`u`||`Deno`in globalThis;function S(){}function _e(e,t){return typeof e==`function`?e(t):e}function ve(e){return typeof e==`number`&&e>=0&&e!==1/0}function ye(e,t){return Math.max(e+(t||0)-Date.now(),0)}function C(e,t){return typeof e==`function`?e(t):e}function w(e,t){return typeof e==`function`?e(t):e}function be(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Se(o,t.options))return!1}else if(!E(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function xe(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(T(t.options.mutationKey)!==T(a))return!1}else if(!E(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Se(e,t){return(t?.queryKeyHashFn||T)(e)}function T(e){return JSON.stringify(e,(e,t)=>Ee(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function E(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>E(e[n],t[n])):!1}var Ce=Object.prototype.hasOwnProperty;function we(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Te(e)&&Te(t);if(!r&&!(Ee(e)&&Ee(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Ce.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=we(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function D(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Te(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ee(e){if(!De(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!De(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function De(e){return Object.prototype.toString.call(e)===`[object Object]`}function Oe(e){return new Promise(t=>{x.setTimeout(t,e)})}function ke(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:we(e,t)}function Ae(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function je(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Me=Symbol();function Ne(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Me?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Pe(e,t){return typeof e==`function`?e(...t):!!e}function Fe(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var O=(()=>{let e=()=>ge;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ie(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Le=he;function Re(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Le,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var k=Re(),ze=new class extends b{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let 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}};function Be(e){return Math.min(1e3*2**e,3e4)}function Ve(e){return(e??`online`)!==`online`||ze.isOnline()}var He=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ue(e){let t=!1,n=0,r,i=Ie(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new He(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>pe.isFocused()&&(e.networkMode===`always`||ze.isOnline())&&e.canRun(),u=()=>Ve(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(O.isServer()?0:3),o=e.retryDelay??Be,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),Oe(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var We=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ve(this.gcTime)&&(this.#e=x.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(O.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(x.clearTimeout(this.#e),this.#e=void 0)}};function Ge(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Fe(e,()=>t.signal,()=>n=!0)},u=Ne(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?je:Ae;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?qe:Ke,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ke(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Ke(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function qe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Je(e,t){return t?Ke(e,t)!=null:!1}function Ye(e,t){return!t||!e.getPreviousPageParam?!1:qe(e,t)!=null}var Xe=class extends We{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=$e(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.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=$e(this.options);e.data!==void 0&&(this.setState(Qe(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ke(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(S).catch(S):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=>w(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Me||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>C(e.options.staleTime,this)===`static`)}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:!ye(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Ne(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Ge(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=Ue({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof He&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof He){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Ze(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Qe(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),k.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Ze(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Qe(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function $e(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var et=class extends b{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Ie(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),nt(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rt(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rt(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let 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 w(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!D(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&it(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||w(this.options.enabled,this.#t)!==w(t.enabled,this.#t)||C(this.options.staleTime,this.#t)!==C(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||w(this.options.enabled,this.#t)!==w(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ot(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(S)),t}#g(){this.#b();let e=C(this.options.staleTime,this.#t);if(O.isServer()||this.#r.isStale||!ve(e))return;let t=ye(this.#r.dataUpdatedAt,e)+1;this.#d=x.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(O.isServer()||w(this.options.enabled,this.#t)===!1||!ve(this.#p)||this.#p===0)&&(this.#f=x.setInterval(()=>{(this.options.refetchIntervalInBackground||pe.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(x.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(x.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&nt(e,t),o=i&&it(e,n,t,r);(a||o)&&(l={...l,...Ze(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ke(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ke(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,ee=_&&g,te=d!==void 0,y={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:ee,isLoading:ee,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!te,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&te,isStale:at(e,t),refetch:this.refetch,promise:this.#o,isEnabled:w(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=y.data!==void 0,r=y.status===`error`&&!t,i=e=>{r?e.reject(y.error):t&&e.resolve(y.data)},a=()=>{let e=this.#o=y.promise=Ie();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||y.data!==o.value)&&a();break;case`rejected`:(!r||y.error!==o.reason)&&a();break}}return y}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!D(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let 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()}#C(e){k.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function tt(e,t){return w(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&w(t.retryOnMount,e)===!1)}function nt(e,t){return tt(e,t)||e.state.data!==void 0&&rt(e,t,t.refetchOnMount)}function rt(e,t,n){if(w(t.enabled,e)!==!1&&C(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&at(e,t)}return!1}function it(e,t,n,r){return(e!==t||w(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&at(e,n)}function at(e,t){return w(t.enabled,e)!==!1&&e.isStaleByTime(C(t.staleTime,e))}function ot(e,t){return!D(e.getCurrentResult(),t)}var st=class extends et{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Je(t,n.data),hasPreviousPage:Ye(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},ct=class extends We{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||lt(),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.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ue({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function lt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ut=class extends b{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),D(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&T(t.mutationKey)!==T(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??lt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){k.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function dt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function ft(e,t,n){let r=e.slice(0);return r[t]=n,r}var pt=class extends b{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,k.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!D(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(dt(e,n).forEach(e=>{e.destroy()}),dt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=we(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new et(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=ft(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},A=e(t(),1),mt=n(),ht=A.createContext(void 0),j=e=>{let t=A.useContext(ht);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},gt=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,mt.jsx)(ht.Provider,{value:e,children:t})),_t=A.createContext(!1),vt=()=>A.useContext(_t);_t.Provider;function yt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var bt=A.createContext(yt()),xt=()=>A.useContext(bt),St=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Pe(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ct=e=>{A.useEffect(()=>{e.clearReset()},[e])},wt=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Pe(n,[e.error,r])),Tt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Et=(e,t)=>e.isLoading&&e.isFetching&&!t,Dt=(e,t)=>e?.suspense&&t.isPending,Ot=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function kt({queries:e,...t},n){let r=j(n),i=vt(),a=xt(),o=A.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Tt(e);let t=r.getQueryCache().get(e.queryHash);St(e,a,t)}),Ct(a);let[s]=A.useState(()=>new pt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;A.useSyncExternalStore(A.useCallback(e=>d?s.subscribe(k.batchCalls(e)):S,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),A.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Dt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Dt(n,e)?Ot(n,new et(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&wt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function At(e,t,n){let r=vt(),i=xt(),a=j(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Tt(o),St(o,i,s),Ct(i);let l=!a.getQueryCache().get(o.queryHash),[u]=A.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(A.useSyncExternalStore(A.useCallback(e=>{let t=f?u.subscribe(k.batchCalls(e)):S;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),A.useEffect(()=>{u.setOptions(o)},[o,u]),Dt(o,d))throw Ot(o,u,i);if(wt({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!O.isServer()&&Et(d,r)&&(l?Ot(o,u,i):s?.promise)?.catch(S).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function M(e,t){return At(e,et,t)}function N(e,t){let n=j(t),[r]=A.useState(()=>new ut(n,e));A.useEffect(()=>{r.setOptions(e)},[r,e]);let i=A.useSyncExternalStore(A.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=A.useCallback((e,t)=>{r.mutate(e,t).catch(S)},[r]);if(i.error&&Pe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function P(e,t){return At(e,st,t)}var jt={projectId:null,apiBase:o},Mt=(0,A.createContext)(jt);function Nt(){return(0,A.useContext)(Mt)}function Pt({projectId:e,children:t}){v()!==e&&f(e),(0,A.useLayoutEffect)(()=>{f(e)},[e]),(0,A.useLayoutEffect)(()=>()=>f(null),[]);let n=(0,A.useMemo)(()=>e===null?jt:{projectId:e,apiBase:`${o}/p/${encodeURIComponent(e)}`},[e]);return(0,mt.jsx)(Mt.Provider,{value:n,children:t})}var F=[`claude`,`codex`,`junie`,`opencode`,`cursor`,`pi`,`copilot`],Ft=new Set([`connected`,`disconnected`,`not-installed`,`unknown`]);function It(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lt(e,t){if(!It(e))return null;let{provider:n,status:r,enabled:i,hint:a,authFailureId:o}=e;return typeof n!=`string`||!F.includes(n)||typeof r!=`string`||!Ft.has(r)||t&&typeof i!=`boolean`||!t&&i!==void 0&&typeof i!=`boolean`||a!==void 0&&typeof a!=`string`||o!==void 0&&(typeof o!=`string`||o.length<1||o.length>128||r!==`disconnected`)?null:{provider:n,status:r,...typeof i==`boolean`?{enabled:i}:{},...a===void 0?{}:{hint:a},...o===void 0?{}:{authFailureId:o}}}function Rt(e){return Lt(e,!1)}function zt(e,t){if(!It(e)||!Array.isArray(e.providers))return null;let n=[],r=new Set;for(let i of e.providers){let e=Lt(i,t);if(e===null||r.has(e.provider))return null;r.add(e.provider),n.push(e)}return n}function I(e){let t=zt(e,!0);if(t===null||t.length===0)return null;let n=new Map(t.map(e=>[e.provider,e]));return F.flatMap(e=>{let t=n.get(e);return t?[t]:[]})}function L(e){let t=I(e);if(t===null)throw Error(`Invalid provider status response`);return{providers:t}}function Bt(e,t){let n=I(e);if(n!==null)return{providers:n.map(e=>e.provider===t.provider?{provider:t.provider,status:t.status,enabled:t.enabled??e.enabled,...t.hint===void 0?{}:{hint:t.hint},...t.authFailureId===void 0?{}:{authFailureId:t.authFailureId}}:e)}}function Vt(e,t,n,r){let i=I(e),a=I(t),o=I(n);if(o===null||a===null)return n;if(i===null)return{providers:a};let s=new Map(i.map(e=>[e.provider,e])),c=new Map(a.map(e=>[e.provider,e]));return{providers:o.map(e=>{let t=s.get(e.provider),n=c.get(e.provider);if(t===void 0||n===void 0)return n??e;let i=r!==void 0&&n.authFailureId===r&&e.authFailureId===void 0;return r!==void 0&&n.authFailureId!==void 0&&n.authFailureId!==r&&e.authFailureId===void 0?n:Ht(t,n)?e:i?{...e,enabled:n.enabled}:n})}}function Ht(e,t){return e.provider===t.provider&&e.status===t.status&&e.enabled===t.enabled&&e.hint===t.hint&&e.authFailureId===t.authFailureId}function Ut(e){let t=I(e);if(t===null)return[];let n=new Set(t.filter(e=>e.enabled&&(e.status===`connected`||e.provider===`junie`&&e.status===`unknown`)).map(e=>e.provider));return F.filter(e=>n.has(e))}function Wt(e,t){return I(e)?.find(e=>e.provider===t)}var Gt=`cezar:sid`,Kt;function qt(e=Date.now()){let t=crypto.getRandomValues(new Uint8Array(16));for(let n=0;n<6;n++)t[n]=Math.floor(e/2**(8*(5-n)))&255;t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function Jt(){try{let e=localStorage.getItem(Gt);if(e)return e;let t=qt();return localStorage.setItem(Gt,t),t}catch{return Kt??=qt()}}var Yt=`x-cezar-sid`;function Xt(){Kt=void 0;try{localStorage.removeItem(Gt)}catch{}}function Zt(e){if(typeof e!=`object`||!e)return;let{name:t,message:n}=e;return{name:typeof t==`string`?t:`unknown`,message:typeof n==`string`?n:``}}var Qt=/\/(?:providers|agent-profiles)(?:\/|$)/;function $t(e,t){if(!Qt.test(e))return;let n=e.split(`/`),r=n[n.indexOf(`providers`)+1];if(n.includes(`providers`)&&_.safeParse(r).success)return r;if(typeof t==`string`)try{let e=JSON.parse(t).provider;return _.safeParse(e).success?e:void 0}catch{return}}var en=null;function tn(e,t,n,r,i){try{let a=new URL(e,window.location.origin).pathname,o=$t(a,r),s=Zt(i);en={method:(t??`GET`).toUpperCase(),path:a,status:n,at:Date.now(),...o?{provider:o}:{},...s?{cause:s}:{}}}catch{}}function nn(e=3e3,t=Date.now()){return en&&t-en.at<=e?en:null}var R=class extends Error{status;manual;command;exists;constructor(e,t,n={}){super(t,n.cause===void 0?void 0:{cause:n.cause}),this.name=`ApiError`,this.status=e,this.manual=n.manual,this.command=n.command,this.exists=n.exists}};function z(e){try{return JSON.parse(e)}catch{return}}function rn(e){return typeof e==`string`?e:void 0}function B(e,t,n){let r=z(n),i=r&&typeof r==`object`?r:{};return new R(e,rn(i.error)??`${e} ${t||`request failed`}`.trim(),{manual:rn(i.manual),command:rn(i.command),exists:typeof i.exists==`boolean`?i.exists:void 0})}var V=fe({fetch:(e,t)=>ln(an(String(e)),t)});function an(e){let t=sn(e.endsWith(`?`)?e.slice(0,-1):e);return t.startsWith(`/`)?`${l()}${t}`:t}var on=`${o}/p/default`;function sn(e){if(v()!==null||!e.startsWith(on))return e;let t=e.slice(on.length);return t===``||t.startsWith(`/`)||t.startsWith(`?`)?`${o}${t}`:e}var H=e=>({init:{signal:e?.signal}});async function U(e,t){let n=await e.text();if(!e.ok)throw B(e.status,e.statusText,n);let r=z(n);if(r===void 0)throw new R(e.status,`the cezar server answered ${t} with a non-JSON body`);return r}async function cn(e,t,n){let r=e.status,i=await U(e,t),a=n.safeParse(i);if(!a.success)throw new R(r,`the cezar server answered ${t} with an unexpected body`);return a.data}async function ln(e,t){try{let n=new Headers(t?.headers);n.set(Yt,Jt());let r=await fetch(e,{...t,headers:n,credentials:`include`});return r.ok||tn(e,t?.method,r.status,t?.body),r}catch(n){throw n instanceof DOMException&&n.name===`AbortError`?n:(tn(e,t?.method,0,t?.body,n),new R(0,`cannot reach the cezar server (${e})`,{cause:n}))}}async function un(e,t){return ln(c(e),t)}async function dn(e,t={}){let n=new Headers(t.headers);n.set(`accept`,`text/plain`);let r=await un(e,{...t,headers:n}),i=await r.text();if(!r.ok)throw B(r.status,r.statusText,i);return i}var W=(e,t=``)=>`/runs/${encodeURIComponent(e)}${t}`;async function fn(e){return U(await V.api.v1.health.$get({},H(e)),`/health`)}async function pn(e){return U(await V.api.v1[`star-count`].$get({},H(e)),`/star-count`)}async function mn(e){return U(await V.api.v1.preview[`design-proxy`].$post({json:e}),`/preview/design-proxy`)}async function hn(e){return U(await V.api.v1.telemetry.consent.$get({},H(e)),`/telemetry/consent`)}async function gn(e){return U(await V.api.v1.telemetry.consent.$put({json:e}),`/telemetry/consent`)}async function _n(e,t){return U(await V.api.v1.models.$get({query:{runner:e}},H(t)),`/models`)}async function vn(e=!1,t){return L(await U(await V.api.v1.providers.status.$get({query:e?{refresh:`1`}:{}},H(t)),`/providers/status`))}async function yn(e){return U(await V.api.v1.p[`:projectId`][`launch-key`].$get({param:{projectId:r()}},H(e)),`/launch-key`)}async function bn(e){return U(await V.api.v1.projects.$get({},H(e)),`/projects`)}async function xn(e,t){return U(await V.api.v1.fs.browse.$get({query:{path:e===``?void 0:e,...t?.showHidden?{showHidden:`1`}:{}}},H(t)),`/fs/browse`)}async function Sn(e){return U(await V.api.v1.p[`:projectId`].runs.$get({param:{projectId:r()}},H(e)),`/runs`)}async function Cn(e,t){return U(await V.api.v1.p[`:projectId`].runs.$get({param:{projectId:e}},H(t)),`/runs`)}async function wn(e){return U(await V.api.v1.workspace[`runs-index`].$get({},H(e)),`/workspace/runs-index`)}async function Tn(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),W(e))}async function En(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].$get({param:{projectId:e,id:encodeURIComponent(t)}},H(n)),W(t))}async function Dn(e,t,n){return cn(await V.api.v1.p[`:projectId`].runs[`:id`].history.$get({param:{projectId:r(),id:encodeURIComponent(e)},query:{...t===void 0?{}:{cursor:t}}},H(n)),`${W(e)}/history`,a)}async function On(e,t){return cn(await V.api.v1.p[`:projectId`].runs[`:id`][`history-context`].$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),`${W(e)}/history-context`,m)}async function kn(e){return U(await V.api.v1.p[`:projectId`][`ui-state`].$get({param:{projectId:r()}},H(e)),`/ui-state`)}async function An(e){return U(await V.api.v1.p[`:projectId`].workflows.$get({param:{projectId:r()}},H(e)),`/workflows`)}async function jn(e){return U(await V.api.v1.p[`:projectId`].skills.$get({param:{projectId:r()},query:{}},H(e)),`/skills`)}async function Mn(e){return U(await V.api.v1.p[`:projectId`].skills.$get({param:{projectId:r()},query:{wait:`1`}},H(e)),`/skills`)}async function Nn(){return U(await V.api.v1.p[`:projectId`].skills.refresh.$post({param:{projectId:r()}}),`/skills/refresh`)}async function Pn(e){return U(await V.api.v1.p[`:projectId`].skills.importable.$get({param:{projectId:r()},query:{}},H(e)),`/skills/importable`)}async function Fn(e){return U(await V.api.v1.p[`:projectId`].skills.importable.$get({param:{projectId:r()},query:{wait:`1`}},H(e)),`/skills/importable`)}async function In(e){return U(await V.api.v1.p[`:projectId`].todos.$get({param:{projectId:r()}},H(e)),`/todos`)}async function Ln(e){return U(await V.api.v1.p[`:projectId`].repo.$get({param:{projectId:r()}},H(e)),`/repo`)}async function Rn(e){return U(await V.api.v1.p[`:projectId`].config.$get({param:{projectId:r()}},H(e)),`/config`)}async function zn(e={}){return U(await V.api.v1.p[`:projectId`][`agent-config`].$get({param:{projectId:r()}},H(e)),`/agent-config`)}async function Bn(e,t={}){return U(await V.api.v1.p[`:projectId`][`agent-config`][`:id`].$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),`/agent-config/${encodeURIComponent(e)}`)}async function Vn(e,t){return U(await V.api.v1.p[`:projectId`][`agent-config`][`:id`].$put({param:{projectId:r(),id:encodeURIComponent(e)},json:t}),`/agent-config/${encodeURIComponent(e)}`)}async function Hn(e){return U(await V.api.v1.p[`:projectId`].repo.changes.$get({param:{projectId:r()}},H(e)),`/repo/changes`)}async function Un(e){return U(await V.api.v1.p[`:projectId`].repo.tree.$get({param:{projectId:r()}},H(e)),`/repo/tree`)}async function Wn(e,t){return U(await V.api.v1.p[`:projectId`].repo.files.$get({param:{projectId:r()},query:{path:e}},H(t)),`/repo/files`)}function Gn(e){return c(`/repo/files?path=${encodeURIComponent(e)}&raw=1`)}async function Kn(e,t){return U(await V.api.v1.p[`:projectId`].repo.commit[`:sha`].$get({param:{projectId:r(),sha:encodeURIComponent(e)},query:{structured:`1`}},H(t)),`/repo/commit/:sha`)}async function qn(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].tree.$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),W(e,`/tree`))}async function Jn(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].commits.$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),W(e,`/commits`))}async function Yn(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].commit[`:sha`].$get({param:{projectId:r(),id:encodeURIComponent(e),sha:encodeURIComponent(t)}},H(n)),W(e,`/commit/${encodeURIComponent(t)}`))}async function Xn(e={},t){return U(await V.api.v1.p[`:projectId`].github.$get({param:{projectId:r()},query:{limit:e.limit===void 0?void 0:String(e.limit),refresh:e.refresh?`1`:void 0,issuesCursor:e.issuesCursor,prsCursor:e.prsCursor}},H(t)),`/github`)}async function Zn(e={},t){return U(await V.api.v1.p[`:projectId`].tracker[`automation-options`].$get({param:{projectId:r()},query:e},H(t)),`/tracker/automation-options`)}async function Qn(e){return U(await V.api.v1.p[`:projectId`].tracker.connection.$get({param:{projectId:r()}},H(e)),`/tracker/connection`)}async function $n(e){return U(await V.api.v1.p[`:projectId`].tracker.connection.$put({param:{projectId:r()},json:e}),`/tracker/connection`)}async function er(){return U(await V.api.v1.p[`:projectId`].tracker.connection.$delete({param:{projectId:r()}}),`/tracker/connection`)}async function tr(e){return U(await V.api.v1.p[`:projectId`].secrets.$get({param:{projectId:r()}},H(e)),`/secrets`)}async function nr(e){return U(await V.api.v1.workspace.secrets.$get({},H(e)),`/workspace/secrets`)}async function rr(e){if(!e.ok)throw B(e.status,e.statusText,await e.text())}async function ir(e,t){await rr(await V.api.v1.p[`:projectId`].secrets[`:name`].$put({param:{projectId:r(),name:e},json:t}))}async function ar(e){await rr(await V.api.v1.p[`:projectId`].secrets[`:name`].$delete({param:{projectId:r(),name:e}}))}async function or(e,t){await rr(await V.api.v1.workspace.secrets[`:name`].$put({param:{name:e},json:t}))}async function sr(e){await rr(await V.api.v1.workspace.secrets[`:name`].$delete({param:{name:e}}))}async function cr(e){return U(await V.api.v1.p[`:projectId`].e2e.$get({param:{projectId:r()}},H(e)),`/e2e`)}async function lr(e){return U(await V.api.v1.p[`:projectId`].e2e.setup.$post({param:{projectId:r()},json:e}),`/e2e/setup`)}async function ur(e){return U(await V.api.v1.p[`:projectId`].tracker.association.$get({param:{projectId:r()}},H(e)),`/tracker/association`)}async function dr(e,t={},n){return U(await V.api.v1.p[`:projectId`].tracker.candidates.$get({param:{projectId:r()},query:{kind:e,q:t.q,cursor:t.cursor,limit:t.limit===void 0?void 0:String(t.limit)}},H(n)),`/tracker/candidates`)}async function fr(e){return U(await V.api.v1.p[`:projectId`].tracker.association.$put({param:{projectId:r()},json:e}),`/tracker/association`)}async function pr(){return U(await V.api.v1.p[`:projectId`].tracker.association.$delete({param:{projectId:r()}}),`/tracker/association`)}function mr(e){return{expectedScope:e.association?i(e.association):void 0,cursor:e.cursor,limit:e.limit===void 0?void 0:String(e.limit),refresh:e.refresh?`1`:void 0,state:e.state,labels:e.labels?.length?JSON.stringify(e.labels):void 0}}async function hr(e={},t){return U(await V.api.v1.p[`:projectId`].tracker.$get({param:{projectId:r()},query:mr(e)},H(t)),`/tracker`)}async function gr(e,t={},n){return U(await V.api.v1.p[`:projectId`].tracker.search.$get({param:{projectId:r()},query:{...mr(t),q:e}},H(n)),`/tracker/search`)}async function _r(e,t){return U(await V.api.v1.p[`:projectId`].tracker[`:id`].$get({param:{projectId:r(),id:encodeURIComponent(e)},query:{expectedScope:t?.association?i(t.association):void 0}},H(t)),`/tracker/${encodeURIComponent(e)}`)}async function vr(e,t){return U(await V.api.v1.p[`:projectId`].github.checks.$get({param:{projectId:r()},query:{prs:e.join(`,`)}},H(t)),`/github/checks`)}async function yr(e,t,n={},i){return U(await V.api.v1.p[`:projectId`].github.search.$get({param:{projectId:r()},query:{kind:e,q:t,limit:n.limit}},H(i)),`/github/search`)}async function br(e,t,n){return U(await V.api.v1.p[`:projectId`].github[`ref-status`].$get({param:{projectId:e},query:{...t.prs?.length?{prs:t.prs.join(`,`)}:{},...t.issues?.length?{issues:t.issues.join(`,`)}:{}}},H(n)),`/github/ref-status`)}async function xr(e,t,n={},i){return U(await V.api.v1.p[`:projectId`].github.comments[`:kind`][`:number`].$get({param:{projectId:r(),kind:e,number:String(t)},query:{refresh:n.refresh?`1`:void 0}},H(i)),`/github/comments/${e}/${t}`)}async function Sr(e,t={},n){return U(await V.api.v1.p[`:projectId`].github.prs[`:number`][`merge-state`].$get({param:{projectId:r(),number:String(e)},query:{refresh:t.refresh?`1`:void 0}},H(n)),`/github/prs/${e}/merge-state`)}async function Cr(e,t){return U(await V.api.v1.p[`:projectId`].github.prs[`:number`].merge.$post({param:{projectId:r(),number:String(e)},json:t}),`/github/prs/:number/merge`)}async function wr(e,t={},n){return U(await V.api.v1.p[`:projectId`].github.prs[`:number`].changes.$get({param:{projectId:r(),number:String(e)},query:{refresh:t.refresh?`1`:void 0}},H(n)),`/github/prs/${e}/changes`)}function Tr(e,t){return dn(W(e,`/diff`),{method:`GET`,signal:t?.signal})}function Er(e,t){return dn(W(e,`/handoff`),{method:`GET`,signal:t?.signal})}async function Dr(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].changes.$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),W(e,`/changes`))}async function Or(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].files.$get({param:{projectId:r(),id:encodeURIComponent(e)},query:{path:t}},H(n)),`/runs/:id/files`)}function kr(e,t){return c(W(e,`/files?path=${encodeURIComponent(t)}&raw=1`))}async function Ar(e,t){return U(await V.api.v1.p[`:projectId`].groups[`:groupId`].$get({param:{projectId:r(),groupId:encodeURIComponent(e)}},H(t)),`/groups/${encodeURIComponent(e)}`)}async function jr(e,t){return U(await V.api.v1.providers.connect.$post({json:{provider:e,...t?{profileId:t}:{}}}),`/providers/connect`)}async function Mr(e){return U(await V.api.v1.providers[`:provider`].update.$post({param:{provider:e}}),`/providers/${encodeURIComponent(e)}/update`)}async function Nr(e,t){return L(await U(await V.api.v1.providers[`:provider`].enabled.$put({param:{provider:e},json:{enabled:t}}),`/providers/${encodeURIComponent(e)}/enabled`))}async function Pr(e,t){return L(await U(await V.api.v1.providers[`:provider`].retry.$post({param:{provider:e},json:{authFailureId:t}}),`/providers/${encodeURIComponent(e)}/retry`))}async function Fr(e){let t=`/projects`,n=await un(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({root:e})}),r=await n.text(),i=z(r),a=i?.project;if((n.ok||n.status===409)&&a!=null)return i;throw n.ok?new R(n.status,`the cezar server answered ${t} without a project`):B(n.status,n.statusText,r)}async function Ir(e){return U(await V.api.v1.projects.checkout.$post({json:e}),`/projects/checkout`)}async function Lr(e){return U(await V.api.v1.projects.create.$post({json:e}),`/projects/create`)}async function Rr(e){return cn(await V.api.v1.projects[`github-owners`].$get({},H(e)),`/projects/github-owners`,d)}async function zr(e){return U(await V.api.v1.projects[`:projectId`].$delete({param:{projectId:encodeURIComponent(e)}}),`/projects/${encodeURIComponent(e)}`)}async function Br(e,t){return U(await V.api.v1.projects[`:projectId`].$patch({param:{projectId:encodeURIComponent(e)},json:t}),`/projects/${encodeURIComponent(e)}`)}async function Vr(e){return U(await V.api.v1.p[`:projectId`].runs.$post({param:{projectId:r()},json:e}),`/runs`)}async function Hr(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].cancel.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/cancel`))}async function Ur(e,t=!0,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].archive.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{archived:t,...n?{surface:n}:{}}}),W(e,`/archive`))}async function Wr(e,t=!0,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].pin.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{pinned:t,...n?{surface:n}:{}}}),W(e,`/pin`))}async function Gr(e,t,n=!0,r){return U(await V.api.v1.p[`:projectId`].runs[`:id`].pin.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{pinned:n,...r?{surface:r}:{}}}),W(t,`/pin`))}async function Kr(e,t,n=!0,r){return U(await V.api.v1.p[`:projectId`].runs[`:id`].archive.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{archived:n,...r?{surface:r}:{}}}),W(t,`/archive`))}async function qr(e,t,n){let r=n?`read`:`unread`;return U(await(n?V.api.v1.p[`:projectId`].runs[`:id`].read.$post({param:{projectId:e,id:encodeURIComponent(t)}}):V.api.v1.p[`:projectId`].runs[`:id`].unread.$post({param:{projectId:e,id:encodeURIComponent(t)}})),W(t,`/${r}`))}async function Jr(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`auto-resume`].$delete({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/auto-resume`))}async function Yr(){return U(await V.api.v1.p[`:projectId`].runs[`archive-finished`].$post({param:{projectId:r()}}),`/runs/archive-finished`)}async function Xr(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].read.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/read`))}async function Zr(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].unread.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/unread`))}async function Qr(){return U(await V.api.v1.p[`:projectId`].runs[`read-all`].$post({param:{projectId:r()}}),`/runs/read-all`)}async function $r(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].finish.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/finish`))}async function ei(e,t={}){let n={...t.text===void 0?{}:{text:t.text},...t.images===void 0?{}:{images:t.images},...t.runner===void 0?{}:{runner:t.runner},...t.model===void 0?{}:{model:t.model},...t.agentProfile===void 0?{}:{agentProfile:t.agentProfile}};return U(await V.api.v1.p[`:projectId`].runs[`:id`].continue.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:n}),W(e,`/continue`))}async function ti(e,t,n={}){return U(await V.api.v1.p[`:projectId`].runs[`:id`].continue.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{...n.text===void 0?{}:{text:n.text},...n.images===void 0?{}:{images:n.images},...n.runner===void 0?{}:{runner:n.runner},...n.model===void 0?{}:{model:n.model},...n.agentProfile===void 0?{}:{agentProfile:n.agentProfile}}}),W(t,`/continue`))}var ni=1e3;async function ri(e,t={}){let n=r(),i=async()=>U(await V.api.v1.p[`:projectId`].runs[`:id`].pr.$post({param:{projectId:n,id:encodeURIComponent(e)},json:t}),W(e,`/pr`));try{return await i()}catch(e){if(!(e instanceof R)||e.status!==0)throw e;await new Promise(e=>setTimeout(e,ni));try{return await i()}catch(t){throw t instanceof R&&t.status===0?e:t}}}async function ii(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].pr.adopt.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/pr/adopt`))}async function ai(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].$patch({param:{projectId:r(),id:encodeURIComponent(e)},json:t}),W(e))}async function oi(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].$delete({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e))}async function si(e){return U(await V.api.v1.p[`:projectId`].todos[`:id`].$delete({param:{projectId:r(),id:encodeURIComponent(e)}}),`/todos/${encodeURIComponent(e)}`)}async function ci(e,t={}){let n={...t.runner===void 0?{}:{runner:t.runner},...t.model===void 0?{}:{model:t.model},...t.prompt===void 0?{}:{prompt:t.prompt}};return U(await V.api.v1.p[`:projectId`].todos[`:id`].start.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:Object.keys(n).length>0?n:void 0}),`/todos/${encodeURIComponent(e)}/start`)}async function li(e,t){return U(await V.api.v1.p[`:projectId`].groups[`:groupId`].pick.$post({param:{projectId:r(),groupId:encodeURIComponent(e)},json:{runId:t}}),`/groups/${encodeURIComponent(e)}/pick`)}async function ui(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`open-in-cli`].$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/open-in-cli`))}async function di(e){return U(await V.api.v1.p[`:projectId`][`open-targets`].$get({param:{projectId:r()}},H(e)),`/open-targets`)}async function fi(e){return U(await V.api.v1.p[`:projectId`][`open-in`].$post({param:{projectId:r()},json:{target:e}}),`/open-in`)}async function pi(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`open-in`].$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{target:t}}),W(e,`/open-in`))}async function mi(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`open-in`].$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{target:`default`,path:t}}),W(e,`/open-in`))}async function hi(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].git.commit.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{message:t}}),W(e,`/git/commit`))}async function gi(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].git.status.$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),W(e,`/git/status`))}async function _i(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].git.push.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/git/push`))}async function vi(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].messages.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{text:t.text??``,images:t.images??[]}}),W(e,`/messages`))}async function yi(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].messages.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{text:n.text??``,images:n.images??[]}}),W(t,`/messages`))}async function bi(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`queued-messages`][`:msgId`].$patch({param:{projectId:r(),id:encodeURIComponent(e),msgId:encodeURIComponent(t)},json:n}),W(e,`/queued-messages/${encodeURIComponent(t)}`))}async function xi(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`queued-messages`][`:msgId`].$delete({param:{projectId:r(),id:encodeURIComponent(e),msgId:encodeURIComponent(t)}}),W(e,`/queued-messages/${encodeURIComponent(t)}`))}async function Si(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].drafts.$get({param:{projectId:r(),id:encodeURIComponent(e)}},H(t)),W(e,`/drafts`))}var Ci=56*1024;async function wi(e,t,n,i){let a=i?.keepalive===!0&&new TextEncoder().encode(JSON.stringify(n)).length<=Ci;return U(await V.api.v1.p[`:projectId`].runs[`:id`].drafts[`:surface`].$put({param:{projectId:r(),id:encodeURIComponent(e),surface:t},json:n},{init:{keepalive:a}}),W(e,`/drafts/${t}`))}async function Ti(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].drafts[`:surface`].images.$post({param:{projectId:r(),id:encodeURIComponent(e),surface:t},json:n}),W(e,`/drafts/${t}/images`))}async function Ei(e){return U(await V.api.v1.workspace.uploads.$post({json:e}),`/workspace/uploads`)}async function Di(e){return U(await V.api.v1.workspace.uploads[`:uploadId`].$delete({param:{uploadId:e}}),`/workspace/uploads/${e}`)}async function Oi(e,t,n,i){return U(await V.api.v1.p[`:projectId`].runs[`:id`].drafts[`:surface`].images[`:imageId`].$get({param:{projectId:r(),id:encodeURIComponent(e),surface:t,imageId:n}},H(i)),W(e,`/drafts/${t}/images/${n}`))}async function ki(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].drafts[`:surface`].images[`:imageId`].$delete({param:{projectId:r(),id:encodeURIComponent(e),surface:t,imageId:n}}),W(e,`/drafts/${t}/images/${n}`))}async function Ai(e){return U(await V.api.v1.p[`:projectId`].repo.branch.$post({param:{projectId:r()},json:e}),`/repo/branch`)}async function ji(e){return U(await V.api.v1.p[`:projectId`].repo.sync.$get({param:{projectId:r()}},H(e)),`/repo/sync`)}async function Mi(e){let t={param:{projectId:r()}},n=V.api.v1.p[`:projectId`].repo;return U(e===`fetch`?await n.fetch.$post(t):e===`pull`?await n.pull.$post(t):e===`push`?await n.push.$post(t):await n.sync.$post(t),`/repo/${e}`)}async function Ni(e){return U(await V.api.v1.p[`:projectId`].plan.$post({param:{projectId:r()},json:{task:e}}),`/plan`)}async function Pi(e){return U(await V.api.v1.p[`:projectId`].automations.$get({param:{projectId:r()}},H(e)),`/automations`)}async function Fi(e){return U(await V.api.v1.p[`:projectId`].automations.$post({param:{projectId:r()},json:e}),`/automations`)}async function Ii(e,t){return U(await V.api.v1.p[`:projectId`].automations[`:id`].$put({param:{projectId:r(),id:encodeURIComponent(e)},json:t}),`/automations/${encodeURIComponent(e)}`)}async function Li(e,t){let n={projectId:r(),id:encodeURIComponent(e)},i=`/automations/${encodeURIComponent(e)}/${t?`enable`:`pause`}`;return U(t?await V.api.v1.p[`:projectId`].automations[`:id`].enable.$post({param:n}):await V.api.v1.p[`:projectId`].automations[`:id`].pause.$post({param:n}),i)}async function Ri(e,t){return U(await V.api.v1.p[`:projectId`].automations[`:id`].check.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:{mode:t}}),`/automations/${encodeURIComponent(e)}/check`)}async function zi(e,t){return U(await V.api.v1.p[`:projectId`][`automation-log`].$get({param:{projectId:r()},query:{automationId:e}},H(t)),`/automation-log?automationId=${encodeURIComponent(e)}`)}async function Bi(e){return U(await V.api.v1.p[`:projectId`][`automation-log`][`:receiptId`].retry.$post({param:{projectId:r(),receiptId:encodeURIComponent(e)}}),`/automation-log/${encodeURIComponent(e)}/retry`)}async function Vi(e){return U(await V.api.v1.p[`:projectId`].automations[`:id`].run.$post({param:{projectId:r(),id:encodeURIComponent(e)}}),`/automations/${encodeURIComponent(e)}/run`)}async function Hi(e){let t=await V.api.v1.p[`:projectId`].automations[`:id`].$delete({param:{projectId:r(),id:encodeURIComponent(e)}});if(!t.ok)throw B(t.status,t.statusText,await t.text())}async function Ui(e,t){return U(await V.api.v1.workspace[`automation-templates`].$get({query:e?{exclude:e}:{}},H(t)),`/workspace/automation-templates`)}async function Wi(e){return U(await V.api.v1.p[`:projectId`].workflows.$post({param:{projectId:r()},json:e}),`/workflows`)}async function Gi(e){return U(await V.api.v1.p[`:projectId`].workflows.nodes.$get({param:{projectId:r()}},H(e)),`/workflows/nodes`)}async function Ki(e){return U(await V.api.v1.p[`:projectId`].workflows.validate.$post({param:{projectId:r()},json:{graph:e}}),`/workflows/validate`)}async function qi(e){return U(await V.api.v1.p[`:projectId`].workflows.graph.$post({param:{projectId:r()},json:e}),`/workflows/graph`)}async function Ji(e){return U(await V.api.v1.p[`:projectId`].workflows.parse.$post({param:{projectId:r()},json:{yaml:e}}),`/workflows/parse`)}async function Yi(e){return U(await V.api.v1.p[`:projectId`].workflows[`:name`].$delete({param:{projectId:r(),name:encodeURIComponent(e)}}),`/workflows/${encodeURIComponent(e)}`)}async function Xi(e,t=r()){return U(await V.api.v1.p[`:projectId`][`ui-state`].$put({param:{projectId:t},json:e}),`/ui-state`)}async function Zi(e){return U(await V.api.v1.workspace[`ui-state`].$get({},H(e)),`/workspace/ui-state`)}async function Qi(e,t={}){return U(await V.api.v1.workspace[`ui-state`].$put({json:e},{init:{keepalive:t.keepalive}}),`/workspace/ui-state`)}async function $i(e){let t=await U(await V.api.v1.workspace.config.$get({},H(e)),`/workspace/config`);return{...t,branding:t.branding?{...t.branding,logoUrl:t.branding.logoUrl?p(t.branding.logoUrl):null}:{name:`cezar`,logoUrl:null},agentDefaults:t.agentDefaults??{},resources:{...t.resources,idleTimeoutMinutes:t.resources.idleTimeoutMinutes===void 0?15:t.resources.idleTimeoutMinutes}}}async function ea(e){let t=new FormData;t.set(`file`,e);let n=await un(`/workspace/branding-logo`,{method:`POST`,body:t}),r=await n.text();if(!n.ok)throw B(n.status,n.statusText,r);let i=z(r),a=g.safeParse(i);if(!a.success)throw new R(n.status,`the cezar server answered /workspace/branding-logo with an unexpected body`);return a.data.logoUrl?p(a.data.logoUrl):null}async function ta(){let e=await un(`/workspace/branding-logo`,{method:`DELETE`}),t=await e.text();if(!e.ok)throw B(e.status,e.statusText,t);let n=g.safeParse(z(t));if(!n.success)throw new R(e.status,`the cezar server answered /workspace/branding-logo with an unexpected body`);return n.data.logoUrl?p(n.data.logoUrl):null}async function na(e){return U(await V.api.v1.workspace[`host-usage`].$get({},H(e)),`/workspace/host-usage`)}async function ra(e){let t=await U(await V.api.v1.workspace[`agent-profiles`].$get({},H(e)),`/workspace/agent-profiles`);return{...t,profileCapableProviders:t.profileCapableProviders??[],selections:t.selections??{},defaults:t.defaults??{},profiles:(t.profiles??[]).map(e=>({...e,files:e.files??[]}))}}async function ia(e){return U(await V.api.v1.workspace[`agent-profiles`].$post({json:e}),`/workspace/agent-profiles`)}async function aa(e,t){return U(await V.api.v1.workspace[`agent-profiles`][`:id`].status.$get({param:{id:encodeURIComponent(e)},query:{...t?.refresh||t?.recheck?{refresh:`1`}:{},...t?.recheck?{recheck:`1`}:{}}},H(t)),`/workspace/agent-profiles/${encodeURIComponent(e)}/status`)}async function oa(e,t){return U(await V.api.v1.workspace[`agent-profiles`][`:id`].details.$get({param:{id:encodeURIComponent(e)}},H(t)),`/workspace/agent-profiles/${encodeURIComponent(e)}/details`)}async function sa(e,t){return U(await V.api.v1.workspace[`agent-profiles`][`:id`].open.$post({param:{id:encodeURIComponent(e)},json:t}),`/workspace/agent-profiles/${encodeURIComponent(e)}/open`)}async function ca(e){return U(await V.api.v1.workspace[`agent-profiles`].selection.$put({json:e}),`/workspace/agent-profiles/selection`)}async function la(e,t){return U(await V.api.v1.workspace[`agent-profiles`][`:id`].$patch({param:{id:encodeURIComponent(e)},json:t}),`/workspace/agent-profiles/${encodeURIComponent(e)}`)}async function ua(e){return U(await V.api.v1.workspace[`agent-profiles`][`:id`].$delete({param:{id:encodeURIComponent(e)}}),`/workspace/agent-profiles/${encodeURIComponent(e)}`)}async function da(e,t){return U(await V.api.v1.workspace[`skills-update`].$get({query:{projectId:e}},H(t)),`/workspace/skills-update?projectId=${encodeURIComponent(e)}`)}async function fa(e){return U(await V.api.v1.workspace[`skills-update`].check.$post({json:{projectId:e}}),`/workspace/skills-update/check`)}async function pa(e){return U(await V.api.v1.workspace[`skills-update`].apply.$post({json:{projectId:e}}),`/workspace/skills-update/apply`)}async function ma(e){return U(await V.api.v1.workspace[`self-update`].$get({},H(e)),`/workspace/self-update`)}async function ha(){return U(await V.api.v1.workspace[`self-update`].refresh.$post({}),`/workspace/self-update/refresh`)}async function ga(e){return U(await V.api.v1.workspace[`self-update`].development.$get({query:e?.refresh?{refresh:`1`}:{}},H(e)),`/workspace/self-update/development`)}async function _a(e){return U(await V.api.v1.workspace[`self-update`].channel.$put({json:{channel:e}}),`/workspace/self-update/channel`)}async function va(e){return U(await V.api.v1.workspace[`self-update`].apply.$post({json:{version:e}}),`/workspace/self-update/apply`)}async function ya(e){return U(await V.api.v1.workspace[`self-update`].apply.$post({json:{version:e,whenIdle:!0}}),`/workspace/self-update/apply`)}async function ba(){return U(await V.api.v1.workspace[`self-update`].scheduled.$delete({}),`/workspace/self-update/scheduled`)}async function xa(e){return U(await V.api.v1.workspace.config.$put({json:e}),`/workspace/config`)}async function Sa(e){return U(await V.api.v1.p[`:projectId`].config.$put({param:{projectId:r()},json:e}),`/config`)}async function Ca(e){return U(await V.api.v1.p[`:projectId`].worktrees.$get({param:{projectId:r()}},H(e)),`/worktrees`)}async function wa(){return U(await V.api.v1.p[`:projectId`].worktrees.reclaim.$post({param:{projectId:r()},json:{}}),`/worktrees/reclaim`)}async function Ta(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`][`remove-worktree`].$post({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/remove-worktree`))}async function Ea(e,t,n){return s.parse(await U(await V.api.v1.p[`:projectId`].tracker.watch.$post({param:{projectId:e},json:t},{init:{signal:n}}),`/tracker/watch`))}async function Da(e,t,n,r){return u.parse(await U(await V.api.v1.p[`:projectId`].tracker.watch[`:watchId`].$get({param:{projectId:e,watchId:t},query:{after:r===void 0?void 0:String(r)}},{init:{signal:n}}),`/tracker/watch`))}async function Oa(e,t,n){return u.parse(await U(await V.api.v1.p[`:projectId`].tracker.watch[`:watchId`].$post({param:{projectId:e,watchId:t}},{init:{signal:n}}),`/tracker/watch`))}async function ka(e={limit:50},t){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`].$get({param:{projectId:r()},query:{cursor:e.cursor,limit:e.limit,attentionOnly:e.attentionOnly===void 0?void 0:e.attentionOnly?`true`:`false`}},H(t)),`/worktree-lifecycle`)}async function Aa(e,t){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`][`:worktreeId`].$get({param:{projectId:r(),worktreeId:e}},H(t)),`/worktree-lifecycle`)}async function ja(e,t){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`].operations[`:operationId`].$get({param:{projectId:r(),operationId:e}},H(t)),`/worktree-lifecycle/operations`)}async function Ma(e,t=0,n){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`].operations[`:operationId`].output.$get({param:{projectId:r(),operationId:e},query:{afterSeq:t,limit:100}},H(n)),`/worktree-lifecycle/operations/output`)}async function Na(e){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`].operations.$post({param:{projectId:r()},json:e}),`/worktree-lifecycle/operations`)}async function Pa(e,t){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`].operations[`:operationId`].actions.$post({param:{projectId:r(),operationId:e},json:t}),`/worktree-lifecycle/operations/actions`)}async function Fa(e){return U(await V.api.v1.p[`:projectId`][`worktree-lifecycle`].preview.$post({param:{projectId:r()},json:e}),`/worktree-lifecycle/preview`)}async function Ia(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal.$get({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/terminal`))}async function La(e,t){return U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal.$post({param:{projectId:r(),id:encodeURIComponent(e)},json:t}),W(e,`/terminal`))}async function Ra(e,t,n){return U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal[`:sessionId`].output.$get({param:{projectId:r(),id:encodeURIComponent(e),sessionId:t},query:{cursor:String(n)}}),W(e,`/terminal/${t}/output`))}async function za(e,t,n){await U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal[`:sessionId`].input.$post({param:{projectId:r(),id:encodeURIComponent(e),sessionId:t},json:{data:n}}),W(e,`/terminal/${t}/input`))}async function Ba(e,t,n,i){await U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal[`:sessionId`].resize.$post({param:{projectId:r(),id:encodeURIComponent(e),sessionId:t},json:{cols:n,rows:i}}),W(e,`/terminal/${t}/resize`))}async function Va(e,t){await U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal[`:sessionId`].$delete({param:{projectId:r(),id:encodeURIComponent(e),sessionId:t}}),W(e,`/terminal/${t}`))}async function Ha(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal.urls.$get({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/terminal/urls`))}async function Ua(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].terminal.commands.$get({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/terminal/commands`))}async function Wa(){return U(await V.api.v1.p[`:projectId`][`start-app`].$get({param:{projectId:r()}}),`/start-app`)}async function Ga(e){return U(await V.api.v1.p[`:projectId`][`start-app`].$put({param:{projectId:r()},json:e}),`/start-app`)}async function Ka(e){return U(await V.api.v1.p[`:projectId`].runs[`:id`].layouts.$get({param:{projectId:r(),id:encodeURIComponent(e)}}),W(e,`/layouts`))}async function qa(e,t,n){let i=n?.keepalive===!0&&new TextEncoder().encode(JSON.stringify(t)).length<=Ci;return U(await V.api.v1.p[`:projectId`].runs[`:id`].layouts.$put({param:{projectId:r(),id:encodeURIComponent(e)},json:t},{init:{keepalive:i}}),W(e,`/layouts`))}function Ja(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}if(!Ya(n))return null;let r=n.project;if(typeof r!=`string`||r===``)return null;switch(e){case`run`:{let{project:e,...t}=n;return Xa(t)?{project:r,event:{type:`run`,run:t}}:null}case`run-deleted`:{let e=n.id;return typeof e==`string`&&e?{project:r,event:{type:`run-deleted`,id:e}}:null}case`todos`:return Array.isArray(n.items)?{project:r,event:{type:`todos`,items:n.items}}:null;case`usage`:return Ya(n.usage)?{project:r,event:{type:`usage`,usage:n.usage}}:null;default:return null}}function Ya(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xa(e){return Ya(e)&&typeof e.id==`string`&&e.id!==``}function Za(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=$a(e[n],t),r}let r=t.createdAt??``,i=e.findIndex(e=>(e.createdAt??``).localeCompare(r)<0),a=[...e];return a.splice(i<0?e.length:i,0,t),a}function Qa(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}function $a(e,t){if(!e)return t;let n=e=>e===`user`?2:+(e===`marker`),r=n(e.titleOrigin)>n(t.titleOrigin)?{title:e.title,titleSummary:e.titleSummary,titleOrigin:e.titleOrigin}:{};return e.usage?{...t,...r,usage:e.usage}:{...t,...r}}var eo=Object.freeze({});function to(){let e=eo,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}var no={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`violet`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`violet`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},ro={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function io(e){return typeof e==`string`&&Object.hasOwn(no,e)}function ao(e){return e!==void 0&&io(e)?no[e]:void 0}var oo={permission:0,error:1,waiting:2,running:3,unseen:4,none:5};function so(e){return!1}function co(e){return!1}function lo(e){let t=e.dispatch?.overBudget?e.dispatch.budgetUsd:void 0;if(!(e.status!==`waiting`||t===void 0))return{spent:e.costUsd??0,ceiling:t}}function G(e){return e.status===`failed`&&e.awaitingAnswerSince!==void 0}function uo(e){return!!e.worktreeLifecycle?.needsAttention||e.status===`waiting`||e.status===`review`||G(e)}function fo(e){let t=e.worktreeLifecycle;return t?.needsAttention?{bucket:`waiting`,tone:`pending`,pulse:!1,label:t.phase===`setup`?`setup needs attention`:`cleanup needs attention`}:t?.activeOperationId?{bucket:`running`,tone:`pending`,pulse:!0,label:t.phase===`setup`?`preparing worktree`:`cleaning up worktree`}:so(e)?{bucket:`permission`,tone:`violet`,pulse:!0,label:`needs permission`}:e.status===`failed`&&e.autoResumeAt?{bucket:`none`,tone:`pending`,pulse:!1,label:`scheduled`}:G(e)?{bucket:`waiting`,tone:`pending`,pulse:!0,label:`needs you`}:e.status===`failed`?{bucket:`error`,tone:`danger`,pulse:!1,label:`failed`}:e.status===`waiting`?{bucket:`waiting`,tone:`pending`,pulse:!0,label:lo(e)?.ceiling===void 0?`needs you`:`budget reached`}:e.status===`review`?{bucket:`waiting`,tone:`violet`,pulse:!0,label:`needs review`}:e.status===`running`&&e.activity===`monitoring`?{bucket:`running`,tone:`violet`,pulse:!0,label:`monitoring`}:e.status===`running`?{bucket:`running`,tone:`violet`,pulse:!0,label:`running`}:co(e)?{bucket:`unseen`,tone:`violet`,pulse:!1,label:`unseen`}:e.status===`queued`?{bucket:`none`,tone:`neutral`,pulse:!1,label:`queued`}:e.status===`done`?{bucket:`none`,tone:`success`,pulse:!1,label:`done`}:{bucket:`none`,tone:`neutral`,pulse:!1,label:`cancelled`}}function po(e){return oo[fo(e).bucket]<=oo.waiting}var mo=[`Pinned`,`Needs you`,`Working`,`Recent`,`Archived`],ho={waiting:0,review:1,running:2,queued:4,done:5,failed:5,cancelled:5},go=3,_o=e=>e.status===`failed`&&e.autoResumeAt!==void 0?go:G(e)?ho.waiting??0:ho[e.status]??9;function vo(e,t){return t===`archived`?`Archived`:e.pinned?`Pinned`:uo(e)?`Needs you`:e.status===`running`||e.status===`queued`||e.status===`failed`&&e.autoResumeAt?`Working`:`Recent`}function yo(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function bo(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function xo(e,t){return t!==void 0&&bo(e).ref===t}function So(e){return e.title.replace(/ \([A-C]\)$/,``)}function Co(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}var wo=[{value:`recent`,label:`Recent`},{value:`created`,label:`Created`}];function To(e,t){let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?t.localeCompare(e):r-n}function Eo(e){if(e.lastActivityAt!==void 0)return e.lastActivityAt;let t=e.finishedAt??e.startedAt??e.createdAt;for(let n of e.steps??[]){let e=n.finishedAt??n.startedAt;e!==void 0&&To(e,t)<0&&(t=e)}return t}function Do(e,t){return t===`created`?e.createdAt:Eo(e)}function Oo(e){return e===`created`?`Created`:`Updated`}function ko(e,t){if(t===`archived`)return[{key:`rest`,label:null,runs:[...e]}];let n=new Map(e.map(e=>[e.id,e])),r=e=>{let t=new Set;for(let r=e;r&&!t.has(r.id);r=n.get(r.dispatch?.parentRunId??``)){if(r.pinned)return!0;t.add(r.id)}return!1},i=e.filter(r);if(i.length===0)return[{key:`rest`,label:null,runs:[...e]}];let a=e.filter(e=>!r(e));return[{key:`pinned`,label:`Pinned`,runs:i},...a.length>0?[{key:`rest`,label:`All tasks`,runs:a}]:[]]}function Ao(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=_o(e)-_o(n);if(r!==0)return r;if(_o(e)===go&&e.autoResumeAt&&n.autoResumeAt){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):To(Eo(e),Eo(n))})}function jo(e,t,n){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,r)=>{if(t!==`archived`){let t=Number(!!r.pinned)-Number(!!e.pinned);if(t!==0)return t}return To(Do(e,n),Do(r,n))})}function Mo(e,t){let n=Co(e),r=Ao(e,t),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])},o=new Set;for(let e of r){if(e.groupId){if(o.has(e.groupId))continue;o.add(e.groupId);let n=r.filter(t=>t.groupId===e.groupId).sort((e,t)=>(e.variant??``).localeCompare(t.variant??``));if(n.length>1){a(vo(e,t),{kind:`group`,groupId:e.groupId,title:So(e),members:n});continue}}a(vo(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null})}return mo.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function No(e,t){let n=[],r=t;for(let t of e){if(t.label===`Pinned`){n.push({label:t.label,rows:[...t.rows]});continue}if(r<=0)continue;let e=t.rows.slice(0,r);r-=e.length,n.push({label:t.label,rows:e})}return n}function Po(e){let t=0,n=0,r=0;for(let i of e){if(i.archived){n+=1;continue}t+=1,uo(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}var Fo=new Set([`running`,`waiting`]),Io=new Set([`done`,`failed`,`review`,`cancelled`]),Lo=new Set([`done`,`failed`,`cancelled`]);function Ro(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function zo(e){return e?`$${e>=10?e.toFixed(0):e.toFixed(2)}`:``}function Bo(e,t=new Date){if(e.status!==`failed`||!e.autoResumeAt)return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function Vo(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=e.steps.find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}function Ho(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[yo(e),e.branch??``,e.workflow,Vo(e)].some(e=>e.toLowerCase().includes(n))):[...e]}function Uo(e){return e.filter(e=>!e.archived&&Lo.has(e.status)&&!G(e)).length}function Wo(e,t=!1){if(!e)return;let n=e.trim().replace(/\/+$/,``),r=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(n),i=r?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(n),a=r??i;if(!a)return;let[,o,s]=a;if(!s||!o||!t&&o.toLowerCase()!==`github.com`)return;let c=s.replace(/\.git$/i,``).split(`/`).filter(Boolean),l=c[c.length-2],u=c[c.length-1];return l&&u?`https://${o.toLowerCase()}/${l}/${u}`:void 0}function Go(e){if(e.pullRequestUrl){let t=Number(K(e.pullRequestUrl));return{url:e.pullRequestUrl,...t>0?{number:t}:{}}}let t=e.prRefs?.find(e=>e.origin===`created`||e.origin===`marker`);if(t)return{number:t.number,...t.url?{url:t.url}:{}};let n=e.markerRefs?.pr;return n===void 0?void 0:{number:n}}function Ko(e){return qo(e)[0]?.url??Jo(e)[0]}function qo(e,t){if(!e.prRefs?.length)return Jo(e).map(e=>({number:Number(K(e)),url:e,origin:`legacy`})).filter(e=>Number.isInteger(e.number)&&e.number>0);let n={created:0,marker:1,legacy:2,derived:3};return[...e.prRefs].sort((e,t)=>n[e.origin]-n[t.origin]).map(e=>({number:e.number,url:e.url??ts(`PR`,e.number,t),origin:e.origin}))}function Jo(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function Yo(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.markerRefs?.issue??e.issueNumber;if(!(!n||!t)&&!Xo(e.referencedIssueCandidates,n,t))return`${t}/issues/${n}`}function Xo(e,t,n){let r=`${n.toLowerCase()}/`;return(e??[]).some(e=>e.endsWith(`/${t}`)&&!e.toLowerCase().startsWith(r))}function Zo(e,t){return e.map((e,t)=>({reference:e,index:t})).sort((e,n)=>{let r=e.reference.kind===`PR`&&t(e.reference)===`closed`,i=n.reference.kind===`PR`&&t(n.reference)===`closed`;return Number(r)-Number(i)||e.index-n.index}).map(({reference:e})=>e)}function Qo(e,t){let n=e.prRefs?.length?qo(e,t).map(e=>({number:e.number,url:e.url})):Jo(e).map(e=>({url:e,number:Number(K(e))||void 0})),r=e.markerRefs?.pr,i=[...r===void 0||n.some(e=>e.number===r)?[]:[{kind:`PR`,number:r}],...n.map(e=>({kind:`PR`,url:e.url,number:e.number})),{kind:`PR`,number:es(e,t)},{kind:`Issue`,url:Yo(e,t)},{kind:`Issue`,number:$o(e,t)}],a=new Set,o=[];for(let e of i){let n=e.url?Number(K(e.url)):e.number;if(!n||!Number.isInteger(n))continue;let r=e.url??ts(e.kind,n,t),i=o.findIndex(t=>t.kind===e.kind&&t.number===n&&(!t.url||!r||t.url===r));if(i>=0){!o[i].url&&r&&(o[i]={...o[i],url:r});continue}let s=`${e.kind}#${n}#${r??``}`;a.has(s)||(a.add(s),o.push({kind:e.kind,number:n,...r?{url:r}:{}}))}return o}function $o(e,t){let n=e.issueNumber;return n===void 0||!t?n:Xo(e.referencedIssueCandidates,n,t)?void 0:n}function es(e,t){let n=e.prNumber;return n===void 0||!t?n:Xo(e.referencedPrCandidates,n,t)?void 0:n}function ts(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function ns(e,t){return Qo(e,t)[0]}function K(e){let t=e.split(`/`).pop()??``;return/^\d+$/.test(t)?t:null}function rs(e,t){let n=Fo.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:Ro(n.rssBytes),kind:`live`}};let r=Ro(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function is(e,t){let n=e.filter(e=>t===`archived`?e.archived:!e.archived),r=new Map;for(let e of n){if(!e.groupId)continue;let t=r.get(e.groupId);t?t.push(e):r.set(e.groupId,[e])}return[...r.entries()].flatMap(([e,t])=>{let n=t[0];return!n||t.length<2||!t.every(e=>Io.has(e.status))?[]:[{groupId:e,title:So(n),count:t.length}]})}function as(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function os(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function ss(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}var cs=`/api/v1/ws`,ls=3e3,us=1e3,ds=7e4,fs=0,ps=1;function ms(e){let t=new Map,n=new Map,r=null,i,a,o,s=()=>{clearTimeout(o),o=setTimeout(()=>{o=void 0,r?.close()},ds)},c=()=>e??`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${cs}`,l=e=>{r?.readyState===ps&&r.send(JSON.stringify(e))},u=()=>{let e=globalThis.WebSocket;if(typeof e!=`function`||r&&(r.readyState===fs||r.readyState===ps))return;let a=new e(c());r=a,a.addEventListener(`open`,()=>{if(a===r){s();for(let e of t.keys())l({type:`subscribe`,topic:e})}}),a.addEventListener(`message`,e=>{if(a!==r)return;s();let i;try{i=JSON.parse(e.data)}catch{return}if(typeof i!=`object`||!i)return;let{type:o,topic:c,data:l}=i;if(typeof c!=`string`)return;if(o===`error`){for(let e of[...n.get(c)??[]])e();return}if(o!==`event`)return;let u=t.get(c);if(u)for(let e of[...u])e(l)}),a.addEventListener(`close`,()=>{a===r&&(r=null,clearTimeout(o),o=void 0,t.size>0&&i===void 0&&(i=setTimeout(()=>{i=void 0,t.size>0&&u()},ls)))}),a.addEventListener(`error`,()=>void 0)};return{subscribe(e,s,c){let d=()=>c?.();c&&(n.has(e)||n.set(e,new Set),n.get(e).add(d));let f=t.get(e);f||(f=new Set,t.set(e,f));let p=f.size===0;f.add(s),clearTimeout(a),a=void 0,r?p&&l({type:`subscribe`,topic:e}):(clearTimeout(i),i=void 0,u());let m=!0;return()=>{m&&(m=!1,n.get(e)?.delete(d),n.get(e)?.size||n.delete(e),f.delete(s),!(f.size>0)&&(t.delete(e),l({type:`unsubscribe`,topic:e}),t.size===0&&a===void 0&&(a=setTimeout(()=>{a=void 0,!(t.size>0)&&(clearTimeout(i),i=void 0,clearTimeout(o),o=void 0,r?.close(),r=null)},us))))}}}}var hs=null;function gs(e,t,n){return hs??=ms(),hs.subscribe(e,t,n)}var q={secrets:{allFor:e=>[`secrets`,e],list:()=>[`secrets`,r()]},e2e:{allFor:e=>[`e2e`,e],status:()=>[`e2e`,r()]},tracker:{allFor:e=>[`tracker`,e],all:()=>[`tracker`,r()],associationFor:e=>[`tracker`,e,`association`],association:()=>[`tracker`,r(),`association`],candidates:(e,t=``)=>[`tracker`,r(),`candidates`,e,t],connection:()=>[`tracker`,r(),`connection`],items:(e,t)=>[`tracker`,r(),`items`,e.kind,e.source.id,e.source.webUrl,e.externalId,e.connectionId??null,t.state,[...t.labels],t.query??``],detail:(e,t)=>[`tracker`,r(),`detail`,e.kind,e.source.id,e.source.webUrl,e.externalId,e.connectionId??null,t]},get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},list:()=>[r(),`runs`,`list`],detail:e=>[r(),`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],gitStatus:e=>[r(),`runs`,`git-status`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],drafts:e=>[r(),`runs`,`drafts`,e],commits:e=>[r(),`runs`,`commits`,e],tree:e=>[r(),`runs`,`tree`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},groups:{detail:e=>[r(),`groups`,e]},get todos(){return[r(),`todos`]},get workflows(){return[r(),`workflows`]},get workflowNodes(){return[r(),`workflow-nodes`]},get skills(){return[r(),`skills`]},get skillsReady(){return[r(),`skills`,`ready`]},get importableSkills(){return[r(),`skills`,`importable`]},get importableSkillsReady(){return[r(),`skills`,`importable`,`ready`]},get launchKey(){return[r(),`launch-key`]},get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoSync(){return[r(),`repo`,`sync`]},get repoTree(){return[r(),`repo`,`tree`]},repoFile:e=>[r(),`repo`,`file`,e],get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:(e=50)=>[r(),`github`,`pages`,e],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},_s=6e4;function vs(){return M({queryKey:q.secrets.list(),queryFn:({signal:e})=>tr({signal:e})})}function ys(){return M({queryKey:J.secrets,queryFn:({signal:e})=>nr({signal:e})})}function bs(){return M({queryKey:q.e2e.status(),queryFn:({signal:e})=>cr({signal:e})})}function xs(){return M({queryKey:q.tracker.connection(),queryFn:({signal:e})=>Qn({signal:e})})}function Ss(){return M({queryKey:q.tracker.association(),queryFn:({signal:e})=>ur({signal:e})})}function Cs(e,t,n){return P({queryKey:q.tracker.candidates(e,t),staleTime:_s,queryFn:({pageParam:n,signal:r})=>dr(e,{q:t.trim()||void 0,cursor:n,limit:50},{signal:r}),initialPageParam:void 0,getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,enabled:n})}var ws=class extends Error{failure;constructor(e){super(e.reason),this.failure=e,this.name=`TrackerRefreshError`}};function Ts(e,t,n=!0){let i=t.query.trim(),a=j(),o=e?q.tracker.items(e,{...t,query:i}):[`tracker`,r(),`items`,`unassociated`];return{...P({queryKey:o,staleTime:1/0,queryFn:({pageParam:n,signal:r})=>i?gr(i,{association:e??void 0,cursor:n,limit:50,state:t.state,labels:t.labels,refresh:!0},{signal:r}):hr({association:e??void 0,cursor:n,limit:50,state:t.state,labels:t.labels,refresh:!1},{signal:r}),initialPageParam:void 0,getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,enabled:e!=null&&n}),queryKey:o,restart:async()=>{await a.cancelQueries({queryKey:o,exact:!0});try{await a.fetchInfiniteQuery({queryKey:o,initialPageParam:void 0,pages:1,getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,staleTime:0,retry:!1,queryFn:async({signal:n})=>{let r={association:e??void 0,limit:50,state:t.state,labels:t.labels,refresh:!0},a=i?await gr(i,r,{signal:n}):await hr(r,{signal:n});if(!a.available)throw new ws(a);return a}})}catch{}}}}function Es(e,t){return M({staleTime:_s,queryKey:e&&t?q.tracker.detail(e,t):[`tracker`,r(),`detail`,`disabled`],queryFn:({signal:n})=>_r(t,{signal:n,association:e??void 0}),enabled:e!=null&&t!=null&&t!==``})}var J={dashboard:[`workspace`,`dashboard`],models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:[`workspace`,`runs-index`],secrets:[`workspace`,`secrets`],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],hostUsage:[`workspace`,`host-usage`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountDetails:e=>[`workspace`,`agent-profiles`,`details`,e],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],skillsUpdate:e=>[`workspace`,`skills-update`,e],selfUpdate:[`workspace`,`self-update`],selfUpdateDevelopment:[`workspace`,`self-update`,`development`],starCount:[`workspace`,`star-count`],telemetryConsent:[`workspace`,`telemetry-consent`],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...J.fsBrowseRoot,e,t]};function Y(e,t=!0){return M({queryKey:J.models(e),queryFn:({signal:t})=>h(e)?_n(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&h(e)})}function Ds(e=!0){let t=Y(`claude`,e),n=Y(`codex`,e),r=Y(`opencode`,e),i=Y(`cursor`,e),a=Y(`pi`,e);return{claude:t,codex:n,junie:Y(`junie`,e),opencode:r,cursor:i,pi:a,copilot:Y(`copilot`,e)}}function Os(){let e=j();return M({queryKey:J.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(J.providerStatus),r=await vn(!1,{signal:t});return Vt(n,e.getQueryData(J.providerStatus),r)},staleTime:5*6e4,refetchInterval:!1,refetchOnWindowFocus:!0})}function ks(){let e=j();return N({mutationFn:()=>vn(!0),onMutate:()=>e.getQueryData(J.providerStatus),onSuccess:(t,n,r)=>e.setQueryData(J.providerStatus,e=>Vt(r,e,t))})}function As(){let e=j();return N({mutationFn:({provider:e,authFailureId:t})=>Pr(e,t),onMutate:()=>e.getQueryData(J.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(J.providerStatus,e=>Vt(r,e,t,n.authFailureId))}})}function js(){return M({queryKey:J.projects,queryFn:({signal:e})=>bn({signal:e})})}function Ms(e,t=!1){return M({queryKey:J.fsBrowse(e,t),queryFn:({signal:n})=>xn(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Ns(){let e=j();return N({mutationFn:e=>Fr(e),onSuccess:()=>e.invalidateQueries({queryKey:J.projects})})}function Ps(){let e=j();return N({mutationFn:e=>zr(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:J.projects})}})}function Fs(){let e=j();return N({mutationFn:e=>{let{id:t,...n}=e;return Br(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:J.projects});let r=e.getQueryData(J.projects);return e.setQueryData(J.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Is(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(J.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(J.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:J.projects})})}function Is(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:ss(s);return c.length>0&&(a.tags=c),a}function X(e){let t=j();return N({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:J.agentProfiles}),t.invalidateQueries({queryKey:J.projects})])}})}function Ls(){return X(e=>ia(e))}function Rs(){return X(e=>{let{id:t,...n}=e;return la(t,n)})}function zs(){return X(e=>ua(e))}function Bs(){return X(e=>ca(e))}function Vs(e,t){return M({queryKey:J.agentAccountDetails(e),queryFn:({signal:t})=>oa(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function Hs(e,t){return M({queryKey:J.agentAccountStatus(e),queryFn:({signal:t})=>aa(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Us(){let e=j();return N({mutationFn:({provider:e,profileId:t})=>jr(e,t),retry:!1,onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:J.agentProfiles}),e.invalidateQueries({queryKey:J.providerStatus})])}})}function Ws(){let e=j();return N({mutationFn:e=>aa(e,{recheck:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(J.agentAccountStatus(n),t),e.invalidateQueries({queryKey:J.agentProfiles})}})}function Gs(){return N({mutationFn:e=>{let{routeId:t,...n}=e;return sa(t,n)},retry:!1})}function Ks(){let e=j();return N({mutationFn:e=>Ir(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:J.projects})})}function qs(){let e=j();return N({mutationFn:e=>Lr(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:J.projects})})}function Js(){return M({queryKey:J.githubOwners,queryFn:({signal:e})=>Rr({signal:e}),staleTime:5*6e4,retry:!1})}function Ys(){let e=j();(0,A.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(q.health)?.capabilities?.localHandoff===!0;n&&t===void 0?t=gs(`health`,t=>{e.setQueryData(q.health,t)}):!n&&t!==void 0&&(t(),t=void 0)};n();let r=e.getQueryCache().subscribe(n);return()=>{r(),t?.()}},[e])}function Xs(){return M({queryKey:q.health,queryFn:({signal:e})=>fn({signal:e})})}function Zs(){let e=Xs().data,t=js().data?.projects,{projectId:n}=Nt(),r=n??e?.bootProject,i=r===void 0?void 0:t?.find(e=>e.id===r);return i?.repoUrl?i.repoUrl:n===null||n===e?.bootProject?Wo(e?.repo?.remote,e?.forge?.kind===`github`):void 0}function Qs(){return M({queryKey:q.openTargets,queryFn:({signal:e})=>di({signal:e}),staleTime:5*6e4})}function $s(e){return M({queryKey:q.runs.list(),queryFn:({signal:e})=>Sn({signal:e}),select:e})}function ec(e=!0,t){return M({queryKey:J.runsIndex,queryFn:({signal:e})=>wn({signal:e}),enabled:e,staleTime:3e4,...t===void 0?{}:{refetchInterval:t}})}function tc(e,t=!0,n=!1,r){return M({queryKey:[n?`default`:e,`runs`,`list`],queryFn:({signal:t})=>Cn(e,{signal:t}),enabled:t,select:r})}function nc(e,t,n){let r=e==="default"?null:e,i=r===null||t!=null&&r===t;return tc(i?`default`:r??`default`,!0,i,n)}function rc(e){return{queryKey:q.runs.detail(e),queryFn:({signal:t})=>Tn(e,{signal:t})}}function ic(e){return M({...rc(e??``),enabled:!!e})}function ac(e,t,n=!0){return M({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>En(e,t,{signal:n}),enabled:n&&!!e&&!!t})}function oc(e){return M({queryKey:q.runs.diff(e??``),queryFn:({signal:t})=>Tr(e,{signal:t}),enabled:!!e})}function sc(e,t=!1){return M({queryKey:q.runs.changes(e??``),queryFn:({signal:t})=>Dr(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:t?4e3:!1,refetchOnWindowFocus:!0,staleTime:0})}function cc(e,t,n=!1){return M({queryKey:q.runs.gitStatus(e),queryFn:({signal:t})=>gi(e,{signal:t}),enabled:t,retry:!1,refetchInterval:n?1e4:!1,refetchOnWindowFocus:!0,staleTime:0})}function lc(e,t=!0){return M({queryKey:q.runs.tree(e??``),queryFn:({signal:t})=>qn(e,{signal:t}),enabled:t&&!!e,retry:!1,staleTime:0})}function uc(e,t){return M({queryKey:q.runs.file(e??``,t??``),queryFn:({signal:n})=>Or(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function dc(e){return M({queryKey:q.groups.detail(e??``),queryFn:({signal:t})=>Ar(e,{signal:t}),enabled:!!e})}function fc(e,t=!1){return M({queryKey:q.runs.commits(e??``),queryFn:({signal:t})=>Jn(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:t?5e3:!1})}function pc(e,t){return M({queryKey:q.runs.commit(e??``,t??``),queryFn:({signal:n})=>Yn(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function mc(e,t=!0){return M({queryKey:q.runs.handoff(e??``),queryFn:({signal:t})=>Er(e,{signal:t}),enabled:!!e&&t})}function hc(e){return M({queryKey:q.runs.drafts(e??``),queryFn:({signal:t})=>Si(e,{signal:t}),enabled:!!e,staleTime:1/0,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1})}function gc(e=!0){return M({queryKey:q.todos,queryFn:({signal:e})=>In({signal:e}),enabled:e})}function _c(){return M({queryKey:q.workflowNodes,queryFn:({signal:e})=>Gi({signal:e}),staleTime:1/0})}function vc(e={}){return M({queryKey:q.workflows,enabled:e.enabled??!0,queryFn:({signal:e})=>An({signal:e})})}function yc(e=!0){let t=j(),n=q.skills,r=n[0],i=M({queryKey:n,queryFn:({signal:e})=>jn({signal:e}),enabled:e}),a=M({queryKey:q.skillsReady,queryFn:({signal:e})=>Mn({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,A.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function bc(e=!0){let t=j(),n=q.importableSkills,r=n[0],i=M({queryKey:n,queryFn:({signal:e})=>Pn({signal:e}),enabled:e}),a=M({queryKey:q.importableSkillsReady,queryFn:({signal:e})=>Fn({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,A.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function xc(){return M({queryKey:q.launchKey,queryFn:({signal:e})=>yn({signal:e}),staleTime:1/0})}function Sc(){return M({queryKey:q.repo,queryFn:({signal:e})=>Ln({signal:e})})}function Cc(){return M({queryKey:q.repoSync,queryFn:({signal:e})=>ji({signal:e}),refetchOnWindowFocus:!0})}function wc(){let e=j();return N({mutationFn:e=>Mi(e),onSuccess:t=>{e.setQueryData(q.repoSync,t.sync),e.invalidateQueries({queryKey:q.repo,predicate:e=>e.queryKey[2]!==`sync`})}})}function Tc(){return M({queryKey:q.repoChanges,queryFn:({signal:e})=>Hn({signal:e}),retry:!1})}function Ec(){return M({queryKey:q.repoTree,queryFn:({signal:e})=>Un({signal:e}),retry:!1,refetchOnWindowFocus:!0,staleTime:0})}function Dc(e){return M({queryKey:q.repoFile(e??``),queryFn:({signal:t})=>Wn(e,{signal:t}),enabled:e!==void 0&&e!==``,retry:!1,refetchOnWindowFocus:!0,staleTime:0})}function Oc(e){return M({queryKey:q.repoCommit(e??``),queryFn:({signal:t})=>Kn(e,{signal:t}),enabled:!!e,retry:!1})}function kc(){return M({queryKey:q.config,queryFn:({signal:e})=>Rn({signal:e})})}function Ac(){return M({queryKey:q.worktrees,queryFn:({signal:e})=>Ca({signal:e})})}function jc(){return M({queryKey:q.uiState,queryFn:({signal:e})=>kn({signal:e})})}function Mc(){return M({queryKey:q.agentConfig,queryFn:({signal:e})=>zn({signal:e})})}function Nc(e){return M({queryKey:q.agentConfigFile(e??``),queryFn:({signal:t})=>Bn(e,{signal:t}),enabled:e!==null})}function Pc(e){let t=j(),n=q.agentConfig,r=q.agentConfigFile(e);return N({mutationFn:t=>Vn(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Fc(){return M({queryKey:J.uiState,queryFn:({signal:e})=>Zi({signal:e})})}function Ic(){return M({queryKey:J.config,queryFn:({signal:e})=>$i({signal:e})})}function Lc(){return M({queryKey:J.agentProfiles,queryFn:({signal:e})=>ra({signal:e})})}var Rc=1e4;function zc(e=!0){return M({queryKey:J.starCount,queryFn:({signal:e})=>pn({signal:e}),enabled:e,staleTime:Rc,refetchInterval:Rc,retry:!1,refetchOnMount:!1})}function Bc(){return M({queryKey:J.telemetryConsent,queryFn:({signal:e})=>hn({signal:e}),staleTime:1/0,retry:!1})}function Vc(e,t=!0){return M({queryKey:J.skillsUpdate(e),queryFn:({signal:t})=>da(e,{signal:t}),enabled:t,refetchInterval:e=>{let t=e.state.data?.status;return t===void 0||t===`idle`||t===`checking`||t===`updating`?6e4:!1}})}function Hc(e=!0){return M({queryKey:J.selfUpdate,queryFn:({signal:e})=>ma({signal:e}),enabled:e,refetchInterval:e=>e.state.data?.job?.status===`running`?1e3:e.state.data?.scheduled?5e3:!1})}function Uc(e=!0){return M({queryKey:J.selfUpdateDevelopment,queryFn:({signal:e})=>ga({signal:e}),enabled:e,staleTime:3e4})}function Wc(){let e=j();return N({mutationFn:()=>ga({refresh:!0}),onSuccess:t=>e.setQueryData(J.selfUpdateDevelopment,t)})}function Gc(){let e=j();return N({mutationFn:()=>ha(),onSuccess:t=>e.setQueryData(J.selfUpdate,t)})}function Kc(){let e=j();return N({mutationFn:e=>_a(e),onSuccess:t=>e.setQueryData(J.selfUpdate,t)})}function qc(){let e=j();return N({mutationFn:e=>va(e),onSuccess:t=>e.setQueryData(J.selfUpdate,t)})}function Jc(){let e=j();return N({mutationFn:e=>ya(e),onSuccess:t=>e.setQueryData(J.selfUpdate,t)})}function Yc(){let e=j();return N({mutationFn:()=>ba(),onSuccess:t=>e.setQueryData(J.selfUpdate,t)})}function Xc(e){let t=j();return N({mutationFn:t=>ai(e,t),onSuccess:e=>{Zc(t,e),t.invalidateQueries({queryKey:q.runs.all})}})}function Zc(e,t){e.setQueryData(q.runs.list(),e=>e?.map(e=>e.id===t.id?$a(e,t):e)),e.setQueryData(q.runs.detail(t.id),e=>e?$a(e,t):t),Qc(e)}function Qc(e){e.invalidateQueries({queryKey:J.runsIndex})}function $c(){let e=j();return N({mutationFn:e=>Xr(e),onMutate:async t=>{await e.cancelQueries({queryKey:q.runs.list()}),await e.cancelQueries({queryKey:q.runs.detail(t)});let n=e.getQueryData(q.runs.list()),r=e.getQueryData(q.runs.detail(t)),i=new Date().toISOString();return e.setQueryData(q.runs.list(),e=>e?.map(e=>e.id===t?{...e,seenAt:i}:e)),e.setQueryData(q.runs.detail(t),e=>e&&{...e,seenAt:i}),{prevList:n,prevDetail:r,id:t}},onError:(t,n,r)=>{r?.prevList&&e.setQueryData(q.runs.list(),r.prevList),r?.prevDetail&&e.setQueryData(q.runs.detail(n),r.prevDetail)},onSuccess:t=>{let n=e=>e.id===t.id?{...e,seenAt:t.seenAt}:e;e.setQueryData(q.runs.list(),e=>e?.map(n)),e.setQueryData(q.runs.detail(t.id),e=>e?n(e):t),Qc(e)}})}function el(){let e=j();return N({mutationFn:e=>Zr(e),onMutate:async t=>{await e.cancelQueries({queryKey:q.runs.list()}),await e.cancelQueries({queryKey:q.runs.detail(t)});let n=e.getQueryData(q.runs.list()),r=e.getQueryData(q.runs.detail(t));return e.setQueryData(q.runs.list(),e=>e?.map(e=>e.id===t?tl(e):e)),e.setQueryData(q.runs.detail(t),e=>e&&tl(e)),{prevList:n,prevDetail:r,id:t}},onError:(t,n,r)=>{r?.prevList&&e.setQueryData(q.runs.list(),r.prevList),r?.prevDetail&&e.setQueryData(q.runs.detail(n),r.prevDetail)},onSuccess:t=>{let n=e=>e.id===t.id?tl(e):e;e.setQueryData(q.runs.list(),e=>e?.map(n)),e.setQueryData(q.runs.detail(t.id),e=>e?n(e):t),Qc(e)}})}function tl(e){let{seenAt:t,...n}=e;return n}function nl(e,t,n){let r=j();return N({mutationFn:({id:n,pinned:r,surface:i})=>t===void 0?Wr(n,r,i??e):Gr(t,n,r,i??e),onSuccess:()=>r.invalidateQueries({queryKey:n===void 0?q.runs.all:[n,`runs`]})})}function rl(e,t,n){let r=j();return N({mutationFn:({id:n,archived:r})=>t===void 0?Ur(n,r,e):Kr(t,n,r,e),onSuccess:()=>r.invalidateQueries({queryKey:n===void 0?q.runs.all:[n,`runs`]})})}function il(e,t){let n=j();return N({mutationFn:n=>t===void 0?vi(e,n):yi(t,e,n),onSuccess:()=>n.invalidateQueries({queryKey:q.runs.all}),onError:e=>{e instanceof R&&e.status===409&&n.invalidateQueries({queryKey:q.runs.all})}})}function al(e,t){let n=j();return N({mutationFn:(n={})=>t===void 0?ei(e,n):ti(t,e,n),onSuccess:()=>n.invalidateQueries({queryKey:q.runs.all})})}function ol(e){let t=j();return N({mutationFn:({msgId:t,message:n})=>bi(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:q.runs.all})})}function sl(e){let t=j();return N({mutationFn:t=>xi(e,t),onSuccess:()=>t.invalidateQueries({queryKey:q.runs.all})})}function cl(e={},t=!0){return M({queryKey:q.github(e),queryFn:({signal:t})=>Xn({limit:e.limit},{signal:t}),enabled:t})}function ll(e=50,t=!0){return P({queryKey:q.githubPages(e),queryFn:({pageParam:t,signal:n})=>Xn({limit:e,issuesCursor:t.issuesCursor,prsCursor:t.prsCursor},{signal:n}),initialPageParam:{issuesCursor:void 0,prsCursor:void 0},getNextPageParam:e=>{let t=e.issuesNextCursor??void 0,n=e.prsNextCursor??void 0;return t||n?{issuesCursor:t,prsCursor:n}:void 0},enabled:t,staleTime:6e4})}function ul(e,t=!0){return M({queryKey:q.githubChecks(e),queryFn:({signal:t})=>vr(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function dl(e,t,n=!0){return M({queryKey:q.githubSearch(e,t),queryFn:({signal:n})=>yr(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var fl=100;function pl(e){return[...e].sort((e,t)=>t-e).slice(0,fl).sort((e,t)=>e-t)}var Z=new Map(yl()),ml=1e3;function hl(e,t){if(Z.get(e)!==t){for(Z.delete(e),Z.set(e,t);Z.size>ml;){let e=Z.keys().next().value;if(e===void 0)break;Z.delete(e)}Sl()}}var Q=new Set(bl());function gl(e,t){if(Q.has(e)!==t){if(t)for(Q.add(e);Q.size>ml;){let e=Q.values().next().value;if(e===void 0)break;Q.delete(e)}else Q.delete(e);Sl()}}var _l=`cez.reference-statuses.v1`,vl=`cez.reference-conflicts.v1`;function yl(){try{let e=globalThis.sessionStorage?.getItem(_l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&io(e[1])):[]}catch{return[]}}function bl(){try{let e=globalThis.sessionStorage?.getItem(vl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var xl;function Sl(){xl===void 0&&(xl=setTimeout(()=>{xl=void 0;try{globalThis.sessionStorage?.setItem(_l,JSON.stringify([...Z])),globalThis.sessionStorage?.setItem(vl,JSON.stringify([...Q]))}catch{}},250))}function Cl(){let e=Nt(),t=Xs();return e.projectId??t.data?.bootProject}function wl(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))hl($({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))hl($({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Tl=5*6e4;function El(e){return e?e.recheckAfterMs:Tl}var $=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Dl(e,t=!0){let n=(0,A.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:pl(t.prs),issues:pl(t.issues)}))},[e.map($).sort().join(`|`)]),r=kt({queries:n.map(e=>({queryKey:q.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>br(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>El(e.state.data)??1/0,refetchInterval:e=>El(e.state.data)??!1,refetchOnWindowFocus:!0}))}),i=(0,A.useMemo)(()=>{let e=new Map;return r.forEach((t,r)=>{let i=n[r];if(!i)return;let a=[...i.prs.map(e=>({projectId:i.projectId,kind:`PR`,number:e})),...i.issues.map(e=>({projectId:i.projectId,kind:`Issue`,number:e}))],o=t.data;for(let n of a){let r=$(n),i=Z.get(r),a=Q.has(r)?!0:void 0;if(o?.available){let t=o.prs[n.number]??o.issues[n.number];if(t){let i=o.conflicts?o.conflicts.includes(n.number):void 0;hl(r,t),i!==void 0&&gl(r,i),e.set(r,{state:`ready`,status:t,...i??a?{conflicting:!0}:{}})}else e.set(r,{state:`unknown`,...i?{status:i}:{}})}else o?e.set(r,{state:`unavailable`,reason:o.reason,...i?{status:i}:{},...a?{conflicting:!0}:{}}):t.isError?e.set(r,{state:`unavailable`,reason:t.error instanceof Error?t.error.message:void 0,...i?{status:i}:{},...a?{conflicting:!0}:{}}):e.set(r,{state:`loading`,...i?{status:i}:{},...a?{conflicting:!0}:{}})}}),e},[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,A.useCallback)(e=>{let t=$(e),n=i.get(t);if(n)return n;let r=Z.get(t);return{state:`idle`,...r?{status:r}:{},...Q.has(t)?{conflicting:!0}:{}}},[i])}function Ol(e,t,n=!0){return M({queryKey:q.githubComments(e,t),queryFn:({signal:n})=>xr(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function kl(e){return M({queryKey:[`github`,`pr-changes`,e??0],queryFn:({signal:t})=>wr(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Wc as $,Va as $i,Yr as $n,Zi as $r,Zc as $t,dc as A,xe as Aa,Ta as Ai,jo as An,xr as Ar,Uc as At,nl as B,fr as Bi,po as Bn,Dn as Br,xs as Bt,cl as C,ct as Ca,Qi as Ci,So as Cn,$r as Cr,Y as Ct,Js as D,_e as Da,Nn as Di,xo as Dn,Pi as Dr,Jc as Dt,ll as E,k as Ea,wa as Ei,Co as En,Ui as Er,ec as Et,$c as F,Me as Fa,Ba as Fi,oo as Fn,ja as Fr,zc as Ft,js as G,Li as Gi,Za as Gn,Ha as Gr,Fs as Gt,ac as H,qi as Hi,ao as Hn,Ka as Hr,Ts as Ht,el as I,pe as Ia,Bi as Ii,lo as In,Ma as Ir,Bc as It,Ws as J,Ga as Ji,Ja as Jn,Wa as Jr,Ic as Jt,Os as K,qr as Ki,to as Kn,ma as Kr,_c as Kt,Gs as L,b as La,Vi as Li,fo as Ln,Oi as Lr,gc as Lt,Ys as M,S as Ma,er as Mi,Do as Mn,Sr as Mr,Kc as Mt,bc as N,E as Na,sr as Ni,bo as Nn,fn as Nr,yc as Nt,kl as O,T as Oa,Oa as Oi,yo as On,Rn as Or,Bs as Ot,xc as P,C as Pa,Gn as Pi,ko as Pn,yn as Pr,Vc as Pt,Gc as Q,ci as Qi,pa as Qn,na as Qr,J as Qt,Qs as R,kr as Ri,G as Rn,Si as Rr,Ss as Rt,Ms as S,j as Sa,xa as Si,Mo as Sn,ta as Sr,Ds as St,Ol as T,ze as Ta,Da as Ti,Po as Tn,zi as Tr,nc as Tt,tc as U,or as Ui,eo as Un,Ia as Ur,jc as Ut,Zs as V,$n as Vi,ro as Vn,On as Vr,Es as Vt,vs as W,vi as Wi,Qa as Wn,Ua as Wr,Rs as Wt,Dl as X,lr as Xi,Pa as Xn,_r as Xr,Fc as Xt,Cl as Y,Ei as Yi,R as Yn,Zn as Yr,ys as Yt,ks as Z,Na as Zi,ii as Zn,hr as Zr,Ac as Zt,al as _,Nt as _a,Sa as _i,rs as _n,Hi as _r,hc as _t,rc as a,za as aa,fi as ai,Ho as an,Ri as ar,Tc as at,bs as b,M as ba,gn as bi,No as bn,Di as br,mc as bt,Mc as c,Xt as ca,ui as ci,Ro as cn,hi as cr,Cc as ct,qc as d,Bt as da,ai as di,Zo as dn,Fi as dr,As as dt,U as ea,ka as ei,gs as en,Kr as er,Ns as et,rl as f,Rt as fa,li as fi,Bo as fn,Ai as fr,ic as ft,Us as g,Pt as ga,_i as gi,Qo as gn,Wi as gr,oc as gt,kc as h,Ut as ha,Fa as hi,ns as hn,La as hr,fc as ht,wl as i,Ki as ia,mn as ii,is as in,V as ir,Sc as it,Xs as j,be as ja,si as ji,Oo as jn,wr as jr,il as jt,dl as k,Se as ka,ar as ki,Ao as kn,Xn as kr,Hc as kt,Nc as l,Jt as la,Ea as li,Go as ln,jr as lr,wc as lt,Ks as m,Wt as ma,Ti as mi,Ko as mn,ri as mr,pc as mt,ws as n,Mr as na,Qr as ni,os as nn,Jr as nr,Ps as nt,Vs as o,nn as oa,mi as oi,Uo as on,fa as or,Oc as ot,Yc as p,L as pa,Ni as pi,Yo as pn,Vr as pr,sc as pt,Pc as q,Nr as qi,$a as qn,da as qr,vc as qt,q as r,ea as ra,Cr as ri,Io as rn,Hr as rr,sl as rt,Hs as s,Yt as sa,pi as si,zo as sn,pr as sr,Dc as st,_s as t,Ii as ta,Aa as ti,as as tn,Ur as tr,zs as tt,Lc as u,F as ua,Ji as ui,K as un,ei as ur,Ec as ut,Ls as v,P as va,wi as vi,Vo as vn,oi as vr,uc as vt,ul as w,Xe as wa,Ra as wi,Eo as wn,aa as wr,$s as wt,ol as x,gt as xa,Xi as xi,To as xn,Yi as xr,lc as xt,qs as y,N as ya,qa as yi,wo as yn,ki as yr,cc as yt,Xc as z,ir as zi,uo as zn,Or as zr,Cs as zt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,Sa as i,Yn as a,_i as o,at as s,ct as c,fr as l,it as u,j as d,lt as f,ot as p,r as m,ut as h,ya as g}from"./queries-CI0EmEcH.js";import{F as _,i as v,r as y,t as b}from"./button-Clwd6u4_.js";import{c as x,f as S,t as C,w}from"./project-router-DZsR9P9C.js";import{t as T}from"./use-desktop-BNN3U2y9.js";import{a as ee,c as te,i as ne,l as E,o as re,r as ie,t as ae,u as oe}from"./file-preview-iucr8WDo.js";import{t as D}from"./arrow-left-BELOeFyX.js";import{n as O,t as k}from"./file-1a6_DhLG.js";import{t as se}from"./check-Dt8U0Zvm.js";import{t as ce}from"./chevron-right-VbYrJ_st.js";import{c as A,d as j,f as le,o as ue,p as M,s as N,t as de,u as P}from"./git-toolbar-DU5Ca6RI.js";import{n as F}from"./upload-J0hBTVF7.js";import{n as fe,t as I}from"./triangle-alert-BqI_9MkV.js";import{t as pe}from"./plus-CBVm02wz.js";import{t as L}from"./search-x-CuinYQnl.js";import{t as R}from"./input-DIWTlsx6.js";import{t as z}from"./diff-stat-CiWUpWY0.js";import{t as B}from"./centered-state-nM7v9xtl.js";import{a as me}from"./index-BBND6Sg3.js";import{t as he}from"./markdown-BzqT8I8y.js";import{t as V}from"./diff-CJKocK17.js";import{t as H}from"./commit-list-xMdmPYbz.js";var ge=_(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),U=e(t(),1),W=n();function _e(){let e=c(),t=f();if(!e.data)return null;let n=e.data,r=e=>t.mutate(e,{onSuccess:e=>S(e.message),onError:e=>S(e.message,{tone:`danger`})}),i=t.isPending,a=t.variables;return(0,W.jsxs)(`div`,{"data-slot":`repo-sync`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[n.upstream?(0,W.jsxs)(`span`,{"data-slot":`repo-upstream`,className:`truncate font-mono text-soft-foreground`,title:`Upstream`,children:[`→ `,n.upstream]}):n.branch?(0,W.jsx)(`span`,{"data-slot":`repo-upstream`,className:`text-soft-foreground`,children:`not published`}):(0,W.jsx)(`span`,{"data-slot":`repo-upstream`,className:`text-soft-foreground`,children:`detached HEAD`}),n.upstream?(0,W.jsx)(K,{ahead:n.ahead,behind:n.behind}):n.outgoing.length>0?(0,W.jsx)(K,{ahead:n.outgoing.length,behind:null}):null,(0,W.jsx)(`span`,{"data-slot":`repo-fetched`,className:`hidden text-soft-foreground sm:inline`,children:n.lastFetchedAt?`fetched ${ye(n.lastFetchedAt)}`:`never fetched`}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,W.jsx)(G,{which:`fetch`,label:`Fetch`,busy:i,pending:a,onClick:r,disabled:!n.pushRemote,children:(0,W.jsx)(P,{"aria-hidden":`true`,className:y(i&&a===`fetch`&&`animate-spin`)})}),n.upstream?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(G,{which:`pull`,label:`Pull`,busy:i,pending:a,onClick:r,disabled:!n.behind,children:(0,W.jsx)(oe,{"aria-hidden":`true`})}),(0,W.jsx)(G,{which:`push`,label:`Push`,busy:i,pending:a,onClick:r,disabled:!n.ahead,children:(0,W.jsx)(O,{"aria-hidden":`true`})}),(0,W.jsx)(G,{which:`sync`,label:`Sync`,busy:i,pending:a,onClick:r,disabled:!n.ahead&&!n.behind,variant:`outline`,children:(0,W.jsx)(P,{"aria-hidden":`true`,className:y(i&&a===`sync`&&`animate-spin`)})})]}):n.branch&&n.pushRemote?(0,W.jsx)(G,{which:`push`,label:`Publish branch`,busy:i,pending:a,onClick:r,variant:`outline`,children:(0,W.jsx)(ge,{"aria-hidden":`true`})}):null]})]})}function G({which:e,label:t,busy:n,pending:r,onClick:i,disabled:a,variant:o=`ghost`,children:s}){return(0,W.jsxs)(b,{variant:o,size:`sm`,"data-action":`repo-${e}`,"aria-busy":n&&r===e,disabled:n||a,onClick:()=>i(e),children:[s,t]})}function K({ahead:e,behind:t}){return e===null&&t===null?null:!e&&!t?(0,W.jsx)(`span`,{"data-slot":`sync-counts`,className:`text-soft-foreground`,children:`in sync`}):(0,W.jsxs)(`span`,{"data-slot":`sync-counts`,className:`flex items-center gap-1 font-mono`,children:[e?(0,W.jsxs)(`span`,{"data-sync":`ahead`,title:`${e} to push`,className:`text-primary`,children:[`↑`,e]}):null,t?(0,W.jsxs)(`span`,{"data-sync":`behind`,title:`${t} to pull`,className:`text-warning`,children:[`↓`,t]}):null]})}function ve({name:e,sync:t}){if(!t)return null;let n=t.branches.find(t=>t.name===e),r=n?n.gone?`upstream gone`:n.upstream?null:`local only`:`remote only`;return(0,W.jsx)(`span`,{"data-slot":`branch-tracking`,className:`flex shrink-0 items-center gap-1 text-[11px]`,children:r?(0,W.jsx)(`span`,{className:`text-soft-foreground`,children:r}):(0,W.jsx)(K,{ahead:n.ahead,behind:n.behind})})}function ye(e){let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/1e3));if(t<60)return`just now`;let n=Math.round(t/60);if(n<60)return`${n} min ago`;let r=Math.round(n/60);return r<24?`${r} h ago`:`${Math.round(r/24)} d ago`}function be({repo:e,info:t}){let n=d(),r=c(),a=i(),s=e=>S(e.message,{tone:`danger`}),u=g({mutationFn:e=>l({name:e}),onSuccess:async e=>{S(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:m.repo}),a.invalidateQueries({queryKey:m.health})]),a.setQueryData(m.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(m.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:s}),f=g({mutationFn:e=>o({baseBranch:e}),onSuccess:e=>{S(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now fork from the checked-out branch`),a.invalidateQueries({queryKey:m.repo})},onError:s}),[p,h]=(0,U.useState)(``),[_,v]=(0,U.useState)(``),x=_.trim().toLowerCase(),C=x?e.branches.filter(e=>e.toLowerCase().includes(x)):e.branches;return(0,W.jsxs)(`section`,{"data-slot":`repo-branches`,className:`flex flex-col gap-6 px-4 py-4 md:px-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Branches`}),(0,W.jsx)(R,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:_,onChange:e=>v(e.target.value),className:`mt-2 max-w-xl`}),(0,W.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-2 flex max-w-xl flex-col divide-y divide-border`,children:[C.map(n=>{let i=n===t.branch,a=e.checkedOutElsewhere?.[n];return(0,W.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":n,className:`flex min-h-9 items-center gap-2 py-1`,children:[(0,W.jsx)(j,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:y(`min-w-0 truncate font-mono text-xs`,i&&`font-semibold`),children:n}),(0,W.jsx)(ve,{name:n,sync:r.data}),i?(0,W.jsxs)(`span`,{"data-slot":`branch-current`,className:`flex shrink-0 items-center gap-1 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:[(0,W.jsx)(se,{"aria-hidden":`true`,className:`size-3`}),`current`]}):a?(0,W.jsx)(`span`,{"data-slot":`branch-elsewhere`,title:`Checked out in ${a}`,className:`ml-auto shrink-0 text-[11px] text-soft-foreground`,children:`in another worktree`}):(0,W.jsx)(b,{variant:`ghost`,size:`sm`,"data-action":`switch-branch`,className:`ml-auto`,disabled:u.isPending,onClick:()=>u.mutate(n),children:`Switch`})]},n)}),C.length===0?(0,W.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,_.trim(),`”.`]}):null]}),(0,W.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-3 flex max-w-md items-center gap-2`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&u.mutate(t,{onSuccess:()=>h(``)})},children:[(0,W.jsx)(R,{"aria-label":`New branch name`,placeholder:`new-branch-name`,value:p,onChange:e=>h(e.target.value)}),(0,W.jsxs)(b,{type:`submit`,variant:`outline`,size:`sm`,"data-action":`create-branch`,disabled:!p.trim()||u.isPending,children:[(0,W.jsx)(pe,{"aria-hidden":`true`}),`Create`]})]})]}),(0,W.jsxs)(`div`,{className:`max-w-md`,children:[(0,W.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Agents’ base branch`}),(0,W.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:f.isPending,onChange:e=>f.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block w-full rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,W.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),e.branches.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] text-soft-foreground`,children:`New task worktrees branch from this.`})]}),n.data?.forge?.available?(0,W.jsx)(xe,{}):null]})}function xe(){let e=r({limit:20});return(0,W.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,W.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,W.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,W.jsx)(Se,{pr:e},e.number))}):(0,W.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function Se({pr:e}){let t=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(fe,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,W.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,W.jsx)(Ce,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,W.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:v(e.url)?(0,W.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:y(n,`hover:bg-muted`),children:t}):(0,W.jsx)(`span`,{className:n,children:t})})}function Ce({checks:e}){return(0,W.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:y(`shrink-0 text-[10px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function we(){let e=s(),t=T(),[n,r]=(0,U.useState)(`unified`),[i,o]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(null),f=(0,U.useRef)(null),p=e.isError&&e.error instanceof a&&e.error.status===409,m=e.data?.files??[],h=(0,U.useMemo)(()=>ne(m),[m]),g=(0,U.useMemo)(()=>m.some(he),[m]),_=t?n:`unified`,v=!t||i;return(0,W.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Uncommitted changes`}),e.data?(0,W.jsx)(de,{stat:e.data.stat}):null,(0,W.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,W.jsx)(N,{mode:n,wrap:i,preview:c,onModeChange:r,onWrapChange:o,onPreviewChange:g?l:void 0})})]}),e.isPending?(0,W.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading changes…`}):e.isError?(0,W.jsx)(B,{icon:p?(0,W.jsx)(M,{}):(0,W.jsx)(I,{}),tone:p?`neutral`:`danger`,heading:`h2`,title:p?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):m.length===0?(0,W.jsx)(B,{icon:(0,W.jsx)(M,{}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 px-4 py-4 max-md:[--diff-sticky-top:7rem] md:px-6 md:py-0`,children:[(0,W.jsx)(`aside`,{"data-slot":`changes-tree-pane`,className:`hidden w-60 shrink-0 overflow-y-auto overscroll-contain py-4 md:block lg:w-72`,children:(0,W.jsx)(re,{root:h,selected:u,onSelect:e=>{d(e),f.current?.scrollToPath(e)}})}),(0,W.jsx)(`div`,{"data-slot":`diff-pane`,"data-diff-scroller":t?``:void 0,className:`min-w-0 flex-1 md:overflow-y-auto md:overscroll-contain`,children:(0,W.jsx)(V,{files:m,viewRef:f,mode:_,wrap:v,preview:t&&g&&c,className:`min-w-0 md:py-4`})})]})]})}function Te({log:e}){let{sha:t}=w(),n=c().data;if(t)return(0,W.jsx)(Ee,{sha:t});let r=new Set(n?.outgoing??[]),i=n?.incoming??[],a=(e,t)=>({sha:e.hash,shaLabel:e.hash,subject:e.subject,author:e.author,when:e.when,href:`/git/commits/${e.hash}`,...t?{sync:t}:{}}),o=i.length>0?(0,W.jsxs)(`section`,{"data-slot":`repo-incoming`,className:`border-b border-border`,children:[(0,W.jsxs)(`h2`,{className:`px-4 pt-3 text-[11px] font-medium text-muted-foreground md:px-6`,children:[`Incoming from `,n?.upstream,` · `,i.length]}),(0,W.jsx)(H,{slot:`repo-incoming-commits`,commits:i.map(e=>a(e,`incoming`))})]}):null;return e.length===0?(0,W.jsx)(B,{icon:(0,W.jsx)(F,{}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,W.jsxs)(W.Fragment,{children:[o,(0,W.jsx)(H,{slot:`repo-commits`,commits:e.map(e=>a(e,r.has(e.hash)?`outgoing`:void 0))})]})}function Ee({sha:e}){let t=p(e),n=T(),[r,i]=(0,U.useState)(`unified`),[o,s]=(0,U.useState)(!1),c=t.isError&&t.error instanceof a&&t.error.status===409,l=n?r:`unified`,u=!n||o;return(0,W.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,W.jsx)(b,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,W.jsxs)(C,{to:`/git/commits`,children:[(0,W.jsx)(D,{"aria-hidden":`true`}),`All commits`]})}),t.data?(0,W.jsx)(z,{stat:t.data.stat}):null,(0,W.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,W.jsx)(N,{mode:r,wrap:o,onModeChange:i,onWrapChange:s})})]}),t.isPending?(0,W.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):t.isError?(0,W.jsx)(B,{icon:c?(0,W.jsx)(L,{}):(0,W.jsx)(I,{}),tone:c?`neutral`:`danger`,heading:`h2`,title:c?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,W.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,W.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,W.jsx)(B,{icon:(0,W.jsx)(F,{}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,W.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:7rem] md:px-6`,children:(0,W.jsx)(V,{files:t.data.files,mode:l,wrap:u,className:`min-w-0`})})]})]})}function q(e,t){let n=0;for(let r of t){if(n=e.indexOf(r,n),n===-1)return!1;n+=r.length}return!0}function De(e,t,n){let r=t.trim().toLowerCase();if(r===``)return{results:[...e],total:e.length};let i=[];for(let t of e){let e=t.toLowerCase();if(!q(e,r))continue;let n=e.slice(e.lastIndexOf(`/`)+1);i.push({path:t,basenameMatch:q(n,r)})}return i.sort((e,t)=>e.basenameMatch===t.basenameMatch?e.path.length===t.path.length?e.path.localeCompare(t.path):e.path.length-t.path.length:e.basenameMatch?-1:1),{results:i.slice(0,n).map(e=>e.path),total:i.length}}var Oe=200;function ke({selected:e,onSelect:t}){let n=h(),r=n.isError&&n.error instanceof a&&n.error.status===409,i=n.data?.paths??[];return n.isPending?(0,W.jsx)(J,{children:(0,W.jsx)(`p`,{"data-slot":`repo-files-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading files…`})}):n.isError?(0,W.jsx)(J,{children:(0,W.jsx)(B,{icon:r?(0,W.jsx)(E,{}):(0,W.jsx)(I,{}),tone:r?`neutral`:`danger`,heading:`h2`,title:r?`No files to browse`:`Could not load the files`,subtitle:n.error.message})}):i.length===0?(0,W.jsx)(J,{children:(0,W.jsx)(B,{icon:(0,W.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`No files yet`,subtitle:`Nothing is tracked in this repository. Files show up here once git knows about them.`})}):(0,W.jsxs)(J,{children:[n.data.truncated?(0,W.jsxs)(`p`,{"data-slot":`repo-files-truncated`,role:`status`,className:`border-b border-border bg-muted/40 px-4 py-2 text-xs text-muted-foreground md:px-6`,children:[`Showing the first `,i.length.toLocaleString(),` files; this repository has more. The tree and the filter cover only what is loaded.`]}):null,(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 px-4 py-4 [--diff-sticky-top:7rem] md:flex-row md:items-start md:px-6`,children:[(0,W.jsx)(`aside`,{"data-slot":`repo-files-tree-pane`,className:y(`w-full shrink-0 md:sticky md:top-[var(--diff-sticky-top)] md:block md:max-h-[calc(100dvh_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,e!==null&&`hidden`),children:(0,W.jsx)(Z,{paths:i,selected:e,onSelect:t})}),(0,W.jsxs)(`div`,{className:y(`min-w-0 flex-1`,e===null&&`hidden md:block`),children:[e===null?null:(0,W.jsxs)(`button`,{type:`button`,"data-slot":`repo-files-back`,onClick:()=>t(null),className:`mb-2 flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground md:hidden`,children:[(0,W.jsx)(D,{"aria-hidden":`true`,className:`size-3.5`}),`Back to the file tree`]}),(0,W.jsx)(ae,{source:{kind:`repo`},path:e})]})]})]})}function J({children:e}){return(0,W.jsx)(`section`,{"data-slot":`repo-files`,className:`flex min-h-0 flex-1 flex-col`,children:e})}function Y(e){if(e===null)return[];let t=e.split(`/`);return t.slice(0,-1).map((e,n)=>t.slice(0,n+1).join(`/`))}function X(e,t,n){let r=[];for(let i of e.dirs){let e=t.has(i.path);r.push({kind:`dir`,path:i.path,name:i.name,level:n,open:e}),e&&r.push(...X(i,t,n+1))}for(let t of e.files)r.push({kind:`file`,path:t.path,name:t.name,level:n,label:t.name});return r}function Z({paths:e,selected:t,onSelect:n}){let[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(()=>new Set(Y(t))),[s,c]=(0,U.useState)(t),l=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=Y(t);e.length!==0&&o(t=>{if(e.every(e=>t.has(e)))return t;let n=new Set(t);for(let t of e)n.add(t);return n})},[t]);let u=r.trim()!==``,d=(0,U.useMemo)(()=>De(e,r,Oe),[e,r]),f=(0,U.useMemo)(()=>ee(e,(e,t)=>({kind:`file`,name:t,path:e})),[e]),p=(0,U.useMemo)(()=>u?d.results.map(e=>({kind:`file`,path:e,name:e.slice(e.lastIndexOf(`/`)+1),level:0,label:e})):X(f,a,0),[u,d.results,f,a]),m=p.find(e=>e.path===s)??p[0],h=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,W.jsxs)(`div`,{"data-slot":`repo-files-browser`,className:`flex min-w-0 flex-col gap-2`,onKeyDown:e=>{e.key!==`/`||e.target===l.current||(e.preventDefault(),l.current?.focus())},children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`label`,{htmlFor:`repo-files-filter`,className:`sr-only`,children:`Filter repository files`}),(0,W.jsx)(`input`,{id:`repo-files-filter`,ref:l,"data-slot":`repo-files-filter`,type:`search`,value:r,placeholder:`Filter files… (/)`,"aria-controls":`repo-files-tree`,autoComplete:`off`,spellCheck:!1,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i(``))},className:`w-full rounded-sm border border-border bg-background px-2 py-1 text-xs placeholder:text-soft-foreground focus:border-foreground focus:outline-none`}),(0,W.jsx)(`p`,{"data-slot":`repo-files-count`,role:`status`,"aria-live":`polite`,className:`sr-only`,children:u?`${d.total} files match ${r.trim()}`:`${e.length} files`})]}),u&&d.total===0?(0,W.jsxs)(`p`,{"data-slot":`repo-files-no-match`,className:`px-1.5 py-1 text-xs text-soft-foreground`,children:[`No file matches `,(0,W.jsx)(`span`,{className:`font-mono`,children:r.trim()}),`.`]}):(0,W.jsx)(`div`,{id:`repo-files-tree`,"data-slot":`repo-files-tree`,"data-filtering":u?`true`:void 0,role:`tree`,"aria-label":`Repository files`,"aria-activedescendant":m?Q(m.path):void 0,onKeyDown:e=>{let t=p.findIndex(e=>e.path===m?.path),r=e=>{let t=p[Math.max(0,Math.min(p.length-1,e))];t&&c(t.path)},i=p[t];if(e.key===`ArrowDown`)e.preventDefault(),r(t+1);else if(e.key===`ArrowUp`)e.preventDefault(),r(t-1);else if(e.key===`ArrowRight`&&i?.kind===`dir`)e.preventDefault(),i.open?r(t+1):h(i.path);else if(e.key===`ArrowLeft`&&i!==void 0)if(e.preventDefault(),i.kind===`dir`&&i.open)h(i.path);else for(let e=t-1;e>=0;--e){let t=p[e];if(t.level<i.level){c(t.path);break}}else(e.key===`Enter`||e.key===` `)&&i!==void 0&&(e.preventDefault(),i.kind===`file`?n(i.path):h(i.path))},className:`min-w-0 text-[13px]`,children:p.map(e=>e.kind===`dir`?(0,W.jsx)(Ae,{row:e,focused:e.path===m?.path,onToggle:()=>{c(e.path),h(e.path)}},e.path):(0,W.jsx)(je,{row:e,active:e.path===t,focused:e.path===m?.path,onSelect:()=>{c(e.path),n(e.path)}},e.path))}),u&&d.total>d.results.length?(0,W.jsxs)(`p`,{"data-slot":`repo-files-more`,className:`px-1.5 py-1 text-xs text-soft-foreground`,children:[(d.total-d.results.length).toLocaleString(),` more — refine the filter.`]}):null]})}var Q=e=>`repo-file-row-${e}`,$=(e,t)=>({paddingLeft:`${t+e*14}px`});function Ae({row:e,focused:t,onToggle:n}){return(0,W.jsxs)(`div`,{id:Q(e.path),role:`treeitem`,"aria-expanded":e.open,"aria-level":e.level+1,"data-slot":`repo-files-dir`,"data-path":e.path,"data-state":e.open?`open`:`closed`,tabIndex:t?0:-1,onClick:n,className:`flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground focus:bg-muted focus:outline-none`,style:$(e.level,6),children:[(0,W.jsx)(ce,{"aria-hidden":`true`,className:y(`size-3.5 shrink-0 transition-transform`,e.open&&`rotate-90`)}),(0,W.jsx)(le,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name})]})}function je({row:e,active:t,focused:n,onSelect:r}){let i=ie(e.path)?te:k;return(0,W.jsxs)(`div`,{id:Q(e.path),role:`treeitem`,"aria-level":e.level+1,"aria-selected":t,"aria-current":t?`true`:void 0,"data-slot":`repo-files-file`,"data-path":e.path,tabIndex:n?0:-1,onClick:r,className:y(`flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted focus:outline-none`,t?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:$(e.level,24),children:[(0,W.jsx)(i,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.label,children:e.label})]})}function Me({tab:e}){let t=u();if(t.isPending)return(0,W.jsx)(me,{});if(t.isError)return(0,W.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(B,{icon:(0,W.jsx)(I,{}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,W.jsx)(Ne,{repo:t.data,info:n,tab:e}):(0,W.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(B,{icon:(0,W.jsx)(j,{}),tone:`neutral`,title:`Not a git repository`,subtitle:`The cockpit is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function Ne({repo:e,info:t,tab:n}){return(0,W.jsxs)(`div`,{"data-route":`repo-git`,className:y(`flex min-h-full flex-col`,n===`changes`&&`md:h-full`),children:[(0,W.jsxs)(`header`,{"data-slot":`repo-header`,className:`sticky top-0 z-20 border-b border-border bg-background/95 px-4 pt-3 backdrop-blur md:px-6`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,W.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Git`}),(0,W.jsx)(ue,{branch:t.branch}),t.remote?(0,W.jsx)(`span`,{"data-slot":`repo-remote`,className:`hidden min-w-0 truncate text-[11px] text-soft-foreground md:inline`,children:t.remote}):null]}),(0,W.jsx)(`div`,{className:`mt-1.5`,children:(0,W.jsx)(_e,{})}),(0,W.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,W.jsx)(A,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,W.jsx)(A,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,W.jsx)(A,{to:`/git/branches`,active:n===`branches`,children:`Branches`}),(0,W.jsx)(A,{to:`/git/files`,active:n===`files`,children:`Files`})]})]}),n===`changes`?(0,W.jsx)(we,{}):n===`commits`?(0,W.jsx)(Te,{log:e.log}):n===`files`?(0,W.jsx)(Pe,{}):(0,W.jsx)(be,{repo:e,info:t})]})}function Pe(){let e=w(),t=x();return(0,W.jsx)(ke,{selected:e[`*`]!==void 0&&e[`*`]!==``?e[`*`]:null,onSelect:e=>t(e===null?`/git/files`:`/git/files/${Fe(e)}`,{replace:!0})})}function Fe(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}export{Me as RepoGitRoute};
|