@hearsay-tools/squawk 0.19.0-pr4622.9213 → 0.19.0-pr4622.9214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/delegation/routes.d.ts +78 -78
- package/dist/features/reports/routes.d.ts +2 -2
- package/dist/server/models-routes.d.ts +12 -12
- package/dist/server/providers-routes.d.ts +58 -58
- package/dist/server/runners-routes.d.ts +10 -10
- package/dist/server/workspace-live-routes.d.ts +5 -5
- package/dist/server/workspace-routes.d.ts +85 -85
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-BwVLJgxK.js → accounts-section-BJcwTmko.js} +1 -1
- package/web/dist/assets/{activity-motion-tBH9QmZu.js → activity-motion-D7ylxNSA.js} +1 -1
- package/web/dist/assets/{activity-route-CkXs29ji.js → activity-route-Bmig0E18.js} +1 -1
- package/web/dist/assets/{agent-accounts-DQ_JY8H9.js → agent-accounts-DaaS69XB.js} +1 -1
- package/web/dist/assets/{agent-config-section-Bii12by6.js → agent-config-section-BOXqQyTv.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-BpiqyCUf.js → agent-defaults-section-Bxfreo-n.js} +1 -1
- package/web/dist/assets/{appearance-B_765RRk.js → appearance-BRqSFVDC.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-B6O9ruku.js → archive-on-merge-field-hDSXItUf.js} +1 -1
- package/web/dist/assets/{ask-card-Cd0Xc7Uq.js → ask-card-CWrAEuZE.js} +1 -1
- package/web/dist/assets/{automations-route-CcVVZs26.js → automations-route-BBsU9yBn.js} +1 -1
- package/web/dist/assets/{commit-list-Dcd0WekD.js → commit-list-5iHD08NO.js} +1 -1
- package/web/dist/assets/{diff-B_cIEbs-.js → diff-CkIsqgZZ.js} +2 -2
- package/web/dist/assets/{diff-controls-BTGIDnSs.js → diff-controls-Bb70UBsP.js} +1 -1
- package/web/dist/assets/{diff-view-J684vGFE.js → diff-view-DLcxtXIH.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-BtnFyMRT.js → discard-changes-dialog-BzypT4vb.js} +1 -1
- package/web/dist/assets/{file-preview-B3jXfVP7.js → file-preview-CJVN0cBa.js} +1 -1
- package/web/dist/assets/{folder-browser-sYsHX_an.js → folder-browser-Cdm2WZOB.js} +1 -1
- package/web/dist/assets/{git-toolbar-SKqi4XfU.js → git-toolbar-DPkpAaKz.js} +1 -1
- package/web/dist/assets/{github-T6wolZwH.js → github-DXBAYLfd.js} +1 -1
- package/web/dist/assets/{global-activity-route-Dx-kvhpz.js → global-activity-route-CQULPYKA.js} +1 -1
- package/web/dist/assets/{hosts-DeyANWdw.js → hosts-IKDCpyJQ.js} +1 -1
- package/web/dist/assets/index-k2m-s5zD.js +21 -0
- package/web/dist/assets/label-ODcSLYVj.js +1 -0
- package/web/dist/assets/{markdown-TRVPj3Mg.js → markdown-C1p1PDmF.js} +1 -1
- package/web/dist/assets/{open-in-menu-g5K4vTnb.js → open-in-menu-CbPtuWnJ.js} +1 -1
- package/web/dist/assets/{option-select-B76TaZGm.js → option-select-C6d3jHce.js} +1 -1
- package/web/dist/assets/{preferences-section-DZRKsK2E.js → preferences-section-ChS8Q-Lu.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-CM10_MPC.js → preview-pane-connected-ELLewN-g.js} +1 -1
- package/web/dist/assets/{project-location-F5rU1iQp.js → project-location-D8vnqA4E.js} +1 -1
- package/web/dist/assets/{projects-section-DvYKR18b.js → projects-section-L3QxEiRK.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-DFiGQ_kP.js → prompt-templates-section-D3GzKJMf.js} +1 -1
- package/web/dist/assets/queries-DHjNE2es.js +1 -0
- package/web/dist/assets/{read-state-DlkdVJHO.js → read-state-jUDTdM3R.js} +1 -1
- package/web/dist/assets/{reference-chip-DTWd5NlK.js → reference-chip-kvc51N1L.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-4jnKyzkr.js → remote-settings-notice-BtVKQ2vp.js} +1 -1
- package/web/dist/assets/{repo-git-bpVnYJKi.js → repo-git-BGSxevNj.js} +1 -1
- package/web/dist/assets/{report-reader-DMyNCIiX.js → report-reader-CvEkEEwN.js} +1 -1
- package/web/dist/assets/{report-selection-BJgUwTp3.js → report-selection-DxBxW6dz.js} +1 -1
- package/web/dist/assets/{reports-CBzt0Dmc.js → reports-1vI74Z6R.js} +1 -1
- package/web/dist/assets/{resources-section-DrFTKHSn.js → resources-section-CpAOY20Z.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-N0GgOh1J.js → review-notes-drafts-D25BaEEb.js} +1 -1
- package/web/dist/assets/{review-panel-BhyjEDJC.js → review-panel-CS9wTfAu.js} +1 -1
- package/web/dist/assets/{review-strip-DoWuOvcF.js → review-strip-nrpQBfNI.js} +1 -1
- package/web/dist/assets/{run-detail-refresh-Bx9zlPFP.js → run-detail-refresh-wJr0M04e.js} +1 -1
- package/web/dist/assets/{run-diff-BqvMg-mp.js → run-diff-BBASqHSE.js} +1 -1
- package/web/dist/assets/{run-header-Bg2x1hvz.js → run-header-DVnksnr4.js} +1 -1
- package/web/dist/assets/{select-Cbi8vDBU.js → select-CEEeAH4k.js} +1 -1
- package/web/dist/assets/{session-context-section-BnezEi_b.js → session-context-section-F1umLA86.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-DCmAHz6j.js → settings-agent-picker-sUQdIon3.js} +1 -1
- package/web/dist/assets/{settings-save-bar-De7cR5EO.js → settings-save-bar-BkU1JDt3.js} +1 -1
- package/web/dist/assets/{settings-shell-kQCF-IMK.js → settings-shell-DodTPpjl.js} +1 -1
- package/web/dist/assets/{sidebar-section-BZHg8W-H.js → sidebar-section-DspuARa_.js} +1 -1
- package/web/dist/assets/{skills-DUOE73c3.js → skills-CrHHdPjJ.js} +1 -1
- package/web/dist/assets/{task-changes-fRMZxCzG.js → task-changes-U1cnUd83.js} +1 -1
- package/web/dist/assets/{task-commits-Cenv0zsB.js → task-commits-DxuX8SZp.js} +1 -1
- package/web/dist/assets/{task-file-scope-K1Ban5eN.js → task-file-scope-DU8AkDkr.js} +1 -1
- package/web/dist/assets/{task-files-EU03WHnV.js → task-files-DaDM9FRg.js} +1 -1
- package/web/dist/assets/{task-github-item-Dhte1Ixh.js → task-github-item-CXzzVHXw.js} +1 -1
- package/web/dist/assets/{task-groups-DcQL5SKa.js → task-groups-BapM4YcT.js} +1 -1
- package/web/dist/assets/{task-thread-DDMomGRh.js → task-thread-9WIv4rPC.js} +1 -1
- package/web/dist/assets/{thread-state-K3qTs1EO.js → thread-state-IooDEE0b.js} +1 -1
- package/web/dist/assets/{use-finish-run-C8c9NAvg.js → use-finish-run-jVAqsGkV.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-BIvAHKwY.js → use-hand-to-agent-state-DfucUGAH.js} +1 -1
- package/web/dist/assets/use-path-bases-C7DRxlRi.js +1 -0
- package/web/dist/assets/{use-workspace-config-save-D6M-r6_i.js → use-workspace-config-save-B2eroiEx.js} +1 -1
- package/web/dist/assets/{workflows-jSPeMWLl.js → workflows-DdKRMlHR.js} +1 -1
- package/web/dist/assets/{workspace-tools-DmZ9LMQc.js → workspace-tools-CePJG7uG.js} +1 -1
- package/web/dist/assets/{worktrees-section-CsXzXEwX.js → worktrees-section-CCgqbLAh.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/index-6oRe52sM.js +0 -21
- package/web/dist/assets/label-BXbOoPSF.js +0 -1
- package/web/dist/assets/queries-DQVUxiSU.js +0 -1
- package/web/dist/assets/use-path-bases-DxT4eodL.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{an as r,cn as i,dn as a,fn as o,gn as s,hn as c,in as l,ln as u,mn as d,on as f,pn as p,rn as m,sn as h,un as g,wn as _,yt as v}from"./queries-DHjNE2es.js";import{f as y,h as b,m as x,u as S}from"./host-context-iTMFRMT5.js";import{Fn as ee,Ji as C,Nn as te,ar as w,ji as ne,or as T,rr as E,tr as re}from"./toaster-Dglox5F-.js";import{i as D,r as O}from"./cez-idle-C0drOeLs.js";import{o as k}from"./dist-CCX8mhHc.js";import{n as ie,t as A}from"./hosts-IKDCpyJQ.js";import{n as ae,r as j,t as M}from"./run-detail-refresh-wJr0M04e.js";import{h as N}from"./es2015-BHonSvOU.js";var oe=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return w({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&T(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&E()}close(){this.readyState=2,this.release()}},P=e(t(),1);function F(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t,exact:!0})):e.invalidateQueries({queryKey:t,exact:!0})}function I(e,t,n,r){let i=m(t,n,r);return e.isMutating({mutationKey:i,exact:!0})>0||e.getMutationCache().getAll().some(e=>{if(e.state.status!==`pending`)return!1;let i=e.state.variables;return i?.hostId===t&&i?.projectId===n&&i?.runId===r})}function se(e,t){if(S()||t)return[];let n=[h(e).reconcile()];return e.getQueryState(A.hosts)&&n.push(F(e,A.hosts)),e.getQueryState(A.hostsProjects)&&n.push(F(e,A.hostsProjects)),n}function ce(e,t,n){if(!S())for(let r of g)e.addEventListener(r,e=>{let i=c(r,e.data);if(i)if(i.type===`host-run-summary`||i.type===`host-run-deleted`){n.run(i);let e=i.type===`host-run-summary`?i.summary.id:i.id,r=m(i.hostId,i.project,e);i.type===`host-run-deleted`?t.getQueryState(r)&&t.removeQueries({queryKey:r,exact:!0}):t.getQueryState(r)&&!I(t,i.hostId,i.project,e)&&t.invalidateQueries({queryKey:r,exact:!0})}else i.type===`host-usage`?n.usage(i.hostId,i.project,i.usage):(i.stateChanged&&F(t,A.hosts),(i.stateChanged||i.indexChanged)&&F(t,A.hostsProjects),i.indexChanged&&n.reconcileHosts(i.hostIds))})}var L=n(),le=`/workspace/events?runs=summary`,R=2,ue=3e3,de=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],z=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],B=new Set;function V(e){return B.add(e),()=>{B.delete(e)}}function H(e){return e[1]===`runs`&&e[2]===`list`}function U(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function W(e){return e.invalidateQueries({predicate:e=>H(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>H(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>U(e,t.queryKey))}var fe=1e3,G=new WeakMap;function K(e){let t=l.repoBranches,n=G.get(e);if(n){n.set(JSON.stringify(t),t);return}G.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=G.get(e);G.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},fe)}function q(e,t,n=!1){if(t?.aborted)return Promise.resolve();let a=[l.runs.all,r.runsIndex,r.projects,l.health,l.worktrees,l.repoBranches,r.providerStatus],o=S()||n?[]:[A.hosts,A.hostsProjects,f],s=()=>{for(let t of a)e.cancelQueries({queryKey:t});for(let t of o)e.cancelQueries({queryKey:t,exact:!0})};return t?.addEventListener(`abort`,s,{once:!0}),D(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>H(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:l.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>H(e.queryKey)}),i(e).reconcile(),...se(e,n),e.invalidateQueries({queryKey:r.projects}),U(e,l.health),e.invalidateQueries({queryKey:l.worktrees}),e.invalidateQueries({queryKey:l.repoBranches}),e.invalidateQueries({queryKey:r.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,s))}function J(e){return x()??Y(e)}function Y(e){let t=e.getQueryData(r.projects);if(t?.bootProject!==null)return typeof t?.bootProject==`string`&&t.bootProject!==``?t.bootProject:e.getQueryData(l.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject??void 0}function pe(e,t){return[_({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function me(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),s=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},c,u,d=(i=!1)=>{u!==void 0&&clearTimeout(u),u=void 0,c!==void 0&&cancelAnimationFrame(c),c=void 0;let a=[];for(let{key:r,baseList:i,baseQuery:c,baseUpdateCount:l,runs:u}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==c||t?.state.dataUpdateCount!==l||t?.state.data!==i){a.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}s(r,a),e.setQueryData(r,e=>{let t=e;for(let e of u.values())t=o(t,e);return t})}if(t.clear(),!i)for(let e of a)r(e);return a},f=t=>{let n=[pe(t,Y(e))],r=[t,`runs`,`list`];return(t===J(e)||e.getQueryState(r))&&n.push(r),t===J(e)&&n.push(l.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,l){let p=f(i);if(l.type===`run-summary`&&l.summary.archived&&p.every(t=>!e.getQueryData(t)?.find(e=>e.id===l.summary.id)?.archived)&&l.type===`run-summary`){for(let r of p){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(l.summary.id,l.summary)}u===void 0&&(u=setTimeout(()=>{d()},50),typeof requestAnimationFrame==`function`&&(c=requestAnimationFrame(()=>{d()})));return}let m=d(!0);for(let t of p)s(t,m),l.type===`run-summary`?e.setQueryData(t,e=>o(e,l.summary)):e.setQueryData(t,e=>a(e,l.id));for(let e of m)r(e)},flush:d,cancel(){i(),n.clear()}}}var he=400;function ge(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},he))};return{onSummary(e,n){let i=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,a=e.delegation?.role===`worker`?e.delegation.supervisorRunId:void 0,o=t.get(e.id);if(t.set(e.id,{shape:n,...i===void 0?{}:{parentRunId:i},...a===void 0?{}:{supervisorRunId:a}}),o?.shape!==n){r(l.runs.relationships(e.id),!0);for(let e of[i,a])e!==void 0&&r(l.runs.relationships(e),!0)}},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:l.runs.relationships(n)}),i?.supervisorRunId!==void 0&&r(l.runs.relationships(i.supervisorRunId),!0),i?.parentRunId===void 0?r([...l.runs.all,`relationships`],!1):r(l.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var X={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function _e(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(X)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(X)}function ve(e,t,n,r,i){switch(n.type){case`run-summary`:{let t=n.summary;if(_e(e,t),i.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;j(e,l.runs.detail(n)),r.refreshParent(n)}let a=l.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:l.worktrees}),K(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:l.runs.detail(n.id)}),e.removeQueries({queryKey:l.runs.diff(n.id)}),e.setQueriesData(X,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(X),e.invalidateQueries({queryKey:l.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function ye(e,t,n,r){if(n!==b()){if(r.type===`run-summary`){let i=r.summary;if(t.fetcher.onEvent(i.id,n),i.delegation?.role===`worker`){let r=i.delegation.parentRunId;j(e,[n,`runs`,`detail`,r]),t.refreshParent(r,n)}return}t.fetcher.forget(r.id,n),e.removeQueries({queryKey:[n,`runs`,`detail`,r.id]}),e.removeQueries({queryKey:[n,`runs`,`diff`,r.id]})}}function be(e,t=y(le)){let n=C();(0,P.useEffect)(()=>{let a=oe;if(typeof a!=`function`)return;let o=null,c=i(n),u=S()?null:h(n),f=()=>{let e=o?.requestReady;return typeof e==`function`&&e.call(o)};c.setUnknownGenerationHandler(f),u?.setUnknownGenerationHandler(f);let p=ae(n),m=M(n),g={fetcher:m,refreshParent:p.refresh},_=d(),v=me(n),y=ge(n),b=!1,x,C=!1,w=!1,T=!1,E=!1,k=()=>{T=!0,E=!1;let e=r.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(w||!E){T=!1;return}k()})},j=()=>{w||x!==void 0||(x=setTimeout(()=>{x=void 0,w||N()},ue))},N=()=>{o?.close(),o=new a(t,{withCredentials:!0}),o.addEventListener(`open`,()=>{b=!0,_.reset(),c.detach(),u?.detach(),O(!1),C&&(v.flush(),q(n)),C||(D(()=>W(n)),n.cancelQueries({queryKey:l.health}).then(()=>{w||n.invalidateQueries({queryKey:l.health})}),c.reconcile()),C=!0});for(let t of de)o.addEventListener(t,r=>{let i=s(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=_.ready(i.event.seq);c.ready(i.event.generation,i.event.seq),u?.ready(i.event.generation),e&&(v.flush(),q(n));return}let a=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&_.frame(i.event.seq);i.event.type===`ping`&&b&&(b=!1,D(()=>W(n)),O(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?c.run(i.project,i.event,a):i.event.type===`usage`&&c.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&(v.onEvent(i.project,i.event),ye(n,g,i.project,i.event)),(i.project===null||i.project===J(n))&&ve(n,e,i.event,g,y),a&&(v.flush(),q(n))});u&&ce(o,n,u);for(let e of z)o.addEventListener(e,t=>{let i;try{i=JSON.parse(t.data)}catch{return}if(e===`project-ready`)c.reconcile({hold:!0});else if(e!==`checkout-progress`&&e!==`automation-change`){n.invalidateQueries({queryKey:r.projects});let e=n.getQueryState(A.hostsProjects);e&&ie(e.data,e.status===`error`)&&n.invalidateQueries({queryKey:A.hostsProjects,exact:!0})}if(e===`project-added`){let e=i?.project?.id;typeof e==`string`&&e!==``&&c.restoreProject(e),c.reconcile({hold:!0})}if(e===`project-removed`){let e=i?.id;typeof e==`string`&&e!==``&&c.dropProject(e)}for(let t of[...B])t(e,i)});o.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=ne.safeParse(t);r.success&&(n.cancelQueries({queryKey:l.health}),n.setQueryData(l.health,r.data))}),o.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let i=ee(t);if(!i)return;let a=r.providerStatus,o=te(n.getQueryData(a),i);if(o!==void 0){n.setQueryData(a,o);return}if(T){E=!0;return}k()}),o.addEventListener(`error`,()=>{O(!1),c.detach(),u?.detach(),o?.readyState===R&&j()})},P=()=>{document.visibilityState===`visible`&&(v.flush(),c.flush(),u?.flush(),(!o||o.readyState===R)&&(clearTimeout(x),x=void 0,N()))},F=()=>{clearTimeout(x),x=void 0,v.flush()};document.addEventListener(`visibilitychange`,P),window.addEventListener(`pagehide`,F);let I=re((e,t)=>(v.flush(),q(n,e,t)));return N(),()=>{I(),w=!0,O(!1),clearTimeout(x),v.flush(),v.cancel(),c.stop(),u?.stop(),p.cancel(),m.cancel(),c.setUnknownGenerationHandler(void 0),u?.setUnknownGenerationHandler(void 0),y.cancel(),document.removeEventListener(`visibilitychange`,P),window.removeEventListener(`pagehide`,F),o?.close(),o=null}},[n,e,t])}var Z=(0,P.createContext)(null);function xe({children:e}){let[t]=(0,P.useState)(p);return be(t),v(),(0,L.jsx)(Z.Provider,{value:t,children:e})}function Q(e){let t=(0,P.useContext)(Z),n=t?t.get:Ce;return(0,P.useSyncExternalStore)(t?t.subscribe:Se,()=>e?n()[e]:void 0,()=>void 0)}var Se=()=>()=>void 0,Ce=()=>u,we=`Label`,$=P.forwardRef((e,t)=>(0,L.jsx)(N.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));$.displayName=we;var Te=$;function Ee({className:e,...t}){return(0,L.jsx)(Te,{"data-slot":`label`,className:k(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}export{Q as i,xe as n,V as r,Ee as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{d as r,f as i,m as a,p as o}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as s}from"./dist-CCX8mhHc.js";import{$t as c,S as l,an as u,en as d,h as f,in as p,nn as m,on as h,rn as g,tn as _,x as v}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{d as r,f as i,m as a,p as o}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as s}from"./dist-CCX8mhHc.js";import{$t as c,S as l,an as u,en as d,h as f,in as p,nn as m,on as h,rn as g,tn as _,x as v}from"./index-k2m-s5zD.js";import{i as y,n as b,s as x}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as S,o as C,r as w,t as T}from"./highlighter-Crq-WTmN.js";var E=e(t(),1),D=n();function O({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,D.jsx)(c,{open:e,onOpenChange:e=>{e||t()},children:(0,D.jsxs)(m,{"data-slot":`link-safety-dialog`,children:[(0,D.jsxs)(u,{children:[(0,D.jsx)(h,{children:`Open this link?`}),(0,D.jsxs)(g,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,D.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,D.jsxs)(p,{children:[(0,D.jsx)(_,{children:`Cancel`}),(0,D.jsx)(d,{onClick:n,children:`Open link`})]})]})})}var k=`text-accent-text underline underline-offset-2`;function A({href:e,children:t,internal:n,...r}){let[a,o]=(0,E.useState)(!1),s=i();return e?n?s?(0,D.jsx)(j,{...r,href:e,children:t}):(0,D.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:k,children:t}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${k}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,D.jsx)(O,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,D.jsx)(`span`,{children:t})}function j({href:e,children:t,...n}){let i=a(),s=o(),c=r(e),l=f();return(0,D.jsx)(`a`,{...n,href:c,"data-streamdown":`link`,className:k,onClick:t=>{M(t,l,e)||P(t,i,e,s)},children:t})}function M(e,t,n){if(!t?.showing||!N(e))return!1;let r=new URL(n,window.location.origin),i=/\/files\/?$/.test(r.pathname)?r.searchParams.get(`path`):null;return!i||!t.revealChange(i)?!1:(e.preventDefault(),!0)}var N=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function P(e,t,n,r){N(e)&&(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var F={code:{name:`shiki`,type:`code-highlighter`,getThemes:()=>[T,T],getSupportedLanguages:()=>C(),supportsLanguage:e=>C().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>S(e,String(t))||(w(e,String(t)).then(e=>n?.(e)),null)}},I=[T,T],L={code:{copy:!0,download:!1},table:!1,mermaid:!1},R=[...Object.values(x),J];function z(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
|
|
2
2
|
`)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var B=[...Object.values(b),z],V=[`p`,`strong`,`em`,`del`,`code`,`a`],H={p:`span`,a:`span`},U={enabled:!0,renderModal:e=>(0,D.jsx)(O,{...e})},W=`https://refused.invalid/`,G=new WeakSet;function K(e){let t=e.position?.start.offset,n=e.position?.end.offset;return t===void 0||n===void 0?null:`${t}:${n}`}function q(e){return(t,n)=>{let r=new Set,i=new Map,a=t=>{if((t.type===`link`||t.type===`definition`)&&t.url){let n=l(t.url,e);if(t.type===`definition`&&t.identifier&&!i.has(t.identifier)&&i.set(t.identifier,n!==null),n){t.url=n;let e=K(t);t.type===`link`&&e!==null&&r.add(e)}}t.children?.forEach(a)};a(t);let o=e=>{let t=K(e);e.type===`linkReference`&&e.identifier&&i.get(e.identifier)&&t!==null&&r.add(t),e.children?.forEach(o)};o(t),n.data.taskLinks=r}}function J(){return(e,t)=>{let n=e=>{let r=K(e);e.tagName===`a`&&r!==null&&t.data.taskLinks instanceof Set&&t.data.taskLinks.has(r)&&G.add(e),e.children?.forEach(n)};n(e)}}var Y=0,X=(0,E.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:r=!1,imageSrc:i}){let a=(0,E.useContext)(v),o=(0,E.useMemo)(()=>{let e={instance:++Y},n=new Set;function o(){let e=t=>{if(t.type===`image`&&t.url&&i){let e=i(t.url);t.url=e?new URL(e,window.location.href).href:W,e&&n.add(t.url)}t.children?.forEach(e)};return e}let s=a?[[q,a]]:[],c=r&&i?[[o,e]]:[];return{key:e.instance,remark:[...t?B:Object.values(b),...s,...c],components:{...a||r?{a:({href:e,children:t,node:n})=>r&&!a&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,D.jsx)(`span`,{children:t}):(0,D.jsx)(A,{href:e,internal:n!==void 0&&G.has(n),children:t})}:{},...r?{img:({src:e,alt:t})=>typeof e==`string`&&n.has(e)?(0,D.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,D.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[a,t,r,i]);return(0,D.jsx)(y,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:F,shikiTheme:I,...s({rehypePlugins:a?R:void 0,remarkPlugins:a||r&&i?o.remark:t?B:void 0,allowedElements:n?V:void 0,unwrapDisallowed:n||void 0,components:n?H:a||r?o.components:void 0}),linkSafety:U,controls:L,lineNumbers:!1,children:e},o.key)});export{P as n,X as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{Qt as t,qt as n}from"./queries-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{Qt as t,qt as n}from"./queries-DHjNE2es.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{t as i}from"./bot-TkDIw4y-.js";import{t as a}from"./external-link-BE6y205O.js";import{t as o}from"./folder-o-AvL3y3.js";import{n as s,t as c}from"./smartphone-Lr8Ug2z_.js";import{t as l}from"./square-terminal-B6RYYieR.js";import{t as u}from"./button-BV_AiLj2.js";import{i as d,l as f,p,r as m,t as h}from"./dropdown-menu-NJZfnQCU.js";import{t as g}from"./own-lookup-DS54wXvD.js";var _=r(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),v=r(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),y=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),b=r(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),x=r(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),S=r(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),C=r(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),w=r(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),T=r(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),E=r(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),D=r(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),O=r(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),k=r(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),A=r(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),j=r(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),M=e(),N={folder:o,terminal:l,vscode:y,cursor:E,zed:j,windsurf:A,sublime:S,idea:x,pycharm:T,webstorm:s,goland:O,rubymine:C,phpstorm:v,clion:b,rider:_,"android-studio":c,xcode:w,warp:D,bot:i,sparkles:k};function P(e,t){let r=F(e.id);return g(N,r===void 0?e.icon:n(t,r)?.icon)??a}function F(e){let t=e.startsWith(`cli:`)?e.slice(4):``;return t===``?void 0:t}function I({choices:e,onPick:n,label:r=`Open in…`,title:i,triggerVariant:o=`ghost`,disabled:s=!1,leading:c,trailing:l,slot:g,className:_}){let v=t().data;return(0,M.jsxs)(h,{children:[(0,M.jsx)(p,{asChild:!0,children:(0,M.jsxs)(u,{variant:o,size:`sm`,title:i,disabled:s,"data-slot":g,className:_,children:[(0,M.jsx)(a,{"aria-hidden":`true`}),r]})}),(0,M.jsxs)(m,{align:`end`,children:[c,c&&e.length>0?(0,M.jsx)(f,{}):null,e.map(({target:e,suffix:t,title:r})=>{let i=P(e,v);return(0,M.jsxs)(d,{"data-target":e.id,title:r,onSelect:()=>n(e.id),children:[(0,M.jsx)(i,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),l]})]})}export{j as i,F as n,P as r,I as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{a as t,i as n,n as r,r as i,t as a}from"./select-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{a as t,i as n,n as r,r as i,t as a}from"./select-CEEeAH4k.js";var o=e(),s=`\0empty`,c=e=>e===``?s:e,l=e=>e===s?``:e;function u({value:e,onValueChange:s,options:u,disabled:d,placeholder:f,contentClassName:p,...m}){let h=String(e);return(0,o.jsxs)(a,{value:u.some(e=>e.value===h)?c(h):``,onValueChange:e=>s(l(e)),...d===void 0?{}:{disabled:d},children:[(0,o.jsx)(n,{"data-value":h,...m,children:(0,o.jsx)(t,{...f===void 0?{}:{placeholder:f}})}),(0,o.jsx)(r,{...p===void 0?{}:{className:p},children:u.map(e=>(0,o.jsx)(i,{value:c(e.value),"data-value":e.value,...e.disabled?{disabled:!0}:{},children:e.label},e.value))})]})}export{u as t};
|
|
@@ -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{It as r,an 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{It as r,an as i}from"./queries-DHjNE2es.js";import{Ji as a,dn as o,n as s}from"./toaster-Dglox5F-.js";import{t as c}from"./switch-B9OfOEzC.js";import{gt as l,ht as u}from"./index-k2m-s5zD.js";import{n as d,t as f}from"./save-cue-CpHgT93o.js";import{n as p}from"./archive-on-merge-field-hDSXItUf.js";var m=e(t(),1),h=n();function g(){let e=a(),t=r(),[n,p]=m.useState(!1),[g,_]=m.useState(l),v=d(),y=t.data;m.useEffect(()=>{y!==void 0&&p(u(y.notifications).enabled)},[y]);let b=m.useCallback(t=>{p(t),o({notifications:{enabled:t}}).then(t=>{e.setQueryData(i.uiState,t),v.flash()}).catch(t=>{s(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:i.uiState})})},[e,v.flash]),x=m.useCallback(e=>{if(!e){b(!1);return}if(l()!=="default"){b(!0);return}b(!0),Notification.requestPermission().then(e=>_(e)).catch(()=>_(l()))},[b]),S=g===`unsupported`;return(0,h.jsxs)(`section`,{"data-slot":`notifications-section`,className:`settings-field flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,h.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,h.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default. `,(0,h.jsx)(f,{saved:v.saved})]})]}),(0,h.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:S,onCheckedChange:x})]}),S?null:(0,h.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":g,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,g===`granted`?`Allowed`:g===`denied`?`Blocked`:`Not requested`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),S?(0,h.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!S&&n&&g===`denied`?(0,h.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,h.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})}function _(){return(0,h.jsxs)(`div`,{"data-slot":`preferences-section`,className:`flex w-full flex-col gap-7`,children:[(0,h.jsx)(g,{}),(0,h.jsx)(p,{})]})}export{_ as PreferencesSection};
|
package/web/dist/assets/{preview-pane-connected-CM10_MPC.js → preview-pane-connected-ELLewN-g.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{u as r}from"./host-context-iTMFRMT5.js";import{ai as i,cr as a,lr as o,n as s,sr as c}from"./toaster-Dglox5F-.js";import{o as l}from"./dist-CCX8mhHc.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{t as f}from"./check-OP-CVgZG.js";import{t as p}from"./chevron-down-CHGyCDBH.js";import{n as m,t as h}from"./circle-x-7nTlobAF.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{t as y}from"./loader-circle-CPBhhDbB.js";import{n as ee,t as te}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-CTbToGmi.js";import{n as S,r as C,t as ne}from"./preview-B5bPk6HT.js";import{t as w}from"./square-terminal-B6RYYieR.js";import{t as T}from"./button-BV_AiLj2.js";import{a as E,c as re,i as D,l as O,p as k,r as A,s as ie,t as j}from"./dropdown-menu-NJZfnQCU.js";import{s as ae}from"./project-router-CPgPVoBJ.js";import{t as M}from"./status-dot-DuorWA5M.js";import{$n as oe,Qn as se,Sr as N,Xn as ce,Zn as le,_ as ue,d as de,f as P,fr as fe,hr as pe,p as me,s as he,u as ge,v as _e,wr as ve,xr as ye}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{u as r}from"./host-context-iTMFRMT5.js";import{ai as i,cr as a,lr as o,n as s,sr as c}from"./toaster-Dglox5F-.js";import{o as l}from"./dist-CCX8mhHc.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{t as f}from"./check-OP-CVgZG.js";import{t as p}from"./chevron-down-CHGyCDBH.js";import{n as m,t as h}from"./circle-x-7nTlobAF.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{t as y}from"./loader-circle-CPBhhDbB.js";import{n as ee,t as te}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-CTbToGmi.js";import{n as S,r as C,t as ne}from"./preview-B5bPk6HT.js";import{t as w}from"./square-terminal-B6RYYieR.js";import{t as T}from"./button-BV_AiLj2.js";import{a as E,c as re,i as D,l as O,p as k,r as A,s as ie,t as j}from"./dropdown-menu-NJZfnQCU.js";import{s as ae}from"./project-router-CPgPVoBJ.js";import{t as M}from"./status-dot-DuorWA5M.js";import{$n as oe,Qn as se,Sr as N,Xn as ce,Zn as le,_ as ue,d as de,f as P,fr as fe,hr as pe,p as me,s as he,u as ge,v as _e,wr as ve,xr as ye}from"./index-k2m-s5zD.js";import{n as be,o as xe}from"./thread-state-IooDEE0b.js";var F=u(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Se=u(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ce=u(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),I=u(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),L=u(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),we=u(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),R=u(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),z=u(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),Te=u(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ee=u(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),B=u(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),V=u(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),H=u(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),U=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),W=u(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),G=u(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),K=u(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),q=u(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),J=u(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=u(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Y=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){if(r())return t.onTransport(`blocked`),{send(){},close(){}};let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,o=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,s=null,l,u=!1,d=!1,f=0,p=0,m=()=>typeof document>`u`||c(),h=()=>{if(u||!m())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(o());n.binaryType=`blob`,s=n,n.addEventListener(`open`,()=>{n===s&&(d=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==s)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=i.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(p=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==s||u)return;if(s=null,!d){if(f+=1,f>=2){u=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,f),l=setTimeout(h,Oe);return}if(p>=5){u=!0,t.onTransport(`closed`);return}let e=ke[Math.min(p,ke.length-1)];p+=1,t.onTransport(`reconnecting`,p),l=setTimeout(h,e)})},g=a(e=>{if(!u)if(e)s||h();else{clearTimeout(l),l=void 0;let e=s;s=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),h(),{send(e){s?.readyState===Ae&&s.send(JSON.stringify(e))},close(){u=!0,g(),clearTimeout(l),l=void 0;let e=s;s=null,e?.close()}}}var X=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,X.jsx)(se,{children:(0,X.jsxs)(ce,{children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:l(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[860px]:gap-1.5 @min-[860px]:px-2.5`,n),children:[(0,X.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,X.jsx)(le,{children:`Experimental`})]})}):e?(0,X.jsx)(se,{children:(0,X.jsxs)(ce,{children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:l(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,X.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(le,{children:`Experimental`})]})}):(0,X.jsxs)(`span`,{"data-slot":`preview-experimental`,className:l(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,X.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Ne({text:e,source:t,onCopy:n,className:r}){let i=e.replace(/\s+$/,``).split(`
|
|
2
2
|
`);return(0,X.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:l(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,r),children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${i.length} ${i.length===1?`line`:`lines`} · ${t}`]}),(0,X.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,X.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Pe=/^([a-z][a-z0-9+.-]*):/i;function Fe(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Pe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Ie(n):Ie(`http://${n}`)}function Ie(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Le(e){return e.replace(/^https?:\/\//i,``)}var Re=`https://github.com/hearsay-tools/squawk#environment-variables`;function ze({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,X.jsx)(Ue,{state:e,actions:t});case`downloading`:return(0,X.jsx)(Ge,{state:e,actions:t});case`download-failed`:return(0,X.jsx)(Ke,{state:e,actions:t});case`sandbox-failed`:return(0,X.jsx)(qe,{state:e,actions:t});case`browser-exited`:return(0,X.jsx)(Je,{state:e,actions:t});case`needs-approval`:return(0,X.jsx)(Ze,{state:e,actions:t});case`port-held`:return(0,X.jsx)(Qe,{state:e,actions:t});case`server-starting`:return(0,X.jsx)($e,{state:e,actions:t});case`server-stalled`:return(0,X.jsx)(et,{state:e,actions:t});case`server-exited`:return(0,X.jsx)(tt,{state:e,actions:t});case`server-stopped`:return(0,X.jsx)(nt,{state:e,actions:t});case`loading`:return(0,X.jsx)(it,{step:e.step,url:n});case`worktree-removed`:return(0,X.jsx)(at,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,X.jsx)(ot,{actions:t});case`taken-over`:return(0,X.jsx)(ct,{state:e,actions:t})}}function Z({icon:e,title:t,children:n,state:r}){return(0,X.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,X.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Q=({children:e})=>(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),$=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Be({server:e}){return(0,X.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(w,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:`Runs ${P(e.command)} in this task's worktree, on the host.`})]})}function Ve({copy:e,command:t,label:n}){return(0,X.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,X.jsx)(`span`,{children:n}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,X.jsx)(N,{className:`size-4`,"aria-hidden":`true`})})]}),(0,X.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function He({server:e,status:t}){return(0,X.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,X.jsx)(M,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,X.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,X.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,X.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,X.jsx)(`span`,{children:`cwd`}),(0,X.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,X.jsx)(`div`,{className:`mt-2.5`,children:(0,X.jsx)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(I,{}),title:`This host has no browser yet`,children:[(0,X.jsx)(Q,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:t.download,children:[(0,X.jsx)(I,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,X.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function We(e){return Math.round(e/1e6)}function Ge({state:e,actions:t}){let n=(0,Y.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(I,{}),title:`Downloading Chromium`,children:[(0,X.jsx)(Q,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:`${We(e.received)} of ${We(e.total)} MB · ${r}%`}),o===void 0?null:(0,X.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ke({state:e,actions:t}){return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(q,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,X.jsx)(Q,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,X.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.download,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,X.jsxs)(T,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(G,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,X.jsx)(Q,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,X.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,X.jsxs)(T,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,X.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Je({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(h,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,X.jsx)(Q,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,X.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,X.jsxs)(T,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Ye=2;function Xe(e){let[t,n]=(0,Y.useState)(()=>Date.now());return(0,Y.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ze({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:r?(0,X.jsx)(J,{className:`text-pending-strong`}):(0,X.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,X.jsx)(Q,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,X.jsx)(He,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,X.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Qe({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(q,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,X.jsx)(Q,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,r=Xe(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,Y.useState)(()=>Date.now());(0,Y.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Ye-(r-a)/1e3));return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,X.jsx)(Q,{children:`Squawk ran ${P(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,X.jsx)(y,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,X.jsx)(Ne,{text:e.logTail.join(`
|
|
3
3
|
`),source:P(n.command),onCopy:t.copy}):null,(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(z,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,X.jsx)(Q,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,X.jsx)(Ne,{text:e.logTail,source:P(n.command),onCopy:t.copy}),(0,X.jsxs)($,{children:[(0,X.jsx)(T,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,X.jsx)(T,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function tt({state:e,actions:t}){let{server:n}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(h,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,X.jsx)(Q,{children:`${P(n.command)} stopped.`}),(0,X.jsx)(Ne,{text:e.logTail,source:P(n.command),onCopy:t.copy}),(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,X.jsx)(Be,{server:n})]})}function nt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(te,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,X.jsx)(Q,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Le(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Le(e.lastUrl)}.`}),(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,X.jsx)(Be,{server:n})]})}var rt=[`browser`,`page`,`frame`];function it({step:e,url:t}){let n=rt.indexOf(e),r=t?Le(t):`the page`;return(0,X.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,X.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${r}`,active:`Opening ${r}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let r=t<n,i=t===n;return(0,X.jsxs)(`li`,{"aria-current":i?`step`:void 0,className:l(`flex items-center gap-3`,i?`font-semibold text-foreground`:r?`text-foreground`:`text-soft-foreground`),children:[r?(0,X.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):i?(0,X.jsx)(y,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,X.jsx)(Ce,{className:`size-5 text-border`,"aria-hidden":`true`}),r?e.done:i?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(we,{}),title:`This task's worktree is gone`,children:[(0,X.jsx)(Q,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,X.jsx)(xe,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function ot({actions:e}){return(0,X.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(Me,{})}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,X.jsx)(H,{})}),(0,X.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,X.jsx)(Q,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,X.jsxs)($,{children:[(0,X.jsx)(T,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,X.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function st(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function ct({state:e,actions:t}){let n=st(e.by);return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(V,{}),title:`Preview is open somewhere else`,children:[(0,X.jsx)(Q,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.useHere,children:[(0,X.jsx)(I,{"aria-hidden":`true`}),`Use it here`]}),(0,X.jsx)(T,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function lt({attempt:e,exhausted:t,onReconnect:n}){return(0,X.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,X.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,X.jsx)(T,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,X.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,X.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,X.jsx)(Q,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),i?(0,X.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,X.jsx)(J,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,X.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,X.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,X.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,X.jsx)(M,{tone:`success`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,X.jsx)(T,{variant:`outline`,size:`sm`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,X.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,X.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,X.jsx)(`ul`,{children:e.map(e=>{let r=ge(e,t),i=me(r);return(0,X.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,X.jsx)(M,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,X.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>n(e.port),children:de(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,X.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(v,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function dt({dialog:e,onResult:t}){let[n,r]=(0,Y.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,Y.useRef)(null),o=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,Y.useRef)(t);s.current=t,(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,X.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,X.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-card-edge bg-card p-4 shadow-modal`,children:[(0,X.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,X.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,X.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,X.jsx)(T,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,X.jsx)(T,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var ft=10,pt=500,mt=500,ht=4,gt=16,_t=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function vt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function yt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var bt=[`left`,`middle`,`right`];function xt(e,t,n,r){let i=vt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:bt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:_t(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=vt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=ft)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=pt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[xt(`mouseMoved`,t,a,{button:`none`,buttons:0}),xt(`mousePressed`,t,a,{button:`left`,buttons:1}),xt(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=mt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=ht;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[xt(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[xt(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[xt(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=vt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?gt:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:_t(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:_t(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:_t(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,Y.useRef)(null),i=(0,Y.useRef)(yt({left:0,top:0},e)),a=(0,Y.useRef)(e);a.current=e;let o=(0,Y.useRef)(t);o.current=t;let s=(0,Y.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,Y.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,Y.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,Y.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,Y.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,X.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:r,onSize:i,renderInput:a,children:o}){let s=(0,Y.useRef)(0),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),[f,p]=(0,Y.useState)(null),m=(0,Y.useRef)(i);m.current=i,(0,Y.useImperativeHandle)(e,()=>({async draw(e){let t=++s.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!c()))try{let i=await Nt(e);try{if(t!==s.current||!c()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,Y.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,X.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:l(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,X.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:r},className:l(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,X.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),a?.({canvas:d.current,scale:g,viewport:h})]}):null,o]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:_},{w:820,h:1180,icon:K},{w:1440,h:900,icon:ee}],Ht=`shrink-0`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,Y.useState)(()=>Date.now());return(0,Y.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,X.jsx)(M,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,X.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,X.jsx)(M,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[960px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`max-w-[9rem] min-w-0 gap-1.5 @min-[760px]:max-w-[11rem]`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,X.jsx)(M,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,X.jsx)(C,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:r}),e?(0,X.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,X.jsx)(p,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,X.jsx)(M,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,X.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,X.jsx)(f,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,Y.useRef)(null),a=e.urlInputRef??i,o=(0,Y.useRef)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),f=(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,X.jsx)(F,{"aria-hidden":`true`})}),p=(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,X.jsx)(d,{"aria-hidden":`true`})}),m=(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,X.jsx)(W,{"aria-hidden":`true`})}),h=e.onSession?(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1`,onClick:e.onSession,children:[(0,X.jsx)(ve,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,X.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,X.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,X.jsx)($t,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:u}),{agentListed:v}=Xt(e),y=e.servers.length+ +!!v>=2,ee=y||e.adopted,te={back:f,forward:p,reload:m,address:_,more:(0,X.jsx)(an,{props:e,compact:t}),session:h,progress:g};return t?(0,X.jsx)(on,{props:e,elements:te}):(0,X.jsx)(sn,{props:e,elements:te,switcher:y,crowded:ee,input:a,focusUrlAfterMenu:o})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(qt,{current:i,agentShown:o})}),(0,X.jsxs)(A,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,X.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=me(ge(t,e.serverStates));return(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,X.jsx)(M,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,X.jsx)(f,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,X.jsx)(O,{}),(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,X.jsx)(g,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:t,draft:n,setDraft:r,focused:i,setFocused:a}){let{url:o,adopted:s}=e;return(0,X.jsxs)(`div`,{className:`relative flex min-w-20 flex-1 items-center`,children:[(0,X.jsx)(g,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(i?o:Le(o)),title:o||void 0,className:l(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,s?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;a(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{a(!1),r(null)},onChange:e=>r(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??o),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),s&&!i?(0,X.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,X.jsx)(Te,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,X.jsx)(B,{"aria-hidden":`true`}):(0,X.jsx)(ee,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:l(`hidden @min-[620px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,X.jsx)(p,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,X.jsxs)(A,{align:`start`,className:`min-w-56`,children:[(0,X.jsxs)(D,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,X.jsx)(B,{"aria-hidden":`true`}),`Fit`,(0,X.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,X.jsx)(f,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,X.jsxs)(D,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,X.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,X.jsx)(f,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,X.jsx)(ie,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,X.jsx)(re,{value:e.value,"data-quality":e.value,className:l(`items-start`,n&&`min-h-11`),children:(0,X.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,X.jsx)(R,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[680px]:inline`,children:Rt(t)}),(0,X.jsx)(p,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,X.jsxs)(A,{align:`start`,className:`w-64`,children:[(0,X.jsx)(E,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,X.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,X.jsx)(Kt,{stats:e,shrunk:n}):t?(0,X.jsxs)(`span`,{"data-slot":`preview-status`,role:`img`,"aria-label":t.label,title:t.label,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,X.jsx)(M,{tone:t.tone,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[760px]:inline`,children:t.label})]}):null}function an({props:e,compact:t}){let{stats:n,navEnabled:r,url:i,current:a,adopted:o}=e;return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,X.jsx)(ye,{"aria-hidden":`true`})})}),(0,X.jsxs)(A,{align:`end`,className:`min-w-64`,children:[n&&!t?(0,X.jsx)(E,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(n)}):null,(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!r,onSelect:()=>e.onReload(!0),children:[(0,X.jsx)(U,{"aria-hidden":`true`}),`Reload without cache`]}),(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:i===``,onSelect:e.onCopyUrl,children:[(0,X.jsx)(pe,{"aria-hidden":`true`}),`Copy page URL`]}),a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{}),o?(0,X.jsxs)(D,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,X.jsx)(Ee,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${a.label} :${a.port}`}),(0,X.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,X.jsxs)(D,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(a.port),children:[(0,X.jsx)(Se,{"aria-hidden":`true`}),`Stop server · ${a.label} :${a.port}`]})]}):null,t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{}),(0,X.jsx)(E,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,X.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,X.jsx)(O,{}),(0,X.jsxs)(D,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,X.jsx)(fe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,X.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,X.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,X.jsx)(M,{tone:`success`,"aria-hidden":`true`}):null,(0,X.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=t;return(0,X.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1 border-b border-border bg-background px-2 py-2 @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,children:[m,l,u,d,n?(0,X.jsx)(Qt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,X.jsx)(en,{props:e}),(0,X.jsx)(nn,{props:e}),(0,X.jsx)(rn,{stats:s,status:c,crowded:r}),o?(0,X.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,X.jsx)(fe,{"aria-hidden":`true`})}),h]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,X.jsx)(ze,{...n,actions:o})}case`empty`:return(0,X.jsx)(ut,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,Y.useState)(un);return(0,Y.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>s(`Copied`),()=>s(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:a}){let l=dn(),u=(0,Y.useRef)(l);u.current=l;let d=o(),f=(0,Y.useRef)(crypto.randomUUID()),p=(0,Y.useRef)(!1),m=ae(),h=_e(ue,!1),[g,_]=(0,Y.useState)(0),[v,y]=(0,Y.useState)({state:`connecting`,attempt:0}),[ee,te]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(void 0),[S,C]=(0,Y.useState)(void 0),[ne,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(void 0),[re,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(void 0),[A,ie]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(void 0),[N,ce]=(0,Y.useState)(void 0),[le,de]=(0,Y.useState)(void 0),[P,fe]=(0,Y.useState)(`fit`),[pe,me]=(0,Y.useState)(zt),[he,ge]=(0,Y.useState)(null),[ve,ye]=(0,Y.useState)(void 0),[be,xe]=(0,Y.useState)(0),F=(0,Y.useRef)(void 0),Se=(0,Y.useRef)(null),Ce=(0,Y.useRef)(null),I=(0,Y.useRef)(void 0),L=(0,Y.useRef)(void 0),we=(0,Y.useRef)(pe);we.current=pe;let R=(0,Y.useRef)({port:T,stage:S,agent:re});R.current={port:T,stage:S,agent:re};let z=(0,Y.useRef)([]),Te=(0,Y.useRef)(void 0),Ee=(0,Y.useRef)(!1),B=(0,Y.useRef)(!1),V=(0,Y.useCallback)(e=>{B.current&&F.current?.send(e)},[]),H=(0,Y.useRef)([]),U=(0,Y.useCallback)(e=>{B.current?F.current?.send(e):H.current.push(e)},[]);(0,Y.useEffect)(()=>{let t;return t=je({projectId:m??`default`,runId:e.id},{onFrame(e){if(!c())return;let n=Date.now();z.current.push({at:n,bytes:e.size}),Ee.current||(Ee.current=!0,M(!0)),(Se.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&xe(e=>e+1),L.current!==void 0&&hn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return w(e.url);case`cursor`:return se(e.cursor);case`dialog`:return ce(e);case`pong`:Te.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:x(e.by),B.current=!1,H.current=[],t?.close();return}},onTransport(e,n){if(B.current=e===`open`,y({state:e,attempt:n??0}),(e===`blocked`||e===`closed`)&&(H.current=[]),e===`open`){te(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:f.current,resume:p.current,quality:we.current,dpr:u.current}),p.current=!0);for(let e of H.current.splice(0))t?.send(e)}}}),F.current=t,()=>{B.current=!1,H.current=[],t?.close(),F.current===t&&(F.current=void 0)}},[m,e.id,g]);let W=d&&v.state===`open`&&b===void 0,G=h||P===`fit`?he:P;(0,Y.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&V({t:`resize`,w:G.w,h:G.h,...l===1?{}:{dpr:l}})},[G?.w,G?.h,l,W,S?.stage,be,V]),(0,Y.useEffect)(()=>{if(!W)return;let e=setInterval(()=>V({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[W,V]);let K=W&&S?.stage===`streaming`;(0,Y.useEffect)(()=>{if(!K){de(void 0);return}let e=setInterval(()=>{let e=Date.now();z.current=z.current.filter(t=>e-t.at<=mn);let t={fps:z.current.length,kbps:Math.round(z.current.reduce((e,t)=>e+t.bytes,0)/1024),...Te.current===void 0?{}:{rttMs:Te.current},...z.current.length>0?{lastFrameAt:z.current.at(-1).at}:{}};de(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[K]),(0,Y.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,Y.useEffect)(()=>{O&&r?.(O)},[O,r]);let q=(0,Y.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,ie(!0),C(void 0),x(void 0),ye(void 0),w(t),E(`port`in e?e.port:void 0),D(`agent`in e),k(yn(e)),V({t:`open`,target:e,viewerId:f.current,quality:we.current,dpr:u.current}),p.current=B.current},[V]),J=(0,Y.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,q]),De=(0,Y.useCallback)(()=>q({agent:!0},``),[q]);(0,Y.useEffect)(()=>{if(n?.agent){if(R.current.agent&&R.current.stage?.stage===`streaming`)return;De();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?J(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||R.current.port===n.port&&R.current.stage?.stage===`streaming`&&n.run!==!0||J(n.port,n.run===!0))},[n]);let Oe=!A&&!b&&v.state!==`blocked`,ke=vn(n,t);(0,Y.useEffect)(()=>{Oe&&!ke&&Ce.current?.focus()},[Oe,ke]);let Ae=e=>{let n=Fe(e,t);if(n.kind===`error`)return ye(n.message);if(n.kind===`server`)return J(n.port);if(R.current.stage?.stage===`streaming`&&!R.current.agent)return I.current={url:n.url},L.current=void 0,E(void 0),k({url:n.url}),ye(void 0),w(n.url),V({t:`nav`,url:n.url});q({url:n.url},n.url)},X=(0,Y.useCallback)(e=>{we.current=e,me(e),Bt(e),V({t:`quality`,quality:e})},[V]),Me=()=>{p.current=!1,x(void 0),y({state:`connecting`,attempt:0}),Ee.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:b,stage:S,url:ne,port:T,agent:re,hasFrame:j,cursor:oe,dialog:N,setDialog:ce,stats:le,viewport:P,setViewport:fe,quality:pe,chooseQuality:X,setStageSize:ge,addressError:ve,stageHandle:Se,urlInput:Ce,send:V,connected:W,streaming:K,openServer:J,openAgent:De,empty:Oe,navigate:Ae,reconnect:Me,actions:(0,Y.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>{B.current?V({t:`run`,port:e}):s(`The preview is reconnecting. Run the server again once it is back.`,{tone:`danger`})},stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:a,useHere:Me,copy:gn}),[V,U,a])}}function xn(e){return(0,X.jsx)(S,{onClose:e.onClose,children:(0,X.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:te,addressError:b,urlInput:x,send:S,streaming:C,openServer:ne,openAgent:w,empty:T,navigate:E,actions:re}=s,D=n.find(e=>e.port===m),O=f?.stage===`streaming`&&f.adopted,k=u&&(l.state===`reconnecting`||l.state===`closed`),{content:A,dim:ie}=cn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),j=ln(A,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:re});return(0,X.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,X.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:Sn(l,u,d!==void 0,f),urlInputRef:x,onSession:a,onNavigate:E,onBack:()=>S({t:`back`}),onForward:()=>S({t:`forward`}),onReload:e=>S({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>ne(e),onPickAgent:w,onViewport:y,onQuality:te,onCopyUrl:()=>gn(p),onStop:re.stop,onClose:o}),b?(0,X.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:b}):null,(0,X.jsx)(Tn,{transportState:s,overlay:j,dim:ie,lost:k})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,X.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,X.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,X.jsx)(lt,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,X.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,X.jsx)(dt,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=ne(e);return(0,Y.useMemo)(()=>{let e=new Map;for(let n of be(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=he(e.run.id);return(0,X.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{En as t,Ft as n,U as r,xt as i}from"./queries-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{En as t,Ft as n,U as r,xt as i}from"./queries-DHjNE2es.js";import{Lt as a,n as o}from"./toaster-Dglox5F-.js";import{y as s}from"./design-icons-QbNMZniQ.js";import{n as c,t as l}from"./open-in-menu-CbPtuWnJ.js";import{s as u}from"./project-router-CPgPVoBJ.js";import{Rn as d}from"./index-k2m-s5zD.js";import{n as f}from"./settings-field-AyinSFR_.js";var p=e();function m(){let e=u(),t=i().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function h(e){navigator.clipboard.writeText(e).then(()=>o(`Project folder copied`)).catch(()=>o(e))}function g(){let e=m(),t=n().data?.homeDir??null;return e===null?null:(0,p.jsx)(f,{wide:!0,title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,p.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,p.jsx)(d,{"data-slot":`project-location-path`,value:e,bases:{home:t,root:null},wrap:!0,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] text-foreground`}),(0,p.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>h(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,p.jsx)(s,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,p.jsx)(_,{root:e})]})]})})}function _({root:e}){let n=r(),i=t({mutationFn:e=>a(e),onError:e=>o(e.message,{tone:`danger`})}),s=(n.data?.targets??[]).filter(e=>c(e.id)===void 0).map(e=>({target:e}));return s.length===0?null:(0,p.jsx)(l,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:i.isPending,choices:s,onPick:e=>i.mutate(e,{onSuccess:()=>o(`Opening the project folder in ${s.find(t=>t.target.id===e)?.target.label??e}`)})})}export{m as n,g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{Dt as i,En as a,Ft as o,Nt as s,Rt as c,an as l,xt as u,zt as d}from"./queries-DQVUxiSU.js";import{Ji as f,n as p,un as m}from"./toaster-Dglox5F-.js";import{n as h}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as g}from"./dist-CCX8mhHc.js";import{k as _,mt as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./button-BV_AiLj2.js";import{n as b,r as x,t as S}from"./popover-BQolmvDR.js";import{t as C}from"./centered-state-N8vWM_Hw.js";import{$t as w,Rn as T,an as ee,en as te,in as E,nn as D,on as O,rn as k,tn as A,ur as j}from"./index-6oRe52sM.js";import{t as M}from"./option-select-B76TaZGm.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-AyinSFR_.js";import{t as L}from"./use-path-bases-DxT4eodL.js";import{r as R}from"./settings-save-bar-De7cR5EO.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-BlEEuyae.js";var V=t(n(),1),H=r();function U(){let e=i();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(ee,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(k,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(T,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(E,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(te,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=u();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(C,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(j,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:o,footer:s,refreshProjects:c=!1}){let u=f(),d=a({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(l.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:l.fsBrowseRoot}):c&&u.invalidateQueries({queryKey:l.projects})}}),[p,h]=z(t),g=p.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{h(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${o}-root`,value:p,disabled:d.isPending,placeholder:i,onChange:e=>{h(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:s}):(0,H.jsxs)(`p`,{"data-slot":`projects-${o}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>c(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(T,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(T,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(y,{asChild:!0,variant:`outline`,children:(0,H.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=s(),[i,a]=(0,V.useState)(``),[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(-1),f=(0,V.useRef)(null),m=e.tags??[],h=d(t,m,i),_=o&&h.length>0,y=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},C=t=>{let n=t.trim().slice(0,32);if(u(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),y([...m,n])}},w=e=>{y(m.filter(t=>t!==e))},T=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>w(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(S,{open:_,onOpenChange:c,children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?T:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&l>=0?`${T}-${l}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:i,maxLength:32,disabled:r.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),u(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;u(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),c(!1),u(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),C(l>=0?h[l]??i:i);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&i===``&&m.length>0){e.preventDefault();let t=m[m.length-1];t!==void 0&&w(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(x,{align:`start`,sideOffset:4,id:T,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${T}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{C(e),f.current?.focus()},onMouseEnter:()=>u(t),className:g(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=s(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(M,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{Dt as i,En as a,Ft as o,Nt as s,Rt as c,an as l,xt as u,zt as d}from"./queries-DHjNE2es.js";import{Ji as f,n as p,un as m}from"./toaster-Dglox5F-.js";import{n as h}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as g}from"./dist-CCX8mhHc.js";import{k as _,mt as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./button-BV_AiLj2.js";import{n as b,r as x,t as S}from"./popover-BQolmvDR.js";import{t as C}from"./centered-state-N8vWM_Hw.js";import{$t as w,Rn as T,an as ee,en as te,in as E,nn as D,on as O,rn as k,tn as A,ur as j}from"./index-k2m-s5zD.js";import{t as M}from"./option-select-C6d3jHce.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-AyinSFR_.js";import{t as L}from"./use-path-bases-C7DRxlRi.js";import{r as R}from"./settings-save-bar-BkU1JDt3.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-BlEEuyae.js";var V=t(n(),1),H=r();function U(){let e=i();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(ee,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(k,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(T,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(E,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(te,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=u();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(C,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(j,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:o,footer:s,refreshProjects:c=!1}){let u=f(),d=a({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(l.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:l.fsBrowseRoot}):c&&u.invalidateQueries({queryKey:l.projects})}}),[p,h]=z(t),g=p.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{h(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${o}-root`,value:p,disabled:d.isPending,placeholder:i,onChange:e=>{h(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:s}):(0,H.jsxs)(`p`,{"data-slot":`projects-${o}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>c(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(T,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(T,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(y,{asChild:!0,variant:`outline`,children:(0,H.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=s(),[i,a]=(0,V.useState)(``),[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(-1),f=(0,V.useRef)(null),m=e.tags??[],h=d(t,m,i),_=o&&h.length>0,y=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},C=t=>{let n=t.trim().slice(0,32);if(u(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),y([...m,n])}},w=e=>{y(m.filter(t=>t!==e))},T=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>w(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(S,{open:_,onOpenChange:c,children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?T:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&l>=0?`${T}-${l}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:i,maxLength:32,disabled:r.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),u(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;u(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),c(!1),u(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),C(l>=0?h[l]??i:i);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&i===``&&m.length>0){e.preventDefault();let t=m[m.length-1];t!==void 0&&w(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(x,{align:`start`,sideOffset:4,id:T,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${T}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{C(e),f.current?.focus()},onMouseEnter:()=>u(t),className:g(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=s(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(M,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{En as r,O as i,Ut as a,in as o}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{En as r,O as i,Ut as a,in as o}from"./queries-DHjNE2es.js";import{Ji as s,R as c,n as l}from"./toaster-Dglox5F-.js";import{o as u}from"./dist-CCX8mhHc.js";import{K as d,X as f,l as p,mt as m,rt as h,st as g,u as _}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-BV_AiLj2.js";import{i as y,r as b,t as x}from"./popover-BQolmvDR.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-4D8sPZJy.js";import{f as O,i as k,p as A,u as j}from"./skills-pM_PouEs.js";import{t as M}from"./centered-state-N8vWM_Hw.js";import{at as N,ct as P,ft as F,lr as I,lt as L}from"./index-k2m-s5zD.js";import{t as R}from"./textarea-BGp28xFr.js";import{n as z,t as B}from"./settings-field-AyinSFR_.js";import{r as V}from"./settings-save-bar-BkU1JDt3.js";import{n as H,t as U}from"./saved-draft-BwzBc-_Y.js";import{t as W}from"./settings-list-detail-BlEEuyae.js";var G=e(t(),1),K=n();function q({template:e}){let t=e.text.trim().split(`
|
|
2
2
|
`)[0]??``,n=e.skills?.length??0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`settings-list-row-title`,children:e.label.trim()||`Untitled template`}),(0,K.jsxs)(`span`,{className:`settings-list-row-meta`,children:[t||`No instructions yet`,n>0?` · ${n} skill${n===1?``:`s`}`:``]})]})}function J(){let e=i();return e.isPending?(0,K.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,K.jsx)(M,{icon:(0,K.jsx)(d,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,K.jsx)(Y,{initial:L(e.data.promptTemplates)})}function Y({initial:e}){let t=s(),n=a(),u=i(),[d,p]=H(e,U),[h,_]=(0,G.useState)(null),y=r({mutationFn:e=>c({promptTemplates:e}),onSuccess:(e,n)=>{t.setQueryData(o.uiState,e),p(t=>U(t,n)?L(e.promptTemplates):t)},onError:e=>l(e.message,{tone:`danger`})}),b=JSON.stringify(d)!==JSON.stringify(e),x=d.some(e=>e.label.trim()===``||e.text.trim()===``);V({dirty:b,invalid:x,save:()=>y.mutateAsync(d),discard:()=>p(e)});let S=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),C=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),w=e=>{let t=d.findIndex(t=>t.id===e),n=d.filter(t=>t.id!==e);p(n),_(n[Math.min(t,n.length-1)]?.id??null)};return(0,K.jsx)(`div`,{"data-slot":`prompt-templates-section`,"data-reports-dirty":``,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,K.jsxs)(z,{wide:!0,title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,K.jsx)(W,{slot:`prompt-template-list`,label:`Prompt templates`,items:d,itemKey:e=>e.id,selectedKey:h,onSelect:_,empty:(0,K.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one, or reset to the built-ins.`}),row:e=>(0,K.jsx)(q,{template:e}),detail:e=>(0,K.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:B,children:`Template label`}),(0,K.jsx)(I,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>S(e.id,{label:t.target.value}),className:`flex-1 border-border bg-background`})]}),(0,K.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:B,children:`Instructions`}),(0,K.jsx)(R,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>S(e.id,{text:t.target.value}),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,K.jsx)(`p`,{className:B,children:`Apply automatically with skills`}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(X,{label:e.label,skills:n.data??[],skillUsage:u.data?.skillUsage,selected:e.skills??[],onToggle:t=>C(e.id,t)}),(e.skills??[]).map(t=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>C(e.id,t),className:`inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,K.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,K.jsxs)(v,{type:`button`,className:`self-start`,variant:`danger-ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>w(e.id),children:[(0,K.jsx)(g,{"aria-hidden":`true`,className:`size-3`}),`Delete template`]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,K.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,onClick:()=>{let e=P();p(t=>[...t,{id:e,label:``,text:``}]),_(e)},children:[(0,K.jsx)(f,{"aria-hidden":`true`,className:`size-3.5`}),`New template`]}),(0,K.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:y.isPending,onClick:()=>p(N.map(e=>({...e}))),children:`Reset to defaults`}),x?(0,K.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-xs text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function X({label:e,skills:t,skillUsage:n,selected:r,onToggle:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),{mostUsed:d,project:f,global:m,ranked:g}=j(t,s,n),v=(e,t)=>{let n=r.includes(e.id);return(0,K.jsxs)(w,{value:O(e),keywords:A(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>i(e.id),children:[(0,K.jsx)(F,{skill:e,emphasized:t}),n?(0,K.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},O(e))};return(0,K.jsxs)(x,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(y,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:u(`inline-flex h-[26px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,r.length>0&&`text-foreground`),children:[(0,K.jsx)(h,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`Add skill`,(0,K.jsx)(_,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(b,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(D,{shouldFilter:!1,children:[(0,K.jsx)(S,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>l.current?.scrollTo(0,0)}),(0,K.jsxs)(E,{ref:l,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[s.trim()&&!t.some(e=>e.id===s.trim())?(0,K.jsx)(C,{children:(0,K.jsxs)(w,{value:`typed-skill`,onSelect:()=>i(s.trim()),children:[`Use skill id “`,s.trim(),`” (unchecked)`]})}):null,(g?g.length===0:d.length===0&&f.length===0&&m.length===0)?(0,K.jsx)(T,{children:`Nothing matches.`}):null,g?g.length>0?(0,K.jsx)(C,{children:g.map(e=>v(e,k(e)))}):null:(0,K.jsxs)(K.Fragment,{children:[d.length>0?(0,K.jsx)(C,{heading:`Most used`,children:d.map(e=>v(e,k(e)))}):null,f.length>0?(0,K.jsx)(C,{heading:`Project skills`,children:f.map(e=>v(e,!0))}):null,m.length>0?(0,K.jsx)(C,{heading:`Global`,children:m.map(e=>v(e,!1))}):null]})]})]})})]})}export{J as PromptTemplatesSection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{h as n,n as r,p as i}from"./host-context-iTMFRMT5.js";import{$ as a,$n as o,$t as s,A as c,An as l,Ar as u,Bi as d,Br as f,C as p,Cn as m,Cr as ee,Ct as te,D as ne,Dn as h,Dr as g,Dt as _,E as v,En as y,Er as re,Et as b,F as x,Fr as S,G as C,Gi as ie,Hi as ae,Ht as oe,Ii as se,Ir as w,It as ce,J as le,Ji as T,Jt as ue,K as de,Kt as fe,L as pe,Li as E,Mn as D,Mr as me,Mt as O,N as he,Nr as ge,Nt as _e,O as ve,Ot as ye,Pi as be,Pn as xe,Pr as Se,Pt as Ce,Q as we,Qi as Te,Qn as Ee,Qt as De,Ri as Oe,Rr as ke,S as Ae,Sn as je,St as Me,Tn as Ne,Tr as Pe,Ui as Fe,Vi as Ie,Vr as Le,Vt as Re,Wi as ze,Wt as Be,X as Ve,Xn as He,Xt as Ue,Y as We,Yi as Ge,Yt as Ke,Zi as qe,Zt as Je,_n as Ye,_t as Xe,a as Ze,an as Qe,ar as $e,b as et,bn as tt,bt as nt,ca as k,ci as rt,cn as it,ct as at,da as ot,en as st,et as ct,fn as lt,gn as ut,gt as dt,h as ft,hn as pt,in as mt,ir as ht,jn as gt,jr as _t,k as vt,kn as yt,kt as bt,ln as xt,m as St,ma as Ct,mn as wt,n as Tt,nn as Et,oa as Dt,on as Ot,pn as kt,pt as At,q as jt,qt as Mt,ra as Nt,sn as Pt,ta as Ft,tn as It,ua as Lt,v as Rt,vt as zt,wn as Bt,wt as Vt,x as Ht,xn as Ut,xt as Wt,y as Gt,yn as Kt,yt as qt,zi as Jt,zr as Yt}from"./toaster-Dglox5F-.js";import{A as Xt,B as A,F as j,H as M,I as N,N as P,P as F,W as I,Z as Zt,a as Qt,j as L,z as R}from"./live-protocol-CNUmr-VT.js";import{c as $t}from"./dist-CCX8mhHc.js";import{t as en}from"./host-storage-Cr_NKfWy.js";function tn(e,t){return e??t}function nn(e,t){let n=tn(e,t);return n===`1`||n===`true`}function rn(e,t,n){return e?.trim()||tn(t,n)||``}var an=class extends qe{#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||on(),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=Te({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),Zt.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function on(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var sn=class extends Ct{#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),Lt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ft(t.mutationKey)!==Ft(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??on();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){Zt.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 cn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function ln(e,t,n){let r=e.slice(0);return r[t]=n,r}var un=class extends Ct{#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,Zt.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||!Lt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(cn(e,n).forEach(e=>{e.destroy()}),cn(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=k(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 Ge(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=ln(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)&&Zt.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},z=e(t(),1);function dn({queries:e,...t},n){let r=T(n),i=ie(),a=ze(),o=z.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Oe(e);let t=r.getQueryCache().get(e.queryHash);Ie(e,a,t)}),Fe(a);let[s]=z.useState(()=>new un(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;z.useSyncExternalStore(z.useCallback(e=>f?s.subscribe(Zt.batchCalls(e)):Dt,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),z.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>d(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&d(n,e)?Jt(n,new Ge(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&ae({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function B(e,t){let n=T(t),[r]=z.useState(()=>new sn(n,e));z.useEffect(()=>{r.setOptions(e)},[r,e]);let i=z.useSyncExternalStore(z.useCallback(e=>r.subscribe(Zt.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=z.useCallback((e,t)=>{r.mutate(e,t).catch(Dt)},[r]);if(i.error&&ot(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function V(e={}){let t=e.projectId??n(),r=e.cacheScope??(e.boot?`default`:t);return e.hostId===void 0?{projectId:t,cacheScope:r}:{projectId:t,cacheScope:r,hostId:e.hostId}}function H(e,t={}){return{...V(t),runId:e}}function fn(){return nn(void 0,void 0)}function U(e){return!fn()&&e}async function pn(e){return l(await h.api.v1.health.$get({},y(e)),`/health`)}async function mn(e){return gt(await h.api.v1.hosts.$get({},y(e)),`/hosts`,Se)}async function hn(e){return gt(await h.api.v1.hosts.projects.$get({},y(e)),`/hosts/projects`,S)}async function gn(e){return gt(await h.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},y(e)),`/hosts/runs-index`,w)}async function _n(e){return l(await h.api.v1.workspace[`ui-state`].$get({},y(e)),`/workspace/ui-state`)}async function vn(e,t={}){return l(await h.api.v1.workspace[`ui-state`].$put({json:e},{init:{...$t({keepalive:t.keepalive})}}),`/workspace/ui-state`)}A({runs:N(`summary`).optional()});var yn=I().min(1),bn=R().int().positive(),xn=A({project:yn,seq:bn,run:Le,relationships:I().min(1)}),Sn=A({project:yn,seq:bn,id:I().min(1)}),Cn=A({generation:I().min(1),seq:R().int().nonnegative()}),wn=A({project:yn,usage:M(I(),ke)});A({runs:P(f),referenceStatuses:Yt,perProjectLimit:R(),truncated:P(I()),generation:I().min(1),eventSeq:R().int().nonnegative()});function Tn(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=xn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=Sn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=wn.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=Cn.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var En=[re,Pe,g,ee];function Dn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case re:{let e=_t.safeParse(n);return e.success?{type:`host-run-summary`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,summary:e.data.run}:null}case Pe:{let e=u.safeParse(n);return e.success?{type:`host-run-deleted`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,id:e.data.id}:null}case g:{let e=me.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case ee:{let e=ge.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function On(){let e,t;return{ready(n){t=void 0;let r=e!==void 0&&n>e;return e=n,r},frame(n){if(t!==void 0&&n<=t)return!1;let r=e!==void 0&&n!==e+1;return e=n,r},seed(n){t=t===void 0?n:Math.max(t,n),e=e===void 0?n:Math.max(e,n)},reset(){e=void 0,t=void 0}}}function kn(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function An(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var jn=Object.freeze({});function Mn(){let e=jn,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function Nn(e){return e.type===`run`?e.run.id:e.id}function Pn(e,t){return{...e,runs:t}}function Fn(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var In=new WeakMap,Ln=new WeakMap;function Rn(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i],o=t(a),s=n.get(o);if(s||(s=new Map,n.set(o,s)),s.set(a.id,i),a.usage!==void 0){let e=r.get(o);e||(e=new Set,r.set(o,e)),e.add(a.id)}}return In.set(e,n),Ln.set(e,r),{positions:n,liveUsage:r}}var zn=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=In.get(e),r=Ln.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=Rn(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=Rn(this.runs,this.scopeOf);this.positions=e.positions,this.liveUsage=e.liveUsage,this.liveUsageCopied=!0}mutableLiveUsage(){if(!this.liveUsageCopied){let e=new Map;for(let[t,n]of this.liveUsage)e.set(t,new Set(n));this.liveUsage=e,this.liveUsageCopied=!0,this.copied&&Ln.set(this.runs,this.liveUsage)}return this.liveUsage}at(e,t){return this.positions.get(e)?.get(t)??-1}liveUsageIds(e){return this.liveUsage.get(e)}setLiveUsage(e,t,n){let r=this.mutableLiveUsage();if(n){let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)}else{let n=r.get(e);if(!n)return;n.delete(t),n.size===0&&r.delete(e)}}mutable(){return this.copied||(this.runs=[...this.runs],this.copied=!0,In.set(this.runs,this.positions),Ln.set(this.runs,this.liveUsage)),this.runs}replace(e,t){let n=this.runs[e];return this.mutable()[e]=t,n?.usage!==void 0!=(t.usage!==void 0)&&this.setLiveUsage(this.scopeOf(t),t.id,t.usage!==void 0),this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}},Bn=e=>e.projectId,Vn=(e,t)=>`${e}\u0000${t}`,Hn=e=>Vn(e.hostId,e.projectId);function Un(e,t,n){let r=new zn(e.runs,Bn),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=Zn(i,e.project,e.usage,r);else{let t=qn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function Wn(e,t,n){let r=new zn(e.runs,Hn),i=e.runs,a=new Set,o=!1;for(let s of t){if(s.type===`usage`){i=Xn(i,Vn(s.hostId,s.project),s.usage,r);continue}let{hostId:t,project:c}=s.change,l=e.hosts.find(e=>e.id===t);if(!l||!l.loaded){a.add(t);continue}let u=n?.(t,c);s.change.type===`run`&&u===!1&&(o=!0);let d=Kn(i,s.change,{scope:Vn(t,c),id:Nn(s.change),inScope:e=>e.hostId===t&&e.projectId===c,truncated:l.truncated.includes(c),perProjectLimit:l.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:c,...e})},r);i=d.runs,d.reconcile&&a.add(t)}return{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:o}}function Gn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Kn(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return a?{runs:r.remove(i),reconcile:n.truncated&&a.archived}:{runs:e,reconcile:!1};let{run:o}=t;if(o.delegation?.role===`worker`)return a?{runs:r.remove(i),reconcile:!1}:{runs:e,reconcile:!1};if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=k(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&Fn(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return Yn(e,s,n.inScope,r);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&Fn(c,n.inScope)>n.perProjectLimit}}function qn(e,t,n,r){let{project:i}=t,a=Kn(e.runs,t,{scope:i,id:Nn(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>Gn(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Pn(e,a.runs),reconcile:a.reconcile}}function Jn(e,t){let n;for(let r of e)t(r)&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Yn(e,t,n,r){let i=Jn(e,n),a=i!==void 0&&t.createdAt>i;return t.archived&&!a?{runs:e,reconcile:!1}:{runs:r.insert(t),reconcile:t.archived||i===void 0||t.createdAt<i}}function Xn(e,t,n,r){let i=!1;for(let[e,a]of Object.entries(n)){let n=r.at(t,e);if(n<0)continue;let o=r.runs[n],s=k(o.usage,a);s!==o.usage&&(r.replace(n,{...o,usage:s}),i=!0)}let a=r.liveUsageIds(t);if(a)for(let e of[...a]){if(Object.prototype.hasOwnProperty.call(n,e))continue;let a=r.at(t,e);if(a<0)continue;let o=r.runs[a];if(o.usage===void 0)continue;let{usage:s,...c}=o;r.replace(a,c),i=!0}return i?r.runs:e}function Zn(e,t,n,r){let i=Xn(e.runs,t,n,r);return i===e.runs?e:Pn(e,i)}function Qn(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 $n(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function er(e,t,n){if(e.lastStream===t)e.floor=n===void 0?void 0: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 tr(e){e.stream=void 0}function nr(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Nn(t)]):JSON.stringify([e,t.project,Nn(t)])}function rr(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=nr(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var ir=1e3;function ar(e,t=ir){if(e.changes.size<=t)return;let n=[...e.changes.entries()].sort((e,t)=>e[1].seq-t[1].seq),r=n.length-t,i;for(let t=0;t<r;t+=1){let[r,a]=n[t];e.changes.delete(r),a.generation===e.lastStream&&(i=i===void 0?a.seq:Math.max(i,a.seq))}i!==void 0&&(e.floor=e.floor===void 0?i:Math.max(e.floor,i))}function or(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function sr(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function cr(e,t,n){if(e.stream!==void 0&&e.stream!==t){let n=e.mismatch!==t;return e.mismatch=t,{mismatch:!0,first:n}}let r=e.lastStream===t&&e.floor!==void 0,i=r&&n<e.floor,a=[...e.changes.entries()].filter(([,e])=>e.generation===t);return{mismatch:!1,covered:r,missed:i,own:a,newer:a.map(([,e])=>e).filter(e=>e.seq>n).sort((e,t)=>e.seq-t.seq)}}function lr(e,t,n){if(!sr(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=Un(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return a.covered&&!a.missed&&(e.floor=i),{index:o.index,reconcile:a.missed||o.reconcile}}function ur(e,t,n){if(!sr(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=Wn(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return(a.covered&&!a.missed||e.lastStream===r&&e.floor===void 0)&&(e.floor=i),{index:o.index,reconcile:a.missed,reconcileHosts:o.reconcileHosts,refreshProjects:o.refreshProjects}}function dr(e,t,n){if(e.length===0)return t;let r=In.get(e)??Rn(e,n).positions,i=e.length===t.length,a=!1,o=[];for(let s=0;s<t.length;s+=1){let c=t[s],l=r.get(n(c))?.get(c.id),u=l===void 0?void 0:e[l],d=u===void 0?c:k(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function fr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Bn),r=k(e.referenceStatuses,t.referenceStatuses),i=k(e.truncated,t.truncated);return n===e.runs&&r===e.referenceStatuses&&i===e.truncated&&t.perProjectLimit===e.perProjectLimit&&t.eventSeq===e.eventSeq?e:n===t.runs&&r===t.referenceStatuses&&i===t.truncated?t:{...t,runs:n,referenceStatuses:r,truncated:i}}function pr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Hn),r=k(e.hosts,t.hosts);return n===e.runs&&r===e.hosts&&t.eventSeq===e.eventSeq&&t.warning===e.warning?e:n===t.runs&&r===t.hosts?t:{...t,runs:n,hosts:r}}function mr(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].createdAt??``)>=t[i].createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function hr(e,t,n,r,i){if(t.generation!==e.generation||r.stream!==void 0&&r.stream!==t.generation)return{index:e,fullReconcile:!0,reconcileHosts:[]};let a=[...r.changes.entries()].filter(([,e])=>e.generation===t.generation&&e.hostId===n),o=Wn(t,a.map(([,e])=>e).filter(e=>e.seq>t.eventSeq).sort((e,t)=>e.seq-t.seq).map(e=>({type:`change`,change:e})),i);for(let[e,n]of a)n.seq<=t.eventSeq&&r.changes.delete(e);let s=o.index.hosts.find(e=>e.id===n),c=e.hosts.some(e=>e.id===n),l=s?c?e.hosts.map(e=>e.id===n?s:e):[...e.hosts,s]:e.hosts.filter(e=>e.id!==n);return{index:{runs:mr(e.runs.filter(e=>e.hostId!==n),o.index.runs.filter(e=>e.hostId===n)),hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var gr=[`workspace`,`runs-index`],W=[`main`,`hosts`,`runs-index`],_r=[`workspace`,`projects`],vr=[`main`,`hosts`,`projects`],yr=6e4,br=100,xr=new WeakMap,Sr=new WeakMap;function Cr(e){let t=xr.get(e);return t||(t=Pr(e),xr.set(e,t)),t}function wr(e){let t=Sr.get(e);return t||(t=Rr(e),Sr.set(e,t)),t}function Tr(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cr(t).merge(e)}function Er(e){let t=e.getQueryData(_r)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Dr(e){let t=e.getQueryData(vr)?.hosts;if(!t)return;let n=new Map;for(let e of t)e.projects!==null&&n.set(e.id,new Set(e.projects.map(e=>e.id)));return(e,t)=>n.get(e)?.has(t)}function Or(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 kr(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 Ar(e){return e.type===`host-run-summary`?{type:`run`,hostId:e.hostId,project:e.project,seq:e.seq,run:e.summary}:{type:`deleted`,hostId:e.hostId,project:e.project,seq:e.seq,id:e.id}}function jr(e){let t,n,r=-1/0;return{markWrite(){r=Date.now()},cancelPending:()=>{t!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),t=void 0,clearTimeout(n),n=void 0},schedule(){if(n!==void 0)return;let i=r+250-Date.now();if(i>0){n=setTimeout(e,i);return}n=setTimeout(e,br),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Mr(e){let t,n,r=!1,i=()=>{clearTimeout(t),t=void 0;let a=e().catch(()=>void 0).finally(()=>{n===a&&(n=void 0,r&&(r=!1,i()))});return n=a,a};return{isInFlight(){return n!==void 0},reconcile(e={}){return n?(r=!0,n):e.hold?(t??=setTimeout(()=>{i()},400),Promise.resolve()):i()},stop(){clearTimeout(t),t=void 0,r=!1}}}function Nr(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n!==void 0&&n.state.data===void 0&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t})):e.invalidateQueries({queryKey:t})}function Pr(e){let t=$n(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(gr),c=Mr(()=>Nr(e,gr)),l=()=>{if(!i){if(i=!0,a?.()){o=!0;return}c.reconcile({hold:!0})}},u=()=>{d.cancelPending();let t=n;n=[];let i=s();if(!i||t.length===0)return;let a=Er(e),{index:o,reconcile:l}=Un(i,t.filter(e=>e.generation===i.generation?e.type===`usage`?!r.has(e.project):!r.has(e.change.project)&&e.change.seq>i.eventSeq:!1),a);o!==i&&f(o),l&&c.reconcile({hold:!0})},d=jr(u),f=t=>{d.markWrite(),e.setQueryData(gr,t)};return{ready(e,n){er(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){tr(t)},run(e,i,a=!1){if(r.has(e))return;let o=kr(e,i);if(!rr(t,o,a)){l();return}n.push({type:`change`,change:o,generation:t.stream}),d.schedule()},usage(e,i){if(!r.has(e)){if(t.stream===void 0){l();return}n.push({type:`usage`,project:e,usage:i,generation:t.stream}),d.schedule()}},dropProject(e){r.add(e),or(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=Qn(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=lr(t,n,Er(e));for(let e of r)a.index=Qn(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),Or(i,n,t.stream)??fr(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var Fr=[1e3,2e3,4e3,8e3,15e3],Ir=6e4;function Lr(e,t){e.setQueryData(W,e=>{if(!e)return e;let n=e.hosts.find(e=>e.id===t);return!n||n.stale?e:{...e,hosts:e.hosts.map(e=>e.id===t?{...e,stale:!0}:e)}})}function Rr(e,t=e=>gn({hostId:e}),n=Fr,r=Ir,i=e=>gn({signal:e})){let a=$n(),o=On(),s=new Map,c=new Map,l=new Map,u=0,d,f=[],p=!1,m,ee=!1,te=!1,ne=!1,h,g,_,v=!1,y=0,re=0,b=!1,x=new Map,S=()=>e.getQueryData(W),C=()=>e.getQueryCache().find({queryKey:W,exact:!0}),ie=()=>{ne||(ne=!0,e.invalidateQueries({queryKey:vr,exact:!0}).finally(()=>{ne=!1}))},ae=e=>{let t=l.get(e);t!==void 0&&(clearTimeout(t),l.delete(e))},oe=()=>{d!==void 0&&(clearTimeout(d),d=void 0),u=0},se=()=>{for(let e of l.values())clearTimeout(e);l.clear(),c.clear(),oe()},w=Mr(()=>C()?(te=!0,Nr(e,W)):Promise.resolve()),ce=()=>{if(!p){if(p=!0,m?.()){ee=!0;return}w.reconcile({hold:!0})}},le=()=>{if((C()?.getObserversCount()??0)===0)return;let e=n[u]??r;u+=1,d!==void 0&&clearTimeout(d),d=setTimeout(()=>{d=void 0,w.reconcile()},e)},T=e=>{if((C()?.getObserversCount()??0)===0)return;let t=c.get(e)??0,i=n[t]??r;c.set(e,t+1),ae(e),l.set(e,setTimeout(()=>{l.delete(e),D([e])},i))},ue=t=>{Lr(e,t),T(t)},de=(t,n)=>{let r=S();if(!r)return!1;if(n.generation!==r.generation||a.stream!==void 0&&a.stream!==n.generation)return w.reconcile(),!0;let i=s.get(t)??r.eventSeq;if(n.eventSeq<i)return ue(t),!1;let o=hr(r,n,t,a,Dr(e));if(o.fullReconcile)return w.reconcile(),!0;let l=o.index.hosts.find(e=>e.id===t);l?(s.set(t,n.eventSeq),l.state===`connected`&&l.stale?T(t):(ae(t),c.delete(t))):(ae(t),c.delete(t),s.delete(t));let u=pr(r,o.index);return u!==r&&he(u),o.reconcileHosts.length>0&&D(o.reconcileHosts,{hold:!0}),!1},fe=(t={})=>{let n=C();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:W,exact:!0,refetchType:`none`}),Promise.resolve();if(!S())return w.reconcile(t)},pe=()=>{let t=C();return!t||t.state.fetchStatus!==`fetching`?Promise.resolve():new Promise(n=>{let r=e.getQueryCache().subscribe(e=>{e.query===t&&t.state.fetchStatus!==`fetching`&&(r(),n())})})},E=()=>{clearTimeout(h),h=void 0;let e=y;if(_||v)return(_??Promise.resolve()).then(()=>{if(!(y!==e||x.size===0))return E()});if(g)return g;let n=[...x.entries()];if(x.clear(),b=!1,n.length===0)return Promise.resolve();let r=fe();if(r)return r;let i=e=>{for(let t=e;t<n.length;t+=1){let[e,r]=n[t];x.has(e)||x.set(e,r)}},a=(async()=>{for(let r=0;r<n.length;r+=1){let[a]=n[r];if(y!==e)break;if(v){i(r);break}try{let n=await t(a);if(y!==e)break;if(de(a,n)){i(r+1);break}}catch{if(y===e){if(v){i(r);break}ue(a)}}}})().finally(()=>{g===a&&(g=void 0,!v&&!_&&y===e&&x.size>0&&(b?E():h??=setTimeout(()=>{E()},400)))});return g=a,a},D=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=fe(t);if(n)return n;for(let t of e)x.set(t,++re);return t.hold||(b=!0),g||(t.hold&&!b&&!_&&!v?(h??=setTimeout(()=>{E()},400),Promise.resolve()):E())},me=()=>{O.cancelPending();let t=f;f=[];let n=S();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=Wn(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=s.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),Dr(e));r!==n&&he(r),a&&ie(),i.length>0&&D(i,{hold:!0})},O=jr(me),he=t=>{O.markWrite(),e.setQueryData(W,t)},ge=e=>{let t=new Set(e.filter(e=>e.state===`connected`&&e.stale).map(e=>e.id));for(let e of[...l.keys()])t.has(e)||(ae(e),c.delete(e));for(let e of[...c.keys()])t.has(e)||c.delete(e);for(let e of t)l.has(e)||T(e)},_e=t=>{let n=S(),r=ur(a,t,Dr(e)),i=Or(n,t,a.stream)??(s.clear(),ge(r.index.hosts),(a.stream===t.generation||a.lastStream===t.generation)&&o.seed(t.eventSeq),pr(n,r.index)),c=y;return r.refreshProjects&&queueMicrotask(()=>{y===c&&ie()}),r.reconcile?queueMicrotask(()=>{y===c&&w.reconcile({hold:!0})}):r.reconcileHosts.length>0&&queueMicrotask(()=>{y===c&&D(r.reconcileHosts,{hold:!0})}),i};return{ready(e){let t=a.lastStream;er(a,e),p=!1;let n=S(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,i=t===void 0&&(n!==void 0||C()?.state.fetchStatus===`fetching`),s=te&&w.isInFlight();te=!1,r?o.reset():i&&n&&o.seed(n.eventSeq),(r||ee||i)&&!s?(ee=!1,w.reconcile({hold:!0})):s&&(ee=!1)},detach(){tr(a),o.reset(),te=!1},run(e){let t=o.frame(e.seq),n=Ar(e);if(!rr(a,n,t)){ce();return}ar(a),f.push({type:`change`,change:n,generation:a.stream}),O.schedule(),t&&w.reconcile({hold:!0})},usage(e,t,n){if(a.stream===void 0){ce();return}f.push({type:`usage`,hostId:e,project:t,usage:n,generation:a.stream}),O.schedule()},setUnknownGenerationHandler(e){m=e},fetchFull:e=>{v=!0,clearTimeout(h),h=void 0;let t=y,n=_,r=g,a=(async()=>{if(n&&await n,r&&await r.catch(()=>void 0),y!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);let a=re,o;try{o=await i(e)}catch(n){throw y===t&&!e?.aborted&&le(),n}if(y!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);oe();for(let[e,t]of[...x.entries()])t<=a&&x.delete(e);return _e(o)})(),o;return o=a.then(()=>pe(),()=>void 0).then(()=>{_===o&&(_=void 0,v=!1,y===t&&x.size>0&&E())}),_=o,a},merge:_e,reconcile:w.reconcile,reconcileHosts:D,reconcileFinite(){let t=S();if(!t)return w.reconcile();let n=e.getQueryData(vr)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?w.reconcile():D(r)},flush:me,stop(){y+=1,v=!1,_=void 0,g=void 0,O.cancelPending(),w.stop(),clearTimeout(h),h=void 0,se(),b=!1,x.clear(),f=[]}}}var zr=(e,t,n)=>[`host`,e,t,`runs`,`detail`,n],G={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t,r=n())=>[r,`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n,r)=>{let i=[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)];return r===void 0?i:[`host`,r,...i]},githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},K={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:gr,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)=>[...K.fsBrowseRoot,e,t]};function Br(e,t=!0,n=!1,r){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>_e(V({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function q(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:K.models(t),refetchType:n})}function Vr(e,t=!0,n){return E({...Hr(e,n),enabled:t})}var Hr=(e,t)=>({queryKey:K.models(e,t),queryFn:({signal:n})=>D(e,{signal:n},t),staleTime:300*1e3});function Ur(e,t=!0){let n=dn({queries:e.map(e=>({...Hr(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var Wr=L([`own`,`provider-spanning`]),Gr=A({suggested:P(A({id:I(),label:I(),desc:I()})),retired:P(I())}),Kr=A({id:L([`settings`,`mcp`,`memory`]),label:I(),note:I().optional(),empty:I().optional(),showsUserMcp:N(!0).optional()}),qr=A({label:I(),note:I().optional(),groups:P(Kr)}),Jr=A({runners:P(A({id:be,displayName:I(),modelListName:I(),modelIdScope:Wr,pickerLabel:I(),pickerDescription:I(),icon:I(),installHint:I(),loginCommand:I(),terminalLogin:F().optional(),browserLogin:F().optional(),managedInstall:N(!0).optional(),accountFolderExample:I().optional(),models:Gr,agentConfig:qr}))}),Yr=[`workspace`,`runners`];async function Xr(e){return gt(await Bt.api.v1.runners.$get({},y(e)),`/runners`,Jr)}var Zr={queryKey:Yr,queryFn:({signal:e})=>Xr({signal:e}),staleTime:1/0};function Qr(){return E(Zr)}function $r(e){return e?.runners??[]}function ei(e){return $r(e).map(e=>e.id)}function ti(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function ni(e){let t=Qr();return{runner:t.isSuccess?ti(e,ei(t.data))??e:e,ready:!t.isPending}}function ri(e,t){return e?.runners.find(e=>e.id===t)}function ii(e,t){return ri(e,t)?.displayName??t}function ai(e,t){return ri(e,t)?.pickerLabel??t}function oi(e,t){return ri(e,t)?.modelListName}function si(e,t,r=!0,i){let a=io(i,r),o=oa(),{runner:s,ready:c}=ni(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),d=E({queryKey:G.runnerSkills(s,l,u),queryFn:({signal:e})=>v(s,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var ci={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`}},li={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function ui(e){return typeof e==`string`&&Object.hasOwn(ci,e)}function di(e){return e!==void 0&&ui(e)?ci[e]:void 0}var fi=`cez.reference-statuses.v1`,pi=`cez.reference-conflicts.v1`,J=new Map(yi()),mi=1e3,Y=new Set(bi()),hi=r()??`__local__`;function gi(){let e=r()??`__local__`;if(hi!==e){hi=e,clearTimeout(xi),xi=void 0,J.clear();for(let[e,t]of yi())J.set(e,t);Y.clear();for(let e of bi())Y.add(e)}}function _i(e,t){if(gi(),J.get(e)!==t){for(J.delete(e),J.set(e,t);J.size>mi;){let e=J.keys().next().value;if(e===void 0)break;J.delete(e)}Si()}}function vi(e,t){if(gi(),Y.has(e)!==t){if(t)for(Y.add(e);Y.size>mi;){let e=Y.values().next().value;if(e===void 0)break;Y.delete(e)}else Y.delete(e);Si()}}function yi(){try{let e=globalThis.sessionStorage?.getItem(en(fi));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`&&ui(e[1])):[]}catch{return[]}}function bi(){try{let e=globalThis.sessionStorage?.getItem(en(pi));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var xi;function Si(){if(xi!==void 0)return;let e=en(fi),t=en(pi);xi=setTimeout(()=>{xi=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...J])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...Y]))}catch{}},250)}var Ci=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function wi(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Ti(e){let t=e.hostId===void 0?{}:{hostId:e.hostId};return[...e.prs.map(n=>({...t,projectId:e.projectId,kind:`PR`,number:n})),...e.issues.map(n=>({...t,projectId:e.projectId,kind:`Issue`,number:n}))]}function Ei(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;_i(t,o),s!==void 0&&vi(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Di(e,t,n){gi();let r=Ci(t),i=J.get(r),a=Y.has(r)?!0:void 0,o=n.data;if(o?.available){Ei(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...wi(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...wi(i,a)});return}e.set(r,{state:`loading`,...wi(i,a)})}function Oi(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Ti(i))Di(n,e,t)}),n}function ki(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 Ai(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 ji(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 Mi(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 Ni(e,t){return $e({kind:`topic`,topic:e},{value:t})}function Pi(){let e=T();return E({queryKey:K.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(K.providerStatus),r=await Pt(!1,{signal:t});return xe(n,e.getQueryData(K.providerStatus),r)},staleTime:5*6e4,refetchInterval:U(!1),refetchOnWindowFocus:!0})}function Fi(){let e=T();return B({mutationFn:()=>Pt(!0),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>xe(r,e,t)),q(e)}})}function Ii(){let e=T();return B({mutationFn:({provider:e,authFailureId:t})=>ut(e,t),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>xe(r,e,t,n.authFailureId)),q(e,n.provider)}})}function Li(e={}){return E({queryKey:K.projects,queryFn:({signal:e})=>Ot({signal:e}),...e})}function Ri(e,t=!1){return E({queryKey:K.fsBrowse(e,t),queryFn:({signal:n})=>Ke(e??void 0,{signal:n,showHidden:t}),retry:!1})}function zi(){let e=T();return B({mutationFn:e=>lt(e),onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function Bi(){let e=T();return B({mutationFn:e=>wt(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:K.projects})}})}function Vi(){let e=T();return B({mutationFn:e=>{let{id:t,...n}=e;return Ut(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:K.projects});let r=e.getQueryData(K.projects);return e.setQueryData(K.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Hi(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(K.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(K.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:K.projects})})}function Hi(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?[]:Mi(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 Ui(e){let t=T();return B({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(K.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:K.projects})})}function Wi(){return Ui(e=>{let{projectId:t,...n}=e;return st(t,n)})}function Gi(){return Ui(e=>{let{projectId:t,webhookId:n,...r}=e;return je(t,n,r)})}function Ki(){return Ui(({projectId:e,webhookId:t})=>pt(e,t))}function qi(){return B({mutationFn:({projectId:e,webhookId:t})=>Kt(e,t),retry:!1})}function Ji(e){let t=T();return B({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:K.agentProfiles}),t.invalidateQueries({queryKey:K.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),q(t)])},onError:()=>{t.invalidateQueries({queryKey:G.health}),t.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function Yi(){return Ji(e=>De(e))}function Xi(){return Ji(e=>{let{id:t,...n}=e;return tt(t,n)})}function Zi(){return Ji(e=>kt(e))}function Qi(){return Ji(e=>Ye(e))}function $i(e,t){return E({queryKey:K.agentAccountStatus(e),queryFn:({signal:t})=>It(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function ea(){let e=T();return B({mutationFn:({provider:e,profileId:t})=>Je(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:K.agentProfiles}),e.invalidateQueries({queryKey:K.providerStatus}),q(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:G.health}),e.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function ta(){let e=T();return B({mutationFn:e=>It(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.agentAccountStatus(n),t),e.invalidateQueries({queryKey:K.agentProfiles}),q(e,t.status.provider)}})}function na(){let e=T();return B({mutationFn:e=>Ue(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function ra(){let e=T();return B({mutationFn:e=>s(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function ia({enabled:e}){return E({queryKey:K.githubOwners,queryFn:({signal:e})=>mt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function aa(){let e=T();(0,z.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(G.health);n&&(Ee({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:i()}),t??=Ni(`health`,t=>{e.setQueryData(G.health,t)}))};n();let r=e.getQueryCache().subscribe(n);return()=>{r(),t?.(),ht()}},[e])}function oa(){return E({queryKey:G.health,queryFn:({signal:e})=>Qe({signal:e})})}function sa(e,t){let n=oa().data,r=Li(t).data?.projects,i=Ze(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?ki(n?.repo?.remote):void 0}function ca(e=!0){return E({queryKey:K.uiState,queryFn:({signal:e})=>xt({signal:e}),enabled:e})}function la(){return E({queryKey:K.config,queryFn:({signal:e})=>it({signal:e})})}function ua(){return E({queryKey:K.agentProfiles,queryFn:({signal:e})=>Et({signal:e})})}var da=[`workspace`,`runs-index`],X=e=>[e.cacheScope,`runs`,`list`],Z=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:zr(e.hostId,e.projectId,e.runId),Q=e=>typeof e==`function`?e():e;function fa(e){let{seenAt:t,...n}=e;return n}function pa(e,t){let n=fa(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function ma(e,t,n){return t?{...e,seenAt:n}:fa(e)}function ha(e,t,n){let r={...e},i=t;for(let e of n)Object.prototype.hasOwnProperty.call(i,e)&&i[e]!==void 0?r[e]=i[e]:delete r[e];return r}function ga(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r}function _a(e){let t=()=>{e.invalidateQueries({queryKey:da})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(a.hostId!==void 0)return r===`indexed`?void 0:e.invalidateQueries({queryKey:[`host`,a.hostId,a.projectId,`runs`]});if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let s=o(),c=[a.projectId,a.cacheScope],l=s!==void 0&&c.some(e=>e===s||e==="default")?[s,`default`]:[],u=new Set([...c,...l,n()]);return Promise.all([...u].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?ma(r,e,n.seenAt):r;async function a(t,n){let r=t.runId,a=new Date().toISOString(),o=e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===r,s=t=>{e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(Z(t)),l=e.getQueryData(W)?.runs.find(o);return e.setQueryData(Z(t),e=>e&&ma(e,n,a)),s(e=>ma(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(Z(t),e=>e&&pa(e,c)),l&&s(e=>pa(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(Z(t),e=>e?o(e):a),s(o)}}}async function s(n,r){let o=Q(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:X(Q(n))}),await e.cancelQueries({queryKey:Z(Q(n))});let s=e.getQueryData(X(Q(n))),c=e.getQueryData(Z(Q(n))),l=Q(n).runId,u=new Date().toISOString();return e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?ma(e,r,u):e)),e.setQueryData(Z(Q(n)),e=>e&&ma(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(X(Q(n)),s),c&&e.setQueryData(Z(Q(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?pa(e,t):e)),c&&e.setQueryData(Z(Q(n)),e=>e&&pa(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(X(Q(n)),e=>e?.map(o));let s={...Q(n),runId:r?l:a.id};e.setQueryData(Z(s),e=>e?o(e):a),t()}}}async function c(t,n){if(t.hostId!==void 0){let r=e.getQueryData(W),i=r?.runs.find(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId),a=n(),o=i?a(i):void 0,s=i&&o?ga(i,o):[];return e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?{...a(e),hostId:e.hostId}:e)}),{previous:r,rollback(){!i||s.length===0||e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?ha(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:da});let i=e.getQueryData(da),a=n();return e.setQueryData(da,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(da,i)},settle(){r(`indexed`,t)}}}return{patchRead:s,patchIndex:c,invalidateAfter:r}}function $(){let e=T();return(0,z.useMemo)(()=>_a(e),[e])}function va(e,t){if(!Qt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),$e({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ya(e,t,n,r){let i=T(),a=JSON.stringify(t),o=(0,z.useMemo)(()=>JSON.parse(a),[a]);(0,z.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=va({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function ba(e,t=!1){return l(await Bt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),yt(e,`/worker-destroy`))}function xa(){return E({queryKey:G.openTargets,queryFn:({signal:e})=>Wt({signal:e}),staleTime:5*6e4})}function Sa(e=!0,t){return E({queryKey:t?G.runs.list(t):G.runs.list(),queryFn:({signal:e})=>_e(V(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function Ca(e,t){return se({queryKey:G.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>dt({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function wa(e){let t=e.trim();return E({queryKey:K.runsSearch(t),queryFn:({signal:e})=>fe(t,{signal:e}),enabled:t.length>=2,placeholderData:Nt,staleTime:1e4})}function Ta(e=!0,t=yr,n){let r=Cr(T());return ya(`/api/v1/workspace/runs-index`,K.runsIndex,U(e?t:!1),Tr),E({queryKey:K.runsIndex,queryFn:({signal:e})=>Ce({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Ea(e){let t=T();return B({mutationFn:({workerId:e,discardWork:t=!1})=>ba(e,t),onSettled:()=>t.invalidateQueries({queryKey:G.runs.relationships(e)})})}function Da(e,t={}){return E({queryKey:G.runs.relationships(e),queryFn:({signal:t})=>O(e,{signal:t}),enabled:t.enabled??!0})}function Oa(e){return E({queryKey:G.runs.detail(e??``),queryFn:({signal:t})=>Me(H(e),{signal:t}),enabled:!!e})}function ka(e,t,n=!0,r){let i=r?.hostId;return E({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:zr(i,e??`default`,t??``),queryFn:({signal:n})=>Me(H(t,{projectId:e,hostId:i}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function Aa(e,t){return E({queryKey:t?[t,`runs`,`diff`,e??``]:G.runs.diff(e??``),queryFn:({signal:n})=>_(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ja(e,t=!1){return ya(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,G.runs.changes(e??``),U(t?4e3:!1)),E({queryKey:G.runs.changes(e??``),queryFn:({signal:t})=>te(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ma(e,t){return E({queryKey:G.runs.file(e??``,t??``),queryFn:({signal:n})=>ye(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Na(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>nt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Pa(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Xe(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fa(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>zt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ia(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>qt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function La(e,t=!1){return ya(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,G.runs.commits(e??``),U(t?5e3:!1)),E({queryKey:G.runs.commits(e??``),queryFn:({signal:t})=>b(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Ra(e,t){return E({queryKey:G.runs.commit(e??``,t??``),queryFn:({signal:n})=>Vt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function za(e,t=!0){return E({queryKey:G.runs.handoff(e??``),queryFn:({signal:t})=>bt(H(e),{signal:t}),enabled:!!e&&t})}function Ba(e,t,n,r){return E({queryKey:r===void 0?e===void 0?G.runs.handoff(t):[e,`runs`,`handoff`,t]:[`host`,r,e??`default`,`runs`,`handoff`,t],queryFn:({signal:n})=>bt(H(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function Va(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Ha(e,t){let r=new Map;for(let t of e){let e=Va(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=dn({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Rt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e},...r===void 0?{}:{hostId:r}}),enabled:t,staleTime:6e4,retry:!1}))}),o=a.map(e=>e.data);return(0,z.useMemo)(()=>{let e=new Map;return o.forEach((t,n)=>{if(!t?.available)return;let r=i[n];for(let n of t.automations)e.set(JSON.stringify([r.hostId??null,r.projectId??null,n.id]),n.name)}),(t,n,r)=>e.get(JSON.stringify([r??null,t??null,n]))},[JSON.stringify([i,a.map(e=>e.dataUpdatedAt)])])}function Ua(e){let t=T();return B({mutationFn:t=>ce(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Wa(e){let t=T();return B({mutationFn:t=>Re(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Ga(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=B({mutationFn:e=>ue(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,z.useCallback)(e=>({...H(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,z.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:c,mutateAsync:l}=a,u=(0,z.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,z.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function Ka(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return B({mutationFn:e=>ue(H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function qa(e){let t=$();return B({mutationFn:({id:t,pinned:n})=>oe(H(t,e),n),onError:e=>Tt(`Could not update pin. ${Ne(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??V(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ja(e,t,r){let i=$();return B({...r===void 0?{}:{mutationKey:zr(r,t??n(),e)},mutationFn:n=>Mt(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof m&&e.status===409&&n&&i.invalidateAfter(`send`,n)}})}function Ya(e,t,r){let i=$();return B({...r===void 0?{}:{mutationKey:zr(r,t??n(),e)},mutationFn:(n={})=>at(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`continue`,n)})}function Xa(e){let t=T();return B({mutationFn:({msgId:t,message:n})=>At(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Za(e){let t=T();return B({mutationFn:t=>Be(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Qa(){return E({queryKey:G.workflows,queryFn:({signal:e})=>vt({signal:e})})}function $a(e){return E({queryKey:e?[e,`repo`]:G.repo,queryFn:({signal:t})=>et({signal:t},e)})}function eo(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>et({signal:t},e)})}function to(){return E({queryKey:G.repoBranches,queryFn:({signal:e})=>Ht({signal:e})})}function no(){return E({queryKey:G.repoChanges,queryFn:({signal:e})=>Ae({signal:e}),retry:!1})}function ro(e){return E({queryKey:G.repoCommit(e??``),queryFn:({signal:t})=>p(e,{signal:t}),enabled:!!e,retry:!1})}function io(e,t=!0){return E({queryKey:e?[e,`config`]:G.config,queryFn:({signal:t})=>Gt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function ao(){return E({queryKey:G.worktrees,queryFn:({signal:e})=>c({signal:e})})}function oo(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>c({signal:t},e),staleTime:0})}function so(e,t=!0,n=!1){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>ve({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:He(e.sidebarLimits)},enabled:t})}function co(e=!0,t){return so(t??n(),e)}function lo(){return E({queryKey:G.agentConfig,queryFn:({signal:e})=>St({signal:e})})}function uo(e){return E({queryKey:G.agentConfigFile(e??``),queryFn:({signal:t})=>ft(e,{signal:t}),enabled:e!==null})}function fo(){return E({queryKey:G.sessionContext,queryFn:({signal:e})=>ne({signal:e})})}function po(e,t,n=``){return E({queryKey:G.sessionContextPreview(e,t,n),queryFn:({signal:n})=>he({content:e,role:t},{signal:n}),placeholderData:Nt,staleTime:0,retry:!1})}function mo(){let e=T();return B({onMutate:()=>({fileKey:G.sessionContext}),mutationFn:e=>pe(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function ho(e){let t=T(),n=G.agentConfig,r=G.agentConfigFile(e);return B({mutationFn:t=>x(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var go=L([`passing`,`failing`,`pending`]).nullable(),_o=A({kind:L([`issue`,`pr`]),number:R(),title:I(),author:I(),createdAt:I(),labels:P(I()),body:I().optional(),url:I(),comments:R(),assignees:P(I()).optional(),projectIds:P(I()).optional(),isDraft:F().optional(),additions:R().optional(),deletions:R().optional(),checks:go.optional()});j(`available`,[A({available:N(!0),item:_o.nullable(),labelColors:M(I(),I()).optional()}),A({available:N(!1),reason:I()})]),A({kind:L([`issue`,`pr`]),number:Xt().int().positive().safe()});var vo=A({id:I(),title:I(),url:I()});A({available:F(),reason:I().optional(),repo:I().optional(),syncedAt:I().optional(),issues:P(_o),prs:P(_o),labelColors:M(I(),I()).optional(),viewerLogin:I().optional(),projects:P(vo).optional(),projectsReason:I().optional(),projectsState:L([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:I().optional(),issuesTotal:R().int().nonnegative().optional(),prsTotal:R().int().nonnegative().optional(),issuesNextCursor:I().nullable().optional(),prsNextCursor:I().nullable().optional(),commentsDeferred:N(!0).optional()});var yo=I().min(1).max(2e3).optional();A({limit:I().optional(),refresh:I().optional(),issuesCursor:yo,prsCursor:yo,issuesDone:N(`1`).optional(),prsDone:N(`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`})}),A({kind:L([`issue`,`pr`]),numbers:I().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:N(`1`).optional()}),j(`available`,[A({available:N(!0),counts:M(R(),R().int().nonnegative())}),A({available:N(!1),reason:I()})]),j(`available`,[A({available:N(!0),checks:M(R(),go)}),A({available:N(!1),reason:I()})]),A({kind:L([`issue`,`pr`]),q:I().trim().min(1).max(256),limit:Xt().int().positive().max(50).optional()}),A({available:F(),projectsReason:I().optional(),reason:I().optional(),items:P(_o),truncated:F().optional(),labelColors:M(I(),I()).optional()});var bo=R().nullable();j(`available`,[A({available:N(!0),prs:M(R(),rt),issues:M(R(),rt),conflicts:P(R()).optional(),recheckAfterMs:bo}),A({available:N(!1),reason:I(),recheckAfterMs:bo})]);var xo=A({id:R(),author:I(),avatarUrl:I().optional(),createdAt:I(),body:I(),kind:L([`comment`,`review`]),reviewState:L([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:I()}),So=L([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Co=A({id:I(),kind:So,actor:I(),avatarUrl:I().optional(),createdAt:I(),url:I().optional(),sha:I().optional(),message:I().optional(),checks:go.optional(),label:A({name:I(),color:I().optional()}).optional(),subject:I().optional(),refNumber:R().optional(),refTitle:I().optional(),refIsPr:F().optional()});A({available:F(),reason:I().optional(),comments:P(xo),truncated:F().optional(),events:P(Co).optional(),detail:A({body:I(),additions:R().int().nonnegative().optional(),deletions:R().int().nonnegative().optional()}).optional()});var wo=L([`merge`,`squash`,`rebase`]),To=A({name:I(),state:L([`passing`,`failing`,`pending`,`unknown`]),required:F().nullable(),url:I().optional()}),Eo=A({number:R(),title:I(),url:I(),state:L([`open`,`closed`,`merged`]),isDraft:F(),headRef:I(),baseRef:I(),headSha:I(),mergeable:L([`mergeable`,`conflicting`,`unknown`]),reviewDecision:L([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:P(To),methods:P(wo),defaultMethod:wo.nullable(),eligibility:L([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:P(A({code:I(),message:I()})),canMerge:F(),canOverride:F()});j(`available`,[A({available:N(!0),mergeState:Eo}),A({available:N(!1),reason:I()})]),A({merged:N(!0),number:R(),url:I(),method:wo,mergeCommitSha:I().optional()});var Do=A({path:I(),previousPath:I().optional(),status:L([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:R(),deletions:R(),patch:I().optional(),patchUnavailableReason:L([`binary`,`too-large`,`not-provided`]).optional(),truncated:F().optional()});j(`available`,[A({available:N(!0),number:R(),headSha:I(),files:P(Do),additions:R(),deletions:R(),truncated:F(),reason:I().optional()}),A({available:N(!1),reason:I()})]),A({generation:I().uuid()}),j(`state`,[A({generation:I().uuid(),state:N(`ready`),projects:P(vo),membership:M(I(),P(I()))}),A({generation:I().uuid(),state:N(`unavailable`),reason:I()})]);function Oo(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 ko(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Ao(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function jo(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){Ao(t.issues,a,r),Ao(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 Mo=e=>e.map(e=>e.number).join(`,`);function No(e,t){let n=e[0];if(e.length>1&&n&&(Mo(n.issues)!==Mo(t.issues)||Mo(n.prs)!==Mo(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)]}var Po=class extends Error{};function Fo(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await C({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Po(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Oo(e),retry:(e,t)=>!(t instanceof Po)&&!(t instanceof m&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Io(e=50,t=!0){let r=T(),i=G.githubPages(e),a=G.githubPagesHead(e);ya(`/api/v1/p/${n()}/github?limit=${e}`,a,U(t?6e4:!1));let o=se({...Fo(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=E({queryKey:a,queryFn:({signal:t})=>C({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,z.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=No(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=dn({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>we(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,z.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!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 r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,z.useMemo)(()=>jo(o.data?.pages??[]),[o.data])}}function Lo(e,t=50,n=!0){let r=se({...Fo([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,z.useMemo)(()=>jo(r.data?.pages??[]),[r.data])}}function Ro(e,t,n=!0){let r=dn({queries:t.filter(e=>e.length>0).map(t=>({queryKey:G.githubCommentCounts(e,t),queryFn:({signal:n})=>jt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,z.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 zo(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ct(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Bo(e,t=!0){return E({queryKey:G.githubChecks(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Vo(e,t,n=!0){return E({queryKey:G.githubSearch(e,t),queryFn:({signal:n})=>ct(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ho=100;function Uo(e){return[...e].sort((e,t)=>t-e).slice(0,Ho).sort((e,t)=>e-t)}function Wo(){let e=Ze(),t=oa();return e.projectId??t.data?.bootProject??void 0}function Go(e,t){let n=t===void 0?{}:{hostId:t};for(let[t,r]of Object.entries(e)){for(let[e,i]of Object.entries(r.prs))_i(Ci({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))_i(Ci({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var Ko=5*6e4;function qo(e){return e?e.recheckAfterMs:Ko}function Jo(e,t=!0){let n=(0,z.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.hostId===void 0?n.projectId:`host:${n.hostId}\u0000${n.projectId}`,r=t.get(e)??{...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.projectId,prs:new Set,issues:new Set};r[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(e,r)}return[...t.values()].map(e=>({...e.hostId===void 0?{}:{hostId:e.hostId},projectId:e.projectId,prs:Uo(e.prs),issues:Uo(e.issues)}))},[e.map(Ci).sort().join(`|`)]),r=dn({queries:n.map(e=>({queryKey:G.githubRefStatus(e.projectId,e.prs,e.issues,e.hostId),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t,...e.hostId===void 0?{}:{hostId:e.hostId}}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>qo(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>U(t&&!fn()?qo(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=T(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:qo(r[t]?.data)??!1}]:[]));(0,z.useEffect)(()=>{if(!t||fn())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=G.githubRefStatus(t.projectId,t.prs,t.issues);return va({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,i]);let s=(0,z.useMemo)(()=>Oi(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,z.useCallback)(e=>{let t=Ci(e),n=s.get(t);if(n)return n;let r=J.get(t);return{state:`idle`,...r?{status:r}:{},...Y.has(t)?{conflicting:!0}:{}}},[s])}function Yo(e,t,n=!0){return E({queryKey:G.githubComments(e,t),queryFn:({signal:n})=>le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Xo(e,t,n=!0){return E({queryKey:G.githubItem(e,t),queryFn:({signal:n})=>We(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zo(e){return E({queryKey:G.githubPrChanges(e??0),queryFn:({signal:t})=>Ve(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Ma as $,q as $t,ao as A,Qi as At,Ga as B,ki as Bt,to as C,fn as Cn,ta as Ct,po as D,dn as Dn,Bi as Dt,fo as E,B as En,Zi as Et,Ha as F,la as Ft,qa as G,ii as Gt,Ua as H,di as Ht,Ya as I,ca as It,Oa as J,ei as Jt,ka as K,$r as Kt,Ea as L,Ni as Lt,Pa as M,Xi as Mt,Fa as N,Vi as Nt,co as O,an as On,Ki as Ot,Ia as P,Gi as Pt,Aa as Q,Qr as Qt,Xa as R,Ai as Rt,$a as S,U as Sn,Pi as St,ro as T,H as Tn,zi as Tt,xa as U,si as Ut,Ka as V,li as Vt,Wa as W,ti as Wt,Ra as X,ai as Xt,ja as Y,oi as Yt,La as Z,ni as Zt,eo as _,pn as _n,ia as _t,Xo as a,K as an,Ja as at,ho as b,_n as bn,sa as bt,Vo as c,Cr as cn,$ as ct,Wo as d,An as dn,na as dt,Ur as en,za as et,Jo as f,kn as fn,ea as ft,io as g,Tn as gn,Ri as gt,uo as h,Dn as hn,Wi as ht,Yo as i,G as in,wa as it,Ca as j,qi as jt,Qa as k,rn as kn,Ii as kt,Lo as l,jn as ln,$i as lt,lo as m,On as mn,ra as mt,Bo as n,Br as nn,Sa as nt,Io as o,W as on,Ba as ot,ko as p,Mn as pn,Yi as pt,Za as q,ri as qt,Ro as r,zr as rn,Ta as rt,Zo as s,wr as sn,va as st,Go as t,Vr as tn,Da as tt,zo as u,En as un,ua as ut,so as v,mn as vn,oa as vt,no as w,V as wn,Fi as wt,mo as x,vn as xn,Li as xt,oo as y,hn as yn,aa as yt,Na as z,ji as zt};
|