@abelxiaoxing/cadence 2.1.9 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +18 -16
- package/src/service-host.mjs +158 -360
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +2 -2
- package/web/dist/manifest.json +6 -6
|
@@ -12,7 +12,7 @@ import{r as e}from"./rolldown-runtime.js";import{n as t,r as n,t as r}from"./rea
|
|
|
12
12
|
`)}function jr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=U(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:dn(n.id),revision:R(n.revision,0),enabled:z(n.enabled),head:H(n.head,G),proposal:H(n.proposal,yr),runs:W(n.runs,200,G),...t?{notice:L(n.notice,1024,!0)}:{}}}function Mr(e){let t=L(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new F(`invalid`);return t}var Nr=196608,Pr=16384,Fr=1e3,Ir=16384,Lr=1024;function Rr(e,t){let n=e=>new TextEncoder().encode(JSON.stringify(e)).length;if(n(e)<=t)return e;let r=0,i=Math.min(e.length,t);for(;r<i;){let a=Math.ceil((r+i)/2);n(e.slice(0,a))<=t?r=a:i=a-1}return/[\uD800-\uDBFF]/u.test(e.slice(r-1,r))?e.slice(0,r-1):e.slice(0,r)}function zr(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
|
|
13
13
|
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function Br(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:Rr(e.text,Ir);return{id:e.id,role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?Rr(zr(e.args),Lr):``,error:e.error,parts:t}}function Vr(e){let t=U(e,[`id`,`updatedAt`]);return{id:dn(t.id),updatedAt:R(t.updatedAt,0)}}var Hr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function Ur(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:fn(U(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=U(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),ordinal:R(n.ordinal,0),before:H(n.before,e=>R(e,0))}}case`conversation-image`:{let n=U(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=R(n.offset,0);if(r%Bn.chunkChars||n.live!==void 0&&n.live!==!0)throw new F(`invalid`);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),...n.live===void 0?{}:{live:!0},entry:Mr(n.entry),index:R(n.index,0),offset:r}}case`conversation-step`:{let n=U(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),turnId:Mr(n.turnId),step:R(n.step,0),part:R(n.part,0)}}case`cadence-conversation`:return{kind:t,id:dn(U(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=U(e,[`kind`,`id`,`leaf`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=U(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:H(r.after,G),...n?{scan:G(r.scan)}:{}}}case`workflow-active`:return U(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=U(e,[`kind`,`id`,`stepId`]);return{kind:t,id:G(n.id),stepId:L(n.stepId,160,!0)}}case`workflow`:{let n=U(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:G(n.id),...n.before===void 0?{}:{before:R(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=U(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new F(`invalid`);return{kind:t,...n?{after:H(i.after,Vr)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return U(e,[`kind`]),{kind:t};case`conversation`:{let n=U(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),known:H(n.known,Mr)}}case`file-part`:{let n=Object.hasOwn(e??{},`location`),r=U(e,[`kind`,`path`,`offset`,...n?[`location`]:[]]),i=R(r.offset,0);if(i%196608||i>=67108864)throw new F(`invalid`);return{kind:t,path:L(r.path,4096),offset:i,...n?{location:fn(r.location)}:{}}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=U(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:B(r.kind,[`files`,`file`,`directories`]),path:L(r.path,4096),...n?{location:fn(r.location)}:{}}}}}function Wr(e){let t=L(e,400);if(t!==t.trim()||/\p{Cc}/u.test(t))throw new F(`invalid`);if([...t].length>100)throw new F(`oversize`);return t}function Gr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=U(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:G(n.commandId),location:fn(n.location),expected:hn(n.expected),choice:me(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=U(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new F(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:G(n.commandId),epoch:G(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:fn(n.location)},...r?{expected:hn(n.expected),choice:me(n.choice)}:{}}:{kind:t,...i,runId:G(n.runId)}}if(t===`cadence-exit`){let n=U(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:fn(n.location)},commandId:G(n.commandId),conversationId:dn(n.conversationId),head:H(n.head,Mr),revision:R(n.revision,0)}}if(t===`image-upload`){let n=U(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new F(`invalid`);let r=Gr(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new F(`invalid`);return{kind:t,commandId:G(n.commandId),imageId:G(n.imageId),send:r,mimeType:B(n.mimeType,Vn),size:R(n.size,1),offset:R(n.offset,0),data:L(n.data,Bn.chunkChars,!0)}}if(t===`cadence-send`){let n=U(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),head:H(n.head,Mr),text:L(n.text,Pr),...n.images===void 0?{}:{images:W(n.images,2**53-1,G)},model:hn(n.model),revision:R(n.revision,0),intent:B(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-revalidate`){let n=U(e,[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`,`head`,`context`,`expected`,`model`]),r=dn(n.conversationId),i=pn(n.context);if(i.id!==r)throw new F(`invalid`);return{kind:t,commandId:G(n.commandId),conversationId:r,revision:R(n.revision,0),proposalId:G(n.proposalId),digest:K(n.digest),head:H(n.head,Mr),context:i,expected:hn(n.expected),model:me(n.model)}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=U(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:G(r.commandId),conversationId:dn(r.conversationId),revision:R(r.revision,0),proposalId:G(r.proposalId),digest:K(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:G(r.grant)}}if(t===`workflow`){let n=U(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:G(n.commandId),epoch:G(n.epoch),request:br(n.request)}}if(t===`send`){let n=U(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),head:H(n.head,Mr),text:L(n.text,Pr),...n.images===void 0?{}:{images:W(n.images,2**53-1,G)},model:hn(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=U(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:G(n.commandId),conversationId:dn(n.conversationId),turnId:G(n.turnId),epoch:G(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:B(n.mode,[`steer`,`queue`]),text:L(n.text,Pr,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:G(n.inputId)}}if(t===`conversation-rename`){let n=U(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),name:Wr(n.name)}}if(t===`conversation-archive`){let n=U(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),archived:z(n.archived)}}let n=U(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:B(n.kind,[`open-project`]),commandId:G(n.commandId),path:L(n.path,4096,!0),epoch:G(n.epoch)}}function Kr(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=U(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?U(i.transcript,[`pages`]):null,o=n?U(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:mn(i.execution)},...i.retry===void 0?{}:{retry:Ge(i.retry)},id:G(i.id),epoch:G(i.epoch),status:B(i.status,Hr),notice:L(i.notice,1024),...a?{transcript:{pages:R(a.pages,0)}}:{},omitted:{thinking:o?z(o.thinking):!1,media:o?z(o.media):!1,other:o?z(o.other):!1},items:W(i.items,256,Yr)}}var qr=[`user`,`assistant`,`tool`,`thinking`];function Jr(e){return W(e,2**53-1,e=>{let t=U(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new F(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:Mr(t.entry),index:R(t.index,0),mimeType:B(t.mimeType,Vn)}})}function Yr(e){let t=U(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:Jr(t.images)},id:L(t.id,160,!0),role:B(t.role,qr),text:L(t.text,262144),name:L(t.name,128),args:L(t.args,65536),error:z(t.error)}}function Xr(e){let t=U(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:Jr(t.images)},id:L(t.id,160,!0),role:B(t.role,qr),text:L(t.text,Ir),clipped:z(t.clipped),name:L(t.name,128),target:L(t.target,Lr),error:z(t.error),parts:R(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&!n.parts)throw new F(`invalid`);return n}function Zr(e){let t=U(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=U(t.omitted,[`thinking`,`media`,`other`]),r=R(t.steps,0);return{...t.execution===void 0?{}:{execution:mn(t.execution)},...t.retry===void 0?{}:{retry:Ge(t.retry)},id:Mr(t.id),entry:H(t.entry,Mr),...t.parent===void 0?{}:{parent:H(t.parent,Mr)},at:R(t.at,0),status:B(t.status,Hr),notice:L(t.notice,1024),omitted:{thinking:z(n.thinking),media:z(n.media),other:z(n.other)},steps:r,stable:R(t.stable,0,r)}}function Qr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=U(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?U(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new F(`invalid`);return{id:dn(n.id),title:L(n.title,512,!0),leaf:H(n.leaf,Mr),status:B(n.status,Hr),updatedAt:R(n.updatedAt,0),origin:B(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:z(n.cadence)}:{},...r?{live:{commandId:G(r.commandId),epoch:G(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function $r(e){let t=U(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:G(t.commandId),text:L(t.text,16384),status:B(t.status,Hr),notice:L(t.notice,1024)}}function ei(e){let t=U(e,[`commandId`,`mode`,`text`]);return{commandId:G(t.commandId),mode:B(t.mode,[`steer`,`queue`]),text:L(t.text,256)}}function ti(e){let t=U(e,[`tokens`,`provider`,`model`]);return{tokens:H(t.tokens,e=>R(e,1)),provider:L(t.provider,128),model:L(t.model,256)}}function ni(e){let t=U(e,[`input`,`read`,`write`]);return{input:R(t.input,0),read:R(t.read,0),write:R(t.write,0)}}function ri(e){let t=U(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:Mr(t.id),parent:H(t.parent,Mr),text:L(t.text,1024),at:R(t.at,0),leaf:Mr(t.leaf),current:z(t.current)}}function ii(e){J(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=U(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:G(n.commandId),imageId:G(n.imageId),offset:R(n.offset,0)}}if(t===`conversation-image`){let n=U(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:B(n.mimeType,Vn),data:L(n.data,Bn.chunkChars,!0),next:H(n.next,e=>R(e,0))}}if(t===`conversation-context`)return{kind:t,context:pn(U(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:xn(U(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=U(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:G(n.commandId),choice:gn(n.choice)}}if(t===`workflow-transcript`){let n=U(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:G(n.runId),stepId:L(n.stepId,160,!0),turn:H(n.turn,Kr)}}if(t===`cadence-conversation`)return{kind:t,state:jr(U(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=U(e,[`kind`,`after`,`scan`]);return{kind:t,after:H(n.after,G),scan:G(n.scan)}}if(t===`workflow-history`){let n=U(e,[`kind`,`entries`,`next`]),r=W(n.entries,Wn.historyPage,e=>{let t=U(e,[`id`,`run`]),n=G(t.id),r=H(t.run,xr);if(r&&r.id!==n)throw new F(`invalid`);return{id:n,run:r}}),i=H(n.next,G);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new F(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=U(e,[`kind`,`runs`,...n?[`links`]:[]]),i=W(r.runs,4,xr),a=n?W(r.links,4,e=>{let t=U(e,[`runId`,`conversationId`]);return{runId:G(t.runId),conversationId:dn(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new F(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-revalidated`){let n=U(e,[`kind`,`commandId`,`state`]);return{kind:t,commandId:G(n.commandId),state:jr(n.state)}}if(t===`cadence-grant`){let n=U(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:G(n.commandId),grant:G(n.grant),expiresAt:R(n.expiresAt,0),revision:R(n.revision,0),proposal:yr(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=U(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:H(t.commandId,G),response:Sr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:W(U(e,[`kind`,`entries`]).entries,8,Qr)};if(n===`conversations`){let t=U(e,[`kind`,`entries`,`next`]);return{kind:n,entries:W(t.entries,200,Qr),next:H(t.next,Vr)}}if(n===`conversation`){let t=U(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[],...Object.hasOwn(e??{},`context`)?[`context`]:[],...Object.hasOwn(e??{},`cache`)?[`cache`]:[],...Object.hasOwn(e??{},`pending`)?[`pending`]:[],...Object.hasOwn(e??{},`undelivered`)?[`undelivered`]:[]]),r=H(t.summary,Qr),i=R(t.turns,0);if(!r&&i)throw new F(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:W(t.commands,64,G)},...t.context===void 0?{}:{context:ti(t.context)},...t.cache===void 0?{}:{cache:ni(t.cache)},...t.pending===void 0?{}:{pending:W(t.pending,8,ei)},...t.undelivered===void 0?{}:{undelivered:W(t.undelivered,8,$r)},summary:r,leaf:H(t.leaf,Mr),continues:z(t.continues),turns:i,branches:R(t.branches,0),runs:W(t.runs,200,G),attempt:H(t.attempt,$r)}}if(n===`conversation-tree`){let t=U(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:dn(t.conversationId),nodes:W(t.nodes,Fr,ri),truncated:z(t.truncated)}}if(n===`conversation-turn`){let t=U(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Zr(t.turn),i=R(t.start,0),a=W(t.steps,24,Xr);if(i+a.length>r.steps)throw new F(`invalid`);return{kind:n,conversationId:dn(t.conversationId),leaf:H(t.leaf,Mr),ordinal:R(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=U(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:dn(t.conversationId),leaf:H(t.leaf,Mr),turnId:Mr(t.turnId),step:R(t.step,0),part:R(t.part,0),item:Yr(t.item)}}if(n===`files`||n===`directories`){let t=U(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:L(t.path,4096),parent:H(t.parent,e=>L(e,4096)),limited:z(t.limited),entries:W(t.entries,200,e=>{let t=U(e,[`name`,`path`,`directory`]);return{name:L(t.name,1024,!0),path:L(t.path,4096,!0),directory:z(t.directory)}})}}if(n===`file`){let t=U(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:L(t.path,4096),text:L(t.text,262144),limited:z(t.limited)}}if(n===`file-part`){let t=U(e,[`kind`,`path`,`size`,`version`,`data`,`next`]),r=R(t.size,0),i=L(t.data,Nr/3*4),a=H(t.next,e=>R(e,1)),o=L(t.version,32,!0);if(r>67108864||!/^[a-f0-9]{32}$/.test(o)||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)||a!==null&&(a%196608!=0||a>=r))throw new F(`invalid`);return{kind:n,path:L(t.path,4096),size:r,version:o,data:i,next:a}}if(n===`projects`)return{kind:n,entries:W(U(e,[`kind`,`entries`]).entries,128,e=>{let t=U(e,[`path`,`current`]);return{path:L(t.path,4096,!0),current:z(t.current)}})};if(n===`accepted`)return{kind:n,commandId:G(U(e,[`kind`,`commandId`]).commandId)};let r=U(e,[`kind`,`commandId`,`path`,`link`]);return{kind:B(r.kind,[`project`]),commandId:G(r.commandId),path:L(r.path,4096,!0),link:L(r.link,8192,!0)}}var ai={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},oi=f.createContext&&f.createContext(ai),si=[`attr`,`size`,`title`];function ci(e,t){if(e==null)return{};var n,r,i=li(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function li(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ui(){return ui=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ui.apply(null,arguments)}function di(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function fi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?di(Object(n),!0).forEach(function(t){pi(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):di(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pi(e,t,n){return(t=mi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mi(e){var t=hi(e,`string`);return typeof t==`symbol`?t:t+``}function hi(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function gi(e){return e&&e.map((e,t)=>f.createElement(e.tag,fi({key:t},e.attr),gi(e.child)))}function $(e){return t=>f.createElement(_i,ui({attr:fi({},e.attr)},t),gi(e.child))}function _i(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=ci(e,si),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,ui({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:fi(fi({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return oi===void 0?t(ai):f.createElement(oi.Consumer,null,e=>t(e))}function vi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function yi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function bi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function xi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`9`,x2:`9`,y2:`15`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`9`,x2:`15`,y2:`15`},child:[]}]})(e)}function Si(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Ci(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function wi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function Ti(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Ei(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},child:[]}]})(e)}function Di(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Oi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function ki(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function Ai(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function ji(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Mi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Ni(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function Pi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},child:[]}]})(e)}function Fi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function Ii(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Li(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function Ri(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function zi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function Bi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function Vi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function Hi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function Ui(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function Wi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function Gi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},child:[]}]})(e)}function Ki(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function Ji(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Yi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function Xi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`6`,y1:`3`,x2:`6`,y2:`15`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`path`,attr:{d:`M18 9a9 9 0 0 1-9 9`},child:[]}]})(e)}function Zi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function $i(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function ea(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function ta(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function na(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function ra(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function ia(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function aa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function oa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function sa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function ca(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function la(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function ua(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function da(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function fa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function pa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function ma(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function ha(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function ga(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function _a(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function va(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function ya(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function ba(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},child:[]}]})(e)}function xa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function Sa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Ca(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function wa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}var Ta=e=>({kind:`error`,error:ie(`unavailable`,e?`uncertain`:`none`)}),Ea=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Ur(e);try{if(!this.transport.workbenchRead)return Ta(!1);let e=Q(await this.transport.workbenchRead(n,t),ii);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?Ta(!1):e}catch{return Ta(!1)}}async workbenchCommand(e){let t=Gr(e);try{if(!this.transport.workbenchCommand)return Ta(!0);let e=Q(await this.transport.workbenchCommand(t),ii);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?Ta(!0):e}catch{return Ta(!0)}}async current(e,t){let n=nn(e);try{if(!this.transport.current)return Ta(!1);let e=Q(await this.transport.current(n,t),ln);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async currentChanges(e,t){let n=rn(e);try{if(!this.transport.currentChanges)return Ta(!1);let e=Q(await this.transport.currentChanges(n,t),un);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Q(await this.transport.activeRuns(e),rt):Ta(!1)}catch{return Ta(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:Ta(!1)}return this.transport.models?Q(await this.transport.models(e),xn):Ta(!1)}catch{return Ta(!1)}}async chooseModel(e,t){let n=_n(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:Ta(!0)}else{if(!this.transport.chooseModel)return Ta(!1);e=Q(await this.transport.chooseModel(n),gn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(J(i)!==J(n.choice)||J(e.value.version.conversation??null)!==J(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return Ta(!0)}return e}catch{return Ta(!0)}}async checkObligations(e,t){G(e);try{let n=Q(await this.transport.checkObligations(e,t),Zt);return n.kind===`ok`&&n.value.taskId!==e?Ta(!1):n}catch{return Ta(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=Qt({...t,kind:e});try{let e=Q(await this.transport.entity(r,n),en);return e.kind===`ok`&&J(e.value.request)!==J(r)?Ta(!1):e}catch{return Ta(!1)}}async session(e){try{return Q(await this.transport.session(e),Et)}catch{return Ta(!1)}}async workspace(e){try{return Q(await this.transport.workspace(e),Dt)}catch{return Ta(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Ft({...t,reader:e});try{let t=Q(await this.transport[e](r,n),Vt);return t.kind===`ok`&&!Ht(r,t.value)?Ta(!1):t}catch{return Ta(!1)}}async graph(e,t){let n=Ut(e);try{let e=Q(await this.transport.graph(n,t),Gt);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async*export(e,t){let n=Kt(e),r=new Yt(n),i;try{if(t.aborted)throw new F(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new F(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new F(`unavailable`);yield i}catch{throw new F(`unavailable`)}}async preflight(e,t){let n=De({expected:e,action:t});try{let e=Q(await this.transport.preflight(n),Me);return e.kind===`ok`&&(J(e.value.preview.version)!==J(n.expected)||J(e.value.preview.action)!==J(n.action))?Ta(!1):e}catch{return Ta(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=Oe(t);if(n.action.kind!==e)return{kind:`error`,error:ie(`invalid`)};try{let e=Q(await this.transport.command(n),ct);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Ta(!0);lt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Ta(!0)}}async cancel(e){let t=Ae(e);try{let e=Q(await this.transport.cancel(t),ct);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Ta(!0);lt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Ta(!0)}}async receipt(e,t){G(e);try{let n=ut(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:ie(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=Le(e);try{let e=Q(await this.transport.snapshot(n,t),mt);return e.kind===`ok`&&J(e.value.scope)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async detail(e,t){let n=ze(e);try{let e=Q(await this.transport.detail(n,t),vt);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async search(e,t){let n=ze(e);try{let e=Q(await this.transport.search(n,t),bt);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}},Da=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=mt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&J(i.scope)===J(r.scope)&&q(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=P.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=P.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=ht(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||J(i.scope)!==J(a.scope))return this.resync();let o=q(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Ct(i.context)!==Ct(a.context)||wt(i.context)!==wt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||J(t.admission)!==J(e.admission))return this.resync();s[n]=e}}if(s.length>P.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{mt(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}};function Oa(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}var ka={session:`/api/v1/session`,workbenchRead:`/api/v1/workbench/read`,workbenchCommand:`/api/v1/workbench/command`,current:`/api/v1/current`,currentChanges:`/api/v1/current-changes`,activeRuns:`/api/v1/active-runs`,models:`/api/v1/models`,chooseModel:`/api/v1/model-choice`,workspace:`/api/v1/workspace`,tasks:`/api/v1/tasks`,runs:`/api/v1/runs`,messages:`/api/v1/messages`,tools:`/api/v1/tools`,contents:`/api/v1/contents`,events:`/api/v1/history-events`,checks:`/api/v1/checks`,changes:`/api/v1/changes`,reviews:`/api/v1/reviews`,checkObligations:`/api/v1/check-obligations`,entity:`/api/v1/entity`,graph:`/api/v1/graph`,snapshot:`/api/v1/snapshot`,detail:`/api/v1/details`,search:`/api/v1/search`,export:`/api/v1/export`,download:`/api/v1/download`,preflight:`/api/v1/preflight`,command:`/api/v1/commands`,cancel:`/api/v1/cancel`,receipt:`/api/v1/receipt`,detach:`/api/v1/detach`},Aa=`/api/v1/events`,ja=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Ma(e,t){if(ja.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return P.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return P.pageBytes}return P.controlBytes}function Na(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Pa(e,t){switch(e){case`workbenchRead`:return Ur(t);case`workbenchCommand`:return Gr(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new F(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Ft(t);if(n.reader!==e)throw new F(`invalid`);return n}case`current`:return nn(t);case`currentChanges`:return rn(t);case`checkObligations`:case`receipt`:return G(t);case`entity`:return Qt(t);case`graph`:return Ut(t);case`snapshot`:return Le(t);case`detail`:case`search`:return ze(t);case`export`:case`download`:return Kt(t);case`chooseModel`:return _n(t);case`preflight`:return De(t);case`command`:return Oe(t);case`cancel`:return Ae(t)}}function Fa(e,t){if(ja.includes(e))return Q(t,Vt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Q(t,ii);case`current`:return Q(t,ln);case`currentChanges`:return Q(t,un);case`activeRuns`:return Q(t,rt);case`models`:return Q(t,xn);case`chooseModel`:return Q(t,gn);case`session`:return Q(t,Et);case`workspace`:return Q(t,Dt);case`checkObligations`:return Q(t,Zt);case`entity`:return Q(t,en);case`graph`:return Q(t,Gt);case`snapshot`:return Q(t,mt);case`detail`:return Q(t,vt);case`search`:return Q(t,bt);case`preflight`:return Q(t,Me);case`command`:case`cancel`:return Q(t,ct);case`receipt`:return ut(t);case`detach`:return Q(t,e=>{if(e!==null)throw new F(`invalid`);return null});default:throw new F(`invalid`)}}function Ia(e){return[...ja,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function La(e,t){let n=ka[e];return t===null||Na(e)?n:`${n}?request=${encodeURIComponent(J(t))}`}function Ra(e,t){let n=Pa(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?ka[e]:La(e,n);return Na(e)||Ia(e)&&(r||ae(i)>P.headerBytes/4)?{path:ka[e],method:`POST`,body:J(n)}:{path:i,method:`GET`}}function za(e){J(e,P.viewerBytes);let t=B(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:mt(U(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:ht(U(e,[`kind`,`event`]).event)}:(U(e,[`kind`]),{kind:t})}var Ba=class{options;attachment;csrf=null;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project))throw new F(`invalid`);this.origin=e.origin,e.build&&=ot(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e,t=!1){let n={"Cache-Control":`no-store`};if(this.options.build&&(n[`X-Cadence-Build`]=J(this.options.build)),this.attachment&&(e||t)&&(n[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(n[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new F(`stale`);n[`Content-Type`]=`application/json`,this.csrf&&(n[`X-Cadence-CSRF`]=this.csrf)}return n}async request(e,t,n){let r=Ra(e,Pa(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Oa([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;e===`session`&&(this.attachment??=crypto.randomUUID());let t=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i,e===`session`),credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),n;try{if(e===`session`&&t.ok&&(n=G(t.headers.get(`x-cadence-attachment`)),n!==this.attachment))throw new F(`invalid`)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Va(t,Ma(e)),s=ce(a);if(ae(a)>Ma(e,s))throw new F(`oversize`);let c=Fa(e,s);if(e===`session`){let e=Q(c,Et);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new F(`forbidden`);this.attachment=n??G(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,_n(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,G(e),t)}entity(e,t){return this.request(`entity`,Qt(e),t)}tasks(e,t){return this.request(`tasks`,Ft(e),t)}runs(e,t){return this.request(`runs`,Ft(e),t)}messages(e,t){return this.request(`messages`,Ft(e),t)}tools(e,t){return this.request(`tools`,Ft(e),t)}contents(e,t){return this.request(`contents`,Ft(e),t)}events(e,t){return this.request(`events`,Ft(e),t)}checks(e,t){return this.request(`checks`,Ft(e),t)}changes(e,t){return this.request(`changes`,Ft(e),t)}reviews(e,t){return this.request(`reviews`,Ft(e),t)}graph(e,t){return this.request(`graph`,Ut(e),t)}preflight(e){return this.request(`preflight`,De(e))}command(e){return this.request(`command`,Oe(e))}cancel(e){return this.request(`cancel`,Ae(e))}receipt(e,t){return this.request(`receipt`,G(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;if(!this.options.localCapability&&!this.csrf){let t=Q(await this.session(),Et);if(t.kind===`error`){if(![`stale`,`unauthenticated`].includes(t.error.code))throw new F(t.error.code);return this.attachment===e&&(this.attachment=void 0),t}}let t=Q(await this.request(`detach`,null),e=>{if(e!==null)throw new F(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw t.error.code===`forbidden`&&!this.options.localCapability&&this.attachment===e&&(this.csrf=null),new F(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Ra(`export`,Kt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new F(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new F(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=P.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+P.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
14
14
|
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield qt(ce(e,P.controlBytes)),r=o.indexOf(`
|
|
15
|
-
`)}if(new TextEncoder().encode(o).length>P.controlBytes)throw new F(`oversize`)}if(n){if(o)throw new F(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=Le(e);if(!this.attachment||!this.options.socket)throw new F(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Aa}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=P.staleMs&&u(`stale`);try{Date.now()-c>=P.reconcileMs?(i.send(J({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},P.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(J({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new F(`invalid`);let n=za(ce(e.data,P.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Va(e,t){if(!e.body)throw new F(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new F(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Ha={sourceHash:`232868837879df863258282acba80cd1f604b8cc5dd71d9c0247f787bc8dcace`,contractHash:`d70dd3e63843be7df42ff10943fcdc78bcd27b881b0ac8222526e8dad7b0e6e2`,buildId:`8707aae09af2c14d9c0311e6f0b76b4925d67a516353a7a2f56beeeed3004dc8`};function Ua(e){let t=new Ba({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...Ha?{build:{kind:`browser`,...Ha}}:{},socket:e=>new WebSocket(e)});return{client:new Ea(t),transport:t}}function Wa(e,t){if(e.initiatorType!==`fetch`)return null;let n;try{n=new URL(e.name)}catch{return null}return n.origin!==t||!/^(?:\/projects\/[a-f0-9]{64})?\/api\/v1\//.test(n.pathname)||!(e.requestStart>0)||!(e.responseStart>=e.requestStart)?null:{at:e.responseStart,ms:e.responseStart-e.requestStart}}function Ga(e,t){let n=null;for(let r of e)t-r.at<=6e4&&(n===null||r.ms<n)&&(n=r.ms);return n===null?null:Math.round(n)}var Ka=[],qa=null,Ja,Ya,Xa=new Set;function Za(){let e=Ga(Ka,performance.now());if(e!==qa){qa=e;for(let e of Xa)e()}}function Qa(e){if(Xa.add(e),Xa.size===1&&typeof PerformanceObserver<`u`)try{Ja=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=Wa(t,location.origin);e&&(Ka=[...Ka.slice(-19),e])}Za()}),Ja.observe({type:`resource`,buffered:!0}),Ya=setInterval(Za,5e3)}catch{Ja=void 0}return()=>{Xa.delete(e),!Xa.size&&(Ja?.disconnect(),Ja=void 0,clearInterval(Ya),Ka=[],qa=null)}}function $a(){return(0,f.useSyncExternalStore)(Qa,()=>qa,()=>null)}function eo(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?dn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function to(e=typeof window>`u`?``:window.location.search){return eo(e,``).project}function no(e=typeof window>`u`?``:window.location.hash){return eo(``,e).chat}function ro(){let e=to();return e?`/projects/${e}`:``}function io(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&eo(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?Mr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function ao(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,Mr(t)),`#${n}`}function oo(e,t){if(typeof window>`u`||no()!==e)return;let n=ao(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function so(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&q(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&J(t.settlement)!==J(r.settlement))?i=!0:(!r||q(t.committedSeq,r.committedSeq)>0||J(r)===J(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function co(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(Ur(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function lo(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}function uo(e,t,n=!1){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)([]),s=co(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}async function fo(e){return ce(await Va(e,1048576),1048576)}function po(e){return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`code`in e.error?String(e.error.code):`unavailable`}function mo(e){let t=Error(po(e));return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`effect`in e.error&&[`none`,`accepted`,`uncertain`].includes(String(e.error.effect))&&(t.effect=e.error.effect),t}async function ho(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await fo(r);if(!r.ok)throw Error(po(i));return t(i)}function go(e){return ho(`/workbench/v1/service`,Ln,e)}function _o(e){return ho(`/workbench/v1/service/release`,Rn,e)}async function vo(e,t){let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t},body:JSON.stringify(e)}),r=await fo(n);if(!n.ok)throw Error(po(r));let i=U(r,[`kind`,`job`]);return V(i.kind,`service-job`),Pn(i.job)}function yo(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function bo(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function xo(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),a=(0,f.useRef)(0),[o,s]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await fo(r);if(!r.ok)throw Error(po(a));let c=Cn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...bo(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...bo(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,f.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:yo(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var So=e=>e===`unauthenticated`||e===`forbidden`,Co=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||t.workspace?.epoch===e&&t.attached&&!t.error&&t.transportStatus===`current`&&a()},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(){this.pollCurrent?.()}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Da,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=()=>{clearTimeout(o),v()&&!h&&(o=setTimeout(C,1e3))},S=e=>{this.serial=this.serial.then(e).catch(e=>{v()&&!h&&(s.abort(),u++,i?.(),_.attached=!1,_.error=e instanceof Error?e.message:`unavailable`,_.actions=!1,_.transportStatus=`stale`,y(),x())})},C=()=>{!v()||h||f||(clearTimeout(o),f=!0,S(async()=>{try{await D()}finally{f=!1}}))},w=async()=>{await this.api.transport.detach()},T=async(t=!0)=>{if(!v()||!_.attached||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{if(t){let e=await this.api.client.session(r);if(!v()||r.aborted)return;if(e.kind===`error`){_.actions=!1,_.error=e.error.code,So(e.error.code)&&E();return}if(e.value.epoch!==_.epoch){_.error=`stale`;return}g=e.value.capabilities.actions}e||(_.transportStatus=`current`);let i=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(i.kind===`ok`){if(i.value.epoch!==_.epoch){_.error=`stale`;return}_.activeRuns=i.value}else if(So(i.error.code)){E();return}else _.activeRuns=void 0;y();let a=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(a.kind===`error`){_.error=a.error.code,So(a.error.code)&&E();return}if(a.value.epoch!==_.epoch){_.error=`stale`;return}if(_.workspace=a.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,So(i.error.code)&&E();else if(i.value.epoch!==_.epoch)_.error=`stale`;else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&!r.aborted&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,v()&&!r.aborted&&(m=!n,_.actions=n&&g,y(),!n&&_.error===`stale`&&C())}},E=()=>{h=!0,_.attached=!1,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Da,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),S(w),y()},D=async()=>{if(!v()||h||(_.attached=!1,_.actions=!1,s.abort(),u++,i?.(),await w(),!v()||h))return;let t=await this.api.client.session();if(!v()||h){await w();return}if(t.kind===`error`){if(So(t.error.code)){E();return}throw Error(t.error.code)}if(s=new AbortController,c=new Da,_={epoch:t.value.epoch,attached:!0,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},g=t.value.capabilities.actions,y(),await T(!1),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&T():T();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(_.attached=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,x()),y())})};return C(),this.pollCurrent=()=>{_.attached?T():C()},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&T())},1e3),()=>{v()&&(b(),S(w))}}};function wo(e,t,n,r){let i=(0,f.useMemo)(()=>new Co(e),[e]),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,f.useEffect)(()=>{if(c({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),n)return i.observe(l&&u?{kind:l,id:u}:null,c)},[i,l,u,n,r,a]),{...s,refresh:()=>i.refresh(),whenReady:(e,t,n)=>i.whenReady(e,t,n),reconnect:()=>{let e=i.nextObservation();return o(e=>e+1),e}}}var To=class{generation=0;identity=``;select(e){e!==this.identity&&(this.identity=e,this.depart())}depart(){this.generation++}ticket(){return this.generation}current(e){return e===this.generation}};function Eo({client:e,value:t,onChange:n}){let{t:r,tx:i}=T(),a=(0,f.useRef)(!0),o=(0,f.useRef)(null);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,f.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,h.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,h.jsx)(`h3`,{children:r(`Command receipt`)}),(0,h.jsx)(`code`,{children:t.commandId}),t.error&&(0,h.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Admission`)}),(0,h.jsx)(`dd`,{children:i(l.admission)}),(0,h.jsx)(`dt`,{children:r(`Execution`)}),(0,h.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,h.jsx)(`dt`,{children:r(`Publication`)}),(0,h.jsx)(`dd`,{children:i(l.publication)}),(0,h.jsx)(`dt`,{children:r(`Run`)}),(0,h.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,h.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,h.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),o.current=new AbortController,e.receipt(t.commandId,o.current.signal).then(e=>{a.current&&(n({commandId:t.commandId,lookup:e}),c(!1))})},children:r(`Observe exact receipt`)})]})}function Do(e,t){let n=e??{content:t.content,chunks:[],offset:0},r=n.content,i=t.content;if(r.recordId!==i.recordId||r.version!==i.version||r.field!==i.field||r.sha256!==i.sha256||r.bytes!==i.bytes||n.offset!==(t.range?.start??0))throw Error(`Noncontiguous immutable field`);return{...n,chunks:[...n.chunks,t.text],offset:t.range?.end??0}}function Oo(e,t,n){switch(t.reader){case`tasks`:return e.tasks(t,n);case`runs`:return e.runs(t,n);case`messages`:return e.messages(t,n);case`tools`:return e.tools(t,n);case`contents`:return e.contents(t,n);case`events`:return e.events(t,n);case`checks`:return e.checks(t,n);case`changes`:return e.changes(t,n);case`reviews`:return e.reviews(t,n)}}function ko(e,t,n,r){return{storeId:e,scope:t,snapshotSeq:n,query:null,recordId:r.recordId,recordVersion:r.version,field:r.field,offset:0}}async function Ao(e,t,n){let r={...t,offset:0};delete r.navigation;let i=null,a=!0;for(;r;){if(n.aborted)throw Error(`canceled`);let t=await e.detail(r,n);if(n.aborted)throw Error(`canceled`);if(t.kind===`error`)throw Error(t.error.code);let o=t.value;r=o.next,`kind`in o||(a&&=o.coverage.observed===`complete`,i=Do(i,o)),await new Promise(e=>setTimeout(e,0))}if(!i||i.offset!==i.content.bytes)throw Error(`incomplete-content`);return{text:i.chunks.join(``),recordingComplete:a}}function jo(e,t){let n=t?J({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),Oo(e,l,n.signal).then(e=>{t===m.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===m.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),m.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&p(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),p(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),p([]),u(t?{...t}:null)}}}function Mo({value:e,compact:t=!1}){let{t:n,tx:r}=T();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,h.jsxs)(`details`,{className:`coverage-details`,children:[(0,h.jsx)(`summary`,{children:n(`Recording details`)}),(0,h.jsx)(Mo,{value:e})]}):(0,h.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[n(`Recording: {observed}; source: {source};`,{observed:r(e.observed),source:r(e.source)}),` `,e.redacted?n(`redacted`):n(`no reported redaction`),e.omissions.length>0&&n(`; omitted: {omissions}`,{omissions:e.omissions.map(r).join(`, `)}),n(`. Not a guarantee of complete original source or universal secret detection.`)]})}function No(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function Po(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return No(e)}return No(e)}function Fo(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(!1),s=(0,f.useRef)(null),c=(0,f.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,f.useCallback)(()=>{c(),o(!1)},[c]);return(0,f.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,f.useCallback)(async e=>{let a=!1;try{a=await Po(e)}catch(e){a=!1,r&&r(e)}return i.current&&(a?(o(!0),c(),s.current=setTimeout(()=>{o(!1),s.current=null},t),n?.(e)):r&&!a&&r(Error(`Copy failed`))),a},[t,n,r,c]),reset:l}}function Io(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
15
|
+
`)}if(new TextEncoder().encode(o).length>P.controlBytes)throw new F(`oversize`)}if(n){if(o)throw new F(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=Le(e);if(!this.attachment||!this.options.socket)throw new F(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Aa}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=P.staleMs&&u(`stale`);try{Date.now()-c>=P.reconcileMs?(i.send(J({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},P.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(J({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new F(`invalid`);let n=za(ce(e.data,P.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Va(e,t){if(!e.body)throw new F(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new F(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Ha={sourceHash:`ad0828373f8d69b3564dc8baf81604cbc64d5c7358a5c88fed3fd63512569528`,contractHash:`d70dd3e63843be7df42ff10943fcdc78bcd27b881b0ac8222526e8dad7b0e6e2`,buildId:`cdb10ead66d8e5131f34d0cf0afca06dd616e3b987b802e68d1b326bec64b5e0`};function Ua(e){let t=new Ba({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...Ha?{build:{kind:`browser`,...Ha}}:{},socket:e=>new WebSocket(e)});return{client:new Ea(t),transport:t}}function Wa(e,t){if(e.initiatorType!==`fetch`)return null;let n;try{n=new URL(e.name)}catch{return null}return n.origin!==t||!/^(?:\/projects\/[a-f0-9]{64})?\/api\/v1\//.test(n.pathname)||!(e.requestStart>0)||!(e.responseStart>=e.requestStart)?null:{at:e.responseStart,ms:e.responseStart-e.requestStart}}function Ga(e,t){let n=null;for(let r of e)t-r.at<=6e4&&(n===null||r.ms<n)&&(n=r.ms);return n===null?null:Math.round(n)}var Ka=[],qa=null,Ja,Ya,Xa=new Set;function Za(){let e=Ga(Ka,performance.now());if(e!==qa){qa=e;for(let e of Xa)e()}}function Qa(e){if(Xa.add(e),Xa.size===1&&typeof PerformanceObserver<`u`)try{Ja=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=Wa(t,location.origin);e&&(Ka=[...Ka.slice(-19),e])}Za()}),Ja.observe({type:`resource`,buffered:!0}),Ya=setInterval(Za,5e3)}catch{Ja=void 0}return()=>{Xa.delete(e),!Xa.size&&(Ja?.disconnect(),Ja=void 0,clearInterval(Ya),Ka=[],qa=null)}}function $a(){return(0,f.useSyncExternalStore)(Qa,()=>qa,()=>null)}function eo(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?dn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function to(e=typeof window>`u`?``:window.location.search){return eo(e,``).project}function no(e=typeof window>`u`?``:window.location.hash){return eo(``,e).chat}function ro(){let e=to();return e?`/projects/${e}`:``}function io(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&eo(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?Mr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function ao(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,Mr(t)),`#${n}`}function oo(e,t){if(typeof window>`u`||no()!==e)return;let n=ao(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function so(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&q(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&J(t.settlement)!==J(r.settlement))?i=!0:(!r||q(t.committedSeq,r.committedSeq)>0||J(r)===J(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function co(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(Ur(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function lo(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}function uo(e,t,n=!1){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)([]),s=co(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}async function fo(e){return ce(await Va(e,1048576),1048576)}function po(e){return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`code`in e.error?String(e.error.code):`unavailable`}function mo(e){let t=Error(po(e));return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`effect`in e.error&&[`none`,`accepted`,`uncertain`].includes(String(e.error.effect))&&(t.effect=e.error.effect),t}async function ho(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await fo(r);if(!r.ok)throw Error(po(i));return t(i)}function go(e){return ho(`/workbench/v1/service`,Ln,e)}function _o(e){return ho(`/workbench/v1/service/release`,Rn,e)}async function vo(e,t){let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t},body:JSON.stringify(e)}),r=await fo(n);if(!n.ok)throw Error(po(r));let i=U(r,[`kind`,`job`]);return V(i.kind,`service-job`),Pn(i.job)}function yo(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function bo(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function xo(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),a=(0,f.useRef)(0),[o,s]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await fo(r);if(!r.ok)throw Error(po(a));let c=Cn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...bo(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...bo(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,f.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:yo(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var So=e=>e===`unauthenticated`||e===`forbidden`,Co=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||t.workspace?.epoch===e&&t.attached&&!t.error&&t.transportStatus===`current`&&a()},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(){this.pollCurrent?.()}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Da,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=()=>{clearTimeout(o),v()&&!h&&(o=setTimeout(C,1e3))},S=e=>{this.serial=this.serial.then(e).catch(e=>{v()&&!h&&(s.abort(),u++,i?.(),_.attached=!1,_.error=e instanceof Error?e.message:`unavailable`,_.actions=!1,_.transportStatus=`stale`,y(),x())})},C=()=>{!v()||h||f||(clearTimeout(o),f=!0,S(async()=>{try{await D()}finally{f=!1}}))},w=async()=>{await this.api.transport.detach()},T=async(t=!0)=>{if(!v()||!_.attached||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{if(t){let e=await this.api.client.session(r);if(!v()||r.aborted)return;if(e.kind===`error`){_.actions=!1,_.error=e.error.code,So(e.error.code)&&E();return}if(e.value.epoch!==_.epoch){_.error=`stale`;return}g=e.value.capabilities.actions}e||(_.transportStatus=`current`);let i=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(i.kind===`ok`){if(i.value.epoch!==_.epoch){_.error=`stale`;return}_.activeRuns=i.value}else if(So(i.error.code)){E();return}else _.activeRuns=void 0;y();let a=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(a.kind===`error`){_.error=a.error.code,So(a.error.code)&&E();return}if(a.value.epoch!==_.epoch){_.error=`stale`;return}if(_.workspace=a.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,So(i.error.code)&&E();else if(i.value.epoch!==_.epoch)_.error=`stale`;else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&!r.aborted&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,v()&&!r.aborted&&(m=!n,_.actions=n&&g,y(),!n&&_.error===`stale`&&C())}},E=()=>{h=!0,_.attached=!1,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Da,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),S(w),y()},D=async()=>{if(!v()||h||(_.attached=!1,_.actions=!1,s.abort(),u++,i?.(),await w(),!v()||h))return;let t=await this.api.client.session();if(!v()||h){await w();return}if(t.kind===`error`){if(So(t.error.code)){E();return}throw Error(t.error.code)}if(s=new AbortController,c=new Da,_={epoch:t.value.epoch,attached:!0,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},g=t.value.capabilities.actions,y(),await T(!1),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&T():T();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(_.attached=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,x()),y())})};return C(),this.pollCurrent=()=>{_.attached?T():C()},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&T())},1e3),()=>{v()&&(b(),S(w))}}};function wo(e,t,n,r){let i=(0,f.useMemo)(()=>new Co(e),[e]),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,f.useEffect)(()=>{if(c({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),n)return i.observe(l&&u?{kind:l,id:u}:null,c)},[i,l,u,n,r,a]),{...s,refresh:()=>i.refresh(),whenReady:(e,t,n)=>i.whenReady(e,t,n),reconnect:()=>{let e=i.nextObservation();return o(e=>e+1),e}}}var To=class{generation=0;identity=``;select(e){e!==this.identity&&(this.identity=e,this.depart())}depart(){this.generation++}ticket(){return this.generation}current(e){return e===this.generation}};function Eo({client:e,value:t,onChange:n}){let{t:r,tx:i}=T(),a=(0,f.useRef)(!0),o=(0,f.useRef)(null);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,f.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,h.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,h.jsx)(`h3`,{children:r(`Command receipt`)}),(0,h.jsx)(`code`,{children:t.commandId}),t.error&&(0,h.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Admission`)}),(0,h.jsx)(`dd`,{children:i(l.admission)}),(0,h.jsx)(`dt`,{children:r(`Execution`)}),(0,h.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,h.jsx)(`dt`,{children:r(`Publication`)}),(0,h.jsx)(`dd`,{children:i(l.publication)}),(0,h.jsx)(`dt`,{children:r(`Run`)}),(0,h.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,h.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,h.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),o.current=new AbortController,e.receipt(t.commandId,o.current.signal).then(e=>{a.current&&(n({commandId:t.commandId,lookup:e}),c(!1))})},children:r(`Observe exact receipt`)})]})}function Do(e,t){let n=e??{content:t.content,chunks:[],offset:0},r=n.content,i=t.content;if(r.recordId!==i.recordId||r.version!==i.version||r.field!==i.field||r.sha256!==i.sha256||r.bytes!==i.bytes||n.offset!==(t.range?.start??0))throw Error(`Noncontiguous immutable field`);return{...n,chunks:[...n.chunks,t.text],offset:t.range?.end??0}}function Oo(e,t,n){switch(t.reader){case`tasks`:return e.tasks(t,n);case`runs`:return e.runs(t,n);case`messages`:return e.messages(t,n);case`tools`:return e.tools(t,n);case`contents`:return e.contents(t,n);case`events`:return e.events(t,n);case`checks`:return e.checks(t,n);case`changes`:return e.changes(t,n);case`reviews`:return e.reviews(t,n)}}function ko(e,t,n,r){return{storeId:e,scope:t,snapshotSeq:n,query:null,recordId:r.recordId,recordVersion:r.version,field:r.field,offset:0}}async function Ao(e,t,n){let r={...t,offset:0};delete r.navigation;let i=null,a=!0;for(;r;){if(n.aborted)throw Error(`canceled`);let t=await e.detail(r,n);if(n.aborted)throw Error(`canceled`);if(t.kind===`error`)throw Error(t.error.code);let o=t.value;r=o.next,`kind`in o||(a&&=o.coverage.observed===`complete`,i=Do(i,o)),await new Promise(e=>setTimeout(e,0))}if(!i||i.offset!==i.content.bytes)throw Error(`incomplete-content`);return{text:i.chunks.join(``),recordingComplete:a}}function jo(e,t){let n=t?J({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),Oo(e,l,n.signal).then(e=>{t===m.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===m.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),m.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&p(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),p(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),p([]),u(t?{...t}:null)}}}function Mo({value:e,compact:t=!1}){let{t:n,tx:r}=T();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,h.jsxs)(`details`,{className:`coverage-details`,children:[(0,h.jsx)(`summary`,{children:n(`Recording details`)}),(0,h.jsx)(Mo,{value:e})]}):(0,h.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[n(`Recording: {observed}; source: {source};`,{observed:r(e.observed),source:r(e.source)}),` `,e.redacted?n(`redacted`):n(`no reported redaction`),e.omissions.length>0&&n(`; omitted: {omissions}`,{omissions:e.omissions.map(r).join(`, `)}),n(`. Not a guarantee of complete original source or universal secret detection.`)]})}function No(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function Po(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return No(e)}return No(e)}function Fo(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(!1),s=(0,f.useRef)(null),c=(0,f.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,f.useCallback)(()=>{c(),o(!1)},[c]);return(0,f.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,f.useCallback)(async e=>{let a=!1;try{a=await Po(e)}catch(e){a=!1,r&&r(e)}return i.current&&(a?(o(!0),c(),s.current=setTimeout(()=>{o(!1),s.current=null},t),n?.(e)):r&&!a&&r(Error(`Copy failed`))),a},[t,n,r,c]),reset:l}}function Io(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
16
16
|
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var Lo=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Ro(!0)},text:{92:Ro(!1)}});let t={enter:{backslashMathInline:zo,backslashMathDisplay:zo,backslashMathBlock:zo},exit:{backslashMathInline:Bo,backslashMathDisplay:Bo,backslashMathBlock:Bo}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Ro(e){return{tokenize:function(t,n,r){let i=this,a=93,o=e?`backslashMathBlock`:`backslashMathDisplay`,s;return c;function c(e){return e===92?(s=t.enter(o),t.consume(e),l):r(e)}function l(n){return n!==91&&(e||n!==40)?r(n):(a=n===91?93:41,!e&&n===40&&(o=`backslashMathInline`,s.type=o),t.consume(n),u)}function u(n){return n===null||e&&i.parser.lazy[i.now().line]?r(n):n===-5||n===-4||n===-3?(t.enter(`lineEnding`),t.consume(n),t.exit(`lineEnding`),u):(f(n),n===92?d:u)}function d(i){return i===a?(f(i),t.exit(o),e?p:n):i===null?r(i):i===-5||i===-4||i===-3?u(i):(f(i),u)}function f(e){t.enter(`backslashMathData`),t.consume(e),t.exit(`backslashMathData`)}function p(e){return e===null||e===-5||e===-4||e===-3?n(e):e===32||e===-2||e===-1?(t.enter(`whitespace`),t.consume(e),t.exit(`whitespace`),p):r(e)}},concrete:e,name:e?`backslashMathBlock`:`backslashMathText`}}var zo=function(e){let t=e.type===`backslashMathBlock`,n=e.type!==`backslashMathInline`,r=this.sliceSerialize(e).slice(2,-2).trim(),i={type:`element`,tagName:`code`,properties:{className:[`language-math`,n?`math-display`:`math-inline`]},children:[{type:`text`,value:r}]},a=t?{type:`math`,meta:null,value:r,data:{hName:`pre`,hChildren:[i]}}:{type:`inlineMath`,value:r,data:{hName:`code`,hProperties:i.properties,hChildren:i.children}};this.enter(a,e)},Bo=function(e){this.exit(e)};function Vo(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var Ho=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function Uo(e,t,n=3){let r=[...e.filter(e=>!Ho(e,t)),t];for(;r.length>n;){let e=r.slice(0,-1).findIndex(e=>e.level!==`error`);r.splice(Math.max(e,0),1)}return r}var Wo=[],Go=1,Ko=new Set;function qo(e){if(!(e.length===Wo.length&&e.every((e,t)=>e===Wo[t]))){Wo=e;for(let e of Ko)e()}}function Jo(e,t,n){let r=Go++;return qo(Uo(Wo,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function Yo(e){qo(Wo.filter(t=>t.id!==e))}function Xo(e){qo(Wo.filter(t=>t.key!==e))}function Zo(e){return Ko.add(e),()=>{Ko.delete(e)}}var Qo=()=>Wo,$o=(0,f.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=T(),{copied:r,copy:i}=Fo();return(0,h.jsx)(`button`,{type:`button`,className:r?`${t} copied`:t,title:n(`Copy displayed text`),"aria-label":n(`Copy displayed text`),onClick:()=>{i(e).then(e=>{e||Jo(`error`,n(`Copy unavailable`))})},children:r?(0,h.jsx)(ga,{}):(0,h.jsx)(ca,{})})}),es=[s,d,Lo],ts=[s,l,d,Lo],ns=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function rs(e){if(e.startsWith(`#`)&&![...e].some(e=>e.charCodeAt(0)<=32))return e;try{let t=new URL(e);return![`https:`,`http:`].includes(t.protocol)||t.username||t.password||t.searchParams.has(`token`)?void 0:e}catch{return}}function is({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?ts:es,rehypePlugins:t?[i,o,...ns]:ns,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ss,a:os,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var as=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(is,{...e})})});function os({href:e,children:t}){let n=e&&rs(e);return n?(0,h.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,h.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function ss({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Io(r).map(e=>{let t=`code-offset:${i}`;return i+=cs(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,h.jsxs)(`div`,{className:`codeblock`,children:[(0,h.jsx)($o,{text:cs(e)}),(0,h.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,h.jsxs)(`div`,{className:`code-line`,children:[o&&(0,h.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,h.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function cs(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(cs).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return cs(t?.children)}return``}function ls(e,t){let n=[],r=t;if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=e.textContent??``;if(!e.parentElement?.closest(`[data-retained-field]`))continue;let i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();if(a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),n.length===1e3)return n;i=t.indexOf(r,i+r.length)}}return n}var us=new Map;function ds(e,t){t.length?us.set(e,t):us.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...us].filter(([e])=>e.endsWith(`-active`)===n).flatMap(([,e])=>e);let r=CSS;if(!r.highlights)return;if(t.length===0){r.highlights.delete(e);return}let i=window.Highlight;i&&r.highlights.set(e,new i(...t))}function fs(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function ps(e,t){let n=t.startContainer.parentElement;for(let r of fs(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function ms({container:e,version:t}){let{t:n}=T(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)(0),l=(0,f.useRef)([]),u=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?ls(n,r):[];return l.current=i,c(i.length),o(0),ds(u,i),()=>ds(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(ps(e.current,l.current[n]),ds(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>ds(`${u}-active`,[]),[u]),(0,h.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,h.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,h.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,h.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function hs({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=J(t),c=(0,f.useMemo)(()=>ze(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await Ao(e,t,n.signal);if(n.signal.aborted)return;let i=await Po(r.text);if(n.signal.aborted)return;w(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||w(a(`Full-field copy refused/incomplete.`))}finally{E.current===n&&(E.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,h.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,h.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,h.jsx)(`summary`,{children:a(`Field details`)}),(0,h.jsxs)(`div`,{className:`detail-identity`,children:[(0,h.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,h.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!!E.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!E.current&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{E.current?.abort(),E.current=null,w(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),C&&(0,h.jsx)(`p`,{role:`status`,children:C}),y&&(0,h.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),_&&(0,h.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,h.jsx)(Mo,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,h.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),k&&(0,h.jsxs)(h.Fragment,{children:[(!i||k.next)&&(0,h.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:k.range?.start??0,end:k.range?.end??0,total:k.content.bytes}),` `,k.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,h.jsx)(ms,{container:D,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:D,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,h.jsx)(as,{text:k.text}):(0,h.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!k||!n||!k.range)return k?.text;let e=Math.max(n.start,k.range.start)-k.range.start,t=Math.min(n.end,k.range.end)-k.range.start;if(t<=e)return k.text;let r=new TextEncoder().encode(k.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,h.jsxs)(h.Fragment,{children:[i(0,e),(0,h.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||m.length>0||d?.next)&&(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.length,onClick:()=>{u(m[m.length-1]),g(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!d?.next,onClick:()=>{d?.next&&(g(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function gs({pager:e,compact:t=!1}){let{t:n,tx:r}=T(),{page:i,busy:a,error:o}=e;return(0,h.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,h.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,h.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&!(t&&i.coverage.observed===`complete`&&i.coverage.source===`complete`&&!i.coverage.redacted&&i.coverage.omissions.length===0)&&(0,h.jsx)(Mo,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:a,onClick:e.refresh,"aria-label":n(`Observe a new snapshot`),title:n(`Observe a new snapshot`),children:t?(0,h.jsx)(ji,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function _s({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=jo(e,{...t,reader:`contents`}),[o,s]=(0,f.useState)(),c=a.page;return(0,h.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,h.jsx)(gs,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(x,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,h.jsx)(`code`,{children:n})}})}),c&&!(`kind`in c)&&c.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,h.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,h.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,h.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,h.jsx)(Mo,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ko(c.request.storeId,c.request.scope,c.request.snapshotSeq,e.content))},children:r(`Inspect complete retained field`)})]},`${e.content.recordId}:${e.content.version}`)),o&&(0,h.jsx)(hs,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function vs({client:e,seed:t}){return(0,h.jsx)(ys,{client:e,seed:t},J(t))}function ys({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),(i.kind===`message`?e.message(i,n.signal):i.kind===`tool`?e.tool(i,n.signal):e.task(i,n.signal)).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,h.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,h.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,h.jsx)(Mo,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,h.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function bs(e){let t=Ra(`download`,Kt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=ro()+t.path,n.download=`cadence-${e.scope.kind}-${e.scope.id}.${e.format===`markdown`?`md`:`ndjson`}`,n.referrerPolicy=`no-referrer`,document.body.appendChild(n),n.click(),n.remove()}function xs({title:e,children:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),n&&(0,h.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),t]})}function Ss({request:e,onClose:t}){let{t:n,tx:r}=T(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(xs,{title:n(`Export retained history`),onClose:t,children:[(0,h.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,h.jsxs)(`label`,{children:[n(`Format`),(0,h.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,h.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,h.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,h.jsx)(`p`,{children:n(`Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.`)}),(0,h.jsx)(`p`,{children:n(`A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{try{bs({...i,format:a}),c(n(`Download requested — completion not verified by this browser UI.`))}catch{c(n(`Download unavailable; no archive claimed complete.`))}},children:n(`Request selected-scope download`)}),(0,h.jsx)(`p`,{role:`status`,children:s})]})}function Cs(e,t){if(!t||ae(t)>P.queryBytes)throw Error(`Query must be 1–${P.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ze({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function ws(e){return e.next?`No hits in this bounded window; search is not finished.`:`No hits in the final retained window. Coverage limits above still apply.`}function Ts({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=T(),[o]=(0,f.useState)(t),s=(0,f.useRef)(null),c=(0,f.useRef)(0),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(0),[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),x=(0,f.useRef)(null),S=(0,f.useCallback)(async(t,n)=>{x.current?.abort();let r=new AbortController;x.current=r,v(!0),b(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?b(i.error.code):(g(i.value),p(0))}catch{c.current===n&&!r.signal.aborted&&b(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&v(!1)}},[e]);return(0,f.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),g(void 0),p(0),b(void 0),!l)return;let t;try{t=Cs(o,l)}catch{b(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void S(t,e),300);return()=>{clearTimeout(n),c.current++,x.current?.abort()}},[l,o,S]),(0,h.jsx)(xs,{title:i(`Search retained history`),onClose:n,children:(0,h.jsxs)(`div`,{className:`gs-modal`,children:[(0,h.jsxs)(`div`,{className:`gs-input-row`,children:[(0,h.jsx)(ki,{}),(0,h.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.max(0,Math.min(e+1,(m?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(e-1,0))),e.key===`Enter`&&m?.hits[d]&&(e.preventDefault(),r(m.hits[d]),n())}})]}),(0,h.jsx)(`p`,{children:i(`Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.`,{kind:a(o.scope.kind),id:o.scope.id,seq:o.snapshotSeq})}),(0,h.jsxs)(`div`,{className:`gs-results`,children:[_&&(0,h.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,h.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Mo,{value:m.coverage}),(0,h.jsxs)(`div`,{className:`gs-section`,children:[(0,h.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:m.hits.length})}),m.hits.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>p(t),onClick:()=>{r(e),n()},children:[(0,h.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,h.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,h.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` /`,` `,i(`bytes {start}–{end}`,{start:e.range.start,end:e.range.end})]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),m.hits.length===0&&(0,h.jsx)(`p`,{children:a(ws(m))})]}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.next,onClick:()=>{m.next&&S(m.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,h.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function Es({run:e,historical:t=!1}){let{t:n,tx:r}=T();return(0,h.jsxs)(`article`,{className:`run-summary`,children:[(0,h.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,h.jsx)(`p`,{children:(0,h.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,h.jsx)(`dd`,{children:r(e.lifecycle)}),(0,h.jsx)(`dt`,{children:n(`Execution`)}),(0,h.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,h.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,h.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,h.jsx)(`dt`,{children:n(`Summary publication`)}),(0,h.jsx)(`dd`,{children:r(e.publication)})]}),(0,h.jsx)(Mo,{value:e.coverage}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,h.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Ds({client:e,seed:t}){return(0,h.jsx)(Os,{client:e,seed:t},J(t))}function Os({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),e.graph(i,n.signal).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,h.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,h.jsx)(Mo,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hs,{client:e,cursor:ko(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,h.jsx)(as,{text:e.instructions}),(0,h.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,h.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function ks({client:e,seed:t,onScope:n}){let{t:r}=T(),i=jo(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(gs,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Es,{run:e.projection,historical:!0}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:r(`Open retained episode/child details`)}),e.projection.admission.graph&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&e.projection.admission.graph&&s({storeId:a.request.storeId,scope:a.request.scope,snapshotSeq:a.request.snapshotSeq,graph:e.projection.admission.graph})},children:r(`Inspect admitted graph and plan`)})]},e.projection.childRunId??e.projection.runId):null),o&&(0,h.jsx)(Ds,{client:e,seed:o},o.graph.recordId)]})}function As({onOpen:e,disabled:t}){let{t:n}=T();return(0,h.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,h.jsx)(ki,{"aria-hidden":`true`})})}function js(e,t,n,r,i){let a=i??t,o=[],s=[],c=0;for(let i of e)n.has(i.id)||(r.has(i.id)?i.top<t.bottom&&i.bottom>t.top&&o.push(i.id):i.top<a.bottom&&i.bottom>a.top||(s.push(i.id),i.bottom<=a.top&&(c+=i.bottom-i.top)));return{show:o,hide:s,shrinkAbove:c}}function Ms(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function Ns(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??Ps(n.role,n.customType)}return r}function Ps(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`tool-result`:return 120;case`custom`:return t===`file`?96:72;default:return 60}}function Fs(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Is(e,t,n=null,r=1800){let[i,a]=(0,f.useState)(()=>new Set),o=(0,f.useRef)(i);o.current=i;let s=(0,f.useRef)(new Map),c=(0,f.useRef)(new Map),l=(0,f.useRef)(new Map),u=(0,f.useRef)(0),d=(0,f.useRef)(new Map);d.current=new Map(t.map(e=>[e.id,e.version]));let p=(0,f.useRef)(new Set);p.current=Ns(t,s.current,r),n!==null&&p.current.add(n);let m=(0,f.useCallback)((e,t)=>{let n=d.current.get(e);n!==void 0&&(c.current.set(e,{h:t,len:n}),s.current.set(e,t))},[]),h=(0,f.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of l.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),o.current.has(e)||m(e,n.height)}let i=js(r,{top:n.top-1200,bottom:n.bottom+1200},p.current,o.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=l.current.get(e);t&&m(e,t.offsetHeight)}a(e=>Ms(e,i))},[m,e]),g=(0,f.useCallback)(()=>{u.current||=requestAnimationFrame(()=>{u.current=0,h()})},[h]);return(0,f.useLayoutEffect)(()=>{t.length?h():a(new Set)},[h,t,n]),(0,f.useEffect)(()=>{let t=new ResizeObserver(g);return e.current&&t.observe(e.current),()=>{t.disconnect(),cancelAnimationFrame(u.current)}},[g,e]),{hidden:i,scheduleSweep:g,recordMeasured:m,register:(0,f.useCallback)(e=>t=>{t?l.current.set(e,t):l.current.delete(e)},[]),placeholder:(0,f.useCallback)((e,t,n)=>Fs(e,t,c.current,n),[])}}var Ls=(0,f.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,f.useRef)(null);return(0,f.useLayoutEffect)(()=>{if(!t)return;let n=s.current;if(!n)return;let r=n.offsetHeight;r>0&&i?.(e,r)},[t,e,i]),t?(0,h.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,h.jsx)(`div`,{ref:s,children:o})}):(0,h.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),Rs=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(fa,{"aria-hidden":`true`}):(0,h.jsx)(ea,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,h.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,h.jsx)(`div`,{className:`msg-text`,children:(0,h.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,h.jsx)(hs,{compact:!0,client:t,cursor:ko(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,h.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,h.jsxs)(`div`,{className:`message-inspection`,children:[(0,h.jsx)(`p`,{className:`msg-ident`,children:r(`Child {child} · message {message} · version {version}`,{child:e.owner.childRunId??``,message:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,h.jsx)(_s,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function zs({messages:e,client:t,seed:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),o=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=Is(i,o);return(0,h.jsxs)(`div`,{className:`messages-wrap`,children:[(0,h.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.scheduleSweep()},children:o.map(({id:e,role:r,message:a})=>(0,h.jsx)(Ls,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,h.jsx)(Rs,{message:a,client:t,seed:n})},e))}),(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,h.jsx)(xa,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Bs({client:e,seed:t}){let{t:n}=T(),r=jo(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(gs,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,h.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,h.jsxs)(h.Fragment,{children:[i.records.length===0&&(0,h.jsx)(`p`,{className:`empty-note panel-empty`,children:i.next?n(`No message records on this page; more history remains.`):n(`No message records on this page.`)}),(0,h.jsx)(zs,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Vs({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,h.jsxs)(`div`,{className:`chead ${n}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,h.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,h.jsx)(ha,{}):(0,h.jsx)(pa,{})}):c,(0,h.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,h.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Hs=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1),s=e.result?e.result.isError?r(`SDK tool error observed`):r(`SDK tool end observed`):e.startObserved?r(`Start observed; end not observed in this snapshot`):r(`No start observed`),c=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,h.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,h.jsx)(Vs,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Si,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(_s,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Us=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function Ws({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=T(),s=new Set(e?.projects.flatMap(e=>e.activities.filter(e=>e.sessionId).map(t=>`${e.path}\0${t.sessionId}`))),c=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(Us(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length);return(0,h.jsxs)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:a(`Active Pi work`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[e&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`{projects} projects · {sessions} sessions`,{projects:e.projects.length,sessions:s.size})}),(t||e?.completeness===`partial`)&&(0,h.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),i.length>0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Owner work already listed below is not duplicated here.`)}),!e&&!t&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Discovering active work…`)}),e?.completeness===`complete`&&!t&&!e.projects.length&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`No active work observed. Idle terminals and owners are not listed.`)}),c?.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,h.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,h.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})]})}function Gs(e){return e.replace(/(?:-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})+$/i,``)}function Ks(e){if(!e.tasks?.length)return null;let t={queued:0,running:0,completed:0,failed:0,superseded:0};for(let n of e.tasks)t[n.state]+=1;return t}var qs=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function Js(e,t){return qs.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function Ys(e){let t=Ks(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function Xs(e,t=e.steps){return(e.tasks??[]).map(n=>{let r=e.delivery?.artifacts?.findLast(e=>e.id===n.id);return{task:n,steps:t.filter(e=>Gs(e.id)===n.id),...r?{artifact:r}:{}}})}var Zs=[`queued`,`running`];function Qs(e,t){let n=e=>Number(!Zs.includes(e));return[...new Set(e)].flatMap(e=>{let r=t.get(e),i=(r?.steps.filter(e=>e.childRunId)??[]).reverse().sort((e,t)=>n(e.status)-n(t.status));return r&&i.length?[{run:r,steps:i}]:[]}).reverse().sort((e,t)=>n(e.steps[0].status)-n(t.steps[0].status))}function $s(e,t){return t.kind===`check`?e.delivery?.acceptance?.waived?.includes(t.id)?!0:t.status===`failed`&&!!e.verification?.steps.includes(t.id)&&(e.deviations??[]).some(e=>e.waives.includes(Gs(t.id))):!1}var ec=[`queued`,`running`],tc=4,nc=1e4;function rc(e,t,n=2e3){let[r,i]=(0,f.useState)(()=>({runs:new Map,failed:!1,unreadable:new Set})),a=(0,f.useRef)({client:e,runs:new Map}),o=JSON.stringify([...new Set(t)]);return(0,f.useEffect)(()=>{let t=new AbortController,r;a.current.client!==e&&(a.current={client:e,runs:new Map});let s=JSON.parse(o),c=new Set(s);for(let e of a.current.runs.keys())c.has(e)||a.current.runs.delete(e);let l=new Map(a.current.runs),u=new Map,d=e=>{let t=new Map;for(let e of s){let n=l.get(e);n&&t.set(e,n)}return i({runs:t,failed:e,unreadable:new Set(u.keys())}),t},f=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return!1;if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`){let e=r.value.response.run;return l.set(n,e),u.delete(n),a.current.runs.set(n,e),!1}return l.has(n)?!0:(u.set(n,Date.now()),!1)},p=async()=>{let e=!1,i=Date.now(),a=s.filter(e=>{let t=l.get(e);return t?ec.includes(t.status):i-(u.get(e)??0)>=nc}).reverse();for(let n=0;n<a.length;n+=tc){let r=await Promise.all(a.slice(n,n+tc).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+tc<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>ec.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),nc))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function ic({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=T(),o=Ks(e),s=n?.runId===e.id?n.stepId:void 0;return(0,h.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${s===null?` active`:``}`,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,h.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,h.jsx)(`span`,{className:`agent-dock-run-state`,children:Js(o,i)})]}),t.map(t=>{let n=Gs(t.id),o=e.tasks?.find(e=>e.id===n);return(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row${s===t.id?` active`:``}`,title:o?`${o.title} · ${e.goal}`:e.goal,onClick:()=>r?.({runId:e.id,stepId:t.id,label:n}),children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsx)(`strong`,{children:`${a(t.kind)} · ${n}`}),o&&(0,h.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(o.state)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function ac({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=rc(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,f.useEffect)(()=>{let t=new AbortController,n,r=async()=>{let i=[],a=!1;for(let n of JSON.parse(b)){let r=await e.snapshot({kind:`task`,id:n},t.signal);if(t.signal.aborted)return;if(r.kind===`ok`)for(let e of r.value.runs)e.childRunId&&i.push({taskId:n,run:e,snapshot:r.value.committedSeq});else a=!0}t.signal.aborted||(g(i),v(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,b]);let x=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],S=[...m,...x.filter(e=>!m.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=Qs(a,y.runs),w=C.flatMap(e=>e.steps),E=S.length+w.length,D=w.filter(e=>ec.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,O=d??(E>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${O?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":O,onClick:()=>p(!O),children:[(0,h.jsx)(ha,{}),(0,h.jsx)(aa,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${D?` live`:``}`,children:D?l(`{active} active · {total} total`,{active:D,total:E}):E})]}),O&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(_||t?.status!==`complete`||y.failed)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),E===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,steps:t})=>(0,h.jsx)(ic,{run:e,steps:t,selected:o,onOpen:c},e.id)),S.map(e=>(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,h.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,h.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}function oc(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function sc(e){let t=new Map;for(let n of e.nodes){if(n.parent===null&&e.truncated)continue;let r=t.get(n.parent);r?r.push(n):t.set(n.parent,[n])}let n=new Map;for(let e of t.values())if(e.length>1)for(let t of e)n.set(t.id,e);return n}var cc=e=>e.filter(e=>e.current);function lc(e,t,n,r,i){let a=e.findIndex(e=>e.id===t);if(a<0)return;let o=new Map(e.map((e,t)=>[e.id,t])),s=n.find(e=>o.has(e.header.id)),c=s?s.ordinal-(o.get(s.header.id)-a):r-+!!i-(e.length-a);return c>=0&&c<r?c:void 0}function uc(e,t,n,r,i){let[a,o]=(0,f.useState)();(0,f.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=co(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,f.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,p]=(0,f.useState)();return(0,f.useEffect)(()=>{u&&p(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function dc({view:e,onChosen:t}){let{t:n,locale:r}=T(),[i,a]=(0,f.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,f.useMemo)(()=>oc(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,h.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,h.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,h.jsx)(ji,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,h.jsxs)(`p`,{className:`branches-pinned`,children:[(0,h.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(n,e.error)}),s?.truncated&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,h.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,h.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,h.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,h.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,h.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,h.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,h.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,h.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,h.jsx)(na,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,h.jsx)(sa,{"aria-hidden":`true`})})]},t.id))})]})}function fc(e,t){if(!e)return;let n=t?.find(t=>t.provider===e.provider&&t.model===e.model)?.contextWindow;return{tokens:e.tokens,window:n&&n>0?n:null,provider:e.provider,model:e.model}}function pc(e){let t=(e,t)=>`${e.toFixed(1).replace(/\.0$/,``)}${t}`;return e>=999950?t(e/1e6,`M`):e>=1e3?t(e/1e3,`K`):String(e)}function mc(e,t){return Math.round(e/t*100)}var hc=e=>e.trim().split(`
|
|
17
17
|
`,1)[0].slice(0,200);function gc(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var _c=(e,t)=>e?e.entry:t,vc=(e,t)=>e!==null&&t>=e.from;function yc(e){if(!e)return null;try{let t=JSON.parse(e);return t.kind!==`edit`&&t.kind!==`continue`||typeof t.turnId!=`string`||!Number.isSafeInteger(t.from)||t.from<0||typeof t.label!=`string`||typeof t.stash!=`string`?null:{kind:t.kind,entry:t.entry===null?null:Mr(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function bc(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function xc(e,t,n,r,i=crypto.randomUUID()){return{kind:`conversation-input`,commandId:i,conversationId:e,turnId:t.commandId,epoch:t.epoch,mode:n,text:r}}function Sc(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function Cc(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function wc(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}var Tc=2e4;async function Ec(e,t,n,r){let i=Oa([t],Tc);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Dc(e,t){if(t===`none`)return`Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.`;switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function Oc(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function kc(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function Ac(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function jc(e){let t={commandId:crypto.randomUUID(),conversationId:dn(e.id),head:e.head===null?null:Mr(e.head)},n=e.location?fn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new F(`stale`);let r=L(e.text,Pr,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:R(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:R(e.revision,0)};return Object.freeze({text:r,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Mc(e.model))}:{}})}function Mc(e){return me({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Nc(e,t){return Object.freeze({...e,model:Object.freeze(Mc(t))})}function Pc(e,t){if(e.model&&J(e.model)!==J(Mc(t)))throw new F(`stale`)}function Fc(e,t){return Object.freeze({...e,preparedEpoch:G(t)})}function Ic(e,t,n){return Object.freeze({...Nc(e,t),installModel:!n})}function Lc(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function Rc(e,t){return!!e&&e===t}async function zc(e,t,n,r){if(!r())throw new F(`stale`);if(!t.installModel||!t.model)return n;if(!yn(n.entries,t.model))throw new F(`unsupported-context`);if(n.selected&&J(Mc(n.selected))===J(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new F(`stale`);if(i.kind===`error`)throw new F(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new F(`stale`);if(a.kind===`error`)throw new F(a.error.code);if(!a.value.selected||J(a.value.version)!==J(i.value.version)||J(a.value.selected)!==J(i.value.selected))throw new F(`stale`);return Pc(t,a.value.selected),a.value}function Bc(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&J(e.location)!==J(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new F(`stale`);let n=Gr(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new F(`invalid`);return n}function Vc(e,t,...n){let r=`cadence:draft:${e}:${t}`;try{let e=e=>[e,`${e}:pending`,`${e}:mode`].some(e=>sessionStorage.getItem(e)!==null);if(e(r))return r;for(let r of n){if(!r)continue;let n=`cadence:draft:${r}:${t}`;if(e(n))return n}}catch{}return r}function Hc(e){for(let t of e){if(!Vn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function Uc(e){Hc([e]);let t=new Uint8Array(await e.arrayBuffer());return Un(t,e.type),t}var Wc=e=>{let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)};async function Gc(e,t,n,r){Hc(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await Uc(a);if(!r())throw Error(`stale`);let o=Wc(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Bn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Bn.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function Kc(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>Bn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Bn.chunkChars)throw Error(`invalid`)}let i=Hn(n.join(``));return Un(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var qc=1e3,Jc=1e4,Yc=4,Xc=e=>e===`queued`||e===`running`,Zc=class extends Error{},Qc=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;pending=[];undelivered=[];commands=[];context;cache;count=0;first=null;opening=null;turns=new Map;imageReaders=new Map;details=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=(e,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.details.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},...this.cache?{cache:this.cache}:{},count:this.count,turns:e,earlier:(e[0]?.ordinal??this.count)>0,loadingEarlier:this.loadingEarlier,error:this.error}}async tick(){if(this.closed||!this.active)return;if(this.running){this.again=!0;return}this.running=!0,clearTimeout(this.timer);let e=this.loadingEarlier,t=this.abort;try{await this.sync(t.signal),t===this.abort&&(this.error=``)}catch(e){if(this.closed)return;t===this.abort&&(this.error=e instanceof Zc?e.message:`unavailable`)}finally{this.running=!1}if(e&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=Xc(this.summary?.status)||[...this.turns.values()].some(e=>Xc(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?qc:Jc)}async sync(e){let t=this.pinned,n=await this.read({kind:`conversation`,id:this.id,leaf:t,known:this.leaf},e);if(e.aborted)return;if(n.kind!==`conversation`)throw new Zc(`invalid`);(!n.continues||n.turns<this.count)&&this.forget();let r=n.leaf===this.leaf?this.count:this.count-1;this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.pending=n.pending??[],this.undelivered=n.undelivered??[],this.commands=n.commands??[],this.context=n.context,this.cache=n.cache,this.summary=n.summary,this.count=n.turns;let i=Math.max(0,n.turns-2);this.first=Math.min(this.first??this.opening??i,i),this.opening=null,this.publish();let a=[];for(let e=this.first;e<this.count;e++){let t=this.turns.get(e);(!t||e>=r||t.header.stable<t.header.steps||Xc(t.header.status))&&a.push(e)}await Promise.all(a.map(t=>this.load(t,n.leaf,e)))}async load(e,t,n){let r=this.turns.get(e),i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{o[i.start+t]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n))))r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)});if(!n.aborted){if(o.some(e=>!e))throw new Zc(`stale`);this.turns.set(e,{ordinal:e,header:a,steps:o,detail:this.detail(t,a.id,n),image:this.imageReader(t,n)})}}async turnRead(e,t,n,r){let i=await this.read({kind:`conversation-turn`,id:this.id,leaf:n,ordinal:e,before:t},r);if(i.kind!==`conversation-turn`||i.ordinal!==e||i.leaf!==n)throw new Zc(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Oa([t,r]);try{return await Kc(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n){let r=`${e??``}:${t}`,i=this.details.get(r);return i||(i=async(r,i,a)=>{let o=await Promise.all(Array.from({length:i},async(i,o)=>{let s=Oa([n,a]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},s.signal);if(n.kind!==`conversation-step`||n.part!==o)throw new Zc(`invalid`);return n.item}finally{s.dispose()}}));return{text:o.map(e=>e.text).join(``),args:o.map(e=>e.args).join(``)}},this.details.set(r,i)),i}async read(e,t=this.abort.signal){this.reads>=Yc&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Zc(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Zc(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function $c(e,t,n,r=null){let[i,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new Qc(e,t,()=>s(n.view()));return n.choose(r),a(n),s(n.view()),()=>n.close()},[e,t,r]),(0,f.useEffect)(()=>{i?.setActive(n)},[i,n]),{...o??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:i?.refresh??el,loadEarlier:i?.loadEarlier??el,showFrom:i?.showFrom??el,choose:i?.choose??el}}function el(){}function tl(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`preparing`?r:void 0,[s,c]=(0,f.useState)(0),l=(0,f.useRef)(0),u=(0,f.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,revision:s,preview:o}),[e,i,a,n,s,o]),d=(0,f.useRef)(u);d.current=u;let p=(0,f.useRef)(!0);(0,f.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let m=(0,f.useCallback)(()=>p.current&&(u.epoch!==null||!!u.preview)&&d.current===u&&l.current===u.revision,[u]),[h,g]=(0,f.useState)();(0,f.useEffect)(()=>{if(u.epoch===null&&!u.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&m();return u.preview?(u.preview(t.signal).then(e=>{n()&&g({scope:u,preview:e})}).catch(e=>{n()&&g({scope:u,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal).then(e=>{n()&&(e.kind===`error`?g({scope:u,error:e.error.code}):e.value.version.epoch===u.epoch?g({scope:u,catalog:e.value}):g({scope:u,error:`stale`}))}).catch(()=>{n()&&g({scope:u,error:`unavailable`})}),()=>t.abort())},[e,u,m]);let _=h?.scope===u&&m()?h:void 0;return{catalog:_?.catalog,preview:_?.preview,error:_?.error,loading:(i!==null||!!o)&&!_,isCurrent:m,reread(){m()&&c(++l.current)},accept(e){return!m()||e.version.epoch!==u.epoch?!1:(g({scope:u,catalog:e}),!0)}}}function nl(e,t,n,r=!1){return t?r||!n||J(n)!==J(e.model)?`validate`:`approve`:`restore`}async function rl(e){let t=structuredClone(e.state),n=t.proposal,r=structuredClone(e.context),i={id:r.id,cwd:r.cwd},a=structuredClone(e.model),o=e.head,s=crypto.randomUUID(),c=()=>!e.signal.aborted&&e.current();if(!n||!t.enabled||r.id!==t.id||!c()||(e.prepare&&await Ec(e.prepare,e.signal,i,e.progress??(()=>{})),!c()))throw Error(`stale`);let l=await e.client.models(e.signal,i);if(!c())throw Error(`stale`);if(l.kind!==`ok`)throw Error(l.error.code);let u=await e.client.workbenchCommand({kind:`cadence-revalidate`,commandId:s,conversationId:t.id,revision:t.revision,proposalId:n.id,digest:n.digest,head:o,context:r,model:a,expected:l.value.version});if(!c())throw Error(`stale`);if(u.kind!==`ok`)throw Error(u.error.code);if(u.value.kind!==`cadence-revalidated`||u.value.state.id!==t.id||u.value.state.revision!==t.revision+1||!u.value.state.enabled||u.value.state.head!==t.head||J(u.value.state.runs)!==J(t.runs)||u.value.state.proposal?.id!==s||u.value.state.proposal.revalidatedFrom!==n.id||u.value.state.proposal.epoch!==l.value.version.epoch||u.value.state.proposal.cwd!==r.cwd||J(u.value.state.proposal.model.conversation??null)!==J(i)||J(u.value.state.proposal.plan)!==J(n.plan))throw Error(`stale`);return u.value.state}async function il(e){let t=e.state.proposal;if(!t||!e.state.enabled||!e.current())throw Error(`stale`);let n={conversationId:e.state.id,revision:e.state.revision,proposalId:t.id,digest:t.digest},r=await e.client.workbenchCommand({kind:`cadence-prepare`,commandId:crypto.randomUUID(),...n});if(r.kind!==`ok`)throw Error(r.error.code);if(r.value.kind!==`cadence-grant`||!e.current()||r.value.revision!==e.state.revision||J(r.value.proposal)!==J(t)||Date.now()>=r.value.expiresAt)throw Error(`stale`);let i=crypto.randomUUID();return e.submitting(i),e.client.workbenchCommand({kind:`cadence-approve`,commandId:i,...n,grant:r.value.grant})}function al(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function ol(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var sl=e=>`cadence:prompt-history:${e}`;function cl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function ll(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function ul(e){try{let t=sessionStorage.getItem(sl(e));return t?cl(JSON.parse(t)):[]}catch{return[]}}function dl(e,t){let n=t;for(;n;)try{sessionStorage.setItem(sl(e),JSON.stringify(n));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||n.length<=1)return;n=n.slice(Math.ceil(n.length/2))}}function fl(e,t){let n=ul(e),r=ll(n,t);r!==n&&dl(e,r)}var pl={index:-1,draft:``};function ml(e,t,n,r){if(n===`older`){if(!e.length||t.index===0)return null;let n=t.index===-1?e.length-1:Math.min(t.index,e.length)-1;return{cursor:{index:n,draft:t.index===-1?r:t.draft},text:e[n]}}if(t.index===-1)return null;let i=t.index+1;return i<e.length?{cursor:{index:i,draft:t.draft},text:e[i]}:{cursor:pl,text:t.draft}}function hl(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function gl(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!hl(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function _l(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{folder:``,name:e}:{folder:e.slice(0,t).replace(/[\\/]+$/,``),name:e.slice(t+1)}}var vl=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function yl(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[],a=[];for(let t of e){let e=t.name.toLowerCase().indexOf(r);e===0?i.push(t):e>0&&a.push(t)}return[...i,...a].slice(0,n)}function bl(e,t,n,r){let i=r.path.includes(`\\`)?`\\`:`/`,a=`@${r.path}${r.directory?i:` `}`,o=e.slice(n);return{text:e.slice(0,t.start)+a+(r.directory?o:o.replace(/^ /,``)),cursor:t.start+a.length}}function xl(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Sl=``;function Cl(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function wl(e,t){return{first:!e.slice(0,t).includes(`
|
|
18
18
|
`),last:!e.slice(t).includes(`
|
|
@@ -31,4 +31,4 @@ import{r as e}from"./rolldown-runtime.js";import{n as t,r as n,t as r}from"./rea
|
|
|
31
31
|
`}${r}`}var Od=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function kd(e){return[...e.matchAll(/[^\\/]+/g)].map(t=>({label:t[0],path:e.slice(0,t.index+t[0].length)}))}function Ad(e,t){let n=e.startsWith(`/`)?`/`:`\\`;return`${e.replace(/[\\/]+$/,``)}${n}${t.split(`/`).join(n)}`}var jd=`file-download`,Md=(0,f.memo)(function({path:e,text:t}){return(0,h.jsx)(as,{text:Dd(t,nu(e))})});function Nd({client:e,enabled:t,location:n,observed:r=``,onReference:i}){let{t:a}=T(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(null),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(``),[g,_]=(0,f.useState)(!1),{copied:v,copy:y}=Fo(),[x,S]=(0,f.useState)(null),C=(0,f.useRef)(null),w=n?.cwd,E=n?.id;(0,f.useEffect)(()=>()=>{C.current?.abort(),C.current=null,S(null)},[e,w,E]);let D=co(e,t?{kind:`files`,path:o,...n?{location:n}:{}}:null),O=co(e,t&&c?{kind:`file`,path:c,...n?{location:n}:{}}:null),{refresh:k}=D,{refresh:ee}=O,A=(0,f.useRef)(r);(0,f.useEffect)(()=>{A.current!==r&&(A.current=r,k(),ee())},[r,k,ee]);let j=D.value?.kind===`files`?D.value:void 0,te=O.value?.kind===`file`?O.value:void 0,M=e=>{s(e),d(null)},ne=(e,t)=>{m(e),y(t).then(e=>{e||Jo(`error`,a(`Copy unavailable`))})},N=t=>{let r=new AbortController;C.current=r,S(t.path),Xo(jd),bd(async i=>{let a=await e.workbenchRead({kind:`file-part`,path:t.path,offset:i,...n?{location:n}:{}},r.signal);if(r.signal.aborted)throw Error(`unavailable`);if(a.kind===`error`)throw Error(a.error.code);return a.value}).then(e=>{if(!r.signal.aborted)return Ed(e,t.name)}).catch(e=>{if(r.signal.aborted)return;let n=e instanceof Error?e.message:String(e);Jo(`error`,a(`Download of {path} failed: {error}`,{path:t.name,error:n===`oversize`?a(`the file is larger than the 64 MiB download limit`):b(a,n)}),jd)}).finally(()=>{C.current===r&&(C.current=null,S(null))})},P=u?.trim().toLowerCase()??``,re=j?.entries.filter(e=>!P||e.name.toLowerCase().includes(P));return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,h.jsx)(`button`,{type:`button`,className:`crumb${o?``:` active`}`,title:n?`${a(`Conversation folder:`)} ${n.cwd}`:void 0,disabled:!n,onClick:()=>M(``),children:n?Od(n.cwd):a(`Not observed`)}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,title:a(`Refresh files`),"aria-label":a(`Refresh files`),disabled:!t,onClick:()=>{D.refresh(),O.refresh()},children:(0,h.jsx)(ji,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${u===null?``:` active`}`,"aria-label":a(`Filter this folder…`),title:a(`Filter this folder…`),"aria-pressed":u!==null,disabled:!j,onClick:()=>d(u===null?``:null),children:(0,h.jsx)(ki,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${g?` active`:``}`,"aria-label":a(`About this panel`),title:a(`About this panel`),"aria-expanded":g,onClick:()=>_(e=>!e),children:(0,h.jsx)(Ji,{"aria-hidden":`true`})}),kd(o).map(e=>(0,h.jsxs)(`span`,{className:`crumb-seg`,children:[(0,h.jsx)(pa,{"aria-hidden":`true`}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${e.path===o?` active`:``}`,title:e.path,onClick:()=>M(e.path),children:e.label})]},e.path))]}),g&&(0,h.jsx)(`p`,{className:`files-policy`,children:a(`Readonly preview · references send paths, not file contents · a download is the file's own bytes, unredacted`)}),u!==null&&(0,h.jsxs)(`label`,{className:`file-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{autoFocus:!0,value:u,"aria-label":a(`Filter this folder…`),placeholder:a(`Filter this folder…`),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&d(null)}}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close`),onClick:()=>d(null),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),D.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(a,D.error)}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":a(`File list`),children:[t?!j&&!D.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(`Reading files…`)}):null:(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(n?`Files appear once this folder has been observed.`:`The conversation folder has not been observed.`)}),j&&j.parent!=null&&!P&&(0,h.jsxs)(`button`,{type:`button`,className:`file-item dir`,"aria-label":a(`Parent folder`),title:a(`Parent folder`),onClick:()=>M(j.parent??``),children:[(0,h.jsx)(Zi,{className:`file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-name`,children:`..`})]}),re?.map(e=>(0,h.jsxs)(`div`,{className:`file-item ${e.directory?`dir`:`file`}${c===e.path?` selected`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-main`,title:e.path,onClick:()=>e.directory?M(e.path):l(e.path),children:[e.directory?(0,h.jsx)(Zi,{className:`file-icon`,"aria-hidden":`true`}):(0,h.jsx)(Qi,{className:`file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-name`,children:e.name})]}),!e.directory&&(0,h.jsx)(`button`,{type:`button`,className:`file-attach download${x===e.path?` busy`:``}`,"aria-label":a(`Download file {path}`,{path:e.name}),title:a(`Download file {path}`,{path:e.name}),"aria-busy":x===e.path,disabled:!t||!!D.error||x!==null,onClick:()=>N(e),children:(0,h.jsx)(ra,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach ref`,"aria-label":a(e.directory?`Link folder path {path} to the chat`:`Reference path only: {path} (the agent reads it on demand)`,{path:e.name}),title:a(e.directory?`Link folder path {path} to the chat`:`Reference path only: {path} (the agent reads it on demand)`,{path:e.name}),disabled:!t||!!D.error,onClick:()=>i(e.path),children:(0,h.jsx)(Ui,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach copy${v&&p===`name:${e.path}`?` copied`:``}`,"aria-label":a(`Copy name {path}`,{path:e.name}),title:a(`Copy name {path}`,{path:e.name}),onClick:()=>ne(`name:${e.path}`,e.name),children:v&&p===`name:${e.path}`?(0,h.jsx)(ga,{"aria-hidden":`true`}):(0,h.jsx)(ca,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach copy${v&&p===`path:${e.path}`?` copied`:``}`,"aria-label":a(`Copy path {path}`,{path:e.name}),title:a(`Copy path {path}`,{path:e.name}),onClick:()=>ne(`path:${e.path}`,n?Ad(n.cwd,e.path):e.path),children:v&&p===`path:${e.path}`?(0,h.jsx)(ga,{"aria-hidden":`true`}):(0,h.jsx)(da,{"aria-hidden":`true`})})]},e.path)),t&&!D.error&&re?.length===0&&(P?(0,h.jsx)(`p`,{className:`panel-empty`,children:a(`No matching files`)}):(0,h.jsx)(`p`,{className:`panel-empty`,children:a(`No visible files`)})),j?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`Bounded listing; narrow the directory to see more.`)})]}),c&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(Qi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{title:c,children:Od(c)}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close preview`),title:a(`Close preview`),onClick:()=>l(null),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),O.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(a,O.error)}),te&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Md,{path:te.path,text:te.text}),te.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`File preview is limited; this is not the complete file.`)})]})]})]})}var Pd=`未命名章节`;function Fd(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function Id(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Fd(r||Pd),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Pd}})}function Ld(e){return e.length>=2}function Rd(e){let t=0,n=0;return e.split(`
|
|
32
32
|
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function zd({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:Rd(e).map(({text:e,key:t})=>{let n=``;return[`diff --git`,`index `,`new file`,`deleted file`,`old mode`,`new mode`,`similarity index`,`rename `,`copy `,`Binary files`,`---`,`+++`].some(t=>e.startsWith(t))?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,h.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})}function Bd({text:e}){let{t}=T(),[n,r]=(0,f.useState)(`raw`),[i,a]=(0,f.useState)(!0),[o,s]=(0,f.useState)(1),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(null),p=(0,f.useRef)(1),m=(0,f.useRef)(null),g=e.split(`
|
|
33
33
|
`);return(0,f.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(m.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=Id(t.map(e=>({level:Number(e.tagName[1]),label:e.textContent??``})));r.forEach((e,n)=>{t[n].id=`preview-${e.id}`}),l(r)},[e,n]),(0,h.jsxs)(`div`,{className:`fp-preview`,children:[(0,h.jsxs)(`div`,{className:`fp-head toolbar`,children:[(0,h.jsxs)(`label`,{children:[t(`View`),(0,h.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value===`markdown`?`markdown`:e.target.value===`diff`?`diff`:`raw`),children:[(0,h.jsx)(`option`,{value:`raw`,children:t(`Raw text / lines`)}),(0,h.jsx)(`option`,{value:`markdown`,children:t(`Safe Markdown`)}),(0,h.jsx)(`option`,{value:`diff`,children:t(`Observed diff`)})]})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),children:t(i?`Wrap: on`:`Wrap: off`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.min(2,e+.1)),children:t(`Zoom +`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.max(.8,e-.1)),children:t(`Zoom −`)}),(0,h.jsx)($o,{text:u?g.slice(u.start-1,u.end).join(`
|
|
34
|
-
`):e})]}),(0,h.jsx)(`p`,{className:`fp-notice`,children:t(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,h.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,h.jsxs)(`div`,{className:`fp-toc-layout`,children:[Ld(c)&&(0,h.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>m.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,h.jsx)(`div`,{className:`fp-markdown-zoom`,ref:m,children:(0,h.jsx)(as,{text:e})})]}):n===`diff`?(0,h.jsx)(zd,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Rd(e).map(({text:e,number:n,key:r})=>(0,h.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,h.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(p.current=n),d({start:Math.min(p.current,n),end:Math.max(p.current,n)})},children:n}),(0,h.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,h.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function Vd({client:e,seed:t}){let{t:n,tx:r}=T(),i=jo(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(gs,{pager:i}),(0,h.jsx)(`p`,{children:n(`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`)}),(0,h.jsx)(`div`,{className:`scm-files-list`,children:s&&!(`kind`in s)&&s.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,i=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,h.jsxs)(`article`,{className:`scm-file`,children:[(0,h.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(ko(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,h.jsx)(hs,{client:e,cursor:a,render:e=>(0,h.jsx)(Bd,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Hd=[`contents`,`checks`,`changes`,`reviews`];function Ud({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(`contents`);return(0,h.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,h.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:Hd.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(_s,{client:e,seed:t}):(0,h.jsx)(Vd,{client:e,seed:{...t,reader:i}},i)})]})}var Wd={relative:`Enter a full path, for example ~/project.`,invalid:`This folder does not exist. Check the path.`,forbidden:`This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).`,unavailable:`This folder could not be read right now; it may lack read permission. Try again.`},Gd=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Kd(e,t){let n=e.startsWith(`/`)?`/`:`\\`,r=(e,t)=>e.endsWith(n)?e+t:e+n+t,i=!!t&&(e===t||e.startsWith(r(t,``))),a=i?t:/^(?:\\\\[^\\]+\\[^\\]+|[A-Za-z]:\\|\/)/.exec(e)?.[0]??``;if(!a)return{inside:i,trail:[{name:e,path:e}]};let o=i?[]:[{name:a===`/`?`/`:a.replace(/\\$/,``),path:a}],s=a;for(let t of e.slice(a.length).split(/[\\/]/).filter(Boolean))s=r(s,t),o.push({name:t,path:s});return{inside:i,trail:o}}function qd({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l}=T(),[u,d]=(0,f.useState)(),[p,m]=(0,f.useState)(n??t),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),ee=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),j=(0,f.useRef)(n??t),te=(0,f.useRef)(null),M=(0,f.useRef)(null),ne=async t=>{A.current?.abort();let n=new AbortController;A.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&ee.current){if(A.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),m(r.value.path),_(!1),y(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,f.useRef)(ne);(0,f.useEffect)(()=>(ee.current=!0,N.current(j.current).then(()=>{ee.current&&w(!1)}),()=>{ee.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{g&&te.current?.select()},[g]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let P=e=>{E||ne(e)},re=()=>{let e=p.trim();E||(Gd(e)?ne(e):k({step:`read`,code:`relative`}))},F=(g||!u)&&p.trim()||u?.path||``,ie=!E&&!x&&!!F,I=async n=>{if(E||!n||x&&n===u?.path)return;if(n!==u?.path&&!Gd(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===u?.path?u.path:(await ne(n))?.path;if(!ee.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),ee.current&&a()}catch(e){ee.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(ee.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},L=u?Kd(u.path,r):void 0,ae=v.trim().toLowerCase(),R=u?.entries.filter(e=>e.name.toLowerCase().includes(ae))??[],z=O&&(O.step===`read`&&Wd[O.code]?l(Wd[O.code]):b(l,O.code));return(0,h.jsxs)(xs,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,h.jsx)(`h3`,{children:l(`Recent folders`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void I(e.path),children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[L&&!g?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:E,onClick:()=>P(`~`),children:[(0,h.jsx)(qi,{"aria-hidden":`true`}),L.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),L.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||L.inside)&&(0,h.jsx)(pa,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:E,onClick:()=>P(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),re()},children:(0,h.jsx)(`input`,{ref:te,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:p,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{m(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),_(!1),m(u.path),k(null))}})}),u&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":g,disabled:E,onClick:()=>{m(u.path),_(!g),k(null)},children:(0,h.jsx)(na,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:v,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(u.parent),children:[(0,h.jsx)(va,{}),l(`Parent folder`)]}),R.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(e.path),children:[(0,h.jsx)(Zi,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),u&&!x&&R.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(ae?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),z&&(0,h.jsxs)(`p`,{role:`alert`,children:[z,O?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[F&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:F})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!ie,onClick:()=>void I(F),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function Jd(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var Yd=[`today`,`yesterday`,`earlier`];function Xd(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function Zd(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=Xd(t(i),n);r.set(e,[...r.get(e)??[],i])}return Yd.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function Qd(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function $d(e,t,n=Date.now()){let r=new Date(e);return Xd(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function ef({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Mi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function tf(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var nf=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),rf=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function af(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var of={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},sf={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},cf={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},lf=e=>`conversation-row:${e}`;function uf(e,t){return t.kind===`refused`?{refusal:{text:sf[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function df(e,t){let{t:n}=T(),[r,i]=(0,f.useState)(()=>new Map),a=(0,f.useRef)(!0);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});Xo(lf(c)),l({pending:o}),af(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=uf(o,e);l(r),i&&Jo(`error`,n(i.text,{code:i.code}),lf(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,nf(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,rf(e,t))}}function ff({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=T(),d=u===`zh`?`zh-CN`:`en-GB`,[p,m]=(0,f.useState)(null),g=p!==null,_=(0,f.useRef)(null),v=(0,f.useRef)(null),y=(0,f.useRef)(!1);(0,f.useEffect)(()=>{let e=_.current;if(!g||!e){y.current&&v.current?.focus({preventScroll:!0}),y.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,m(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g]);let b=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),x=(0,h.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":b,title:b,children:e.origin===`terminal`?(0,h.jsx)(Ci,{"aria-hidden":`true`}):(0,h.jsx)(Ri,{"aria-hidden":`true`})}),S=()=>{if(p===null)return;let t=tf(p);t===null?Jo(`error`,l(`A name can have at most {count} characters.`,{count:100}),lf(e.id)):(y.current=!0,m(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(of[a.pending]):a?.unknown?l(cf[a.unknown.action],{code:a.unknown.code}):``;return g?(0,h.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),S()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||m(null)},children:[(0,h.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[x,(0,h.jsx)(`input`,{ref:_,className:`session-rename-input`,value:p,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>m(e.target.value)})]}),(0,h.jsxs)(`span`,{className:`session-actions`,children:[(0,h.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,h.jsx)(ga,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{y.current=!0,m(null)},children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]})]}):(0,h.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[x,(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,h.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,h.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:$d(e.updatedAt,d)})]}),c&&(0,h.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,h.jsx)(`button`,{ref:v,type:`button`,className:`session-action`,disabled:C,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>m(e.title),children:(0,h.jsx)(na,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,disabled:C,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,h.jsx)(Ai,{"aria-hidden":`true`}):(0,h.jsx)(Sa,{"aria-hidden":`true`})})]}),w&&(0,h.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function pf({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=T(),a=e.value?.entries??[];return(0,h.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,h.jsx)(ba,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,b(i,e.error)]}),e.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,h.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,h.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var mf={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function hf({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,h.jsxs)(`header`,{className:`lp-section-header`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(ha,{"aria-hidden":`true`}):(0,h.jsx)(pa,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,h.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function gf({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=Jd(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,h.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,h.jsx)(pa,{"aria-hidden":`true`}):(0,h.jsx)(ha,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(aa,{"aria-hidden":`true`}):(0,h.jsx)(Ri,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function _f({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=T(),a=e.page;return(0,h.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(gf,{runs:a.records.flatMap(e=>e.kind===`run`&&!r.includes(e.projection.runId)?[e.projection]:[]),scope:t,snapshot:a.request.snapshotSeq??void 0,onScope:n}),a.records.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,h.jsx)(gs,{pager:e,compact:!0})]})}function vf({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,canCancel:c,canceling:l,onCancel:u,onTask:d,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,onConversationsChanged:C,workflows:w,workflowLinks:E=[],workflowError:D=!1,discovery:O,selectedWorkflow:k,onWorkflow:ee,onCancelWorkflow:A}){let{t:j,tx:te}=T(),[M,ne]=(0,f.useState)(``),[N,P]=(0,f.useState)(!1),re=uo(e,N,!0),F=re.refresh,ie=df(e,e=>{F(),C?.(e)}),I=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,L=jo(e,I),ae=jo(e,r&&I&&t?{...I,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),R=L.page&&!(`kind`in L.page)?L.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],z=s?.status===`complete`?s.runs:[],B=R.filter(e=>!z.some(t=>t.taskId===e.owner.taskId)),V=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":j(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:j(`Task conversations`)}),(0,h.jsx)(_f,{pager:ae,scope:i,onScope:p,exclude:z.map(e=>e.runId)},r)]}),[H,U]=(0,f.useState)(()=>new Set),W=e=>{let t=E.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>ee?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[j(`Cadence workflow`),` · `,te(e.phase),` · `,te(e.status)]})]})]}),A&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:H.has(e.id),onClick:()=>{U(t=>new Set(t).add(e.id)),A(e).finally(()=>U(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),j(`Cancel workflow — request stop`)]})]},e.id)},G=m.filter(e=>e.status===`running`||e.status===`queued`),K=m.filter(e=>!G.includes(e)),oe=e=>w?.findLast(t=>E.some(n=>n.runId===t.id&&n.conversationId===e.id)),q=e=>{let t=e.status===`running`||e.status===`queued`,n=t||e.status===`completed`?oe(e):void 0,r=n?te(ed(n)):e.cadence&&t?j(`Discussing`):e.status===`completed`?``:te(e.status);return(0,h.jsx)(ff,{chat:e,selected:e.id===y,state:r,tone:n?`running`:e.status,onOpen:()=>b?.(e.id),row:ie.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>ie.archive(e.id,t),onRename:t||e.archived?void 0:t=>ie.rename(e.id,t)},e.id)},se=K.filter(e=>Qd(e.title,M)),J=B.filter(e=>Qd(e.goal,M));return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,h.jsx)(Ws,{...O,represented:!n&&O.project?[...(w??[]).map(e=>Us(O.project,`workflow`,e.id,e.epoch)),...G.flatMap(e=>e.live?[Us(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(ef,{onConversation:x}),!n&&(0,h.jsxs)(hf,{title:j(`Running work`),count:s?.status===`complete`&&w&&!D&&g?String(z.length+G.length+w.length):j(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Active roster unavailable; absence is not proof of settlement.`)}),D&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Conversation activity unavailable.`)}),G.map(q),w?.map(W),s?.status===`complete`&&z.length===0&&G.length===0&&w?.length===0&&!D&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`No active runs`)}),z.map(e=>{let t=R.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??j(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[te(e.kind),` · `,te(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),j(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(gf,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(hf,{title:j(N?`Archived conversations`:`Conversation history`),count:N?re.value?`${re.value.entries.length}${re.value.next||re.canPrevious?`+`:``}`:j(`Not observed`):t?L.page&&!(`kind`in L.page)?`${K.length+B.length}${L.page.next||L.canPrevious||_?`+`:``}`:j(`Not observed`):`${K.length}${_?`+`:``}`,className:`grow`,actions:(0,h.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":N,title:j(N?`Back to history`:`Show archived`),"aria-label":j(N?`Back to history`:`Show archived`),onClick:()=>P(e=>!e),children:(0,h.jsx)(Sa,{"aria-hidden":`true`})}),children:[N&&(0,h.jsx)(pf,{list:re,unavailable:S,onBack:()=>P(!1),row:q}),(0,h.jsxs)(`nav`,{"aria-label":j(`Tasks`),className:`task-list`,hidden:N,children:[(K.length>0||B.length>0)&&(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:M,placeholder:j(`Filter conversations…`),"aria-label":j(`Filter conversations…`),onChange:e=>ne(e.target.value)}),M&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:j(`Clear filter`),"aria-label":j(`Clear filter`),onClick:()=>ne(``),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),S&&K.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),Zd(se,e=>e.updatedAt).map(e=>(0,h.jsxs)(`div`,{className:`lp-time-group`,children:[(0,h.jsx)(`h3`,{className:`lp-time-label`,children:j(mf[e.key])}),e.items.map(q)]},e.key)),J.length>0&&(0,h.jsx)(`h3`,{className:`lp-time-label`,children:j(`Tasks`)}),J.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Ri,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:j(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&V]},e.owner.taskId)),se.length===0&&J.length===0&&(K.length>0||B.length>0)&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`No listed conversation matches. Pages not loaded are not searched.`)}),L.page&&!(`kind`in L.page)&&B.length===0&&K.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`No conversations yet.`)}),v,t&&(0,h.jsx)(gs,{pager:L,compact:!0})]}),!N&&!J.some(e=>e.owner.taskId===r)&&V]})]})}var yf=[`queued`,`running`];function bf({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=co(e,{kind:`workflow`,id:t.runId},s),u=l.value?.kind===`workflow`&&l.value.response.type===`run`?l.value.response.run:null,d=t.stepId?u?.steps.find(e=>e.id===t.stepId):void 0,p=d?yf.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!yf.includes(u.status)&&c(0)},[u]);let m=co(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!u?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,f.useMemo)(()=>g?$l(g):null,[g]),[v,y]=(0,f.useState)(!1),b=co(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(aa,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(sd,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,h.jsx)(Uu,{turn:_}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,h.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,h.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,h.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,h.jsx)(as,{text:d.text}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,h.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>y(!0),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,h.jsx)(`p`,{role:`alert`,children:b.error})]})]})]})}function xf({path:e,disabled:t=!1,onClick:n}){let{t:r}=T(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Sf({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=T(),o=r||t||n;return!e&&!o?null:(0,h.jsxs)(h.Fragment,{children:[e&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,h.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,h.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,h.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,h.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,h.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function Cf(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=to();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:G(e)});if(n&&(a.set(`scope`,JSON.stringify(Le(n.scope))),n.snapshotSeq&&a.set(`snapshot`,oe(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function wf(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=G(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?Le(ce(r)):void 0,o=i?oe(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ze(ce(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Tf=`cadence-panel-layout-v1`,Ef={left:260,right:360,navigation:!0,inspector:!1};function Df(e,t=600){return Math.max(220,Math.min(t,e))}function Of(e){let t={...Ef};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=Df(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function kf(e,t){let n=e<=900,r=Df(t.left,e-560),i=Df(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:Df(e-560-s),rightMaximum:Df(e-560-a)}}function Af({side:e,width:t,onResize:n,maximum:r}){let{t:i}=T(),a=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>a.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Df(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(Df(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Df(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var jf=[],Mf={error:wa,warning:Ca,info:Gi};function Nf({toast:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=n||i,s=Vo(e.level);(0,f.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>Yo(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=Mf[e.level];return(0,h.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,h.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,h.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>Yo(e.id),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]})}function Pf(){let e=(0,f.useSyncExternalStore)(Zo,Qo,()=>jf);return(0,h.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,h.jsx)(Nf,{toast:e},e.id))})}function Ff(e,t,n,r){(0,f.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus({preventScroll:!0});let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus({preventScroll:!0})):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus({preventScroll:!0}))}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[e,t,n,r])}var If=.4,Lf=1.05;function Rf(e){return Math.min(300,e*.86)}function zf(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Bf(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Vf(e,t){return e===`left`?t:-t}function Hf(e,t){return Math.max(-e,Math.min(0,-e+t))}function Uf(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Wf(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Uf(r*Lf,n,t)>=If}var Gf=new Set([`auto`,`scroll`,`overlay`]);function Kf(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Gf.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function qf(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Jf(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=zf(r.clientX,window.innerWidth,n);i&&!Kf(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=Bf(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Rf(window.innerWidth),h=m*Lf;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=Vf(r,d);let b=Hf(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Uf(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Wf({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(qf(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var Yf={system:[Fi,`System`],light:[wi,`Light`],dark:[Pi,`Dark`]};function Xf({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,onRefresh:u,onDisconnect:d,onOpenService:p,content:m}){let{t:g,locale:_,setLocale:v}=T(),[y,b]=(0,f.useState)(j),[S,C]=Yf[y],w=g(`Theme: {current}. Switch to {next}.`,{current:g(C),next:g(Yf[M(y)][1])}),{mobile:E,overlay:D,closeDrawer:O}=e,k=(0,f.useRef)(null),ee=(0,f.useRef)(null),A=()=>{ee.current&&(ee.current.open=!1)};return Jf({enabled:E,open:D,onOpenChange:e.setDrawer,container:k}),Ff(k,D,!!D,O),(0,h.jsxs)(`div`,{className:`app${e.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":g(`Toggle conversation navigation`),"aria-expanded":E?D===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,h.jsx)(zi,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:_===`zh`?`en`:`zh-CN`,"aria-label":_===`zh`?`Switch to English`:`切换到中文`,"data-tip":_===`zh`?`Switch to English`:`切换到中文`,onClick:()=>v(_===`zh`?`en`:`zh`),children:[(0,h.jsx)(Yi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:_===`zh`?`EN`:`中文`})]}),(0,h.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":w,"data-tip":w,onClick:()=>{let e=M(y);te(e),b(e)},children:(0,h.jsx)(S,{"aria-hidden":`true`})}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:ee,onKeyDown:e=>{e.key===`Escape`&&ee.current&&(ee.current.open=!1,ee.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":g(`More`),title:g(`More`),children:(0,h.jsx)(Ni,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Observe current state`),onClick:()=>{A(),u()},children:[(0,h.jsx)(ji,{"aria-hidden":`true`}),g(`Refresh status`)]}),p&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Cadence service`),onClick:()=>{A(),p()},children:[(0,h.jsx)(Oi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Cadence service`),(0,h.jsx)(`small`,{children:g(`Version, restart and upgrade.`)})]})]}),d&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Disconnect this page`),title:g(`Return — accepted work continues`),onClick:()=>{A(),O(),d()},children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Disconnect this page`),(0,h.jsx)(`small`,{children:g(`Started work keeps running.`)})]})]}),(0,h.jsx)(`div`,{className:`more-menu-build`,title:Ha?.buildId??g(`unbuilt source`),children:(0,h.jsx)(x,{text:g(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ha?.buildId??g(`unbuilt source`)})}})})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":g(`Toggle workspace panels`),"aria-expanded":E?D===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,h.jsx)(Di,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:r??g(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{ref:k,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":g(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${D?` on`:``}`,onClick:O}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${D===`left`?` open`:``}`,"aria-label":g(`Conversation navigation`),tabIndex:-1,inert:E?D!==`left`:!e.navigation||D===`right`,children:t}),(0,h.jsx)(Af,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,h.jsx)(`main`,{className:`main`,inert:D!==null,children:m}),(0,h.jsx)(Af,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${D===`right`?` open`:``}`,"aria-label":g(`Files and history drawer`),tabIndex:-1,inert:E?D!==`right`:!e.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":g(`Workspace panels`),children:[i??(0,h.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),g(`Files`)]}),(0,h.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":g(`Collapse panel`),title:g(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,h.jsx)(pa,{"aria-hidden":`true`})})]}),n]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,h.jsx)(Pf,{})]})}function Zf(e){let t=Math.max(0,e.input),n=Math.max(0,e.read),r=Math.max(0,e.write),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0}}function Qf({cache:e}){let{t}=T(),n=e?Zf(e):void 0,r=n&&n.totalInput>0?n:void 0,i=r?`${(r.hitRate*100).toFixed(1)}%`:`—`,a=r?r.hitRate>=.7?` ok`:r.hitRate>=.4?` mid`:` warn`:``,o=r?`${t(`Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)`,{rate:i,read:pc(r.read),write:pc(r.write),miss:pc(r.miss),input:pc(r.totalInput)})} ${t(`Summed over every usage record of this session, on every branch.`)}`:t(`Cache hit: this session's usage records state no input tokens yet.`);return(0,h.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,h.jsx)(ia,{})}),(0,h.jsxs)(`span`,{className:`bar-item-text`,children:[(0,h.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,h.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var $f=31.42;function ep({usage:e}){let{t}=T(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?mc(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:pc(n),window:pc(r),percent:i}):t(`Context {used} tokens`,{used:pc(n)}):t(`Context size not observed yet`),o=e?[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `):t(`No completed model response is within reach of this branch's end, so no context size is stated.`),s=(0,h.jsxs)(`svg`,{className:`ctx-ring${i===null?``:i>=80?` warn`:i>=50?` mid`:` ok`}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,h.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,h.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:$f,strokeDashoffset:+($f*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,h.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,h.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,h.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`ctx-val`,children:pc(n)}),r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,h.jsx)(`span`,{className:`ctx-max`,children:pc(r)})]})]})})]})}function tp({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,h.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,h.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function np({dot:e,tip:t,latency:n,children:r}){let{t:i}=T(),a=n===null?t:`${i(`Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).`,{ms:n})} ${t}`;return(0,h.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,h.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,h.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function rp(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function ip({since:e,label:t}){let[n,r]=(0,f.useState)(Date.now);(0,f.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?rp(n-e):``;return(0,h.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,h.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,h.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function ap(){let[e,t]=(0,f.useState)(()=>{try{return Of(localStorage.getItem(Tf))}catch{return Of(null)}}),[n,r]=(0,f.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,f.useState)(null);(0,f.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=kf(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Tf,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,f.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}function op(e,t,n,r,i=`en`){let a=(e,t)=>v(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,o=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:o,group:`${r??`owner`}:${o}`,groupLabel:`${r??a(`Owner`)} · ${v(i,o)}`,kind:o===`tools`?`tool`:o===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:r??a(`owner`)}),status:a(`recorded fact`),clock:e.kind===`capture-fact`?a(`Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.`,{child:e.link.childRunId,first:e.capture.source.firstObservedMs,last:e.capture.source.lastObservedMs}):a(`Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.`,{epoch:e.link.epoch,ms:e.observedMs}),...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),c;return{lang:i,onData(e){return c=e,()=>{c=void 0}},readState(){c?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:s.length}],activeId:e})},readSegments(t){t===e&&c?.({kind:`segs`,convId:t,segs:s,reset:!0})},readSegment(t,n){let r=s.findIndex(e=>e.key===n);t!==e||r<0||c?.({kind:`seg_detail`,convId:t,key:n,seg:s[r],detail:JSON.stringify(o[r],null,2),analysis:{position:a(`Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.`,{seq:o[r].committedSeq,ordinal:r+1})}})},openDetail(t,r){let i=o.find(e=>e.recordId===r);t===e&&i&&n(i)},searchHistory:r}}var sp=`modulepreload`,cp=function(e){return`/`+e},lp={},up=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=cp(t,n),t=s(t),t in lp)return;lp[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:sp,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function dp({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=jo(e,{...t,reader:`events`}),a=i.page;return(0,h.jsxs)(`section`,{className:`timeline-view`,children:[(0,h.jsx)(`p`,{children:r(`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`)}),(0,h.jsx)(gs,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(fp,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function fp({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=T(),o=(0,f.useRef)(null),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(!1),d=(0,f.useRef)(r);return d.current=r,(0,f.useEffect)(()=>{let e=!1,r;return up(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,op(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(_s,{client:e,seed:t})]})}var pp=[[`tools`,Si],[`context`,Wi],[`timeline`,ua],[`runs`,Xi]];function mp({api:e,onOpenProject:t,homeFolder:n,projectEntries:r,notices:i,discovery:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareExecution:l,directoryNamespaces:u,previewModels:d,initialDraft:p,onDraftApplied:m}){let{t:g,tx:_}=T(),[v]=(0,f.useState)(()=>e??Ua()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,f.useState)(!1),[C]=(0,f.useState)(wf),[w,E]=(0,f.useState)(C?.taskId??null),[D,O]=(0,f.useState)(()=>C?null:no()??crypto.randomUUID()),k=io(y,D??``),[ee,A]=(0,f.useState)(null),[j,te]=(0,f.useState)([]),[M,ne]=(0,f.useState)(null),[N,P]=(0,f.useState)(C?`task`:`files`),[re,F]=(0,f.useState)(),[ie,I]=(0,f.useState)(),[L,ae]=(0,f.useState)(),[R,z]=(0,f.useState)(),[B,V]=(0,f.useState)(0),[H,U]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=no();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[W]=(0,f.useState)(()=>crypto.randomUUID()),G=(0,f.useCallback)(()=>I(void 0),[]),[K,oe]=(0,f.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),q=xo(s?.id,s?.epoch),se=!s||q.readiness===`running`,ce=!!s&&(q.readiness===`stopped`||q.readiness===`not-started`),le=(0,f.useRef)(null);se&&q.value?.epoch&&(le.current=q.value.epoch);let ue=!s||!ce&&(se||le.current!==null),Y=wo(v,w?{kind:`task`,id:w}:null,!x&&ue,le.current),de=(0,f.useRef)(!0);(Y.workspace||Y.observation||Y.error||Y.transportStatus===`stale`)&&(de.current=!1);let fe=!!(s&&(q.value||q.error)),pe=!x&&!!(Y.workspace||fe),me=(0,f.useRef)(null);(Y.workspace||q.value?.workspaceId)&&(me.current=Y.workspace?.workspaceId??q.value?.workspaceId??null);let he=e=>l?async(t,n,r)=>{let i=await l(e,t,n,r);if(t.aborted)throw Error(`stale`);q.prepared(i);let a=Y.reconnect();await Y.whenReady(i,t,a)}:void 0,ge=he(`send`),_e=he(`plan-validation`),ve=uo(v.client,pe),ye=co(v.client,Y.workspace&&!x?{kind:`conversation-active`}:null,1e3),be=ye.value?.kind===`conversation-active`?ye.value.entries:[],xe=[...be,...(ve.value?.entries??[]).filter(e=>!be.some(t=>t.id===e.id))],Se=co(v.client,Y.workspace&&!x?{kind:`workflow-active`}:null,2e3),Ce=Se.value?.kind===`workflow-active`?Se.value:void 0,we=(0,f.useMemo)(()=>[...new Set([...Ce?.runs.map(e=>e.id)??[],...j])],[Ce,j]),Te=co(v.client,!s&&Y.workspace&&!x?{kind:`projects`}:null),Ee=H??s?.cwd??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0),De=L?.id===D?L:void 0,Oe=R?.id===D?R:void 0,ke=$a();(0,f.useEffect)(()=>{De&&no()===De.id&&history.replaceState({...history.state,cadenceCwd:De.cwd,cadenceConversationId:De.id},``,location.href)},[De]);let Ae=D?De:Ee?{id:W,cwd:Ee}:void 0,je=De?.cwd??Ee??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0)??Y.workspace?.rootLabel,Me={state:Y.observation,transportStatus:Y.transportStatus,error:Y.error,refresh:Y.refresh},Ne=Me.state?.snapshot.scope.kind===`task`&&Me.state.snapshot.scope.id===w?Me.state.snapshot.context:void 0,Pe=ap(),{closeDrawer:Fe}=Pe,Ie=N===`branches`&&!!D,Le=!Ie&&(N!==`task`||!K),Re=()=>{P(`branches`),Pe.mobile?Pe.setDrawer(`right`):Pe.inspector||Pe.toggle(`right`)},[ze,Be]=(0,f.useState)(C?.snapshotSeq),[Ve,He]=(0,f.useState)(``),[X,Ue]=(0,f.useState)(``),We=(0,f.useRef)(null),[Ge,Z]=(0,f.useState)(`messages`),[Ke,qe]=(0,f.useState)(!1),[Je,Ye]=(0,f.useState)(!1),[Xe,Ze]=(0,f.useState)(),[Qe,$e]=(0,f.useState)(C?.cursor),[et,tt]=(0,f.useState)(``),[nt,rt]=(0,f.useState)([]),[it,at]=(0,f.useState)(new Set),ot=(0,f.useRef)(!0),st=e=>{ot.current&&rt(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?so(t,e):t)})},ct=(0,f.useRef)(new To),lt=J({taskId:w,scope:K,selectedSnapshot:ze??null,detached:x,attachment:Y.attachmentVersion,workspaceContext:Y.workspace?.context??null,observationError:Y.error??null});ct.current.select(lt),(0,f.useEffect)(()=>(ot.current=!0,()=>{ot.current=!1,ct.current.depart()}),[]);let Q=e=>{b(``);let t=e??crypto.randomUUID();e||U(je??Ee),A(null),t!==D&&(te([]),I(void 0)),ct.current.depart(),O(t),E(null),oe(null),He(``),Ue(``),Ze(void 0),$e(void 0),Be(void 0),Z(`messages`),P(e=>e===`task`?`files`:e),Fe();let n=t===D?io(location.hash,t).leaf:null;history.replaceState({cadenceCwd:je??Ee,cadenceConversationId:t},``,`${location.pathname}${location.search}${ao(`#chat=${t}`,n)}`)};(0,f.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let ut=(e,t)=>{A(null),te([]),O(null),P(`task`),He(t??``),Ue(``),Be(void 0),ct.current.depart(),E(e),oe({kind:`task`,id:e}),Ze(void 0),$e(void 0),Z(`messages`),Fe(),history.replaceState(null,``,Cf(e))};(0,f.useEffect)(()=>{let e=()=>{let e=wf();if(e)A(null),te([]),O(null),P(`task`),ct.current.depart(),Be(e.snapshotSeq),He(``),Ue(``),E(e.taskId),oe(e.scope??{kind:`task`,id:e.taskId}),Ze(void 0),$e(e.cursor),Z(`messages`),Fe();else{let e=no();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&U(t),I(void 0),A(null),te([]),O(e),E(null),oe(null),P(e=>e===`task`?`files`:e),ct.current.depart(),Fe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Fe]);let dt=(e,t,n)=>{A(null),Be(t),Ue(n??``),ct.current.depart(),oe(e),Ze(void 0),$e(void 0),Z(`messages`),Fe(),w&&history.replaceState(null,``,Cf(w,void 0,{scope:e,snapshotSeq:t}))},ft=ze??Me.state?.snapshot.committedSeq??Y.workspace?.committedSeq,pt=Y.workspace?.storeId,mt=K&&pt&&ft?{storeId:pt,scope:K,snapshotSeq:ft,reader:`messages`,after:null,limit:50}:null,ht=K&&pt&&ft?{storeId:pt,scope:K,snapshotSeq:ft,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,gt=Ne?Me.state?.snapshot.runs??[]:[],_t=ct.current.ticket(),vt=e=>{st(e),e.receipt&&ct.current.current(_t)&&Y.refresh()},yt=e=>{if(it.has(e)||!Y.attached||!Y.activeRuns)return;let t=crypto.randomUUID(),n=Y.activeRuns.epoch;at(t=>new Set(t).add(e)),st({commandId:t,error:g(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{vt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:g(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>st({commandId:t,error:g(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{ot.current&&at(t=>{let n=new Set(t);return n.delete(e),n})})};if(x)return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:g(`Detached`)}),(0,h.jsx)(`p`,{children:g(`Accepted service work continues. No Cancel was requested.`)}),nt.map(e=>(0,h.jsxs)(`p`,{children:[g(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>S(!1),children:g(`Reconnect as a viewer`)})]});let bt=Y.activeRuns,xt=bt?.status===`complete`?bt.runs:[],St=!x&&!Y.error&&Y.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`),Ct=se&&St,wt=se&&!!Y.workspace&&Y.attached&&!Y.error&&St,Tt=de.current&&!Me.state&&!Me.error&&!q.error&&(!s||!q.value&&q.readiness===`unknown`||q.readiness===`running`),Et=ce?{status:q.readiness===`not-started`?`not-started`:`stopped`}:se&&St&&Y.attached&&Y.epoch&&(!s||q.value?.epoch===Y.epoch)?{status:`ready`,epoch:Y.epoch,attachmentVersion:Y.attachmentVersion}:{status:Tt?`connecting`:`unavailable`},Dt=x?`Viewer disconnected`:Tt?`Connecting…`:s&&q.readiness===`unknown`?`Project readiness unknown`:s&&q.readiness===`stale`?`Project observation stale`:ce?`Ready to prepare execution`:St?Y.workspace?Me.state?.connection??(w?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`,Ot=Tt?`busy`:ce?``:!Ct||!Y.workspace?`error`:Me.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`)?`ok`:`busy`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Xf,{panels:Pe,onOpenService:o,onRefresh:()=>{Y.refresh(),q.refresh()},onDisconnect:()=>{qe(!1),Ye(!1),ct.current.depart(),S(!0)},inspectorLabel:g(K&&N===`task`?`History details`:Ie?`Branches`:`Files`),toolbar:K&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":g(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ge===`messages`&&!Qe,onClick:()=>{$e(void 0),Ze(void 0),Z(`messages`)},children:[(0,h.jsx)(Ri,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:We,onKeyDown:e=>{e.key===`Escape`&&We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Ge===`messages`?g(`Details`):_(Ge),(0,h.jsx)(ha,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[pp.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Ge===e,onClick:()=>{$e(void 0),Ze(void 0),Z(e),We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),_(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Export selected scope`),disabled:!mt,onClick:()=>{We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus()),Ye(!0)},children:[(0,h.jsx)(ra,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!w,onClick:()=>{w&&Po(Cf(w,Qe,K?{scope:K,snapshotSeq:ze}:void 0)).then(e=>e?Jo(`info`,g(`Link copied.`)):Jo(`error`,g(`Link copy unavailable.`)))},children:[(0,h.jsx)(Ui,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),actions:K&&(0,h.jsx)(As,{disabled:!ht,onOpen:()=>qe(!0)}),notices:(0,h.jsxs)(h.Fragment,{children:[!Y.workspace&&xt.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:xt.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[_(e.kind),` `,e.runId,` · `,_(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ut(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Y.attached||it.has(e.runId),onClick:()=>yt(e.runId),children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),i,(0,h.jsx)(Sf,{error:et,projectObservationError:q.error,observationError:Y.error,unavailable:!Tt&&!ce&&!Ct,onRefresh:()=>{Y.refresh(),q.refresh()}})]}),navigation:(0,h.jsxs)(h.Fragment,{children:[!pe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,h.jsx)(Ws,{...a}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(Tt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,h.jsx)(vf,{discovery:a,client:v.client,workspace:Y.workspace,executionStopped:ce,taskId:w,scope:K,runs:gt,snapshot:Me.state?.snapshot.committedSeq,activeRuns:Y.activeRuns,canCancel:Y.attached,canceling:it,onCancel:yt,chats:xe,chatActivityKnown:ye.value?.kind===`conversation-active`&&!ye.error,chatHistoryPartial:ve.loading||ve.canPrevious||!!ve.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[ve.error&&(0,h.jsx)(`p`,{role:`alert`,children:ve.error}),ve.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:g(`Reading conversation history…`)}),ve.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.previous,children:g(`Newer conversations`)}),ve.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.next,children:g(`Older conversations`)}),ve.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:ve.first,children:g(`Latest conversations`)}),ve.error&&(0,h.jsx)(`button`,{type:`button`,onClick:ve.refresh,children:g(`Observe current state`)})]}),conversationId:D,onConversation:Q,onNewConversation:()=>Q(),actionsUnavailable:wt?``:g(ce?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{ve.refresh(),e===D&&V(e=>e+1)},workflows:Ce?.runs,workflowLinks:Ce?.links,workflowError:!!Se.error,selectedWorkflow:ee?.runId,onWorkflow:(e,t)=>{t?Q(t):(A({runId:e.id,stepId:null,label:e.goal}),Fe())},onCancelWorkflow:async e=>{tt(await od(v.client,e)),Se.refresh()},onTask:ut,onScope:dt}),Y.workspace&&(0,h.jsx)(ac,{client:v.client,active:Y.activeRuns,taskId:w,runs:gt,snapshot:ft,workflowRuns:we,selected:ee,onOpenWorkflow:e=>{A(e),Fe()},onOpen:(e,t,n,r)=>{ut(e),oe({kind:`child`,id:t}),Ue(r),Be(n),history.replaceState(null,``,Cf(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,h.jsxs)(h.Fragment,{children:[D&&s&&!fe&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),ee&&(0,h.jsx)(bf,{client:v.client,agent:ee,backLabel:g(D?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>A(null),onOpenAgent:A},`${ee.runId}:${ee.stepId??``}`),D&&(!s||fe)&&(0,h.jsx)(vd,{client:v.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:Ee,onLocation:ae,onActivity:z,hidden:!!ee,onOpenAgent:A,onWorkflowRuns:te,onBranches:F,onOpenBranches:Re,workspaceId:s?`checkout:${s.path}`:me.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?q.value?.workspaceId??void 0:void 0,prepareForSend:ge,prepareForPlan:_e,actionsReady:wt,observe:B,available:pe,canInterrupt:Y.attached,enabled:ge?pe:!!Y.workspace&&Y.attached&&!Y.error,modelAvailability:Et,previewModels:d,initialDraft:p?.conversationId===D?p:void 0,onDraftApplied:()=>m?.(D),onModelChanged:()=>{ct.current.depart(),Y.refresh(),q.refresh()},onChanged:()=>{ve.refresh(),Y.refresh()},reference:ie,onReferenceUsed:G},`${s?.id??me.current??`connecting`}:${D}:${k.leaf??``}`),K&&!ee&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[K.kind!==`task`&&w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ut(w,Ve),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:Ve||K.id,children:K.kind===`task`?Ve||g(`Task {id}`,{id:K.id.slice(0,8)}):X||g(`{kind} {id}`,{kind:_(K.kind),id:K.id.slice(0,8)})}),K.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[g(`Recorded conversation`),` ·`,` `,g(`snapshot {seq}`,{seq:ft??``})]}),(0,h.jsx)(`code`,{children:K.id}),(0,h.jsx)(`p`,{children:g(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!ee,children:[!mt&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:g(`History is readonly. Start new work in a conversation with /cadence.`)})]}),mt&&Qe?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Xe&&(Xe.owner.entity.kind===`task`||Xe.owner.entity.kind===`message`||Xe.owner.entity.kind===`tool`)&&(0,h.jsx)(vs,{client:v.client,seed:{storeId:Qe.storeId,scope:Qe.scope,snapshotSeq:Qe.snapshotSeq,kind:Xe.owner.entity.kind,id:Xe.owner.entity.id,version:Xe.owner.entity.version}},`${Xe.owner.entity.id}:${Xe.owner.entity.version}`),(0,h.jsx)(hs,{client:v.client,cursor:Qe,highlight:Xe?.range},`${Qe.recordId}:${Qe.recordVersion}`)]}):mt&&(0,h.jsxs)(`div`,{className:Ge===`messages`||Ge===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ge===`messages`&&(0,h.jsx)(Bs,{client:v.client,seed:mt}),Ge===`tools`&&(0,h.jsx)(hp,{client:v.client,seed:mt}),Ge===`context`&&(0,h.jsx)(_s,{client:v.client,seed:mt}),Ge===`timeline`&&(0,h.jsx)(dp,{client:v.client,seed:mt,onSearch:()=>qe(!0)}),Ge===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:g(`Runs in the current snapshot`)}),gt.length>0?gt.map(e=>(0,h.jsx)(Es,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Ne&&Me.state?g(`No owner run projection in this snapshot.`):g(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:g(`Retained runs`)}),(0,h.jsx)(ks,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}},onScope:dt},w)]})]},`${K?.kind}:${K?.id}:${ze??`current`}`)]}),Y.workspace&&nt.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:nt.map(e=>(0,h.jsx)(Eo,{client:v.client,value:e,onChange:st},e.commandId))})]}),inspectorTabs:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Le,onClick:()=>P(`files`),children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),g(`Files`)]}),D&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ie,onClick:()=>P(`branches`),children:[(0,h.jsx)(Xi,{"aria-hidden":`true`}),g(`Branches`)]}),K&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!mt,onClick:()=>P(`task`),children:[(0,h.jsx)(Wi,{"aria-hidden":`true`}),g(`History details`)]})]}),inspector:Ie?(0,h.jsx)(dc,{view:re?.id===D?re:void 0,onChosen:Fe}):Le?(0,h.jsx)(Nd,{location:Ae,client:v.client,enabled:pe&&!!Ae,observed:`${q.readiness}:${q.value?.epoch??``}`,onReference:e=>{D||Q(W);let t=!D&&Ae?`${Ae.cwd.replace(/[\\/]+$/,``)}${Ae.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;I(t),Fe()}},Ae?.cwd??`owner`):mt?(0,h.jsx)(Ud,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}}},w):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),status:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(np,{tip:g(`Connection freshness is not execution outcome.`),dot:Ot,latency:Ot===`ok`||Ot===``?ke:null,children:_(Dt)}),s&&(0,h.jsx)(tp,{tone:`faint`,icon:(0,h.jsx)(Oi,{}),children:g(`Execution service: {status}`,{status:_(q.readiness)})}),Oe&&(0,h.jsx)(ep,{usage:Oe.context}),Oe&&(0,h.jsx)(Qf,{cache:Oe.cache}),Oe&&Oe.turns>0&&(0,h.jsx)(tp,{icon:(0,h.jsx)(Ri,{}),tip:g(`Turns in this conversation: {count}`,{count:Oe.turns}),children:Oe.turns}),Oe&&Oe.runningSince!==null&&(0,h.jsx)(ip,{since:Oe.runningSince,label:g(`Working`)}),bt?.status===`complete`?xt.length>0&&(0,h.jsx)(tp,{tone:`warn`,children:g(Ct?xt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:xt.length})}):!Tt&&!ce&&(0,h.jsx)(tp,{tone:`faint`,children:g(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(Y.workspace||s)&&(0,h.jsx)(xf,{path:je,onClick:()=>c?c(je):ne(``)})}),M!==null&&Y.workspace&&(0,h.jsx)(qd,{onOpen:t,projects:r??(Te.value?.kind===`projects`?Te.value.entries:[]),client:v.client,current:je??Y.workspace.rootLabel,initial:M||void 0,home:n,epoch:Y.workspace.epoch,onClose:()=>ne(null)}),Ke&&ht&&(0,h.jsx)(Ts,{client:v.client,seed:ht,onClose:()=>qe(!1),onHit:e=>{Ze(e),$e(e.cursor),w&&history.replaceState(null,``,Cf(w,e.cursor,K?{scope:K,snapshotSeq:ze}:void 0))}}),Je&&ht&&(0,h.jsx)(Ss,{request:{storeId:ht.storeId,scope:ht.scope,snapshotSeq:ht.snapshotSeq,format:`ndjson`},onClose:()=>Ye(!1)})]})}function hp({client:e,seed:t}){let n=jo(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(gs,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(Hs,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var gp=`cadence:folder-draft`,_p=()=>({text:``,model:null});function vp(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return _p();let t=null;try{e.model!=null&&(t=me(e.model))}catch{}return{text:e.text,model:t}}catch{return _p()}}function yp(e){try{e.text||e.model?sessionStorage.setItem(gp,JSON.stringify(e)):sessionStorage.removeItem(gp)}catch{}}function bp(e,t,n){let r=Vc(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(gp)}catch{}return{...n,conversationId:t}}var xp=`cadence-last-project`;function Sp(){try{let e=localStorage.getItem(xp);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Cp(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(xp,e)}catch{}}function wp(e){let t=Sp();return t?e.projects.find(e=>e.id===t):void 0}async function Tp(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=Cn(await fo(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Ep(e,t){let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t}),r=await fo(n);if(!n.ok)throw Error(po(r));return bn(r)}async function Dp(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await fo(t);if(!t.ok)throw Error(po(n));return On(n)}async function Op(e,t,n,r,i){let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await fo(s);if(!s.ok)throw mo(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(po(c));let l=Sn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function kp(e,t){let n=await Dp(t);return Op(`/workbench/v1/select`,{path:e},n,t)}async function Ap(e,t,n,r,i){let a=await Dp(n),o=a.projects.find(t=>t.id===e.id);if(!o||o.path!==e.path||o.cwd!==e.cwd)throw Error(`stale`);let s=await Op(t===`send`?`/workbench/v1/prepare-send`:`/workbench/v1/prepare-plan`,{projectId:e.id,commandId:crypto.randomUUID(),...r?{location:r}:{}},a,n,()=>i?.(`dispatched`));if(!s.project.epoch||s.project.id!==e.id||s.project.path!==e.path||s.project.cwd!==e.cwd)throw Error(`stale`);return i?.(`confirmed`),s}async function jp(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await kp(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Mp=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Np(e){let t=U(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:G(t.id),source:B(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:dn(t.sessionId),cwd:L(t.cwd,4096,!0),leaf:t.leaf===null?null:L(t.leaf,128,!0),history:B(t.history,[`shared`,`unavailable`]),phase:B(t.phase,Mp),freshness:B(t.freshness,[`current`,`stale`,`unknown`]),observedAt:R(t.observedAt,0),epoch:t.epoch===null?null:G(t.epoch),instance:t.instance===null?null:G(t.instance),executionCwd:t.executionCwd===null?null:L(t.executionCwd,4096,!0)}}function Pp(e){let t=U(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:V(t.kind,`activity-discovery`),epoch:G(t.epoch),observedAt:R(t.observedAt,0),completeness:B(t.completeness,[`complete`,`partial`]),unavailable:R(t.unavailable,0,1e4),projects:W(t.projects,128,e=>{let t=U(e,[`path`,`activities`]);return{path:L(t.path,4096,!0),activities:W(t.activities,256,Np)}})}}async function Fp(e){let t=Oa([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal}),n=await fo(e);if(!e.ok)throw Error(po(n));return Pp(n)}finally{t.dispose()}}function Ip(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function Lp(e,t,n,r=Fp){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?Ip(o,Date.now()):void 0,t(o,e instanceof Error?e.message:`unavailable`)}finally{i.signal.aborted||(a=setTimeout(s,3e3))}};return s(),()=>{i.abort(),clearTimeout(a)}}function Rp(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return Lp(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function zp({ready:e,previewModels:t,draft:n=_p(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=T(),d=ap(),[p,m]=(0,f.useState)(!1),g=tl(null,{status:`not-started`},`folder-setup`,t),_=()=>{d.closeDrawer(),a()};return(0,h.jsx)(Xf,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(ef,{disabled:!e,onConversation:_}),l&&(0,h.jsx)(Ws,{...l}),(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:u(`Conversation history`)})}),(0,h.jsx)(`div`,{className:`lp-section-body`,children:(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:u(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":u(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsxs)(Wu,{hint:u(`Choose a working folder to start. You can write a draft below.`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:_,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),u(`Choose a folder…`)]}),i&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i.status===`checking`?u(`Returning to your last folder {path}…`,{path:i.path}):u(`Could not restore {path}. Choose a folder to continue; nothing was started.`,{path:i.path})})]})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{"aria-label":u(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:u(`Write a message. Choose a folder before sending…`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(Il,{scope:`next-conversation`,availability:{status:`not-started`},read:g,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:p,onOpenChange:e=>{e&&!g.preview&&!g.loading&&g.reread(),m(e)},onChanged:()=>{}}),(0,h.jsx)(`span`,{className:`composer-hint`,children:u(`Choose a folder before sending.`)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,h.jsx)(va,{"aria-hidden":`true`})})]})]})]}),inspector:(0,h.jsx)(`aside`,{className:`panel files-panel`,children:(0,h.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,h.jsx)(tp,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,h.jsx)(xf,{disabled:!e,onClick:_})})}var Bp=`cadence-recovery-dismissed`,Vp={reboot:`The machine restarted while Cadence was running. Cadence recovered automatically.`,crash:`Cadence ended unexpectedly last time. It recovered automatically.`,restart:`Cadence ran into a problem and restarted itself.`,storage:`Cadence repaired some incomplete files automatically.`},Hp={"released-locks":`Released the previous run's locks.`,"stopped-workers":`Stopped {count} leftover worker processes.`,"stopped-owner":`Stopped the unresponsive previous process.`,"continued-history":`History continues after the last complete entry.`,"archived-history":`Unreadable history was archived and a new one was started.`,"archived-state":`Damaged state was archived; it started afresh.`,"rebuilt-registry":`Rebuilt the project registry.`,"removed-temporaries":`Set aside interrupted temporary files.`};function Up(){try{let e=JSON.parse(localStorage.getItem(Bp)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Wp(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Gp({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Up),[a,o]=(0,f.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(Bp,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:Wp(e.path)}):e.scope===`workbench`?n(`Cadence service`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Vp[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,h.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:u(e)}),` `,(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(Hp[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Kp={restart:18e4,upgrade:12e5},qp=1e3,Jp={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},Yp=e=>e instanceof Error?e.message:`unavailable`;function Xp(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(Jp[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function Zp(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Qp(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function $p({epoch:e,csrf:t,onClose:n}){let{t:r}=T(),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(null),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(),[E,D]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=new AbortController;return go(e.signal).then(a,t=>{e.signal.aborted||s(Yp(t))}),()=>e.abort()},[E]),(0,f.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>Kp[e.action])return w(`timeout`);try{let t=await go(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof F||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,qp)};return r=setTimeout(i,qp),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),_o().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),vo({action:n.action,from:i.version,to:n.to,work:i.work,epoch:e},t).then(e=>y({job:e,since:Date.now()})).catch(e=>{s(Yp(e)),m(!1),D(e=>e+1)}).finally(()=>_(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&Zp(C),o=i?.unit;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,h.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(x?`Cadence is starting again…`:`Stopping Cadence…`):r(x?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,h.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:Kp[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Xp(r,C)]}),(0,h.jsx)(`p`,{children:r(C===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,h.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,h.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,h.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,h.jsx)(`footer`,{children:a?(0,h.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let ee=i&&c&&typeof c==`object`?zn(c.version,i.version)>0:!1;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:n,children:[i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,h.jsx)(`p`,{children:Qp(r,i.upgrade)}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:Xp(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):ee?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):In(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(ya,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(ji,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function em(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(vp),[a,o]=(0,f.useState)(),s=(0,f.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,f.useState)(to),u=(0,f.useCallback)(e=>Ep(c??void 0,e),[c]),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(null),[_,v]=(0,f.useState)(``),[y,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(0),[w,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useCallback)(()=>C(e=>e+1),[]),ee=Rp(t?.epoch,k),A=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>A.current?.abort(),[]);let j=(0,f.useRef)(new Map),te=(0,f.useRef)(!c),M=(0,f.useRef)(null),ne=(0,f.useCallback)(()=>{M.current&&(M.current.abort(),M.current=null,O(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await fo(t);t.status===400&&po(r)===`invalid`?n(null):t.ok?(n(On(r)),x(``)):x(po(r))}catch{e.signal.aborted||x(`unavailable`)}})(),()=>e.abort()},[S]),(0,f.useEffect)(()=>{let e=()=>{A.current?.abort(),ne(),O(null),l(to())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ne]),(0,f.useEffect)(()=>{if(!t||!te.current||(te.current=!1,r.text||r.model))return;let e=wp(t);if(!e)return;let n=new AbortController;M.current=n,O({status:`checking`,path:e.cwd}),Tp(e.id,n.signal).then(t=>{n.signal.aborted||(M.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),O(null),l(e.id)):O({status:`unavailable`,path:e.cwd}))})},[t,r]);let N=(0,f.useCallback)((e,n)=>{ne(),O(null),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&j.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=!t?.projects.some(e=>e.id===c)&&!n&&!!(r.text||r.model);s?(o(bp(e.path,a,r)),i(_p())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:j.current.get(e.id)??`#chat=${a}`}`),l(e.id),p(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,ne,t,r]),P=(0,f.useCallback)(async e=>{A.current?.abort();let t=new AbortController;A.current=t;let r=await kp(e,t.signal);t.signal.aborted||(n(r.entry),N(r.project))},[N]),I=t?{value:ee.value,error:ee.error,opening:!!m,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,r)=>{A.current?.abort(),ne();let i=new AbortController;A.current=i,g(r.cwd),v(``),jp(t,r,i.signal).then(e=>{i.signal.aborted||(n(e.entry),N(e.project,r))}).catch(t=>{i.signal.aborted||v(b(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{A.current===i&&g(null)})}}:void 0,L=async(e,r,i,a)=>{let o=t?.projects.find(e=>e.id===c);if(!o)throw Error(`unavailable`);let s=await Ap(o,e,r,i,a);if(r.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},ae=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new F(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await fo(n);if(!n.ok){let e=po(r);return{kind:`error`,error:ie(re.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:ii(r)}}catch{return{kind:`error`,error:ie(`unavailable`)}}}}),[]),R=(0,f.useMemo)(()=>c?Ua(c):void 0,[c]),z=t?.projects.find(e=>e.id===c);if((0,f.useEffect)(()=>{z&&Cp(z.id)},[z]),t===null)return(0,h.jsx)(mp,{});let B=t&&w&&(0,h.jsx)($p,{epoch:t.epoch,csrf:t.csrf,onClose:()=>E(!1)}),V=()=>E(!0),H=t&&d!==null&&(0,h.jsx)(qd,{selectOnly:!0,client:ae,current:z?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>p(null),onOpen:P});return t&&z&&R?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mp,{api:R,project:z,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===z.path).map(e=>e.id).sort(),discovery:I,onPrepareExecution:L,onChooseFolder:e=>{A.current?.abort(),p(e??z.cwd)},onOpenProject:P,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,children:_}),(0,h.jsx)(Gp,{notices:t.recoveries,project:z.path}),` `]}),onOpenService:V},z.id),B,H]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(zp,{discovery:I,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),yp(e)},restore:D,onRefresh:()=>C(e=>e+1),onOpenService:t?V:void 0,onChooseFolder:()=>{ne(),v(``),A.current?.abort(),p(t?.home??``)},notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:_}),t&&(0,h.jsx)(Gp,{notices:t.recoveries}),y&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[y,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e=>e+1),children:e(`Reload observation`)})]}),c&&!z&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),H,B]})}function tm(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var nm=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(tm,{}):this.props.children}};A(ee());var rm=document.getElementById(`root`);if(!rm)throw Error(`Application root unavailable`);(0,p.createRoot)(rm).render((0,h.jsx)(E,{children:(0,h.jsx)(nm,{children:(0,h.jsx)(em,{})})}));export{up as t};
|
|
34
|
+
`):e})]}),(0,h.jsx)(`p`,{className:`fp-notice`,children:t(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,h.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,h.jsxs)(`div`,{className:`fp-toc-layout`,children:[Ld(c)&&(0,h.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>m.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,h.jsx)(`div`,{className:`fp-markdown-zoom`,ref:m,children:(0,h.jsx)(as,{text:e})})]}):n===`diff`?(0,h.jsx)(zd,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Rd(e).map(({text:e,number:n,key:r})=>(0,h.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,h.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(p.current=n),d({start:Math.min(p.current,n),end:Math.max(p.current,n)})},children:n}),(0,h.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,h.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function Vd({client:e,seed:t}){let{t:n,tx:r}=T(),i=jo(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(gs,{pager:i}),(0,h.jsx)(`p`,{children:n(`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`)}),(0,h.jsx)(`div`,{className:`scm-files-list`,children:s&&!(`kind`in s)&&s.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,i=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,h.jsxs)(`article`,{className:`scm-file`,children:[(0,h.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(ko(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,h.jsx)(hs,{client:e,cursor:a,render:e=>(0,h.jsx)(Bd,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Hd=[`contents`,`checks`,`changes`,`reviews`];function Ud({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(`contents`);return(0,h.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,h.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:Hd.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(_s,{client:e,seed:t}):(0,h.jsx)(Vd,{client:e,seed:{...t,reader:i}},i)})]})}var Wd={relative:`Enter a full path, for example ~/project.`,invalid:`This folder does not exist. Check the path.`,forbidden:`This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).`,unavailable:`This folder could not be read right now; it may lack read permission. Try again.`},Gd=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Kd(e,t){let n=e.startsWith(`/`)?`/`:`\\`,r=(e,t)=>e.endsWith(n)?e+t:e+n+t,i=!!t&&(e===t||e.startsWith(r(t,``))),a=i?t:/^(?:\\\\[^\\]+\\[^\\]+|[A-Za-z]:\\|\/)/.exec(e)?.[0]??``;if(!a)return{inside:i,trail:[{name:e,path:e}]};let o=i?[]:[{name:a===`/`?`/`:a.replace(/\\$/,``),path:a}],s=a;for(let t of e.slice(a.length).split(/[\\/]/).filter(Boolean))s=r(s,t),o.push({name:t,path:s});return{inside:i,trail:o}}function qd({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l}=T(),[u,d]=(0,f.useState)(),[p,m]=(0,f.useState)(n??t),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),ee=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),j=(0,f.useRef)(n??t),te=(0,f.useRef)(null),M=(0,f.useRef)(null),ne=async t=>{A.current?.abort();let n=new AbortController;A.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&ee.current){if(A.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),m(r.value.path),_(!1),y(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,f.useRef)(ne);(0,f.useEffect)(()=>(ee.current=!0,N.current(j.current).then(()=>{ee.current&&w(!1)}),()=>{ee.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{g&&te.current?.select()},[g]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let P=e=>{E||ne(e)},re=()=>{let e=p.trim();E||(Gd(e)?ne(e):k({step:`read`,code:`relative`}))},F=(g||!u)&&p.trim()||u?.path||``,ie=!E&&!x&&!!F,I=async n=>{if(E||!n||x&&n===u?.path)return;if(n!==u?.path&&!Gd(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===u?.path?u.path:(await ne(n))?.path;if(!ee.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),ee.current&&a()}catch(e){ee.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(ee.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},L=u?Kd(u.path,r):void 0,ae=v.trim().toLowerCase(),R=u?.entries.filter(e=>e.name.toLowerCase().includes(ae))??[],z=O&&(O.step===`read`&&Wd[O.code]?l(Wd[O.code]):b(l,O.code));return(0,h.jsxs)(xs,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,h.jsx)(`h3`,{children:l(`Recent folders`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void I(e.path),children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[L&&!g?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:E,onClick:()=>P(`~`),children:[(0,h.jsx)(qi,{"aria-hidden":`true`}),L.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),L.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||L.inside)&&(0,h.jsx)(pa,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:E,onClick:()=>P(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),re()},children:(0,h.jsx)(`input`,{ref:te,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:p,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{m(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),_(!1),m(u.path),k(null))}})}),u&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":g,disabled:E,onClick:()=>{m(u.path),_(!g),k(null)},children:(0,h.jsx)(na,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:v,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(u.parent),children:[(0,h.jsx)(va,{}),l(`Parent folder`)]}),R.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(e.path),children:[(0,h.jsx)(Zi,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),u&&!x&&R.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(ae?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),z&&(0,h.jsxs)(`p`,{role:`alert`,children:[z,O?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[F&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:F})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!ie,onClick:()=>void I(F),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function Jd(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var Yd=[`today`,`yesterday`,`earlier`];function Xd(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function Zd(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=Xd(t(i),n);r.set(e,[...r.get(e)??[],i])}return Yd.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function Qd(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function $d(e,t,n=Date.now()){let r=new Date(e);return Xd(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function ef({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Mi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function tf(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var nf=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),rf=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function af(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var of={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},sf={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},cf={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},lf=e=>`conversation-row:${e}`;function uf(e,t){return t.kind===`refused`?{refusal:{text:sf[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function df(e,t){let{t:n}=T(),[r,i]=(0,f.useState)(()=>new Map),a=(0,f.useRef)(!0);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});Xo(lf(c)),l({pending:o}),af(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=uf(o,e);l(r),i&&Jo(`error`,n(i.text,{code:i.code}),lf(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,nf(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,rf(e,t))}}function ff({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=T(),d=u===`zh`?`zh-CN`:`en-GB`,[p,m]=(0,f.useState)(null),g=p!==null,_=(0,f.useRef)(null),v=(0,f.useRef)(null),y=(0,f.useRef)(!1);(0,f.useEffect)(()=>{let e=_.current;if(!g||!e){y.current&&v.current?.focus({preventScroll:!0}),y.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,m(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g]);let b=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),x=(0,h.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":b,title:b,children:e.origin===`terminal`?(0,h.jsx)(Ci,{"aria-hidden":`true`}):(0,h.jsx)(Ri,{"aria-hidden":`true`})}),S=()=>{if(p===null)return;let t=tf(p);t===null?Jo(`error`,l(`A name can have at most {count} characters.`,{count:100}),lf(e.id)):(y.current=!0,m(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(of[a.pending]):a?.unknown?l(cf[a.unknown.action],{code:a.unknown.code}):``;return g?(0,h.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),S()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||m(null)},children:[(0,h.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[x,(0,h.jsx)(`input`,{ref:_,className:`session-rename-input`,value:p,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>m(e.target.value)})]}),(0,h.jsxs)(`span`,{className:`session-actions`,children:[(0,h.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,h.jsx)(ga,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{y.current=!0,m(null)},children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]})]}):(0,h.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[x,(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,h.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,h.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:$d(e.updatedAt,d)})]}),c&&(0,h.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,h.jsx)(`button`,{ref:v,type:`button`,className:`session-action`,disabled:C,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>m(e.title),children:(0,h.jsx)(na,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,disabled:C,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,h.jsx)(Ai,{"aria-hidden":`true`}):(0,h.jsx)(Sa,{"aria-hidden":`true`})})]}),w&&(0,h.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function pf({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=T(),a=e.value?.entries??[];return(0,h.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,h.jsx)(ba,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,b(i,e.error)]}),e.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,h.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,h.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var mf={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function hf({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,h.jsxs)(`header`,{className:`lp-section-header`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(ha,{"aria-hidden":`true`}):(0,h.jsx)(pa,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,h.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function gf({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=Jd(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,h.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,h.jsx)(pa,{"aria-hidden":`true`}):(0,h.jsx)(ha,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(aa,{"aria-hidden":`true`}):(0,h.jsx)(Ri,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function _f({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=T(),a=e.page;return(0,h.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(gf,{runs:a.records.flatMap(e=>e.kind===`run`&&!r.includes(e.projection.runId)?[e.projection]:[]),scope:t,snapshot:a.request.snapshotSeq??void 0,onScope:n}),a.records.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,h.jsx)(gs,{pager:e,compact:!0})]})}function vf({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,canCancel:c,canceling:l,onCancel:u,onTask:d,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,onConversationsChanged:C,workflows:w,workflowLinks:E=[],workflowError:D=!1,discovery:O,selectedWorkflow:k,onWorkflow:ee,onCancelWorkflow:A}){let{t:j,tx:te}=T(),[M,ne]=(0,f.useState)(``),[N,P]=(0,f.useState)(!1),re=uo(e,N,!0),F=re.refresh,ie=df(e,e=>{F(),C?.(e)}),I=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,L=jo(e,I),ae=jo(e,r&&I&&t?{...I,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),R=L.page&&!(`kind`in L.page)?L.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],z=s?.status===`complete`?s.runs:[],B=R.filter(e=>!z.some(t=>t.taskId===e.owner.taskId)),V=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":j(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:j(`Task conversations`)}),(0,h.jsx)(_f,{pager:ae,scope:i,onScope:p,exclude:z.map(e=>e.runId)},r)]}),[H,U]=(0,f.useState)(()=>new Set),W=e=>{let t=E.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>ee?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[j(`Cadence workflow`),` · `,te(e.phase),` · `,te(e.status)]})]})]}),A&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:H.has(e.id),onClick:()=>{U(t=>new Set(t).add(e.id)),A(e).finally(()=>U(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),j(`Cancel workflow — request stop`)]})]},e.id)},G=m.filter(e=>e.status===`running`||e.status===`queued`),K=m.filter(e=>!G.includes(e)),oe=e=>w?.findLast(t=>E.some(n=>n.runId===t.id&&n.conversationId===e.id)),q=e=>{let t=e.status===`running`||e.status===`queued`,n=t||e.status===`completed`?oe(e):void 0,r=n?te(ed(n)):e.cadence&&t?j(`Discussing`):e.status===`completed`?``:te(e.status);return(0,h.jsx)(ff,{chat:e,selected:e.id===y,state:r,tone:n?`running`:e.status,onOpen:()=>b?.(e.id),row:ie.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>ie.archive(e.id,t),onRename:t||e.archived?void 0:t=>ie.rename(e.id,t)},e.id)},se=K.filter(e=>Qd(e.title,M)),J=B.filter(e=>Qd(e.goal,M));return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,h.jsx)(Ws,{...O,represented:!n&&O.project?[...(w??[]).map(e=>Us(O.project,`workflow`,e.id,e.epoch)),...G.flatMap(e=>e.live?[Us(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(ef,{onConversation:x}),!n&&(0,h.jsxs)(hf,{title:j(`Running work`),count:s?.status===`complete`&&w&&!D&&g?String(z.length+G.length+w.length):j(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Active roster unavailable; absence is not proof of settlement.`)}),D&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Conversation activity unavailable.`)}),G.map(q),w?.map(W),s?.status===`complete`&&z.length===0&&G.length===0&&w?.length===0&&!D&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`No active runs`)}),z.map(e=>{let t=R.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??j(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[te(e.kind),` · `,te(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),j(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(gf,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(hf,{title:j(N?`Archived conversations`:`Conversation history`),count:N?re.value?`${re.value.entries.length}${re.value.next||re.canPrevious?`+`:``}`:j(`Not observed`):t?L.page&&!(`kind`in L.page)?`${K.length+B.length}${L.page.next||L.canPrevious||_?`+`:``}`:j(`Not observed`):`${K.length}${_?`+`:``}`,className:`grow`,actions:(0,h.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":N,title:j(N?`Back to history`:`Show archived`),"aria-label":j(N?`Back to history`:`Show archived`),onClick:()=>P(e=>!e),children:(0,h.jsx)(Sa,{"aria-hidden":`true`})}),children:[N&&(0,h.jsx)(pf,{list:re,unavailable:S,onBack:()=>P(!1),row:q}),(0,h.jsxs)(`nav`,{"aria-label":j(`Tasks`),className:`task-list`,hidden:N,children:[(K.length>0||B.length>0)&&(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:M,placeholder:j(`Filter conversations…`),"aria-label":j(`Filter conversations…`),onChange:e=>ne(e.target.value)}),M&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:j(`Clear filter`),"aria-label":j(`Clear filter`),onClick:()=>ne(``),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),S&&K.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),Zd(se,e=>e.updatedAt).map(e=>(0,h.jsxs)(`div`,{className:`lp-time-group`,children:[(0,h.jsx)(`h3`,{className:`lp-time-label`,children:j(mf[e.key])}),e.items.map(q)]},e.key)),J.length>0&&(0,h.jsx)(`h3`,{className:`lp-time-label`,children:j(`Tasks`)}),J.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Ri,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:j(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&V]},e.owner.taskId)),se.length===0&&J.length===0&&(K.length>0||B.length>0)&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`No listed conversation matches. Pages not loaded are not searched.`)}),L.page&&!(`kind`in L.page)&&B.length===0&&K.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`No conversations yet.`)}),v,t&&(0,h.jsx)(gs,{pager:L,compact:!0})]}),!N&&!J.some(e=>e.owner.taskId===r)&&V]})]})}var yf=[`queued`,`running`];function bf({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=co(e,{kind:`workflow`,id:t.runId},s),u=l.value?.kind===`workflow`&&l.value.response.type===`run`?l.value.response.run:null,d=t.stepId?u?.steps.find(e=>e.id===t.stepId):void 0,p=d?yf.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!yf.includes(u.status)&&c(0)},[u]);let m=co(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!u?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,f.useMemo)(()=>g?$l(g):null,[g]),[v,y]=(0,f.useState)(!1),b=co(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(aa,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(sd,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,h.jsx)(Uu,{turn:_}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,h.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,h.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,h.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,h.jsx)(as,{text:d.text}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,h.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>y(!0),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,h.jsx)(`p`,{role:`alert`,children:b.error})]})]})]})}function xf({path:e,disabled:t=!1,onClick:n}){let{t:r}=T(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Sf({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=T(),o=r||t||n;return!e&&!o?null:(0,h.jsxs)(h.Fragment,{children:[e&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,h.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,h.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,h.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,h.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,h.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function Cf(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=to();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:G(e)});if(n&&(a.set(`scope`,JSON.stringify(Le(n.scope))),n.snapshotSeq&&a.set(`snapshot`,oe(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function wf(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=G(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?Le(ce(r)):void 0,o=i?oe(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ze(ce(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Tf=`cadence-panel-layout-v1`,Ef={left:260,right:360,navigation:!0,inspector:!1};function Df(e,t=600){return Math.max(220,Math.min(t,e))}function Of(e){let t={...Ef};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=Df(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function kf(e,t){let n=e<=900,r=Df(t.left,e-560),i=Df(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:Df(e-560-s),rightMaximum:Df(e-560-a)}}function Af({side:e,width:t,onResize:n,maximum:r}){let{t:i}=T(),a=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>a.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Df(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(Df(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Df(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var jf=[],Mf={error:wa,warning:Ca,info:Gi};function Nf({toast:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=n||i,s=Vo(e.level);(0,f.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>Yo(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=Mf[e.level];return(0,h.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,h.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,h.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>Yo(e.id),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]})}function Pf(){let e=(0,f.useSyncExternalStore)(Zo,Qo,()=>jf);return(0,h.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,h.jsx)(Nf,{toast:e},e.id))})}function Ff(e,t,n,r){(0,f.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus({preventScroll:!0});let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus({preventScroll:!0})):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus({preventScroll:!0}))}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[e,t,n,r])}var If=.4,Lf=1.05;function Rf(e){return Math.min(300,e*.86)}function zf(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Bf(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Vf(e,t){return e===`left`?t:-t}function Hf(e,t){return Math.max(-e,Math.min(0,-e+t))}function Uf(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Wf(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Uf(r*Lf,n,t)>=If}var Gf=new Set([`auto`,`scroll`,`overlay`]);function Kf(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Gf.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function qf(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Jf(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=zf(r.clientX,window.innerWidth,n);i&&!Kf(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=Bf(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Rf(window.innerWidth),h=m*Lf;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=Vf(r,d);let b=Hf(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Uf(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Wf({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(qf(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var Yf={system:[Fi,`System`],light:[wi,`Light`],dark:[Pi,`Dark`]};function Xf({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,onRefresh:u,onDisconnect:d,onOpenService:p,content:m}){let{t:g,locale:_,setLocale:v}=T(),[y,b]=(0,f.useState)(j),[S,C]=Yf[y],w=g(`Theme: {current}. Switch to {next}.`,{current:g(C),next:g(Yf[M(y)][1])}),{mobile:E,overlay:D,closeDrawer:O}=e,k=(0,f.useRef)(null),ee=(0,f.useRef)(null),A=()=>{ee.current&&(ee.current.open=!1)};return Jf({enabled:E,open:D,onOpenChange:e.setDrawer,container:k}),Ff(k,D,!!D,O),(0,h.jsxs)(`div`,{className:`app${e.className} antialiased`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":g(`Toggle conversation navigation`),"aria-expanded":E?D===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,h.jsx)(zi,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:_===`zh`?`en`:`zh-CN`,"aria-label":_===`zh`?`Switch to English`:`切换到中文`,"data-tip":_===`zh`?`Switch to English`:`切换到中文`,onClick:()=>v(_===`zh`?`en`:`zh`),children:[(0,h.jsx)(Yi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:_===`zh`?`EN`:`中文`})]}),(0,h.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":w,"data-tip":w,onClick:()=>{let e=M(y);te(e),b(e)},children:(0,h.jsx)(S,{"aria-hidden":`true`})}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:ee,onKeyDown:e=>{e.key===`Escape`&&ee.current&&(ee.current.open=!1,ee.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":g(`More`),title:g(`More`),children:(0,h.jsx)(Ni,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Observe current state`),onClick:()=>{A(),u()},children:[(0,h.jsx)(ji,{"aria-hidden":`true`}),g(`Refresh status`)]}),p&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Cadence service`),onClick:()=>{A(),p()},children:[(0,h.jsx)(Oi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Cadence service`),(0,h.jsx)(`small`,{children:g(`Version, restart and upgrade.`)})]})]}),d&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Disconnect this page`),title:g(`Return — accepted work continues`),onClick:()=>{A(),O(),d()},children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Disconnect this page`),(0,h.jsx)(`small`,{children:g(`Started work keeps running.`)})]})]}),(0,h.jsx)(`div`,{className:`more-menu-build`,title:Ha?.buildId??g(`unbuilt source`),children:(0,h.jsx)(x,{text:g(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ha?.buildId??g(`unbuilt source`)})}})})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":g(`Toggle workspace panels`),"aria-expanded":E?D===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,h.jsx)(Di,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:r??g(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{ref:k,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":g(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${D?` on`:``}`,onClick:O}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${D===`left`?` open`:``}`,"aria-label":g(`Conversation navigation`),tabIndex:-1,inert:E?D!==`left`:!e.navigation||D===`right`,children:t}),(0,h.jsx)(Af,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,h.jsx)(`main`,{className:`main`,inert:D!==null,children:m}),(0,h.jsx)(Af,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${D===`right`?` open`:``}`,"aria-label":g(`Files and history drawer`),tabIndex:-1,inert:E?D!==`right`:!e.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":g(`Workspace panels`),children:[i??(0,h.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),g(`Files`)]}),(0,h.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":g(`Collapse panel`),title:g(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,h.jsx)(pa,{"aria-hidden":`true`})})]}),n]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,h.jsx)(Pf,{})]})}function Zf(e){let t=Math.max(0,e.input),n=Math.max(0,e.read),r=Math.max(0,e.write),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0}}function Qf({cache:e}){let{t}=T(),n=e?Zf(e):void 0,r=n&&n.totalInput>0?n:void 0,i=r?`${(r.hitRate*100).toFixed(1)}%`:`—`,a=r?r.hitRate>=.7?` ok`:r.hitRate>=.4?` mid`:` warn`:``,o=r?`${t(`Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)`,{rate:i,read:pc(r.read),write:pc(r.write),miss:pc(r.miss),input:pc(r.totalInput)})} ${t(`Summed over every usage record of this session, on every branch.`)}`:t(`Cache hit: this session's usage records state no input tokens yet.`);return(0,h.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,h.jsx)(ia,{})}),(0,h.jsxs)(`span`,{className:`bar-item-text`,children:[(0,h.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,h.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var $f=31.42;function ep({usage:e}){let{t}=T(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?mc(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:pc(n),window:pc(r),percent:i}):t(`Context {used} tokens`,{used:pc(n)}):t(`Context size not observed yet`),o=e?[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `):t(`No completed model response is within reach of this branch's end, so no context size is stated.`),s=(0,h.jsxs)(`svg`,{className:`ctx-ring${i===null?``:i>=80?` warn`:i>=50?` mid`:` ok`}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,h.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,h.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:$f,strokeDashoffset:+($f*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,h.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,h.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,h.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`ctx-val`,children:pc(n)}),r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,h.jsx)(`span`,{className:`ctx-max`,children:pc(r)})]})]})})]})}function tp({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,h.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,h.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function np({dot:e,tip:t,latency:n,children:r}){let{t:i}=T(),a=n===null?t:`${i(`Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).`,{ms:n})} ${t}`;return(0,h.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,h.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,h.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function rp(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function ip({since:e,label:t}){let[n,r]=(0,f.useState)(Date.now);(0,f.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?rp(n-e):``;return(0,h.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,h.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,h.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function ap(){let[e,t]=(0,f.useState)(()=>{try{return Of(localStorage.getItem(Tf))}catch{return Of(null)}}),[n,r]=(0,f.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,f.useState)(null);(0,f.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=kf(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Tf,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,f.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}function op(e,t,n,r,i=`en`){let a=(e,t)=>v(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,o=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:o,group:`${r??`owner`}:${o}`,groupLabel:`${r??a(`Owner`)} · ${v(i,o)}`,kind:o===`tools`?`tool`:o===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:r??a(`owner`)}),status:a(`recorded fact`),clock:e.kind===`capture-fact`?a(`Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.`,{child:e.link.childRunId,first:e.capture.source.firstObservedMs,last:e.capture.source.lastObservedMs}):a(`Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.`,{epoch:e.link.epoch,ms:e.observedMs}),...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),c;return{lang:i,onData(e){return c=e,()=>{c=void 0}},readState(){c?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:s.length}],activeId:e})},readSegments(t){t===e&&c?.({kind:`segs`,convId:t,segs:s,reset:!0})},readSegment(t,n){let r=s.findIndex(e=>e.key===n);t!==e||r<0||c?.({kind:`seg_detail`,convId:t,key:n,seg:s[r],detail:JSON.stringify(o[r],null,2),analysis:{position:a(`Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.`,{seq:o[r].committedSeq,ordinal:r+1})}})},openDetail(t,r){let i=o.find(e=>e.recordId===r);t===e&&i&&n(i)},searchHistory:r}}var sp=`modulepreload`,cp=function(e){return`/`+e},lp={},up=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=cp(t,n),t=s(t),t in lp)return;lp[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:sp,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function dp({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=jo(e,{...t,reader:`events`}),a=i.page;return(0,h.jsxs)(`section`,{className:`timeline-view`,children:[(0,h.jsx)(`p`,{children:r(`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`)}),(0,h.jsx)(gs,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(fp,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function fp({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=T(),o=(0,f.useRef)(null),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(!1),d=(0,f.useRef)(r);return d.current=r,(0,f.useEffect)(()=>{let e=!1,r;return up(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,op(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(_s,{client:e,seed:t})]})}var pp=[[`tools`,Si],[`context`,Wi],[`timeline`,ua],[`runs`,Xi]];function mp({api:e,onOpenProject:t,homeFolder:n,projectEntries:r,notices:i,discovery:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareExecution:l,directoryNamespaces:u,previewModels:d,initialDraft:p,onDraftApplied:m}){let{t:g,tx:_}=T(),[v]=(0,f.useState)(()=>e??Ua()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,f.useState)(!1),[C]=(0,f.useState)(wf),[w,E]=(0,f.useState)(C?.taskId??null),[D,O]=(0,f.useState)(()=>C?null:no()??crypto.randomUUID()),k=io(y,D??``),[ee,A]=(0,f.useState)(null),[j,te]=(0,f.useState)([]),[M,ne]=(0,f.useState)(null),[N,P]=(0,f.useState)(C?`task`:`files`),[re,F]=(0,f.useState)(),[ie,I]=(0,f.useState)(),[L,ae]=(0,f.useState)(),[R,z]=(0,f.useState)(),[B,V]=(0,f.useState)(0),[H,U]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=no();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[W]=(0,f.useState)(()=>crypto.randomUUID()),G=(0,f.useCallback)(()=>I(void 0),[]),[K,oe]=(0,f.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),q=xo(s?.id,s?.epoch),se=!s||q.readiness===`running`,ce=!!s&&(q.readiness===`stopped`||q.readiness===`not-started`),le=(0,f.useRef)(null);se&&q.value?.epoch&&(le.current=q.value.epoch);let ue=!s||!ce&&(se||le.current!==null),Y=wo(v,w?{kind:`task`,id:w}:null,!x&&ue,le.current),de=(0,f.useRef)(!0);(Y.workspace||Y.observation||Y.error||Y.transportStatus===`stale`)&&(de.current=!1);let fe=!!(s&&(q.value||q.error)),pe=!x&&!!(Y.workspace||fe),me=(0,f.useRef)(null);(Y.workspace||q.value?.workspaceId)&&(me.current=Y.workspace?.workspaceId??q.value?.workspaceId??null);let he=e=>l?async(t,n,r)=>{let i=await l(e,t,n,r);if(t.aborted)throw Error(`stale`);q.prepared(i);let a=Y.reconnect();await Y.whenReady(i,t,a)}:void 0,ge=he(`send`),_e=he(`plan-validation`),ve=uo(v.client,pe),ye=co(v.client,Y.workspace&&!x?{kind:`conversation-active`}:null,1e3),be=ye.value?.kind===`conversation-active`?ye.value.entries:[],xe=[...be,...(ve.value?.entries??[]).filter(e=>!be.some(t=>t.id===e.id))],Se=co(v.client,Y.workspace&&!x?{kind:`workflow-active`}:null,2e3),Ce=Se.value?.kind===`workflow-active`?Se.value:void 0,we=(0,f.useMemo)(()=>[...new Set([...Ce?.runs.map(e=>e.id)??[],...j])],[Ce,j]),Te=co(v.client,!s&&Y.workspace&&!x?{kind:`projects`}:null),Ee=H??s?.cwd??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0),De=L?.id===D?L:void 0,Oe=R?.id===D?R:void 0,ke=$a();(0,f.useEffect)(()=>{De&&no()===De.id&&history.replaceState({...history.state,cadenceCwd:De.cwd,cadenceConversationId:De.id},``,location.href)},[De]);let Ae=D?De:Ee?{id:W,cwd:Ee}:void 0,je=De?.cwd??Ee??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0)??Y.workspace?.rootLabel,Me={state:Y.observation,transportStatus:Y.transportStatus,error:Y.error,refresh:Y.refresh},Ne=Me.state?.snapshot.scope.kind===`task`&&Me.state.snapshot.scope.id===w?Me.state.snapshot.context:void 0,Pe=ap(),{closeDrawer:Fe}=Pe,Ie=N===`branches`&&!!D,Le=!Ie&&(N!==`task`||!K),Re=()=>{P(`branches`),Pe.mobile?Pe.setDrawer(`right`):Pe.inspector||Pe.toggle(`right`)},[ze,Be]=(0,f.useState)(C?.snapshotSeq),[Ve,He]=(0,f.useState)(``),[X,Ue]=(0,f.useState)(``),We=(0,f.useRef)(null),[Ge,Z]=(0,f.useState)(`messages`),[Ke,qe]=(0,f.useState)(!1),[Je,Ye]=(0,f.useState)(!1),[Xe,Ze]=(0,f.useState)(),[Qe,$e]=(0,f.useState)(C?.cursor),[et,tt]=(0,f.useState)(``),[nt,rt]=(0,f.useState)([]),[it,at]=(0,f.useState)(new Set),ot=(0,f.useRef)(!0),st=e=>{ot.current&&rt(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?so(t,e):t)})},ct=(0,f.useRef)(new To),lt=J({taskId:w,scope:K,selectedSnapshot:ze??null,detached:x,attachment:Y.attachmentVersion,workspaceContext:Y.workspace?.context??null,observationError:Y.error??null});ct.current.select(lt),(0,f.useEffect)(()=>(ot.current=!0,()=>{ot.current=!1,ct.current.depart()}),[]);let Q=e=>{b(``);let t=e??crypto.randomUUID();e||U(je??Ee),A(null),t!==D&&(te([]),I(void 0)),ct.current.depart(),O(t),E(null),oe(null),He(``),Ue(``),Ze(void 0),$e(void 0),Be(void 0),Z(`messages`),P(e=>e===`task`?`files`:e),Fe();let n=t===D?io(location.hash,t).leaf:null;history.replaceState({cadenceCwd:je??Ee,cadenceConversationId:t},``,`${location.pathname}${location.search}${ao(`#chat=${t}`,n)}`)};(0,f.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let ut=(e,t)=>{A(null),te([]),O(null),P(`task`),He(t??``),Ue(``),Be(void 0),ct.current.depart(),E(e),oe({kind:`task`,id:e}),Ze(void 0),$e(void 0),Z(`messages`),Fe(),history.replaceState(null,``,Cf(e))};(0,f.useEffect)(()=>{let e=()=>{let e=wf();if(e)A(null),te([]),O(null),P(`task`),ct.current.depart(),Be(e.snapshotSeq),He(``),Ue(``),E(e.taskId),oe(e.scope??{kind:`task`,id:e.taskId}),Ze(void 0),$e(e.cursor),Z(`messages`),Fe();else{let e=no();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&U(t),I(void 0),A(null),te([]),O(e),E(null),oe(null),P(e=>e===`task`?`files`:e),ct.current.depart(),Fe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Fe]);let dt=(e,t,n)=>{A(null),Be(t),Ue(n??``),ct.current.depart(),oe(e),Ze(void 0),$e(void 0),Z(`messages`),Fe(),w&&history.replaceState(null,``,Cf(w,void 0,{scope:e,snapshotSeq:t}))},ft=ze??Me.state?.snapshot.committedSeq??Y.workspace?.committedSeq,pt=Y.workspace?.storeId,mt=K&&pt&&ft?{storeId:pt,scope:K,snapshotSeq:ft,reader:`messages`,after:null,limit:50}:null,ht=K&&pt&&ft?{storeId:pt,scope:K,snapshotSeq:ft,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,gt=Ne?Me.state?.snapshot.runs??[]:[],_t=ct.current.ticket(),vt=e=>{st(e),e.receipt&&ct.current.current(_t)&&Y.refresh()},yt=e=>{if(it.has(e)||!Y.attached||!Y.activeRuns)return;let t=crypto.randomUUID(),n=Y.activeRuns.epoch;at(t=>new Set(t).add(e)),st({commandId:t,error:g(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{vt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:g(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>st({commandId:t,error:g(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{ot.current&&at(t=>{let n=new Set(t);return n.delete(e),n})})};if(x)return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:g(`Detached`)}),(0,h.jsx)(`p`,{children:g(`Accepted service work continues. No Cancel was requested.`)}),nt.map(e=>(0,h.jsxs)(`p`,{children:[g(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>S(!1),children:g(`Reconnect as a viewer`)})]});let bt=Y.activeRuns,xt=bt?.status===`complete`?bt.runs:[],St=!x&&!Y.error&&Y.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`),Ct=se&&St,wt=se&&!!Y.workspace&&Y.attached&&!Y.error&&St,Tt=de.current&&!Me.state&&!Me.error&&!q.error&&(!s||!q.value&&q.readiness===`unknown`||q.readiness===`running`),Et=ce?{status:q.readiness===`not-started`?`not-started`:`stopped`}:se&&St&&Y.attached&&Y.epoch&&(!s||q.value?.epoch===Y.epoch)?{status:`ready`,epoch:Y.epoch,attachmentVersion:Y.attachmentVersion}:{status:Tt?`connecting`:`unavailable`},Dt=x?`Viewer disconnected`:Tt?`Connecting…`:s&&q.readiness===`unknown`?`Project readiness unknown`:s&&q.readiness===`stale`?`Project observation stale`:ce?`Ready to prepare execution`:St?Y.workspace?Me.state?.connection??(w?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`,Ot=Tt?`busy`:ce?``:!Ct||!Y.workspace?`error`:Me.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`)?`ok`:`busy`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Xf,{panels:Pe,onOpenService:o,onRefresh:()=>{Y.refresh(),q.refresh()},onDisconnect:()=>{qe(!1),Ye(!1),ct.current.depart(),S(!0)},inspectorLabel:g(K&&N===`task`?`History details`:Ie?`Branches`:`Files`),toolbar:K&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":g(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ge===`messages`&&!Qe,onClick:()=>{$e(void 0),Ze(void 0),Z(`messages`)},children:[(0,h.jsx)(Ri,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:We,onKeyDown:e=>{e.key===`Escape`&&We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Ge===`messages`?g(`Details`):_(Ge),(0,h.jsx)(ha,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[pp.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Ge===e,onClick:()=>{$e(void 0),Ze(void 0),Z(e),We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),_(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Export selected scope`),disabled:!mt,onClick:()=>{We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus()),Ye(!0)},children:[(0,h.jsx)(ra,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!w,onClick:()=>{w&&Po(Cf(w,Qe,K?{scope:K,snapshotSeq:ze}:void 0)).then(e=>e?Jo(`info`,g(`Link copied.`)):Jo(`error`,g(`Link copy unavailable.`)))},children:[(0,h.jsx)(Ui,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),actions:K&&(0,h.jsx)(As,{disabled:!ht,onOpen:()=>qe(!0)}),notices:(0,h.jsxs)(h.Fragment,{children:[!Y.workspace&&xt.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:xt.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[_(e.kind),` `,e.runId,` · `,_(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ut(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Y.attached||it.has(e.runId),onClick:()=>yt(e.runId),children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),i,(0,h.jsx)(Sf,{error:et,projectObservationError:q.error,observationError:Y.error,unavailable:!Tt&&!ce&&!Ct,onRefresh:()=>{Y.refresh(),q.refresh()}})]}),navigation:(0,h.jsxs)(h.Fragment,{children:[!pe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,h.jsx)(Ws,{...a}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(Tt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,h.jsx)(vf,{discovery:a,client:v.client,workspace:Y.workspace,executionStopped:ce,taskId:w,scope:K,runs:gt,snapshot:Me.state?.snapshot.committedSeq,activeRuns:Y.activeRuns,canCancel:Y.attached,canceling:it,onCancel:yt,chats:xe,chatActivityKnown:ye.value?.kind===`conversation-active`&&!ye.error,chatHistoryPartial:ve.loading||ve.canPrevious||!!ve.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[ve.error&&(0,h.jsx)(`p`,{role:`alert`,children:ve.error}),ve.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:g(`Reading conversation history…`)}),ve.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.previous,children:g(`Newer conversations`)}),ve.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.next,children:g(`Older conversations`)}),ve.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:ve.first,children:g(`Latest conversations`)}),ve.error&&(0,h.jsx)(`button`,{type:`button`,onClick:ve.refresh,children:g(`Observe current state`)})]}),conversationId:D,onConversation:Q,onNewConversation:()=>Q(),actionsUnavailable:wt?``:g(ce?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{ve.refresh(),e===D&&V(e=>e+1)},workflows:Ce?.runs,workflowLinks:Ce?.links,workflowError:!!Se.error,selectedWorkflow:ee?.runId,onWorkflow:(e,t)=>{t?Q(t):(A({runId:e.id,stepId:null,label:e.goal}),Fe())},onCancelWorkflow:async e=>{tt(await od(v.client,e)),Se.refresh()},onTask:ut,onScope:dt}),Y.workspace&&(0,h.jsx)(ac,{client:v.client,active:Y.activeRuns,taskId:w,runs:gt,snapshot:ft,workflowRuns:we,selected:ee,onOpenWorkflow:e=>{A(e),Fe()},onOpen:(e,t,n,r)=>{ut(e),oe({kind:`child`,id:t}),Ue(r),Be(n),history.replaceState(null,``,Cf(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,h.jsxs)(h.Fragment,{children:[D&&s&&!fe&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),ee&&(0,h.jsx)(bf,{client:v.client,agent:ee,backLabel:g(D?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>A(null),onOpenAgent:A},`${ee.runId}:${ee.stepId??``}`),D&&(!s||fe)&&(0,h.jsx)(vd,{client:v.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:Ee,onLocation:ae,onActivity:z,hidden:!!ee,onOpenAgent:A,onWorkflowRuns:te,onBranches:F,onOpenBranches:Re,workspaceId:s?`checkout:${s.path}`:me.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?q.value?.workspaceId??void 0:void 0,prepareForSend:ge,prepareForPlan:_e,actionsReady:wt,observe:B,available:pe,canInterrupt:Y.attached,enabled:ge?pe:!!Y.workspace&&Y.attached&&!Y.error,modelAvailability:Et,previewModels:d,initialDraft:p?.conversationId===D?p:void 0,onDraftApplied:()=>m?.(D),onModelChanged:()=>{ct.current.depart(),Y.refresh(),q.refresh()},onChanged:()=>{ve.refresh(),Y.refresh()},reference:ie,onReferenceUsed:G},`${s?.id??me.current??`connecting`}:${D}:${k.leaf??``}`),K&&!ee&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[K.kind!==`task`&&w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ut(w,Ve),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:Ve||K.id,children:K.kind===`task`?Ve||g(`Task {id}`,{id:K.id.slice(0,8)}):X||g(`{kind} {id}`,{kind:_(K.kind),id:K.id.slice(0,8)})}),K.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[g(`Recorded conversation`),` ·`,` `,g(`snapshot {seq}`,{seq:ft??``})]}),(0,h.jsx)(`code`,{children:K.id}),(0,h.jsx)(`p`,{children:g(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!ee,children:[!mt&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:g(`History is readonly. Start new work in a conversation with /cadence.`)})]}),mt&&Qe?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Xe&&(Xe.owner.entity.kind===`task`||Xe.owner.entity.kind===`message`||Xe.owner.entity.kind===`tool`)&&(0,h.jsx)(vs,{client:v.client,seed:{storeId:Qe.storeId,scope:Qe.scope,snapshotSeq:Qe.snapshotSeq,kind:Xe.owner.entity.kind,id:Xe.owner.entity.id,version:Xe.owner.entity.version}},`${Xe.owner.entity.id}:${Xe.owner.entity.version}`),(0,h.jsx)(hs,{client:v.client,cursor:Qe,highlight:Xe?.range},`${Qe.recordId}:${Qe.recordVersion}`)]}):mt&&(0,h.jsxs)(`div`,{className:Ge===`messages`||Ge===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ge===`messages`&&(0,h.jsx)(Bs,{client:v.client,seed:mt}),Ge===`tools`&&(0,h.jsx)(hp,{client:v.client,seed:mt}),Ge===`context`&&(0,h.jsx)(_s,{client:v.client,seed:mt}),Ge===`timeline`&&(0,h.jsx)(dp,{client:v.client,seed:mt,onSearch:()=>qe(!0)}),Ge===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:g(`Runs in the current snapshot`)}),gt.length>0?gt.map(e=>(0,h.jsx)(Es,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Ne&&Me.state?g(`No owner run projection in this snapshot.`):g(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:g(`Retained runs`)}),(0,h.jsx)(ks,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}},onScope:dt},w)]})]},`${K?.kind}:${K?.id}:${ze??`current`}`)]}),Y.workspace&&nt.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:nt.map(e=>(0,h.jsx)(Eo,{client:v.client,value:e,onChange:st},e.commandId))})]}),inspectorTabs:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Le,onClick:()=>P(`files`),children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),g(`Files`)]}),D&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ie,onClick:()=>P(`branches`),children:[(0,h.jsx)(Xi,{"aria-hidden":`true`}),g(`Branches`)]}),K&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!mt,onClick:()=>P(`task`),children:[(0,h.jsx)(Wi,{"aria-hidden":`true`}),g(`History details`)]})]}),inspector:Ie?(0,h.jsx)(dc,{view:re?.id===D?re:void 0,onChosen:Fe}):Le?(0,h.jsx)(Nd,{location:Ae,client:v.client,enabled:pe&&!!Ae,observed:`${q.readiness}:${q.value?.epoch??``}`,onReference:e=>{D||Q(W);let t=!D&&Ae?`${Ae.cwd.replace(/[\\/]+$/,``)}${Ae.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;I(t),Fe()}},Ae?.cwd??`owner`):mt?(0,h.jsx)(Ud,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}}},w):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),status:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(np,{tip:g(`Connection freshness is not execution outcome.`),dot:Ot,latency:Ot===`ok`||Ot===``?ke:null,children:_(Dt)}),s&&(0,h.jsx)(tp,{tone:`faint`,icon:(0,h.jsx)(Oi,{}),children:g(`Execution service: {status}`,{status:_(q.readiness)})}),Oe&&(0,h.jsx)(ep,{usage:Oe.context}),Oe&&(0,h.jsx)(Qf,{cache:Oe.cache}),Oe&&Oe.turns>0&&(0,h.jsx)(tp,{icon:(0,h.jsx)(Ri,{}),tip:g(`Turns in this conversation: {count}`,{count:Oe.turns}),children:Oe.turns}),Oe&&Oe.runningSince!==null&&(0,h.jsx)(ip,{since:Oe.runningSince,label:g(`Working`)}),bt?.status===`complete`?xt.length>0&&(0,h.jsx)(tp,{tone:`warn`,children:g(Ct?xt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:xt.length})}):!Tt&&!ce&&(0,h.jsx)(tp,{tone:`faint`,children:g(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(Y.workspace||s)&&(0,h.jsx)(xf,{path:je,onClick:()=>c?c(je):ne(``)})}),M!==null&&Y.workspace&&(0,h.jsx)(qd,{onOpen:t,projects:r??(Te.value?.kind===`projects`?Te.value.entries:[]),client:v.client,current:je??Y.workspace.rootLabel,initial:M||void 0,home:n,epoch:Y.workspace.epoch,onClose:()=>ne(null)}),Ke&&ht&&(0,h.jsx)(Ts,{client:v.client,seed:ht,onClose:()=>qe(!1),onHit:e=>{Ze(e),$e(e.cursor),w&&history.replaceState(null,``,Cf(w,e.cursor,K?{scope:K,snapshotSeq:ze}:void 0))}}),Je&&ht&&(0,h.jsx)(Ss,{request:{storeId:ht.storeId,scope:ht.scope,snapshotSeq:ht.snapshotSeq,format:`ndjson`},onClose:()=>Ye(!1)})]})}function hp({client:e,seed:t}){let n=jo(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(gs,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(Hs,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var gp=`cadence:folder-draft`,_p=()=>({text:``,model:null});function vp(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return _p();let t=null;try{e.model!=null&&(t=me(e.model))}catch{}return{text:e.text,model:t}}catch{return _p()}}function yp(e){try{e.text||e.model?sessionStorage.setItem(gp,JSON.stringify(e)):sessionStorage.removeItem(gp)}catch{}}function bp(e,t,n){let r=Vc(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(gp)}catch{}return{...n,conversationId:t}}var xp=`cadence-last-project`;function Sp(){try{let e=localStorage.getItem(xp);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Cp(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(xp,e)}catch{}}function wp(e){let t=Sp();return t?e.projects.find(e=>e.id===t):void 0}async function Tp(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=Cn(await fo(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Ep(e,t){let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t}),r=await fo(n);if(!n.ok)throw Error(po(r));return bn(r)}async function Dp(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await fo(t);if(!t.ok)throw Error(po(n));return On(n)}async function Op(e,t,n,r,i){let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await fo(s);if(!s.ok)throw mo(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(po(c));let l=Sn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function kp(e,t){let n=await Dp(t);return Op(`/workbench/v1/select`,{path:e},n,t)}async function Ap(e,t,n,r,i){let a=await Dp(n),o=a.projects.find(t=>t.id===e.id);if(!o||o.path!==e.path||o.cwd!==e.cwd)throw Error(`stale`);let s=await Op(t===`send`?`/workbench/v1/prepare-send`:`/workbench/v1/prepare-plan`,{projectId:e.id,commandId:crypto.randomUUID(),...r?{location:r}:{}},a,n,()=>i?.(`dispatched`));if(!s.project.epoch||s.project.id!==e.id||s.project.path!==e.path||s.project.cwd!==e.cwd)throw Error(`stale`);return i?.(`confirmed`),s}async function jp(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await kp(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Mp=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Np(e){let t=U(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:G(t.id),source:B(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:dn(t.sessionId),cwd:L(t.cwd,4096,!0),leaf:t.leaf===null?null:L(t.leaf,128,!0),history:B(t.history,[`shared`,`unavailable`]),phase:B(t.phase,Mp),freshness:B(t.freshness,[`current`,`stale`,`unknown`]),observedAt:R(t.observedAt,0),epoch:t.epoch===null?null:G(t.epoch),instance:t.instance===null?null:G(t.instance),executionCwd:t.executionCwd===null?null:L(t.executionCwd,4096,!0)}}function Pp(e){let t=U(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:V(t.kind,`activity-discovery`),epoch:G(t.epoch),observedAt:R(t.observedAt,0),completeness:B(t.completeness,[`complete`,`partial`]),unavailable:R(t.unavailable,0,1e4),projects:W(t.projects,128,e=>{let t=U(e,[`path`,`activities`]);return{path:L(t.path,4096,!0),activities:W(t.activities,256,Np)}})}}async function Fp(e){let t=Oa([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal}),n=await fo(e);if(!e.ok)throw Error(po(n));return Pp(n)}finally{t.dispose()}}function Ip(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function Lp(e,t,n,r=Fp){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?Ip(o,Date.now()):void 0,t(o,e instanceof Error?e.message:`unavailable`)}finally{i.signal.aborted||(a=setTimeout(s,3e3))}};return s(),()=>{i.abort(),clearTimeout(a)}}function Rp(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return Lp(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function zp({ready:e,previewModels:t,draft:n=_p(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=T(),d=ap(),[p,m]=(0,f.useState)(!1),g=tl(null,{status:`not-started`},`folder-setup`,t),_=()=>{d.closeDrawer(),a()};return(0,h.jsx)(Xf,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(ef,{disabled:!e,onConversation:_}),l&&(0,h.jsx)(Ws,{...l}),(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:u(`Conversation history`)})}),(0,h.jsx)(`div`,{className:`lp-section-body`,children:(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:u(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":u(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsxs)(Wu,{hint:u(`Choose a working folder to start. You can write a draft below.`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:_,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),u(`Choose a folder…`)]}),i&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i.status===`checking`?u(`Returning to your last folder {path}…`,{path:i.path}):u(`Could not restore {path}. Choose a folder to continue; nothing was started.`,{path:i.path})})]})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{"aria-label":u(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:u(`Write a message. Choose a folder before sending…`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(Il,{scope:`next-conversation`,availability:{status:`not-started`},read:g,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:p,onOpenChange:e=>{e&&!g.preview&&!g.loading&&g.reread(),m(e)},onChanged:()=>{}}),(0,h.jsx)(`span`,{className:`composer-hint`,children:u(`Choose a folder before sending.`)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,h.jsx)(va,{"aria-hidden":`true`})})]})]})]}),inspector:(0,h.jsx)(`aside`,{className:`panel files-panel`,children:(0,h.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,h.jsx)(tp,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,h.jsx)(xf,{disabled:!e,onClick:_})})}var Bp=`cadence-recovery-dismissed`,Vp={reboot:`The machine restarted while Cadence was running. Cadence recovered automatically.`,crash:`Cadence ended unexpectedly last time. It recovered automatically.`,restart:`Cadence ran into a problem and restarted itself.`,storage:`Cadence repaired some incomplete files automatically.`},Hp={"released-locks":`Released the previous run's locks.`,"stopped-workers":`Stopped {count} leftover worker processes.`,"stopped-owner":`Stopped the unresponsive previous process.`,"continued-history":`History continues after the last complete entry.`,"archived-history":`Unreadable history was archived and a new one was started.`,"archived-state":`Damaged state was archived; it started afresh.`,"rebuilt-registry":`Rebuilt the project registry.`,"removed-temporaries":`Set aside interrupted temporary files.`};function Up(){try{let e=JSON.parse(localStorage.getItem(Bp)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Wp(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Gp({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Up),[a,o]=(0,f.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(Bp,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:Wp(e.path)}):e.scope===`workbench`?n(`Cadence service`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Vp[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,h.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:u(e)}),` `,(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(Hp[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Kp={restart:18e4,upgrade:12e5},qp=1e3,Jp={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},Yp=e=>e instanceof Error?e.message:`unavailable`;function Xp(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(Jp[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function Zp(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Qp(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function $p({epoch:e,csrf:t,onClose:n}){let{t:r}=T(),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(null),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(),[E,D]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=new AbortController;return go(e.signal).then(a,t=>{e.signal.aborted||s(Yp(t))}),()=>e.abort()},[E]),(0,f.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>Kp[e.action])return w(`timeout`);try{let t=await go(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof F||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,qp)};return r=setTimeout(i,qp),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),_o().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),vo({action:n.action,from:i.version,to:n.to,work:i.work,epoch:e},t).then(e=>y({job:e,since:Date.now()})).catch(e=>{s(Yp(e)),m(!1),D(e=>e+1)}).finally(()=>_(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&Zp(C),o=i?.unit;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,h.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(x?`Cadence is starting again…`:`Stopping Cadence…`):r(x?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,h.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:Kp[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Xp(r,C)]}),(0,h.jsx)(`p`,{children:r(C===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,h.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,h.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,h.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,h.jsx)(`footer`,{children:a?(0,h.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let ee=i&&c&&typeof c==`object`?zn(c.version,i.version)>0:!1;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:n,children:[i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,h.jsx)(`p`,{children:Qp(r,i.upgrade)}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:Xp(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):ee?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):In(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(ya,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(ji,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function em(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(vp),[a,o]=(0,f.useState)(),s=(0,f.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,f.useState)(to),u=(0,f.useCallback)(e=>Ep(c??void 0,e),[c]),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(null),[_,v]=(0,f.useState)(``),[y,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(0),[w,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useCallback)(()=>C(e=>e+1),[]),ee=Rp(t?.epoch,k),A=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>A.current?.abort(),[]);let j=(0,f.useRef)(new Map),te=(0,f.useRef)(!c),M=(0,f.useRef)(null),ne=(0,f.useCallback)(()=>{M.current&&(M.current.abort(),M.current=null,O(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await fo(t);t.status===400&&po(r)===`invalid`?n(null):t.ok?(n(On(r)),x(``)):x(po(r))}catch{e.signal.aborted||x(`unavailable`)}})(),()=>e.abort()},[S]),(0,f.useEffect)(()=>{let e=()=>{A.current?.abort(),ne(),O(null),l(to())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ne]),(0,f.useEffect)(()=>{if(!t||!te.current||(te.current=!1,r.text||r.model))return;let e=wp(t);if(!e)return;let n=new AbortController;M.current=n,O({status:`checking`,path:e.cwd}),Tp(e.id,n.signal).then(t=>{n.signal.aborted||(M.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),O(null),l(e.id)):O({status:`unavailable`,path:e.cwd}))})},[t,r]);let N=(0,f.useCallback)((e,n)=>{ne(),O(null),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&j.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=!t?.projects.some(e=>e.id===c)&&!n&&!!(r.text||r.model);s?(o(bp(e.path,a,r)),i(_p())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:j.current.get(e.id)??`#chat=${a}`}`),l(e.id),p(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,ne,t,r]),P=(0,f.useCallback)(async e=>{A.current?.abort();let t=new AbortController;A.current=t;let r=await kp(e,t.signal);t.signal.aborted||(n(r.entry),N(r.project))},[N]),I=t?{value:ee.value,error:ee.error,opening:!!m,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,r)=>{A.current?.abort(),ne();let i=new AbortController;A.current=i,g(r.cwd),v(``),jp(t,r,i.signal).then(e=>{i.signal.aborted||(n(e.entry),N(e.project,r))}).catch(t=>{i.signal.aborted||v(b(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{A.current===i&&g(null)})}}:void 0,L=async(e,r,i,a)=>{let o=t?.projects.find(e=>e.id===c);if(!o)throw Error(`unavailable`);let s=await Ap(o,e,r,i,a);if(r.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},ae=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new F(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await fo(n);if(!n.ok){let e=po(r);return{kind:`error`,error:ie(re.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:ii(r)}}catch{return{kind:`error`,error:ie(`unavailable`)}}}}),[]),R=(0,f.useMemo)(()=>c?Ua(c):void 0,[c]),z=t?.projects.find(e=>e.id===c);if((0,f.useEffect)(()=>{z&&Cp(z.id)},[z]),t===null)return(0,h.jsx)(mp,{});let B=t&&w&&(0,h.jsx)($p,{epoch:t.epoch,csrf:t.csrf,onClose:()=>E(!1)}),V=()=>E(!0),H=t&&d!==null&&(0,h.jsx)(qd,{selectOnly:!0,client:ae,current:z?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>p(null),onOpen:P});return t&&z&&R?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mp,{api:R,project:z,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===z.path).map(e=>e.id).sort(),discovery:I,onPrepareExecution:L,onChooseFolder:e=>{A.current?.abort(),p(e??z.cwd)},onOpenProject:P,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,children:_}),(0,h.jsx)(Gp,{notices:t.recoveries,project:z.path}),` `]}),onOpenService:V},z.id),B,H]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(zp,{discovery:I,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),yp(e)},restore:D,onRefresh:()=>C(e=>e+1),onOpenService:t?V:void 0,onChooseFolder:()=>{ne(),v(``),A.current?.abort(),p(t?.home??``)},notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:_}),t&&(0,h.jsx)(Gp,{notices:t.recoveries}),y&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[y,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e=>e+1),children:e(`Reload observation`)})]}),c&&!z&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),H,B]})}function tm(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var nm=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(tm,{}):this.props.children}};A(ee());var rm=document.getElementById(`root`);if(!rm)throw Error(`Application root unavailable`);(0,p.createRoot)(rm).render((0,h.jsx)(E,{children:(0,h.jsx)(nm,{children:(0,h.jsx)(em,{})})}));export{up as t};
|