@wjarka/cezarion 0.18.0-dev.7685 → 0.18.0-dev.7694
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/package.json +2 -2
- package/web/dist/assets/{activity-motion-DjV4Xoms.js → activity-motion-4jefGnf3.js} +1 -1
- package/web/dist/assets/{activity-route-CeDmVBg_.js → activity-route-CrgEEOkP.js} +1 -1
- package/web/dist/assets/attention-CfWn6Sw7.js +1 -0
- package/web/dist/assets/{cez-idle-D1rXzVuh.js → cez-idle-BZ4uUtP5.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-BkPuLrzW.js → commit-diff-panel-BhqIhVpi.js} +1 -1
- package/web/dist/assets/{diff-BBZcIIOt.js → diff-Dtz4yPu-.js} +2 -2
- package/web/dist/assets/{diff-view-DUNXpfvw.js → diff-view-01iQrxA3.js} +1 -1
- package/web/dist/assets/{file-preview-QFfT9j-q.js → file-preview-Bqu0JXBY.js} +1 -1
- package/web/dist/assets/{git-toolbar-Bd54EFZj.js → git-toolbar-zEjeF-_V.js} +1 -1
- package/web/dist/assets/{github-D1ZGYZ6k.js → github-D3a22EyV.js} +1 -1
- package/web/dist/assets/{global-activity-route-BVmBGVep.js → global-activity-route-DXD818_k.js} +1 -1
- package/web/dist/assets/index-DPA7Ibhf.js +14 -0
- package/web/dist/assets/{live-protocol-DKHlCFyG.js → live-protocol-60uiPDg6.js} +1 -1
- package/web/dist/assets/{live-worker-BWdeGzQX.ts → live-worker-DBw-5jVE.ts} +3 -1
- package/web/dist/assets/{markdown-B6DqG9Ie.js → markdown-Dzq31k8-.js} +1 -1
- package/web/dist/assets/{picker-pill-Dbb3GY1a.js → picker-pill-Bmxuo6r5.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-DHH1E04c.js → preview-pane-connected-TaIGMKvt.js} +1 -1
- package/web/dist/assets/{project-router-LT30LjzY.js → project-router-BLLH9tz9.js} +1 -1
- package/web/dist/assets/project-scope-context-CR3cozni.js +4 -0
- package/web/dist/assets/{prompt-template-menu-Dc2ufWt7.js → prompt-template-menu-Fb8KyZ2w.js} +1 -1
- package/web/dist/assets/{queries-DHY6U3e_.js → queries-BCXjp1_j.js} +1 -1
- package/web/dist/assets/{reference-chip-BKeVxG_E.js → reference-chip-1O0efJ0d.js} +1 -1
- package/web/dist/assets/{repo-git-DyuGJJ8w.js → repo-git-BvN7c_-7.js} +1 -1
- package/web/dist/assets/{report-reader-TX7SV7cO.js → report-reader-BEGToSIA.js} +1 -1
- package/web/dist/assets/{reports-DC4T6nCI.js → reports-D61rDO35.js} +1 -1
- package/web/dist/assets/{run-header-CZANvy6Z.js → run-header-gwQQqs03.js} +1 -1
- package/web/dist/assets/runners-D8udSrRd.js +1 -0
- package/web/dist/assets/{skills-DAe4cSA-.js → skills-DB3DAhWt.js} +1 -1
- package/web/dist/assets/{tab-link-C_0J92TF.js → tab-link-DkArCoa9.js} +1 -1
- package/web/dist/assets/{task-changes-Fj_aEo7v.js → task-changes-C4Hp9Bog.js} +1 -1
- package/web/dist/assets/{task-commits-B0Ezfa9a.js → task-commits-IGZ1CJcy.js} +1 -1
- package/web/dist/assets/{task-files-HfwuKxjl.js → task-files-CBrQO4v2.js} +1 -1
- package/web/dist/assets/{task-github-item-B8bv9VSp.js → task-github-item-BJwFCJMl.js} +1 -1
- package/web/dist/assets/{task-thread-Bm755mTM.js → task-thread-Dkn8HN1R.js} +1 -1
- package/web/dist/assets/{thread-state-CJEzn845.js → thread-state-DVfKElYJ.js} +1 -1
- package/web/dist/assets/{use-desktop-EnHXg46f.js → use-desktop-CEB_iBfH.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-CUbaxdrd.js → use-hand-to-agent-state-ChF_oDo3.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-CvdGA_PU.js → useInfiniteQuery-Bh_R8jAH.js} +1 -1
- package/web/dist/assets/useQuery-Ct6O0RmO.js +1 -0
- package/web/dist/assets/{workflows-DMaQulmN.js → workflows-BTzKBfs-.js} +1 -1
- package/web/dist/assets/ws-DCvFYEh3.js +1 -0
- package/web/dist/index.html +15 -15
- package/web/dist/live-worker.js +2 -2
- package/web/dist/assets/attention-zJ-ho5os.js +0 -1
- package/web/dist/assets/index-Eo2qZksq.js +0 -14
- package/web/dist/assets/project-scope-context-DMCS5p-N.js +0 -4
- package/web/dist/assets/runners-C-sPUQye.js +0 -1
- package/web/dist/assets/useQuery-BJFZunTR.js +0 -1
- package/web/dist/assets/ws-BxsIvFCG.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,F as i,M as a,O as o,d as s,j as c,k as l}from"./button-C1fD-ZFr.js";import{A as u,B as d,C as f,D as p,E as m,F as h,G as g,H as _,I as v,J as y,K as b,L as x,M as S,N as C,O as ee,P as w,R as T,S as E,T as D,U as O,V as te,W as k,Y as A,b as ne,c as re,i as ie,j,k as M,m as ae,o as oe,q as N,r as se,u as ce,w as le,x as ue,y as de,z as fe}from"./live-protocol-60uiPDg6.js";var pe=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(){}},me=new class extends pe{#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`}},he=typeof window>`u`||`Deno`in globalThis;function ge(){}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 P(e,t){return typeof e==`function`?e(t):e}function F(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(!we(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(Ce(t.options.mutationKey)!==Ce(a))return!1}else if(!we(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Se(e,t){return(t?.queryKeyHashFn||Ce)(e)}function Ce(e){return JSON.stringify(e,(e,t)=>ke(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function we(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>we(e[n],t[n])):!1}var Te=Object.prototype.hasOwnProperty;function Ee(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Oe(e)&&Oe(t);if(!r&&!(ke(e)&&ke(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:Te.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ee(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function De(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 Oe(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ke(e){if(!Ae(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ae(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ae(e){return Object.prototype.toString.call(e)===`[object Object]`}function je(e){return new Promise(t=>{A.setTimeout(t,e)})}function Me(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ee(e,t)}function Ne(e){return e}function Pe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Fe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ie=Symbol();function Le(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ie?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Re(e,t){return typeof e==`function`?e(...t):!!e}function ze(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 Be=(()=>{let e=()=>he;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ve(){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 He=new class extends pe{#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 Ue(e){return Math.min(1e3*2**e,3e4)}function We(e){return(e??`online`)!==`online`||He.isOnline()}var Ge=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ke(e){let t=!1,n=0,r,i=Ve(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Ge(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>me.isFocused()&&(e.networkMode===`always`||He.isOnline())&&e.canRun(),u=()=>We(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??(Be.isServer()?0:3),o=e.retryDelay??Ue,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),je(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 qe=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ve(this.gcTime)&&(this.#e=A.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Be.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(A.clearTimeout(this.#e),this.#e=void 0)}};function Je(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=>{ze(e,()=>t.signal,()=>n=!0)},u=Le(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?Fe:Pe;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Xe:Ye,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:Ye(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 Ye(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 Xe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ze(e,t){return t?Ye(e,t)!=null:!1}function Qe(e,t){return!t||!e.getPreviousPageParam?!1:Xe(e,t)!=null}var $e=class extends qe{#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=nt(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=nt(this.options);e.data!==void 0&&(this.setState(tt(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Me(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(ge).catch(ge):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=>F(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ie||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>P(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=Le(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`?Je(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=Ke({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ge&&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 Ge){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,...et(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...tt(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),y.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function et(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:We(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function tt(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function nt(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 rt=class extends pe{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Ve(),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),at(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ot(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ot(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 F(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&&!De(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&st(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||F(this.options.enabled,this.#t)!==F(t.enabled,this.#t)||P(this.options.staleTime,this.#t)!==P(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||F(this.options.enabled,this.#t)!==F(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 lt(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(ge)),t}#g(){this.#b();let e=P(this.options.staleTime,this.#t);if(Be.isServer()||this.#r.isStale||!ve(e))return;let t=ye(this.#r.dataUpdatedAt,e)+1;this.#d=A.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,!(Be.isServer()||F(this.options.enabled,this.#t)===!1||!ve(this.#p)||this.#p===0)&&(this.#f=A.setInterval(()=>{(this.options.refetchIntervalInBackground||me.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(A.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(A.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&&at(e,t),o=i&&st(e,n,t,r);(a||o)&&(l={...l,...et(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=Me(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=Me(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`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,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&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:ct(e,t),refetch:this.refetch,promise:this.#o,isEnabled:F(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=Ve();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}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),!De(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){y.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function it(e,t){return F(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&F(t.retryOnMount,e)===!1)}function at(e,t){return it(e,t)||e.state.data!==void 0&&ot(e,t,t.refetchOnMount)}function ot(e,t,n){if(F(t.enabled,e)!==!1&&P(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&ct(e,t)}return!1}function st(e,t,n,r){return(e!==t||F(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&ct(e,n)}function ct(e,t){return F(t.enabled,e)!==!1&&e.isStaleByTime(P(t.staleTime,e))}function lt(e,t){return!De(e.getCurrentResult(),t)}var I=e(t(),1),ut=n(),dt=I.createContext(void 0),ft=e=>{let t=I.useContext(dt);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pt=({client:e,children:t})=>(I.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,ut.jsx)(dt.Provider,{value:e,children:t})),mt=I.createContext(!1),ht=()=>I.useContext(mt);mt.Provider;function gt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var _t=I.createContext(gt()),vt=()=>I.useContext(_t),yt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Re(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},bt=e=>{I.useEffect(()=>{e.clearReset()},[e])},xt=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Re(n,[e.error,r])),St=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))}},Ct=(e,t)=>e.isLoading&&e.isFetching&&!t,wt=(e,t)=>e?.suspense&&t.isPending,Tt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Et(e,t,n){let r=ht(),i=vt(),a=ft(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,St(o),yt(o,i,s),bt(i);let l=!a.getQueryCache().get(o.queryHash),[u]=I.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(I.useSyncExternalStore(I.useCallback(e=>{let t=f?u.subscribe(y.batchCalls(e)):ge;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),I.useEffect(()=>{u.setOptions(o)},[o,u]),wt(o,d))throw Tt(o,u,i);if(xt({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&&!Be.isServer()&&Ct(d,r)&&(l?Tt(o,u,i):s?.promise)?.catch(ge).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}var Dt={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},Ot;Ot||={};var kt=T({root:_(),branch:_(),remote:_().optional()}),L=_().min(1);function At(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)} (removed)`}function jt(e){return`The ${e.charAt(0).toUpperCase()+e.slice(1)} runner is no longer supported. Pick another runner to continue this task in a new session.`}var Mt=T({name:_().min(1),available:S(),version:_().optional(),hint:_().optional()}),Nt=T({kind:w(`github`),available:S().optional(),reason:_().optional()}),Pt=T({localHandoff:S(),settingsAdmin:S(),remoteSettingsAdmin:S(),automations:S(),preview:S(),tokenMetrics:S(),tokenUsageMetrics:S(),costMetrics:S()}),Ft=T({version:_(),latestVersion:_().optional(),repoRoot:_(),repo:kt.nullable(),checks:j(Mt),defaultRunner:L,forge:Nt.nullable(),capabilities:Pt,projects:j(T({id:_(),name:_()})),bootProject:_()}).extend({capabilities:Pt.partial()}),It=Error(`finite cycle deadline`);async function Lt(e,t,n,r){let i=(e,t)=>{for(let r of n)r.value(e,t)},a=()=>r.aborted&&r.reason!==It,o=await e(t,{credentials:`include`,signal:r}).catch(e=>{throw a()||i(void 0,`HTTP 0`),e});if(!o.ok){let e=await o.json().catch(()=>void 0);throw a()&&r.throwIfAborted(),i(e,`HTTP ${o.status}`),Error(`read HTTP ${o.status}`)}let s=await o.json();r.throwIfAborted();for(let e of n)e.value(s)}function Rt(e,t,n=(...e)=>fetch(...e)){let r,i,a,o=!0,s=0,c=-1/0,l=-1/0,u=new Map,d,f=e=>{let t=new Map;for(let n of e){let{kind:e,...r}=n.demand,i=`${r.projectId}/${r.runId}`;(!t.has(i)||t.get(i).afterSeq>r.afterSeq)&&t.set(i,r)}return[...t.values()]},p=async(e,t,r)=>{l=Date.now();for(let i=0;i<e.length;i+=32){let a=e.slice(i,i+32),o=await n(`/api/v1/workspace/run-event-batches`,{method:`POST`,credentials:`include`,signal:t,headers:{"content-type":`application/json`},body:JSON.stringify({runs:f(a)})});if(!o.ok)throw Error(`task batch HTTP ${o.status}`);let s=ce.parse(await o.json());t.throwIfAborted();let c=d!==void 0&&d!==s.generation;if(d=s.generation,c){await Promise.all(a.map(e=>e.reset(`server restarted`,t)));continue}for(let e of s.results)for(let n of a){let i=n.demand;if(!(e.runId!==i.runId||e.projectId!==i.projectId)){if(e.type!==`batch`){await n.reset(e.error,t),t.throwIfAborted();continue}for(let t of e.events)t.seq>i.afterSeq&&(n.frame({type:`event`,projectId:i.projectId,runId:i.runId,name:t.type.includes(`.`)?`ui-event`:`run-event`,event:t}),i.afterSeq=t.seq);i.cursor=e.cursor,i.afterSeq=Math.max(i.afterSeq,e.afterSeq),r.drain||=e.hasMore}}}},m=t=>{t&&(l=-1/0);let n=e().flatMap(e=>e.demand.kind===`run`?[l+2e3]:e.demand.kind===`workspace`?[c+5e3]:e.demand.kind===`read`?[(u.get(e.demand.path)??Date.now())+e.demand.intervalMs]:[]);n.length&&(i=setTimeout(()=>{i=void 0,h()},s?Math.min(3e4,1e3*2**s):t?50:Math.max(50,Math.min(...n)-Date.now())+(e().some(e=>e.demand.kind===`run`)?Math.random()*100:0)))},h=async()=>{if(o||r)return;r=new AbortController;let i=r;a=setTimeout(()=>i.abort(It),1e4);let d={drain:!1};try{let r=e(),a=new Set(r.flatMap(e=>e.demand.kind===`read`?[e.demand.path]:[]));for(let e of u.keys())a.has(e)||u.delete(e);let o=r.filter(e=>e.demand.kind===`run`);o.length&&Date.now()-l>=2e3&&await p(o,i.signal,d),r.some(e=>e.demand.kind===`workspace`)&&Date.now()-c>=5e3&&(c=Date.now(),await t(i.signal));for(let e of r){if(e.demand.kind!==`read`)continue;let{path:t,intervalMs:a}=e.demand;if(!u.has(t)){u.set(t,Date.now());continue}Date.now()-u.get(t)<a||(u.set(t,Date.now()),await Lt(n,t,r.filter(e=>e.demand.kind===`read`&&e.demand.path===t),i.signal))}s=0}catch{o||(s=Math.min(s+1,5))}finally{clearTimeout(a),a=void 0,r===i&&(r=void 0),!o&&e().length&&m(d.drain)}};return{start(e=!1){if(!o){r||(clearTimeout(i),i=void 0,h());return}o=!1,c=e?Date.now():-1/0,l=-1/0,h()},refresh(){c=l=-1/0;for(let e of u.keys())u.set(e,-1/0);!r&&!o&&(clearTimeout(i),i=void 0,h())},stop(){o=!0,u.clear(),clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,r?.abort()}}}var zt=!1,Bt=new Set,Vt=()=>typeof document<`u`&&document.visibilityState===`visible`&&!zt,Ht=()=>{let e=Vt();for(let t of[...Bt])t(e)},Ut=()=>{zt=!0,Ht()},Wt=()=>{zt=!1,Ht()};function Gt(e){return Bt.size===0&&typeof window<`u`&&(zt=!1,document.addEventListener(`visibilitychange`,Ht),document.addEventListener(`freeze`,Ut),document.addEventListener(`resume`,Wt),window.addEventListener(`pagehide`,Ut),window.addEventListener(`pageshow`,Wt)),Bt.add(e),()=>{Bt.delete(e),!Bt.size&&typeof window<`u`&&(document.removeEventListener(`visibilitychange`,Ht),document.removeEventListener(`freeze`,Ut),document.removeEventListener(`resume`,Wt),window.removeEventListener(`pagehide`,Ut),window.removeEventListener(`pageshow`,Wt))}}function Kt(){return(0,I.useSyncExternalStore)(Gt,Vt,()=>!1)}var qt=new Set;function Jt(e){return qt.add(e),()=>{qt.delete(e)}}async function Yt(e,t=!1){e.throwIfAborted(),await Xt(Promise.all([...qt].map(async n=>n(e,t))),e)}function Xt(e,t){return new Promise((n,r)=>{let i=()=>r(t.reason);t.addEventListener(`abort`,i,{once:!0}),t.aborted&&i(),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function Zt(e,t){let n=new URL(e.apiBase||`/`,location.href);return n.origin!==location.origin||n.pathname!==`/`||t||typeof SharedWorker!=`function`}function Qt(){return new URL(`/live-worker.js`,location.href)}function $t(e){for(let t of e)t.handlers.ready?.()}function en(){let e=new Map,t=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,n,r,i,a,o=0,s=0,c=0,l=!1,u=!1,d=!1,f=!1,p,m,h=0,g,_=new Set,v=e=>{g!==e&&(g=e,queueMicrotask(()=>{for(let e of[..._])e()}))},y=()=>[...e.values()].filter(e=>!e.recovering&&!e.released),b,x=()=>{b?.abort();let e=b=new AbortController,t=setTimeout(()=>e.abort(),1e4);Yt(e.signal).catch(()=>{}).finally(()=>clearTimeout(t))},S=Rt(y,e=>Yt(e,!0),(e,t)=>fetch(`${n?.apiBase??``}${String(e)}`,t)),C=e=>e.kind===`run`&&e.projectId==="default"&&n?{...e,projectId:n.bootProject}:e,ee=e=>{if(r)try{r.port.postMessage({version:3,documentId:t,epoch:o,...e})}catch{D()}},w=!1,T=()=>{if(!l||p)return;let e=y().map(e=>({id:e.id,demand:e.demand}));if(!e.length){E();return}ee({type:`sync`,entries:e,...w?{workspaceReady:!0}:{}})},E=()=>{if(clearInterval(i),i=void 0,r){let e=r;r=void 0;try{e.port.postMessage({type:`sync`,version:3,documentId:t,epoch:++o,entries:[]})}catch{}e.port.onmessage=null,e.port.onmessageerror=null,e.port.close()}};function D(){if(!(!l||d)){u=!0,E(),v(`finite`);for(let e of y())e.handlers.ready?.();S.start(),x()}}let O=async(e,t,n)=>{if(e.recovering||e.released)return;let r=new AbortController,i=()=>r.abort(n?.reason);n?.addEventListener(`abort`,i,{once:!0}),n?.aborted&&i();let a=setTimeout(()=>r.abort(),1e4);e.recovery=r,e.recovering=!0,++o,T();try{let n=await Xt(Promise.resolve(e.handlers.reset?.(t,r.signal)),r.signal);if(r.signal.throwIfAborted(),e.released||!l)return;n&&e.demand.kind===`run`&&Object.assign(e.demand,n)}catch(e){if(n)throw e;l&&!p&&D()}finally{clearTimeout(a),n?.removeEventListener(`abort`,i),e.recovery=void 0,e.recovering=!1,!e.released&&l&&!n&&(++o,te())}},te=(t=!1)=>{if(!(d||p||!n||!e.size||!Vt())){if(l=!0,Zt(n,u||f)){v(`finite`),$t(y()),S.start(t);return}if(r){v(`topics`),$t(y()),T();return}try{let t=new SharedWorker(Qt(),{type:`module`,name:se});r=t,c=Date.now(),v(`topics`),t.addEventListener(`error`,()=>{r===t&&D()}),t.port.onmessageerror=()=>{r===t&&D()},t.port.onmessage=({data:n})=>{if(r!==t||!l)return;let i=re.safeParse(n);if(!i.success){D();return}let a=i.data;if(a.type===`hello`){c=Date.now(),T();return}if(a.type===`unavailable`){f=!0,D();return}if(a.epoch!==o||(c=Date.now(),a.type===`alive`))return;let s=e.get(a.id);if(!(!s||s.recovering)){if(a.type===`reset`){if(a.reason===`shared task capacity reached`)D();else if(a.reason===`server restarted`)for(let e of y())O(e,a.reason);else O(s,a.reason);return}if(a.type===`value`){s.handlers.value?.(a.value,a.error);return}s.frame(a.frame)}},t.port.start(),$t(y()),T(),i=setInterval(()=>{if(Date.now()-c>=15e3){D();return}T()},ie)}catch{D()}}},k=()=>{l=!1,E(),S.stop(),b?.abort(),p?.abort(),p=void 0,clearTimeout(m),m=void 0;for(let t of e.values())t.recovery?.abort()},A=t=>{if(!t){k();return}if(l||d||!n||!e.size)return;u=!1,l=!0;let r=p=new AbortController,i=setTimeout(()=>r.abort(),1e4);(async()=>{let t=await fetch(`${n.apiBase}/api/v1/health`,{credentials:`include`,signal:r.signal,cache:`no-store`});if(!t.ok)throw Error(`bootstrap HTTP ${t.status}`);let i=Ft.pick({bootProject:!0}).parse(await t.json());r.signal.throwIfAborted(),n={...n,bootProject:i.bootProject};for(let t of e.values())t.bootAlias&&t.demand.kind===`run`&&(t.demand.projectId=i.bootProject);await Yt(r.signal),await Promise.all(y().filter(e=>e.demand.kind===`run`).map(e=>O(e,`document resumed`,r.signal))),r.signal.throwIfAborted(),p===r&&(p=void 0,h=0,te(!0))})().catch(()=>{p!==r||d||!Vt()||(l=!1,h=Math.min(h+1,5),m=setTimeout(()=>{m=void 0,A(!0)},Math.min(3e4,1e3*2**h)))}).finally(()=>clearTimeout(i))},ne=()=>{Vt()&&(k(),A(!0))},j=()=>{a||typeof window>`u`||(a=Gt(A),window.addEventListener(`online`,ne))};return{resetSession(){k(),n=void 0,u=!1,f=!1,w=!1,v(void 0)},requestWorkspaceReady(){return!r||g!==`topics`?!1:(w=!0,T(),!0)},workspaceReadyReceived(){w=!1},transport:()=>g,onTransport(e){return _.add(e),()=>{_.delete(e)}},bootProject:()=>n?.bootProject,configure(t){if(!p&&!(n&&n.apiBase===t.apiBase&&n.bootProject===t.bootProject)){k(),n=t,u=!1;for(let n of e.values())n.bootAlias&&n.demand.kind===`run`&&(n.demand.projectId=t.bootProject);++o,te()}},subscribe(t,n){let r=C(oe.parse(t)),i=String(++s),c={id:i,demand:r,handlers:n,bootAlias:t.kind===`run`&&t.projectId==="default",recovering:!1,released:!1,frame(e){if(!(c.released||c.recovering||!l||p))if(`type`in e&&e.type===`event`&&c.demand.kind===`run`){if(e.projectId!==c.demand.projectId||e.runId!==c.demand.runId||e.event.seq<=c.demand.afterSeq)return;n.frame?.(e),c.demand.afterSeq=e.event.seq,ee({type:`ack`,id:i,seq:e.event.seq})}else`type`in e&&(e.type===`reset`||e.type===`error`)?O(c,e.error):n.frame?.(e)},value:(e,t)=>{!c.released&&l&&!p&&n.value?.(e,t)},reset:(e,t)=>O(c,e,t)};return e.set(i,c),++o,j(),te(),()=>{if(!c.released){if(c.released=!0,c.recovery?.abort(),e.delete(i),++o,e.size){T();return}k(),a?.(),a=void 0,window.removeEventListener(`online`,ne)}}},invalidateReads(){for(let e of y())e.demand.kind===`read`&&ee({type:`refresh`,id:e.id});S.refresh()},dispose(){d=!0,k(),e.clear(),a?.(),a=void 0,typeof window<`u`&&window.removeEventListener(`online`,ne)}}}var R=en(),tn=R.configure,nn=R.subscribe,rn=R.invalidateReads,an=R.bootProject,on=R.transport,sn=R.onTransport,cn=R.resetSession,ln=R.requestWorkspaceReady,un=R.workspaceReadyReceived,dn=new Set([`connected`,`disconnected`,`not-installed`,`unknown`]);function fn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pn(e,t){return typeof e==`boolean`||!t&&e===void 0}function mn(e,t){return e===void 0||typeof e==`string`&&e.length>=1&&e.length<=128&&t===`disconnected`}function hn(e,t,n,r,i,a){return typeof e==`string`&&e.length>0&&typeof t==`string`&&dn.has(t)&&pn(n,a)&&(r===void 0||typeof r==`string`)&&mn(i,t)}function gn(e,t){if(!fn(e))return null;let{provider:n,status:r,enabled:i,hint:a,authFailureId:o}=e;return hn(n,r,i,a,o,t)?{provider:n,status:r,...typeof i==`boolean`?{enabled:i}:{},...typeof a==`string`?{hint:a}:{},...typeof o==`string`?{authFailureId:o}:{}}:null}function _n(e){return gn(e,!1)}function vn(e,t){if(!fn(e)||!Array.isArray(e.providers))return null;let n=[],r=new Set;for(let i of e.providers){let e=gn(i,t);if(e===null||r.has(e.provider))return null;r.add(e.provider),n.push(e)}return n}function yn(e){let t=vn(e,!0);return t===null||t.length===0?null:t}function bn(e){let t=yn(e);if(t===null)throw Error(`Invalid provider status response`);return{providers:t}}function xn(e,t){let n=yn(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 Sn(e,t,n,r){let i=yn(e),a=yn(t),o=yn(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:Cn(t,n)?e:i?{...e,enabled:n.enabled}:n})}}function Cn(e,t){return e.provider===t.provider&&e.status===t.status&&e.enabled===t.enabled&&e.hint===t.hint&&e.authFailureId===t.authFailureId}function wn(e,t){let n=yn(e);if(n===null)return[];let r=new Set(n.filter(e=>e.enabled&&e.status===`connected`).map(e=>e.provider));return(t?.runners??[]).map(e=>e.id).filter(e=>r.has(e))}function Tn(e,t){return yn(e)?.find(e=>e.provider===t)}var En=M([`low`,`medium`,`high`,`xhigh`,`max`]),Dn=_().max(32).optional(),On=M([`queued`,`running`,`waiting`,`review`,`done`,`failed`,`cancelled`]),kn=M([`pending`,`running`,`waiting`,`review`,`done`,`failed`,`cancelled`,`skipped`]),An=M([`agent`,`check`]);function jn(){return d(_(),_().optional())}T({browseRoot:_(),projectsDir:_(),archiveOnMerge:S().nullable(),effectiveArchiveOnMerge:S(),archiveOnMergeSource:M([`global`,`environment`,`default`]),composerDefaults:T({autonomous:S().nullable(),worktree:S().nullable(),inheritedAutonomous:O([S(),w(`source-dependent`)]),inheritedWorktree:S()}),resources:T({maxParallel:x(),maxMonitoringSessions:x(),monitoringWakeIntervalMinutes:x().nullable(),autoResumeOnUsageLimit:S(),memoryLimitMb:x().nullable(),worktreeRetentionDefault:x()}),agentDefaults:T({runner:L.optional(),models:jn().optional()})}),T({browseRoot:_().trim().min(1).max(4096).optional(),projectsDir:_().trim().min(1).max(4096).optional(),archiveOnMerge:S().nullable().optional(),composerDefaults:T({autonomous:S().nullable().optional(),worktree:S().nullable().optional()}).optional(),agentDefaults:T({runner:L.nullable().optional(),models:d(_(),_().trim().min(1).max(200).nullable().optional()).optional()}).optional(),resources:T({maxParallel:x().int().min(1).max(16).optional(),maxMonitoringSessions:x().int().min(0).max(16).optional(),monitoringWakeIntervalMinutes:x().int().min(1).max(60).nullable().optional(),autoResumeOnUsageLimit:S().optional(),memoryLimitMb:x().int().min(0).max(1048576).nullable().optional(),worktreeRetentionDefault:x().int().min(0).max(1e3).optional()}).optional()});var Mn=T({accent:M([`cezarion`,`lime`,`violet`]).optional(),density:M([`comfortable`,`compact`,`ultra`]).optional(),width:M([`narrow`,`wide`]).optional()}),Nn=h({expandedColumns:d(_(),S()).optional()}),Pn=T({overall:x().int().positive().nullable().optional(),needsYou:x().int().positive().nullable().optional(),finished:x().int().positive().nullable().optional(),working:x().int().positive().nullable().optional()});function Fn(e){let t={overall:10,needsYou:null,finished:null,working:null},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let e of Object.keys(t)){let r=Pn.shape[e].safeParse(n[e]);r.success&&r.data!==void 0&&(t[e]=r.data)}return t}h({sidebarLimits:Pn.optional(),lastTask:T({source:M([`workflow`,`skill`]),ref:_()}).nullable().optional(),recentSources:j(T({source:M([`workflow`,`skill`]),ref:_()})).optional(),lastWorktree:S().optional(),lastAutonomous:S().optional(),skillUsage:d(_(),x()).optional(),runsView:M([`list`,`table`]).optional(),githubView:M([`issues`,`prs`]).optional(),appearance:Mn.optional(),promptTemplates:j(T({id:_(),label:_(),text:_(),skills:j(_()).optional()})).optional()});var In=te({projectId:_().min(1).max(64),pathname:_().min(1).max(2048).startsWith(`/p/`),search:_().max(4096).startsWith(`?`).optional(),hash:_().max(2048).startsWith(`#`).optional()}),Ln=h({sidebar:h({collapsed:d(_(),S()).optional(),projectOrder:j(_()).optional()}).optional(),dismissedProviderAuthFailures:jn().optional(),appearance:Mn.optional(),notifications:h({enabled:S().optional()}).optional(),taskTable:Nn.optional(),lastLocation:In.optional()}),Rn=200,zn=50;h({...Ln.shape,sidebar:h({collapsed:d(_().min(1).max(64),S()).refine(e=>Object.keys(e).length<=Rn,{message:`sidebar.collapsed must have at most ${Rn} entries`}).optional(),projectOrder:j(_().min(1).max(64)).max(Rn).optional()}).optional(),dismissedProviderAuthFailures:d(_(),_().min(1).max(128).optional()).optional(),taskTable:Nn.extend({expandedColumns:d(_().min(1).max(64),S()).refine(e=>Object.keys(e).length<=zn,{message:`taskTable.expandedColumns must have at most ${zn} entries`}).optional()}).optional()}).superRefine((e,t)=>{Object.keys(e).length>Rn&&t.addIssue({code:`custom`,message:`ui-state has too many keys (max ${Rn})`})});var Bn=jn(),Vn=4e3,Hn=7200,Un=T({commands:j(_().trim().min(1).max(Vn)).max(20),timeoutSeconds:x().int().min(1).max(Hn).optional()}).strict();T({archiveOnMerge:S().nullable(),effectiveArchiveOnMerge:S(),archiveOnMergeSource:M([`project`,`global`,`environment`,`default`]),baseBranch:_().nullable(),defaultRunner:L,systemPrompt:_().nullable(),defaultModels:Bn,modelsLocked:S(),maxParallel:x(),memoryLimitMb:x().nullable(),worktreeRetention:x(),liveTitleUpdates:S().nullable(),reviewGate:S().nullable(),worktreeSetup:T({commands:j(_()),timeoutSeconds:x()}).nullable(),worktreeSetupIssue:_().nullable(),worktreeTeardown:T({commands:j(_()),timeoutSeconds:x()}).nullable(),worktreeTeardownIssue:_().nullable()}),T({archiveOnMerge:S().nullable().optional(),baseBranch:_().trim().min(1).max(200).nullable().optional(),defaultRunner:L.optional(),systemPrompt:_().trim().max(2e4).nullable().optional(),defaultModels:d(_(),_().trim().max(200).nullable().optional()).optional(),maxParallel:x().int().min(1).max(16).optional(),memoryLimitMb:x().int().min(0).max(1048576).nullable().optional(),worktreeRetention:x().int().min(0).max(1e3).nullable().optional(),liveTitleUpdates:S().nullable().optional(),reviewGate:S().nullable().optional(),worktreeSetup:Un.nullable().optional(),worktreeTeardown:Un.nullable().optional()});var Wn=L,Gn=M([`connected`,`disconnected`,`not-installed`,`unknown`]),Kn=T({requiresAccountHome:S().optional(),provider:Wn,status:Gn,enabled:S().optional(),hint:_().optional(),authFailureId:_().optional(),profileId:_().optional()});T({providers:j(Kn)}),C(`opened`,[T({opened:w(!0),command:_()}),T({opened:w(!1),connected:w(!0),command:_()})]),C(`state`,[T({id:b(),state:w(`waiting`),url:_().url()}),T({id:b(),state:M([`connected`,`cancelled`])}),T({id:b(),state:w(`failed`),error:_()})]);var qn=L,Jn=T({id:_(),label:_(),description:_(),effortLevels:j(En).optional()});T({runner:L,models:j(Jn),source:M([`live`,`cache`,`unavailable`]),stale:S(),reason:_().optional()});var Yn=T({runner:qn,requestedModel:_(),availableModels:j(Jn),otherRunners:j(qn)});T({targets:j(T({id:_(),label:_(),icon:_().optional()}))}),T({target:_().trim().min(1,`target required`).max(200)}),T({opened:w(!0),path:_()});var Xn=M([`spawn`,`inspect`,`steer`,`stop`,`destroy`,`diff`,`wait`]),z=_().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Zn=_().regex(/^[0-9a-f]{64}$/),B=j(b()).min(1).max(32).refine(e=>new Set(e).size===e.length),Qn=j(Xn).max(7).refine(e=>new Set(e).size===e.length),$n=j(M([`process`,`worktree`,`branch`])).max(3).refine(e=>new Set(e).size===e.length),er=_().max(2e3),tr=T({ownerRunId:b(),resourceId:b(),kind:w(`owned-isolated`),path:_().min(1),branch:_().min(1),baselineSha:z}).strict(),nr=T({ownerRunId:b(),resourceId:b(),kind:w(`shared`),path:_().min(1),hostRunId:b(),baselineSha:z}).strict(),rr=C(`kind`,[tr,nr]),ir={"owned-isolated":!0,shared:!1};function ar(e){return ir[e.kind]}var or=te({kinds:j(M([`owned-isolated`,`shared`])).max(2).refine(e=>new Set(e).size===e.length),live:x().int().min(0).max(32),get children(){return or.optional()}}),V=T({id:b(),workerIds:j(b()).max(32).refine(e=>new Set(e).size===e.length),requestIds:j(b()).min(1).max(32).optional(),requestOutcomes:j(D).max(32).optional(),deadline:N(),mode:E.optional(),revisions:j(T({workerId:b(),revision:x().int().nonnegative()}).strict()).max(32).optional(),reason:M([`outcome`,`timeout`,`cancelled`,`message`]).optional(),phase:M([`registered`,`parked`,`wake-pending`]),outcomes:j(ue).max(32),wakeId:b().optional()}).strict(),sr=V.omit({deadline:!0,requestIds:!0,requestOutcomes:!0}).extend({via:w(`completion`)}).strict(),cr=T({attempts:x().int().positive(),nextAt:N(),needsAttention:w(!0).optional()}).strict(),lr=T({requestedAt:N(),phase:M([`requested`,`terminating`,`cleaning`,`complete`,`incomplete`]),remaining:$n,error:er.optional(),discardWork:w(!0).optional()}).strict(),ur=lr.extend({retry:cr.optional()}).strict(),dr=T({requestId:b(),workerId:b(),requestHash:Zn,supervisorRunId:b().optional(),deletion:T({phase:M([`pending`,`complete`]),revision:x().int().nonnegative(),resourceId:b(),generation:b()}).strict().optional()}).strict(),fr=L,pr=_().min(1).max(4096).refine(e=>!/[\\\u0000-\u001f\u007f:]/.test(e)&&!e.startsWith(`/`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e.toLowerCase()!==`.git`));function mr(e){return e.split(`/`).at(-1)?.toLowerCase()===`.gitignore`?`--attach cannot attach a .gitignore: ${e}; ignore rules must come from the baseline`:void 0}var hr=C(`kind`,[T({kind:w(`baseline-file`),path:pr}).strict(),T({kind:w(`parent-attachment`),id:_().min(1).max(255).regex(/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/).refine(e=>!e.includes(`..`))}).strict(),T({kind:w(`parent-file`),path:pr}).strict().superRefine(({path:e},t)=>{let n=mr(e);n&&t.addIssue({code:`custom`,path:[`path`],message:n})})]),gr=T({text:_().max(1e5).optional(),artifacts:j(hr).max(32).optional()}).strict().superRefine(({artifacts:e=[]},t)=>{let n=new Set;for(let[r,i]of e.entries())i.kind===`parent-file`&&(n.has(i.path)&&t.addIssue({code:Dt.custom,path:[`artifacts`,r,`path`],message:`duplicate --attach path: ${i.path}`}),n.add(i.path))}),_r=T({source:hr,path:_().min(1).max(8192),sha256:Zn,bytes:x().int().min(0).max(2**53-1)}).strict(),vr=T({text:_().max(1e5).optional(),inputs:j(_r).max(32)}).strict(),yr=T({state:w(`unavailable`),reason:M([`no-assistant-output`,`missing`,`unreadable`,`unverified`,`unsupported`]),detail:er.optional()}).strict(),br=T({state:w(`deleted`),reason:w(`missing`)}).strict(),xr=M([`running`,`review-ready`,`completed`,`failed`,`cancelled`]),Sr=C(`state`,[T({state:w(`available`),id:_().max(255),path:_().max(8192)}).strict(),yr.extend({id:_().max(255),path:_().max(8192)}),br.extend({id:_().max(255),path:_().max(8192)})]),Cr=M([`available`,`unavailable`,`deleted`]),wr=C(`state`,[T({state:w(`unchanged`)}).strict(),T({state:w(`changed`),paths:j(_().max(8192)).max(100),truncated:S(),headMoved:S(),branchMoved:S(),indexMoved:S()}).strict(),T({state:w(`unavailable`),reason:er}).strict()]);T({result:T({workerId:b(),parentRunId:b(),revision:x().int().nonnegative(),observedAt:N(),status:On,outcome:M([`running`,`review-ready`,`completed`,`failed`,`cancelled`,`destroyed`]),lastExecutionOutcome:xr,partial:S(),settled:S(),error:er.optional(),backend:fr.optional(),model:_().max(512).optional(),baselineSha:z,workspace:C(`kind`,[tr.extend({state:Cr.optional()}),nr.extend({state:Cr.optional()})]),cleanup:M([`retained`,`requested`,`terminating`,`cleaning`,`complete`,`incomplete`]),summary:C(`state`,[T({state:w(`available`),text:_().min(1).max(4e3),source:M([`assistant`,`failure`]),seq:x().int().nonnegative(),truncated:S()}).strict(),yr,br]),head:C(`state`,[T({state:w(`available`),sha:z}).strict(),yr.extend({sha:z.optional()}),br.extend({sha:z.optional()})]),diff:C(`state`,[T({state:w(`available`),snapshotId:b(),path:_().min(1).max(8192),truncated:S()}).strict(),yr,br]),changes:wr.optional(),artifacts:C(`state`,[T({state:w(`available`),items:j(Sr).max(32),truncated:S()}).strict(),yr,br])}).strict(),diffSnapshot:_().max(4e5).optional()}).strict();var Tr=T({workerId:b(),revision:x().int().nonnegative(),snapshotId:b(),observedAt:N(),lastExecutionOutcome:xr,previous:T({revision:x().int().nonnegative(),observedAt:N(),lastExecutionOutcome:xr}).strict().optional()}).strict(),Er=C(`role`,[T({role:w(`root`),conversation:le.optional(),permissions:Qn,spawnGrant:or.optional(),receipts:j(dr).max(1024).refine(e=>new Set(e.map(e=>`${e.supervisorRunId??``} ${e.requestId}`)).size===e.length&&new Set(e.map(e=>e.workerId)).size===e.length),wait:V.optional(),lastWait:V.optional(),results:j(Tr).max(1024).refine(e=>new Set(e.map(e=>e.workerId)).size===e.length).optional(),finishRequestedAt:N().optional(),historyDeletion:w(`pending`).optional(),completion:T({phase:M([`waiting`,`attention`]),waitId:b().optional()}).strict().optional()}).strict(),T({role:w(`worker`),wait:V.optional(),lastWait:V.optional(),permissions:Qn,spawnGrant:or.optional(),parentRunId:b(),supervisorRunId:b().optional(),workspace:rr,destroy:lr.optional(),context:vr.optional(),executionRevision:x().int().nonnegative().optional(),executionStartSeq:x().int().nonnegative().optional()}).strict(),T({role:w(`invalid`)}).strict()]);function Dr(e){return e?.role===`root`||e?.role===`worker`&&!!e.spawnGrant?.kinds.length}var Or=C(`role`,[Er.options[0].pick({role:!0}).strip().extend({wait:V.pick({phase:!0,requestIds:!0,workerIds:!0}).partial({workerIds:!0}).strip().extend({outcomes:j(ue.pick({workerId:!0}).strip()).max(32).optional()}).optional()}),Er.options[1].pick({role:!0,parentRunId:!0,supervisorRunId:!0}).strip().extend({wait:V.pick({phase:!0,requestIds:!0}).strip().optional()}),Er.options[2].strip()]),kr=M([`isolated`,`shared`]);T({task:_().min(1).max(1e5),baseline:_().min(1).max(1024).optional(),workspace:kr.optional(),requestId:b(),context:gr.optional(),backend:fr.optional(),model:_().trim().min(1).max(512).optional(),effort:Dn,workflow:_().trim().min(1).max(200).optional(),skill:_().trim().min(1).max(200).optional()}).strict().refine(e=>e.skill===void 0||e.workflow===void 0,{message:`--skill and --workflow cannot be used together`}).refine(e=>e.task.length+(e.context?.text?.length??0)<=1e5,{message:`Combined task and context exceed 100000 characters`}),T({text:_().max(1e5).refine(e=>e.trim().length>0)}).strict(),T({workerIds:B,timeoutSeconds:x().int().min(1).max(7200).default(600),mode:E.optional()}).strict().refine(e=>e.mode!==`one`||e.workerIds.length===1,{message:`one mode requires exactly one worker`});var Ar=T({workerId:b(),settled:S(),parentRunId:b(),supervisorRunId:b().optional(),status:M([`queued`,`running`,`waiting`,...ue.shape.status.options]),currentStepId:_().optional(),workspace:rr,backend:fr.optional(),model:_().max(512).optional(),inputs:j(_r).max(32).optional(),wait:V.optional(),completionWait:sr.optional(),destroy:ur.optional(),outcome:ue.optional(),scope:T({backend:M([`cgroup`,`job`,`groups`]),guarantee:M([`contained`,`scoped`])}).strict().optional()}),jr=Ar.pick({workerId:!0,parentRunId:!0,supervisorRunId:!0,status:!0,workspace:!0,destroy:!0}).extend({revision:x().int().nonnegative(),settled:S(),destroyed:S()}).strict(),Mr=T({workers:j(jr).max(1024)}).strict();T({offset:_().regex(/^\d{1,4}$/).refine(e=>Number(e)<=1024).optional()}).strict(),Mr.extend({workers:j(jr).max(32),nextOffset:x().int().min(1).max(1024).optional()}).strict(),T({workerId:b(),baselineSha:z,diff:_().max(4e5),truncated:S()}),T({workerId:b(),state:M([`stopping`,`terminated`])});var Nr=T({uncommittedFiles:x().int().nonnegative(),commits:x().int().nonnegative()}).strict();T({discardWork:w(!0).optional()}).strict(),T({workerId:b(),state:M([`complete`,`incomplete`]),work:Nr.optional(),deleted:j(C(`kind`,[T({kind:w(`worktree`),path:_().max(8192)}).strict(),T({kind:w(`branch`),ref:_().max(1024)}).strict()])).max(2).optional(),remaining:$n,error:er.optional()});var Pr=T({outstanding:x().int().nonnegative(),limit:x().int().nonnegative(),created:x().int().nonnegative(),creationLimit:x().int().nonnegative()}).strict(),Fr=T({id:_(),title:_(),titleSummary:_().optional(),titleOrigin:M([`user`,`auto`,`marker`]).optional()}),Ir=T({parentRunId:b().optional(),supervisorRunId:b().optional(),workers:j(Ar).max(1024),titles:j(Fr).max(1025).optional(),capacity:Pr.optional()});T({code:M([`unavailable_transport`,`unauthenticated`,`denied_scope`,`invalid_input`,`invalid_baseline`,`incompatible_state`,`capacity_limit`,`unavailable_diff`,`incomplete_cleanup`]),error:er,modelChoices:Yn.optional()}),T({workerId:b()}).strict(),T({workerId:b(),baselineSha:z}).strict(),T({workerId:b(),state:M([`queued`,`delivered`])}).strict();var Lr=T({wait:V,instruction:_().min(1).max(1e3)}).strict();T({}).strict(),T({waitId:b()}).strict();var Rr=T({wait:V}).strict();T({peerIds:B,timeoutSeconds:x().int().min(1).max(7200).default(600)}).strict();var zr=C(`reason`,[T({reason:w(`message`),peerRunId:b(),messageId:b()}).strict(),T({reason:w(`settled`),peerRunId:b()}).strict(),T({reason:w(`timeout`)}).strict()]);function Br(e,t){(e.phase===`resolved`||e.phase===`delivered`)&&!e.result&&t.addIssue({code:`custom`,message:`a ${e.phase} peer wait has a result`,path:[`result`]}),e.phase===`open`&&e.result&&t.addIssue({code:`custom`,message:`an open peer wait has no result`,path:[`result`]})}var Vr=T({id:b(),peerIds:B,deadline:N(),phase:M([`open`,`resolved`,`delivered`,`cancelled`]),result:zr.optional()}).strict().superRefine(Br),Hr=T({wait:Vr,instruction:_().min(1).max(1e3)}).strict(),Ur=T({wait:Vr}).strict();O([Lr,Hr]),O([Rr,Ur]);var Wr=M([`passing`,`failing`,`pending`]).nullable(),Gr=T({kind:M([`issue`,`pr`]),number:x(),title:_(),author:_(),createdAt:_(),labels:j(_()),body:_().optional(),url:_(),comments:x(),assignees:j(_()).optional(),projectIds:j(_()).optional(),isDraft:S().optional(),additions:x().optional(),deletions:x().optional(),checks:Wr.optional()});C(`available`,[T({available:w(!0),item:Gr.nullable(),labelColors:d(_(),_()).optional()}),T({available:w(!1),reason:_()})]),T({kind:M([`issue`,`pr`]),number:ee().int().positive().safe()});var Kr=T({id:_(),title:_(),url:_()});T({available:S(),reason:_().optional(),repo:_().optional(),syncedAt:_().optional(),issues:j(Gr),prs:j(Gr),labelColors:d(_(),_()).optional(),viewerLogin:_().optional(),projects:j(Kr).optional(),projectsReason:_().optional(),projectsState:M([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:_().optional(),issuesTotal:x().int().nonnegative().optional(),prsTotal:x().int().nonnegative().optional(),issuesNextCursor:_().nullable().optional(),prsNextCursor:_().nullable().optional(),commentsDeferred:w(!0).optional()});var qr=_().min(1).max(2e3).optional();T({limit:_().optional(),refresh:_().optional(),issuesCursor:qr,prsCursor:qr,issuesDone:w(`1`).optional(),prsDone:w(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),T({kind:M([`issue`,`pr`]),numbers:_().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:w(`1`).optional()}),C(`available`,[T({available:w(!0),counts:d(x(),x().int().nonnegative())}),T({available:w(!1),reason:_()})]),C(`available`,[T({available:w(!0),checks:d(x(),Wr)}),T({available:w(!1),reason:_()})]),T({kind:M([`issue`,`pr`]),q:_().trim().min(1).max(256),limit:ee().int().positive().max(50).optional()}),T({available:S(),projectsReason:_().optional(),reason:_().optional(),items:j(Gr),truncated:S().optional(),labelColors:d(_(),_()).optional()});var Jr=M([`draft`,`review-required`,`changes-requested`,`checks-pending`,`checks-failing`,`ready`,`merged`,`closed`,`open`,`completed`,`not-planned`]),Yr=x().nullable();C(`available`,[T({available:w(!0),prs:d(x(),Jr),issues:d(x(),Jr),conflicts:j(x()).optional(),recheckAfterMs:Yr}),T({available:w(!1),reason:_(),recheckAfterMs:Yr})]);var Xr=T({id:x(),author:_(),avatarUrl:_().optional(),createdAt:_(),body:_(),kind:M([`comment`,`review`]),reviewState:M([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:_()}),Zr=M([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Qr=T({id:_(),kind:Zr,actor:_(),avatarUrl:_().optional(),createdAt:_(),url:_().optional(),sha:_().optional(),message:_().optional(),checks:Wr.optional(),label:T({name:_(),color:_().optional()}).optional(),subject:_().optional(),refNumber:x().optional(),refTitle:_().optional(),refIsPr:S().optional()});T({available:S(),reason:_().optional(),comments:j(Xr),truncated:S().optional(),events:j(Qr).optional(),detail:T({body:_(),additions:x().int().nonnegative().optional(),deletions:x().int().nonnegative().optional()}).optional()});var $r=M([`merge`,`squash`,`rebase`]),ei=T({name:_(),state:M([`passing`,`failing`,`pending`,`unknown`]),required:S().nullable(),url:_().optional()}),ti=T({number:x(),title:_(),url:_(),state:M([`open`,`closed`,`merged`]),isDraft:S(),headRef:_(),baseRef:_(),headSha:_(),mergeable:M([`mergeable`,`conflicting`,`unknown`]),reviewDecision:M([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:j(ei),methods:j($r),defaultMethod:$r.nullable(),eligibility:M([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:j(T({code:_(),message:_()})),canMerge:S(),canOverride:S()});C(`available`,[T({available:w(!0),mergeState:ti}),T({available:w(!1),reason:_()})]),T({merged:w(!0),number:x(),url:_(),method:$r,mergeCommitSha:_().optional()});var ni=T({path:_(),previousPath:_().optional(),status:M([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:x(),deletions:x(),patch:_().optional(),patchUnavailableReason:M([`binary`,`too-large`,`not-provided`]).optional(),truncated:S().optional()});C(`available`,[T({available:w(!0),number:x(),headSha:_(),files:j(ni),additions:x(),deletions:x(),truncated:S(),reason:_().optional()}),T({available:w(!1),reason:_()})]),T({generation:_().uuid()}),C(`state`,[T({generation:_().uuid(),state:w(`ready`),projects:j(Kr),membership:d(_(),j(_()))}),T({generation:_().uuid(),state:w(`unavailable`),reason:_()})]),T({command:_().min(1).max(1024),port:x().int().min(1).max(65535),cwd:_().optional(),label:_().min(1).max(48).optional(),path:_().startsWith(`/`).optional()});var ri=M([`registered`,`replaced`,`invalid_input`,`cwd_outside_worktree`,`cezar_port`,`port_held`,`too_many`,`preview_disabled`,`headless`,`worktree_missing`,`unavailable`]);T({ok:S(),code:ri,message:_(),hint:_()}),T({port:x().int().min(1).max(65535),restart:S().optional()}).strict(),T({ok:S(),code:M([`stopped`,`restarted`,`approval_required`,`adopted`,`not_registered`,`port_held`,`port_in_use`,`invalid_input`,`preview_disabled`,`headless`,`worktree_missing`,`unavailable`]),message:_(),hint:_()});var H=T({port:x().int().min(1).max(65535),command:_(),cwd:_().optional(),label:_(),path:_().optional(),registeredAt:N(),answeredAtRegistration:S()}),ii=M([`registered`,`starting`,`up`,`stalled`,`exited`,`stopped`,`adopted`,`unavailable`]),ai=T({type:w(`preview.agent-browser`),state:M([`connected`,`disconnected`])}),oi=x().int().min(1).max(65535),si=e=>Math.min(4e3,Math.max(100,Math.round(e))),ci=e=>Math.min(2,Math.max(1,e)),li=M([`normal`,`high`,`ultra`]),ui=M([`mousePressed`,`mouseReleased`,`mouseMoved`,`mouseWheel`]),di=M([`left`,`middle`,`right`,`none`]),fi=M([`keyDown`,`rawKeyDown`,`keyUp`]);C(`t`,[T({t:w(`open`),viewerId:_().min(1).max(128).optional(),resume:S().optional(),target:O([T({port:oi}),T({url:_().min(1).max(2048)}),T({agent:w(!0)})]),quality:li.optional(),dpr:x().finite().transform(ci).optional()}),T({t:w(`quality`),quality:li}),T({t:w(`run`),port:oi}),T({t:w(`stop`),port:oi}),T({t:w(`keepWaiting`),port:oi}),T({t:w(`resize`),w:x().finite().transform(si),h:x().finite().transform(si),dpr:x().finite().transform(ci).optional()}),T({t:w(`mouse`),type:ui,x:x().finite(),y:x().finite(),button:di.optional(),buttons:x().optional(),clickCount:x().optional(),deltaX:x().optional(),deltaY:x().optional(),modifiers:x().optional()}),T({t:w(`key`),type:fi,key:_().optional(),code:_().optional(),text:_().optional(),modifiers:x().optional(),vk:x().optional(),commands:j(_()).optional()}),T({t:w(`insertText`),text:_()}),T({t:w(`nav`),url:_().min(1).max(2048)}),T({t:w(`back`)}),T({t:w(`forward`)}),T({t:w(`reload`),ignoreCache:S().optional()}),T({t:w(`dialogResult`),accept:S(),text:_().optional()}),T({t:w(`ack`)}),T({t:w(`ping`),ts:x()}),T({t:w(`download`)}),T({t:w(`cancelDownload`)}),T({t:w(`retryBrowser`)})]);var pi=C(`t`,[C(`stage`,[T({t:w(`state`),stage:w(`chromium-missing`),installCommand:_(),canDownload:S()}),T({t:w(`state`),stage:w(`downloading`),received:x(),total:x()}),T({t:w(`state`),stage:w(`download-failed`),error:_(),installCommand:_()}),T({t:w(`state`),stage:w(`sandbox-failed`),stderrTail:_()}),T({t:w(`state`),stage:w(`browser-exited`),reason:M([`timeout`,`exited`]).optional(),signal:_().optional(),exitCode:x().int().optional(),stderrTail:_(),serverUp:S()}),T({t:w(`state`),stage:w(`needs-approval`),server:H,wasRunning:S()}),T({t:w(`state`),stage:w(`port-held`),server:H,ownerTitle:_()}),T({t:w(`state`),stage:w(`server-starting`),server:H,attempt:x().int(),startedAt:N(),logTail:j(_())}),T({t:w(`state`),stage:w(`server-stalled`),server:H,logTail:_()}),T({t:w(`state`),stage:w(`server-exited`),server:H,exitCode:x().int().nullable(),logTail:_()}),T({t:w(`state`),stage:w(`server-stopped`),server:H,reason:M([`user`,`idle`]),lastUrl:_()}),T({t:w(`state`),stage:w(`worktree-removed`),server:H.optional()}),T({t:w(`state`),stage:w(`loading`),step:M([`browser`,`page`,`frame`])}),T({t:w(`state`),stage:w(`streaming`),adopted:S()}),T({t:w(`state`),stage:w(`agent-idle`)})]),T({t:w(`url`),url:_()}),T({t:w(`cursor`),cursor:_()}),T({t:w(`dialog`),type:M([`alert`,`confirm`,`prompt`,`beforeunload`]),message:_(),defaultPrompt:_().optional(),origin:_()}),T({t:w(`replaced`),by:_()}),T({t:w(`pong`),ts:x()}),T({t:w(`downloadProgress`),received:x(),total:x()})]),mi=[`text/plain`,`text/markdown`,`text/x-markdown`,`application/pdf`];function hi(e){return e.startsWith(`image/`)}function gi(e){return hi(e)||mi.includes(e)}function _i(e){return/png/.test(e)?`png`:/jpe?g/.test(e)?`jpg`:/webp/.test(e)?`webp`:/gif/.test(e)?`gif`:e===`application/pdf`?`pdf`:e===`text/plain`?`txt`:e===`text/markdown`||e===`text/x-markdown`?`md`:`img`}var vi=new Set([`png`,`jpg`,`jpeg`,`webp`,`gif`,`img`]);function yi(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&vi.has(t)}var bi=T({replayAfterOpen:w(!0).optional(),id:_(),text:_(),images:j(_()).optional(),createdAt:_()}),xi=bi.extend({origin:M([`human`,`lifecycle`]).optional(),agentInputId:b().optional(),task:_().optional(),resumeContext:T({failure:T({stepId:_().optional(),error:_()}).optional(),restarted:w(!0).optional(),cutOff:T({tools:j(_()).max(6).optional(),subagents:j(_()).max(6).optional()}).optional()}).optional()}),U=T({id:_().min(1),name:_().optional(),prompt:_().optional(),skill:_().optional(),model:_().optional(),effort:_().max(32).optional(),timeoutMs:x().int().min(0).max(2147483647).optional(),runner:L.optional(),agentProfile:_().min(1).max(64).optional(),allowedTools:j(_()).optional(),bashAllowlist:j(_()).optional(),command:_().optional(),onFail:T({retry:_().min(1),max:x().int().positive().default(2)}).optional()}).refine(e=>!!e.command!=!!(e.prompt??e.skill),{message:`a step is either an agent step (prompt/skill) or a check step (command), not both`}).refine(e=>!e.command||e.timeoutMs===void 0,{message:`timeoutMs applies only to agent steps`,path:[`timeoutMs`]}),Si=T({name:_(),description:_().optional(),steps:j(U),source:M([`built-in`,`file`]),path:_().optional()});function Ci(e,t,n){let r=new Set;for(let n of e.steps)n.command||r.add(n.runner??t);return n.filter(e=>r.has(e))}var wi=T({path:_(),message:_()});T({workflows:j(Si),issues:j(wi)}),T({name:_().trim().min(1).max(80),description:_().max(2e3,`must be at most 2000 characters`).optional(),steps:j(U).min(1).max(8).optional(),skills:j(_().trim().min(1)).min(1).max(8).optional(),overwrite:S().optional()}).refine(e=>!!e.steps!=!!e.skills,{message:`provide either "steps" or "skills", not both`}),T({path:_(),name:_()}),T({name:_(),description:_().optional(),steps:j(U)}),T({ok:w(!0),path:_()}),T({name:_().optional(),steps:j(U),rationale:_(),fallback:S()});var Ti=/^https:\/\/([a-zA-Z0-9](?:[a-zA-Z0-9.-]*[a-zA-Z0-9])?)\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)\/pull\/([1-9][0-9]*)$/,Ei=_().max(2048).regex(Ti).refine(e=>{let t=Ti.exec(e);return!!t&&Number.isSafeInteger(Number(t[4]))&&t[3]!==`.`&&t[3]!==`..`},`Expected an HTTPS GitHub PR URL with a positive integer PR number`),Di=M([`checks`,`merge`,`merge_or_blocked`]),Oi=T({pr:Ei,until:Di.default(`checks`),wake_on_conflict:S().default(!0),timeout_seconds:x().int().min(1).max(7200).default(1800),head_sha:_().regex(/^[0-9a-f]{40}$/i).optional()}).strict(),ki=_().regex(/^[0-9a-f]{40}$/i),Ai=T({prUrl:Ei,repository:_().max(2048).regex(/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/),prNumber:x().int().positive().max(2**53-1),headSha:ki}).strict(),ji=M([`passed`,`failed`,`cancelled`,`skipped`,`no_checks`,`stuck`,`startup_failure`,`head_changed`,`conflicting`,`deadline`,`error`,`merged`,`closed`,`blocked`]),Mi=M(`invalid_request.unsupported_host.gh_missing.authentication.inaccessible_pr.malformed_data.output_limit.query_timeout.command_failed.wait_conflict.capacity.unavailable.unauthorized.persistence.manager_disposed.capability_revoked.run_missing.run_not_running.run_stopping.session_replaced.session_closed.run_cancelled.finish_requested.generation_mismatch.worker_wait_pending.worker_execution_stopped.root_finish_pending.registration_aborted.turn_changed`.split(`.`));T({code:Mi,message:_().max(4096)}).strict();function Ni(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<=127?1:e<=2047?2:e<=65535?3:4}return t}var Pi=T({reason:M([`conflict`,`no_pending_merge`]),isInMergeQueue:S(),autoMergeEnabled:S(),event:T({kind:M([`queue_removal`,`auto_merge_disabled`]),createdAt:N({offset:!0}),reason:_().max(256).optional(),reasonCode:_().max(256).optional()}).strict().optional()}).strict(),Fi=T({outcome:ji,headSha:ki,observedHeadSha:ki.optional(),mergeable:M([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]).optional(),mergeStateStatus:_().max(64).optional(),mergedAt:N({offset:!0}).optional(),mergeCommitSha:ki.optional(),mergeBlock:Pi.optional(),observedAt:N(),checks:j(T({name:_().max(256),state:_().max(256),link:_().max(2048)}).strict()).max(100),totalChecks:x().int().nonnegative(),truncated:S(),diagnostic:_().max(4096).refine(e=>Ni(e)<=4096).optional()}).strict().refine(e=>e.outcome===`blocked`==(e.mergeBlock!==void 0),`Only blocked outcomes require mergeBlock`).refine(e=>Ni(JSON.stringify(e))<=32*1024,`CI result exceeds 32 KiB`),Ii=Ai.extend({id:b(),generation:_().min(1).max(256),turnId:_().min(1).max(256),timeoutSeconds:x().int().min(1).max(7200),until:Di.default(`checks`),wakeOnConflict:S().default(!0),callerHead:w(!0).optional(),registeredAt:N(),deadline:N(),phase:M([`registered`,`parked`,`wake-pending`,`delivered`,`withdrawn`]),result:Fi.optional(),wakeId:_().min(1).max(256).optional(),deliveredAt:N().optional()}).strict();Ai.extend({waitId:b(),registeredAt:N(),deadline:N(),phase:Ii.shape.phase}).strict();function Li(e){return e.status===`waiting`&&e.autoResumeAt!==void 0}var Ri=7200,zi=1800,Bi=7200,Vi=4096,Hi=7200,Ui=4096;function Wi(e){let t=e?.role===`root`&&`conversation`in e?e.conversation:void 0,n=Array.isArray(t?.messages)?t.messages:[];return new Set(n.flatMap(e=>{let t=e&&typeof e==`object`?e:void 0;return t?.relationship===`peer`&&t.kind===`request`&&typeof t.id==`string`?[t.id]:[]}))}function Gi(e,t){let n=Wi(e);return!!t?.some(e=>n.has(e))}function Ki(e){if(e.requestIds){let t=new Set(e.requestOutcomes?.map(e=>e.requestId));return e.requestIds.map(e=>({key:`request:${e}`,settled:t.has(e)}))}let t=new Set(e.outcomes?.map(e=>e.workerId));return(e.workerIds??[]).map(e=>({key:`worker:${e}`,settled:t.has(e)}))}function qi(e){let t=e.filter(e=>e.kind===`worker`);if(t.length)return new Set(t.flatMap(e=>Ki(e).filter(e=>!e.settled).map(e=>e.key))).size}function Ji(e){let t;for(let n of e)(!t||Date.parse(n.deadline)<Date.parse(t.deadline))&&(t=n);return t}function Yi(e){let t=(Array.isArray(e.waits)?e.waits:[]).filter(e=>e?.phase===`open`),n=t.filter(e=>e.kind===`human`);if(n.length)return n.some(e=>e.askSeq!==void 0)?{kind:`human`,shown:!0}:{kind:`human`};if(Li(e))return{kind:`usage-limit`,at:e.autoResumeAt};let r=qi(t);if(r!==void 0){let n=t.filter(e=>e.kind===`worker`),i=n.every(e=>e.requestIds!==void 0),a=i&&n.some(t=>Gi(e.delegation,t.requestIds));return{kind:`workers`,count:r,...i?{replies:!0}:{},...a?{peers:!0}:{}}}let i=t.filter(e=>e.kind===`peer`);if(i.length)return{kind:`peers`,count:new Set(i.flatMap(e=>e.peerIds)).size};let a=t.filter(e=>e.kind===`subagent`);if(a.length)return{kind:`subagents`,count:new Set(a.flatMap(e=>e.children.filter(e=>e.status===`running`).map(e=>e.id))).size};let o=Ji(t.filter(e=>e.kind===`pr`));if(o)return{kind:`pr`,until:o.until,waitId:o.id,prUrl:o.prUrl,repository:o.repository,prNumber:o.prNumber,deadline:o.deadline};let s=Ji(t.filter(e=>e.kind===`process`));if(s)return{kind:`process`,waitId:s.id,pid:s.pid,deadline:s.deadline,...s.note===void 0?{}:{note:s.note}};let c=Ji(t.filter(e=>e.kind===`timer`));if(c)return{kind:`timer`,waitId:c.id,at:c.deadline,...c.note===void 0?{}:{note:c.note}}}function Xi(e){return Array.isArray(e.waits)&&e.waits.some(e=>e?.kind===`human`&&e.phase===`open`)}function Zi(e){return Array.isArray(e.waits)&&e.waits.some(e=>e?.kind===`human`&&e.phase===`open`&&(e.source===`agent`||!!e.questions?.length))}function Qi(e){return e.waitWakePending?!0:Array.isArray(e.waits)&&e.waits.some(e=>e?.phase===`resolved`)}function $i(e){return e.waitingOn??Yi(e)}var ea=512,ta=x().int().min(2),na=M([`open`,`resolved`,`delivered`,`cancelled`]),ra=M([`cezar_wait`,`cezar_wait_for_ci`,`cezar_ask`,`monitoring-line`,`schedule-wakeup`,`ask-line`,`native-ask`,`no-wait`,`budget`,`cez-worker-wait`,`completion`,`cez-message-wait`,`native-subagents`]),W={id:b(),source:M([`agent`,`cezar`]),via:ra,registeredAt:N(),phase:na,resolvedAt:N().optional(),deliveredAt:N().optional(),cancelledAt:N().optional(),turnId:_().min(1).max(256)},ia=T({...W,kind:w(`pr`),deadline:N(),...Ai.shape,generation:_().min(1).max(256),timeoutSeconds:x().int().min(1).max(7200),until:Di,wakeOnConflict:S(),callerHead:w(!0).optional(),result:Fi.optional()}).strict(),aa=T({...W,kind:w(`timer`),deadline:N(),seconds:x().int().min(60).max(Ri),note:_().max(ea).optional()}).strict(),oa=T({outcome:M([`exit_file`,`exited`,`deadline`,`error`]),observedAt:N(),exitCode:x().int().min(-2147483648).max(2147483647).optional(),exitFileNote:w(`not-an-exit-code`).optional(),diagnostic:_().max(512).optional()}).strict(),sa=T({...W,kind:w(`process`),deadline:N(),timeoutSeconds:x().int().min(1).max(Bi),pid:ta,startToken:_().min(1).max(256).optional(),exitFile:_().min(1).max(Vi).optional(),note:_().max(ea).optional(),result:oa.optional()}).strict(),ca=T({...W,kind:w(`human`),questions:p.shape.questions.optional(),context:m.optional(),askSeq:x().int().nonnegative().optional()}).strict(),la=T({...W,kind:w(`worker`),deadline:N().optional(),timeoutSeconds:x().int().min(1).max(Hi).optional(),mode:E.optional(),workerIds:B.optional(),revisions:j(T({workerId:b(),revision:x().int().nonnegative()}).strict()).max(32).optional(),outcomes:j(ue).max(32).optional(),requestIds:B.optional(),requestOutcomes:j(D).max(32).optional(),result:T({reason:M([`outcome`,`timeout`])}).strict().optional(),wakeInputId:b().optional()}).strict().superRefine((e,t)=>{let n=e.deadline!==void 0,r=e.timeoutSeconds!==void 0;e.source===`agent`?(n||t.addIssue({code:`custom`,message:`an agent worker wait requires a deadline`,path:[`deadline`]}),r||t.addIssue({code:`custom`,message:`an agent worker wait requires timeoutSeconds`,path:[`timeoutSeconds`]})):n!==r&&t.addIssue({code:`custom`,message:`a cezar worker wait takes deadline and timeoutSeconds together or neither`,path:[n?`timeoutSeconds`:`deadline`]});let i=e.workerIds!==void 0;if(i===(e.requestIds!==void 0)){t.addIssue({code:`custom`,message:`a worker wait names workerIds or requestIds, exactly one`,path:[i?`requestIds`:`workerIds`]});return}e.mode===`one`&&(e.workerIds??e.requestIds)?.length!==1&&t.addIssue({code:`custom`,message:`one mode requires exactly one id`,path:[`mode`]});let a=i?[`revisions`,`outcomes`]:[`requestOutcomes`],o=i?[`requestOutcomes`]:[`revisions`,`outcomes`];for(let n of a)e[n]===void 0&&t.addIssue({code:`custom`,message:`${n} is required with ${i?`workerIds`:`requestIds`}`,path:[n]});for(let n of o)e[n]!==void 0&&t.addIssue({code:`custom`,message:`${n} does not go with ${i?`workerIds`:`requestIds`}`,path:[n]})}),ua=e=>e.deadline!==void 0,da=T({...W,kind:w(`peer`),deadline:N(),timeoutSeconds:x().int().min(1).max(Hi),peerIds:B,result:zr.optional()}).strict().superRefine(Br),fa=T({id:_().min(1).max(256),status:M([`running`,`completed`,`failed`,`cancelled`])}).strict(),pa=T({reason:M([`settled`,`timeout`,`interrupted`,`superseded`])}).strict(),ma=C(`kind`,[ia,aa,ca,la,sa,da,T({...W,kind:w(`subagent`),source:w(`cezar`),via:w(`native-subagents`),deadline:N(),children:j(fa).min(1).max(32),result:pa.optional()}).strict()]),ha=(e,t,n)=>{t===`one`&&e.length!==1&&n.addIssue({code:`custom`,message:`one mode requires exactly one id`,path:[`mode`]})},ga=x().int().min(1).max(Hi).default(600),_a={operation_id:b().optional()};C(`kind`,[Oi.extend({kind:w(`pr`),..._a}).strict(),T({kind:w(`worker`),..._a,worker_ids:B,mode:E.optional(),timeout_seconds:ga}).strict().superRefine((e,t)=>ha(e.worker_ids,e.mode,t)),T({kind:w(`request`),..._a,request_ids:B,mode:E.optional(),timeout_seconds:ga}).strict().superRefine((e,t)=>ha(e.request_ids,e.mode,t)),T({kind:w(`peer`),..._a,peer_ids:B,timeout_seconds:ga}).strict(),T({kind:w(`timer`),..._a,seconds:x().int().min(60).max(Ri),note:_().max(ea).optional()}).strict(),T({kind:w(`process`),..._a,pid:ta,exit_file:_().min(1).max(Vi).optional(),timeout_seconds:x().int().min(1).max(Bi).default(zi),note:_().max(ea).optional()}).strict()]),T({wait_id:b()}).strict();var va={wait_id:b(),summary:_().max(256)},G=C(`kind`,[T({...va,kind:M([`pr`,`timer`,`worker`,`process`,`peer`,`subagent`]),deadline:N()}).strict(),T({...va,kind:w(`human`)}).strict()]),ya=M([...Mi.options,`timers_disabled`,`wake_budget_spent`,`denied_scope`,`exit_file_outside`,`process_not_allowed`,`process_not_owned`,`duplicate_deadline`,`operation_conflict`,`outcome_unknown`,`messaging_off`]),ba=_().max(Ui),xa=T({operationId:b(),requestHash:_().regex(/^[0-9a-f]{64}$/),wait:ma,deduplicated:S()}).strict(),Sa={operation_id:b().optional()};C(`ok`,[T({ok:w(!0),...Sa,effect:M([`applied`,`unchanged`]).optional(),deduplicated:S().optional(),replayed:S().optional(),wait_phase:M([...na.options,`unavailable`]).optional(),wait_id:b(),kind:M([`pr`,`timer`,`worker`,`request`,`process`,`peer`]),deadline:N(),open_waits:j(G).max(16)}).strict(),T({ok:w(!1),...Sa,effect:M([`refused`,`unknown`]).optional(),retained_wait:G.optional(),code:ya,message:ba,open_waits:j(G).max(16).optional()}).strict()]),p.extend({context:m});var Ca=M([`invalid_request`,`capacity`,`persistence`,`unavailable`,`unauthorized`,`autonomous_run`,`manager_disposed`,`capability_revoked`,`run_missing`,`run_not_running`,`run_stopping`,`session_replaced`,`session_closed`,`run_cancelled`,`finish_requested`,`generation_mismatch`,`worker_wait_pending`,`worker_execution_stopped`,`root_finish_pending`,`supervisor_is_worker`]);C(`ok`,[T({ok:w(!0),wait_id:b(),open_waits:j(G).max(16)}).strict(),T({ok:w(!1),code:Ca,message:ba,open_waits:j(G).max(16).optional()}).strict()]),C(`cancelled`,[T({cancelled:w(!0),wait_id:b(),open_waits:j(G).max(16)}).strict(),T({cancelled:w(!1),code:M([`not_found`,`already_resolved`,`human_question`,`invalid_request`,`unavailable`]),message:ba,open_waits:j(G).max(16).optional()}).strict()]),T({summary:_().max(2e3).optional()}).strict();var wa=M([`workers_outstanding`,`workers_uncollected`,`worker_questions`,`requests_outstanding`,`requests_unanswered`,`human_question_pending`,`worker_wait_pending`,`root_finish_pending`,`not_final_step`,`manager_disposed`,`capability_revoked`,`run_missing`,`run_not_running`,`run_stopping`,`session_replaced`,`session_closed`,`run_cancelled`,`finish_requested`,`generation_mismatch`,`invalid_request`,`unavailable`,`input_pending`]),Ta=C(`kind`,[T({kind:w(`wait_result`),wait_id:_(),wait_kind:_()}).strict(),T({kind:w(`queued`),input_id:_().optional(),source:_()}).strict(),T({kind:w(`in_flight`),input_id:_()}).strict(),T({kind:w(`unread`),input_id:_()}).strict()]),Ea={ok:w(!0),finishes:w(`at_turn_end`),open_waits:j(G).max(16)};C(`ok`,[C(`completes`,[T({...Ea,completes:w(`task`)}).strict(),T({...Ea,completes:w(`step`),next_step:_().min(1)}).strict()]),T({ok:w(!1),code:wa,message:ba,workers:j(T({worker_id:_(),reason:M([`outstanding`,`uncollected`,`question`])}).strict()).max(64).optional(),open_waits:j(G).max(16).optional(),owed:j(Ta).max(64).optional()}).strict()]);var Da=fe(e=>e&&typeof e==`object`&&e.kind===`ci`?{...e,kind:`pr`,until:`checks`}:e,C(`kind`,[T({kind:w(`human`),shown:w(!0).optional()}),T({kind:w(`usage-limit`),at:_()}),T({kind:w(`workers`),count:x().int().nonnegative(),replies:w(!0).optional(),peers:w(!0).optional()}),T({kind:w(`peers`),count:x().int().nonnegative()}),T({kind:w(`subagents`),count:x().int().nonnegative()}),T({kind:w(`pr`),until:Di,waitId:b(),prUrl:Ai.shape.prUrl,repository:Ai.shape.repository,prNumber:Ai.shape.prNumber,deadline:N()}),T({kind:w(`process`),waitId:b(),pid:ta,deadline:N(),note:_().max(ea).optional()}),T({kind:w(`timer`),waitId:b(),at:N(),note:_().max(ea).optional()})]));function Oa(e){let t=e.delegation;if(!t||t.role===`invalid`)return;let n=(e.waits??[]).filter(e=>e.kind===`worker`&&ua(e)&&(e.phase===`open`||e.phase===`resolved`)).at(-1);if(!n)return;let r=Ma(n);return n.phase===`open`&&e.status===`waiting`&&!Xi(e)?{...r,phase:`parked`}:r}function ka(e,t){return(e??[]).filter(e=>e.kind===`worker`&&e.via===`completion`&&!ua(e)&&(e.phase===`open`||e.phase===`resolved`)&&(t===void 0||!!e.workerIds?.includes(t))).at(-1)}function Aa(e,t){let n=e.phase===`cancelled`?`cancelled`:e.phase===`open`?void 0:e.result?.reason,r=e.phase===`open`&&t.status===`waiting`&&!Xi(t);return{id:e.id,via:`completion`,workerIds:e.workerIds??[],...e.mode===void 0?{}:{mode:e.mode},...e.revisions?.length?{revisions:e.revisions}:{},...n===void 0?{}:{reason:n},phase:r?`parked`:e.phase===`open`?`registered`:`wake-pending`,outcomes:e.outcomes??[],wakeId:e.wakeInputId??e.id}}function ja(e){if(!Dr(e.delegation))return;let t=ka(e.waits);return t?Aa(t,e):void 0}function Ma(e){let t=e.phase===`cancelled`?`cancelled`:e.phase===`open`?void 0:e.result?.reason;return{id:e.id,workerIds:e.workerIds??[],...e.requestIds===void 0?{}:{requestIds:e.requestIds},...e.requestOutcomes===void 0?{}:{requestOutcomes:e.requestOutcomes},deadline:e.deadline,...e.mode===void 0?{}:{mode:e.mode},...e.revisions?.length?{revisions:e.revisions}:{},...t===void 0?{}:{reason:t},phase:e.phase===`open`?`registered`:`wake-pending`,outcomes:e.outcomes??[],wakeId:e.wakeInputId??e.id}}var Na=T({autosave:j(T({at:_(),note:_(),periodic:T({branch:_().nullable(),count:x().int().positive(),first:_().nullable(),latest:_().nullable()}).optional()}))});function Pa(e,t){let n=`\n${e}\n`;for(let e=n.indexOf(`\n${t}`);e>=0;e=n.indexOf(`\n${t}`,e+1)){let r=e+1+t.length;if(n[r]===`
|
|
2
|
+
`||n.startsWith(`\r
|
|
3
|
+
`,r))return e}return-1}function Fa(e,t){let n=e.indexOf(`
|
|
4
|
+
`,t);return n<0?e.length:n+1}var Ia={archiveWhenDone:S().optional(),autoMergePr:S().optional()},La={allowWorkers:S().optional(),allowMessaging:S().optional()},Ra=e=>e.allowWorkers!==!1,za=e=>e.allowMessaging!==!1,Ba=T({owner:_().min(1),repo:_().min(1),number:x().int().positive()}).extend({mergedAt:_().datetime()}),Va=T({reason:w(`pull-requests-merged`),archivedAt:_().datetime(),fingerprint:_(),pullRequests:j(Ba)}),Ha=T({id:_().uuid(),phase:M([`pending`,`blocked`,`complete`]),message:_().optional()}),K=x().finite().nonnegative(),Ua=T({id:_(),name:_(),kind:An,status:kn,iterations:x(),retriesUsed:x().int().nonnegative().optional(),tokensUsed:x(),inputTokens:K.optional(),outputTokens:K.optional(),usageInvocationsStarted:K.optional(),usageInvocationsObserved:K.optional(),usageTurnsStarted:K.optional(),usageTurnsRecorded:K.optional(),usageInvocationEpoch:K.optional(),startedAt:_().optional(),finishedAt:_().optional(),error:_().optional(),sessionId:_().optional(),backend:L.optional(),removedBackend:_().optional(),profileId:_().optional(),skillPath:_().min(1).optional(),costUsd:x().optional(),synthetic:w(`continuation`).optional(),continuesStepId:_().optional()}),Wa=T({adds:x(),dels:x(),files:x(),repointed:S().optional()}),Ga=T({cpuPct:x(),rssBytes:x(),procCount:x()}),Ka=T({lastDeliveredAt:_().optional(),lastError:_().max(1024).optional(),lastErrorWebhookId:_().optional()}),qa=T({status:M([`running`,`done`,`failed`]),startedAt:_(),finishedAt:_().optional(),durationMs:x().optional(),error:_().optional()}),Ja=T({number:x().int().positive().lt(1e7),url:_().regex(/^https?:\/\/github\.com\/[a-z0-9_.-]+\/[a-z0-9_.-]+\/pull\/\d+\/?(?:[?#][^\s]*)?$/i).optional(),source:M([`declared`,`created`])}).refine(e=>e.url===void 0||Number(/\/pull\/(\d+)/i.exec(e.url)?.[1])===e.number,{message:`PR URL and number must agree`}),Ya=T({stepId:_(),mode:M([`resume`,`start`])}),Xa=T({session:_(),at:_(),seq:x().int().nonnegative(),openWaits:j(_()).max(32),settledWaits:j(_()).max(32),lastInput:_().optional(),summary:_().optional(),freeTurn:w(!0).optional()}),q=T({id:_(),title:_(),titleSummary:_().optional(),diffStat:Wa.optional(),workflow:_(),task:_(),queuedMessages:j(bi).optional(),stopping:S().optional(),continuationMessage:xi.optional(),workflowCursor:Ya.optional(),doneAccepted:Xa.optional(),invalidAsk:S().optional(),delegation:Er.optional(),agentInputs:j(f).optional(),waits:j(ma).optional(),waitRegistrations:j(xa).optional(),lastWaits:j(ma).optional(),lastWaitsError:_().max(256).optional(),automaticWakes:x().int().nonnegative().optional(),waitDeliveryFailures:x().int().nonnegative().optional(),previewServers:j(H).optional(),taskImages:j(_()).optional(),model:_().optional(),effort:_().max(32).optional(),modelIdentity:_().optional(),runner:L.optional(),removedRunner:_().optional(),agentProfile:_().optional(),systemPrompt:_().optional(),generateFollowups:S().optional(),autonomous:S().optional(),...Ia,...La,completionAction:Ha.optional(),archiveBlocker:T({message:_(),runId:_().optional(),pullRequestUrl:_().optional()}).optional(),automation:T({automationId:_(),automationRevision:x(),receiptId:_(),event:_(),githubUrl:_()}).optional(),automationTrigger:T({automationId:_(),automationRevision:x(),receiptId:_(),trigger:M([`schedule`,`catch-up`,`manual`]),occurrenceAt:_()}).optional(),destroyRetry:cr.optional(),notify:S().optional(),webhook:Ka.optional(),status:On,hasPendingPermission:S().optional(),autoResumeAt:_().optional(),autoResumeAttempts:x().optional(),autoResumeReason:M([`usage-limit`,`provider-error`]).optional(),parkReason:M([`turn`,`hold`,`closing-wakes`]).optional(),createdAt:_(),startedAt:_().optional(),finishedAt:_().optional(),tokensUsed:x(),inputTokens:K.optional(),outputTokens:K.optional(),costUsd:x().optional(),pullRequestUrl:_().optional(),pullRequests:j(Ja).optional(),referencedPullRequestUrl:_().optional(),prNumber:x().optional(),issueNumber:x().optional(),referencedIssueNumberSeeded:S().optional(),titleOrigin:M([`user`,`auto`,`marker`]).optional(),markerRefs:T({pr:x().optional(),issue:x().optional()}).optional(),referencedPrCandidates:j(_()).optional(),referencedIssueUrl:_().optional(),referencedIssueCandidates:j(_()).optional(),worktree:w(!1).optional(),worktreePath:_().optional(),branch:_().optional(),baseBranch:_().optional(),worktreeReclaimedAt:_().optional(),worktreeSetup:qa.optional(),groupId:_().optional(),variant:_().optional(),clientRequestId:_().optional(),clientRequestHash:_().optional(),peakRssBytes:x().optional(),peakProcCount:x().optional(),archived:S(),archivedAt:_().optional(),autoArchive:Va.optional(),manualUnarchivedAt:_().datetime().optional(),pinned:S().optional(),pinnedAt:_().optional(),seenAt:_().optional(),currentStepId:_().optional(),error:_().optional(),steps:j(Ua),workflowDef:Si.optional(),handoffRecords:Na.optional()});q.extend({finishBlocked:_().nullable().optional(),cliResumeCommand:_().optional(),cliHandoff:w(!1).optional(),usage:Ga.optional()});var Za=T({id:_(),title:_(),titleSummary:_().optional(),titleOrigin:M([`user`,`auto`,`marker`]).optional(),status:On,hasPendingPermission:q.shape.hasPendingPermission,waitingOn:Da.optional(),waitWakePending:w(!0).optional(),delegation:Or.optional(),createdAt:_(),finishedAt:_().optional(),seenAt:_().optional(),archived:S(),autoResumeAt:_().optional(),autoResumeReason:q.shape.autoResumeReason,workflow:_(),branch:_().optional(),startedAt:_().optional(),pullRequestUrl:_().optional(),pullRequests:j(Ja).optional(),referencedPullRequestUrl:_().optional(),prNumber:x().optional(),issueNumber:x().optional(),referencedIssueUrl:_().optional(),markerRefs:T({pr:x().optional(),issue:x().optional()}).optional(),costUsd:x().optional(),peakRssBytes:x().optional(),peakProcCount:x().optional(),usage:Ga.optional(),workflowLabel:_(),groupId:_().optional(),variant:_().optional(),pinned:S().optional(),automationId:_().optional(),runner:q.shape.runner,removedRunner:q.shape.removedRunner,model:_().optional(),notify:S().optional(),diffStat:Wa.optional(),tokensUsed:x(),inputTokens:q.shape.inputTokens,outputTokens:q.shape.outputTokens,currentStepId:_().optional(),currentStepBackend:L.optional(),error:_().optional(),worktreePath:_().optional()}),Qa=Za.extend({projectId:_()});function $a(e){return e.automationId!==void 0}var eo=d(_(),T({prs:d(x(),Jr),issues:d(x(),Jr)}));T({archived:M([`recent`,`all`]).optional()}),T({before:_().optional(),limit:ee().int().min(1).max(200).optional(),q:_().optional()});var to=T({runs:j(Za),nextCursor:_().nullable(),total:x().int().nonnegative()});T({q:_().trim().min(2),limit:ee().int().min(1).max(50).optional()});var no=T({runs:j(Qa),truncated:j(_())});T({cancelled:S()}),T({cancelled:w(!0)}),T({scope:M([`unpinned`,`pinned`]).optional(),automation:S().optional()}),T({archived:x(),ids:j(_()),pinnedIds:j(_())}),T({automation:S().optional()}),T({read:x()}),T({deleted:w(!0)}),T({finished:w(!0)}),T({continued:w(!0)}),T({url:_(),dryRun:S()}),O([T({delivered:w(!0)}),T({queued:w(!0),message:bi}),T({deferred:w(!0)})]),T({message:bi}),T({removed:w(!0)}),T({opened:w(!0),command:_()}),T({removed:w(!0)}),T({committed:w(!0),sha:_()}),T({pushed:w(!0),branch:_(),remote:_(),upstreamSet:S()}),T({commits:j(T({sha:_(),subject:_(),author:_(),when:_()}))}),T({id:_().min(1),file:_().regex(/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/).refine(e=>!e.includes(`..`))});var ro=T({mediaType:_().refine(gi,{message:`unsupported attachment type — images, plain text, markdown and PDF only`}),data:_().min(1).max(7e6)}),io=T({workflow:_().min(1).optional(),steps:j(U).min(1).max(8).optional(),task:_().min(1).max(1e5,`must be at most 100000 characters`),model:_().optional(),effort:_().max(32).optional(),runner:L.optional(),agentProfile:_().max(64).optional(),worktree:S().optional(),autonomous:S().optional(),...Ia,...La,systemPrompt:_().trim().max(2e4,`must be at most 20000 characters`).optional().transform(e=>e||void 0),images:j(ro).max(4).optional()});io.extend({steps:j(U.safeExtend({skillPath:_().min(1).optional()})).min(1).max(8).optional(),clientRequestId:_().uuid().optional(),notify:S().optional()}).refine(e=>!!e.workflow!=!!e.steps,{message:`provide either "workflow" or "steps", not both`}),T({text:_().max(1e5).default(``),images:j(ro).max(4).default([])}).refine(e=>e.text.trim().length>0||e.images.length>0,{message:`message needs text or at least one attachment`}),T({title:_().trim().min(1).max(300).optional(),task:_().trim().min(1).max(1e5).optional(),...Ia,...La}),T({pinned:S().optional()}),T({notify:S(),message:_().trim().max(1e5).optional().transform(e=>e||void 0)});var ao=`default`,oo=T({id:_(),provider:Wn,label:_(),configDir:_(),path:_(),exists:S(),looksValid:S(),isDefault:S(),status:Kn.optional()});function so(e){return e.isDefault?`default:${e.provider}`:e.id}var co=jn();T({editable:S(),profiles:j(oo),profileCapableProviders:j(Wn),selections:d(_(),co)}),T({projectId:_().min(1).max(64),provider:Wn,profileId:_().max(64).nullable()}),T({selections:d(_(),co)}),T({status:Kn}),T({provider:Wn,label:_().trim().max(200).optional(),configDir:_().trim().min(1).max(4096)}),T({profile:oo}),T({label:_().trim().max(200).optional(),configDir:_().trim().min(1).max(4096).optional()}),T({removed:w(!0),id:_()});var lo=/^[\w!#$%&'*.^`|~+-]+$/,uo=(e,t,n={})=>{if(!lo.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},fo=(e,t,n)=>(t=encodeURIComponent(t),uo(e,t,n)),po=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),mo=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??`);e=e.replace(t,r?`/${r}`:``)}return e},ho=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},go=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},_o=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function vo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yo(e,t){if(!vo(e)&&!vo(t))return t;let n={...e};for(let e in t){let r=t[e];vo(n[e])&&vo(r)?n[e]=yo(n[e],r):n[e]=r}return n}var bo=(e,t)=>new Proxy(()=>{},{get(n,r){if(!(typeof r!=`string`||r===`then`))return bo(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),xo=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(fo(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=_o(a),a=mo(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})}},So=(e,t)=>bo(function n(r){let i=t?.buildSearchParams??ho,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=po(e,a.join(`/`));if(s===`url`||s===`path`){let t=c;return r.args[0]&&(r.args[0].param&&(t=mo(c,r.args[0].param)),r.args[0].query&&(t=t+`?`+i(r.args[0].query).toString())),t=_o(t),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=go(r.args[0]&&r.args[0].param?mo(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 xo(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=yo(t,e);return l.fetch(r.args[0],a)}return l},[]);function Co(e={}){let{baseUrl:t=``,token:n,headers:r,fetch:i}=e;return So(t,{headers:{...n?{Authorization:`Bearer ${n}`}:{},...r},...i?{fetch:i}:{}})}var wo={permission:0,error:1,waiting:2,running:3,unseen:4,none:5},To=[`needs-permission`,`failed`,`needs-you`,`needs-review`,`running`,`usage-limit`,`waiting-on-workers`,`waiting-on-subagents`,`waiting-for-ci`,`waiting-for-merge`,`waiting-for-command`,`monitoring`,`waiting-for-capacity`,`queued`,`done`,`cancelled`,`unseen`];function Eo(e){return e.hasPendingPermission===!0&&(e.status===`waiting`||e.status===`running`)}function Do(e){return!1}function Oo(e,t,n=!1){if(t.requestIds?.length)return e===`worker`?`waiting on parent reply`:n?`waiting on replies`:`waiting on worker replies`;let r=new Set(t.outcomes?.map(e=>e.workerId)),i=t.workerIds?.filter(e=>!r.has(e)).length;return i?`waiting on ${i} worker${i===1?``:`s`}`:`waiting on workers`}var ko={"needs-permission":{bucket:`permission`,tone:`info`,shape:`filled`,pulse:!0,label:`needs permission`},failed:{bucket:`error`,tone:`danger`,shape:`filled`,pulse:!1,label:`failed`},"needs-you":{bucket:`waiting`,tone:`pending`,shape:`filled`,pulse:!0,label:`needs you`},"needs-review":{bucket:`waiting`,tone:`info`,shape:`filled`,pulse:!0,label:`needs review`},running:{bucket:`running`,tone:`running`,shape:`filled`,pulse:!0,label:`running`},"usage-limit":{bucket:`none`,tone:`neutral`,shape:`ring`,pulse:!1,label:`usage limit`},"waiting-on-workers":{bucket:`none`,tone:`running`,shape:`workers`,pulse:!1,label:`waiting on workers`},"waiting-on-subagents":{bucket:`none`,tone:`running`,shape:`workers`,pulse:!1,label:`waiting for subagents`},"waiting-for-ci":{bucket:`running`,tone:`running`,shape:`ring`,pulse:!0,label:`waiting for CI`},"waiting-for-merge":{bucket:`running`,tone:`running`,shape:`ring`,pulse:!0,label:`waiting for merge`},"waiting-for-command":{bucket:`running`,tone:`running`,shape:`ring`,pulse:!0,label:`waiting for a command`},monitoring:{bucket:`running`,tone:`running`,shape:`ring`,pulse:!0,label:`monitoring`},"waiting-for-capacity":{bucket:`none`,tone:`running`,shape:`ring`,pulse:!1,label:`waiting for capacity`},queued:{bucket:`none`,tone:`neutral`,shape:`ring`,pulse:!1,label:`queued`},done:{bucket:`none`,tone:`success`,shape:`filled`,pulse:!1,label:`done`},cancelled:{bucket:`none`,tone:`neutral`,shape:`filled`,pulse:!1,label:`cancelled`},unseen:{bucket:`unseen`,tone:`accent`,shape:`filled`,pulse:!1,label:`unseen`}},Ao={rung:`waiting-for-capacity`,...ko[`waiting-for-capacity`]};function J(e){return e===`waiting-for-capacity`?Ao:{rung:e,...ko[e]}}function jo(e){return Array.isArray(e.waits)&&e.waits.some(e=>e?.kind===`worker`&&e.phase===`resolved`)}function Mo(e,t){let n=J(`waiting-on-workers`),r=Dr(e.delegation)&&!t.replies&&!!t.count;if(e.delegation?.role===`worker`&&!r)return{...n,shape:`ring`,label:`waiting on parent reply`};if(t.replies)return{...n,label:t.peers?`waiting on replies`:`waiting on worker replies`};let i=t.count;return{...n,label:i?`waiting on ${i} worker${i===1?``:`s`}`:n.label}}function No(e){let t=$i(e);return t?.kind===`workers`?Mo(e,t).label:void 0}function Po(e){let t=e.count;return{...J(`waiting-on-workers`),shape:`ring`,label:t?`waiting on ${t} task${t===1?``:`s`}`:`waiting on tasks`}}function Fo(e){let t=e.count,n=J(`waiting-on-subagents`);return{...n,label:t?`waiting for ${t} subagent${t===1?``:`s`}`:n.label}}function Io(e,t){if(!(e.status!==`waiting`&&e.status!==`queued`)){if(t?.kind===`usage-limit`)return`usage-limit`;if(e.delegation?.role!==`invalid`&&jo(e))return`waiting-for-capacity`;if(e.status===`waiting`){switch(t?.kind){case`workers`:case`peers`:return`waiting-on-workers`;case`subagents`:return`waiting-on-subagents`;case`pr`:return t.until===`checks`?`waiting-for-ci`:`waiting-for-merge`;case`process`:return`waiting-for-command`;case`timer`:return`monitoring`}return t===void 0&&Qi(e)?`waiting-for-capacity`:`needs-you`}}}var Lo=[(e,t)=>t?.kind===`human`&&(t.shown||e.status===`waiting`)?`needs-you`:void 0,e=>e.status===`review`?`needs-review`:void 0,e=>e.status===`running`?`running`:void 0,Io,e=>Do(e)?`unseen`:void 0,e=>e.status===`queued`?`queued`:void 0,e=>e.status===`done`?`done`:void 0];function Ro(e,t){for(let n of Lo){let r=n(e,t);if(r!==void 0)return r}return`cancelled`}function zo(e){if(Eo(e))return J(`needs-permission`);if(e.status===`failed`)return J(`failed`);let t=e.status===`waiting`||e.status===`queued`||e.status===`running`?$i(e):void 0,n=Ro(e,t);return n===`waiting-on-workers`&&t?.kind===`workers`?Mo(e,t):n===`waiting-on-workers`&&t?.kind===`peers`?Po(t):n===`waiting-on-subagents`&&t?.kind===`subagents`?Fo(t):J(n)}var Bo=new Set([`waiting`,`permission`]);function Vo(e){return Bo.has(ko[e].bucket)}function Ho(e){return e.archived!==!0&&Vo(zo(e).rung)}var Uo=[`needs-you`,`failed`,`done`,`cancelled`,`running`,`waiting-workers`,`waiting-ci`,`waiting-timer`,`waiting-other`],Wo=[`needs-you`,`failed`,`done`,`cancelled`],Go=2048,Ko=1024,qo=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/,Jo=/^[a-z0-9][a-z0-9-]{0,63}$/,Yo=1e3,Xo=/^[A-Za-z0-9_-]{1,64}$/,Zo=64*1024,Qo=M(Uo),$o=T({id:_(),name:_(),description:_().optional(),url:_(),tokenSet:S(),tasks:S(),triggers:j(Qo).optional(),agent:S()}),es=T({id:_(),name:_(),root:_(),addedAt:_(),lastOpenedAt:_(),source:M([`local`,`checkout`]),status:M([`ok`,`missing`,`not-git`]),branch:_().optional(),forge:w(`github`).optional(),repoUrl:_().optional(),maxParallel:x().optional(),tags:j(_()).optional(),webhook:T({url:_(),tokenSet:S(),triggers:j(Qo).optional()}).optional(),webhooks:j($o).optional()});T({projects:j(es),bootProject:_(),projectsDir:_()});var ts=T({project:es,error:_().optional()});T({removed:w(!0),id:_()}),T({project:es});var ns=_().trim().max(Go).pipe(g({protocol:/^https?$/,error:`webhook url must be an http(s) URL`})).refine(e=>!/^https?:\/\/[^/?#]*@/i.test(e),`webhook url must not contain credentials; put the secret in the token`),rs=T({url:ns,token:_().trim().max(Ko).optional(),triggers:j(Qo).refine(e=>new Set(e).size===e.length,`webhook triggers must not repeat`).optional()}),is=j(Qo).refine(e=>new Set(e).size===e.length,`webhook triggers must not repeat`),as=_().trim().min(1,`webhook name is required`).max(80),os=_().trim().max(Yo),ss=_().trim().max(Ko);T({name:as,description:os.optional(),url:ns,token:ss.optional(),tasks:S().optional(),triggers:is.optional(),agent:S().optional()}),T({name:as.optional(),description:os.optional(),url:ns.optional(),token:ss.optional(),tasks:S().optional(),triggers:is.optional(),agent:S().optional()}).refine(e=>Object.values(e).some(e=>e!==void 0),`specify at least one webhook field`),T({projectId:_(),webhookId:_().regex(Xo,`unknown webhook`)}),T({project:es,webhook:$o});var cs=T({id:_(),name:_(),description:_().optional()});T({webhooks:j(cs)}),T({projectId:_(),webhook:_().min(1).max(80)}),T({runId:_().min(1).max(128).optional(),title:_().trim().min(1).max(200).optional(),message:_().trim().min(1,`message is required`).max(Zo),data:d(_(),k()).optional()}),T({ok:S(),webhook:cs.pick({id:!0,name:!0}),deliveryId:_(),attempts:x(),status:x().optional(),error:_().optional(),dryRun:S().optional()}),T({ok:S(),status:x().optional(),error:_().optional(),dryRun:S().optional()}),T({maxParallel:x().int().min(1).max(16).nullable().optional(),tags:j(_().trim().min(1).max(32)).max(20).nullable().optional(),webhook:rs.nullable().optional()}).refine(e=>e.maxParallel!==void 0||e.tags!==void 0||e.webhook!==void 0,`specify maxParallel, tags or webhook`),T({url:_().trim().min(1).max(512),name:_().trim().max(128).optional(),checkoutId:_().trim().max(128).optional()}),T({name:_().trim().regex(qo),github:T({owner:_().trim().min(1).max(64),template:_().trim().max(512).optional()}).optional(),checkoutId:_().trim().max(128).optional()}),ts.extend({warning:_().optional()});var ls=T({login:_(),personal:S(),avatarUrl:_().optional(),description:_().optional()}),us=C(`available`,[T({available:w(!0),owners:j(ls)}),T({available:w(!1),reason:_()})]),ds=T({name:_(),path:_(),isRepo:S()});T({path:_(),parent:_().nullable(),dirs:j(ds),truncated:S()}),T({checkoutId:_().min(1).max(128)}),T({progress:ae.nullable()}),T({root:_().trim().min(1).max(4096)});var fs=T({status:_(),path:_()}),ps=T({runId:_(),title:_(),prNumber:x().nullable()}),ms=T({hash:_(),subject:_(),author:_(),when:_(),at:_(),source:ps.optional()}),hs=T({ref:_(),ahead:x(),behind:x(),fetchedAt:_().nullable()});O([T({info:u(),status:j(v()),log:j(v()),branches:j(v()),baseBranch:u(),tracking:u()}),T({info:kt,status:j(fs),log:j(ms),branches:j(_()),baseBranch:_().nullable(),tracking:hs.nullable()})]),T({branch:_(),created:S()});var gs=M([`active`,`not-landed`,`orphan`,`merged`,`empty`,`other`]),_s=M([`open`,`draft`,`merged`,`closed`]),vs=T({name:_(),class:gs,runId:_().nullable(),title:_().nullable(),runStatus:On.nullable(),ahead:x(),lastCommit:T({sha:_(),subject:_(),at:_()}),diffStat:T({additions:x(),deletions:x()}).nullable(),pr:T({number:x(),url:_(),state:_s}).nullable(),keptReason:_().optional(),parentRunId:_().optional()});T({base:_(),prStateKnown:S(),branches:j(vs),counts:T({notLanded:x(),cleanup:x()})}).pick({base:!0,prStateKnown:!0,counts:!0}).extend({allBranches:x()}),T({names:j(_().trim().min(1).max(250)).min(1).max(500),confirm:_().optional()});var ys=T({name:_(),reason:_()});T({deleted:j(_()),refused:j(ys),dropped:j(T({sha:_(),subject:_()})).optional()}),T({error:_(),refused:j(ys)}),T({branches:j(_())}),T({branch:_().trim().min(1).max(200).optional(),confirm:S().optional()});var bs=T({branch:_(),pulled:w(!0),summary:_()}),xs=T({error:_(),branch:_(),risks:j(M([`active_runs`,`dirty_tree`]))});O([xs,T({error:_()})]);var Ss=T({adds:x(),dels:x(),files:x()}),Cs=T({path:_(),oldPath:_().optional(),status:M([`added`,`modified`,`deleted`,`renamed`,`copied`]),adds:x(),dels:x(),binary:S(),image:S().optional(),patch:_()});T({files:j(Cs),stat:Ss,repointedHead:T({headBranch:_(),taskBranch:_()}).optional()}),T({sha:_(),subject:_(),author:_(),when:_(),files:j(Cs),stat:Ss});var ws=T({name:_(),type:M([`dir`,`file`]),size:x().optional()});C(`type`,[T({type:w(`dir`),path:_(),entries:j(ws)}),T({type:w(`file`),path:_(),size:x(),binary:S(),tooLarge:S(),content:_().optional()})]),T({worktrees:j(T({runId:_(),title:_(),status:On,branch:_().nullable(),sizeBytes:x().nullable(),finishedAt:_().nullable(),reclaimable:S(),pastKeep:S()})),totalBytes:x().nullable(),keep:x()}),T({runId:_(),worktreeReclaimedAt:_()}),T({reclaimed:j(_())});var Y=class extends Error{status;manual;command;exists;work;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,this.work=n.work}};function Ts(e){try{return JSON.parse(e)}catch{return}}function Es(e){return typeof e==`string`?e:void 0}function Ds(e,t,n){let r=Ts(n),i=r&&typeof r==`object`?r:{};return new Y(e,Es(i.error)??`${e} ${t||`request failed`}`.trim(),{manual:Es(i.manual),command:Es(i.command),exists:typeof i.exists==`boolean`?i.exists:void 0,work:Os(i.work)})}function Os(e){if(!e||typeof e!=`object`)return;let{uncommittedFiles:t,commits:n}=e;return typeof t==`number`&&typeof n==`number`?{uncommittedFiles:t,commits:n}:void 0}var X=Co({fetch:(e,t)=>Ns(ks(String(e)),t)});function ks(e){let t=js(e.endsWith(`?`)?e.slice(0,-1):e);return t.startsWith(`/`)?`${r()}${t}`:t}var As=`${o}/p/default`;function js(e){if(c()!==null||!e.startsWith(As))return e;let t=e.slice(As.length);return t===``||t.startsWith(`/`)||t.startsWith(`?`)?`${o}${t}`:e}var Z=e=>({init:{...s({signal:e?.signal})}});async function Q(e,t){let n=await e.text();if(!e.ok)throw Ds(e.status,e.statusText,n);let r=Ts(n);if(r===void 0)throw new Y(e.status,`the Squawk server answered ${t} with a non-JSON body`);return r}async function Ms(e,t,n){let r=e.status,i=await Q(e,t),a=n.safeParse(i);if(!a.success)throw new Y(r,`the Squawk server answered ${t} with an unexpected body`);return a.data}async function Ns(e,t){try{let n=await fetch(e,{...t,credentials:`include`});return n.ok&&t?.method&&![`GET`,`HEAD`].includes(t.method.toUpperCase())&&rn(),n}catch(t){throw t instanceof DOMException&&t.name===`AbortError`?t:new Y(0,`cannot reach the Squawk server (${e})`,{cause:t})}}async function Ps(e,t){return Ns(l(e),t)}async function Fs(e,t={}){let n=new Headers(t.headers);n.set(`accept`,`text/plain`);let r=await Ps(e,{...t,headers:n}),i=await r.text();if(!r.ok)throw Ds(r.status,r.statusText,i);return i}var $=(e,t=``)=>`/runs/${encodeURIComponent(e)}${t}`;async function Is(e){return Q(await X.api.v1.health.$get({},Z(e)),`/health`)}async function Ls(e=!1,t){return bn(await Q(await X.api.v1.providers.status.$get({query:e?{refresh:`1`}:{}},Z(t)),`/providers/status`))}async function Rs(e){return Q(await X.api.v1.projects.$get({},Z(e)),`/projects`)}async function zs(e,t){return Q(await X.api.v1.fs.browse.$get({query:{path:e===``?void 0:e,...t?.showHidden?{showHidden:`1`}:{}}},Z(t)),`/fs/browse`)}async function Bs(e,t){return Q(await X.api.v1.p[`:projectId`][`run-summaries`].$get({param:{projectId:e.projectId},query:{archived:`recent`}},Z(t)),`/run-summaries`)}async function Vs(e,t){let n={...e.before===void 0?{}:{before:e.before},...e.limit===void 0?{}:{limit:e.limit},...e.q?{q:e.q}:{}};return Ms(await X.api.v1.p[`:projectId`][`run-summaries`].archived.$get({param:{projectId:a()},query:n},Z(t)),`/run-summaries/archived`,to)}async function Hs(e){return Q(await X.api.v1.workspace[`runs-index`].$get({},Z(e)),`/workspace/runs-index`)}async function Us(e,t){return Ms(await X.api.v1.workspace[`runs-search`].$get({query:{q:e}},Z(t)),`/workspace/runs-search`,no)}async function Ws(e,t){return Ms(await X.api.v1.p[`:projectId`].runs[`:id`].relationships.$get({param:{projectId:a(),id:encodeURIComponent(e)},query:{}},Z(t)),`${$(e)}/relationships`,Ir)}async function Gs({projectId:e,runId:t},n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].$get({param:{projectId:e,id:encodeURIComponent(t)}},Z(n)),$(t))}async function Ks(e,t,n){return Ms(await X.api.v1.p[`:projectId`].runs[`:id`].history.$get({param:{projectId:a(),id:encodeURIComponent(e)},query:{...t===void 0?{}:{cursor:t}}},Z(n)),`${$(e)}/history`,ne)}async function qs(e,t){return Ms(await X.api.v1.p[`:projectId`].runs[`:id`][`history-context`].$get({param:{projectId:a(),id:encodeURIComponent(e)}},Z(t)),`${$(e)}/history-context`,de)}async function Js(e,t=a()){return Q(await X.api.v1.p[`:projectId`][`ui-state`].$get({param:{projectId:t}},Z(e)),`/ui-state`)}async function Ys(e){return Q(await X.api.v1.p[`:projectId`].workflows.$get({param:{projectId:e?.projectId??a()}},Z(e)),`/workflows`)}async function Xs(e,t,n){return Q(await X.api.v1.p[`:projectId`][`runner-skills`].$get({param:{projectId:n?.projectId??a()},query:{runner:e,...t?{account:t}:{},...n?.refresh?{refresh:`1`}:{}}},Z(n)),`/runner-skills`)}async function Zs(e,t){return Q(await X.api.v1.p[`:projectId`].repo.$get({param:{projectId:t??a()}},Z(e)),`/repo`)}async function Qs(e,t){return Q(await X.api.v1.p[`:projectId`].repo.branches.$get({param:{projectId:t??a()}},Z(e)),`/repo/branches`)}async function $s(e){return Q(await X.api.v1.p[`:projectId`].repo.branches.delete.$post({param:{projectId:a()},json:e}),`/repo/branches/delete`)}async function ec(e,t){let n=await X.api.v1.p[`:projectId`].repo.pull.$post({param:{projectId:t??a()},json:e}),r=await n.text(),i=Ts(r);if(n.status===409){let e=xs.safeParse(i);if(e.success)return e.data;throw Ds(n.status,n.statusText,r)}if(!n.ok)throw Ds(n.status,n.statusText,r);if(i===void 0)throw new Y(n.status,`the Squawk server answered /repo/pull with a non-JSON body`);let o=bs.safeParse(i);if(!o.success)throw new Y(n.status,`the Squawk server answered /repo/pull with an unexpected body`);return o.data}async function tc(e){return Q(await X.api.v1.p[`:projectId`].config.$get({param:{projectId:a()}},Z(e)),`/config`)}async function nc(e={}){return Q(await X.api.v1.p[`:projectId`][`agent-config`].$get({param:{projectId:a()}},Z(e)),`/agent-config`)}async function rc(e,t={}){return Q(await X.api.v1.p[`:projectId`][`agent-config`][`:id`].$get({param:{projectId:a(),id:encodeURIComponent(e)}},Z(t)),`/agent-config/${encodeURIComponent(e)}`)}async function ic(e,t){return Q(await X.api.v1.p[`:projectId`][`agent-config`][`:id`].$put({param:{projectId:a(),id:encodeURIComponent(e)},json:t}),`/agent-config/${encodeURIComponent(e)}`)}async function ac(e){return Q(await X.api.v1.p[`:projectId`].repo.changes.$get({param:{projectId:a()}},Z(e)),`/repo/changes`)}async function oc(e,t){return Q(await X.api.v1.p[`:projectId`].repo.commit[`:sha`].$get({param:{projectId:t?.projectId??a(),sha:encodeURIComponent(e)},query:{structured:`1`}},Z(t)),`/repo/commit/:sha`)}async function sc(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].commits.$get({param:{projectId:a(),id:encodeURIComponent(e)}},Z(t)),$(e,`/commits`))}async function cc(e,t,n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].commit[`:sha`].$get({param:{projectId:n?.projectId??a(),id:encodeURIComponent(e),sha:encodeURIComponent(t)}},Z(n)),$(e,`/commit/${encodeURIComponent(t)}`))}async function lc(e={},t){return Q(await X.api.v1.p[`:projectId`].github.$get({param:{projectId:e.projectId??a()},query:{limit:e.limit===void 0?void 0:String(e.limit),refresh:e.refresh?`1`:void 0,issuesCursor:e.issuesCursor,prsCursor:e.prsCursor,issuesDone:e.issuesDone?`1`:void 0,prsDone:e.prsDone?`1`:void 0}},Z(t)),`/github`)}async function uc(e,t,n={},r){return Q(await X.api.v1.p[`:projectId`].github[`comment-counts`].$get({param:{projectId:a()},query:{kind:e,numbers:t.join(`,`),refresh:n.refresh?`1`:void 0}},Z(r)),`/github/comment-counts`)}async function dc(e,t){return Q(await X.api.v1.p[`:projectId`].github.projects.$get({param:{projectId:a()},query:{generation:e}},Z(t)),`/github/projects`)}async function fc(e,t){return Q(await X.api.v1.p[`:projectId`].github.checks.$get({param:{projectId:a()},query:{prs:e.join(`,`)}},Z(t)),`/github/checks`)}async function pc(e,t,n={},r){return Q(await X.api.v1.p[`:projectId`].github.search.$get({param:{projectId:n.projectId??a()},query:{kind:e,q:t,limit:n.limit}},Z(r)),`/github/search`)}async function mc(e,t,n){return Q(await X.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(`,`)}:{}}},Z(n)),`/github/ref-status`)}async function hc(e,t,n={},r){return Q(await X.api.v1.p[`:projectId`].github.comments[`:kind`][`:number`].$get({param:{projectId:a(),kind:e,number:String(t)},query:{refresh:n.refresh?`1`:void 0}},Z(r)),`/github/comments/${e}/${t}`)}async function gc(e,t,n={},r){return Q(await X.api.v1.p[`:projectId`].github.items[`:kind`][`:number`].$get({param:{projectId:r?.projectId??a(),kind:e,number:String(t)},query:{refresh:n.refresh?`1`:void 0}},Z(r)),`/github/items/${e}/${t}`)}async function _c(e,t={},n){return Q(await X.api.v1.p[`:projectId`].github.prs[`:number`][`merge-state`].$get({param:{projectId:a(),number:String(e)},query:{refresh:t.refresh?`1`:void 0}},Z(n)),`/github/prs/${e}/merge-state`)}async function vc(e,t){return Q(await X.api.v1.p[`:projectId`].github.prs[`:number`].merge.$post({param:{projectId:a(),number:String(e)},json:t}),`/github/prs/:number/merge`)}async function yc(e,t={},n){return Q(await X.api.v1.p[`:projectId`].github.prs[`:number`].changes.$get({param:{projectId:a(),number:String(e)},query:{refresh:t.refresh?`1`:void 0}},Z(n)),`/github/prs/${e}/changes`)}function bc(e,t){return Fs($(e,`/diff`),{method:`GET`,...s({signal:t?.signal})})}async function xc({projectId:e,runId:t},n){let r=await X.api.v1.p[`:projectId`].runs[`:id`].handoff.$get({param:{projectId:e,id:encodeURIComponent(t)}},{init:{...s({signal:n?.signal})},headers:{accept:`text/plain`}}),i=await r.text();if(!r.ok)throw Ds(r.status,r.statusText,i);return i}async function Sc(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].changes.$get({param:{projectId:a(),id:encodeURIComponent(e)}},Z(t)),$(e,`/changes`))}async function Cc(e,t,n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].files.$get({param:{projectId:a(),id:encodeURIComponent(e)},query:{path:t}},Z(n)),`/runs/:id/files`)}async function wc(e,t,n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`file-link`].$get({param:{projectId:a(),id:e},query:{path:t}},Z(n)),`/runs/:id/file-link`)}async function Tc(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].artifacts.$get({param:{projectId:a(),id:e}},Z(t)),`/runs/:id/artifacts`)}async function Ec(e,t,n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].artifacts[`:artifactId`].$get({param:{projectId:a(),id:e,artifactId:t}},Z(n)),`/runs/:id/artifacts/:artifactId`)}async function Dc(e,t,n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].artifacts[`:artifactId`].metadata.$get({param:{projectId:a(),id:e,artifactId:t}},Z(n)),`/runs/:id/artifacts/:artifactId/metadata`)}function Oc(e,t,n){return l($(e,`/artifacts/${encodeURIComponent(t)}/${n}`))}function kc(e,t){return l($(e,`/file-link?path=${encodeURIComponent(t)}&raw=1`))}function Ac(e,t){return l($(e,`/files?path=${encodeURIComponent(t)}&raw=1`))}async function jc(e,t){return Q(await X.api.v1.providers.connect.$post({json:{provider:e,...t?{profileId:t}:{}}}),`/providers/connect`)}async function Mc(e,t){return bn(await Q(await X.api.v1.providers[`:provider`].enabled.$put({param:{provider:e},json:{enabled:t}}),`/providers/${encodeURIComponent(e)}/enabled`))}async function Nc(e,t){return bn(await Q(await X.api.v1.providers[`:provider`].retry.$post({param:{provider:e},json:{authFailureId:t}}),`/providers/${encodeURIComponent(e)}/retry`))}async function Pc(e){let t=`/projects`,n=await Ps(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({root:e})}),r=await n.text(),i=Ts(r),a=i?.project;if((n.ok||n.status===409)&&a!=null)return i;throw n.ok?new Y(n.status,`the Squawk server answered ${t} without a project`):Ds(n.status,n.statusText,r)}async function Fc(e){return Q(await X.api.v1.projects.checkout.$post({json:e}),`/projects/checkout`)}async function Ic(e){return Q(await X.api.v1.projects.create.$post({json:e}),`/projects/create`)}async function Lc(e){return Ms(await X.api.v1.projects[`github-owners`].$get({},Z(e)),`/projects/github-owners`,us)}async function Rc(e){return Q(await X.api.v1.projects[`:projectId`].$delete({param:{projectId:encodeURIComponent(e)}}),`/projects/${encodeURIComponent(e)}`)}async function zc(e,t){return Q(await X.api.v1.projects[`:projectId`].$patch({param:{projectId:encodeURIComponent(e)},json:t}),`/projects/${encodeURIComponent(e)}`)}async function Bc(e,t){return Q(await X.api.v1.projects[`:projectId`].webhooks.$post({param:{projectId:encodeURIComponent(e)},json:t}),`/projects/${encodeURIComponent(e)}/webhooks`)}async function Vc(e,t,n){return Q(await X.api.v1.projects[`:projectId`].webhooks[`:webhookId`].$patch({param:{projectId:encodeURIComponent(e),webhookId:encodeURIComponent(t)},json:n}),`/projects/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}`)}async function Hc(e,t){return Q(await X.api.v1.projects[`:projectId`].webhooks[`:webhookId`].$delete({param:{projectId:encodeURIComponent(e),webhookId:encodeURIComponent(t)}}),`/projects/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}`)}async function Uc(e,t){return Q(await X.api.v1.projects[`:projectId`].webhooks[`:webhookId`].test.$post({param:{projectId:encodeURIComponent(e),webhookId:encodeURIComponent(t)}}),`/projects/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}/test`)}async function Wc(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].notify.$post({param:{projectId:a(),id:encodeURIComponent(e)},json:t}),$(e,`/notify`))}async function Gc(e){return Q(await X.api.v1.p[`:projectId`].runs.$post({param:{projectId:a()},json:e}),`/runs`)}async function Kc(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].cancel.$post({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e,`/cancel`))}async function qc({projectId:e,runId:t},n=!0){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].archive.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{archived:n}}),$(t,`/archive`))}async function Jc({projectId:e,runId:t},n=!0){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].pin.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{pinned:n}}),$(t,`/pin`))}async function Yc({projectId:e,runId:t},n){let r=n?`read`:`unread`;return Q(await(n?X.api.v1.p[`:projectId`].runs[`:id`].read.$post({param:{projectId:e,id:encodeURIComponent(t)}}):X.api.v1.p[`:projectId`].runs[`:id`].unread.$post({param:{projectId:e,id:encodeURIComponent(t)}})),$(t,`/${r}`))}async function Xc(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`auto-resume`].$delete({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e,`/auto-resume`))}async function Zc({projectId:e},t,n){return Q(await X.api.v1.p[`:projectId`].runs[`archive-finished`].$post({param:{projectId:e},json:{...t?{scope:t}:{},...n===void 0?{}:{automation:n}}}),`/runs/archive-finished`)}async function Qc(e){return Q(await X.api.v1.p[`:projectId`].runs[`read-all`].$post({param:{projectId:a()},json:e===void 0?{}:{automation:e}}),`/runs/read-all`)}async function $c(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].finish.$post({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e,`/finish`))}async function el({projectId:e,runId:t},n={}){let r={...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.effort===void 0?{}:{effort:n.effort},...n.agentProfile===void 0?{}:{agentProfile:n.agentProfile}};return Q(await X.api.v1.p[`:projectId`].runs[`:id`].continue.$post({param:{projectId:e,id:encodeURIComponent(t)},json:r}),$(t,`/continue`))}async function tl(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].pr.$post({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e,`/pr`))}async function nl(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].$patch({param:{projectId:a(),id:encodeURIComponent(e)},json:t}),$(e))}async function rl(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].$delete({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e))}async function il(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`open-in-cli`].$post({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e,`/open-in-cli`))}async function al(e){return Q(await X.api.v1.p[`:projectId`][`open-targets`].$get({param:{projectId:a()}},Z(e)),`/open-targets`)}async function ol(e,t=a()){return Q(await X.api.v1.p[`:projectId`][`open-in`].$post({param:{projectId:t},json:{target:e}}),`/open-in`)}async function sl(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`open-in`].$post({param:{projectId:a(),id:encodeURIComponent(e)},json:{target:t}}),$(e,`/open-in`))}async function cl(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`open-in`].$post({param:{projectId:a(),id:encodeURIComponent(e)},json:{target:`default`,path:t}}),$(e,`/open-in`))}async function ll(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].git.commit.$post({param:{projectId:a(),id:encodeURIComponent(e)},json:{message:t}}),$(e,`/git/commit`))}async function ul(e){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].git.push.$post({param:{projectId:a(),id:encodeURIComponent(e)}}),$(e,`/git/push`))}async function dl(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].permissions.$post({param:{projectId:a(),id:encodeURIComponent(e)},json:t}),$(e,`/permissions`))}async function fl({projectId:e,runId:t},n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`].messages.$post({param:{projectId:e,id:encodeURIComponent(t)},json:{text:n.text??``,images:n.images??[]}}),$(t,`/messages`))}async function pl(e,t,n){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`queued-messages`][`:msgId`].$patch({param:{projectId:a(),id:encodeURIComponent(e),msgId:encodeURIComponent(t)},json:n}),$(e,`/queued-messages/${encodeURIComponent(t)}`))}async function ml(e,t){return Q(await X.api.v1.p[`:projectId`].runs[`:id`][`queued-messages`][`:msgId`].$delete({param:{projectId:a(),id:encodeURIComponent(e),msgId:encodeURIComponent(t)}}),$(e,`/queued-messages/${encodeURIComponent(t)}`))}async function hl(e,t){return Q(await X.api.v1.p[`:projectId`].repo.branch.$post({param:{projectId:t??a()},json:e}),`/repo/branch`)}async function gl(e){return Q(await X.api.v1.p[`:projectId`].plan.$post({param:{projectId:a()},json:{task:e}}),`/plan`)}async function _l(e){return Q(await X.api.v1.p[`:projectId`].automations.$get({param:{projectId:e?.projectId??a()},query:e?.archived?{archived:e.archived}:{}},Z(e)),`/automations`)}async function vl(e){return Q(await X.api.v1.p[`:projectId`].automations.$post({param:{projectId:a()},json:e}),`/automations`)}async function yl(e,t){return Q(await X.api.v1.p[`:projectId`].automations[`:id`].$put({param:{projectId:a(),id:encodeURIComponent(e)},json:t}),`/automations/${encodeURIComponent(e)}`)}async function bl(e,t){let n={projectId:a(),id:encodeURIComponent(e)},r=`/automations/${encodeURIComponent(e)}/${t?`enable`:`pause`}`;return Q(t?await X.api.v1.p[`:projectId`].automations[`:id`].enable.$post({param:n}):await X.api.v1.p[`:projectId`].automations[`:id`].pause.$post({param:n}),r)}async function xl(e,t){return Q(await X.api.v1.p[`:projectId`].automations[`:id`].check.$post({param:{projectId:a(),id:encodeURIComponent(e)},json:{mode:t}}),`/automations/${encodeURIComponent(e)}/check`)}async function Sl(e){return Q(await X.api.v1.p[`:projectId`].automations[`:id`].cancel.$post({param:{projectId:a(),id:encodeURIComponent(e)}}),`/automations/${encodeURIComponent(e)}/cancel`)}async function Cl(e){let t=await X.api.v1.p[`:projectId`].automations[`:id`].$delete({param:{projectId:a(),id:encodeURIComponent(e)}});if(!t.ok)throw Ds(t.status,t.statusText,await t.text())}async function wl(e){return Q(await X.api.v1.p[`:projectId`].automations[`:id`].run.$post({param:{projectId:a(),id:encodeURIComponent(e)}}),`/automations/${encodeURIComponent(e)}/run`)}async function Tl(e){return Q(await X.api.v1.p[`:projectId`][`automation-log`][`:receiptId`].retry.$post({param:{projectId:a(),receiptId:encodeURIComponent(e)}}),`/automation-log/${encodeURIComponent(e)}/retry`)}async function El(e,t){return Q(await X.api.v1[`automation-checks`][`:checkId`].$get({param:{checkId:encodeURIComponent(e)}},Z(t)),`/automation-checks/${encodeURIComponent(e)}`)}async function Dl(e,t){return Q(await X.api.v1.p[`:projectId`][`automation-log`].$get({param:{projectId:a()},query:{automationId:e}},Z(t)),`/automation-log?automationId=${encodeURIComponent(e)}`)}async function Ol(e){return Q(await X.api.v1.p[`:projectId`].workflows.$post({param:{projectId:a()},json:e}),`/workflows`)}async function kl(e){return Q(await X.api.v1.p[`:projectId`].workflows.parse.$post({param:{projectId:a()},json:{yaml:e}}),`/workflows/parse`)}async function Al(e){return Q(await X.api.v1.p[`:projectId`].workflows[`:name`].$delete({param:{projectId:a(),name:encodeURIComponent(e)}}),`/workflows/${encodeURIComponent(e)}`)}async function jl(e,t=a()){return Q(await X.api.v1.p[`:projectId`][`ui-state`].$put({param:{projectId:t},json:e}),`/ui-state`)}async function Ml(e){return Q(await X.api.v1.workspace[`ui-state`].$get({},Z(e)),`/workspace/ui-state`)}async function Nl(e,t={}){return Q(await X.api.v1.workspace[`ui-state`].$put({json:e},{init:{...s({keepalive:t.keepalive})}}),`/workspace/ui-state`)}async function Pl(e){let t=await Q(await X.api.v1.workspace.config.$get({},Z(e)),`/workspace/config`);return{...t,agentDefaults:t.agentDefaults??{}}}async function Fl(e){let t=await Q(await X.api.v1.workspace[`agent-profiles`].$get({},Z(e)),`/workspace/agent-profiles`);return{...t,profileCapableProviders:t.profileCapableProviders??[],selections:t.selections??{},profiles:t.profiles??[]}}async function Il(e){return Q(await X.api.v1.workspace[`agent-profiles`].$post({json:e}),`/workspace/agent-profiles`)}async function Ll(e,t){return Q(await X.api.v1.workspace[`agent-profiles`][`:id`].status.$get({param:{id:encodeURIComponent(e)},query:t?.refresh?{refresh:`1`}:{}},Z(t)),`/workspace/agent-profiles/${encodeURIComponent(e)}/status`)}async function Rl(e){return Q(await X.api.v1.workspace[`agent-profiles`].selection.$put({json:e}),`/workspace/agent-profiles/selection`)}async function zl(e,t){return Q(await X.api.v1.workspace[`agent-profiles`][`:id`].$patch({param:{id:encodeURIComponent(e)},json:t}),`/workspace/agent-profiles/${encodeURIComponent(e)}`)}async function Bl(e){return Q(await X.api.v1.workspace[`agent-profiles`][`:id`].$delete({param:{id:encodeURIComponent(e)}}),`/workspace/agent-profiles/${encodeURIComponent(e)}`)}async function Vl(e){return Q(await X.api.v1.workspace.config.$put({json:e}),`/workspace/config`)}async function Hl(e,t){return Q(await X.api.v1.p[`:projectId`].config.$put({param:{projectId:t??a()},json:e}),`/config`)}async function Ul(e,t){return Q(await X.api.v1.p[`:projectId`].worktrees.$get({param:{projectId:t??a()}},Z(e)),`/worktrees`)}async function Wl(){return Q(await X.api.v1.p[`:projectId`].worktrees.reclaim.$post({param:{projectId:a()},json:{}}),`/worktrees/reclaim`)}async function Gl(e){return Q(await X.api.v1.p[`:projectId`].worktrees[`:runId`].reclaim.$post({param:{projectId:a(),runId:encodeURIComponent(e)}}),`/worktrees/${encodeURIComponent(e)}/reclaim`)}async function Kl(e,t){return Q(await X.api.v1.projects.checkout[`:checkoutId`].progress.$get({param:{checkoutId:e}},Z(t)),`/projects/checkout/progress`)}async function ql(e,t,n){return Q(await X.api.v1.models.$get({query:{runner:e,...n&&n!=="default"?{profileId:n}:{}}},Z(t)),`/models`)}var Jl={projectId:null,apiBase:o},Yl=(0,I.createContext)(Jl);function Xl(){return(0,I.useContext)(Yl)}function Zl({projectId:e,children:t}){c()!==e&&i(e),(0,I.useLayoutEffect)(()=>{i(e)},[e]),(0,I.useLayoutEffect)(()=>()=>i(null),[]);let n=(0,I.useMemo)(()=>e===null?Jl:{projectId:e,apiBase:`${o}/p/${encodeURIComponent(e)}`},[e]);return(0,ut.jsx)(Yl.Provider,{value:n,children:t})}export{gc as $,Zi as $n,pt as $r,Pc as $t,rl as A,Uo as An,Jt as Ar,Ml as At,Ec as B,$a as Bn,At as Br,kl as Bt,hl as C,qo as Cn,_n as Cr,Ws as Ct,dl as D,wo as Dn,tn as Dr,Js as Dt,Ol as E,Go as En,wn as Er,Hs as Et,Ll as F,Oo as Fn,un as Fr,Wc as Ft,_l as G,Ia as Gn,St as Gr,ul as Gt,Tc as H,eo as Hn,L as Hr,Jc as Ht,nc as I,No as In,Vt as Ir,ol as It,wc as J,Ra as Jn,yt as Jr,jl as Jt,Kl as K,za as Kn,Tt as Kr,ic as Kt,rc as L,ao as Ln,Gt as Lr,cl as Lt,pl as M,zo as Mn,ln as Mr,Z as Mt,kc as N,Ho as Nn,cn as Nr,Qc as Nt,Cl as O,To as On,an as Or,Ys as Ot,$c as P,Vo as Pn,nn as Pr,vc as Pt,hc as Q,Oa as Qn,ht as Qr,Wl as Qt,Fl as R,so as Rn,Kt as Rr,sl as Rt,Bc as S,pe as Si,Jo as Sn,Sn as Sr,qs as St,tl as T,Ko as Tn,Tn as Tr,Bs as Tt,El as U,Qa as Un,Dt as Ur,gl as Ut,Dc as V,Ga as Vn,jt as Vr,nl as Vt,Dl as W,Za as Wn,Et as Wr,ec as Wt,fc as X,Fa as Xn,bt as Xr,Nl as Xt,lc as Y,Pa as Yn,xt as Yr,Vl as Yt,uc as Z,ja as Zn,vt as Zr,Gl as Zt,jc as _,P as _i,Ms as _n,Hn as _r,sc as _t,Y as a,qe as ai,Nc as an,U as ar,pc as at,vl as b,Ie as bi,zc as bn,On as br,xc as bt,Oc as c,_e as ci,$ as cn,yi as cr,Rs as ct,Sl as d,Ne as di,fl as dn,pi as dr,Qs as dt,ft as ei,Bl as en,Gi as er,Lc as et,Kc as f,xe as fi,bl as fn,H as fr,ac as ft,ll as g,Ee as gi,Q as gn,Vn as gr,cc as gt,Fc as h,we as hi,Uc as hn,ar as hr,Sc as ht,ql as i,Qe as ii,Tl as in,Ci as ir,mc as it,Al as j,J as jn,sn as jr,Ul as jt,$s as k,Wo as kn,on as kr,Pl as kt,zs as l,Ce as li,Us as ln,hi as lr,Ls as lt,xl as m,ge as mi,Yc as mn,Dr as mr,Gs as mt,Zl as n,$e as ni,Hc as nn,Li as nr,_c as nt,Zc as o,Ke as oi,wl as on,_i as or,Is as ot,X as p,be as pi,Mc as pn,ii as pr,oc as pt,tc as q,La as qn,wt as qr,Hl as qt,Xl as r,Ze as ri,ml as rn,Di as rr,dc as rt,qc as s,He as si,Ac as sn,gi as sr,al as st,Yl as t,rt as ti,Rc as tn,$i as tr,yc as tt,Xc as u,Se as ui,Rl as un,ai as ur,Zs as ut,el as v,De as vi,zl as vn,Fn as vr,bc as vt,Gc as w,Yo as wn,bn as wr,Xs as wt,Ic as x,me as xi,Vc as xn,xn as xr,Ks as xt,Il as y,Re as yi,yl as yn,Pn as yr,Cc as yt,Vs as z,io as zn,Ft as zr,il as zt};
|
package/web/dist/assets/{prompt-template-menu-Dc2ufWt7.js → prompt-template-menu-Fb8KyZ2w.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r}from"./button-C1fD-ZFr.js";import{It as i}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r}from"./button-C1fD-ZFr.js";import{It as i}from"./queries-BCXjp1_j.js";import{N as a,S as o,a as s,o as c,r as l}from"./use-desktop-CEB_iBfH.js";import{W as u,l as d,tt as f}from"./design-icons-B6-0w7Aw.js";import{c as p}from"./project-router-BLLH9tz9.js";import{F as m,I as h,M as g,N as _,P as v,j as y,k as b}from"./picker-pill-Bmxuo6r5.js";import{a as x}from"./skills-pM_PouEs.js";var S=n();function C({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`skeleton`,className:r(`animate-pulse rounded-md bg-accent`,e),...t})}var w=[`assigned`,`no-task`,`has-task`,`all`],T=[`review`,`mine`,`failing`,`all`],E=50,D=`is:open review-requested:@me`,O=`is:open status:failure`;function k(e,t){return e===`prs`&&(t===`review`||t===`failing`)}function A(e){return e===`review`?D:e===`failing`?O:null}function j(e,t){return t===null?null:(e===`issues`?w:T).includes(t)?t:`all`}function M(e,t,n,r=``){let i=`${n===void 0?e===`issues`?`/github`:`/github/prs`:`${e===`issues`?`/github/issues`:`/github/prs`}/${n}`}${r}`;return t===null?i:`${i}?filter=${encodeURIComponent(t)}`}function N(e,t){let n=t??`all`;return n===`all`?e===`issues`?`all`:`all-prs`:n}function P(e){return e===`all`?{view:`issues`,filter:`all`}:e===`all-prs`?{view:`prs`,filter:`all`}:{view:e===`review`||e===`mine`||e===`failing`?`prs`:`issues`,filter:e}}var F=[{id:`assigned`,label:`Assigned to me`},{id:`no-task`,label:`No task yet`},{id:`has-task`,label:`Has a task`},{id:`all`,label:`All open`}],I=[{id:`review`,label:`Review requested`},{id:`mine`,label:`Mine`},{id:`failing`,label:`Checks failing`},{id:`all-prs`,label:`All open`}],L=Object.fromEntries([...F,...I].map(e=>[e.id,e.label]));function R(e){return e===null?``:`${e.value}${e.bound===`atLeast`?`+`:``}`}function z(e,t){if(t?.bound===`atLeast`)return e===`review`||e===`failing`?`At least ${t.value}: GitHub search returns at most ${E} results.`:`At least ${t.value}: only the loaded pages are counted. Scroll to load more.`}var B=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase()===t.toLowerCase();function V(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean);return t.length>=2?`${t[0]}/${t[1]}`.toLowerCase():null}catch{return null}}function H(e,t,n){return new Set(e.filter(e=>!e.archived).flatMap(e=>U(e,t,n)))}function U(e,t,n){let r=t?.toLowerCase();return o(e,void 0,n).filter(e=>e.kind===`Issue`&&(!e.url||r!==void 0&&V(e.url)===r)).map(e=>e.number)}function W(e,t,n,r){let i=new Map;for(let o of e)!a(o)&&U(o,n,r).includes(t)&&i.set(o.id,o);return[...i.values()].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt)||e.id.localeCompare(t.id))}function G(e,t){let n=new Map(t.map(e=>[e.number,e]));return e.map(e=>n.get(e.number)??e)}function K(e){return e?.available?{value:e.items.length,bound:e.truncated?`atLeast`:`exact`}:null}function q({gh:e,tasks:t,review:n,failing:r}){let a={assigned:null,"no-task":null,"has-task":null,all:null,review:K(n),mine:null,failing:K(r),"all-prs":null};if(!e?.available)return a;let o=!i(e,`issues`),s=!i(e,`prs`),c=(e,t)=>({value:e,bound:t?`atLeast`:`exact`}),l=t?e.issues.filter(e=>t.has(e.number)).length:null;return{...a,all:c(e.issuesTotal??e.issues.length,!1),"all-prs":c(e.prsTotal??e.prs.length,!1),assigned:e.viewerLogin?c(e.issues.filter(t=>t.assignees?.some(t=>B(t,e.viewerLogin))).length,o):null,mine:e.viewerLogin?c(e.prs.filter(t=>B(t.author,e.viewerLogin)).length,s):null,"has-task":l===null?null:c(l,o),"no-task":l===null?null:c(e.issues.length-l,o)}}var J=e(t(),1);function Y({templates:e,onInsert:t,triggerClassName:n,disabled:i,iconOnly:a=!1,label:o=`Template`}){let[C,w]=(0,J.useState)(!1),T=(0,J.useRef)(null),E=p();return e.length===0?null:(0,S.jsxs)(l,{open:C,onOpenChange:w,children:[(0,S.jsx)(c,{asChild:!0,children:(0,S.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:i,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a?`w-[26px] justify-center px-0`:`h-11 gap-2 rounded-lg px-3 text-foreground`,n),children:[(0,S.jsx)(u,{"aria-hidden":`true`,className:a?`size-3 shrink-0 text-accent-icon`:`size-[18px] shrink-0 text-muted-foreground`}),a?null:(0,S.jsxs)(S.Fragment,{children:[o,(0,S.jsx)(d,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`})]})]})}),(0,S.jsx)(s,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,S.jsxs)(b,{filter:x,children:[(0,S.jsx)(_,{placeholder:`search templates…`,onInput:()=>T.current?.scrollTo(0,0)}),(0,S.jsxs)(m,{ref:T,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,S.jsx)(y,{children:`Nothing matches.`}),(0,S.jsx)(g,{heading:`Insert a template`,children:e.map(e=>(0,S.jsxs)(v,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{t(e.text),w(!1)},children:[(0,S.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,S.jsxs)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`inline-flex shrink-0 items-center gap-0.5 text-[12px] font-medium text-accent-text`,children:[(0,S.jsx)(f,{"aria-hidden":`true`,className:`size-2.5`}),e.skills.length]}):null]}),(0,S.jsx)(`span`,{className:`line-clamp-1 text-[11px] text-soft-foreground`,children:e.text})]},e.id))}),(0,S.jsx)(h,{}),(0,S.jsx)(g,{children:(0,S.jsx)(v,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-[12px] text-muted-foreground`,onSelect:()=>{w(!1),E(`/settings/prompt-templates`)},children:`Edit templates…`})})]})]})})]})}export{G as _,I as a,q as c,M as d,k as f,N as g,j as h,F as i,P as l,W as m,L as n,D as o,H as p,O as r,z as s,Y as t,R as u,A as v,C as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{A as n,M as r}from"./button-C1fD-ZFr.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$t as s,At as c,B as l,Ct as u,Dr as d,Dt as f,Et as p,F as m,Ft as h,G as g,Gr as _,H as v,Ht as y,I as ee,J as te,Jr as ne,Kr as re,Kt as ie,L as ae,M as oe,Nr as se,Or as ce,Ot as le,Q as ue,Qr as de,R as fe,S as pe,Si as me,Sr as b,Tt as he,V as ge,Vt as _e,X as ve,Xr as ye,Y as x,Yr as be,Z as xe,Zr as Se,_ as Ce,_t as we,a as Te,ai as Ee,an as De,at as Oe,bn as ke,bt as Ae,cn as je,ct as Me,di as Ne,dn as Pe,dt as Fe,ei as S,en as Ie,et as Le,ft as Re,gi as C,gn as ze,gt as Be,h as Ve,hn as He,ht as Ue,i as We,it as Ge,jt as Ke,kt as qe,l as Je,li as Ye,ln as Xe,lt as Ze,mi as Qe,mn as $e,mt as et,nn as tt,oi as nt,ot as rt,p as it,pt as at,q as ot,qr as st,r as ct,rn as lt,rt as ut,st as dt,ti as ft,tn as pt,tt as mt,un as ht,ut as gt,v as _t,vi as vt,vn as yt,vr as bt,vt as xt,wt as St,x as Ct,xn as wt,y as Tt,yi as Et,yt as Dt,z as Ot}from"./project-scope-context-DMCS5p-N.js";import{q as w}from"./live-protocol-DKHlCFyG.js";import{t as T}from"./useInfiniteQuery-CvdGA_PU.js";import{t as E}from"./useQuery-BJFZunTR.js";import{n as kt,r as D,t as At}from"./ws-BxsIvFCG.js";import{n as jt}from"./toaster-Cxgzn9ip.js";var Mt=class extends Ee{#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||Nt(),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=nt({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),w.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Nt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Pt=class extends me{#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),vt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ye(t.mutationKey)!==Ye(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??Nt();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){w.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 Ft(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function It(e,t,n){let r=e.slice(0);return r[t]=n,r}var Lt=class extends me{#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,w.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||!vt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ft(e,n).forEach(e=>{e.destroy()}),Ft(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=C(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 ft(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=It(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)&&w.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},O=e(t(),1);function k({queries:e,...t},n){let r=S(n),i=de(),a=Se(),o=O.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{_(e);let t=r.getQueryCache().get(e.queryHash);ne(e,a,t)}),ye(a);let[s]=O.useState(()=>new Lt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;O.useSyncExternalStore(O.useCallback(e=>d?s.subscribe(w.batchCalls(e)):Qe,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),O.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>st(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&st(n,e)?re(n,new ft(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&be({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 A(e,t){let n=S(t),[r]=O.useState(()=>new Pt(n,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);let i=O.useSyncExternalStore(O.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((e,t)=>{r.mutate(e,t).catch(Qe)},[r]);if(i.error&&Et(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function j(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function M(e,t={}){return{...j(t),runId:e}}function N(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Z.models(t),refetchType:n})}function Rt(e,t=!0,n){return E({...zt(e,n),enabled:t})}var zt=(e,t)=>({queryKey:Z.models(e,t),queryFn:({signal:n})=>We(e,{signal:n},t),staleTime:300*1e3});function Bt(e,t=!0){let n=k({queries:e.map(e=>({...zt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var P=[`workspace`,`runs-index`],F=e=>[e.cacheScope,`runs`,`list`],I=e=>[e.cacheScope,`runs`,`detail`,e.runId],L=e=>typeof e==`function`?e():e;function Vt(e){let{seenAt:t,...n}=e;return n}function Ht(e,t){let n=Vt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function R(e,t,n){return t?{...e,seenAt:n}:Vt(e)}function Ut(e){let t=()=>{e.invalidateQueries({queryKey:P})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=ce(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:F(L(n))}),await e.cancelQueries({queryKey:I(L(n))});let i=e.getQueryData(F(L(n))),a=e.getQueryData(I(L(n))),o=L(n).runId,s=new Date().toISOString();return e.setQueryData(F(L(n)),e=>e?.map(e=>e.id===o?R(e,r,s):e)),e.setQueryData(I(L(n)),e=>e&&R(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(F(L(n)),i),a&&e.setQueryData(I(L(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(F(L(n)),e=>e?.map(e=>e.id===o?Ht(e,t):e)),a&&e.setQueryData(I(L(n)),e=>e&&Ht(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?R(e,r,i.seenAt):e;e.setQueryData(F(L(n)),e=>e?.map(a));let s={...L(n),runId:r?o:i.id};e.setQueryData(I(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:P});let i=e.getQueryData(P),a=r();return e.setQueryData(P,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(P,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function z(){let e=S();return(0,O.useMemo)(()=>Ut(e),[e])}function Wt(e){return e.type===`run`?e.run.id:e.id}function B(e,t){return{...e,runs:t}}function Gt(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function Kt(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function qt(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Jt(e,t,n){let{project:r}=t,i=Wt(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:B(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:B(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!qt(e,r,n))return{index:e,reconcile:!0};let l=C(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||Gt(t,r)>e.perProjectLimit);return{index:B(e,t),reconcile:n}}if(s)return Xt(e,l);let u=Kt(e.runs,l);return{index:B(e,u),reconcile:l.archived&&Gt(u,r)>e.perProjectLimit}}function Yt(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Xt(e,t){let n=Yt(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:B(e,Kt(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function Zt(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=C(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?B(e,i):e}function Qt(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function $t(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function en(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function tn(e){e.stream=void 0}function nn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,Wt(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function rn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function an(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function on(e,t,n){if(!an(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=Jt(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var V=[`workspace`,`runs-index`],sn=[`workspace`,`projects`],cn=6e4,ln=100,un=new WeakMap;function H(e){let t=un.get(e);return t||(t=hn(e),un.set(e,t)),t}function dn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:H(t).merge(e)}function fn(e){let t=e.getQueryData(sn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function pn(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function mn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function hn(e){let t=$t(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(V,t)},h=()=>e.getQueryData(V),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:V,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:V,exact:!0}).then(()=>e.invalidateQueries({queryKey:V})):e.invalidateQueries({queryKey:V})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=fn(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=Zt(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=Jt(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,ln),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){en(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){tn(t)},run(e,r,i=!1){if(l.has(e))return;let a=mn(e,r);if(!nn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),rn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=Qt(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=on(t,n,fn(e));for(let e of l)i.index=Qt(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),pn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var gn={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:`merged`},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:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},_n={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function vn(e){return typeof e==`string`&&Object.hasOwn(gn,e)}function yn(e){return e!==void 0&&vn(e)?gn[e]:void 0}var bn=`cez.reference-statuses.v1`,xn=`cez.reference-conflicts.v1`,U=new Map(wn()),Sn=1e3;function W(e,t){if(U.get(e)!==t){for(U.delete(e),U.set(e,t);U.size>Sn;){let e=U.keys().next().value;if(e===void 0)break;U.delete(e)}En()}}var G=new Set(Tn());function Cn(e,t){if(G.has(e)!==t){if(t)for(G.add(e);G.size>Sn;){let e=G.values().next().value;if(e===void 0)break;G.delete(e)}else G.delete(e);En()}}function wn(){try{let e=globalThis.sessionStorage?.getItem(bn);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`&&vn(e[1])):[]}catch{return[]}}function Tn(){try{let e=globalThis.sessionStorage?.getItem(xn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var K;function En(){K===void 0&&(K=setTimeout(()=>{K=void 0;try{globalThis.sessionStorage?.setItem(bn,JSON.stringify([...U])),globalThis.sessionStorage?.setItem(xn,JSON.stringify([...G]))}catch{}},250))}var q=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function J(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Dn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function On(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;W(t,o),s!==void 0&&Cn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function kn(e,t,n){let r=q(t),i=U.get(r),a=G.has(r)?!0:void 0,o=n.data;if(o?.available){On(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...J(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...J(i,a)});return}e.set(r,{state:`loading`,...J(i,a)})}function An(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Dn(i))kn(n,e,t)}),n}async function jn(e,t=!1){return ze(await it.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),je(e,`/worker-destroy`))}function Mn(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Nn(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 Pn(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 Fn(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`}))}function In(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Ln(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Rn(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function zn(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Rn(t.issues,a,r),Rn(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var Y=e=>e.map(e=>e.number).join(`,`);function Bn(e,t){let n=e[0];if(e.length>1&&n&&(Y(n.issues)!==Y(t.issues)||Y(n.prs)!==Y(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function Vn(e,t,n=!0){let i=Ur(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=r(),l=E({queryKey:X.runnerSkills(o,s),queryFn:({signal:e})=>St(o,s,{signal:e,projectId:c}),enabled:n&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...l,runner:o,account:s,data:l.data?.skills,list:l.data,unchecked:l.isError||!l.data||l.data.source===`unavailable`}}var X={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},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=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],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],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},Z={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:V,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Z.fsBrowseRoot,e,t]};function Hn(){let e=S();return E({queryKey:Z.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Z.providerStatus),r=await Ze(!1,{signal:t});return b(n,e.getQueryData(Z.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function Un(){let e=S();return A({mutationFn:()=>Ze(!0),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>b(r,e,t)),N(e)}})}function Wn(){let e=S();return A({mutationFn:({provider:e,authFailureId:t})=>De(e,t),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>b(r,e,t,n.authFailureId)),N(e,n.provider)}})}function Gn(e={}){return E({queryKey:Z.projects,queryFn:({signal:e})=>Me({signal:e}),...e})}function Kn(e,t=!1){return E({queryKey:Z.fsBrowse(e,t),queryFn:({signal:n})=>Je(e??void 0,{signal:n,showHidden:t}),retry:!1})}function qn(){let e=S();return A({mutationFn:e=>s(e),onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function Jn(){let e=S();return A({mutationFn:e=>pt(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Z.projects})}})}function Yn(){let e=S();return A({mutationFn:e=>{let{id:t,...n}=e;return ke(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Z.projects});let r=e.getQueryData(Z.projects);return e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Xn(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Z.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Z.projects})})}function Xn(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?[]:Fn(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Zn(e){let t=S();return A({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Z.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Z.projects})})}function Qn(){return Zn(e=>{let{projectId:t,...n}=e;return pe(t,n)})}function $n(){return Zn(e=>{let{projectId:t,webhookId:n,...r}=e;return wt(t,n,r)})}function er(){return Zn(({projectId:e,webhookId:t})=>tt(e,t))}function tr(){return A({mutationFn:({projectId:e,webhookId:t})=>He(e,t),retry:!1})}function nr(e){let t=S();return A({mutationFn:t=>h(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Q(e){let t=S();return A({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Z.agentProfiles}),t.invalidateQueries({queryKey:Z.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),N(t)])}})}function rr(){return Q(e=>Tt(e))}function ir(){return Q(e=>{let{id:t,...n}=e;return yt(t,n)})}function ar(){return Q(e=>Ie(e))}function or(){return Q(e=>ht(e))}function sr(e,t){return E({queryKey:Z.agentAccountStatus(e),queryFn:({signal:t})=>m(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function cr(){let e=S();return A({mutationFn:({provider:e,profileId:t})=>Ce(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Z.agentProfiles}),e.invalidateQueries({queryKey:Z.providerStatus}),N(e,n,`none`)])}})}function lr(){let e=S();return A({mutationFn:e=>m(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Z.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Z.agentProfiles}),N(e,t.status.provider)}})}function ur(){let e=S();return A({mutationFn:e=>Ve(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function dr(){let e=S();return A({mutationFn:e=>Ct(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function fr({enabled:e}){return E({queryKey:Z.githubOwners,queryFn:({signal:e})=>Le({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function pr(){let e=S();(0,O.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(X.health),i=r?.capabilities?.localHandoff===!0;r&&d({local:i,bootProject:r.bootProject??`default`,apiBase:n()}),i&&t===void 0?t=At(`health`,t=>{e.setQueryData(X.health,t)}):!i&&t!==void 0&&(t(),t=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),se()}},[e])}function $(){return E({queryKey:X.health,queryFn:({signal:e})=>rt({signal:e})})}function mr(e,t){let n=$().data,r=Gn(t).data?.projects,i=ct(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?Mn(n?.repo?.remote):void 0}function hr(){return E({queryKey:X.openTargets,queryFn:({signal:e})=>dt({signal:e}),staleTime:5*6e4})}function gr(){return E({queryKey:X.runs.list(),queryFn:({signal:e})=>he(j(),{signal:e})})}function _r(e,t){return T({queryKey:X.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Ot({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function vr(e){let t=e.trim();return E({queryKey:Z.runsSearch(t),queryFn:({signal:e})=>Xe(t,{signal:e}),enabled:t.length>=2,placeholderData:Ne,staleTime:1e4})}function yr(e=!0,t=cn){let n=H(S());return D(`/api/v1/workspace/runs-index`,Z.runsIndex,a(e?t:!1),dn),E({queryKey:Z.runsIndex,queryFn:({signal:e})=>p({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function br(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>he(j({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function xr(e){let t=S();return A({mutationFn:({workerId:e,discardWork:t=!1})=>jn(e,t),onSettled:()=>t.invalidateQueries({queryKey:X.runs.relationships(e)})})}function Sr(e,t={}){return E({queryKey:X.runs.relationships(e),queryFn:({signal:t})=>u(e,{signal:t}),enabled:t.enabled??!0})}function Cr(e){return E({queryKey:X.runs.detail(e??``),queryFn:({signal:t})=>et(M(e),{signal:t}),enabled:!!e})}function wr(e,t,n=!0){return E({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>et(M(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Tr(e){return E({queryKey:X.runs.diff(e??``),queryFn:({signal:t})=>xt(e,{signal:t}),enabled:!!e})}function Er(e,t=!1){return D(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,X.runs.changes(e??``),a(t?4e3:!1)),E({queryKey:X.runs.changes(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Dr(e,t){return E({queryKey:X.runs.file(e??``,t??``),queryFn:({signal:n})=>Dt(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Or(e,t){return E({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>te(e,t,{signal:n}),enabled:t!==null,retry:!1})}function kr(e,t){return E({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>l(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ar(e,t){return E({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>ge(e,t,{signal:n}),enabled:t!==null,retry:!1})}function jr(e){return E({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>v(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Mr(e,t=!1){return D(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,X.runs.commits(e??``),a(t?5e3:!1)),E({queryKey:X.runs.commits(e??``),queryFn:({signal:t})=>we(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Nr(e,t){return E({queryKey:X.runs.commit(e??``,t??``),queryFn:({signal:n})=>Be(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Pr(e,t=!0){return E({queryKey:X.runs.handoff(e??``),queryFn:({signal:t})=>Ae(M(e),{signal:t}),enabled:!!e&&t})}function Fr(e,t,n){return E({queryKey:e===void 0?X.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Ae(M(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Ir(e,t){let n=[...new Set(e)],i=k({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>g({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,O.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function Lr(){return E({queryKey:X.workflows,queryFn:({signal:e})=>le({signal:e})})}function Rr(){return E({queryKey:X.repo,queryFn:({signal:e})=>gt({signal:e})})}function zr(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>gt({signal:t},e)})}function Br(){return E({queryKey:X.repoBranches,queryFn:({signal:e})=>Fe({signal:e})})}function Vr(){return E({queryKey:X.repoChanges,queryFn:({signal:e})=>Re({signal:e}),retry:!1})}function Hr(e){return E({queryKey:X.repoCommit(e??``),queryFn:({signal:t})=>at(e,{signal:t}),enabled:!!e,retry:!1})}function Ur(){return E({queryKey:X.config,queryFn:({signal:e})=>ot({signal:e})})}function Wr(){return E({queryKey:X.worktrees,queryFn:({signal:e})=>Ke({signal:e})})}function Gr(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>Ke({signal:t},e),staleTime:0})}function Kr(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>f({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:bt(e.sidebarLimits)},enabled:t})}function qr(){return Kr(r())}function Jr(){return E({queryKey:X.agentConfig,queryFn:({signal:e})=>ee({signal:e})})}function Yr(e){return E({queryKey:X.agentConfigFile(e??``),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:e!==null})}function Xr(e){let t=S(),n=X.agentConfig,r=X.agentConfigFile(e);return A({mutationFn:t=>ie(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Zr(){return E({queryKey:Z.uiState,queryFn:({signal:e})=>c({signal:e})})}function Qr(){return E({queryKey:Z.config,queryFn:({signal:e})=>qe({signal:e})})}function $r(){return E({queryKey:Z.agentProfiles,queryFn:({signal:e})=>fe({signal:e})})}function ei(e){let t=S();return A({mutationFn:t=>_e(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function ti(e){let t=z(),n=e?.projectId,r=e?.cacheScope,i=A({mutationFn:e=>$e(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,O.useCallback)(e=>({...M(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,O.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,O.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,O.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ni(){let e=z();return A({mutationFn:e=>$e(M(e),!1),onMutate:t=>e.patchRead(()=>M(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ri(e){let t=z();return A({mutationFn:({id:t,pinned:n})=>y(M(t,e),n),onError:e=>jt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??j(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function ii(e,t){let n=z();return A({mutationFn:n=>Pe(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof Te&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ai(e,t){let n=z();return A({mutationFn:(n={})=>_t(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function oi(e){let t=S();return A({mutationFn:({msgId:t,message:n})=>oe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function si(e){let t=S();return A({mutationFn:t=>lt(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function ci(e={},t=!0){let n=S(),i=X.github(e);D(`/api/v1/p/${r()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=E({queryKey:X.github(e),queryFn:({signal:t})=>x({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=E({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>ut(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{!s||!c.data&&!c.error||n.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[n,s,c.data,c.error,i]),o}var li=class extends Error{};function ui(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await x({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new li(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>In(e),retry:(e,t)=>!(t instanceof li)&&!(t instanceof Te&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function di(e=50,t=!0){let n=S(),i=X.githubPages(e),o=X.githubPagesHead(e);D(`/api/v1/p/${r()}/github?limit=${e}`,o,a(t?6e4:!1));let s=T({...ui(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=E({queryKey:o,queryFn:({signal:t})=>x({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,O.useEffect)(()=>{if(!c.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=Bn(e.pages,c.data);t===`refetch`?l():n.setQueryData(i,{...e,pages:t})},[n,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=k({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ut(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,O.useEffect)(()=>{d.forEach((e,t)=>{let r=u[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:i}:t})})},[n,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,O.useMemo)(()=>zn(s.data?.pages??[]),[s.data])}}function fi(e,t=50,n=!0){let r=T({...ui([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,O.useMemo)(()=>zn(r.data?.pages??[]),[r.data])}}function pi(e,t,n=!0){let r=k({queries:t.filter(e=>e.length>0).map(t=>({queryKey:X.githubCommentCounts(e,t),queryFn:({signal:n})=>xe(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,O.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function mi(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Oe(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function hi(e,t=!0){return E({queryKey:X.githubChecks(e),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function gi(e,t,n=!0){return E({queryKey:X.githubSearch(e,t),queryFn:({signal:n})=>Oe(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var _i=100;function vi(e){return[...e].sort((e,t)=>t-e).slice(0,_i).sort((e,t)=>e-t)}function yi(){let e=ct(),t=$();return e.projectId??t.data?.bootProject}function bi(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))W(q({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))W(q({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var xi=5*6e4;function Si(e){return e?e.recheckAfterMs:xi}function Ci(e,t=!0){let n=(0,O.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:vi(t.prs),issues:vi(t.issues)}))},[e.map(q).sort().join(`|`)]),r=k({queries:n.map(e=>({queryKey:X.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>Ge(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Si(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=S(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Si(r[t]?.data)??!1})));(0,O.useEffect)(()=>{if(!t||i())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=X.githubRefStatus(t.projectId,t.prs,t.issues);return kt({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,O.useMemo)(()=>An(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,O.useCallback)(e=>{let t=q(e),n=s.get(t);if(n)return n;let r=U.get(t);return{state:`idle`,...r?{status:r}:{},...G.has(t)?{conflicting:!0}:{}}},[s])}function wi(e,t,n=!0){return E({queryKey:X.githubComments(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ti(e,t,n=!0){return E({queryKey:X.githubItem(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ei(e){return E({queryKey:X.githubPrChanges(e??0),queryFn:({signal:t})=>mt(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Ci as $,Ei as A,Lr as At,fi as B,_n as Bt,ci as C,ii as Ct,Ti as D,ir as Dt,wi as E,qr as Et,ni as F,Vn as Ft,br as G,Bt as Gt,zr as H,H as Ht,nr as I,Ln as It,Gn as J,M as Jt,Kr as K,Rt as Kt,hr as L,Nn as Lt,$ as M,Zr as Mt,pr as N,Wr as Nt,fr as O,Yn as Ot,ti as P,Z as Pt,yi as Q,ei as R,Pn as Rt,Kn as S,or as St,pi as T,tr as Tt,mr as U,z as Ut,mi as V,yn as Vt,wr as W,N as Wt,Xr as X,Mt as Xt,Hn as Y,A as Yt,lr as Z,dr as _,Pr as _t,Yr as a,si as at,oi as b,yr as bt,kr as c,Vr as ct,Ir as d,Cr as dt,Un as et,ur as f,Er as ft,rr as g,Dr as gt,ai as h,Tr as ht,Jr as i,er as it,gi as j,Qr as jt,di as k,$n as kt,Ar as l,Hr as lt,cr as m,Mr as mt,bi as n,ar as nt,$r as o,Rr as ot,Ur as p,Nr as pt,Gr as q,j as qt,sr as r,Jn as rt,_r as s,Br as st,X as t,qn as tt,jr as u,Wn as ut,Qn as v,Sr as vt,hi as w,Fr as wt,Or as x,vr as xt,xr as y,gr as yt,ri as z,Mn as zt};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{A as n,M as r}from"./button-C1fD-ZFr.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$t as s,At as c,B as l,Ct as u,Dr as d,Dt as f,Et as p,F as m,Ft as h,G as g,Gr as _,H as v,Ht as y,I as ee,J as te,Jr as ne,Kr as re,Kt as ie,L as ae,M as oe,Nr as se,Or as ce,Ot as le,Q as ue,Qr as de,R as fe,S as pe,Si as me,Sr as b,Tt as he,V as ge,Vt as _e,X as ve,Xr as ye,Y as x,Yr as be,Z as xe,Zr as Se,_ as Ce,_t as we,a as Te,ai as Ee,an as De,at as Oe,bn as ke,bt as Ae,cn as je,ct as Me,di as Ne,dn as Pe,dt as Fe,ei as S,en as Ie,et as Le,ft as Re,gi as C,gn as ze,gt as Be,h as Ve,hn as He,ht as Ue,i as We,it as Ge,jt as Ke,kt as qe,l as Je,li as Ye,ln as Xe,lt as Ze,mi as Qe,mn as $e,mt as et,nn as tt,oi as nt,ot as rt,p as it,pt as at,q as ot,qr as st,r as ct,rn as lt,rt as ut,st as dt,ti as ft,tn as pt,tt as mt,un as ht,ut as gt,v as _t,vi as vt,vn as yt,vr as bt,vt as xt,wt as St,x as Ct,xn as wt,y as Tt,yi as Et,yt as Dt,z as Ot}from"./project-scope-context-CR3cozni.js";import{J as w}from"./live-protocol-60uiPDg6.js";import{t as T}from"./useInfiniteQuery-Bh_R8jAH.js";import{t as E}from"./useQuery-Ct6O0RmO.js";import{n as kt,r as D,t as At}from"./ws-DCvFYEh3.js";import{n as jt}from"./toaster-Cxgzn9ip.js";var Mt=class extends Ee{#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||Nt(),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=nt({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),w.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Nt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Pt=class extends me{#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),vt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ye(t.mutationKey)!==Ye(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??Nt();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){w.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 Ft(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function It(e,t,n){let r=e.slice(0);return r[t]=n,r}var Lt=class extends me{#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,w.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||!vt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ft(e,n).forEach(e=>{e.destroy()}),Ft(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=C(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 ft(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=It(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)&&w.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},O=e(t(),1);function k({queries:e,...t},n){let r=S(n),i=de(),a=Se(),o=O.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{_(e);let t=r.getQueryCache().get(e.queryHash);ne(e,a,t)}),ye(a);let[s]=O.useState(()=>new Lt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;O.useSyncExternalStore(O.useCallback(e=>d?s.subscribe(w.batchCalls(e)):Qe,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),O.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>st(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&st(n,e)?re(n,new ft(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&be({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 A(e,t){let n=S(t),[r]=O.useState(()=>new Pt(n,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);let i=O.useSyncExternalStore(O.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((e,t)=>{r.mutate(e,t).catch(Qe)},[r]);if(i.error&&Et(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function j(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function M(e,t={}){return{...j(t),runId:e}}function N(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Z.models(t),refetchType:n})}function Rt(e,t=!0,n){return E({...zt(e,n),enabled:t})}var zt=(e,t)=>({queryKey:Z.models(e,t),queryFn:({signal:n})=>We(e,{signal:n},t),staleTime:300*1e3});function Bt(e,t=!0){let n=k({queries:e.map(e=>({...zt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var P=[`workspace`,`runs-index`],F=e=>[e.cacheScope,`runs`,`list`],I=e=>[e.cacheScope,`runs`,`detail`,e.runId],L=e=>typeof e==`function`?e():e;function Vt(e){let{seenAt:t,...n}=e;return n}function Ht(e,t){let n=Vt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function R(e,t,n){return t?{...e,seenAt:n}:Vt(e)}function Ut(e){let t=()=>{e.invalidateQueries({queryKey:P})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=ce(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:F(L(n))}),await e.cancelQueries({queryKey:I(L(n))});let i=e.getQueryData(F(L(n))),a=e.getQueryData(I(L(n))),o=L(n).runId,s=new Date().toISOString();return e.setQueryData(F(L(n)),e=>e?.map(e=>e.id===o?R(e,r,s):e)),e.setQueryData(I(L(n)),e=>e&&R(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(F(L(n)),i),a&&e.setQueryData(I(L(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(F(L(n)),e=>e?.map(e=>e.id===o?Ht(e,t):e)),a&&e.setQueryData(I(L(n)),e=>e&&Ht(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?R(e,r,i.seenAt):e;e.setQueryData(F(L(n)),e=>e?.map(a));let s={...L(n),runId:r?o:i.id};e.setQueryData(I(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:P});let i=e.getQueryData(P),a=r();return e.setQueryData(P,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(P,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function z(){let e=S();return(0,O.useMemo)(()=>Ut(e),[e])}function Wt(e){return e.type===`run`?e.run.id:e.id}function B(e,t){return{...e,runs:t}}function Gt(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function Kt(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function qt(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Jt(e,t,n){let{project:r}=t,i=Wt(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:B(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:B(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!qt(e,r,n))return{index:e,reconcile:!0};let l=C(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||Gt(t,r)>e.perProjectLimit);return{index:B(e,t),reconcile:n}}if(s)return Xt(e,l);let u=Kt(e.runs,l);return{index:B(e,u),reconcile:l.archived&&Gt(u,r)>e.perProjectLimit}}function Yt(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Xt(e,t){let n=Yt(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:B(e,Kt(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function Zt(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=C(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?B(e,i):e}function Qt(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function $t(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function en(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function tn(e){e.stream=void 0}function nn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,Wt(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function rn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function an(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function on(e,t,n){if(!an(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=Jt(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var V=[`workspace`,`runs-index`],sn=[`workspace`,`projects`],cn=6e4,ln=100,un=new WeakMap;function H(e){let t=un.get(e);return t||(t=hn(e),un.set(e,t)),t}function dn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:H(t).merge(e)}function fn(e){let t=e.getQueryData(sn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function pn(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function mn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function hn(e){let t=$t(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(V,t)},h=()=>e.getQueryData(V),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:V,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:V,exact:!0}).then(()=>e.invalidateQueries({queryKey:V})):e.invalidateQueries({queryKey:V})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=fn(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=Zt(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=Jt(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,ln),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){en(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){tn(t)},run(e,r,i=!1){if(l.has(e))return;let a=mn(e,r);if(!nn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),rn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=Qt(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=on(t,n,fn(e));for(let e of l)i.index=Qt(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),pn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var gn={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:`merged`},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:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},_n={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function vn(e){return typeof e==`string`&&Object.hasOwn(gn,e)}function yn(e){return e!==void 0&&vn(e)?gn[e]:void 0}var bn=`cez.reference-statuses.v1`,xn=`cez.reference-conflicts.v1`,U=new Map(wn()),Sn=1e3;function W(e,t){if(U.get(e)!==t){for(U.delete(e),U.set(e,t);U.size>Sn;){let e=U.keys().next().value;if(e===void 0)break;U.delete(e)}En()}}var G=new Set(Tn());function Cn(e,t){if(G.has(e)!==t){if(t)for(G.add(e);G.size>Sn;){let e=G.values().next().value;if(e===void 0)break;G.delete(e)}else G.delete(e);En()}}function wn(){try{let e=globalThis.sessionStorage?.getItem(bn);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`&&vn(e[1])):[]}catch{return[]}}function Tn(){try{let e=globalThis.sessionStorage?.getItem(xn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var K;function En(){K===void 0&&(K=setTimeout(()=>{K=void 0;try{globalThis.sessionStorage?.setItem(bn,JSON.stringify([...U])),globalThis.sessionStorage?.setItem(xn,JSON.stringify([...G]))}catch{}},250))}var q=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function J(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Dn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function On(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;W(t,o),s!==void 0&&Cn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function kn(e,t,n){let r=q(t),i=U.get(r),a=G.has(r)?!0:void 0,o=n.data;if(o?.available){On(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...J(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...J(i,a)});return}e.set(r,{state:`loading`,...J(i,a)})}function An(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Dn(i))kn(n,e,t)}),n}async function jn(e,t=!1){return ze(await it.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),je(e,`/worker-destroy`))}function Mn(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Nn(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 Pn(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 Fn(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`}))}function In(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Ln(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Rn(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function zn(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Rn(t.issues,a,r),Rn(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var Y=e=>e.map(e=>e.number).join(`,`);function Bn(e,t){let n=e[0];if(e.length>1&&n&&(Y(n.issues)!==Y(t.issues)||Y(n.prs)!==Y(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function Vn(e,t,n=!0){let i=Ur(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=r(),l=E({queryKey:X.runnerSkills(o,s),queryFn:({signal:e})=>St(o,s,{signal:e,projectId:c}),enabled:n&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...l,runner:o,account:s,data:l.data?.skills,list:l.data,unchecked:l.isError||!l.data||l.data.source===`unavailable`}}var X={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},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=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],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],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},Z={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:V,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Z.fsBrowseRoot,e,t]};function Hn(){let e=S();return E({queryKey:Z.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Z.providerStatus),r=await Ze(!1,{signal:t});return b(n,e.getQueryData(Z.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function Un(){let e=S();return A({mutationFn:()=>Ze(!0),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>b(r,e,t)),N(e)}})}function Wn(){let e=S();return A({mutationFn:({provider:e,authFailureId:t})=>De(e,t),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>b(r,e,t,n.authFailureId)),N(e,n.provider)}})}function Gn(e={}){return E({queryKey:Z.projects,queryFn:({signal:e})=>Me({signal:e}),...e})}function Kn(e,t=!1){return E({queryKey:Z.fsBrowse(e,t),queryFn:({signal:n})=>Je(e??void 0,{signal:n,showHidden:t}),retry:!1})}function qn(){let e=S();return A({mutationFn:e=>s(e),onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function Jn(){let e=S();return A({mutationFn:e=>pt(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Z.projects})}})}function Yn(){let e=S();return A({mutationFn:e=>{let{id:t,...n}=e;return ke(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Z.projects});let r=e.getQueryData(Z.projects);return e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Xn(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Z.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Z.projects})})}function Xn(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?[]:Fn(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Zn(e){let t=S();return A({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Z.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Z.projects})})}function Qn(){return Zn(e=>{let{projectId:t,...n}=e;return pe(t,n)})}function $n(){return Zn(e=>{let{projectId:t,webhookId:n,...r}=e;return wt(t,n,r)})}function er(){return Zn(({projectId:e,webhookId:t})=>tt(e,t))}function tr(){return A({mutationFn:({projectId:e,webhookId:t})=>He(e,t),retry:!1})}function nr(e){let t=S();return A({mutationFn:t=>h(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Q(e){let t=S();return A({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Z.agentProfiles}),t.invalidateQueries({queryKey:Z.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),N(t)])}})}function rr(){return Q(e=>Tt(e))}function ir(){return Q(e=>{let{id:t,...n}=e;return yt(t,n)})}function ar(){return Q(e=>Ie(e))}function or(){return Q(e=>ht(e))}function sr(e,t){return E({queryKey:Z.agentAccountStatus(e),queryFn:({signal:t})=>m(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function cr(){let e=S();return A({mutationFn:({provider:e,profileId:t})=>Ce(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Z.agentProfiles}),e.invalidateQueries({queryKey:Z.providerStatus}),N(e,n,`none`)])}})}function lr(){let e=S();return A({mutationFn:e=>m(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Z.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Z.agentProfiles}),N(e,t.status.provider)}})}function ur(){let e=S();return A({mutationFn:e=>Ve(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function dr(){let e=S();return A({mutationFn:e=>Ct(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function fr({enabled:e}){return E({queryKey:Z.githubOwners,queryFn:({signal:e})=>Le({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function pr(){let e=S();(0,O.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(X.health);r&&(d({bootProject:r.bootProject??`default`,apiBase:n()}),t??=At(`health`,t=>{e.setQueryData(X.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),se()}},[e])}function $(){return E({queryKey:X.health,queryFn:({signal:e})=>rt({signal:e})})}function mr(e,t){let n=$().data,r=Gn(t).data?.projects,i=ct(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?Mn(n?.repo?.remote):void 0}function hr(){return E({queryKey:X.openTargets,queryFn:({signal:e})=>dt({signal:e}),staleTime:5*6e4})}function gr(){return E({queryKey:X.runs.list(),queryFn:({signal:e})=>he(j(),{signal:e})})}function _r(e,t){return T({queryKey:X.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Ot({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function vr(e){let t=e.trim();return E({queryKey:Z.runsSearch(t),queryFn:({signal:e})=>Xe(t,{signal:e}),enabled:t.length>=2,placeholderData:Ne,staleTime:1e4})}function yr(e=!0,t=cn){let n=H(S());return D(`/api/v1/workspace/runs-index`,Z.runsIndex,a(e?t:!1),dn),E({queryKey:Z.runsIndex,queryFn:({signal:e})=>p({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function br(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>he(j({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function xr(e){let t=S();return A({mutationFn:({workerId:e,discardWork:t=!1})=>jn(e,t),onSettled:()=>t.invalidateQueries({queryKey:X.runs.relationships(e)})})}function Sr(e,t={}){return E({queryKey:X.runs.relationships(e),queryFn:({signal:t})=>u(e,{signal:t}),enabled:t.enabled??!0})}function Cr(e){return E({queryKey:X.runs.detail(e??``),queryFn:({signal:t})=>et(M(e),{signal:t}),enabled:!!e})}function wr(e,t,n=!0){return E({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>et(M(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Tr(e){return E({queryKey:X.runs.diff(e??``),queryFn:({signal:t})=>xt(e,{signal:t}),enabled:!!e})}function Er(e,t=!1){return D(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,X.runs.changes(e??``),a(t?4e3:!1)),E({queryKey:X.runs.changes(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Dr(e,t){return E({queryKey:X.runs.file(e??``,t??``),queryFn:({signal:n})=>Dt(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Or(e,t){return E({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>te(e,t,{signal:n}),enabled:t!==null,retry:!1})}function kr(e,t){return E({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>l(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ar(e,t){return E({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>ge(e,t,{signal:n}),enabled:t!==null,retry:!1})}function jr(e){return E({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>v(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Mr(e,t=!1){return D(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,X.runs.commits(e??``),a(t?5e3:!1)),E({queryKey:X.runs.commits(e??``),queryFn:({signal:t})=>we(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Nr(e,t){return E({queryKey:X.runs.commit(e??``,t??``),queryFn:({signal:n})=>Be(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Pr(e,t=!0){return E({queryKey:X.runs.handoff(e??``),queryFn:({signal:t})=>Ae(M(e),{signal:t}),enabled:!!e&&t})}function Fr(e,t,n){return E({queryKey:e===void 0?X.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Ae(M(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Ir(e,t){let n=[...new Set(e)],i=k({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>g({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,O.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function Lr(){return E({queryKey:X.workflows,queryFn:({signal:e})=>le({signal:e})})}function Rr(){return E({queryKey:X.repo,queryFn:({signal:e})=>gt({signal:e})})}function zr(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>gt({signal:t},e)})}function Br(){return E({queryKey:X.repoBranches,queryFn:({signal:e})=>Fe({signal:e})})}function Vr(){return E({queryKey:X.repoChanges,queryFn:({signal:e})=>Re({signal:e}),retry:!1})}function Hr(e){return E({queryKey:X.repoCommit(e??``),queryFn:({signal:t})=>at(e,{signal:t}),enabled:!!e,retry:!1})}function Ur(){return E({queryKey:X.config,queryFn:({signal:e})=>ot({signal:e})})}function Wr(){return E({queryKey:X.worktrees,queryFn:({signal:e})=>Ke({signal:e})})}function Gr(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>Ke({signal:t},e),staleTime:0})}function Kr(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>f({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:bt(e.sidebarLimits)},enabled:t})}function qr(){return Kr(r())}function Jr(){return E({queryKey:X.agentConfig,queryFn:({signal:e})=>ee({signal:e})})}function Yr(e){return E({queryKey:X.agentConfigFile(e??``),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:e!==null})}function Xr(e){let t=S(),n=X.agentConfig,r=X.agentConfigFile(e);return A({mutationFn:t=>ie(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Zr(){return E({queryKey:Z.uiState,queryFn:({signal:e})=>c({signal:e})})}function Qr(){return E({queryKey:Z.config,queryFn:({signal:e})=>qe({signal:e})})}function $r(){return E({queryKey:Z.agentProfiles,queryFn:({signal:e})=>fe({signal:e})})}function ei(e){let t=S();return A({mutationFn:t=>_e(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function ti(e){let t=z(),n=e?.projectId,r=e?.cacheScope,i=A({mutationFn:e=>$e(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,O.useCallback)(e=>({...M(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,O.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,O.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,O.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ni(){let e=z();return A({mutationFn:e=>$e(M(e),!1),onMutate:t=>e.patchRead(()=>M(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ri(e){let t=z();return A({mutationFn:({id:t,pinned:n})=>y(M(t,e),n),onError:e=>jt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??j(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function ii(e,t){let n=z();return A({mutationFn:n=>Pe(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof Te&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ai(e,t){let n=z();return A({mutationFn:(n={})=>_t(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function oi(e){let t=S();return A({mutationFn:({msgId:t,message:n})=>oe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function si(e){let t=S();return A({mutationFn:t=>lt(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function ci(e={},t=!0){let n=S(),i=X.github(e);D(`/api/v1/p/${r()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=E({queryKey:X.github(e),queryFn:({signal:t})=>x({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=E({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>ut(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{!s||!c.data&&!c.error||n.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[n,s,c.data,c.error,i]),o}var li=class extends Error{};function ui(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await x({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new li(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>In(e),retry:(e,t)=>!(t instanceof li)&&!(t instanceof Te&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function di(e=50,t=!0){let n=S(),i=X.githubPages(e),o=X.githubPagesHead(e);D(`/api/v1/p/${r()}/github?limit=${e}`,o,a(t?6e4:!1));let s=T({...ui(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=E({queryKey:o,queryFn:({signal:t})=>x({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,O.useEffect)(()=>{if(!c.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=Bn(e.pages,c.data);t===`refetch`?l():n.setQueryData(i,{...e,pages:t})},[n,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=k({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ut(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,O.useEffect)(()=>{d.forEach((e,t)=>{let r=u[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:i}:t})})},[n,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,O.useMemo)(()=>zn(s.data?.pages??[]),[s.data])}}function fi(e,t=50,n=!0){let r=T({...ui([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,O.useMemo)(()=>zn(r.data?.pages??[]),[r.data])}}function pi(e,t,n=!0){let r=k({queries:t.filter(e=>e.length>0).map(t=>({queryKey:X.githubCommentCounts(e,t),queryFn:({signal:n})=>xe(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,O.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function mi(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Oe(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function hi(e,t=!0){return E({queryKey:X.githubChecks(e),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function gi(e,t,n=!0){return E({queryKey:X.githubSearch(e,t),queryFn:({signal:n})=>Oe(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var _i=100;function vi(e){return[...e].sort((e,t)=>t-e).slice(0,_i).sort((e,t)=>e-t)}function yi(){let e=ct(),t=$();return e.projectId??t.data?.bootProject}function bi(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))W(q({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))W(q({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var xi=5*6e4;function Si(e){return e?e.recheckAfterMs:xi}function Ci(e,t=!0){let n=(0,O.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:vi(t.prs),issues:vi(t.issues)}))},[e.map(q).sort().join(`|`)]),r=k({queries:n.map(e=>({queryKey:X.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>Ge(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Si(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=S(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Si(r[t]?.data)??!1})));(0,O.useEffect)(()=>{if(!t||i())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=X.githubRefStatus(t.projectId,t.prs,t.issues);return kt({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,O.useMemo)(()=>An(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,O.useCallback)(e=>{let t=q(e),n=s.get(t);if(n)return n;let r=U.get(t);return{state:`idle`,...r?{status:r}:{},...G.has(t)?{conflicting:!0}:{}}},[s])}function wi(e,t,n=!0){return E({queryKey:X.githubComments(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ti(e,t,n=!0){return E({queryKey:X.githubItem(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ei(e){return E({queryKey:X.githubPrChanges(e??0),queryFn:({signal:t})=>mt(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Ci as $,Ei as A,Lr as At,fi as B,_n as Bt,ci as C,ii as Ct,Ti as D,ir as Dt,wi as E,qr as Et,ni as F,Vn as Ft,br as G,Bt as Gt,zr as H,H as Ht,nr as I,Ln as It,Gn as J,M as Jt,Kr as K,Rt as Kt,hr as L,Nn as Lt,$ as M,Zr as Mt,pr as N,Wr as Nt,fr as O,Yn as Ot,ti as P,Z as Pt,yi as Q,ei as R,Pn as Rt,Kn as S,or as St,pi as T,tr as Tt,mr as U,z as Ut,mi as V,yn as Vt,wr as W,N as Wt,Xr as X,Mt as Xt,Hn as Y,A as Yt,lr as Z,dr as _,Pr as _t,Yr as a,si as at,oi as b,yr as bt,kr as c,Vr as ct,Ir as d,Cr as dt,Un as et,ur as f,Er as ft,rr as g,Dr as gt,ai as h,Tr as ht,Jr as i,er as it,gi as j,Qr as jt,di as k,$n as kt,Ar as l,Hr as lt,cr as m,Mr as mt,bi as n,ar as nt,$r as o,Rr as ot,Ur as p,Nr as pt,Gr as q,j as qt,sr as r,Jn as rt,_r as s,Br as st,X as t,qn as tt,jr as u,Wn as ut,Qn as v,Sr as vt,hi as w,Fr as wt,Or as x,vr as xt,xr as y,gr as yt,ri as z,Mn as zt};
|