@straiffi/archon 1.0.10 → 1.0.11

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.
@@ -61,76 +61,76 @@ Definition of Done`,disabled:m||g||v,className:`min-h-24`})})}),(0,q.jsxs)(`div`
61
61
  `),stages:e.stages,priority:e.priority??`normal`,injectionMode:e.injection_mode??`relevant`}),Ob=({memory:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>(0,q.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 p-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h5`,{className:`text-sm font-semibold text-foreground`,children:e.title}),(0,q.jsxs)(Z,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:[`Suggested `,e.kind]}),e.duplicate_match&&(0,q.jsx)(Z,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:`Possible duplicate`})]}),(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:e.content})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:t,onClick:()=>{r(e)},children:e.duplicate_match&&e.kind===`decision`?`Save as new decision`:`Accept`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>{i(e)},children:`Dismiss`})]})]})}),kb=({memory:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onDraftChange:o,onStartEdit:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>e?(0,q.jsx)(vg,{open:t,onOpenChange:a,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:e.title}),(0,q.jsxs)(Eg,{children:[`Review this suggested `,e.kind,` before saving it into project memory.`]})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[e.duplicate_match&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,q.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,q.jsxs)(`p`,{children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[e.duplicate_match.title,`:`]}),` `,e.duplicate_match.content]})]}),n?(0,q.jsx)(Eb,{draft:i,onChange:o,onCancel:c,onSubmit:()=>{l(e,!1)},isSaving:r,submitLabel:e.duplicate_match&&e.kind===`decision`?`Save as new decision`:`Accept as ${e.kind}`,layout:`dialog`,allowKindChange:!1,secondaryActions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>{u(e)},children:[`Dismiss `,e.kind]}),e.kind===`decision`&&e.duplicate_match&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>{l(e,!0)},children:`Update existing decision`})]})}):(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.content}),(0,q.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Scope:`}),` `,e.scope]}),e.rationale&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Why:`}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Implications:`}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Stages:`}),` `,e.stages.map(e=>db(e)).join(`, `)]}),e.kind===`convention`&&e.priority&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Priority:`}),` `,Xy[e.priority]]}),e.kind===`convention`&&e.injection_mode&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Injection:`}),` `,Zy[e.injection_mode]]})]})]})]}),!n&&(0,q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-border pt-4`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:`Close`}),(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>{u(e)},children:[`Dismiss `,e.kind]}),(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>s(e),children:`Edit`}),e.kind===`decision`&&e.duplicate_match&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>{l(e,!0)},children:`Update existing decision`}),(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>{l(e,!1)},children:e.duplicate_match&&e.kind===`decision`?`Save as new decision`:`Accept as ${e.kind}`})]})]})}):null,Ab=({mode:e,projectId:t,memoryEnabled:n,persistedMemoryEnabled:r,onMemoryEnabledChange:i,showActivationControls:a=!0,archiveLayout:o=!1})=>{let[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)([]),[d,f]=(0,b.useState)([]),[p,m]=(0,b.useState)([]),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(null),[y,x]=(0,b.useState)(null),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(Qy),[D,O]=(0,b.useState)(Qy),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)(null),[L,R]=(0,b.useState)([]),[z,ee]=(0,b.useState)(!1),[B,V]=(0,b.useState)(!1),[H,te]=(0,b.useState)(null),[U,ne]=(0,b.useState)(!1),[W,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(!1),[G,oe]=(0,b.useState)(null),se=(0,b.useRef)(null),ce=o&&e===`edit`&&!!t&&n&&r,le=e===`edit`&&!!t,ue=e===`create`&&n,de=e===`edit`&&n&&!r,K=!n;(0,b.useEffect)(()=>{if(!ce||!t){u([]),f([]),m([]),c(null),x(null),w(null),v(null),oe(null),I(null),R([]),te(null),V(!1);return}let e=new AbortController;return g(!0),V(!0),v(null),te(null),bb(t,e.signal).then(t=>{e.signal.aborted||(v(null),u(t.conventions),f(t.decisions),m(t.suggestions),I(t.generatedContext?.context??null),R(t.generatedContext?.artifacts??[]))}).catch(t=>{e.signal.aborted||v(t instanceof Error?t.message:`Unable to load project memory right now.`)}).finally(()=>{e.signal.aborted||(g(!1),V(!1))}),()=>{e.abort()}},[ce,t]),(0,b.useEffect)(()=>{if(!t||!ce||!cb(F))return;V(!0);let e=window.setInterval(()=>{gb(t).then(e=>{te(null),I(e.context),R(e.artifacts),V(!1)}).catch(e=>{te(e instanceof Error?e.message:`Unable to refresh project context right now.`),V(!1)})},Jy);return()=>{window.clearInterval(e),V(!1)}},[ce,F,t]);let fe=(0,b.useMemo)(()=>N?l:l.filter(e=>e.status===`active`),[l,N]),pe=(0,b.useMemo)(()=>N?d:d.filter(e=>e.status===`accepted`),[d,N]),me=(0,b.useMemo)(()=>{let e=fe.map(e=>{let t=[`Convention`,Xy[e.priority],Zy[e.injection_mode],ob(e.status)];return e.stages.length>0&&t.push(e.stages.length===1?db(e.stages[0]):`${e.stages.length} stages`),{id:e.id,kind:`convention`,title:e.title,preview:e.instruction,meta:t,archived:sb(e.status),updatedAt:e.updated_at}}),t=pe.map(e=>({id:e.id,kind:`decision`,title:e.title,preview:e.decision,meta:[`Decision`,ob(e.status)],archived:sb(e.status),updatedAt:e.updated_at}));return[...e,...t].sort((e,t)=>e.archived===t.archived?t.updatedAt.localeCompare(e.updatedAt)||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id):e.archived?1:-1)},[fe,pe]),he=(0,b.useMemo)(()=>p,[p]),ge=(0,b.useMemo)(()=>pb(L),[L]),_e=()=>{c(null),E(Qy())},ve=()=>{w(null),O(Qy())},ye=async()=>{if(t){A(!0);try{if(T.kind===`convention`){let e={kind:`convention`,title:T.title.trim(),scope:T.scope.trim()||null,instruction:T.content.trim(),rationale:T.rationale.trim()||null,stages:T.stages,priority:T.priority,injection_mode:T.injectionMode},n=s?.id?await nt(t,s.id,e):await tt(t,e);u(e=>tb(e,_b(n.memory)))}else{let e={kind:`decision`,title:T.title.trim(),scope:T.scope.trim()||null,decision:T.content.trim(),rationale:T.rationale.trim()||null,implications:rb(T.implicationsText)},n=s?.id?await nt(t,s.id,e):await tt(t,e);f(e=>nb(e,vb(n.memory)))}_e()}catch(e){X.error(e instanceof Error?e.message:`Unable to save the project memory right now.`,{id:`project-memory-save-error`})}finally{A(!1)}}},be=e=>{c({kind:`convention`,id:e.id}),E(ib(e))},xe=()=>{c({kind:`decision`,id:null}),E(Qy(`decision`))},Se=e=>{c({kind:`decision`,id:e.id}),E(ab(e))},Ce=e=>{C&&C!==e.id&&ve(),x(e.id)},we=e=>{e||(x(null),ve())},Te=e=>{x(e.id),w(e.id),O(Db(e))},Ee=async(e,n)=>{if(!t)return;let r=C===e.id?D:Db(e),i=e.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:rb(r.implicationsText)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:r.stages,priority:r.priority,injection_mode:r.injectionMode};M(e.id);try{if(n&&!e.duplicate_match)throw Error(`No existing decision is available for this suggestion.`);if(n&&e.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let r=n?await pt(t,e.id,e.duplicate_match?.memory_id??``,i):await dt(t,e.id,i);r.memory.kind===`decision`?f(e=>nb(e,vb(r.memory))):u(e=>tb(e,_b(r.memory))),m(t=>t.filter(t=>t.id!==e.id)),x(null),ve()}catch(e){X.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{M(null)}},De=async e=>{if(t){M(e.id);try{await ft(t,e.id),m(t=>t.filter(t=>t.id!==e.id)),y===e.id&&x(null),C===e.id&&ve()}catch(e){X.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{M(null)}}},Oe=async(e,n)=>{if(!t)return!1;try{let r=n===`archive`?await rt(t,e.id):await it(t,e.id);return u(e=>tb(e,_b(r.memory))),!0}catch(e){return X.error(e instanceof Error?e.message:n===`archive`?`Unable to archive the project convention right now.`:`Unable to restore the project convention right now.`,{id:n===`archive`?`project-memory-convention-archive-error`:`project-memory-convention-restore-error`}),!1}},ke=async(e,n)=>{if(!t)return!1;try{let r=n===`archive`?await rt(t,e.id):n===`supersede`?await at(t,e.id):await it(t,e.id);return f(e=>nb(e,vb(r.memory))),!0}catch(e){let t=n===`archive`?`Unable to archive the project decision right now.`:n===`supersede`?`Unable to supersede the project decision right now.`:`Unable to restore the project decision right now.`,r=n===`archive`?`project-memory-decision-archive-error`:n===`supersede`?`project-memory-decision-supersede-error`:`project-memory-decision-restore-error`;return X.error(e instanceof Error?e.message:t,{id:r}),!1}},Ae=s!==null,je=F?.scan??null,Me=s?.kind===`convention`&&s.id?l.find(e=>e.id===s.id)??null:null,Ne=s?.kind===`decision`&&s.id?d.find(e=>e.id===s.id)??null:null,Pe=y?p.find(e=>e.id===y)??null:null,Fe=cb(F),Ie=l.length+d.length+p.length,Le=je?.status??null,Re=!o||Le!==`done`,ze=()=>{t&&(ne(!0),te(null),st(t).then(async e=>{I(e),R((await ct(t)).artifacts),X.success(`Project context scan started.`,{id:`project-context-scan-started`})}).catch(async e=>{if(e instanceof S&&e.status===409){X.error(`A project context scan is already active for this project.`,{id:`project-context-scan-conflict`});try{let e=await gb(t);I(e.context),R(e.artifacts)}catch(e){te(e instanceof Error?e.message:`Unable to refresh project context right now.`)}return}X.error(e instanceof Error?e.message:`Unable to start the project context scan right now.`,{id:`project-context-scan-error`})}).finally(()=>{ne(!1)}))},Be=async()=>{if(t){re(!0);try{let{filename:e,archive:n}=await mt(t),r=new Blob([JSON.stringify(n,null,2)],{type:`application/json;charset=utf-8`}),i=window.URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),window.URL.revokeObjectURL(i),X.success(`Project memory exported.`,{id:`project-memory-export-success`})}catch(e){X.error(e instanceof Error?e.message:`Unable to export project memory right now.`,{id:`project-memory-export-error`})}finally{re(!1)}}},Ve=async e=>{if(!t){e.target.value=``;return}let n=e.target.files?.[0];if(e.target.value=``,n){ae(!0);try{let e=await ht(t,JSON.parse(await Sb(n)));if(ce){let e=await bb(t);u(e.conventions),f(e.decisions),m(e.suggestions),I(e.generatedContext?.context??null),R(e.generatedContext?.artifacts??[]),v(null),te(null)}oe(e),X.success(`Project memory imported.`,{id:`project-memory-import-success`})}catch(e){X.error(e instanceof Error?e.message:`Unable to import project memory right now.`,{id:`project-memory-import-error`})}finally{ae(!1)}}},He=(0,q.jsxs)(`div`,{className:o?`rounded-lg border border-border/70 bg-background/35 p-4`:`rounded-2xl border border-border/70 bg-background/25 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Memory transfer`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Export or import one Archon JSON archive for this project's saved conventions, decisions, and generated scan history.`}),!le&&(0,q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:`Create the project first to export or import a memory archive.`})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 self-start`,children:[(0,q.jsxs)(Y,{type:`button`,variant:`outline`,onClick:()=>{Be()},disabled:!le||W||ie,children:[(0,q.jsx)(Wy,{className:`h-3.5 w-3.5`}),W?`Exporting...`:`Export`]}),(0,q.jsxs)(Y,{type:`button`,variant:`outline`,onClick:()=>{se.current?.click()},disabled:!le||W||ie,children:[(0,q.jsx)(Gy,{className:`h-3.5 w-3.5`}),ie?`Importing...`:`Import`]})]})]}),(0,q.jsx)(`input`,{ref:se,type:`file`,accept:`application/json,.json`,className:`hidden`,"aria-label":`Import project memory JSON`,onChange:e=>{Ve(e)}}),G&&(0,q.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:[`Imported `,G.summary.conventions_imported,` conventions, skipped `,G.summary.conventions_skipped]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:[`Imported `,G.summary.decisions_imported,` decisions, skipped `,G.summary.decisions_skipped]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:[`Imported `,G.summary.scans_imported,` scans, skipped `,G.summary.scans_skipped]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:[`Imported `,G.summary.artifacts_imported,` artifacts, skipped `,G.summary.artifacts_skipped]}),(0,q.jsx)(`div`,{className:`sm:col-span-2 xl:col-span-4 rounded-lg border border-border/60 bg-background/35 px-3 py-2 text-sm text-muted-foreground`,children:xb(G)})]})]}),Ue=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[Re&&(0,q.jsx)(Z,{variant:`outline`,className:`px-3 py-1 text-xs uppercase tracking-[0.24em]`,children:lb(F)}),F?.stale&&(0,q.jsx)(Z,{variant:`outline`,className:`px-3 py-1 text-xs uppercase tracking-[0.24em] text-amber-300`,children:`Stale`})]}),We=(0,q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`min-w-[7.5rem] shrink-0 justify-center`,disabled:U||Fe,onClick:ze,children:[U||Fe?(0,q.jsx)(C_,{className:`size-3.5 animate-spin`}):(0,q.jsx)(Ky,{className:`size-3.5`}),U||Fe?`Scanning`:`Scan now`]});return o?(0,q.jsxs)(`div`,{className:`space-y-5`,children:[K&&(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:`Enable project memory to manage conventions, accepted decisions, and prompt context for this project.`}),ue&&(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:`Create the project first, then reopen settings to add conventions and decisions.`}),de&&(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,children:`Save these settings to enable project memory, then reopen settings to manage conventions, accepted decisions, and manual scans.`}),ce&&(0,q.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[18rem_minmax(0,1fr)]`,children:[(0,q.jsxs)(`aside`,{className:`space-y-4 rounded-xl border border-border/70 bg-background/35 p-4 xl:sticky xl:top-4 xl:self-start`,children:[(0,q.jsxs)(`div`,{className:`border-b border-border/60 pb-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground`,children:`Generated context`}),(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Scan archive`})]}),(0,q.jsx)(`div`,{className:`pt-0.5`,children:We})]}),(0,q.jsx)(`div`,{className:`mt-3`,children:Ue})]}),H&&(0,q.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-red-300`,children:H}),B?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:`Loading latest scan status...`}):je?(0,q.jsxs)(`div`,{className:`space-y-4`,children:[je.error&&(0,q.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-red-300`,children:je.error}),F?.stale&&(0,q.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-200`,children:`The repository HEAD has changed since the latest successful scan. Generated context may be outdated.`}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:[`Scan artifacts (`,ge.length,`)`]}),Fe&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,q.jsx)(C_,{className:`size-3.5 animate-spin`}),`Updating`]})]}),(0,q.jsxs)(`div`,{className:`relative rounded-lg border border-border/60 bg-background/35 p-3`,children:[ge.length===0?(0,q.jsx)(`div`,{className:`flex min-h-32 items-center justify-center rounded-md border border-dashed border-border/70 bg-background/30 px-4 text-sm text-muted-foreground`,children:`No scan artifacts yet.`}):(0,q.jsx)(`div`,{className:`space-y-0`,children:ge.map(e=>(0,q.jsx)(Tb,{artifact:e,onClick:()=>ee(!0)},e.id))}),Fe&&(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-3 z-10 rounded-md border border-border/70 bg-background/78 backdrop-blur-sm`})]})]})]}):(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:`No scan yet. Run a manual scan when you want Archon to capture compact project context from the repository.`})]}),(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-border/70 bg-card/55 shadow-[0_18px_40px_rgba(0,0,0,0.16)]`,children:[_&&(0,q.jsx)(`div`,{className:`m-4 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-red-300`,children:_}),(0,q.jsxs)(`div`,{className:`border-b border-border/60 px-5 py-4`,children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between`,children:(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground`,children:`Memory`}),(0,q.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Memories`})]})}),(0,q.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Memories`}),(0,q.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-foreground`,children:Ie})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Suggested`}),(0,q.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-foreground`,children:he.length})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Saved`}),(0,q.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-foreground`,children:me.length})]})]})]}),(0,q.jsxs)(`div`,{className:`space-y-8 px-5 py-5`,children:[(0,q.jsxs)(`section`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,q.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Suggested memories`}),(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[he.length,` items`]})]}),h?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:`Loading suggested memories...`}):he.length>0?(0,q.jsx)(`ul`,{className:`space-y-3`,children:he.map(e=>(0,q.jsx)(Ob,{memory:e,isPending:j===e.id,onReview:Ce,onAccept:async e=>{await Ee(e,!1)},onDismiss:De},e.id))}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No suggested memories right now.`})]}),(0,q.jsxs)(`section`,{className:`space-y-4 border-t border-border/60 pt-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,q.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Saved memories`}),(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[me.length,` items`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(sy,{id:`memory-show-archived-memories`,checked:N,onCheckedChange:P,"aria-label":`Show archived memories`}),(0,q.jsx)(Vg,{htmlFor:`memory-show-archived-memories`,className:`text-sm text-muted-foreground`,children:`Show archived`})]}),(0,q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:xe,children:[(0,q.jsx)(Ev,{className:`size-3.5`}),`New memory`]})]})]}),h?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:`Loading saved memories...`}):(0,q.jsx)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:me.map(e=>(0,q.jsx)(wb,{title:e.title,meta:e.meta,preview:e.preview,archived:e.archived,ariaLabel:`Open ${e.kind} ${e.title}`,onClick:()=>{if(e.kind===`convention`){let t=l.find(t=>t.id===e.id);t&&be(t);return}let t=d.find(t=>t.id===e.id);t&&Se(t)},accentClassName:e.kind===`convention`?`bg-sky-300/50`:`bg-amber-300/45`},e.id))}),!h&&me.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No saved memories yet.`})]})]})]})]}),(0,q.jsx)(vg,{open:Ae,onOpenChange:e=>{e||_e()},children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-3xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:s?.id?`Edit memory`:`Create memory`}),(0,q.jsx)(Eg,{children:`Keep the memory concise and durable so future work can reuse it without cleanup.`})]}),(0,q.jsx)(Eb,{draft:T,onChange:E,onCancel:_e,onSubmit:()=>{ye()},isSaving:k,submitLabel:s?.id?`Save memory`:`Create memory`,layout:`dialog`,allowKindChange:s?.id==null,secondaryActions:Me?Me.status===`active`?(0,q.jsx)(Y,{type:`button`,variant:`warning`,onClick:()=>{Oe(Me,`archive`).then(e=>{e&&_e()})},children:`Archive`}):(0,q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>{Oe(Me,`restore`).then(e=>{e&&_e()})},children:`Restore`}):Ne?Ne.status===`accepted`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>{ke(Ne,`supersede`).then(e=>{e&&_e()})},children:`Supersede`}),(0,q.jsx)(Y,{type:`button`,variant:`warning`,onClick:()=>{ke(Ne,`archive`).then(e=>{e&&_e()})},children:`Archive`})]}):(0,q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>{ke(Ne,`restore`).then(e=>{e&&_e()})},children:`Restore`}):null})]})}),(0,q.jsx)(kb,{memory:Pe,isOpen:Pe!==null,isEditing:C!==null,isPending:j===Pe?.id,draft:D,onOpenChange:we,onDraftChange:O,onStartEdit:Te,onCancelEdit:ve,onAccept:Ee,onDismiss:De}),(0,q.jsx)(vg,{open:z,onOpenChange:ee,children:(0,q.jsx)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:`Scan archive`}),(0,q.jsx)(Eg,{className:`sr-only`,children:`Read-only generated context.`})]}),ge.length===0?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-4 text-sm text-muted-foreground`,children:`No scan artifacts yet.`}):(0,q.jsx)(`div`,{className:`space-y-4`,children:ge.map(e=>{let t=mb(e),n=hb(t.title);return(0,q.jsxs)(`section`,{className:`space-y-2 rounded-lg border border-border/70 bg-background/40 px-4 py-3`,children:[(n||t.categoryLabel)&&(0,q.jsxs)(`div`,{className:`space-y-1`,children:[n&&(0,q.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:t.title}),t.categoryLabel&&(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:t.categoryLabel})]}),(0,q.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-6 text-foreground`,children:e.content_markdown?.trim()||`No generated notes in this artifact yet.`})]},e.id)})})]})})})]}):(0,q.jsxs)(`div`,{className:`space-y-5`,children:[a&&(0,q.jsx)(`div`,{className:`rounded-2xl border border-border/70 bg-background/25 p-4`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enable project memory`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Memory stays in Archon, not in the target repository. When disabled, Archon preserves saved items but stops injecting them into prompts.`})]}),(0,q.jsx)(sy,{"aria-label":`Enable project memory`,checked:n,onCheckedChange:i})]})}),He]})},jb=({title:e,description:t,headerAccessory:n,children:r})=>(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border/60 pb-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),n]}),r]}),Mb=({label:e,summary:t,tone:n=`default`})=>(0,q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start text-left`,children:(0,q.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:J(`text-sm font-medium`,n===`danger`?`text-red-200`:`text-foreground`),children:e}),(0,q.jsx)(`span`,{className:J(`shrink-0 text-[10px] font-semibold uppercase tracking-[0.18em]`,n===`danger`?`text-red-300/80`:`text-muted-foreground`),children:t})]})}),Nb=()=>({name:``,cmd:``,cwd:``}),Pb=()=>({source:``,target:``,mode:`copy`}),Fb=()=>({name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:``,helperVariant:``,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}),Ib=e=>({name:e.name,repoPath:e.repoPath,linkedProjectIds:e.linkedProjectIds,runSetupText:e.runSetup.join(`
62
62
  `),runServices:e.runServices.length>0?e.runServices.map(e=>({name:e.name??``,cmd:e.cmd??``,cwd:e.cwd??``})):[],runIde:e.runIde,previewServiceName:e.previewServiceName??``,previewPath:e.previewPath??``,previewCapabilityMode:e.previewCapabilityMode??`auto`,helperModel:e.helperModel,helperVariant:e.helperVariant,commitMessageRules:e.commitMessageRules,autoParkStaleTickets:e.autoParkStaleTickets,memoryEnabled:e.memoryEnabled,worktreeSync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source??``,target:e.target??``,mode:e.mode})):[]}),Lb=e=>e.split(`
63
63
  `).map(e=>e.trim()).filter(e=>e.length>0),Rb=e=>e.cmd.trim()!==``||e.cwd.trim()!==``,zb=e=>e.filter(Rb).map(e=>({...e.name.trim()===``?{}:{name:e.name.trim()},cmd:e.cmd.trim(),cwd:e.cwd.trim()})),Bb=e=>e.source.trim()!==``||e.target.trim()!==``,Vb=e=>e.filter(Bb).map(e=>({source:e.source.trim(),target:e.target.trim(),mode:e.mode})),Hb=e=>Lb(e).length===0,Ub=e=>!e.some(Rb),Wb=e=>!e.some(Bb),Gb=e=>e.length===0?`No linked projects`:e.length===1?e[0]:`${e.length} linked projects`,Kb=e=>e.name||e.repoPath||e.previewServiceName?!0:e.runServices.some(e=>!!e.cmd)||e.worktreeSync.some(e=>!!e.source),qb=e=>e.name||e.repoPath?`general`:e.previewServiceName||e.runServices.some(e=>!!e.cmd)?`services`:e.worktreeSync.some(e=>!!e.source)?`sync`:`general`,Jb=e=>{let t=e.runServices.map(e=>Rb(e)&&e.cmd.trim()===``?{cmd:`A service command is required when a service row has values.`}:{}),n=e.worktreeSync.map(e=>Bb(e)&&e.source.trim()===``?{source:`A source path is required when a sync row has values.`}:{}),r=zb(e.runServices),i=e.previewServiceName.trim(),a=i!==``&&!r.some(e=>e.name===i)?`Choose a named service before enabling preview.`:void 0;return{name:e.name.trim()===``?`Project name is required.`:void 0,repoPath:e.repoPath.trim()===``?`Repository path is required.`:void 0,previewServiceName:a,runServices:t,worktreeSync:n}},Yb=({mode:e=`create`,projectId:t=null,initialValues:n=Fb(),availableHelperModels:r=[],isLoadingHelperModels:i=!1,linkedProjectOptions:a=[],isAutoConfigReady:o=!1,repoPathLocked:s=!1,repoPathLockedMessage:c=null,deleteBlockedMessage:l=null,onAutoConfig:u,onBrowseRepoPath:d,onValidateRepoPath:f,onClose:p,onSubmit:m,onDelete:h})=>{let[g,_]=(0,b.useState)(()=>Ib(n)),[v,y]=(0,b.useState)({runServices:[],worktreeSync:[]}),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)({status:`idle`}),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(e===`edit`&&t?null:0),F=(0,b.useRef)(n.repoPath.trim()),I=(0,b.useRef)(0),L=(0,b.useRef)(null),R=(0,b.useRef)(n.repoPath.trim()||null),z=(0,b.useRef)(n.repoPath.trim()||null),ee=(0,b.useRef)(null),[B,V]=(0,b.useState)(`general`),H=g.repoPath.trim(),te=s?H!==``:f?H!==``&&(H===F.current||T.status===`valid`&&z.current===H):H!==``,U=j||g.name.trim()===``||!te,ne=D||!!l,W=x||g.repoPath.trim()===``||!o,re=new Map(a.map(e=>[e.id,e.name])),ie=g.linkedProjectIds.map(e=>re.get(e)).filter(e=>typeof e==`string`),ae=[{value:`general`,label:`General`,summary:`Required`},{value:`automation`,label:`Automation`,summary:g.helperModel||g.commitMessageRules.trim()||g.runSetupText.trim()||g.runIde.trim()||g.linkedProjectIds.length>0||g.autoParkStaleTickets?`Configured`:`Optional`},{value:`services`,label:`Services`,summary:g.runServices.length===0?`None`:`${g.runServices.length}`},{value:`sync`,label:`Sync`,summary:g.worktreeSync.length===0?`None`:`${g.worktreeSync.length}`},{value:`memory`,label:`Memory`,summary:g.memoryEnabled?`Enabled`:`Disabled`},...e===`edit`&&t?[{value:`integrations`,label:`Integrations`,summary:N===null?`Loading`:`${N} enabled`}]:[],...e===`edit`&&h?[{value:`danger`,label:`Danger Zone`,summary:l?`Blocked`:`Ready`,tone:`danger`}]:[]],G=(0,b.useCallback)(()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null)},[]);(0,b.useEffect)(()=>{if(e!==`edit`||!t){P(0);return}let n=new AbortController;return P(null),ty(t,n.signal).then(e=>{if(n.signal.aborted)return;let t=e.connections.filter(e=>e.status===`connected`).length;P(t)}).catch(()=>{n.signal.aborted||P(0)}),()=>{n.abort()}},[e,t]);let oe=(0,b.useCallback)(async e=>{if(!f){E({status:`idle`});return}let t=e.trim();if(t===``){R.current=null,z.current=null,E({status:`idle`});return}let n=I.current+1;I.current=n,R.current=t,E({status:`checking`});try{let e=await f(t);if(I.current!==n)return;if(e.valid&&e.repoRoot){z.current=t,E({status:`valid`,repoRoot:e.repoRoot});return}z.current=null,E({status:`invalid`,error:e.error??`Repository path is not a valid git repository.`})}catch(e){if(I.current!==n)return;let t=e instanceof Error?e.message:`Unable to validate the repository path right now.`;z.current=null,E({status:`invalid`,error:t})}},[f]);(0,b.useEffect)(()=>{if(G(),s){I.current+=1,R.current=H||null,z.current=H||null,E(H===``?{status:`idle`}:{status:`valid`,repoRoot:H});return}if(!f||H===``){I.current+=1,R.current=null,z.current=null,E({status:`idle`});return}if(H===F.current){I.current+=1,R.current=H,z.current=H,E({status:`valid`,repoRoot:H});return}if(ee.current===H){ee.current=null;return}if(R.current!==H)return E({status:`idle`}),L.current=window.setTimeout(()=>{oe(H)},350),()=>{G()}},[G,f,s,oe,H,g.repoPath]);let se=(e,t)=>{_(n=>({...n,[e]:t})),(e===`name`||e===`repoPath`)&&y(t=>({...t,[e]:void 0}))},ce=(e,t,n)=>{_(r=>({...r,runServices:r.runServices.map((r,i)=>i===e?{...r,[t]:n}:r)})),y(t=>({...t,runServices:t.runServices.map((t,n)=>n===e?{...t,cmd:void 0}:t)}))},le=(e,t,n)=>{_(r=>({...r,worktreeSync:r.worktreeSync.map((r,i)=>i!==e||t===`mode`&&n!==`copy`&&n!==`symlink`?r:{...r,[t]:n})})),y(t=>({...t,worktreeSync:t.worktreeSync.map((t,n)=>n===e?{...t,source:void 0}:t)}))},ue=e=>{_(t=>({...t,linkedProjectIds:t.linkedProjectIds.includes(e)?t.linkedProjectIds.filter(t=>t!==e):[...t.linkedProjectIds,e].sort((e,t)=>e.localeCompare(t))}))},de=()=>{_(e=>({...e,runServices:[...e.runServices,Nb()]})),y(e=>({...e,runServices:[...e.runServices,{}]}))},K=e=>{_(t=>({...t,runServices:t.runServices.filter((t,n)=>n!==e)})),y(t=>({...t,runServices:t.runServices.filter((t,n)=>n!==e)}))},fe=()=>{_(e=>({...e,worktreeSync:[...e.worktreeSync,Pb()]})),y(e=>({...e,worktreeSync:[...e.worktreeSync,{}]}))},pe=e=>{_(t=>({...t,worktreeSync:t.worktreeSync.filter((t,n)=>n!==e)})),y(t=>({...t,worktreeSync:t.worktreeSync.filter((t,n)=>n!==e)}))},me=async e=>{if(e.preventDefault(),j)return;let t=Jb(g);if(y(t),Kb(t)){V(qb(t));return}M(!0);let n=await m({name:g.name.trim(),repoPath:g.repoPath.trim(),linkedProjectIds:g.linkedProjectIds,runSetup:Lb(g.runSetupText),runServices:zb(g.runServices),runIde:g.runIde.trim(),...g.previewServiceName.trim()===``?{}:{previewServiceName:g.previewServiceName.trim()},...g.previewPath.trim()===``?{}:{previewPath:g.previewPath.trim()},...g.previewServiceName.trim()!==``||g.previewPath.trim()!==``||g.previewCapabilityMode!==`auto`?{previewCapabilityMode:g.previewCapabilityMode}:{},helperModel:g.helperModel,helperVariant:g.helperVariant,commitMessageRules:g.commitMessageRules.trim(),autoParkStaleTickets:g.autoParkStaleTickets,memoryEnabled:g.memoryEnabled,worktreeSync:Vb(g.worktreeSync)});n&&(X.error(n,{id:`project-modal-submit-error`}),M(!1))},he=async()=>{if(!h||ne)return;O(!0);let e=await h();e&&(X.error(e,{id:`project-modal-delete-error`}),O(!1))},ge=async()=>{if(!(!u||W)){S(!0);try{let e=await u(g.repoPath.trim(),g.helperModel,g.helperVariant),t=[];_(n=>{let r={...n};return Hb(n.runSetupText)&&e.run_setup.length>0&&(r.runSetupText=e.run_setup.join(`
64
- `),t.push(`setup commands`)),Ub(n.runServices)&&e.run_services.length>0&&(r.runServices=e.run_services.map(e=>({name:e.name??``,cmd:e.cmd,cwd:e.cwd??``})),t.push(`services`)),Wb(n.worktreeSync)&&e.worktree_sync.length>0&&(r.worktreeSync=e.worktree_sync.map(e=>({source:e.source,target:e.target??``,mode:e.mode})),t.push(`worktree sync`)),r}),y(e=>({...e,runServices:t.includes(`services`)?[]:e.runServices,worktreeSync:t.includes(`worktree sync`)?[]:e.worktreeSync})),t.length>0?X.success(`Auto-config applied.`,{id:`project-modal-auto-config-success`}):X.info(`Auto-config found no empty fields to fill.`,{id:`project-modal-auto-config-noop`})}catch{X.error(`Auto-config failed.`,{id:`project-modal-auto-config-error`})}finally{S(!1)}}},_e=async()=>{if(!(!d||C||s)){w(!0);try{let e=await d();e&&(ee.current=e.trim(),se(`repoPath`,e),oe(e))}catch(e){let t=e instanceof Error?e.message:`Unable to open the folder picker.`;X.error(t,{id:`project-modal-browse-repo-path-error`})}finally{w(!1)}}};return(0,q.jsx)(vg,{open:!0,onOpenChange:e=>{e||p()},children:(0,q.jsxs)(Sg,{showCloseButton:!1,overlayClassName:`bg-black/70`,className:`flex h-[calc(100vh-1.5rem)] max-h-[58rem] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden rounded-3xl border border-[#2a2a38] bg-[#16161f] p-0 shadow-2xl sm:max-w-6xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,q.jsx)(Tg,{className:`sr-only`,children:e===`edit`?`Edit project settings`:`Add a repository to Archon`}),(0,q.jsx)(Eg,{className:`sr-only`,children:`Configure a project repository, setup commands, services, and IDE launch settings.`}),(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border px-6 py-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:e===`edit`?`Edit project settings`:`Add project`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e===`edit`?`Update how Archon prepares and opens worktrees for this repository.`:`Point Archon at a repository, then define only the behavior you want Archon to manage.`})]}),(0,q.jsx)(bg,{asChild:!0,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Close modal`,variant:`ghost`,size:`icon-sm`,className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})})]}),(0,q.jsxs)(`form`,{onSubmit:me,className:`flex flex-1 flex-col overflow-hidden`,children:[(0,q.jsxs)(Zv,{value:B,onValueChange:e=>V(e),orientation:`vertical`,className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,q.jsxs)(`aside`,{className:`border-b border-border/70 px-4 py-4 md:w-[18rem] md:border-r md:border-b-0 md:px-5 md:py-5`,children:[(0,q.jsx)(`p`,{className:`px-2 text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Settings`}),(0,q.jsx)(Qv,{className:`mt-3 flex w-full flex-col items-stretch gap-1 border-0 bg-transparent p-0 shadow-none`,children:ae.map(e=>(0,q.jsx)($v,{value:e.value,className:J(`h-auto w-full justify-start whitespace-normal border-transparent bg-transparent px-3 py-3 text-left shadow-none hover:bg-background/50 data-[state=active]:border-border/70 data-[state=active]:bg-card/90`,e.tone===`danger`&&`data-[state=active]:border-red-500/30 data-[state=active]:bg-destructive/10`),children:(0,q.jsx)(Mb,{label:e.label,summary:e.summary,tone:e.tone})},e.value))})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,q.jsx)(ey,{value:`general`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`General`,description:`Start with the repository Archon should use when it creates and manages worktrees for this project.`,children:(0,q.jsx)(Sy,{name:g.name,repoPath:g.repoPath,repoPathLocked:s,repoPathLockedMessage:c,isBrowsingRepoPath:C,repoPathValidation:T,nameError:v.name,repoPathError:v.repoPath,onNameChange:e=>se(`name`,e),onRepoPathChange:e=>se(`repoPath`,e),onBrowseRepoPath:d?()=>{_e()}:void 0})})}),(0,q.jsx)(ey,{value:`automation`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Automation`,description:`Configure helper defaults, setup behavior, and optional workflow rules Archon can apply to this project.`,children:(0,q.jsx)(_y,{onAutoConfig:u?()=>{ge()}:void 0,isAutoConfigDisabled:W,isAutoConfiguring:x,helperModel:g.helperModel,helperVariant:g.helperVariant,availableHelperModels:r,isLoadingHelperModels:i,onHelperModelChange:e=>{_(t=>({...t,helperModel:e,helperVariant:e===t.helperModel?t.helperVariant:``}))},onHelperVariantChange:e=>{_(t=>({...t,helperVariant:e}))},commitMessageRules:g.commitMessageRules,onCommitMessageRulesChange:e=>se(`commitMessageRules`,e),linkedProjectOptions:a,selectedLinkedProjectNames:ie,linkedProjectTriggerLabel:Gb(ie),linkedProjectIds:g.linkedProjectIds,onToggleLinkedProject:ue,runSetupText:g.runSetupText,onRunSetupChange:e=>se(`runSetupText`,e),runIde:g.runIde,onRunIdeChange:e=>se(`runIde`,e),autoParkStaleTickets:g.autoParkStaleTickets,onAutoParkStaleTicketsChange:e=>{_(t=>({...t,autoParkStaleTickets:e}))}})})}),(0,q.jsx)(ey,{value:`services`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Services`,description:`Add long-running commands that Archon should start automatically inside each worktree.`,children:(0,q.jsx)(vy,{runServices:g.runServices,runServiceErrors:v.runServices,previewServiceName:g.previewServiceName,previewPath:g.previewPath,previewCapabilityMode:g.previewCapabilityMode,previewServiceNameError:v.previewServiceName,onAddServiceRow:de,onServiceChange:ce,onPreviewServiceNameChange:e=>{_(t=>({...t,previewServiceName:e})),y(e=>({...e,previewServiceName:void 0}))},onPreviewPathChange:e=>{_(t=>({...t,previewPath:e}))},onPreviewCapabilityModeChange:e=>{_(t=>({...t,previewCapabilityMode:e}))},onRemoveServiceRow:K})})}),(0,q.jsx)(ey,{value:`sync`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Sync`,description:`Define which local files Archon should copy or symlink into a worktree the first time it is created.`,children:(0,q.jsx)(yy,{worktreeSync:g.worktreeSync,worktreeSyncErrors:v.worktreeSync,onAddWorktreeSyncRow:fe,onWorktreeSyncChange:le,onRemoveWorktreeSyncRow:pe})})}),(0,q.jsx)(ey,{value:`memory`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Memory`,description:`Turn project memory on or off and manage the saved context Archon keeps outside the repository.`,headerAccessory:(0,q.jsx)(Z,{variant:`outline`,className:`self-start px-3 py-1 text-xs uppercase tracking-[0.24em]`,children:g.memoryEnabled?`Enabled`:`Disabled`}),children:(0,q.jsx)(Ab,{mode:e,projectId:t,memoryEnabled:g.memoryEnabled,persistedMemoryEnabled:n.memoryEnabled,onMemoryEnabledChange:e=>{_(t=>({...t,memoryEnabled:e}))}})})}),e===`edit`&&t&&(0,q.jsx)(ey,{value:`integrations`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Integrations`,description:`Connect external systems that add richer context to planning, tickets, and pull requests for this project.`,children:(0,q.jsx)(Hy,{projectId:t,onEnabledCountChange:P})})}),e===`edit`&&h&&(0,q.jsx)(ey,{value:`danger`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Danger Zone`,description:`Delete this project only after its tickets and worktrees are already gone. This action cannot be undone.`,children:(0,q.jsx)(Cy,{projectName:g.name,deleteBlockedMessage:l,isDeleteDisabled:ne,isDeleting:D,showDeleteConfirm:k,onDeleteConfirmToggle:A,onDelete:()=>{he()}})})})]})]}),(0,q.jsx)(`div`,{className:`border-t border-border px-6 py-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end`,children:[(0,q.jsx)(Y,{type:`button`,onClick:p,variant:`ghost`,children:`Cancel`}),(0,q.jsx)(Y,{type:`submit`,disabled:U,variant:`success`,children:j?e===`edit`?`Saving...`:`Creating...`:e===`edit`?`Save changes`:`Create project`})]})})]})]})})},Xb=({compactAt:e,tightAt:t,width:n})=>n<=0?`wide`:n<=t?`tight`:n<=e?`compact`:`wide`,Zb=({compactAt:e,tightAt:t})=>{let[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(`wide`),o=(0,b.useCallback)(n=>{r(n);let i=n?Math.round(n.getBoundingClientRect().width):0;a(n=>{let r=Xb({compactAt:e,tightAt:t,width:i});return n===r?n:r})},[e,t]);return(0,b.useEffect)(()=>{if(!n)return;let r=()=>{let r=Math.round(n.getBoundingClientRect().width);a(n=>{let i=Xb({compactAt:e,tightAt:t,width:r});return n===i?n:i})};if(r(),typeof ResizeObserver!=`function`)return;let i=new ResizeObserver(()=>{r()});return i.observe(n),()=>{i.disconnect()}},[e,n,t]),{ref:o,mode:i}},Qb=({className:e})=>(0,q.jsx)(ch,{"aria-hidden":`true`,className:e}),$b=({className:e})=>(0,q.jsx)(eh,{"aria-hidden":`true`,className:e}),ex=({className:e})=>(0,q.jsx)(Qm,{"aria-hidden":`true`,className:e}),tx=new Map,nx=({projectId:e,reviewCapabilityContextKey:t})=>t?`${e}:${t}`:null,rx=e=>e.map(e=>({...e})),ix=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return r&&e.id===r.id&&e.comment===r.comment}),ax=e=>e?rx(tx.get(e)??[]):[],ox=({contextKey:e,drafts:t})=>{if(e){if(t.length===0){tx.delete(e);return}tx.set(e,rx(t))}};function sx(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 cx(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sx(Object(n),!0).forEach((function(t){lx(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sx(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function lx(e,t,n){return(t=function(e){var t=function(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)}(e,`string`);return typeof t==`symbol`?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ux(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function dx(e,t){return mx(e)||function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||gx(e,t)||vx()}function fx(e){return mx(e)||hx(e)||gx(e)||vx()}function px(e){return function(e){if(Array.isArray(e))return _x(e)}(e)||hx(e)||gx(e)||function(){throw TypeError(`Invalid attempt to spread non-iterable instance.
65
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function mx(e){if(Array.isArray(e))return e}function hx(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function gx(e,t){if(e){if(typeof e==`string`)return _x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_x(e,t):void 0}}function _x(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function vx(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
66
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yx(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=gx(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
67
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}var bx=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function xx(e,t){return e(t={exports:{}},t.exports),t.exports}var Sx=xx((function(e){(function(){var t={}.hasOwnProperty;function n(){for(var e=[],r=0;r<arguments.length;r++){var i=arguments[r];if(i){var a=typeof i;if(a===`string`||a===`number`)e.push(i);else if(Array.isArray(i)){if(i.length){var o=n.apply(null,i);o&&e.push(o)}}else if(a===`object`){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes(`[native code]`)){e.push(i.toString());continue}for(var s in i)t.call(i,s)&&i[s]&&e.push(s)}}}return e.join(` `)}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})),Cx={hunkClassName:``,lineClassName:``,gutterClassName:``,codeClassName:``,monotonous:!1,gutterType:`default`,viewType:`split`,widgets:{},hideGutter:!1,selectedChanges:[],generateAnchorID:function(){},generateLineClassName:function(){},renderGutter:function(e){var t=e.renderDefault;return(0,e.wrapInAnchor)(t())},codeEvents:{},gutterEvents:{}},wx=(0,b.createContext)(Cx),Tx=wx.Provider,Ex=function(){return(0,b.useContext)(wx)},Dx=xx((function(e,t){(function(t){function n(e){var t=e.slice(11),n=null,r=null;switch(t.indexOf(`"`)){case-1:n=(o=t.split(` `))[0].slice(2),r=o[1].slice(2);break;case 0:var i=t.indexOf(`"`,2);n=t.slice(3,i);var a=t.indexOf(`"`,i+1);r=a<0?t.slice(i+4):t.slice(a+3,-1);break;default:var o;n=(o=t.split(` `))[0].slice(2),r=o[1].slice(3,-1)}return{oldPath:n,newPath:r}}e.exports={parse:function(e){for(var t,r,i,a,o,s=[],c=2,l=e.split(`
68
- `),u=l.length,d=0;d<u;){var f=l[d];if(f.indexOf(`diff --git`)===0){t={hunks:[],oldEndingNewLine:!0,newEndingNewLine:!0,oldPath:(o=n(f)).oldPath,newPath:o.newPath},s.push(t);var p,m=null;simiLoop:for(;p=l[++d];){var h=p.indexOf(` `),g=h>-1?p.slice(0,h):g;switch(g){case`diff`:d--;break simiLoop;case`deleted`:case`new`:var _=p.slice(h+1);_.indexOf(`file mode`)===0&&(t[g===`new`?`newMode`:`oldMode`]=_.slice(10));break;case`similarity`:t.similarity=parseInt(p.split(` `)[2],10);break;case`index`:var v=p.slice(h+1).split(` `),y=v[0].split(`..`);t.oldRevision=y[0],t.newRevision=y[1],v[1]&&(t.oldMode=t.newMode=v[1]);break;case`copy`:case`rename`:var b=p.slice(h+1);b.indexOf(`from`)===0?t.oldPath=b.slice(5):t.newPath=b.slice(3),m=g;break;case`---`:var x=p.slice(h+1),S=l[++d].slice(4);x===`/dev/null`?(S=S.slice(2),m=`add`):S===`/dev/null`?(x=x.slice(2),m=`delete`):(m=`modify`,x=x.slice(2),S=S.slice(2)),x&&(t.oldPath=x),S&&(t.newPath=S),c=5;break simiLoop}}t.type=m||`modify`}else if(f.indexOf(`Binary`)===0)t.isBinary=!0,t.type=f.indexOf(`/dev/null and`)>=0?`add`:f.indexOf(`and /dev/null`)>=0?`delete`:`modify`,c=2,t=null;else if(c===5)if(f.indexOf(`@@`)===0){var C=/^@@\s+-([0-9]+)(,([0-9]+))?\s+\+([0-9]+)(,([0-9]+))?/.exec(f);r={content:f,oldStart:C[1]-0,newStart:C[4]-0,oldLines:C[3]-0||1,newLines:C[6]-0||1,changes:[]},t.hunks.push(r),i=r.oldStart,a=r.newStart}else{var w=f.slice(0,1),T={content:f.slice(1)};switch(w){case`+`:T.type=`insert`,T.isInsert=!0,T.lineNumber=a,a++;break;case`-`:T.type=`delete`,T.isDelete=!0,T.lineNumber=i,i++;break;case` `:T.type=`normal`,T.isNormal=!0,T.oldLineNumber=i,T.newLineNumber=a,i++,a++;break;case`\\`:var E=r.changes[r.changes.length-1];E.isDelete||(t.newEndingNewLine=!1),E.isInsert||(t.oldEndingNewLine=!1)}T.type&&r.changes.push(T)}d++}return s}}})()}));function Ox(e){return e.type===`insert`}function kx(e){return e.type===`delete`}function Ax(e){return e.type===`normal`}function jx(e,t){var n=t.nearbySequences===`zip`?function(e){return dx(e.reduce((function(e,t,n){var r=dx(e,3),i=r[0],a=r[1],o=r[2];return a?Ox(t)&&o>=0?(i.splice(o+1,0,t),[i,t,o+2]):(i.push(t),[i,t,kx(t)&&kx(a)?o:n]):(i.push(t),[i,t,kx(t)?n:-1])}),[[],null,-1]),1)[0]}(e.changes):e.changes;return cx(cx({},e),{},{isPlain:!1,changes:n})}function Mx(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=function(e){if(e.startsWith(`diff --git`))return e;var t=e.indexOf(`
64
+ `),t.push(`setup commands`)),Ub(n.runServices)&&e.run_services.length>0&&(r.runServices=e.run_services.map(e=>({name:e.name??``,cmd:e.cmd,cwd:e.cwd??``})),t.push(`services`)),Wb(n.worktreeSync)&&e.worktree_sync.length>0&&(r.worktreeSync=e.worktree_sync.map(e=>({source:e.source,target:e.target??``,mode:e.mode})),t.push(`worktree sync`)),r}),y(e=>({...e,runServices:t.includes(`services`)?[]:e.runServices,worktreeSync:t.includes(`worktree sync`)?[]:e.worktreeSync})),t.length>0?X.success(`Auto-config applied.`,{id:`project-modal-auto-config-success`}):X.info(`Auto-config found no empty fields to fill.`,{id:`project-modal-auto-config-noop`})}catch{X.error(`Auto-config failed.`,{id:`project-modal-auto-config-error`})}finally{S(!1)}}},_e=async()=>{if(!(!d||C||s)){w(!0);try{let e=await d();e&&(ee.current=e.trim(),se(`repoPath`,e),oe(e))}catch(e){let t=e instanceof Error?e.message:`Unable to open the folder picker.`;X.error(t,{id:`project-modal-browse-repo-path-error`})}finally{w(!1)}}};return(0,q.jsx)(vg,{open:!0,onOpenChange:e=>{e||p()},children:(0,q.jsxs)(Sg,{showCloseButton:!1,overlayClassName:`bg-black/70`,className:`flex h-[calc(100vh-1.5rem)] max-h-[58rem] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden rounded-3xl border border-[#2a2a38] bg-[#16161f] p-0 shadow-2xl sm:max-w-6xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,q.jsx)(Tg,{className:`sr-only`,children:e===`edit`?`Edit project settings`:`Add a repository to Archon`}),(0,q.jsx)(Eg,{className:`sr-only`,children:`Configure a project repository, setup commands, services, and IDE launch settings.`}),(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border px-6 py-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:e===`edit`?`Edit project settings`:`Add project`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e===`edit`?`Update how Archon prepares and opens worktrees for this repository.`:`Point Archon at a repository, then define only the behavior you want Archon to manage.`})]}),(0,q.jsx)(bg,{asChild:!0,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Close modal`,variant:`ghost`,size:`icon-sm`,className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})})]}),(0,q.jsxs)(`form`,{onSubmit:me,className:`flex flex-1 flex-col overflow-hidden`,children:[(0,q.jsxs)(Zv,{value:B,onValueChange:e=>V(e),orientation:`vertical`,className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,q.jsxs)(`aside`,{className:`border-b border-border/70 px-4 py-4 md:w-[18rem] md:border-r md:border-b-0 md:px-5 md:py-5`,children:[(0,q.jsx)(`p`,{className:`px-2 text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Settings`}),(0,q.jsx)(Qv,{className:`mt-3 flex w-full flex-col items-stretch gap-1 border-0 bg-transparent p-0 shadow-none`,children:ae.map(e=>(0,q.jsx)($v,{value:e.value,className:J(`h-auto w-full justify-start whitespace-normal border-transparent bg-transparent px-3 py-3 text-left shadow-none hover:bg-background/50 data-[state=active]:border-border/70 data-[state=active]:bg-card/90`,e.tone===`danger`&&`data-[state=active]:border-red-500/30 data-[state=active]:bg-destructive/10`),children:(0,q.jsx)(Mb,{label:e.label,summary:e.summary,tone:e.tone})},e.value))})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,q.jsx)(ey,{value:`general`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`General`,description:`Start with the repository Archon should use when it creates and manages worktrees for this project.`,children:(0,q.jsx)(Sy,{name:g.name,repoPath:g.repoPath,repoPathLocked:s,repoPathLockedMessage:c,isBrowsingRepoPath:C,repoPathValidation:T,nameError:v.name,repoPathError:v.repoPath,onNameChange:e=>se(`name`,e),onRepoPathChange:e=>se(`repoPath`,e),onBrowseRepoPath:d?()=>{_e()}:void 0})})}),(0,q.jsx)(ey,{value:`automation`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Automation`,description:`Configure helper defaults, setup behavior, and optional workflow rules Archon can apply to this project.`,children:(0,q.jsx)(_y,{onAutoConfig:u?()=>{ge()}:void 0,isAutoConfigDisabled:W,isAutoConfiguring:x,helperModel:g.helperModel,helperVariant:g.helperVariant,availableHelperModels:r,isLoadingHelperModels:i,onHelperModelChange:e=>{_(t=>({...t,helperModel:e,helperVariant:e===t.helperModel?t.helperVariant:``}))},onHelperVariantChange:e=>{_(t=>({...t,helperVariant:e}))},commitMessageRules:g.commitMessageRules,onCommitMessageRulesChange:e=>se(`commitMessageRules`,e),linkedProjectOptions:a,selectedLinkedProjectNames:ie,linkedProjectTriggerLabel:Gb(ie),linkedProjectIds:g.linkedProjectIds,onToggleLinkedProject:ue,runSetupText:g.runSetupText,onRunSetupChange:e=>se(`runSetupText`,e),runIde:g.runIde,onRunIdeChange:e=>se(`runIde`,e),autoParkStaleTickets:g.autoParkStaleTickets,onAutoParkStaleTicketsChange:e=>{_(t=>({...t,autoParkStaleTickets:e}))}})})}),(0,q.jsx)(ey,{value:`services`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Services`,description:`Add long-running commands that Archon should start automatically inside each worktree.`,children:(0,q.jsx)(vy,{runServices:g.runServices,runServiceErrors:v.runServices,previewServiceName:g.previewServiceName,previewPath:g.previewPath,previewCapabilityMode:g.previewCapabilityMode,previewServiceNameError:v.previewServiceName,onAddServiceRow:de,onServiceChange:ce,onPreviewServiceNameChange:e=>{_(t=>({...t,previewServiceName:e})),y(e=>({...e,previewServiceName:void 0}))},onPreviewPathChange:e=>{_(t=>({...t,previewPath:e}))},onPreviewCapabilityModeChange:e=>{_(t=>({...t,previewCapabilityMode:e}))},onRemoveServiceRow:K})})}),(0,q.jsx)(ey,{value:`sync`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Sync`,description:`Define which local files Archon should copy or symlink into a worktree the first time it is created.`,children:(0,q.jsx)(yy,{worktreeSync:g.worktreeSync,worktreeSyncErrors:v.worktreeSync,onAddWorktreeSyncRow:fe,onWorktreeSyncChange:le,onRemoveWorktreeSyncRow:pe})})}),(0,q.jsx)(ey,{value:`memory`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Memory`,description:`Turn project memory on or off and manage the saved context Archon keeps outside the repository.`,headerAccessory:(0,q.jsx)(Z,{variant:`outline`,className:`self-start px-3 py-1 text-xs uppercase tracking-[0.24em]`,children:g.memoryEnabled?`Enabled`:`Disabled`}),children:(0,q.jsx)(Ab,{mode:e,projectId:t,memoryEnabled:g.memoryEnabled,persistedMemoryEnabled:n.memoryEnabled,onMemoryEnabledChange:e=>{_(t=>({...t,memoryEnabled:e}))}})})}),e===`edit`&&t&&(0,q.jsx)(ey,{value:`integrations`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Integrations`,description:`Connect external systems that add richer context to planning, tickets, and pull requests for this project.`,children:(0,q.jsx)(Hy,{projectId:t,onEnabledCountChange:P})})}),e===`edit`&&h&&(0,q.jsx)(ey,{value:`danger`,className:`mt-0`,children:(0,q.jsx)(jb,{title:`Danger Zone`,description:`Delete this project only after its tickets and worktrees are already gone. This action cannot be undone.`,children:(0,q.jsx)(Cy,{projectName:g.name,deleteBlockedMessage:l,isDeleteDisabled:ne,isDeleting:D,showDeleteConfirm:k,onDeleteConfirmToggle:A,onDelete:()=>{he()}})})})]})]}),(0,q.jsx)(`div`,{className:`border-t border-border px-6 py-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end`,children:[(0,q.jsx)(Y,{type:`button`,onClick:p,variant:`ghost`,children:`Cancel`}),(0,q.jsx)(Y,{type:`submit`,disabled:U,variant:`success`,children:j?e===`edit`?`Saving...`:`Creating...`:e===`edit`?`Save changes`:`Create project`})]})})]})]})})},Xb=({compactAt:e,tightAt:t,width:n})=>n<=0?`wide`:n<=t?`tight`:n<=e?`compact`:`wide`,Zb=({compactAt:e,tightAt:t})=>{let[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(`wide`),o=(0,b.useCallback)(n=>{r(n);let i=n?Math.round(n.getBoundingClientRect().width):0;a(n=>{let r=Xb({compactAt:e,tightAt:t,width:i});return n===r?n:r})},[e,t]);return(0,b.useEffect)(()=>{if(!n)return;let r=()=>{let r=Math.round(n.getBoundingClientRect().width);a(n=>{let i=Xb({compactAt:e,tightAt:t,width:r});return n===i?n:i})};if(r(),typeof ResizeObserver!=`function`)return;let i=new ResizeObserver(()=>{r()});return i.observe(n),()=>{i.disconnect()}},[e,n,t]),{ref:o,mode:i}},Qb=120,$b=160,ex=(e,t)=>t===0?0:e<0?t-1:e>=t?0:e,tx=e=>({start:e.selectionStart??0,end:e.selectionEnd??0}),nx=e=>e?`${e.replaceStart}:${e.replaceEnd}:${e.query}`:null,rx=({value:e,selection:t})=>{if(t.start!==t.end)return null;let n=t.start;for(;n>0&&!/\s/.test(e[n-1]??``);)--n;let r=t.end;for(;r<e.length&&!/\s/.test(e[r]??``);)r+=1;return!e.slice(n,r).startsWith(`@`)||n>0&&!/\s/.test(e[n-1]??``)?null:{query:e.slice(n+1,t.start),replaceStart:n,replaceEnd:r}},ix=(e,t)=>{if(e){if(typeof e==`function`){e(t);return}e.current=t}},ax=e=>{let t=Number.parseFloat(e);return Number.isNaN(t)?0:t},ox=e=>{let t=ax(e.lineHeight);if(t>0)return t;let n=ax(e.fontSize);return n>0?n*1.2:20},sx=(e,t)=>{let n=window.getComputedStyle(e),r=document.createElement(`div`),i=document.createElement(`span`),a=e.value.slice(0,t),o=`borderBottomWidth.borderLeftWidth.borderRightWidth.borderTopWidth.boxSizing.fontFamily.fontFeatureSettings.fontKerning.fontSize.fontStretch.fontStyle.fontVariant.fontVariationSettings.fontWeight.letterSpacing.lineHeight.paddingBottom.paddingLeft.paddingRight.paddingTop.tabSize.textIndent.textTransform.whiteSpace.width.wordBreak.wordSpacing.overflowWrap`.split(`.`);r.setAttribute(`aria-hidden`,`true`),Object.assign(r.style,{position:`absolute`,visibility:`hidden`,top:`0`,left:`-9999px`,overflow:`hidden`,whiteSpace:`pre-wrap`,wordWrap:`break-word`,pointerEvents:`none`}),o.forEach(e=>{r.style[e]=n[e]}),r.textContent=a,i.textContent=`​`,r.append(i),document.body.append(r);let s=ax(n.borderTopWidth),c=ox(n),l=i.offsetTop+s-e.scrollTop;return r.remove(),{top:l,lineHeight:c}},cx=(0,b.forwardRef)(({projectId:e,suggestionTicketId:t=null,value:n,onValueChange:r,onKeyDown:i,onBlur:a,onFocus:o,onScroll:s,onSelect:c,suggestionAnchor:l=`edge`,suggestionPlacement:u=`below`,wrapperClassName:d,className:f,...p},m)=>{let h=(0,b.useRef)(null),g=(0,b.useRef)(null),[_,v]=(0,b.useState)({start:0,end:0}),[y,x]=(0,b.useState)([]),[S,C]=(0,b.useState)(0),[w,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(null),N=(0,b.useId)(),P=(0,b.useMemo)(()=>rx({value:n,selection:_}),[_,n]),F=nx(P),I=y.length>0,L=k===F,R=D&&I&&!L,z=!!e&&!!F&&w!==F&&(I||D||L);(0,b.useEffect)(()=>{let e=g.current;if(e===null)return;let t=h.current;if(!t)return;let n=requestAnimationFrame(()=>{let n=Math.min(e,t.value.length);t.focus(),t.setSelectionRange(n,n),v({start:n,end:n}),g.current=null});return()=>{cancelAnimationFrame(n)}},[n]),(0,b.useEffect)(()=>{if(!e||!F){E(null),x([]),A(null),O(!1),C(0);return}if(w===F)return;O(!0);let n=new AbortController,r=window.setTimeout(async()=>{try{let r=await We(e,P?.query??``,{signal:n.signal,ticketId:t});if(n.signal.aborted)return;x(r),A(F),C(0)}catch(e){T(e)||(x([]),A(F),C(0))}finally{n.signal.aborted||O(!1)}},Qb);return()=>{n.abort(),window.clearTimeout(r)}},[P?.query,F,w,e,t]),(0,b.useEffect)(()=>{C(e=>ex(e,y.length))},[y]),(0,b.useLayoutEffect)(()=>{if(!z||l!==`caret`){M(null);return}let e=h.current;if(!e){M(null);return}let{top:t,lineHeight:n}=sx(e,_.start),r=t,i=e.clientHeight-(t+n),a=r>=$b||r>=i?`above`:`below`,o=a===`above`?Math.max(t-8,0):t+n+8;M(e=>e&&e.placement===a&&Math.abs(e.top-o)<1?e:{placement:a,top:o})},[_.start,z,l,n]),(0,b.useEffect)(()=>{!z||y.length===0||document.getElementById(`${N}-option-${S}`)?.scrollIntoView({block:`nearest`})},[S,N,y.length,z]);let ee=()=>{F&&E(F)},B=e=>{if(!e||!P||!L)return;let t=n.slice(P.replaceEnd),i=t.length===0||!/^\s/.test(t),a=`@${e.path}${i?` `:``}`,o=n.slice(0,P.replaceStart)+a+t,s=P.replaceStart+a.length,c=`${P.replaceStart}:${s}:${e.path}`;g.current=s,E(c),A(null),x([]),r(o)},V=e=>{v(tx(e.currentTarget)),r(e.target.value)},H=e=>{ee(),a?.(e)},te=e=>{v(tx(e.currentTarget)),o?.(e)},U=e=>{v(tx(e.currentTarget)),c?.(e)},ne=e=>{v(tx(e.currentTarget)),s?.(e)},W=l===`caret`&&j,re=W?{top:`${j.top}px`,transform:j.placement===`above`?`translateY(-100%)`:void 0}:void 0,ie=e=>{if(z){if(!L&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`)){e.preventDefault();return}if(e.key===`ArrowDown`){e.preventDefault(),C(e=>ex(e+1,y.length));return}if(e.key===`ArrowUp`){e.preventDefault(),C(e=>ex(e-1,y.length));return}if(e.key===`Enter`){e.preventDefault();let t=y[S]??null;t&&B(t);return}if(e.key===`Escape`){e.preventDefault(),ee();return}}i?.(e)};return(0,q.jsxs)(`div`,{className:J(`relative min-w-0`,d),children:[(0,q.jsx)(Og,{...p,ref:e=>{h.current=e,ix(m,e)},value:n,onChange:V,onBlur:H,onFocus:te,onKeyDown:ie,onScroll:ne,onSelect:U,"aria-activedescendant":z&&y[S]?`${N}-option-${S}`:void 0,"aria-controls":z?N:void 0,"aria-expanded":z,className:f}),z?(0,q.jsxs)(`div`,{id:N,role:`listbox`,"aria-busy":D,"data-testid":`file-mention-suggestions`,"data-suggestion-anchor":W?`caret`:`edge`,"data-suggestion-placement":W?j.placement:u,className:J(`absolute inset-x-0 z-20 overflow-hidden rounded-xl border border-border bg-popover shadow-2xl shadow-black/30`,!W&&(u===`above`?`bottom-full mb-2`:`top-full mt-2`)),style:re,children:[R?(0,q.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 rounded-full border border-border/80 bg-popover/95 px-2 py-0.5 text-[11px] font-medium text-muted-foreground shadow-sm`,children:`Updating...`}):null,(0,q.jsx)(`div`,{className:`max-h-72 overflow-y-auto p-1`,children:D&&!I?(0,q.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`Loading file suggestions...`}):I?y.map((e,t)=>{let n=t===S,r=e.directory?`${e.directory}/`:``;return(0,q.jsx)(`button`,{id:`${N}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,disabled:!L,className:J(`flex w-full rounded-lg px-3 py-1.5 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`hover:bg-accent/60`,!L&&`cursor-wait opacity-80 disabled:pointer-events-none`),onMouseDown:e=>{e.preventDefault()},onMouseEnter:()=>{L&&C(t)},onClick:()=>{B(e)},children:(0,q.jsxs)(`span`,{className:`min-w-0 truncate text-sm`,children:[r?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:r}):null,(0,q.jsx)(`span`,{className:`font-medium`,children:e.name})]})},e.path)}):(0,q.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`No matching files found.`})})]}):null]})});cx.displayName=`ProjectFileMentionTextarea`;var lx=({className:e})=>(0,q.jsx)(qm,{"aria-hidden":`true`,className:e}),ux=({projectId:e,suggestionTicketId:t=null,value:n,placeholder:r,disabled:i,isSubmitDisabled:a,isSending:o,disabledReason:s,onValueChange:c,onKeyDown:l,onSubmit:u,textareaRef:d,composerInlineControls:f,composerTheme:p=`default`,composerSize:m=`default`,shellClassName:h})=>{let g=p===`plan`?`rounded-l-none border-l-3 border-l-sky-300/25 focus-within:border-l-sky-300/55`:p===`build`?`rounded-l-none border-l-3 border-l-emerald-400/30 focus-within:border-l-emerald-400/65`:null,_=m===`compact-on-laptop`?`min-h-[4.5rem] sm:min-h-16 2xl:min-h-20`:`min-h-[4.5rem] sm:min-h-20`,v=m===`compact-on-laptop`?`px-4 py-2 2xl:py-2.5`:`px-4 py-2.5`,y=m===`compact-on-laptop`?`absolute top-1/2 right-2.5 h-8 w-9 -translate-y-1/2 rounded-lg border-border/80 bg-secondary/80 px-0 text-foreground shadow-sm hover:bg-secondary 2xl:right-3 2xl:h-9 2xl:w-10`:`absolute top-1/2 right-3 h-9 w-10 -translate-y-1/2 rounded-lg border-border/80 bg-secondary/80 px-0 text-foreground shadow-sm hover:bg-secondary`,b=!!f;return(0,q.jsxs)(`div`,{"data-testid":`conversation-composer-shell`,className:J(`relative overflow-visible rounded-[1.35rem] border border-border/80 bg-card/65 transition-[border-color,box-shadow,background-color] shadow-[0_10px_30px_rgba(0,0,0,0.16)]`,`focus-within:border-ring/60 focus-within:bg-card/85 focus-within:ring-2 focus-within:ring-ring/15`,g,h),children:[(0,q.jsxs)(`div`,{className:J(`relative`,_,v),children:[(0,q.jsx)(cx,{ref:d,projectId:e,suggestionTicketId:t,value:n,onValueChange:c,onKeyDown:l,suggestionPlacement:`above`,wrapperClassName:`pr-12`,placeholder:r,disabled:i,"aria-label":`Follow-up prompt`,className:J(_,`border-0 bg-transparent px-0 py-0 text-[15px] leading-6 shadow-none focus-visible:border-transparent focus-visible:ring-0`)}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`secondary`,"aria-label":o?`Sending prompt`:`Send prompt`,disabled:!n.trim()||o||a,title:s,className:J(y,b&&`top-[calc(50%+0.5rem)]`),onClick:u,children:o?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(lx,{className:`h-4 w-4`})})]}),f?(0,q.jsx)(`div`,{className:`px-3 pb-2.5`,children:f}):null]})},dx=({className:e})=>(0,q.jsx)(ch,{"aria-hidden":`true`,className:e}),fx=({className:e})=>(0,q.jsx)(eh,{"aria-hidden":`true`,className:e}),px=({className:e})=>(0,q.jsx)(Qm,{"aria-hidden":`true`,className:e}),mx=new Map,hx=({projectId:e,reviewCapabilityContextKey:t})=>t?`${e}:${t}`:null,gx=e=>e.map(e=>({...e})),_x=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return r&&e.id===r.id&&e.comment===r.comment}),vx=e=>e?gx(mx.get(e)??[]):[],yx=({contextKey:e,drafts:t})=>{if(e){if(t.length===0){mx.delete(e);return}mx.set(e,gx(t))}},bx=12,xx=20,Sx=e=>{let t=Number.parseFloat(e);return Number.isNaN(t)?0:t},Cx=e=>{let t=window.getComputedStyle(e),n=(Sx(t.lineHeight)||xx)*bx+Sx(t.paddingTop)+Sx(t.paddingBottom)+Sx(t.borderTopWidth)+Sx(t.borderBottomWidth);e.style.height=`auto`;let r=Math.min(e.scrollHeight,n);e.style.height=`${r}px`,e.style.overflowY=e.scrollHeight>n?`auto`:`hidden`};function wx(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 Tx(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wx(Object(n),!0).forEach((function(t){Ex(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wx(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ex(e,t,n){return(t=function(e){var t=function(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)}(e,`string`);return typeof t==`symbol`?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dx(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ox(e,t){return jx(e)||function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||Nx(e,t)||Fx()}function kx(e){return jx(e)||Mx(e)||Nx(e)||Fx()}function Ax(e){return function(e){if(Array.isArray(e))return Px(e)}(e)||Mx(e)||Nx(e)||function(){throw TypeError(`Invalid attempt to spread non-iterable instance.
65
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function jx(e){if(Array.isArray(e))return e}function Mx(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Nx(e,t){if(e){if(typeof e==`string`)return Px(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Px(e,t):void 0}}function Px(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Fx(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
66
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ix(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Nx(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
67
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}var Lx=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function Rx(e,t){return e(t={exports:{}},t.exports),t.exports}var zx=Rx((function(e){(function(){var t={}.hasOwnProperty;function n(){for(var e=[],r=0;r<arguments.length;r++){var i=arguments[r];if(i){var a=typeof i;if(a===`string`||a===`number`)e.push(i);else if(Array.isArray(i)){if(i.length){var o=n.apply(null,i);o&&e.push(o)}}else if(a===`object`){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes(`[native code]`)){e.push(i.toString());continue}for(var s in i)t.call(i,s)&&i[s]&&e.push(s)}}}return e.join(` `)}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})),Bx={hunkClassName:``,lineClassName:``,gutterClassName:``,codeClassName:``,monotonous:!1,gutterType:`default`,viewType:`split`,widgets:{},hideGutter:!1,selectedChanges:[],generateAnchorID:function(){},generateLineClassName:function(){},renderGutter:function(e){var t=e.renderDefault;return(0,e.wrapInAnchor)(t())},codeEvents:{},gutterEvents:{}},Vx=(0,b.createContext)(Bx),Hx=Vx.Provider,Ux=function(){return(0,b.useContext)(Vx)},Wx=Rx((function(e,t){(function(t){function n(e){var t=e.slice(11),n=null,r=null;switch(t.indexOf(`"`)){case-1:n=(o=t.split(` `))[0].slice(2),r=o[1].slice(2);break;case 0:var i=t.indexOf(`"`,2);n=t.slice(3,i);var a=t.indexOf(`"`,i+1);r=a<0?t.slice(i+4):t.slice(a+3,-1);break;default:var o;n=(o=t.split(` `))[0].slice(2),r=o[1].slice(3,-1)}return{oldPath:n,newPath:r}}e.exports={parse:function(e){for(var t,r,i,a,o,s=[],c=2,l=e.split(`
68
+ `),u=l.length,d=0;d<u;){var f=l[d];if(f.indexOf(`diff --git`)===0){t={hunks:[],oldEndingNewLine:!0,newEndingNewLine:!0,oldPath:(o=n(f)).oldPath,newPath:o.newPath},s.push(t);var p,m=null;simiLoop:for(;p=l[++d];){var h=p.indexOf(` `),g=h>-1?p.slice(0,h):g;switch(g){case`diff`:d--;break simiLoop;case`deleted`:case`new`:var _=p.slice(h+1);_.indexOf(`file mode`)===0&&(t[g===`new`?`newMode`:`oldMode`]=_.slice(10));break;case`similarity`:t.similarity=parseInt(p.split(` `)[2],10);break;case`index`:var v=p.slice(h+1).split(` `),y=v[0].split(`..`);t.oldRevision=y[0],t.newRevision=y[1],v[1]&&(t.oldMode=t.newMode=v[1]);break;case`copy`:case`rename`:var b=p.slice(h+1);b.indexOf(`from`)===0?t.oldPath=b.slice(5):t.newPath=b.slice(3),m=g;break;case`---`:var x=p.slice(h+1),S=l[++d].slice(4);x===`/dev/null`?(S=S.slice(2),m=`add`):S===`/dev/null`?(x=x.slice(2),m=`delete`):(m=`modify`,x=x.slice(2),S=S.slice(2)),x&&(t.oldPath=x),S&&(t.newPath=S),c=5;break simiLoop}}t.type=m||`modify`}else if(f.indexOf(`Binary`)===0)t.isBinary=!0,t.type=f.indexOf(`/dev/null and`)>=0?`add`:f.indexOf(`and /dev/null`)>=0?`delete`:`modify`,c=2,t=null;else if(c===5)if(f.indexOf(`@@`)===0){var C=/^@@\s+-([0-9]+)(,([0-9]+))?\s+\+([0-9]+)(,([0-9]+))?/.exec(f);r={content:f,oldStart:C[1]-0,newStart:C[4]-0,oldLines:C[3]-0||1,newLines:C[6]-0||1,changes:[]},t.hunks.push(r),i=r.oldStart,a=r.newStart}else{var w=f.slice(0,1),T={content:f.slice(1)};switch(w){case`+`:T.type=`insert`,T.isInsert=!0,T.lineNumber=a,a++;break;case`-`:T.type=`delete`,T.isDelete=!0,T.lineNumber=i,i++;break;case` `:T.type=`normal`,T.isNormal=!0,T.oldLineNumber=i,T.newLineNumber=a,i++,a++;break;case`\\`:var E=r.changes[r.changes.length-1];E.isDelete||(t.newEndingNewLine=!1),E.isInsert||(t.oldEndingNewLine=!1)}T.type&&r.changes.push(T)}d++}return s}}})()}));function Gx(e){return e.type===`insert`}function Kx(e){return e.type===`delete`}function qx(e){return e.type===`normal`}function Jx(e,t){var n=t.nearbySequences===`zip`?function(e){return Ox(e.reduce((function(e,t,n){var r=Ox(e,3),i=r[0],a=r[1],o=r[2];return a?Gx(t)&&o>=0?(i.splice(o+1,0,t),[i,t,o+2]):(i.push(t),[i,t,Kx(t)&&Kx(a)?o:n]):(i.push(t),[i,t,Kx(t)?n:-1])}),[[],null,-1]),1)[0]}(e.changes):e.changes;return Tx(Tx({},e),{},{isPlain:!1,changes:n})}function Yx(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=function(e){if(e.startsWith(`diff --git`))return e;var t=e.indexOf(`
69
69
  `),n=e.indexOf(`
70
70
  `,t+1),r=e.slice(0,t),i=e.slice(t+1,n),a=r.split(` `).slice(1,-3).join(` `),o=i.split(` `).slice(1,-3).join(` `);return[`diff --git a/${a} b/${o}`,`index 1111111..2222222 100644`,`--- a/${a}`,`+++ b/${o}`,e.slice(n+1)].join(`
71
- `)}(e.trimStart());return Dx.parse(n).map((function(e){return function(e,t){var n=e.hunks.map((function(e){return jx(e,t)}));return cx(cx({},e),{},{hunks:n})}(e,t)}))}function Nx(e){return e[0]}function Px(e){return e[e.length-1]}function Fx(e){return[`${e}Start`,`${e}Lines`]}function Ix(e){return e===`old`?function(e){return Ox(e)?-1:Ax(e)?e.oldLineNumber:e.lineNumber}:function(e){return kx(e)?-1:Ax(e)?e.newLineNumber:e.lineNumber}}function Lx(e,t){return function(n,r){var i=n[e],a=i+n[t];return r>=i&&r<a}}function Rx(e,t){return function(n,r,i){var a=n[e]+n[t],o=r[e];return i>=a&&i<o}}function zx(e){var t=Ix(e),n=function(e){var t=dx(Fx(e),2),n=Lx(t[0],t[1]);return function(e,t){return e.find((function(e){return n(e,t)}))}}(e);return function(e,r){var i=n(e,r);if(i)return i.changes.find((function(e){return t(e)===r}))}}function Bx(e){var t=e===`old`?`new`:`old`,n=dx(Fx(e),2),r=n[0],i=n[1],a=dx(Fx(t),2),o=a[0],s=a[1],c=Ix(e),l=Ix(t),u=Lx(r,i),d=Rx(r,i);return function(e,t){var n=Nx(e);if(t<n[r]){var a=n[r]-t;return n[o]-a}var f=Px(e);if(f[r]+f[i]<=t){var p=t-f[r]-f[i];return f[o]+f[s]+p}for(var m=0;m<e.length;m++){var h=e[m],g=e[m+1];if(u(h,t)){var _=h.changes.findIndex((function(e){return c(e)===t})),v=h.changes[_];if(Ax(v))return l(v);var y=kx(v)?_+1:_-1,b=h.changes[y];if(!b)return-1;var x=Ox(v)?`delete`:`insert`;return b.type===x?l(b):-1}if(d(h,g,t)){var S=t-h[r]-h[i];return h[o]+h[s]+S}}throw Error(`Unexpected line position ${t}`)}}var Vx=function(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1},Hx=function(){this.__data__=[],this.size=0},Ux=function(e,t){return e===t||e!=e&&t!=t},Wx=function(e,t){for(var n=e.length;n--;)if(Ux(e[n][0],t))return n;return-1},Gx=Array.prototype.splice,Kx=function(e){var t=this.__data__,n=Wx(t,e);return!(n<0)&&(n==t.length-1?t.pop():Gx.call(t,n,1),--this.size,!0)},qx=function(e){var t=this.__data__,n=Wx(t,e);return n<0?void 0:t[n][1]},Jx=function(e){return Wx(this.__data__,e)>-1},Yx=function(e,t){var n=this.__data__,r=Wx(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function Xx(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Xx.prototype.clear=Hx,Xx.prototype.delete=Kx,Xx.prototype.get=qx,Xx.prototype.has=Jx,Xx.prototype.set=Yx;var Zx=Xx,Qx=function(){this.__data__=new Zx,this.size=0},$x=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},eS=function(e){return this.__data__.get(e)},tS=function(e){return this.__data__.has(e)},nS=typeof bx==`object`&&bx&&bx.Object===Object&&bx,rS=typeof self==`object`&&self&&self.Object===Object&&self,iS=nS||rS||Function(`return this`)(),aS=iS.Symbol,oS=Object.prototype,sS=oS.hasOwnProperty,cS=oS.toString,lS=aS?aS.toStringTag:void 0,uS=function(e){var t=sS.call(e,lS),n=e[lS];try{e[lS]=void 0;var r=!0}catch{}var i=cS.call(e);return r&&(t?e[lS]=n:delete e[lS]),i},dS=Object.prototype.toString,fS=function(e){return dS.call(e)},pS=aS?aS.toStringTag:void 0,mS=function(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:pS&&pS in Object(e)?uS(e):fS(e)},hS=function(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)},gS=function(e){if(!hS(e))return!1;var t=mS(e);return t==`[object Function]`||t==`[object GeneratorFunction]`||t==`[object AsyncFunction]`||t==`[object Proxy]`},_S=iS[`__core-js_shared__`],vS=function(){var e=/[^.]+$/.exec(_S&&_S.keys&&_S.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),yS=function(e){return!!vS&&vS in e},bS=Function.prototype.toString,xS=function(e){if(e!=null){try{return bS.call(e)}catch{}try{return e+``}catch{}}return``},SS=/^\[object .+?Constructor\]$/,CS=Function.prototype,wS=Object.prototype,TS=CS.toString,ES=wS.hasOwnProperty,DS=RegExp(`^`+TS.call(ES).replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),OS=function(e){return!(!hS(e)||yS(e))&&(gS(e)?DS:SS).test(xS(e))},kS=function(e,t){return e?.[t]},AS=function(e,t){var n=kS(e,t);return OS(n)?n:void 0},jS=AS(iS,`Map`),MS=AS(Object,`create`),NS=function(){this.__data__=MS?MS(null):{},this.size=0},PS=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t},FS=Object.prototype.hasOwnProperty,IS=function(e){var t=this.__data__;if(MS){var n=t[e];return n===`__lodash_hash_undefined__`?void 0:n}return FS.call(t,e)?t[e]:void 0},LS=Object.prototype.hasOwnProperty,RS=function(e){var t=this.__data__;return MS?t[e]!==void 0:LS.call(t,e)},zS=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=MS&&t===void 0?`__lodash_hash_undefined__`:t,this};function BS(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}BS.prototype.clear=NS,BS.prototype.delete=PS,BS.prototype.get=IS,BS.prototype.has=RS,BS.prototype.set=zS;var VS=BS,HS=function(){this.size=0,this.__data__={hash:new VS,map:new(jS||Zx),string:new VS}},US=function(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null},WS=function(e,t){var n=e.__data__;return US(t)?n[typeof t==`string`?`string`:`hash`]:n.map},GS=function(e){var t=WS(this,e).delete(e);return this.size-=+!!t,t},KS=function(e){return WS(this,e).get(e)},qS=function(e){return WS(this,e).has(e)},JS=function(e,t){var n=WS(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function YS(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}YS.prototype.clear=HS,YS.prototype.delete=GS,YS.prototype.get=KS,YS.prototype.has=qS,YS.prototype.set=JS;var XS=YS,ZS=function(e,t){var n=this.__data__;if(n instanceof Zx){var r=n.__data__;if(!jS||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new XS(r)}return n.set(e,t),this.size=n.size,this};function QS(e){var t=this.__data__=new Zx(e);this.size=t.size}QS.prototype.clear=Qx,QS.prototype.delete=$x,QS.prototype.get=eS,QS.prototype.has=tS,QS.prototype.set=ZS;var $S=QS,eC=function(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this},tC=function(e){return this.__data__.has(e)};function nC(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new XS;++t<n;)this.add(e[t])}nC.prototype.add=nC.prototype.push=eC,nC.prototype.has=tC;var rC=nC,iC=function(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1},aC=function(e,t){return e.has(t)},oC=function(e,t,n,r,i,a){var o=1&n,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=2&n?new rC:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!iC(t,(function(e,t){if(!aC(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)}))){f=!1;break}}else if(m!==h&&!i(m,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f},sC=iS.Uint8Array,cC=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n},lC=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n},uC=aS?aS.prototype:void 0,dC=uC?uC.valueOf:void 0,fC=function(e,t,n,r,i,a,o){switch(n){case`[object DataView]`:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case`[object ArrayBuffer]`:return!(e.byteLength!=t.byteLength||!a(new sC(e),new sC(t)));case`[object Boolean]`:case`[object Date]`:case`[object Number]`:return Ux(+e,+t);case`[object Error]`:return e.name==t.name&&e.message==t.message;case`[object RegExp]`:case`[object String]`:return e==t+``;case`[object Map]`:var s=cC;case`[object Set]`:var c=1&r;if(s||=lC,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=2,o.set(e,t);var u=oC(s(e),s(t),r,i,a,o);return o.delete(e),u;case`[object Symbol]`:if(dC)return dC.call(e)==dC.call(t)}return!1},pC=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e},mC=Array.isArray,hC=function(e,t,n){var r=t(e);return mC(e)?r:pC(r,n(e))},gC=function(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a},_C=function(){return[]},vC=Object.prototype.propertyIsEnumerable,yC=Object.getOwnPropertySymbols,bC=yC?function(e){return e==null?[]:(e=Object(e),gC(yC(e),(function(t){return vC.call(e,t)})))}:_C,xC=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},SC=function(e){return typeof e==`object`&&!!e},CC=function(e){return SC(e)&&mS(e)==`[object Arguments]`},wC=Object.prototype,TC=wC.hasOwnProperty,EC=wC.propertyIsEnumerable,DC=CC(function(){return arguments}())?CC:function(e){return SC(e)&&TC.call(e,`callee`)&&!EC.call(e,`callee`)},OC=function(){return!1},kC=xx((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?iS.Buffer:void 0;e.exports=(i?i.isBuffer:void 0)||OC})),AC=/^(?:0|[1-9]\d*)$/,jC=function(e,t){var n=typeof e;return!!(t??=9007199254740991)&&(n==`number`||n!=`symbol`&&AC.test(e))&&e>-1&&e%1==0&&e<t},MC=function(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991},NC={};NC[`[object Float32Array]`]=NC[`[object Float64Array]`]=NC[`[object Int8Array]`]=NC[`[object Int16Array]`]=NC[`[object Int32Array]`]=NC[`[object Uint8Array]`]=NC[`[object Uint8ClampedArray]`]=NC[`[object Uint16Array]`]=NC[`[object Uint32Array]`]=!0,NC[`[object Arguments]`]=NC[`[object Array]`]=NC[`[object ArrayBuffer]`]=NC[`[object Boolean]`]=NC[`[object DataView]`]=NC[`[object Date]`]=NC[`[object Error]`]=NC[`[object Function]`]=NC[`[object Map]`]=NC[`[object Number]`]=NC[`[object Object]`]=NC[`[object RegExp]`]=NC[`[object Set]`]=NC[`[object String]`]=NC[`[object WeakMap]`]=!1;var PC=function(e){return SC(e)&&MC(e.length)&&!!NC[mS(e)]},FC=function(e){return function(t){return e(t)}},IC=xx((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&nS.process;e.exports=function(){try{return r&&r.require&&r.require(`util`).types||i&&i.binding&&i.binding(`util`)}catch{}}()})),LC=IC&&IC.isTypedArray,RC=LC?FC(LC):PC,zC=Object.prototype.hasOwnProperty,BC=function(e,t){var n=mC(e),r=!n&&DC(e),i=!n&&!r&&kC(e),a=!n&&!r&&!i&&RC(e),o=n||r||i||a,s=o?xC(e.length,String):[],c=s.length;for(var l in e)!t&&!zC.call(e,l)||o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||jC(l,c))||s.push(l);return s},VC=Object.prototype,HC=function(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||VC)},UC=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),WC=Object.prototype.hasOwnProperty,GC=function(e){if(!HC(e))return UC(e);var t=[];for(var n in Object(e))WC.call(e,n)&&n!=`constructor`&&t.push(n);return t},KC=function(e){return e!=null&&MC(e.length)&&!gS(e)},qC=function(e){return KC(e)?BC(e):GC(e)},JC=function(e){return hC(e,qC,bC)},YC=Object.prototype.hasOwnProperty,XC=function(e,t,n,r,i,a){var o=1&n,s=JC(e),c=s.length;if(c!=JC(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:YC.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){var h=e[u=s[l]],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v==y||!(`constructor`in e)||!(`constructor`in t)||typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y||(p=!1)}return a.delete(e),a.delete(t),p},ZC=AS(iS,`DataView`),QC=AS(iS,`Promise`),$C=AS(iS,`Set`),ew=AS(iS,`WeakMap`),tw=xS(ZC),nw=xS(jS),rw=xS(QC),iw=xS($C),aw=xS(ew),ow=mS;(ZC&&ow(new ZC(new ArrayBuffer(1)))!=`[object DataView]`||jS&&ow(new jS)!=`[object Map]`||QC&&ow(QC.resolve())!=`[object Promise]`||$C&&ow(new $C)!=`[object Set]`||ew&&ow(new ew)!=`[object WeakMap]`)&&(ow=function(e){var t=mS(e),n=t==`[object Object]`?e.constructor:void 0,r=n?xS(n):``;if(r)switch(r){case tw:return`[object DataView]`;case nw:return`[object Map]`;case rw:return`[object Promise]`;case iw:return`[object Set]`;case aw:return`[object WeakMap]`}return t});var sw=ow,cw=`[object Object]`,lw=Object.prototype.hasOwnProperty,uw=function(e,t,n,r,i,a){var o=mC(e),s=mC(t),c=o?`[object Array]`:sw(e),l=s?`[object Array]`:sw(t),u=(c=c==`[object Arguments]`?cw:c)==cw,d=(l=l==`[object Arguments]`?cw:l)==cw,f=c==l;if(f&&kC(e)){if(!kC(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new $S,o||RC(e)?oC(e,t,n,r,i,a):fC(e,t,c,n,r,i,a);if(!(1&n)){var p=u&&lw.call(e,`__wrapped__`),m=d&&lw.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new $S,i(h,g,n,r,a)}}return!!f&&(a||=new $S,XC(e,t,n,r,i,a))},dw=function e(t,n,r,i,a){return t===n||(t==null||n==null||!SC(t)&&!SC(n)?t!=t&&n!=n:uw(t,n,r,i,e,a))},fw=function(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){var c=(s=n[i])[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new $S;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?dw(u,l,3,r,d):f))return!1}}return!0},pw=function(e){return e==e&&!hS(e)},mw=function(e){for(var t=qC(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,pw(i)]}return t},hw=function(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}},gw=function(e){var t=mw(e);return t.length==1&&t[0][2]?hw(t[0][0],t[0][1]):function(n){return n===e||fw(n,e,t)}},_w=function(e){return typeof e==`symbol`||SC(e)&&mS(e)==`[object Symbol]`},vw=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yw=/^\w*$/,bw=function(e,t){if(mC(e))return!1;var n=typeof e;return!(n!=`number`&&n!=`symbol`&&n!=`boolean`&&e!=null&&!_w(e))||yw.test(e)||!vw.test(e)||t!=null&&e in Object(t)};function xw(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(`Expected a function`);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(xw.Cache||XS),n}xw.Cache=XS;var Sw=xw,Cw=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ww=/\\(\\)?/g,Tw=function(e){var t=Sw(e,(function(e){return n.size===500&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Cw,(function(e,n,r,i){t.push(r?i.replace(ww,`$1`):n||e)})),t})),Ew=function(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},Dw=aS?aS.prototype:void 0,Ow=Dw?Dw.toString:void 0,kw=function e(t){if(typeof t==`string`)return t;if(mC(t))return Ew(t,e)+``;if(_w(t))return Ow?Ow.call(t):``;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n},Aw=function(e){return e==null?``:kw(e)},jw=function(e,t){return mC(e)?e:bw(e,t)?[e]:Tw(Aw(e))},Mw=function(e){if(typeof e==`string`||_w(e))return e;var t=e+``;return t==`0`&&1/e==-1/0?`-0`:t},Nw=function(e,t){for(var n=0,r=(t=jw(t,e)).length;e!=null&&n<r;)e=e[Mw(t[n++])];return n&&n==r?e:void 0},Pw=function(e,t,n){var r=e==null?void 0:Nw(e,t);return r===void 0?n:r},Fw=function(e,t){return e!=null&&t in Object(e)},Iw=function(e,t,n){for(var r=-1,i=(t=jw(t,e)).length,a=!1;++r<i;){var o=Mw(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:!!(i=e==null?0:e.length)&&MC(i)&&jC(o,i)&&(mC(e)||DC(e))},Lw=function(e,t){return e!=null&&Iw(e,t,Fw)},Rw=function(e,t){return bw(e)&&pw(t)?hw(Mw(e),t):function(n){var r=Pw(n,e);return r===void 0&&r===t?Lw(n,e):dw(t,r,3)}},zw=function(e){return e},Bw=function(e){return function(t){return t?.[e]}},Vw=function(e){return function(t){return Nw(t,e)}},Hw=function(e){return bw(e)?Bw(Mw(e)):Vw(e)},Uw=function(e){return typeof e==`function`?e:e==null?zw:typeof e==`object`?mC(e)?Rw(e[0],e[1]):gw(e):Hw(e)},Ww=/\s/,Gw=function(e){for(var t=e.length;t--&&Ww.test(e.charAt(t)););return t},Kw=/^\s+/,qw=function(e){return e&&e.slice(0,Gw(e)+1).replace(Kw,``)},Jw=/^[-+]0x[0-9a-f]+$/i,Yw=/^0b[01]+$/i,Xw=/^0o[0-7]+$/i,Zw=parseInt,Qw=function(e){if(typeof e==`number`)return e;if(_w(e))return NaN;if(hS(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=hS(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=qw(e);var n=Yw.test(e);return n||Xw.test(e)?Zw(e.slice(2),n?2:8):Jw.test(e)?NaN:+e},$w=function(e){return e?(e=Qw(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:e===0?e:0},eT=function(e){var t=$w(e),n=t%1;return t==t?n?t-n:t:0};function tT(e){if(!e)throw Error(`change is not provided`);return Ax(e)?`N${e.oldLineNumber}`:`${Ox(e)?`I`:`D`}${e.lineNumber}`}Bx(`old`);var nT=Ix(`old`),rT=Ix(`new`);zx(`old`),zx(`new`),Bx(`new`),Bx(`old`);var iT=function(){try{var e=AS(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),aT=function(e,t,n){t==`__proto__`&&iT?iT(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},oT=function(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(!1===n(a[c],c,a))break}return t}}(),sT=function(e,t){return e&&oT(e,t,qC)},cT=function(e,t){var n={};return t=Uw(t),sT(e,(function(e,r,i){aT(n,r,t(e,r,i))})),n},lT=[`changeKey`,`text`,`tokens`,`renderToken`],uT=function e(t,n){var r=t.type,i=t.value,a=t.markType,o=t.properties,s=t.className,c=t.children,l=function(t){return(0,q.jsx)(`span`,{className:t,children:i||c&&c.map(e)},n)};switch(r){case`text`:return i;case`mark`:return l(`diff-code-mark diff-code-mark-${a}`);case`edit`:return l(`diff-code-edit`);default:var u=o&&o.className;return l(Sx(s||u))}};function dT(e){if(!Array.isArray(e))return!0;if(e.length>1)return!1;if(e.length===1){var t=dx(e,1)[0];return t.type===`text`&&!t.value}return!0}function fT(e){var t=e.changeKey,n=e.text,r=e.tokens,i=e.renderToken,a=ux(e,lT),o=i?function(e,t){return i(e,uT,t)}:uT;return(0,q.jsx)(`td`,cx(cx({},a),{},{"data-change-key":t,children:r?dT(r)?` `:r.map(o):n||` `}))}var pT=(0,b.memo)(fT);function mT(e,t){return function(){var n=t===`old`?nT(e):rT(e);return n===-1?void 0:n}}function hT(e,t){return function(n){return e&&n?(0,q.jsx)(`a`,{href:t?`#`+t:void 0,children:n}):n}}function gT(e,t){return t?function(n){e(),t(n)}:e}function _T(e,t,n,r){return(0,b.useMemo)((function(){var i=cT(e,(function(e){return function(n){return e&&e(t,n)}}));return i.onMouseEnter=gT(n,i.onMouseEnter),i.onMouseLeave=gT(r,i.onMouseLeave),i}),[e,n,r,t])}function vT(e,t,n,r,i,a,o,s,c){var l={change:t,side:r,inHoverState:s,renderDefault:mT(t,r),wrapInAnchor:hT(i,a)};return(0,q.jsx)(`td`,cx(cx({className:e},o),{},{"data-change-key":n,children:c(l)}))}function yT(e){var t,n,r,i=e.change,a=e.selected,o=e.tokens,s=e.className,c=e.generateLineClassName,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.gutterAnchor,h=e.generateAnchorID,g=e.renderToken,_=e.renderGutter,v=i.type,y=i.content,x=tT(i),S=dx((t=dx((0,b.useState)(!1),2),n=t[0],r=t[1],[n,(0,b.useCallback)((function(){return r(!0)}),[]),(0,b.useCallback)((function(){return r(!1)}),[])]),3),C=S[0],w=S[1],T=S[2],E=(0,b.useMemo)((function(){return{change:i}}),[i]),D=_T(d,E,w,T),O=_T(f,E,w,T),k=h(i),A=c({changes:[i],defaultGenerate:function(){return s}}),j=Sx(`diff-gutter`,`diff-gutter-${v}`,l,{"diff-gutter-selected":a}),M=Sx(`diff-code`,`diff-code-${v}`,u,{"diff-code-selected":a});return(0,q.jsxs)(`tr`,{id:k,className:Sx(`diff-line`,A),children:[!p&&vT(j,i,x,`old`,m,k,D,C,_),!p&&vT(j,i,x,`new`,m,k,D,C,_),(0,q.jsx)(pT,cx({className:M,changeKey:x,text:y,tokens:o,renderToken:g},O))]})}var bT=(0,b.memo)(yT);function xT(e){var t=e.hideGutter,n=e.element;return(0,q.jsx)(`tr`,{className:`diff-widget`,children:(0,q.jsx)(`td`,{colSpan:t?1:3,className:`diff-widget-content`,children:n})})}var ST=[`hideGutter`,`selectedChanges`,`tokens`,`lineClassName`],CT=[`hunk`,`widgets`,`className`];function wT(e){var t=e.hunk,n=e.widgets,r=e.className,i=ux(e,CT),a=function(e,t){return e.reduce((function(e,n){var r=tT(n);e.push([`change`,r,n]);var i=t[r];return i&&e.push([`widget`,r,i]),e}),[])}(t.changes,n);return(0,q.jsx)(`tbody`,{className:Sx(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=dx(e,3),r=n[0],i=n[1],a=n[2],o=t.hideGutter,s=t.selectedChanges,c=t.tokens,l=t.lineClassName,u=ux(t,ST);if(r===`change`){var d=kx(a)?`old`:`new`,f=kx(a)?nT(a):rT(a),p=c?c[d][f-1]:null;return(0,q.jsx)(bT,cx({className:l,change:a,hideGutter:o,selected:s.includes(i),tokens:p},u),`change${i}`)}return r===`widget`?(0,q.jsx)(xT,{hideGutter:o,element:a},`widget${i}`):null}(e,i)}))})}var TT=0;function ET(e,t,n,r){var i=(0,b.useCallback)((function(){return t(e)}),[e,t]),a=(0,b.useCallback)((function(){return t(``)}),[t]);return(0,b.useMemo)((function(){var t=cT(r,(function(t){return function(r){return t&&t({side:e,change:n},r)}}));return t.onMouseEnter=gT(i,t.onMouseEnter),t.onMouseLeave=gT(a,t.onMouseLeave),t}),[n,r,i,e,a])}function DT(e){var t=e.change,n=e.side,r=e.selected,i=e.tokens,a=e.gutterClassName,o=e.codeClassName,s=e.gutterEvents,c=e.codeEvents,l=e.anchorID,u=e.gutterAnchor,d=e.gutterAnchorTarget,f=e.hideGutter,p=e.hover,m=e.renderToken,h=e.renderGutter;if(!t){var g=Sx(`diff-gutter`,`diff-gutter-omit`,a),_=Sx(`diff-code`,`diff-code-omit`,o);return[!f&&(0,q.jsx)(`td`,{className:g},`gutter`),(0,q.jsx)(`td`,{className:_},`code`)]}var v=t.type,y=t.content,b=tT(t),x=n===TT?`old`:`new`,S=cx({id:l||void 0,className:Sx(`diff-gutter`,`diff-gutter-${v}`,lx({"diff-gutter-selected":r},`diff-line-hover-`+x,p),a),children:h({change:t,side:x,inHoverState:p,renderDefault:mT(t,x),wrapInAnchor:hT(u,d)})},s),C=Sx(`diff-code`,`diff-code-${v}`,lx({"diff-code-selected":r},`diff-line-hover-`+x,p),o);return[!f&&(0,q.jsx)(`td`,cx(cx({},S),{},{"data-change-key":b}),`gutter`),(0,q.jsx)(pT,cx({className:C,changeKey:b,text:y,tokens:i,renderToken:m},c),`code`)]}function OT(e){var t=e.className,n=e.oldChange,r=e.newChange,i=e.oldSelected,a=e.newSelected,o=e.oldTokens,s=e.newTokens,c=e.monotonous,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.generateAnchorID,h=e.generateLineClassName,g=e.gutterAnchor,_=e.renderToken,v=e.renderGutter,y=dx((0,b.useState)(``),2),x=y[0],S=y[1],C=ET(`old`,S,n,d),w=ET(`new`,S,r,d),T=ET(`old`,S,n,f),E=ET(`new`,S,r,f),D=n&&m(n),O=r&&m(r),k=h({changes:[n,r],defaultGenerate:function(){return t}}),A={monotonous:c,hideGutter:p,gutterClassName:l,codeClassName:u,gutterEvents:d,codeEvents:f,renderToken:_,renderGutter:v},j=cx(cx({},A),{},{change:n,side:TT,selected:i,tokens:o,gutterEvents:C,codeEvents:T,anchorID:D,gutterAnchor:g,gutterAnchorTarget:D,hover:x===`old`}),M=cx(cx({},A),{},{change:r,side:1,selected:a,tokens:s,gutterEvents:w,codeEvents:E,anchorID:n===r?null:O,gutterAnchor:g,gutterAnchorTarget:n===r?D:O,hover:x===`new`});return c?(0,q.jsx)(`tr`,{className:Sx(`diff-line`,k),children:DT(n?j:M)}):(0,q.jsxs)(`tr`,{className:Sx(`diff-line`,function(e,t){return e&&!t?`diff-line-old-only`:!e&&t?`diff-line-new-only`:e===t?`diff-line-normal`:`diff-line-compare`}(n,r),k),children:[DT(j),DT(M)]})}var kT=(0,b.memo)(OT);function AT(e){var t=e.hideGutter,n=e.oldElement,r=e.newElement;return e.monotonous?(0,q.jsx)(`tr`,{className:`diff-widget`,children:(0,q.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n||r})}):n===r?(0,q.jsx)(`tr`,{className:`diff-widget`,children:(0,q.jsx)(`td`,{colSpan:t?2:4,className:`diff-widget-content`,children:n})}):(0,q.jsxs)(`tr`,{className:`diff-widget`,children:[(0,q.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n}),(0,q.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:r})]})}var jT=[`selectedChanges`,`monotonous`,`hideGutter`,`tokens`,`lineClassName`],MT=[`hunk`,`widgets`,`className`];function NT(e,t){return(e?tT(e):`00`)+(t?tT(t):`00`)}function PT(e){var t=e.hunk,n=e.widgets,r=e.className,i=ux(e,MT),a=function(e,t){for(var n=function(e){return e&&t[tT(e)]||null},r=[],i=0;i<e.length;i++){var a=e[i];if(Ax(a))r.push([`change`,NT(a,a),a,a]);else if(kx(a)){var o=e[i+1];o&&Ox(o)?(i+=1,r.push([`change`,NT(a,o),a,o])):r.push([`change`,NT(a,null),a,null])}else r.push([`change`,NT(null,a),null,a]);var s=r[r.length-1],c=n(s[2]),l=n(s[3]);if(c||l){var u=s[1];r.push([`widget`,u,c,l])}}return r}(t.changes,n);return(0,q.jsx)(`tbody`,{className:Sx(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=dx(e,4),r=n[0],i=n[1],a=n[2],o=n[3],s=t.selectedChanges,c=t.monotonous,l=t.hideGutter,u=t.tokens,d=t.lineClassName,f=ux(t,jT);return r===`change`?(0,q.jsx)(kT,cx({className:d,oldChange:a,newChange:o,monotonous:c,hideGutter:l,oldSelected:!!a&&s.includes(tT(a)),newSelected:!!o&&s.includes(tT(o)),oldTokens:a&&u?u.old[nT(a)-1]:null,newTokens:o&&u?u.new[rT(o)-1]:null},f),`change${i}`):r===`widget`?(0,q.jsx)(AT,{monotonous:c,hideGutter:l,oldElement:a,newElement:o},`widget${i}`):null}(e,i)}))})}var FT=[`gutterType`,`hunkClassName`];function IT(e){var t=e.hunk,n=Ex(),r=n.gutterType,i=n.hunkClassName,a=ux(n,FT),o=r===`none`,s=r===`anchor`;return(0,q.jsx)(a.viewType===`unified`?wT:PT,cx(cx({},a),{},{hunk:t,hideGutter:o,gutterAnchor:s,className:i}))}function LT(){}function RT(e,t){var n=t?`auto`:`none`;e instanceof HTMLElement&&e.style.userSelect!==n&&(e.style.userSelect=n)}function zT(e){return e.map((function(e){return(0,q.jsx)(IT,{hunk:e},function(e){return`-${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines}`}(e))}))}function BT(e){var t=e.diffType,n=e.hunks,r=e.optimizeSelection,i=e.className,a=e.hunkClassName,o=a===void 0?Cx.hunkClassName:a,s=e.lineClassName,c=s===void 0?Cx.lineClassName:s,l=e.generateLineClassName,u=l===void 0?Cx.generateLineClassName:l,d=e.gutterClassName,f=d===void 0?Cx.gutterClassName:d,p=e.codeClassName,m=p===void 0?Cx.codeClassName:p,h=e.gutterType,g=h===void 0?Cx.gutterType:h,_=e.viewType,v=_===void 0?Cx.viewType:_,y=e.gutterEvents,x=y===void 0?Cx.gutterEvents:y,S=e.codeEvents,C=S===void 0?Cx.codeEvents:S,w=e.generateAnchorID,T=w===void 0?Cx.generateAnchorID:w,E=e.selectedChanges,D=E===void 0?Cx.selectedChanges:E,O=e.widgets,k=O===void 0?Cx.widgets:O,A=e.renderGutter,j=A===void 0?Cx.renderGutter:A,M=e.tokens,N=e.renderToken,P=e.children,F=P===void 0?zT:P,I=(0,b.useRef)(null),L=(0,b.useCallback)((function(e){var t=e.target;if(e.button===0){var n=function(e,t){for(var n=e;n&&n!==document.documentElement&&!n.classList.contains(t);)n=n.parentElement;return n===document.documentElement?null:n}(t,`diff-code`);if(n&&n.parentElement){var r=window.getSelection();r&&r.removeAllRanges();var i=px(n.parentElement.children).indexOf(n);if(i===1||i===3){var a,o=yx(I.current?I.current.querySelectorAll(`.diff-line`):[]);try{for(o.s();!(a=o.n()).done;){var s=a.value.children;RT(s[1],i===1),RT(s[3],i===3)}}catch(e){o.e(e)}finally{o.f()}}}}}),[]),R=g===`none`,z=t===`add`||t===`delete`,ee=v===`split`&&!z&&r?L:LT,B=(0,b.useMemo)((function(){return(0,q.jsxs)(`colgroup`,v===`unified`?{children:[!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{})]}:z?{children:[!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{})]}:{children:[!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{}),!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{})]})}),[v,z,R]);return(0,q.jsx)(Tx,{value:(0,b.useMemo)((function(){return{hunkClassName:o,lineClassName:c,generateLineClassName:u,gutterClassName:f,codeClassName:m,monotonous:z,hideGutter:R,viewType:v,gutterType:g,codeEvents:C,gutterEvents:x,generateAnchorID:T,selectedChanges:D,widgets:k,renderGutter:j,tokens:M,renderToken:N}}),[m,C,T,f,x,g,R,o,c,u,z,j,N,D,M,v,k]),children:(0,q.jsxs)(`table`,{ref:I,className:Sx(`diff`,`diff-${v}`,i),onMouseDown:ee,children:[B,F(n)]})})}var VT=(0,b.memo)(BT),HT=function(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r},UT=function(e,t){return function(n,r){if(n==null)return n;if(!KC(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&!1!==r(o[a],a,o););return n}}(sT),WT=function(e,t,n,r){return UT(e,(function(e,i,a){t(r,e,n(e),a)})),r},GT=function(e,t){return function(n,r){var i=mC(n)?HT:WT,a=t?t():{};return i(n,e,Uw(r),a)}},KT=GT((function(e,t,n){aT(e,n,t)})),qT=aS?aS.isConcatSpreadable:void 0,JT=function(e){return mC(e)||DC(e)||!!(qT&&e&&e[qT])},YT=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||=JT,a||=[];++o<s;){var c=t[o];n>0&&r(c)?n>1?e(c,n-1,r,i,a):pC(a,c):i||(a[a.length]=c)}return a},XT=function(e,t){var n=-1,r=KC(e)?Array(e.length):[];return UT(e,(function(e,i,a){r[++n]=t(e,i,a)})),r},ZT=function(e,t){return(mC(e)?Ew:XT)(e,Uw(t))},QT=function(e,t){return YT(ZT(e,t),1)};function $T(e,t){var n=t.newStart;return dx(t.changes.reduce((function(e,t){var n=dx(e,2),r=n[0],i=n[1];return kx(t)?(r.splice(i,1),[r,i]):(Ox(t)&&r.splice(i,0,t.content),[r,i+1])}),[e,n-1]),1)[0]}function eE(e,t,n){if(!e.length)return[];var r=t===`old`?nT:rT,i=KT(e,r),a=r(e[e.length-1]);return Array.from({length:a}).map((function(e,t){return n(i[t+1])}))}function tE(e){var t=dx(function(e){return QT(e,(function(e){return e.changes})).reduce((function(e,t){var n=dx(e,2),r=n[0],i=n[1];return Ax(t)?(r.push(t),i.push(t)):kx(t)?r.push(t):i.push(t),[r,i]}),[[],[]])}(e),2),n=t[0],r=t[1],i=function(e){return e?e.content:``};return[eE(n,`old`,i).join(`
72
- `),eE(r,`new`,i).join(`
73
- `)]}function nE(e){return{type:`root`,children:e}}function rE(e,t){if(t.oldSource){var n=function(e,t){return t.reduce($T,e.split(`
71
+ `)}(e.trimStart());return Wx.parse(n).map((function(e){return function(e,t){var n=e.hunks.map((function(e){return Jx(e,t)}));return Tx(Tx({},e),{},{hunks:n})}(e,t)}))}function Xx(e){return e[0]}function Zx(e){return e[e.length-1]}function Qx(e){return[`${e}Start`,`${e}Lines`]}function $x(e){return e===`old`?function(e){return Gx(e)?-1:qx(e)?e.oldLineNumber:e.lineNumber}:function(e){return Kx(e)?-1:qx(e)?e.newLineNumber:e.lineNumber}}function eS(e,t){return function(n,r){var i=n[e],a=i+n[t];return r>=i&&r<a}}function tS(e,t){return function(n,r,i){var a=n[e]+n[t],o=r[e];return i>=a&&i<o}}function nS(e){var t=$x(e),n=function(e){var t=Ox(Qx(e),2),n=eS(t[0],t[1]);return function(e,t){return e.find((function(e){return n(e,t)}))}}(e);return function(e,r){var i=n(e,r);if(i)return i.changes.find((function(e){return t(e)===r}))}}function rS(e){var t=e===`old`?`new`:`old`,n=Ox(Qx(e),2),r=n[0],i=n[1],a=Ox(Qx(t),2),o=a[0],s=a[1],c=$x(e),l=$x(t),u=eS(r,i),d=tS(r,i);return function(e,t){var n=Xx(e);if(t<n[r]){var a=n[r]-t;return n[o]-a}var f=Zx(e);if(f[r]+f[i]<=t){var p=t-f[r]-f[i];return f[o]+f[s]+p}for(var m=0;m<e.length;m++){var h=e[m],g=e[m+1];if(u(h,t)){var _=h.changes.findIndex((function(e){return c(e)===t})),v=h.changes[_];if(qx(v))return l(v);var y=Kx(v)?_+1:_-1,b=h.changes[y];if(!b)return-1;var x=Gx(v)?`delete`:`insert`;return b.type===x?l(b):-1}if(d(h,g,t)){var S=t-h[r]-h[i];return h[o]+h[s]+S}}throw Error(`Unexpected line position ${t}`)}}var iS=function(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1},aS=function(){this.__data__=[],this.size=0},oS=function(e,t){return e===t||e!=e&&t!=t},sS=function(e,t){for(var n=e.length;n--;)if(oS(e[n][0],t))return n;return-1},cS=Array.prototype.splice,lS=function(e){var t=this.__data__,n=sS(t,e);return!(n<0)&&(n==t.length-1?t.pop():cS.call(t,n,1),--this.size,!0)},uS=function(e){var t=this.__data__,n=sS(t,e);return n<0?void 0:t[n][1]},dS=function(e){return sS(this.__data__,e)>-1},fS=function(e,t){var n=this.__data__,r=sS(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function pS(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}pS.prototype.clear=aS,pS.prototype.delete=lS,pS.prototype.get=uS,pS.prototype.has=dS,pS.prototype.set=fS;var mS=pS,hS=function(){this.__data__=new mS,this.size=0},gS=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},_S=function(e){return this.__data__.get(e)},vS=function(e){return this.__data__.has(e)},yS=typeof Lx==`object`&&Lx&&Lx.Object===Object&&Lx,bS=typeof self==`object`&&self&&self.Object===Object&&self,xS=yS||bS||Function(`return this`)(),SS=xS.Symbol,CS=Object.prototype,wS=CS.hasOwnProperty,TS=CS.toString,ES=SS?SS.toStringTag:void 0,DS=function(e){var t=wS.call(e,ES),n=e[ES];try{e[ES]=void 0;var r=!0}catch{}var i=TS.call(e);return r&&(t?e[ES]=n:delete e[ES]),i},OS=Object.prototype.toString,kS=function(e){return OS.call(e)},AS=SS?SS.toStringTag:void 0,jS=function(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:AS&&AS in Object(e)?DS(e):kS(e)},MS=function(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)},NS=function(e){if(!MS(e))return!1;var t=jS(e);return t==`[object Function]`||t==`[object GeneratorFunction]`||t==`[object AsyncFunction]`||t==`[object Proxy]`},PS=xS[`__core-js_shared__`],FS=function(){var e=/[^.]+$/.exec(PS&&PS.keys&&PS.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),IS=function(e){return!!FS&&FS in e},LS=Function.prototype.toString,RS=function(e){if(e!=null){try{return LS.call(e)}catch{}try{return e+``}catch{}}return``},zS=/^\[object .+?Constructor\]$/,BS=Function.prototype,VS=Object.prototype,HS=BS.toString,US=VS.hasOwnProperty,WS=RegExp(`^`+HS.call(US).replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),GS=function(e){return!(!MS(e)||IS(e))&&(NS(e)?WS:zS).test(RS(e))},KS=function(e,t){return e?.[t]},qS=function(e,t){var n=KS(e,t);return GS(n)?n:void 0},JS=qS(xS,`Map`),YS=qS(Object,`create`),XS=function(){this.__data__=YS?YS(null):{},this.size=0},ZS=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t},QS=Object.prototype.hasOwnProperty,$S=function(e){var t=this.__data__;if(YS){var n=t[e];return n===`__lodash_hash_undefined__`?void 0:n}return QS.call(t,e)?t[e]:void 0},eC=Object.prototype.hasOwnProperty,tC=function(e){var t=this.__data__;return YS?t[e]!==void 0:eC.call(t,e)},nC=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=YS&&t===void 0?`__lodash_hash_undefined__`:t,this};function rC(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}rC.prototype.clear=XS,rC.prototype.delete=ZS,rC.prototype.get=$S,rC.prototype.has=tC,rC.prototype.set=nC;var iC=rC,aC=function(){this.size=0,this.__data__={hash:new iC,map:new(JS||mS),string:new iC}},oC=function(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null},sC=function(e,t){var n=e.__data__;return oC(t)?n[typeof t==`string`?`string`:`hash`]:n.map},cC=function(e){var t=sC(this,e).delete(e);return this.size-=+!!t,t},lC=function(e){return sC(this,e).get(e)},uC=function(e){return sC(this,e).has(e)},dC=function(e,t){var n=sC(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function fC(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}fC.prototype.clear=aC,fC.prototype.delete=cC,fC.prototype.get=lC,fC.prototype.has=uC,fC.prototype.set=dC;var pC=fC,mC=function(e,t){var n=this.__data__;if(n instanceof mS){var r=n.__data__;if(!JS||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new pC(r)}return n.set(e,t),this.size=n.size,this};function hC(e){var t=this.__data__=new mS(e);this.size=t.size}hC.prototype.clear=hS,hC.prototype.delete=gS,hC.prototype.get=_S,hC.prototype.has=vS,hC.prototype.set=mC;var gC=hC,_C=function(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this},vC=function(e){return this.__data__.has(e)};function yC(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new pC;++t<n;)this.add(e[t])}yC.prototype.add=yC.prototype.push=_C,yC.prototype.has=vC;var bC=yC,xC=function(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1},SC=function(e,t){return e.has(t)},CC=function(e,t,n,r,i,a){var o=1&n,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=2&n?new bC:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!xC(t,(function(e,t){if(!SC(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)}))){f=!1;break}}else if(m!==h&&!i(m,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f},wC=xS.Uint8Array,TC=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n},EC=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n},DC=SS?SS.prototype:void 0,OC=DC?DC.valueOf:void 0,kC=function(e,t,n,r,i,a,o){switch(n){case`[object DataView]`:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case`[object ArrayBuffer]`:return!(e.byteLength!=t.byteLength||!a(new wC(e),new wC(t)));case`[object Boolean]`:case`[object Date]`:case`[object Number]`:return oS(+e,+t);case`[object Error]`:return e.name==t.name&&e.message==t.message;case`[object RegExp]`:case`[object String]`:return e==t+``;case`[object Map]`:var s=TC;case`[object Set]`:var c=1&r;if(s||=EC,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=2,o.set(e,t);var u=CC(s(e),s(t),r,i,a,o);return o.delete(e),u;case`[object Symbol]`:if(OC)return OC.call(e)==OC.call(t)}return!1},AC=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e},jC=Array.isArray,MC=function(e,t,n){var r=t(e);return jC(e)?r:AC(r,n(e))},NC=function(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a},PC=function(){return[]},FC=Object.prototype.propertyIsEnumerable,IC=Object.getOwnPropertySymbols,LC=IC?function(e){return e==null?[]:(e=Object(e),NC(IC(e),(function(t){return FC.call(e,t)})))}:PC,RC=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},zC=function(e){return typeof e==`object`&&!!e},BC=function(e){return zC(e)&&jS(e)==`[object Arguments]`},VC=Object.prototype,HC=VC.hasOwnProperty,UC=VC.propertyIsEnumerable,WC=BC(function(){return arguments}())?BC:function(e){return zC(e)&&HC.call(e,`callee`)&&!UC.call(e,`callee`)},GC=function(){return!1},KC=Rx((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?xS.Buffer:void 0;e.exports=(i?i.isBuffer:void 0)||GC})),qC=/^(?:0|[1-9]\d*)$/,JC=function(e,t){var n=typeof e;return!!(t??=9007199254740991)&&(n==`number`||n!=`symbol`&&qC.test(e))&&e>-1&&e%1==0&&e<t},YC=function(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991},XC={};XC[`[object Float32Array]`]=XC[`[object Float64Array]`]=XC[`[object Int8Array]`]=XC[`[object Int16Array]`]=XC[`[object Int32Array]`]=XC[`[object Uint8Array]`]=XC[`[object Uint8ClampedArray]`]=XC[`[object Uint16Array]`]=XC[`[object Uint32Array]`]=!0,XC[`[object Arguments]`]=XC[`[object Array]`]=XC[`[object ArrayBuffer]`]=XC[`[object Boolean]`]=XC[`[object DataView]`]=XC[`[object Date]`]=XC[`[object Error]`]=XC[`[object Function]`]=XC[`[object Map]`]=XC[`[object Number]`]=XC[`[object Object]`]=XC[`[object RegExp]`]=XC[`[object Set]`]=XC[`[object String]`]=XC[`[object WeakMap]`]=!1;var ZC=function(e){return zC(e)&&YC(e.length)&&!!XC[jS(e)]},QC=function(e){return function(t){return e(t)}},$C=Rx((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&yS.process;e.exports=function(){try{return r&&r.require&&r.require(`util`).types||i&&i.binding&&i.binding(`util`)}catch{}}()})),ew=$C&&$C.isTypedArray,tw=ew?QC(ew):ZC,nw=Object.prototype.hasOwnProperty,rw=function(e,t){var n=jC(e),r=!n&&WC(e),i=!n&&!r&&KC(e),a=!n&&!r&&!i&&tw(e),o=n||r||i||a,s=o?RC(e.length,String):[],c=s.length;for(var l in e)!t&&!nw.call(e,l)||o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||JC(l,c))||s.push(l);return s},iw=Object.prototype,aw=function(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||iw)},ow=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),sw=Object.prototype.hasOwnProperty,cw=function(e){if(!aw(e))return ow(e);var t=[];for(var n in Object(e))sw.call(e,n)&&n!=`constructor`&&t.push(n);return t},lw=function(e){return e!=null&&YC(e.length)&&!NS(e)},uw=function(e){return lw(e)?rw(e):cw(e)},dw=function(e){return MC(e,uw,LC)},fw=Object.prototype.hasOwnProperty,pw=function(e,t,n,r,i,a){var o=1&n,s=dw(e),c=s.length;if(c!=dw(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:fw.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){var h=e[u=s[l]],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v==y||!(`constructor`in e)||!(`constructor`in t)||typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y||(p=!1)}return a.delete(e),a.delete(t),p},mw=qS(xS,`DataView`),hw=qS(xS,`Promise`),gw=qS(xS,`Set`),_w=qS(xS,`WeakMap`),vw=RS(mw),yw=RS(JS),bw=RS(hw),xw=RS(gw),Sw=RS(_w),Cw=jS;(mw&&Cw(new mw(new ArrayBuffer(1)))!=`[object DataView]`||JS&&Cw(new JS)!=`[object Map]`||hw&&Cw(hw.resolve())!=`[object Promise]`||gw&&Cw(new gw)!=`[object Set]`||_w&&Cw(new _w)!=`[object WeakMap]`)&&(Cw=function(e){var t=jS(e),n=t==`[object Object]`?e.constructor:void 0,r=n?RS(n):``;if(r)switch(r){case vw:return`[object DataView]`;case yw:return`[object Map]`;case bw:return`[object Promise]`;case xw:return`[object Set]`;case Sw:return`[object WeakMap]`}return t});var ww=Cw,Tw=`[object Object]`,Ew=Object.prototype.hasOwnProperty,Dw=function(e,t,n,r,i,a){var o=jC(e),s=jC(t),c=o?`[object Array]`:ww(e),l=s?`[object Array]`:ww(t),u=(c=c==`[object Arguments]`?Tw:c)==Tw,d=(l=l==`[object Arguments]`?Tw:l)==Tw,f=c==l;if(f&&KC(e)){if(!KC(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new gC,o||tw(e)?CC(e,t,n,r,i,a):kC(e,t,c,n,r,i,a);if(!(1&n)){var p=u&&Ew.call(e,`__wrapped__`),m=d&&Ew.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new gC,i(h,g,n,r,a)}}return!!f&&(a||=new gC,pw(e,t,n,r,i,a))},Ow=function e(t,n,r,i,a){return t===n||(t==null||n==null||!zC(t)&&!zC(n)?t!=t&&n!=n:Dw(t,n,r,i,e,a))},kw=function(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){var c=(s=n[i])[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new gC;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?Ow(u,l,3,r,d):f))return!1}}return!0},Aw=function(e){return e==e&&!MS(e)},jw=function(e){for(var t=uw(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Aw(i)]}return t},Mw=function(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}},Nw=function(e){var t=jw(e);return t.length==1&&t[0][2]?Mw(t[0][0],t[0][1]):function(n){return n===e||kw(n,e,t)}},Pw=function(e){return typeof e==`symbol`||zC(e)&&jS(e)==`[object Symbol]`},Fw=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Iw=/^\w*$/,Lw=function(e,t){if(jC(e))return!1;var n=typeof e;return!(n!=`number`&&n!=`symbol`&&n!=`boolean`&&e!=null&&!Pw(e))||Iw.test(e)||!Fw.test(e)||t!=null&&e in Object(t)};function Rw(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(`Expected a function`);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Rw.Cache||pC),n}Rw.Cache=pC;var zw=Rw,Bw=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vw=/\\(\\)?/g,Hw=function(e){var t=zw(e,(function(e){return n.size===500&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Bw,(function(e,n,r,i){t.push(r?i.replace(Vw,`$1`):n||e)})),t})),Uw=function(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},Ww=SS?SS.prototype:void 0,Gw=Ww?Ww.toString:void 0,Kw=function e(t){if(typeof t==`string`)return t;if(jC(t))return Uw(t,e)+``;if(Pw(t))return Gw?Gw.call(t):``;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n},qw=function(e){return e==null?``:Kw(e)},Jw=function(e,t){return jC(e)?e:Lw(e,t)?[e]:Hw(qw(e))},Yw=function(e){if(typeof e==`string`||Pw(e))return e;var t=e+``;return t==`0`&&1/e==-1/0?`-0`:t},Xw=function(e,t){for(var n=0,r=(t=Jw(t,e)).length;e!=null&&n<r;)e=e[Yw(t[n++])];return n&&n==r?e:void 0},Zw=function(e,t,n){var r=e==null?void 0:Xw(e,t);return r===void 0?n:r},Qw=function(e,t){return e!=null&&t in Object(e)},$w=function(e,t,n){for(var r=-1,i=(t=Jw(t,e)).length,a=!1;++r<i;){var o=Yw(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:!!(i=e==null?0:e.length)&&YC(i)&&JC(o,i)&&(jC(e)||WC(e))},eT=function(e,t){return e!=null&&$w(e,t,Qw)},tT=function(e,t){return Lw(e)&&Aw(t)?Mw(Yw(e),t):function(n){var r=Zw(n,e);return r===void 0&&r===t?eT(n,e):Ow(t,r,3)}},nT=function(e){return e},rT=function(e){return function(t){return t?.[e]}},iT=function(e){return function(t){return Xw(t,e)}},aT=function(e){return Lw(e)?rT(Yw(e)):iT(e)},oT=function(e){return typeof e==`function`?e:e==null?nT:typeof e==`object`?jC(e)?tT(e[0],e[1]):Nw(e):aT(e)},sT=/\s/,cT=function(e){for(var t=e.length;t--&&sT.test(e.charAt(t)););return t},lT=/^\s+/,uT=function(e){return e&&e.slice(0,cT(e)+1).replace(lT,``)},dT=/^[-+]0x[0-9a-f]+$/i,fT=/^0b[01]+$/i,pT=/^0o[0-7]+$/i,mT=parseInt,hT=function(e){if(typeof e==`number`)return e;if(Pw(e))return NaN;if(MS(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=MS(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=uT(e);var n=fT.test(e);return n||pT.test(e)?mT(e.slice(2),n?2:8):dT.test(e)?NaN:+e},gT=function(e){return e?(e=hT(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:e===0?e:0},_T=function(e){var t=gT(e),n=t%1;return t==t?n?t-n:t:0};function vT(e){if(!e)throw Error(`change is not provided`);return qx(e)?`N${e.oldLineNumber}`:`${Gx(e)?`I`:`D`}${e.lineNumber}`}rS(`old`);var yT=$x(`old`),bT=$x(`new`);nS(`old`),nS(`new`),rS(`new`),rS(`old`);var xT=function(){try{var e=qS(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),ST=function(e,t,n){t==`__proto__`&&xT?xT(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},CT=function(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(!1===n(a[c],c,a))break}return t}}(),wT=function(e,t){return e&&CT(e,t,uw)},TT=function(e,t){var n={};return t=oT(t),wT(e,(function(e,r,i){ST(n,r,t(e,r,i))})),n},ET=[`changeKey`,`text`,`tokens`,`renderToken`],DT=function e(t,n){var r=t.type,i=t.value,a=t.markType,o=t.properties,s=t.className,c=t.children,l=function(t){return(0,q.jsx)(`span`,{className:t,children:i||c&&c.map(e)},n)};switch(r){case`text`:return i;case`mark`:return l(`diff-code-mark diff-code-mark-${a}`);case`edit`:return l(`diff-code-edit`);default:var u=o&&o.className;return l(zx(s||u))}};function OT(e){if(!Array.isArray(e))return!0;if(e.length>1)return!1;if(e.length===1){var t=Ox(e,1)[0];return t.type===`text`&&!t.value}return!0}function kT(e){var t=e.changeKey,n=e.text,r=e.tokens,i=e.renderToken,a=Dx(e,ET),o=i?function(e,t){return i(e,DT,t)}:DT;return(0,q.jsx)(`td`,Tx(Tx({},a),{},{"data-change-key":t,children:r?OT(r)?` `:r.map(o):n||` `}))}var AT=(0,b.memo)(kT);function jT(e,t){return function(){var n=t===`old`?yT(e):bT(e);return n===-1?void 0:n}}function MT(e,t){return function(n){return e&&n?(0,q.jsx)(`a`,{href:t?`#`+t:void 0,children:n}):n}}function NT(e,t){return t?function(n){e(),t(n)}:e}function PT(e,t,n,r){return(0,b.useMemo)((function(){var i=TT(e,(function(e){return function(n){return e&&e(t,n)}}));return i.onMouseEnter=NT(n,i.onMouseEnter),i.onMouseLeave=NT(r,i.onMouseLeave),i}),[e,n,r,t])}function FT(e,t,n,r,i,a,o,s,c){var l={change:t,side:r,inHoverState:s,renderDefault:jT(t,r),wrapInAnchor:MT(i,a)};return(0,q.jsx)(`td`,Tx(Tx({className:e},o),{},{"data-change-key":n,children:c(l)}))}function IT(e){var t,n,r,i=e.change,a=e.selected,o=e.tokens,s=e.className,c=e.generateLineClassName,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.gutterAnchor,h=e.generateAnchorID,g=e.renderToken,_=e.renderGutter,v=i.type,y=i.content,x=vT(i),S=Ox((t=Ox((0,b.useState)(!1),2),n=t[0],r=t[1],[n,(0,b.useCallback)((function(){return r(!0)}),[]),(0,b.useCallback)((function(){return r(!1)}),[])]),3),C=S[0],w=S[1],T=S[2],E=(0,b.useMemo)((function(){return{change:i}}),[i]),D=PT(d,E,w,T),O=PT(f,E,w,T),k=h(i),A=c({changes:[i],defaultGenerate:function(){return s}}),j=zx(`diff-gutter`,`diff-gutter-${v}`,l,{"diff-gutter-selected":a}),M=zx(`diff-code`,`diff-code-${v}`,u,{"diff-code-selected":a});return(0,q.jsxs)(`tr`,{id:k,className:zx(`diff-line`,A),children:[!p&&FT(j,i,x,`old`,m,k,D,C,_),!p&&FT(j,i,x,`new`,m,k,D,C,_),(0,q.jsx)(AT,Tx({className:M,changeKey:x,text:y,tokens:o,renderToken:g},O))]})}var LT=(0,b.memo)(IT);function RT(e){var t=e.hideGutter,n=e.element;return(0,q.jsx)(`tr`,{className:`diff-widget`,children:(0,q.jsx)(`td`,{colSpan:t?1:3,className:`diff-widget-content`,children:n})})}var zT=[`hideGutter`,`selectedChanges`,`tokens`,`lineClassName`],BT=[`hunk`,`widgets`,`className`];function VT(e){var t=e.hunk,n=e.widgets,r=e.className,i=Dx(e,BT),a=function(e,t){return e.reduce((function(e,n){var r=vT(n);e.push([`change`,r,n]);var i=t[r];return i&&e.push([`widget`,r,i]),e}),[])}(t.changes,n);return(0,q.jsx)(`tbody`,{className:zx(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=Ox(e,3),r=n[0],i=n[1],a=n[2],o=t.hideGutter,s=t.selectedChanges,c=t.tokens,l=t.lineClassName,u=Dx(t,zT);if(r===`change`){var d=Kx(a)?`old`:`new`,f=Kx(a)?yT(a):bT(a),p=c?c[d][f-1]:null;return(0,q.jsx)(LT,Tx({className:l,change:a,hideGutter:o,selected:s.includes(i),tokens:p},u),`change${i}`)}return r===`widget`?(0,q.jsx)(RT,{hideGutter:o,element:a},`widget${i}`):null}(e,i)}))})}var HT=0;function UT(e,t,n,r){var i=(0,b.useCallback)((function(){return t(e)}),[e,t]),a=(0,b.useCallback)((function(){return t(``)}),[t]);return(0,b.useMemo)((function(){var t=TT(r,(function(t){return function(r){return t&&t({side:e,change:n},r)}}));return t.onMouseEnter=NT(i,t.onMouseEnter),t.onMouseLeave=NT(a,t.onMouseLeave),t}),[n,r,i,e,a])}function WT(e){var t=e.change,n=e.side,r=e.selected,i=e.tokens,a=e.gutterClassName,o=e.codeClassName,s=e.gutterEvents,c=e.codeEvents,l=e.anchorID,u=e.gutterAnchor,d=e.gutterAnchorTarget,f=e.hideGutter,p=e.hover,m=e.renderToken,h=e.renderGutter;if(!t){var g=zx(`diff-gutter`,`diff-gutter-omit`,a),_=zx(`diff-code`,`diff-code-omit`,o);return[!f&&(0,q.jsx)(`td`,{className:g},`gutter`),(0,q.jsx)(`td`,{className:_},`code`)]}var v=t.type,y=t.content,b=vT(t),x=n===HT?`old`:`new`,S=Tx({id:l||void 0,className:zx(`diff-gutter`,`diff-gutter-${v}`,Ex({"diff-gutter-selected":r},`diff-line-hover-`+x,p),a),children:h({change:t,side:x,inHoverState:p,renderDefault:jT(t,x),wrapInAnchor:MT(u,d)})},s),C=zx(`diff-code`,`diff-code-${v}`,Ex({"diff-code-selected":r},`diff-line-hover-`+x,p),o);return[!f&&(0,q.jsx)(`td`,Tx(Tx({},S),{},{"data-change-key":b}),`gutter`),(0,q.jsx)(AT,Tx({className:C,changeKey:b,text:y,tokens:i,renderToken:m},c),`code`)]}function GT(e){var t=e.className,n=e.oldChange,r=e.newChange,i=e.oldSelected,a=e.newSelected,o=e.oldTokens,s=e.newTokens,c=e.monotonous,l=e.gutterClassName,u=e.codeClassName,d=e.gutterEvents,f=e.codeEvents,p=e.hideGutter,m=e.generateAnchorID,h=e.generateLineClassName,g=e.gutterAnchor,_=e.renderToken,v=e.renderGutter,y=Ox((0,b.useState)(``),2),x=y[0],S=y[1],C=UT(`old`,S,n,d),w=UT(`new`,S,r,d),T=UT(`old`,S,n,f),E=UT(`new`,S,r,f),D=n&&m(n),O=r&&m(r),k=h({changes:[n,r],defaultGenerate:function(){return t}}),A={monotonous:c,hideGutter:p,gutterClassName:l,codeClassName:u,gutterEvents:d,codeEvents:f,renderToken:_,renderGutter:v},j=Tx(Tx({},A),{},{change:n,side:HT,selected:i,tokens:o,gutterEvents:C,codeEvents:T,anchorID:D,gutterAnchor:g,gutterAnchorTarget:D,hover:x===`old`}),M=Tx(Tx({},A),{},{change:r,side:1,selected:a,tokens:s,gutterEvents:w,codeEvents:E,anchorID:n===r?null:O,gutterAnchor:g,gutterAnchorTarget:n===r?D:O,hover:x===`new`});return c?(0,q.jsx)(`tr`,{className:zx(`diff-line`,k),children:WT(n?j:M)}):(0,q.jsxs)(`tr`,{className:zx(`diff-line`,function(e,t){return e&&!t?`diff-line-old-only`:!e&&t?`diff-line-new-only`:e===t?`diff-line-normal`:`diff-line-compare`}(n,r),k),children:[WT(j),WT(M)]})}var KT=(0,b.memo)(GT);function qT(e){var t=e.hideGutter,n=e.oldElement,r=e.newElement;return e.monotonous?(0,q.jsx)(`tr`,{className:`diff-widget`,children:(0,q.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n||r})}):n===r?(0,q.jsx)(`tr`,{className:`diff-widget`,children:(0,q.jsx)(`td`,{colSpan:t?2:4,className:`diff-widget-content`,children:n})}):(0,q.jsxs)(`tr`,{className:`diff-widget`,children:[(0,q.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:n}),(0,q.jsx)(`td`,{colSpan:t?1:2,className:`diff-widget-content`,children:r})]})}var JT=[`selectedChanges`,`monotonous`,`hideGutter`,`tokens`,`lineClassName`],YT=[`hunk`,`widgets`,`className`];function XT(e,t){return(e?vT(e):`00`)+(t?vT(t):`00`)}function ZT(e){var t=e.hunk,n=e.widgets,r=e.className,i=Dx(e,YT),a=function(e,t){for(var n=function(e){return e&&t[vT(e)]||null},r=[],i=0;i<e.length;i++){var a=e[i];if(qx(a))r.push([`change`,XT(a,a),a,a]);else if(Kx(a)){var o=e[i+1];o&&Gx(o)?(i+=1,r.push([`change`,XT(a,o),a,o])):r.push([`change`,XT(a,null),a,null])}else r.push([`change`,XT(null,a),null,a]);var s=r[r.length-1],c=n(s[2]),l=n(s[3]);if(c||l){var u=s[1];r.push([`widget`,u,c,l])}}return r}(t.changes,n);return(0,q.jsx)(`tbody`,{className:zx(`diff-hunk`,r),children:a.map((function(e){return function(e,t){var n=Ox(e,4),r=n[0],i=n[1],a=n[2],o=n[3],s=t.selectedChanges,c=t.monotonous,l=t.hideGutter,u=t.tokens,d=t.lineClassName,f=Dx(t,JT);return r===`change`?(0,q.jsx)(KT,Tx({className:d,oldChange:a,newChange:o,monotonous:c,hideGutter:l,oldSelected:!!a&&s.includes(vT(a)),newSelected:!!o&&s.includes(vT(o)),oldTokens:a&&u?u.old[yT(a)-1]:null,newTokens:o&&u?u.new[bT(o)-1]:null},f),`change${i}`):r===`widget`?(0,q.jsx)(qT,{monotonous:c,hideGutter:l,oldElement:a,newElement:o},`widget${i}`):null}(e,i)}))})}var QT=[`gutterType`,`hunkClassName`];function $T(e){var t=e.hunk,n=Ux(),r=n.gutterType,i=n.hunkClassName,a=Dx(n,QT),o=r===`none`,s=r===`anchor`;return(0,q.jsx)(a.viewType===`unified`?VT:ZT,Tx(Tx({},a),{},{hunk:t,hideGutter:o,gutterAnchor:s,className:i}))}function eE(){}function tE(e,t){var n=t?`auto`:`none`;e instanceof HTMLElement&&e.style.userSelect!==n&&(e.style.userSelect=n)}function nE(e){return e.map((function(e){return(0,q.jsx)($T,{hunk:e},function(e){return`-${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines}`}(e))}))}function rE(e){var t=e.diffType,n=e.hunks,r=e.optimizeSelection,i=e.className,a=e.hunkClassName,o=a===void 0?Bx.hunkClassName:a,s=e.lineClassName,c=s===void 0?Bx.lineClassName:s,l=e.generateLineClassName,u=l===void 0?Bx.generateLineClassName:l,d=e.gutterClassName,f=d===void 0?Bx.gutterClassName:d,p=e.codeClassName,m=p===void 0?Bx.codeClassName:p,h=e.gutterType,g=h===void 0?Bx.gutterType:h,_=e.viewType,v=_===void 0?Bx.viewType:_,y=e.gutterEvents,x=y===void 0?Bx.gutterEvents:y,S=e.codeEvents,C=S===void 0?Bx.codeEvents:S,w=e.generateAnchorID,T=w===void 0?Bx.generateAnchorID:w,E=e.selectedChanges,D=E===void 0?Bx.selectedChanges:E,O=e.widgets,k=O===void 0?Bx.widgets:O,A=e.renderGutter,j=A===void 0?Bx.renderGutter:A,M=e.tokens,N=e.renderToken,P=e.children,F=P===void 0?nE:P,I=(0,b.useRef)(null),L=(0,b.useCallback)((function(e){var t=e.target;if(e.button===0){var n=function(e,t){for(var n=e;n&&n!==document.documentElement&&!n.classList.contains(t);)n=n.parentElement;return n===document.documentElement?null:n}(t,`diff-code`);if(n&&n.parentElement){var r=window.getSelection();r&&r.removeAllRanges();var i=Ax(n.parentElement.children).indexOf(n);if(i===1||i===3){var a,o=Ix(I.current?I.current.querySelectorAll(`.diff-line`):[]);try{for(o.s();!(a=o.n()).done;){var s=a.value.children;tE(s[1],i===1),tE(s[3],i===3)}}catch(e){o.e(e)}finally{o.f()}}}}}),[]),R=g===`none`,z=t===`add`||t===`delete`,ee=v===`split`&&!z&&r?L:eE,B=(0,b.useMemo)((function(){return(0,q.jsxs)(`colgroup`,v===`unified`?{children:[!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{})]}:z?{children:[!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{})]}:{children:[!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{}),!R&&(0,q.jsx)(`col`,{className:`diff-gutter-col`}),(0,q.jsx)(`col`,{})]})}),[v,z,R]);return(0,q.jsx)(Hx,{value:(0,b.useMemo)((function(){return{hunkClassName:o,lineClassName:c,generateLineClassName:u,gutterClassName:f,codeClassName:m,monotonous:z,hideGutter:R,viewType:v,gutterType:g,codeEvents:C,gutterEvents:x,generateAnchorID:T,selectedChanges:D,widgets:k,renderGutter:j,tokens:M,renderToken:N}}),[m,C,T,f,x,g,R,o,c,u,z,j,N,D,M,v,k]),children:(0,q.jsxs)(`table`,{ref:I,className:zx(`diff`,`diff-${v}`,i),onMouseDown:ee,children:[B,F(n)]})})}var iE=(0,b.memo)(rE),aE=function(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r},oE=function(e,t){return function(n,r){if(n==null)return n;if(!lw(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&!1!==r(o[a],a,o););return n}}(wT),sE=function(e,t,n,r){return oE(e,(function(e,i,a){t(r,e,n(e),a)})),r},cE=function(e,t){return function(n,r){var i=jC(n)?aE:sE,a=t?t():{};return i(n,e,oT(r),a)}},lE=cE((function(e,t,n){ST(e,n,t)})),uE=SS?SS.isConcatSpreadable:void 0,dE=function(e){return jC(e)||WC(e)||!!(uE&&e&&e[uE])},fE=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||=dE,a||=[];++o<s;){var c=t[o];n>0&&r(c)?n>1?e(c,n-1,r,i,a):AC(a,c):i||(a[a.length]=c)}return a},pE=function(e,t){var n=-1,r=lw(e)?Array(e.length):[];return oE(e,(function(e,i,a){r[++n]=t(e,i,a)})),r},mE=function(e,t){return(jC(e)?Uw:pE)(e,oT(t))},hE=function(e,t){return fE(mE(e,t),1)};function gE(e,t){var n=t.newStart;return Ox(t.changes.reduce((function(e,t){var n=Ox(e,2),r=n[0],i=n[1];return Kx(t)?(r.splice(i,1),[r,i]):(Gx(t)&&r.splice(i,0,t.content),[r,i+1])}),[e,n-1]),1)[0]}function _E(e,t,n){if(!e.length)return[];var r=t===`old`?yT:bT,i=lE(e,r),a=r(e[e.length-1]);return Array.from({length:a}).map((function(e,t){return n(i[t+1])}))}function vE(e){var t=Ox(function(e){return hE(e,(function(e){return e.changes})).reduce((function(e,t){var n=Ox(e,2),r=n[0],i=n[1];return qx(t)?(r.push(t),i.push(t)):Kx(t)?r.push(t):i.push(t),[r,i]}),[[],[]])}(e),2),n=t[0],r=t[1],i=function(e){return e?e.content:``};return[_E(n,`old`,i).join(`
72
+ `),_E(r,`new`,i).join(`
73
+ `)]}function yE(e){return{type:`root`,children:e}}function bE(e,t){if(t.oldSource){var n=function(e,t){return t.reduce(gE,e.split(`
74
74
  `)).join(`
75
- `)}(t.oldSource,e),r=t.highlight?function(e){return t.refractor.highlight(e,t.language)}:function(e){return[{type:`text`,value:e}]};return[nE(r(t.oldSource)),nE(r(n))]}var i=dx(tE(e),2),a=i[0],o=i[1],s=t.highlight?function(e){return nE(t.refractor.highlight(e,t.language))}:function(e){return nE([{type:`text`,value:e}])};return[s(a),s(o)]}function iE(e){return e.map((function(e){return cx({},e)}))}function aE(e,t){return[].concat(px(iE(e.slice(0,-1))),[t])}function oE(e){return e.type===`text`}function sE(e){var t=e[e.length-1];if(oE(t))return t;throw Error(`Invalid token path with leaf of type ${t.type}`)}function cE(e,t,n,r){var i=e.slice(0,-1),a=sE(e),o=[];if(n<=0||t>=a?.value.length)return[e];var s=function(e,t){var n=a.value.slice(e,t);return[].concat(px(i),[cx(cx({},a),{},{value:n})])};if(t>0){var c=s(0,t);o.push(iE(c))}var l=s(Math.max(t,0),n);if(o.push(r?function(e,t){return[t].concat(px(iE(e)))}(l,r):iE(l)),n<a.value.length){var u=s(n);o.push(iE(u))}return o}var lE=[`children`];function uE(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(e.children){var r=e.children,i=ux(e,lE);n.push(i);var a,o=yx(r);try{for(o.s();!(a=o.n()).done;)uE(a.value,t,n)}catch(e){o.e(e)}finally{o.f()}n.pop()}else t.push(iE([].concat(px(n.slice(1)),[e])));return t}function dE(e){return e.reduce((function(e,t){var n=e[e.length-1],r=fx(function(e){var t=sE(e);return t.value.includes(`
75
+ `)}(t.oldSource,e),r=t.highlight?function(e){return t.refractor.highlight(e,t.language)}:function(e){return[{type:`text`,value:e}]};return[yE(r(t.oldSource)),yE(r(n))]}var i=Ox(vE(e),2),a=i[0],o=i[1],s=t.highlight?function(e){return yE(t.refractor.highlight(e,t.language))}:function(e){return yE([{type:`text`,value:e}])};return[s(a),s(o)]}function xE(e){return e.map((function(e){return Tx({},e)}))}function SE(e,t){return[].concat(Ax(xE(e.slice(0,-1))),[t])}function CE(e){return e.type===`text`}function wE(e){var t=e[e.length-1];if(CE(t))return t;throw Error(`Invalid token path with leaf of type ${t.type}`)}function TE(e,t,n,r){var i=e.slice(0,-1),a=wE(e),o=[];if(n<=0||t>=a?.value.length)return[e];var s=function(e,t){var n=a.value.slice(e,t);return[].concat(Ax(i),[Tx(Tx({},a),{},{value:n})])};if(t>0){var c=s(0,t);o.push(xE(c))}var l=s(Math.max(t,0),n);if(o.push(r?function(e,t){return[t].concat(Ax(xE(e)))}(l,r):xE(l)),n<a.value.length){var u=s(n);o.push(xE(u))}return o}var EE=[`children`];function DE(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(e.children){var r=e.children,i=Dx(e,EE);n.push(i);var a,o=Ix(r);try{for(o.s();!(a=o.n()).done;)DE(a.value,t,n)}catch(e){o.e(e)}finally{o.f()}n.pop()}else t.push(xE([].concat(Ax(n.slice(1)),[e])));return t}function OE(e){return e.reduce((function(e,t){var n=e[e.length-1],r=kx(function(e){var t=wE(e);return t.value.includes(`
76
76
  `)?t.value.split(`
77
- `).map((function(n){return aE(e,cx(cx({},t),{},{value:n}))})):[e]}(t)),i=r[0],a=r.slice(1);return[].concat(px(e.slice(0,-1)),[[].concat(px(n),[i])],px(a.map((function(e){return[e]}))))}),[[]])}function fE(e){return dE(uE(e))}var pE=function(e,t,n){var r=(n=typeof n==`function`?n:void 0)?n(e,t):void 0;return r===void 0?dw(e,t,void 0,n):!!r},mE=function(e,t){return dw(e,t)},hE=function(e){var t=e==null?0:e.length;return t?e[t-1]:void 0};function gE(e,t){if(!e.children)throw Error(`parent node missing children property`);var n,r,i=hE(e.children);return i&&(r=t,(n=i).type===r.type&&(n.type===`text`||n.children&&r.children&&pE(n,r,(function(e,t,n){return n===`chlidren`||mE(e,t)}))))?e.children[e.children.length-1]=function(e,t){return`value`in e&&`value`in t?cx(cx({},e),{},{value:`${e.value}${t.value}`}):e}(i,t):e.children.push(t),e.children[e.children.length-1]}function _E(e){var t,n={type:`root`,children:[]},r=yx(e);try{var i=function(){var e=t.value;e.reduce((function(t,n,r){return gE(t,r===e.length-1?cx({},n):cx(cx({},n),{},{children:[]}))}),n)};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}return n}var vE=Object.prototype.hasOwnProperty,yE=GT((function(e,t,n){vE.call(e,n)?e[n].push(t):aT(e,n,[t])})),bE=Object.prototype.hasOwnProperty,xE=function(e){if(e==null)return!0;if(KC(e)&&(mC(e)||typeof e==`string`||typeof e.splice==`function`||kC(e)||RC(e)||DC(e)))return!e.length;var t=sw(e);if(t==`[object Map]`||t==`[object Set]`)return!e.size;if(HC(e))return!GC(e).length;for(var n in e)if(bE.call(e,n))return!1;return!0},SE=function(e,t){var n=t.start,r=n+t.length;return dx(e.reduce((function(e,i){var a=dx(e,2),o=a[0],s=a[1],c=s+sE(i).value.length;if(s>r||c<n)o.push(i);else{var l=cE(i,n-s,r-s,t);o.push.apply(o,px(l))}return[o,c]}),[[],0]),1)[0]};function CE(e,t){var n=yE(t,`lineNumber`);return e.map((function(e,t){return function(e,t){return xE(t)?e:t.reduce(SE,e)}(e,n[t+1])}))}function wE(e,t){return function(n){var r=dx(n,2),i=r[0],a=r[1];return[CE(i,e),CE(a,t)]}}var TE=function(e){return e!=null&&e.length?YT(e,1):[]},EE=Math.max,DE=function(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:eT(n);return i<0&&(i=EE(r+i,0)),Vx(e,Uw(t),i)},OE=xx((function(e){var t=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32};t.Diff=function(e,t){return[e,t]},t.prototype.diff_main=function(e,n,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+1e3*this.Diff_Timeout);var a=i;if(e==null||n==null)throw Error(`Null input. (diff_main)`);if(e==n)return e?[new t.Diff(0,e)]:[];r===void 0&&(r=!0);var o=r,s=this.diff_commonPrefix(e,n),c=e.substring(0,s);e=e.substring(s),n=n.substring(s),s=this.diff_commonSuffix(e,n);var l=e.substring(e.length-s);e=e.substring(0,e.length-s),n=n.substring(0,n.length-s);var u=this.diff_compute_(e,n,o,a);return c&&u.unshift(new t.Diff(0,c)),l&&u.push(new t.Diff(0,l)),this.diff_cleanupMerge(u),u},t.prototype.diff_compute_=function(e,n,r,i){var a;if(!e)return[new t.Diff(1,n)];if(!n)return[new t.Diff(-1,e)];var o=e.length>n.length?e:n,s=e.length>n.length?n:e,c=o.indexOf(s);if(c!=-1)return a=[new t.Diff(1,o.substring(0,c)),new t.Diff(0,s),new t.Diff(1,o.substring(c+s.length))],e.length>n.length&&(a[0][0]=a[2][0]=-1),a;if(s.length==1)return[new t.Diff(-1,e),new t.Diff(1,n)];var l=this.diff_halfMatch_(e,n);if(l){var u=l[0],d=l[1],f=l[2],p=l[3],m=l[4],h=this.diff_main(u,f,r,i),g=this.diff_main(d,p,r,i);return h.concat([new t.Diff(0,m)],g)}return r&&e.length>100&&n.length>100?this.diff_lineMode_(e,n,i):this.diff_bisect_(e,n,i)},t.prototype.diff_lineMode_=function(e,n,r){var i=this.diff_linesToChars_(e,n);e=i.chars1,n=i.chars2;var a=i.lineArray,o=this.diff_main(e,n,!1,r);this.diff_charsToLines_(o,a),this.diff_cleanupSemantic(o),o.push(new t.Diff(0,``));for(var s=0,c=0,l=0,u=``,d=``;s<o.length;){switch(o[s][0]){case 1:l++,d+=o[s][1];break;case-1:c++,u+=o[s][1];break;case 0:if(c>=1&&l>=1){o.splice(s-c-l,c+l),s=s-c-l;for(var f=this.diff_main(u,d,!1,r),p=f.length-1;p>=0;p--)o.splice(s,0,f[p]);s+=f.length}l=0,c=0,u=``,d=``}s++}return o.pop(),o},t.prototype.diff_bisect_=function(e,n,r){for(var i=e.length,a=n.length,o=Math.ceil((i+a)/2),s=o,c=2*o,l=Array(c),u=Array(c),d=0;d<c;d++)l[d]=-1,u[d]=-1;l[s+1]=0,u[s+1]=0;for(var f=i-a,p=f%2!=0,m=0,h=0,g=0,_=0,v=0;v<o&&!(new Date().getTime()>r);v++){for(var y=-v+m;y<=v-h;y+=2){for(var b=s+y,x=(E=y==-v||y!=v&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1)-y;E<i&&x<a&&e.charAt(E)==n.charAt(x);)E++,x++;if(l[b]=E,E>i)h+=2;else if(x>a)m+=2;else if(p&&(w=s+f-y)>=0&&w<c&&u[w]!=-1&&E>=(C=i-u[w]))return this.diff_bisectSplit_(e,n,E,x,r)}for(var S=-v+g;S<=v-_;S+=2){for(var C,w=s+S,T=(C=S==-v||S!=v&&u[w-1]<u[w+1]?u[w+1]:u[w-1]+1)-S;C<i&&T<a&&e.charAt(i-C-1)==n.charAt(a-T-1);)C++,T++;if(u[w]=C,C>i)_+=2;else if(T>a)g+=2;else if(!p&&(b=s+f-S)>=0&&b<c&&l[b]!=-1){var E;if(x=s+(E=l[b])-b,E>=(C=i-C))return this.diff_bisectSplit_(e,n,E,x,r)}}}return[new t.Diff(-1,e),new t.Diff(1,n)]},t.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},t.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){(o=e.indexOf(`
77
+ `).map((function(n){return SE(e,Tx(Tx({},t),{},{value:n}))})):[e]}(t)),i=r[0],a=r.slice(1);return[].concat(Ax(e.slice(0,-1)),[[].concat(Ax(n),[i])],Ax(a.map((function(e){return[e]}))))}),[[]])}function kE(e){return OE(DE(e))}var AE=function(e,t,n){var r=(n=typeof n==`function`?n:void 0)?n(e,t):void 0;return r===void 0?Ow(e,t,void 0,n):!!r},jE=function(e,t){return Ow(e,t)},ME=function(e){var t=e==null?0:e.length;return t?e[t-1]:void 0};function NE(e,t){if(!e.children)throw Error(`parent node missing children property`);var n,r,i=ME(e.children);return i&&(r=t,(n=i).type===r.type&&(n.type===`text`||n.children&&r.children&&AE(n,r,(function(e,t,n){return n===`chlidren`||jE(e,t)}))))?e.children[e.children.length-1]=function(e,t){return`value`in e&&`value`in t?Tx(Tx({},e),{},{value:`${e.value}${t.value}`}):e}(i,t):e.children.push(t),e.children[e.children.length-1]}function PE(e){var t,n={type:`root`,children:[]},r=Ix(e);try{var i=function(){var e=t.value;e.reduce((function(t,n,r){return NE(t,r===e.length-1?Tx({},n):Tx(Tx({},n),{},{children:[]}))}),n)};for(r.s();!(t=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}return n}var FE=Object.prototype.hasOwnProperty,IE=cE((function(e,t,n){FE.call(e,n)?e[n].push(t):ST(e,n,[t])})),LE=Object.prototype.hasOwnProperty,RE=function(e){if(e==null)return!0;if(lw(e)&&(jC(e)||typeof e==`string`||typeof e.splice==`function`||KC(e)||tw(e)||WC(e)))return!e.length;var t=ww(e);if(t==`[object Map]`||t==`[object Set]`)return!e.size;if(aw(e))return!cw(e).length;for(var n in e)if(LE.call(e,n))return!1;return!0},zE=function(e,t){var n=t.start,r=n+t.length;return Ox(e.reduce((function(e,i){var a=Ox(e,2),o=a[0],s=a[1],c=s+wE(i).value.length;if(s>r||c<n)o.push(i);else{var l=TE(i,n-s,r-s,t);o.push.apply(o,Ax(l))}return[o,c]}),[[],0]),1)[0]};function BE(e,t){var n=IE(t,`lineNumber`);return e.map((function(e,t){return function(e,t){return RE(t)?e:t.reduce(zE,e)}(e,n[t+1])}))}function VE(e,t){return function(n){var r=Ox(n,2),i=r[0],a=r[1];return[BE(i,e),BE(a,t)]}}var HE=function(e){return e!=null&&e.length?fE(e,1):[]},UE=Math.max,WE=function(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:_T(n);return i<0&&(i=UE(r+i,0)),iS(e,oT(t),i)},GE=Rx((function(e){var t=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32};t.Diff=function(e,t){return[e,t]},t.prototype.diff_main=function(e,n,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+1e3*this.Diff_Timeout);var a=i;if(e==null||n==null)throw Error(`Null input. (diff_main)`);if(e==n)return e?[new t.Diff(0,e)]:[];r===void 0&&(r=!0);var o=r,s=this.diff_commonPrefix(e,n),c=e.substring(0,s);e=e.substring(s),n=n.substring(s),s=this.diff_commonSuffix(e,n);var l=e.substring(e.length-s);e=e.substring(0,e.length-s),n=n.substring(0,n.length-s);var u=this.diff_compute_(e,n,o,a);return c&&u.unshift(new t.Diff(0,c)),l&&u.push(new t.Diff(0,l)),this.diff_cleanupMerge(u),u},t.prototype.diff_compute_=function(e,n,r,i){var a;if(!e)return[new t.Diff(1,n)];if(!n)return[new t.Diff(-1,e)];var o=e.length>n.length?e:n,s=e.length>n.length?n:e,c=o.indexOf(s);if(c!=-1)return a=[new t.Diff(1,o.substring(0,c)),new t.Diff(0,s),new t.Diff(1,o.substring(c+s.length))],e.length>n.length&&(a[0][0]=a[2][0]=-1),a;if(s.length==1)return[new t.Diff(-1,e),new t.Diff(1,n)];var l=this.diff_halfMatch_(e,n);if(l){var u=l[0],d=l[1],f=l[2],p=l[3],m=l[4],h=this.diff_main(u,f,r,i),g=this.diff_main(d,p,r,i);return h.concat([new t.Diff(0,m)],g)}return r&&e.length>100&&n.length>100?this.diff_lineMode_(e,n,i):this.diff_bisect_(e,n,i)},t.prototype.diff_lineMode_=function(e,n,r){var i=this.diff_linesToChars_(e,n);e=i.chars1,n=i.chars2;var a=i.lineArray,o=this.diff_main(e,n,!1,r);this.diff_charsToLines_(o,a),this.diff_cleanupSemantic(o),o.push(new t.Diff(0,``));for(var s=0,c=0,l=0,u=``,d=``;s<o.length;){switch(o[s][0]){case 1:l++,d+=o[s][1];break;case-1:c++,u+=o[s][1];break;case 0:if(c>=1&&l>=1){o.splice(s-c-l,c+l),s=s-c-l;for(var f=this.diff_main(u,d,!1,r),p=f.length-1;p>=0;p--)o.splice(s,0,f[p]);s+=f.length}l=0,c=0,u=``,d=``}s++}return o.pop(),o},t.prototype.diff_bisect_=function(e,n,r){for(var i=e.length,a=n.length,o=Math.ceil((i+a)/2),s=o,c=2*o,l=Array(c),u=Array(c),d=0;d<c;d++)l[d]=-1,u[d]=-1;l[s+1]=0,u[s+1]=0;for(var f=i-a,p=f%2!=0,m=0,h=0,g=0,_=0,v=0;v<o&&!(new Date().getTime()>r);v++){for(var y=-v+m;y<=v-h;y+=2){for(var b=s+y,x=(E=y==-v||y!=v&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1)-y;E<i&&x<a&&e.charAt(E)==n.charAt(x);)E++,x++;if(l[b]=E,E>i)h+=2;else if(x>a)m+=2;else if(p&&(w=s+f-y)>=0&&w<c&&u[w]!=-1&&E>=(C=i-u[w]))return this.diff_bisectSplit_(e,n,E,x,r)}for(var S=-v+g;S<=v-_;S+=2){for(var C,w=s+S,T=(C=S==-v||S!=v&&u[w-1]<u[w+1]?u[w+1]:u[w-1]+1)-S;C<i&&T<a&&e.charAt(i-C-1)==n.charAt(a-T-1);)C++,T++;if(u[w]=C,C>i)_+=2;else if(T>a)g+=2;else if(!p&&(b=s+f-S)>=0&&b<c&&l[b]!=-1){var E;if(x=s+(E=l[b])-b,E>=(C=i-C))return this.diff_bisectSplit_(e,n,E,x,r)}}}return[new t.Diff(-1,e),new t.Diff(1,n)]},t.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},t.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){(o=e.indexOf(`
78
78
  `,i))==-1&&(o=e.length-1);var c=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(c):r[c]!==void 0)?t+=String.fromCharCode(r[c]):(s==a&&(c=e.substring(i),o=e.length),t+=String.fromCharCode(s),r[c]=s,n[s++]=c),i=o+1}return t}n[0]=``;var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},t.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join(``)}},t.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?a=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,c!=0&&e.substring(i-o)!=t.substring(0,o)||(a=o,o++)}},t.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length<n.length)return null;var i=this;function a(e,t,n){for(var r,a,o,s,c=e.substring(n,n+Math.floor(e.length/4)),l=-1,u=``;(l=t.indexOf(c,l+1))!=-1;){var d=i.diff_commonPrefix(e.substring(n),t.substring(l)),f=i.diff_commonSuffix(e.substring(0,n),t.substring(0,l));u.length<f+d&&(u=t.substring(l-f,l)+t.substring(l,l+d),r=e.substring(0,n-f),a=e.substring(n+d),o=t.substring(0,l-f),s=t.substring(l+d))}return 2*u.length>=e.length?[r,a,o,s,u]:null}var o,s,c,l,u,d=a(n,r,Math.ceil(n.length/4)),f=a(n,r,Math.ceil(n.length/2));return d||f?(o=f?d&&d[4].length>f[4].length?d:f:d,e.length>t.length?(s=o[0],c=o[1],l=o[2],u=o[3]):(l=o[0],u=o[1],s=o[2],c=o[3]),[s,c,l,u,o[4]]):null},t.prototype.diff_cleanupSemantic=function(e){for(var n=!1,r=[],i=0,a=null,o=0,s=0,c=0,l=0,u=0;o<e.length;)e[o][0]==0?(r[i++]=o,s=l,c=u,l=0,u=0,a=e[o][1]):(e[o][0]==1?l+=e[o][1].length:u+=e[o][1].length,a&&a.length<=Math.max(s,c)&&a.length<=Math.max(l,u)&&(e.splice(r[i-1],0,new t.Diff(-1,a)),e[r[i-1]+1][0]=1,i--,o=--i>0?r[i-1]:-1,s=0,c=0,l=0,u=0,a=null,n=!0)),o++;for(n&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),o=1;o<e.length;){if(e[o-1][0]==-1&&e[o][0]==1){var d=e[o-1][1],f=e[o][1],p=this.diff_commonOverlap_(d,f),m=this.diff_commonOverlap_(f,d);p>=m?(p>=d.length/2||p>=f.length/2)&&(e.splice(o,0,new t.Diff(0,f.substring(0,p))),e[o-1][1]=d.substring(0,d.length-p),e[o+1][1]=f.substring(p),o++):(m>=d.length/2||m>=f.length/2)&&(e.splice(o,0,new t.Diff(0,d.substring(0,m))),e[o-1][0]=1,e[o-1][1]=f.substring(0,f.length-m),e[o+1][0]=-1,e[o+1][1]=d.substring(m),o++),o++}o++}},t.prototype.diff_cleanupSemanticLossless=function(e){function n(e,n){if(!e||!n)return 6;var r=e.charAt(e.length-1),i=n.charAt(0),a=r.match(t.nonAlphaNumericRegex_),o=i.match(t.nonAlphaNumericRegex_),s=a&&r.match(t.whitespaceRegex_),c=o&&i.match(t.whitespaceRegex_),l=s&&r.match(t.linebreakRegex_),u=c&&i.match(t.linebreakRegex_),d=l&&e.match(t.blanklineEndRegex_),f=u&&n.match(t.blanklineStartRegex_);return d||f?5:l||u?4:a&&!s&&c?3:s||c?2:a||o?1:0}for(var r=1;r<e.length-1;){if(e[r-1][0]==0&&e[r+1][0]==0){var i=e[r-1][1],a=e[r][1],o=e[r+1][1],s=this.diff_commonSuffix(i,a);if(s){var c=a.substring(a.length-s);i=i.substring(0,i.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=i,u=a,d=o,f=n(i,a)+n(a,o);a.charAt(0)===o.charAt(0);){i+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var p=n(i,a)+n(a,o);p>=f&&(f=p,l=i,u=a,d=o)}e[r-1][1]!=l&&(l?e[r-1][1]=l:(e.splice(r-1,1),r--),e[r][1]=u,d?e[r+1][1]=d:(e.splice(r+1,1),r--))}r++}},t.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,t.whitespaceRegex_=/\s/,t.linebreakRegex_=/[\r\n]/,t.blanklineEndRegex_=/\n\r?\n$/,t.blanklineStartRegex_=/^\r?\n\r?\n/,t.prototype.diff_cleanupEfficiency=function(e){for(var n=!1,r=[],i=0,a=null,o=0,s=!1,c=!1,l=!1,u=!1;o<e.length;)e[o][0]==0?(e[o][1].length<this.Diff_EditCost&&(l||u)?(r[i++]=o,s=l,c=u,a=e[o][1]):(i=0,a=null),l=u=!1):(e[o][0]==-1?u=!0:l=!0,a&&(s&&c&&l&&u||a.length<this.Diff_EditCost/2&&s+c+l+u==3)&&(e.splice(r[i-1],0,new t.Diff(-1,a)),e[r[i-1]+1][0]=1,i--,a=null,s&&c?(l=u=!0,i=0):(o=--i>0?r[i-1]:-1,l=u=!1),n=!0)),o++;n&&this.diff_cleanupMerge(e)},t.prototype.diff_cleanupMerge=function(e){e.push(new t.Diff(0,``));for(var n,r=0,i=0,a=0,o=``,s=``;r<e.length;)switch(e[r][0]){case 1:a++,s+=e[r][1],r++;break;case-1:i++,o+=e[r][1],r++;break;case 0:i+a>1?(i!==0&&a!==0&&((n=this.diff_commonPrefix(s,o))!==0&&(r-i-a>0&&e[r-i-a-1][0]==0?e[r-i-a-1][1]+=s.substring(0,n):(e.splice(0,0,new t.Diff(0,s.substring(0,n))),r++),s=s.substring(n),o=o.substring(n)),(n=this.diff_commonSuffix(s,o))!==0&&(e[r][1]=s.substring(s.length-n)+e[r][1],s=s.substring(0,s.length-n),o=o.substring(0,o.length-n))),r-=i+a,e.splice(r,i+a),o.length&&(e.splice(r,0,new t.Diff(-1,o)),r++),s.length&&(e.splice(r,0,new t.Diff(1,s)),r++),r++):r!==0&&e[r-1][0]==0?(e[r-1][1]+=e[r][1],e.splice(r,1)):r++,a=0,i=0,o=``,s=``}e[e.length-1][1]===``&&e.pop();var c=!1;for(r=1;r<e.length-1;)e[r-1][0]==0&&e[r+1][0]==0&&(e[r][1].substring(e[r][1].length-e[r-1][1].length)==e[r-1][1]?(e[r][1]=e[r-1][1]+e[r][1].substring(0,e[r][1].length-e[r-1][1].length),e[r+1][1]=e[r-1][1]+e[r+1][1],e.splice(r-1,1),c=!0):e[r][1].substring(0,e[r+1][1].length)==e[r+1][1]&&(e[r-1][1]+=e[r+1][1],e[r][1]=e[r][1].substring(e[r+1][1].length)+e[r+1][1],e.splice(r+1,1),c=!0)),r++;c&&this.diff_cleanupMerge(e)},t.prototype.diff_xIndex=function(e,t){var n,r=0,i=0,a=0,o=0;for(n=0;n<e.length&&(e[n][0]!==1&&(r+=e[n][1].length),e[n][0]!==-1&&(i+=e[n][1].length),!(r>t));n++)a=r,o=i;return e.length!=n&&e[n][0]===-1?o:o+(t-a)},t.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,r=/</g,i=/>/g,a=/\n/g,o=0;o<e.length;o++){var s=e[o][0],c=e[o][1].replace(n,`&amp;`).replace(r,`&lt;`).replace(i,`&gt;`).replace(a,`&para;<br>`);switch(s){case 1:t[o]=`<ins style="background:#e6ffe6;">`+c+`</ins>`;break;case-1:t[o]=`<del style="background:#ffe6e6;">`+c+`</del>`;break;case 0:t[o]=`<span>`+c+`</span>`}}return t.join(``)},t.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==1&&(t[n]=e[n][1]);return t.join(``)},t.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==-1&&(t[n]=e[n][1]);return t.join(``)},t.prototype.diff_levenshtein=function(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=e[i][0],o=e[i][1];switch(a){case 1:n+=o.length;break;case-1:r+=o.length;break;case 0:t+=Math.max(n,r),n=0,r=0}}return t+=Math.max(n,r)},t.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case 1:t[n]=`+`+encodeURI(e[n][1]);break;case-1:t[n]=`-`+e[n][1].length;break;case 0:t[n]=`=`+e[n][1].length}return t.join(` `).replace(/%20/g,` `)},t.prototype.diff_fromDelta=function(e,n){for(var r=[],i=0,a=0,o=n.split(/\t/g),s=0;s<o.length;s++){var c=o[s].substring(1);switch(o[s].charAt(0)){case`+`:try{r[i++]=new t.Diff(1,decodeURI(c))}catch{throw Error(`Illegal escape in diff_fromDelta: `+c)}break;case`-`:case`=`:var l=parseInt(c,10);if(isNaN(l)||l<0)throw Error(`Invalid number in diff_fromDelta: `+c);var u=e.substring(a,a+=l);o[s].charAt(0)==`=`?r[i++]=new t.Diff(0,u):r[i++]=new t.Diff(-1,u);break;default:if(o[s])throw Error(`Invalid diff operation in diff_fromDelta: `+o[s])}}if(a!=e.length)throw Error(`Delta length (`+a+`) does not equal source text length (`+e.length+`).`);return r},t.prototype.match_main=function(e,t,n){if(e==null||t==null||n==null)throw Error(`Null input. (match_main)`);return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},t.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error(`Pattern too long for this browser.`);var r=this.match_alphabet_(t),i=this;function a(e,r){var a=e/t.length,o=Math.abs(n-r);return i.Match_Distance?a+o/i.Match_Distance:o?1:a}var o=this.Match_Threshold,s=e.indexOf(t,n);s!=-1&&(o=Math.min(a(0,s),o),(s=e.lastIndexOf(t,n+t.length))!=-1&&(o=Math.min(a(0,s),o)));var c,l,u=1<<t.length-1;s=-1;for(var d,f=t.length+e.length,p=0;p<t.length;p++){for(c=0,l=f;c<l;)a(p,n+l)<=o?c=l:f=l,l=Math.floor((f-c)/2+c);f=l;var m=Math.max(1,n-l+1),h=Math.min(n+l,e.length)+t.length,g=Array(h+2);g[h+1]=(1<<p)-1;for(var _=h;_>=m;_--){var v=r[e.charAt(_-1)];if(g[_]=p===0?(g[_+1]<<1|1)&v:(g[_+1]<<1|1)&v|(d[_+1]|d[_])<<1|1|d[_+1],g[_]&u){var y=a(p,_-1);if(y<=o){if(o=y,!((s=_-1)>n))break;m=Math.max(1,2*n-s)}}}if(a(p+1,n)>o)break;d=g}return s},t.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},t.prototype.patch_addContext_=function(e,n){if(n.length!=0){if(e.start2===null)throw Error(`patch not initialized`);for(var r=n.substring(e.start2,e.start2+e.length1),i=0;n.indexOf(r)!=n.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=n.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var a=n.substring(e.start2-i,e.start2);a&&e.diffs.unshift(new t.Diff(0,a));var o=n.substring(e.start2+e.length1,e.start2+e.length1+i);o&&e.diffs.push(new t.Diff(0,o)),e.start1-=a.length,e.start2-=a.length,e.length1+=a.length+o.length,e.length2+=a.length+o.length}},t.prototype.patch_make=function(e,n,r){var i,a;if(typeof e==`string`&&typeof n==`string`&&r===void 0)i=e,(a=this.diff_main(i,n,!0)).length>2&&(this.diff_cleanupSemantic(a),this.diff_cleanupEfficiency(a));else if(e&&typeof e==`object`&&n===void 0&&r===void 0)a=e,i=this.diff_text1(a);else if(typeof e==`string`&&n&&typeof n==`object`&&r===void 0)i=e,a=n;else{if(typeof e!=`string`||typeof n!=`string`||!r||typeof r!=`object`)throw Error(`Unknown call format to patch_make.`);i=e,a=r}if(a.length===0)return[];for(var o=[],s=new t.patch_obj,c=0,l=0,u=0,d=i,f=i,p=0;p<a.length;p++){var m=a[p][0],h=a[p][1];switch(c||m===0||(s.start1=l,s.start2=u),m){case 1:s.diffs[c++]=a[p],s.length2+=h.length,f=f.substring(0,u)+h+f.substring(u);break;case-1:s.length1+=h.length,s.diffs[c++]=a[p],f=f.substring(0,u)+f.substring(u+h.length);break;case 0:h.length<=2*this.Patch_Margin&&c&&a.length!=p+1?(s.diffs[c++]=a[p],s.length1+=h.length,s.length2+=h.length):h.length>=2*this.Patch_Margin&&c&&(this.patch_addContext_(s,d),o.push(s),s=new t.patch_obj,c=0,d=f,l=u)}m!==1&&(l+=h.length),m!==-1&&(u+=h.length)}return c&&(this.patch_addContext_(s,d),o.push(s)),o},t.prototype.patch_deepCopy=function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=new t.patch_obj;a.diffs=[];for(var o=0;o<i.diffs.length;o++)a.diffs[o]=new t.Diff(i.diffs[o][0],i.diffs[o][1]);a.start1=i.start1,a.start2=i.start2,a.length1=i.length1,a.length2=i.length2,n[r]=a}return n},t.prototype.patch_apply=function(e,t){if(e.length==0)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var r=0,i=[],a=0;a<e.length;a++){var o,s,c=e[a].start2+r,l=this.diff_text1(e[a].diffs),u=-1;if(l.length>this.Match_MaxBits?(o=this.match_main(t,l.substring(0,this.Match_MaxBits),c))!=-1&&((u=this.match_main(t,l.substring(l.length-this.Match_MaxBits),c+l.length-this.Match_MaxBits))==-1||o>=u)&&(o=-1):o=this.match_main(t,l,c),o==-1)i[a]=!1,r-=e[a].length2-e[a].length1;else if(i[a]=!0,r=o-c,l==(s=u==-1?t.substring(o,o+l.length):t.substring(o,u+this.Match_MaxBits)))t=t.substring(0,o)+this.diff_text2(e[a].diffs)+t.substring(o+l.length);else{var d=this.diff_main(l,s,!1);if(l.length>this.Match_MaxBits&&this.diff_levenshtein(d)/l.length>this.Patch_DeleteThreshold)i[a]=!1;else{this.diff_cleanupSemanticLossless(d);for(var f,p=0,m=0;m<e[a].diffs.length;m++){var h=e[a].diffs[m];h[0]!==0&&(f=this.diff_xIndex(d,p)),h[0]===1?t=t.substring(0,o+f)+h[1]+t.substring(o+f):h[0]===-1&&(t=t.substring(0,o+f)+t.substring(o+this.diff_xIndex(d,p+h[1].length))),h[0]!==-1&&(p+=h[1].length)}}}}return[t=t.substring(n.length,t.length-n.length),i]},t.prototype.patch_addPadding=function(e){for(var n=this.Patch_Margin,r=``,i=1;i<=n;i++)r+=String.fromCharCode(i);for(i=0;i<e.length;i++)e[i].start1+=n,e[i].start2+=n;var a=e[0],o=a.diffs;if(o.length==0||o[0][0]!=0)o.unshift(new t.Diff(0,r)),a.start1-=n,a.start2-=n,a.length1+=n,a.length2+=n;else if(n>o[0][1].length){var s=n-o[0][1].length;o[0][1]=r.substring(o[0][1].length)+o[0][1],a.start1-=s,a.start2-=s,a.length1+=s,a.length2+=s}return(o=(a=e[e.length-1]).diffs).length==0||o[o.length-1][0]!=0?(o.push(new t.Diff(0,r)),a.length1+=n,a.length2+=n):n>o[o.length-1][1].length&&(s=n-o[o.length-1][1].length,o[o.length-1][1]+=r.substring(0,s),a.length1+=s,a.length2+=s),r},t.prototype.patch_splitMax=function(e){for(var n=this.Match_MaxBits,r=0;r<e.length;r++)if(!(e[r].length1<=n)){var i=e[r];e.splice(r--,1);for(var a=i.start1,o=i.start2,s=``;i.diffs.length!==0;){var c=new t.patch_obj,l=!0;for(c.start1=a-s.length,c.start2=o-s.length,s!==``&&(c.length1=c.length2=s.length,c.diffs.push(new t.Diff(0,s)));i.diffs.length!==0&&c.length1<n-this.Patch_Margin;){var u=i.diffs[0][0],d=i.diffs[0][1];u===1?(c.length2+=d.length,o+=d.length,c.diffs.push(i.diffs.shift()),l=!1):u===-1&&c.diffs.length==1&&c.diffs[0][0]==0&&d.length>2*n?(c.length1+=d.length,a+=d.length,l=!1,c.diffs.push(new t.Diff(u,d)),i.diffs.shift()):(d=d.substring(0,n-c.length1-this.Patch_Margin),c.length1+=d.length,a+=d.length,u===0?(c.length2+=d.length,o+=d.length):l=!1,c.diffs.push(new t.Diff(u,d)),d==i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(d.length))}s=(s=this.diff_text2(c.diffs)).substring(s.length-this.Patch_Margin);var f=this.diff_text1(i.diffs).substring(0,this.Patch_Margin);f!==``&&(c.length1+=f.length,c.length2+=f.length,c.diffs.length!==0&&c.diffs[c.diffs.length-1][0]===0?c.diffs[c.diffs.length-1][1]+=f:c.diffs.push(new t.Diff(0,f))),l||e.splice(++r,0,c)}}},t.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join(``)},t.prototype.patch_fromText=function(e){var n=[];if(!e)return n;for(var r=e.split(`
79
79
  `),i=0,a=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;i<r.length;){var o=r[i].match(a);if(!o)throw Error(`Invalid patch string: `+r[i]);var s=new t.patch_obj;for(n.push(s),s.start1=parseInt(o[1],10),o[2]===``?(s.start1--,s.length1=1):o[2]==`0`?s.length1=0:(s.start1--,s.length1=parseInt(o[2],10)),s.start2=parseInt(o[3],10),o[4]===``?(s.start2--,s.length2=1):o[4]==`0`?s.length2=0:(s.start2--,s.length2=parseInt(o[4],10)),i++;i<r.length;){var c=r[i].charAt(0);try{var l=decodeURI(r[i].substring(1))}catch{throw Error(`Illegal escape in patch_fromText: `+l)}if(c==`-`)s.diffs.push(new t.Diff(-1,l));else if(c==`+`)s.diffs.push(new t.Diff(1,l));else if(c==` `)s.diffs.push(new t.Diff(0,l));else{if(c==`@`)break;if(c!==``)throw Error(`Invalid patch mode "`+c+`" in: `+l)}i++}}return n},(t.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0}).prototype.toString=function(){for(var e,t=[`@@ -`+(this.length1===0?this.start1+`,0`:this.length1==1?this.start1+1:this.start1+1+`,`+this.length1)+` +`+(this.length2===0?this.start2+`,0`:this.length2==1?this.start2+1:this.start2+1+`,`+this.length2)+` @@
80
80
  `],n=0;n<this.diffs.length;n++){switch(this.diffs[n][0]){case 1:e=`+`;break;case-1:e=`-`;break;case 0:e=` `}t[n+1]=e+encodeURI(this.diffs[n][1])+`
81
- `}return t.join(``).replace(/%20/g,` `)},e.exports=t,e.exports.diff_match_patch=t,e.exports.DIFF_DELETE=-1,e.exports.DIFF_INSERT=1,e.exports.DIFF_EQUAL=0})),kE=OE.DIFF_EQUAL,AE=OE.DIFF_DELETE,jE=OE.DIFF_INSERT;function ME(e){var t=DE(e,(function(e){return!Ax(e)}));if(t===-1)return[];var n=DE(e,(function(e){return!!Ax(e)}),t);return n===-1?[e.slice(t)]:[e.slice(t,n)].concat(px(ME(e.slice(n))))}function NE(e){return e.reduce((function(e,t){var n=dx(t,2),r=n[0],i=fx(n[1].split(`
82
- `).map((function(e){return[r,e]}))),a=i[0],o=i.slice(1);return[].concat(px(e.slice(0,-1)),[[].concat(px(e[e.length-1]),[a])],px(o.map((function(e){return[e]}))))}),[[]])}function PE(e,t){return e.reduce((function(e,n){var r=dx(e,2),i=r[0],a=r[1],o=dx(n,2),s=o[0],c=o[1];if(s!==kE){var l={type:`edit`,lineNumber:t,start:a,length:c.length};i.push(l)}return[i,a+c.length]}),[[],0])[0]}function FE(e,t){return QT(e,(function(e,n){return PE(e,t+n)}))}function IE(e,t){var n=new OE,r=n.diff_main(e,t);return n.diff_cleanupSemantic(r),r.length<=1?[[],[]]:function(e){return e.reduce((function(e,t){var n=dx(e,2),r=n[0],i=n[1];switch(dx(t,1)[0]){case jE:i.push(t);break;case AE:r.push(t);break;default:r.push(t),i.push(t)}return[r,i]}),[[],[]])}(r)}function LE(e){var t=dx(e.reduce((function(e,t){var n=dx(e,2),r=n[0],i=n[1];return kx(t)?[r+(r?`
81
+ `}return t.join(``).replace(/%20/g,` `)},e.exports=t,e.exports.diff_match_patch=t,e.exports.DIFF_DELETE=-1,e.exports.DIFF_INSERT=1,e.exports.DIFF_EQUAL=0})),KE=GE.DIFF_EQUAL,qE=GE.DIFF_DELETE,JE=GE.DIFF_INSERT;function YE(e){var t=WE(e,(function(e){return!qx(e)}));if(t===-1)return[];var n=WE(e,(function(e){return!!qx(e)}),t);return n===-1?[e.slice(t)]:[e.slice(t,n)].concat(Ax(YE(e.slice(n))))}function XE(e){return e.reduce((function(e,t){var n=Ox(t,2),r=n[0],i=kx(n[1].split(`
82
+ `).map((function(e){return[r,e]}))),a=i[0],o=i.slice(1);return[].concat(Ax(e.slice(0,-1)),[[].concat(Ax(e[e.length-1]),[a])],Ax(o.map((function(e){return[e]}))))}),[[]])}function ZE(e,t){return e.reduce((function(e,n){var r=Ox(e,2),i=r[0],a=r[1],o=Ox(n,2),s=o[0],c=o[1];if(s!==KE){var l={type:`edit`,lineNumber:t,start:a,length:c.length};i.push(l)}return[i,a+c.length]}),[[],0])[0]}function QE(e,t){return hE(e,(function(e,n){return ZE(e,t+n)}))}function $E(e,t){var n=new GE,r=n.diff_main(e,t);return n.diff_cleanupSemantic(r),r.length<=1?[[],[]]:function(e){return e.reduce((function(e,t){var n=Ox(e,2),r=n[0],i=n[1];switch(Ox(t,1)[0]){case JE:i.push(t);break;case qE:r.push(t);break;default:r.push(t),i.push(t)}return[r,i]}),[[],[]])}(r)}function eD(e){var t=Ox(e.reduce((function(e,t){var n=Ox(e,2),r=n[0],i=n[1];return Kx(t)?[r+(r?`
83
83
  `:``)+t.content,i]:[r,i+(i?`
84
- `:``)+t.content]}),[``,``]),2),n=dx(IE(t[0],t[1]),2),r=n[0],i=n[1];if(r.length===0&&i.length===0)return[[],[]];var a=function(e){if(e&&!Ax(e))return e.lineNumber},o=a(e.find(kx)),s=a(e.find(Ox));if(o===void 0||s===void 0)throw Error(`Could not find start line number for edit`);return[FE(NE(r),o),FE(NE(i),s)]}function RE(e){var t=dx(e.reduce((function(e,t){var n=dx(e,3),r=n[0],i=n[1],a=n[2];if(!a||!kx(a)||!Ox(t))return[r,i,t];var o=dx(IE(a.content,t.content),2),s=o[0],c=o[1];return[r.concat(PE(s,a.lineNumber)),i.concat(PE(c,t.lineNumber)),t]}),[[],[],null]),2);return[t[0],t[1]]}function zE(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).type,n=(t===void 0?`block`:t)===`block`?LE:RE,r=dx(QT(e.map((function(e){return e.changes})),ME).map(n).reduce((function(e,t){var n=dx(e,2),r=n[0],i=n[1],a=dx(t,2),o=a[0],s=a[1];return[r.concat(o),i.concat(s)]}),[[],[]]),2),i=r[0],a=r[1];return wE(TE(i),TE(a))}var BE=[`enhancers`],VE=function(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.enhancers,i=r===void 0?[]:r,a=dx(rE(e,ux(n,BE)),2),o=a[0],s=a[1],c=[fE(o),fE(s)],l=dx((t=[c[0],c[1]],i.reduce((function(e,t){return t(e)}),t)),2),u=l[0],d=l[1],f=[u.map(_E),d.map(_E)],p=f[1];return{old:f[0].map((function(e){return e.children??[]})),new:p.map((function(e){return e.children??[]}))}},HE=e=>e.type===`insert`?{oldLineNumber:null,newLineNumber:e.lineNumber}:e.type===`delete`?{oldLineNumber:e.lineNumber,newLineNumber:null}:{oldLineNumber:`oldLineNumber`in e?e.oldLineNumber:e.lineNumber,newLineNumber:`newLineNumber`in e?e.newLineNumber:e.lineNumber},UE=e=>{let{oldLineNumber:t,newLineNumber:n}=HE(e);return n===null?t===null?e.lineNumber:t:n},WE=(e,t)=>{let{oldLineNumber:n,newLineNumber:r}=HE(t);return e.new_line_number!==null&&r===e.new_line_number?!0:e.old_line_number!==null&&n===e.old_line_number},GE=(e,t)=>WE(e,t),KE=e=>e.replace(/^[ab]\//,``),qE=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?KE(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?KE(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},JE=e=>{let[t,n]=qE(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},YE=e=>e.oldLineNumber!==null&&e.newLineNumber!==null?`old ${e.oldLineNumber}, new ${e.newLineNumber}`:e.newLineNumber===null?e.oldLineNumber===null?`line unavailable`:`old ${e.oldLineNumber}`:`new ${e.newLineNumber}`,XE=e=>e===`bundle_diff`?`Branch diff`:`Uncommitted`,ZE=(e,t)=>`${e}::${t}`,QE=(e,t)=>{let n=e.changes.findIndex(e=>tT(e)===tT(t));if(n===-1)return t.content;let r=Math.max(0,n-1),i=Math.min(e.changes.length,n+2);return e.changes.slice(r,i).map(e=>e.content).join(`
85
- `)},$E=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,eD=e=>[e.hunk_header,e.line_content].filter(e=>!!e).join(`
86
- `).trim(),tD=(e,t)=>{let n=t.find(t=>t.pathCandidates.includes(e.file_path??``));if(!n)return e.file_path?{filePath:e.file_path,diffSnippet:eD(e)}:null;let r=n.hunks.flatMap(e=>e.changes.map(t=>({hunk:e,change:t}))).find(({change:t})=>GE(e,t));return r?{filePath:e.file_path??JE(n),diffSnippet:QE(r.hunk,r.change)}:{filePath:e.file_path??JE(n),diffSnippet:eD(e)}},nD=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,rD=e=>e.subject_type===`file`,iD=e=>e.body.trim(),aD=(e,t)=>{if(!e.file_path)return null;let n=t.find(t=>t.pathCandidates.includes(e.file_path??``));if(!n)return{filePath:e.file_path,diffSnippet:iD(e)};let r=n.hunks.flatMap(e=>e.changes.map(t=>({hunk:e,change:t}))).find(({change:t})=>GE(e,t));return r?{filePath:e.file_path,diffSnippet:QE(r.hunk,r.change)}:{filePath:e.file_path,diffSnippet:iD(e)}},oD=e=>e.pagePath||e.pageUrl||`/`,sD=({drafts:e,findings:t,githubComments:n,previewComments:r=[],uncommittedFiles:i=[],bundleFiles:a=[]})=>{let o=[...e],s=[...t].sort((e,t)=>{let n=e.file_path??``,r=t.file_path??``;if(n!==r)return n.localeCompare(r);let i=e.new_line_number??e.old_line_number??2**53-1,a=t.new_line_number??t.old_line_number??2**53-1;return i===a?e.ordinal-t.ordinal:i-a}),c=[...n].sort((e,t)=>{let n=e.file_path??``,r=t.file_path??``;if(n!==r)return n.localeCompare(r);let i=e.new_line_number??e.old_line_number??2**53-1,a=t.new_line_number??t.old_line_number??2**53-1;return i===a?e.id.localeCompare(t.id):i-a}),l=[...r].sort((e,t)=>{let n=oD(e),r=oD(t);return n===r?e.elementLabel===t.elementLabel?e.selectorHint===t.selectorHint?e.id.localeCompare(t.id):e.selectorHint.localeCompare(t.selectorHint):e.elementLabel.localeCompare(t.elementLabel):n.localeCompare(r)}),u=o.map((e,t)=>[`${t+1}. Source: Manual comment (${XE(e.scope)})`,`File: ${e.filePath}`,`Line: ${YE(e)}`,`Hunk: ${e.hunkHeader}`,`Changed line: ${e.lineContent}`,`Comment: ${e.comment}`,`Context:`,"```diff",e.diffSnippet,"```"].join(`
87
- `)),d=s.map((e,t)=>{let n=tD(e,i),r=[`${o.length+t+1}. Source: Archon review finding`,`Finding: ${e.ordinal}`];return n?.filePath&&r.push(`File: ${n.filePath}`),r.push(`Line: ${$E(e)}`),r.push(`Severity: ${e.severity}`),r.push(`Title: ${e.title}`),r.push(`What: ${e.what_text}`),e.why_text&&r.push(`Why it matters: ${e.why_text}`),e.fix_text&&r.push(`Requested fix: ${e.fix_text}`),n?.diffSnippet&&(r.push(`Context:`),r.push("```diff"),r.push(n.diffSnippet),r.push("```")),r.join(`
88
- `)}),f=c.map((e,t)=>{let n=aD(e,a),r=[`${o.length+s.length+t+1}. Source: GitHub ${e.kind===`review`?`review summary`:`review comment`}`,`Author: ${e.author}`];return n?.filePath&&r.push(`File: ${n.filePath}`),e.kind===`inline`&&!rD(e)&&r.push(`Line: ${nD(e)}`),e.is_outdated&&r.push(`Status: Outdated on GitHub`),r.push(`Comment: ${e.body}`),n?.diffSnippet&&(r.push(`Context:`),r.push("```diff"),r.push(n.diffSnippet),r.push("```")),r.push(`GitHub URL: ${e.url}`),r.join(`
89
- `)}),p=l.map((e,t)=>{let n=[`${o.length+s.length+c.length+t+1}. Source: Preview comment`,`Page: ${oD(e)}`,`Element: ${e.elementLabel}`,`Selector hint: ${e.selectorHint}`];return e.textSnippet&&n.push(`Text: ${e.textSnippet}`),e.href&&n.push(`Href: ${e.href}`),e.src&&n.push(`Src: ${e.src}`),n.push(`Comment: ${e.comment}`),n.join(`
84
+ `:``)+t.content]}),[``,``]),2),n=Ox($E(t[0],t[1]),2),r=n[0],i=n[1];if(r.length===0&&i.length===0)return[[],[]];var a=function(e){if(e&&!qx(e))return e.lineNumber},o=a(e.find(Kx)),s=a(e.find(Gx));if(o===void 0||s===void 0)throw Error(`Could not find start line number for edit`);return[QE(XE(r),o),QE(XE(i),s)]}function tD(e){var t=Ox(e.reduce((function(e,t){var n=Ox(e,3),r=n[0],i=n[1],a=n[2];if(!a||!Kx(a)||!Gx(t))return[r,i,t];var o=Ox($E(a.content,t.content),2),s=o[0],c=o[1];return[r.concat(ZE(s,a.lineNumber)),i.concat(ZE(c,t.lineNumber)),t]}),[[],[],null]),2);return[t[0],t[1]]}function nD(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).type,n=(t===void 0?`block`:t)===`block`?eD:tD,r=Ox(hE(e.map((function(e){return e.changes})),YE).map(n).reduce((function(e,t){var n=Ox(e,2),r=n[0],i=n[1],a=Ox(t,2),o=a[0],s=a[1];return[r.concat(o),i.concat(s)]}),[[],[]]),2),i=r[0],a=r[1];return VE(HE(i),HE(a))}var rD=[`enhancers`],iD=function(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.enhancers,i=r===void 0?[]:r,a=Ox(bE(e,Dx(n,rD)),2),o=a[0],s=a[1],c=[kE(o),kE(s)],l=Ox((t=[c[0],c[1]],i.reduce((function(e,t){return t(e)}),t)),2),u=l[0],d=l[1],f=[u.map(PE),d.map(PE)],p=f[1];return{old:f[0].map((function(e){return e.children??[]})),new:p.map((function(e){return e.children??[]}))}},aD=e=>e.type===`insert`?{oldLineNumber:null,newLineNumber:e.lineNumber}:e.type===`delete`?{oldLineNumber:e.lineNumber,newLineNumber:null}:{oldLineNumber:`oldLineNumber`in e?e.oldLineNumber:e.lineNumber,newLineNumber:`newLineNumber`in e?e.newLineNumber:e.lineNumber},oD=e=>{let{oldLineNumber:t,newLineNumber:n}=aD(e);return n===null?t===null?e.lineNumber:t:n},sD=(e,t)=>{let{oldLineNumber:n,newLineNumber:r}=aD(t);return e.new_line_number!==null&&r===e.new_line_number?!0:e.old_line_number!==null&&n===e.old_line_number},cD=(e,t)=>sD(e,t),lD=e=>e.replace(/^[ab]\//,``),uD=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?lD(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?lD(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},dD=e=>{let[t,n]=uD(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},fD=e=>e.oldLineNumber!==null&&e.newLineNumber!==null?`old ${e.oldLineNumber}, new ${e.newLineNumber}`:e.newLineNumber===null?e.oldLineNumber===null?`line unavailable`:`old ${e.oldLineNumber}`:`new ${e.newLineNumber}`,pD=e=>e===`bundle_diff`?`Branch diff`:`Uncommitted`,mD=(e,t)=>`${e}::${t}`,hD=(e,t)=>{let n=e.changes.findIndex(e=>vT(e)===vT(t));if(n===-1)return t.content;let r=Math.max(0,n-1),i=Math.min(e.changes.length,n+2);return e.changes.slice(r,i).map(e=>e.content).join(`
85
+ `)},gD=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,_D=e=>[e.hunk_header,e.line_content].filter(e=>!!e).join(`
86
+ `).trim(),vD=(e,t)=>{let n=t.find(t=>t.pathCandidates.includes(e.file_path??``));if(!n)return e.file_path?{filePath:e.file_path,diffSnippet:_D(e)}:null;let r=n.hunks.flatMap(e=>e.changes.map(t=>({hunk:e,change:t}))).find(({change:t})=>cD(e,t));return r?{filePath:e.file_path??dD(n),diffSnippet:hD(r.hunk,r.change)}:{filePath:e.file_path??dD(n),diffSnippet:_D(e)}},yD=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,bD=e=>e.subject_type===`file`,xD=e=>e.body.trim(),SD=(e,t)=>{if(!e.file_path)return null;let n=t.find(t=>t.pathCandidates.includes(e.file_path??``));if(!n)return{filePath:e.file_path,diffSnippet:xD(e)};let r=n.hunks.flatMap(e=>e.changes.map(t=>({hunk:e,change:t}))).find(({change:t})=>cD(e,t));return r?{filePath:e.file_path,diffSnippet:hD(r.hunk,r.change)}:{filePath:e.file_path,diffSnippet:xD(e)}},CD=e=>e.pagePath||e.pageUrl||`/`,wD=({drafts:e,findings:t,githubComments:n,previewComments:r=[],uncommittedFiles:i=[],bundleFiles:a=[]})=>{let o=[...e],s=[...t].sort((e,t)=>{let n=e.file_path??``,r=t.file_path??``;if(n!==r)return n.localeCompare(r);let i=e.new_line_number??e.old_line_number??2**53-1,a=t.new_line_number??t.old_line_number??2**53-1;return i===a?e.ordinal-t.ordinal:i-a}),c=[...n].sort((e,t)=>{let n=e.file_path??``,r=t.file_path??``;if(n!==r)return n.localeCompare(r);let i=e.new_line_number??e.old_line_number??2**53-1,a=t.new_line_number??t.old_line_number??2**53-1;return i===a?e.id.localeCompare(t.id):i-a}),l=[...r].sort((e,t)=>{let n=CD(e),r=CD(t);return n===r?e.elementLabel===t.elementLabel?e.selectorHint===t.selectorHint?e.id.localeCompare(t.id):e.selectorHint.localeCompare(t.selectorHint):e.elementLabel.localeCompare(t.elementLabel):n.localeCompare(r)}),u=o.map((e,t)=>[`${t+1}. Source: Manual comment (${pD(e.scope)})`,`File: ${e.filePath}`,`Line: ${fD(e)}`,`Hunk: ${e.hunkHeader}`,`Changed line: ${e.lineContent}`,`Comment: ${e.comment}`,`Context:`,"```diff",e.diffSnippet,"```"].join(`
87
+ `)),d=s.map((e,t)=>{let n=vD(e,i),r=[`${o.length+t+1}. Source: Archon review finding`,`Finding: ${e.ordinal}`];return n?.filePath&&r.push(`File: ${n.filePath}`),r.push(`Line: ${gD(e)}`),r.push(`Severity: ${e.severity}`),r.push(`Title: ${e.title}`),r.push(`What: ${e.what_text}`),e.why_text&&r.push(`Why it matters: ${e.why_text}`),e.fix_text&&r.push(`Requested fix: ${e.fix_text}`),n?.diffSnippet&&(r.push(`Context:`),r.push("```diff"),r.push(n.diffSnippet),r.push("```")),r.join(`
88
+ `)}),f=c.map((e,t)=>{let n=SD(e,a),r=[`${o.length+s.length+t+1}. Source: GitHub ${e.kind===`review`?`review summary`:`review comment`}`,`Author: ${e.author}`];return n?.filePath&&r.push(`File: ${n.filePath}`),e.kind===`inline`&&!bD(e)&&r.push(`Line: ${yD(e)}`),e.is_outdated&&r.push(`Status: Outdated on GitHub`),r.push(`Comment: ${e.body}`),n?.diffSnippet&&(r.push(`Context:`),r.push("```diff"),r.push(n.diffSnippet),r.push("```")),r.push(`GitHub URL: ${e.url}`),r.join(`
89
+ `)}),p=l.map((e,t)=>{let n=[`${o.length+s.length+c.length+t+1}. Source: Preview comment`,`Page: ${CD(e)}`,`Element: ${e.elementLabel}`,`Selector hint: ${e.selectorHint}`];return e.textSnippet&&n.push(`Text: ${e.textSnippet}`),e.href&&n.push(`Href: ${e.href}`),e.src&&n.push(`Src: ${e.src}`),n.push(`Comment: ${e.comment}`),n.join(`
90
90
  `)}),m=[...u,...d,...f,...p],h=t.length>0||e.length>0||n.length>0;return[r.length>0?h?`Please address the following selected fixes from the current diff and preview.`:`Please address the following selected fixes from the current preview.`:h?`Please address the following selected fixes in the current diff.`:`Please address the selected fixes in the current diff.`,``,...m.flatMap(e=>[e,``]),`Apply only the selected fixes. Keep unrelated changes intact.`].join(`
91
- `).trim()},cD={phone:{label:`Phone`,width:390,height:844},tablet:{label:`Tablet`,width:768,height:1024},laptop:{label:`Laptop`,width:1440,height:900}},lD=[.5,.75,1,1.25],uD=[{value:`responsive`,label:`Responsive`},{value:`phone`,label:`Phone`},{value:`tablet`,label:`Tablet`},{value:`laptop`,label:`Laptop`}],dD=`archon-preview-selection`,fD=`archon-preview-selection-parent`,pD=320,mD=248,hD=12,gD=16,_D=12,vD=8,yD=8,bD={a:`Link`,article:`Article`,button:`Button`,footer:`Footer`,form:`Form`,h1:`Heading`,h2:`Heading`,h3:`Heading`,h4:`Heading`,h5:`Heading`,h6:`Heading`,header:`Header`,img:`Image`,input:`Input`,label:`Label`,li:`List item`,main:`Main content`,nav:`Navigation`,option:`Option`,p:`Text block`,section:`Section`,select:`Select`,span:`Text`,textarea:`Text area`},xD={button:`Button`,checkbox:`Checkbox`,heading:`Heading`,img:`Image`,link:`Link`,menuitem:`Menu item`,option:`Option`,radio:`Radio option`,searchbox:`Search field`,switch:`Switch`,tab:`Tab`,textbox:`Text field`},SD=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`preview-review-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,CD=({previewUrl:e,reviewCapability:t,status:n})=>t&&!t.canSelect?t.disabledReason:t?.submitPrompt?n?.state!==`ready`||!e?`Wait for the preview to finish loading first.`:null:`Preview selection is only available for build-capable ticket runs.`,wD=e=>e?.target?`${e.target.kind}:${e.target.id}`:null,TD=(e,t)=>{let n=e.getBoundingClientRect(),r=t.viewport.width>0?n.width/t.viewport.width:1,i=t.viewport.height>0?n.height/t.viewport.height:1;return{left:n.left+t.bounds.left*r,top:n.top+t.bounds.top*i,width:t.bounds.width*r,height:t.bounds.height*i}},ED=(e,t)=>{let n=t.width,r=t.height,i=e.left+e.width+hD,a=i+n<=window.innerWidth-gD,o=e.left-n-hD,s=Math.max(gD,window.innerWidth-n-gD),c=a?i:o>=gD?o:Math.min(Math.max(gD,e.left),s),l=Math.max(gD,e.top),u=Math.max(gD,window.innerHeight-r-gD);return{left:c,top:l+r<=window.innerHeight-gD?l:Math.max(gD,Math.min(e.top+e.height-r,u))}},DD=e=>{if(!e)return null;let t=e.replace(/\s+/g,` `).trim();return t.length>0?t:null},OD=(e,t=96)=>{if(e.length<=t)return e;let n=e.slice(0,t+1),r=n.lastIndexOf(` `);return`${(r>Math.floor(t*.6)?n.slice(0,r):n.slice(0,t)).trimEnd()}...`},kD=({elementLabel:e,textSnippet:t})=>{let n=e.match(/\[role=([^\]]+)\]/i)?.[1]?.toLowerCase()??null;if(n&&xD[n])return xD[n];let r=e.match(/^[a-z0-9-]+/i)?.[0]?.toLowerCase()??null;return r===`div`?t?`Text block`:`Container`:r&&xD[r]?xD[r]:r&&bD[r]?bD[r]:`Element`},AD=e=>{let t=DD(e.textSnippet);return{kindLabel:kD({elementLabel:e.elementLabel,textSnippet:t}),detail:t?OD(t):null}},jD=({pagePath:e,selectorHint:t})=>`${e}::${t}`,MD=(e,t)=>jD(e)===jD(t),ND=(e,t)=>{let n=Array.from(e.children).filter(e=>e instanceof HTMLElement);return n.length===0?0:n.reduce((e,t)=>e+Math.round(t.getBoundingClientRect().width),0)+(n.length-1)*t},PD=({title:e,description:t,showSpinner:n=!1})=>(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,q.jsxs)(`div`,{className:`max-w-sm rounded-2xl border border-border/70 bg-background/70 p-5 text-center shadow-lg shadow-black/20`,children:[n&&(0,q.jsx)(C_,{className:`mx-auto mb-3 h-5 w-5 animate-spin text-muted-foreground`}),(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:t})]})}),FD=({iframeKey:e,iframeRef:t,iframeSrc:n,onLoad:r,preset:i,zoom:a})=>{let o=i===null,s=i?{"--preview-width":`${i.width}px`,"--preview-height":`${i.height}px`,"--preview-scale":`${a}`,"--preview-scaled-width":`${Math.round(i.width*a)}px`,"--preview-scaled-height":`${Math.round(i.height*a)}px`}:void 0;return(0,q.jsx)(`div`,{className:o?`flex h-full min-h-0 flex-col p-4`:`flex h-full min-h-0 items-start justify-center overflow-auto p-6`,children:(0,q.jsx)(`div`,{className:o?`min-h-0 flex-1`:`w-[var(--preview-scaled-width)]`,style:s,children:(0,q.jsx)(`div`,{className:o?`h-full min-h-0 overflow-hidden bg-white shadow-2xl shadow-black/20`:`h-[var(--preview-scaled-height)] w-[var(--preview-scaled-width)] overflow-hidden rounded-[1.5rem] border border-border/80 bg-white shadow-2xl shadow-black/30`,children:(0,q.jsx)(`iframe`,{ref:t,src:n,sandbox:`allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts`,title:`Project preview`,className:o?`h-full w-full border-0 bg-white`:`h-[var(--preview-height)] w-[var(--preview-width)] origin-top-left scale-[var(--preview-scale)] border-0 bg-white`,onLoad:r},e)})})})},ID=({tooltip:e,children:t,...n})=>(0,q.jsx)(u_,{content:e,side:`bottom`,children:(0,q.jsx)(`span`,{className:`inline-flex`,children:(0,q.jsx)(Y,{...n,children:t})})}),LD=({comment:e,onRemoveComment:t})=>{let n=AD(e);return(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(Qb,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:n.kindLabel}),n.detail&&(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:n.detail}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.comment})]}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5 h-7 w-7 flex-shrink-0 text-muted-foreground hover:text-foreground`,"aria-label":`Delete pending comment for ${e.elementLabel}`,onClick:()=>t(e.id),children:(0,q.jsx)(qv,{className:`h-4 w-4`})})]})})},RD=({isOpen:e,canSendReview:t,comments:n,triggerMode:r=`full`,disabledReason:i,isSubmittingReview:a,onOpenChange:o,onRemoveComment:s,onClearPendingFixes:c,onSubmitReview:l})=>{let u=n.length;return(0,q.jsxs)(Hg,{open:e,onOpenChange:o,children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,className:r===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":`Pending comments`,disabled:u===0,children:[r===`compact`?(0,q.jsx)(Qb,{className:`h-4 w-4`}):(0,q.jsx)(`span`,{children:`Pending comments`}),(0,q.jsx)(Z,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:u}),(0,q.jsx)(m_,{className:`h-4 w-4`})]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,q.jsxs)(Gg,{className:`flex-row items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Kg,{children:`Pending comments`}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review preview comments before sending them back to the agent.`})]}),(0,q.jsx)(Z,{variant:`outline`,children:u})]}),u===0?(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`No preview comments queued yet.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:n.map(e=>(0,q.jsx)(LD,{comment:e,onRemoveComment:s},e.id))}),(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-end gap-2 border-t border-border/70 pt-4`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,children:`Clear all`}),(0,q.jsxs)(Y,{type:`button`,size:`sm`,disabled:!t,title:i??void 0,onClick:l,children:[a?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):null,(0,q.jsx)(`span`,{children:a?`Sending...`:`Send fixes (${u})`})]})]})]})]})]})},zD=({comment:e,composerRef:t,disabled:n,mode:r,onAddComment:i,onCancel:a,onCommentChange:o,position:s,target:c})=>{let l=(0,b.useRef)(null),u=AD(c);return(0,b.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[]),(0,q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[85]`,"aria-live":`polite`,children:(0,q.jsxs)(`div`,{ref:t,className:`pointer-events-auto fixed w-80 max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl border border-border/80 bg-background/95 p-4 shadow-2xl shadow-black/40 backdrop-blur`,style:{left:`${s.left}px`,top:`${s.top}px`},children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`min-w-0`,children:(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:r===`edit`?`Edit preview comment`:`Add preview comment`})}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close preview comment composer`,onClick:a,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]}),(0,q.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/70 bg-background/50 px-3 py-3 text-xs`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:u.kindLabel}),u.detail&&(0,q.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-muted-foreground`,children:u.detail})]}),(0,q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,q.jsx)(Og,{ref:l,"aria-label":`Preview comment`,className:`min-h-28 resize-none`,placeholder:`Describe the change you want here.`,value:e,onChange:e=>o(e.target.value)}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:n,onClick:i,children:r===`edit`?`Save comment`:`Add comment`})]})]})]})})},BD=({project:e,mode:t,status:n,viewportPreset:r,zoom:i,activeRun:a=null,reviewCapability:o=null,isStoppingActiveRun:s=!1,onHide:c,onStopActiveRun:l=()=>{},onToggleExpanded:u,onViewportPresetChange:d,onZoomChange:f})=>{let p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useRef)(null),v=(0,b.useRef)(null),y=(0,b.useRef)(!1),x=(0,b.useRef)(null),S=(0,b.useRef)(null),C=(0,b.useRef)(null),[w,T]=(0,b.useState)(0),[E,D]=(0,b.useState)(!1),[O,k]=(0,b.useState)(null),[A,j]=(0,b.useState)(null),[M,N]=(0,b.useState)(``),[P,F]=(0,b.useState)({width:pD,height:mD}),[I,L]=(0,b.useState)([]),[R,z]=(0,b.useState)(!1),[ee,B]=(0,b.useState)(!1),[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(!1),ne=(0,b.useMemo)(()=>n?.proxy_url??null,[n?.proxy_url]),W=(0,b.useMemo)(()=>{if(!ne)return`*`;try{return new URL(ne).origin}catch{return`*`}},[ne]),re=(0,b.useMemo)(()=>n?.detected_url??n?.proxy_url??null,[n?.detected_url,n?.proxy_url]),ie=r===`responsive`?null:cD[r],ae=uD.find(e=>e.value===r)?.label??`Responsive`,G=lD.findIndex(e=>e===i),oe=r===`responsive`,se=!oe&&G>0,ce=!oe&&G>=0&&G<lD.length-1,le=t===`expanded`,{mode:ue,ref:de}=Zb({compactAt:le?860:700,tightAt:le?680:520}),K=a!==null,fe=I.length,pe=(0,b.useMemo)(()=>wD(o),[o]),me=(0,b.useMemo)(()=>nx({projectId:e.id,reviewCapabilityContextKey:pe}),[e.id,pe]),he=(0,b.useMemo)(()=>O?ED(O.anchorRect,P):null,[P,O]),ge=(0,b.useMemo)(()=>CD({previewUrl:ne,reviewCapability:o,status:n}),[ne,o,n]),_e=!!o?.submitPrompt&&fe>0&&!ee,ve=V?`compact`:`full`,ye=A?`edit`:`add`,be=(0,b.useMemo)(()=>I.map(e=>({id:e.id,pagePath:e.pagePath,selectorHint:e.selectorHint})),[I]),xe=(0,b.useCallback)(e=>{h.current=e,de(e)},[de]),Se=(0,b.useCallback)(()=>{let e=p.current;if(e)try{e.src=`about:blank`}catch{}},[]),Ce=(0,b.useCallback)(e=>{p.current?.contentWindow&&p.current.contentWindow.postMessage({source:fD,...e},W)},[W]),we=(0,b.useCallback)(()=>{Ce({type:`sync-comments`,comments:be})},[be,Ce]),Te=(0,b.useCallback)(e=>I.find(t=>MD(e,t))??null,[I]),Ee=(0,b.useCallback)(()=>{k(null),j(null),N(``),Ce({type:`clear-selection`})},[Ce]),De=(0,b.useCallback)((e={})=>{let{resetIframe:t=!1,bumpIframeKey:n=!1}=e;D(!1),k(null),j(null),N(``),z(!1),Ce({type:`clear-selection`}),Ce({type:`set-enabled`,enabled:!1}),t&&(Se(),n&&T(e=>e+1))},[Se,Ce]),Oe=(0,b.useCallback)(()=>{De()},[De]),ke=(0,b.useCallback)(()=>{De(),L([])},[De]);(0,b.useEffect)(()=>{ge!==null&&E&&Oe()},[Oe,ge,E]),(0,b.useEffect)(()=>{let e=ax(me);L(t=>ix(t,e)?t:e)},[me]),(0,b.useEffect)(()=>{ox({contextKey:me,drafts:I})},[I,me]),(0,b.useEffect)(()=>{we()},[we]),(0,b.useEffect)(()=>{y.current=E},[E]),(0,b.useEffect)(()=>{x.current=O},[O]),(0,b.useEffect)(()=>{I.length>0||z(!1)},[I.length]);let Ae=(0,b.useRef)({contextKey:a?.context_key??null,previewUrl:ne,state:n?.state??null});(0,b.useEffect)(()=>{let e=Ae.current,t={contextKey:a?.context_key??null,previewUrl:ne,state:n?.state??null},r=e.contextKey!==null&&e.contextKey!==t.contextKey,i=e.previewUrl!==null&&e.previewUrl!==t.previewUrl,o=e.state===`ready`&&t.state!==`ready`;(r||i||o)&&De({resetIframe:!0,bumpIframeKey:r||i}),Ae.current=t},[a?.context_key,De,ne,n?.state]),(0,b.useEffect)(()=>()=>{Se()},[Se]),(0,b.useLayoutEffect)(()=>{let e=h.current,t=g.current,n=_.current,r=v.current;if(!e||!t||!n||!r)return;let i=()=>{let i=Math.round(e.getBoundingClientRect().width),a=Math.round(r.getBoundingClientRect().width),o=Array.from(t.children).filter(e=>e instanceof HTMLElement),s=o.reduce((e,t)=>t===n?e:e+Math.round(t.getBoundingClientRect().width),0),c=ND(n,yD),l=s+c+Math.max(0,o.length-1)*vD;if(i<=0||a<=0||c<=0){let e=ue!==`wide`,t=ue===`tight`;H(t=>t===e?t:e),U(e=>e===t?e:t);return}V?C.current=a:S.current=a;let u=a,d=S.current??u,f=C.current??u,p=Math.max(0,i-d-_D),m=Math.max(0,i-f-_D),h=l>p,g=h&&C.current!==null&&l>m;H(e=>e===h?e:h),U(e=>e===g?e:g)};if(i(),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(()=>{i()});return a.observe(e),a.observe(t),a.observe(n),a.observe(r),Array.from(t.children).forEach(e=>{e instanceof HTMLElement&&a.observe(e)}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&a.observe(e)}),()=>{a.disconnect()}},[ue,V]),(0,b.useLayoutEffect)(()=>{if(!O||!m.current)return;let e=()=>{if(!m.current)return;let e=m.current.getBoundingClientRect(),t=Math.max(pD,Math.ceil(e.width)||pD),n=Math.max(1,window.innerHeight-gD*2),r=Math.ceil(e.height)||mD,i=Math.min(r,n);F(e=>e.width===t&&e.height===i?e:{width:t,height:i})};e();let t=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{e()});return t?.observe(m.current),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t?.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[M,O]),(0,b.useEffect)(()=>{let e=e=>{let t=e.source===p.current?.contentWindow,n=W!==`*`&&e.origin===W;if(!t&&!n||!e.data||typeof e.data!=`object`)return;let r=e.data;if(r.source!==dD)return;let i=r.type;if(i!==`element-selected`&&i!==`comment-marker-clicked`||i===`element-selected`&&(!y.current||!p.current)||!p.current||i===`element-selected`&&x.current)return;let a=r.payload;if(!a||typeof a!=`object`)return;let o=a,s=Te(o);k({...o,anchorRect:TD(p.current,o)}),j(s?.id??null),N(s?.comment??``)};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[Te,W]);let je=(0,b.useCallback)(()=>{k(null),j(null),N(``),Ce({type:`clear-selection`}),Ce({type:`sync-comments`,comments:be}),E&&ge===null&&Ce({type:`set-enabled`,enabled:!0})},[be,Ce,ge,E]),Me=(0,b.useCallback)(()=>{if(ge===null){if(E){Oe();return}D(!0),Ce({type:`set-enabled`,enabled:!0})}},[Oe,Ce,ge,E]),Ne=(0,b.useCallback)(()=>{De(),T(e=>e+1)},[De]),Pe=(0,b.useCallback)(()=>{De({resetIframe:!0}),c()},[De,c]),Fe=(0,b.useCallback)(()=>{De({resetIframe:!0,bumpIframeKey:!0}),l()},[De,l]),Ie=(0,b.useCallback)(()=>{if(!O)return;let e=M.trim();e&&(L(t=>{let n=t.find(e=>e.id===A||MD(O,e)),r={id:n?.id??SD(),pagePath:O.pagePath,pageUrl:O.pageUrl,elementLabel:O.elementLabel,selectorHint:O.selectorHint,textSnippet:O.textSnippet,href:O.href,src:O.src,comment:e};return n?t.map(e=>e.id===n.id?r:e):[...t,r]}),Ee())},[Ee,M,A,O]),Le=(0,b.useCallback)(e=>{A===e&&Ee(),L(t=>t.filter(t=>t.id!==e))},[Ee,A]),Re=(0,b.useCallback)(async()=>{if(!(!o?.submitPrompt||!_e)){B(!0);try{await o.submitPrompt(sD({drafts:[],findings:[],githubComments:[],previewComments:I})),ke(),X.success(`Fixes submitted.`,{id:`preview-review-submit-success`})}catch(e){X.error(e instanceof Error?e.message:`Unable to submit the preview review right now.`,{id:`preview-review-submit-error`})}finally{B(!1)}}},[_e,I,ke,o]),ze=n?n.state===`ready`?ne?(0,q.jsx)(FD,{iframeKey:w,iframeRef:p,iframeSrc:ne,onLoad:je,preset:ie,zoom:i}):(0,q.jsx)(PD,{title:`Preview error`,description:`Archon did not provide a preview URL for the active run.`}):n.state===`detecting`?(0,q.jsx)(PD,{title:`Detecting preview`,description:n.message??`Waiting for the preview service to report a browser URL.`,showSpinner:!0}):n.state===`unsupported`?(0,q.jsx)(PD,{title:`Preview unavailable`,description:n.message??`This run cannot be embedded as an in-app preview.`}):n.state===`error`?(0,q.jsx)(PD,{title:`Preview error`,description:n.message??`Archon could not load the current preview target.`}):(0,q.jsx)(PD,{title:`Preview idle`,description:n.message??`Start a run to load the in-app preview.`}):(0,q.jsx)(PD,{title:`Loading preview`,description:`Archon is loading the current preview state for this project.`,showSpinner:!0});return(0,q.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col overflow-hidden bg-[#11131a] ${le?`rounded-2xl border border-border/70 shadow-2xl shadow-black/50`:``}`,children:[(0,q.jsxs)(`div`,{ref:xe,"data-responsive-mode":ue,"data-testid":`project-preview-header`,className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-2 border-b border-border/70 px-3 py-3`,children:[(0,q.jsxs)(`div`,{ref:g,"data-testid":`preview-header-flow`,className:J(`flex min-w-0 items-center gap-2`,te?`flex-wrap`:`flex-nowrap`),children:[(0,q.jsx)(t_,{label:``,triggerLabel:ae,triggerAriaLabel:`Preview viewport preset`,selectId:`preview-viewport-preset`,className:`w-[10.5rem] max-w-full shrink-0`,triggerClassName:`h-8 rounded-lg border-border/70 bg-background/70 px-2.5 text-xs`,contentClassName:`min-w-[10.5rem]`,groups:[{label:``,options:uD}],isSelected:e=>r===e,onSelect:e=>{(e===`responsive`||e===`phone`||e===`tablet`||e===`laptop`)&&d(e)}}),(0,q.jsxs)(`div`,{"data-testid":`preview-zoom-controls`,className:`flex shrink-0 items-center gap-1 rounded-lg border border-border/70 bg-background/50 p-1`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:!se,className:`h-6 px-2 text-xs`,onClick:()=>{G>0&&f(lD[G-1]??i)},children:`-`}),(0,q.jsxs)(`span`,{className:`min-w-12 text-center text-xs text-muted-foreground`,children:[Math.round(i*100),`%`]}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:!ce,className:`h-6 px-2 text-xs`,onClick:()=>{G>=0&&G<lD.length-1&&f(lD[G+1]??i)},children:`+`})]}),(0,q.jsxs)(`div`,{ref:_,"data-testid":`preview-action-chunk`,"data-action-chunk-wrapped":te?`true`:`false`,className:J(`flex shrink-0 items-center gap-2`,te&&`basis-full justify-start`),children:[(0,q.jsx)(ID,{type:`button`,"aria-label":`Reload preview`,tooltip:`Reload`,size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,onClick:Ne,children:(0,q.jsx)(Ky,{className:`h-4 w-4`})}),(0,q.jsx)(ID,{type:`button`,"aria-label":`Open preview in new tab`,tooltip:`Open in new tab`,size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,disabled:!re,onClick:()=>{re&&window.open(re,`_blank`,`noopener,noreferrer`)},children:(0,q.jsx)($b,{className:`h-4 w-4`})}),(0,q.jsx)(ID,{type:`button`,"aria-label":`Toggle preview selection mode`,"aria-pressed":E,"data-testid":`preview-selection-toggle`,tooltip:ge??(E?`Disable selection mode`:`Enable selection mode`),size:`icon-sm`,variant:`outline`,className:E?`h-8 w-8 border-sky-500 bg-sky-500 text-white hover:bg-sky-600 hover:text-white`:`h-8 w-8`,disabled:ge!==null,onClick:Me,children:(0,q.jsx)(ex,{className:`h-4 w-4`})}),K&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Stop preview run`,variant:`destructive`,size:`sm`,className:`h-8 gap-2 px-3`,disabled:s,onClick:Fe,children:[s?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:s?`Stopping...`:`Stop`})]})]})]}),(0,q.jsxs)(`div`,{ref:v,"data-testid":`preview-anchor-actions`,className:`flex shrink-0 items-center gap-2 justify-self-end`,children:[(0,q.jsx)(`div`,{className:`min-w-0`,children:(0,q.jsx)(RD,{isOpen:R,canSendReview:_e,comments:I,triggerMode:ve,disabledReason:o?.disabledReason,isSubmittingReview:ee,onOpenChange:z,onRemoveComment:Le,onClearPendingFixes:ke,onSubmitReview:()=>{Re()}})}),(0,q.jsx)(ID,{type:`button`,"aria-label":le?`Collapse preview`:`Expand preview`,tooltip:le?`Collapse`:`Expand`,size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,onClick:u,children:le?(0,q.jsx)(Ny,{className:`h-4 w-4`}):(0,q.jsx)(Py,{className:`h-4 w-4`})}),(0,q.jsx)(ID,{type:`button`,"aria-label":`Close preview`,tooltip:`Close`,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,onClick:Pe,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1`,children:ze}),O&&he&&(0,q.jsx)(zD,{comment:M,composerRef:m,disabled:M.trim().length===0,mode:ye,onAddComment:Ie,onCancel:Ee,onCommentChange:N,position:he,target:O})]})},VD=(e,t)=>O(C(`/projects/${e}/chat-sessions`),{signal:t,fallbackErrorMessage:`Unable to load chat sessions right now.`}),HD=(e,t)=>O(C(`/projects/${e}/chat-sessions`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create a chat session right now.`}),UD=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}`),{signal:n,fallbackErrorMessage:`Unable to load the chat session right now.`}),WD=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}`),{method:`PATCH`,body:n,fallbackErrorMessage:`Unable to update the chat session right now.`}),GD=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}/messages`),{method:`POST`,body:n,fallbackErrorMessage:`Unable to send the chat prompt right now.`}),KD=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}/stop`),{method:`POST`,fallbackErrorMessage:`Unable to interrupt the chat response right now.`}),qD=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}`),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the chat session right now.`}),JD=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}/diff`),{fallbackErrorMessage:`Unable to load the chat diff right now.`}),YD=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}/git-status`),{fallbackErrorMessage:`Unable to load the chat git status right now.`}),XD=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}/messages/${n}/create-tickets`),{method:`POST`,fallbackErrorMessage:`Unable to create tickets from the chat proposal right now.`}),ZD=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function QD(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function $D(e){return`nodeType`in e}function eO(e){return e?QD(e)?e:$D(e)?e.ownerDocument?.defaultView??window:window:window}function tO(e){let{Document:t}=eO(e);return e instanceof t}function nO(e){return QD(e)?!1:e instanceof eO(e).HTMLElement}function rO(e){return e instanceof eO(e).SVGElement}function iO(e){return e?QD(e)?e.document:$D(e)?tO(e)?e:nO(e)||rO(e)?e.ownerDocument:document:document:document}var aO=ZD?b.useLayoutEffect:b.useEffect;function oO(e){let t=(0,b.useRef)(e);return aO(()=>{t.current=e}),(0,b.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function sO(){let e=(0,b.useRef)(null);return[(0,b.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,b.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function cO(e,t){t===void 0&&(t=[e]);let n=(0,b.useRef)(e);return aO(()=>{n.current!==e&&(n.current=e)},t),n}function lO(e,t){let n=(0,b.useRef)();return(0,b.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function uO(e){let t=oO(e),n=(0,b.useRef)(null);return[n,(0,b.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function dO(e){let t=(0,b.useRef)();return(0,b.useEffect)(()=>{t.current=e},[e]),t.current}var fO={};function pO(e,t){return(0,b.useMemo)(()=>{if(t)return t;let n=fO[e]==null?0:fO[e]+1;return fO[e]=n,e+`-`+n},[e,t])}function mO(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var hO=mO(1),gO=mO(-1);function _O(e){return`clientX`in e&&`clientY`in e}function vO(e){if(!e)return!1;let{KeyboardEvent:t}=eO(e.target);return t&&e instanceof t}function yO(e){if(!e)return!1;let{TouchEvent:t}=eO(e.target);return t&&e instanceof t}function bO(e){if(yO(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return _O(e)?{x:e.clientX,y:e.clientY}:null}var xO=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[xO.Translate.toString(e),xO.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),SO=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function CO(e){return e.matches(SO)?e:e.querySelector(SO)}var wO={display:`none`};function TO(e){let{id:t,value:n}=e;return b.createElement(`div`,{id:t,style:wO},n)}function EO(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return b.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function DO(){let[e,t]=(0,b.useState)(``);return{announce:(0,b.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var OO=(0,b.createContext)(null);function kO(e){let t=(0,b.useContext)(OO);(0,b.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function AO(){let[e]=(0,b.useState)(()=>new Set),t=(0,b.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,b.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var jO={draggable:`
91
+ `).trim()},TD={phone:{label:`Phone`,width:390,height:844},tablet:{label:`Tablet`,width:768,height:1024},laptop:{label:`Laptop`,width:1440,height:900}},ED=[.5,.75,1,1.25],DD=[{value:`responsive`,label:`Responsive`},{value:`phone`,label:`Phone`},{value:`tablet`,label:`Tablet`},{value:`laptop`,label:`Laptop`}],OD=`archon-preview-selection`,kD=`archon-preview-selection-parent`,AD=320,jD=248,MD=12,ND=16,PD=12,FD=8,ID=8,LD=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`preview-review-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,RD=({previewUrl:e,reviewCapability:t,status:n})=>t&&!t.canSelect?t.disabledReason:t?.submitPrompt?n?.state!==`ready`||!e?`Wait for the preview to finish loading first.`:null:`Preview selection is only available for build-capable ticket runs.`,zD=e=>e?.target?`${e.target.kind}:${e.target.id}`:null,BD=(e,t)=>{let n=e.getBoundingClientRect(),r=t.viewport.width>0?n.width/t.viewport.width:1,i=t.viewport.height>0?n.height/t.viewport.height:1;return{left:n.left+t.bounds.left*r,top:n.top+t.bounds.top*i,width:t.bounds.width*r,height:t.bounds.height*i}},VD=(e,t)=>{let n=t.width,r=t.height,i=e.left+e.width+MD,a=i+n<=window.innerWidth-ND,o=e.left-n-MD,s=Math.max(ND,window.innerWidth-n-ND),c=a?i:o>=ND?o:Math.min(Math.max(ND,e.left),s),l=Math.max(ND,e.top),u=Math.max(ND,window.innerHeight-r-ND);return{left:c,top:l+r<=window.innerHeight-ND?l:Math.max(ND,Math.min(e.top+e.height-r,u))}},HD=e=>{if(!e)return null;let t=e.replace(/\s+/g,` `).trim();return t.length>0?t:null},UD=(e,t=96)=>{if(e.length<=t)return e;let n=e.slice(0,t+1),r=n.lastIndexOf(` `);return`${(r>Math.floor(t*.6)?n.slice(0,r):n.slice(0,t)).trimEnd()}...`},WD=({elementLabel:e,textSnippet:t})=>{let n=e.match(/^[a-z0-9-]+/i)?.[0]?.toLowerCase()??null;return n?`<${n}>`:t?`Element`:`Unknown element`},GD=e=>{let t=HD(e.textSnippet);return{kindLabel:WD({elementLabel:e.elementLabel,textSnippet:t}),detail:t?UD(t):null}},KD=({pagePath:e,selectorHint:t})=>`${e}::${t}`,qD=(e,t)=>KD(e)===KD(t),JD=(e,t)=>{let n=Array.from(e.children).filter(e=>e instanceof HTMLElement);return n.length===0?0:n.reduce((e,t)=>e+Math.round(t.getBoundingClientRect().width),0)+(n.length-1)*t},YD=({title:e,description:t,showSpinner:n=!1})=>(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,q.jsxs)(`div`,{className:`max-w-sm rounded-2xl border border-border/70 bg-background/70 p-5 text-center shadow-lg shadow-black/20`,children:[n&&(0,q.jsx)(C_,{className:`mx-auto mb-3 h-5 w-5 animate-spin text-muted-foreground`}),(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:t})]})}),XD=({iframeKey:e,iframeRef:t,iframeSrc:n,onLoad:r,preset:i,zoom:a})=>{let o=i===null,s=i?{"--preview-width":`${i.width}px`,"--preview-height":`${i.height}px`,"--preview-scale":`${a}`,"--preview-scaled-width":`${Math.round(i.width*a)}px`,"--preview-scaled-height":`${Math.round(i.height*a)}px`}:void 0;return(0,q.jsx)(`div`,{className:o?`flex h-full min-h-0 flex-col p-4`:`flex h-full min-h-0 items-start justify-center overflow-auto p-6`,children:(0,q.jsx)(`div`,{className:o?`min-h-0 flex-1`:`w-[var(--preview-scaled-width)]`,style:s,children:(0,q.jsx)(`div`,{className:o?`h-full min-h-0 overflow-hidden bg-white shadow-2xl shadow-black/20`:`h-[var(--preview-scaled-height)] w-[var(--preview-scaled-width)] overflow-hidden rounded-[1.5rem] border border-border/80 bg-white shadow-2xl shadow-black/30`,children:(0,q.jsx)(`iframe`,{ref:t,src:n,sandbox:`allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts`,title:`Project preview`,className:o?`h-full w-full border-0 bg-white`:`h-[var(--preview-height)] w-[var(--preview-width)] origin-top-left scale-[var(--preview-scale)] border-0 bg-white`,onLoad:r},e)})})})},ZD=({tooltip:e,children:t,...n})=>(0,q.jsx)(u_,{content:e,side:`bottom`,children:(0,q.jsx)(`span`,{className:`inline-flex`,children:(0,q.jsx)(Y,{...n,children:t})})}),QD=({comment:e,onRemoveComment:t})=>{let n=GD(e);return(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(dx,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:n.kindLabel}),n.detail&&(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:n.detail}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.comment})]}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5 h-7 w-7 flex-shrink-0 text-muted-foreground hover:text-foreground`,"aria-label":`Delete pending comment for ${e.elementLabel}`,onClick:()=>t(e.id),children:(0,q.jsx)(qv,{className:`h-4 w-4`})})]})})},$D=({isOpen:e,canSendReview:t,comments:n,triggerMode:r=`full`,disabledReason:i,isSubmittingReview:a,onOpenChange:o,onRemoveComment:s,onClearPendingFixes:c,onSubmitReview:l})=>{let u=n.length;return(0,q.jsxs)(Hg,{open:e,onOpenChange:o,children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,className:r===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":`Pending comments`,disabled:u===0,children:[r===`compact`?(0,q.jsx)(dx,{className:`h-4 w-4`}):(0,q.jsx)(`span`,{children:`Pending comments`}),(0,q.jsx)(Z,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:u}),(0,q.jsx)(m_,{className:`h-4 w-4`})]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,q.jsxs)(Gg,{className:`flex-row items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Kg,{children:`Pending comments`}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review preview comments before sending them back to the agent.`})]}),(0,q.jsx)(Z,{variant:`outline`,children:u})]}),u===0?(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`No preview comments queued yet.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:n.map(e=>(0,q.jsx)(QD,{comment:e,onRemoveComment:s},e.id))}),(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-end gap-2 border-t border-border/70 pt-4`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,children:`Clear all`}),(0,q.jsxs)(Y,{type:`button`,size:`sm`,disabled:!t,title:i??void 0,onClick:l,children:[a?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):null,(0,q.jsx)(`span`,{children:a?`Sending...`:`Send fixes (${u})`})]})]})]})]})]})},eO=e=>e?.promptPlaceholder?e.promptPlaceholder:e?.target?.kind===`bundle`?`Follow up on this bundle`:e?.target?.kind===`ticket`?`Follow up on this ticket`:`Describe what Archon should do next.`,tO=({comment:e,composerRef:t,disabled:n,mode:r,onAddComment:i,onCancel:a,onCommentChange:o,position:s,target:c})=>{let l=(0,b.useRef)(null),u=GD(c);return(0,b.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[]),(0,q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[85]`,"aria-live":`polite`,children:(0,q.jsxs)(`div`,{ref:t,className:`pointer-events-auto fixed w-80 max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl border border-border/80 bg-background/95 p-4 shadow-2xl shadow-black/40 backdrop-blur`,style:{left:`${s.left}px`,top:`${s.top}px`},children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`min-w-0`,children:(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:r===`edit`?`Edit preview comment`:`Add preview comment`})}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close preview comment composer`,onClick:a,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]}),(0,q.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/70 bg-background/50 px-3 py-3 text-xs`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:u.kindLabel}),u.detail&&(0,q.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-muted-foreground`,children:u.detail})]}),(0,q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,q.jsx)(Og,{ref:l,"aria-label":`Preview comment`,className:`min-h-28 resize-none`,placeholder:`Describe the change you want here.`,value:e,onChange:e=>o(e.target.value)}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:n,onClick:i,children:r===`edit`?`Save comment`:`Add comment`})]})]})]})})},nO=({project:e,mode:t,status:n,viewportPreset:r,zoom:i,activeRun:a=null,reviewCapability:o=null,isStoppingActiveRun:s=!1,onHide:c,onStopActiveRun:l=()=>{},onToggleExpanded:u,onViewportPresetChange:d,onZoomChange:f})=>{let p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useRef)(null),v=(0,b.useRef)(null),y=(0,b.useRef)(null),x=(0,b.useRef)(!1),S=(0,b.useRef)(null),C=(0,b.useRef)(null),w=(0,b.useRef)(null),[T,E]=(0,b.useState)(0),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)({width:AD,height:jD}),[L,R]=(0,b.useState)([]),[z,ee]=(0,b.useState)(!1),[B,V]=(0,b.useState)(!1),[H,te]=(0,b.useState)(!1),[U,ne]=(0,b.useState)(``),[W,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(!1),[G,oe]=(0,b.useState)(!1),se=(0,b.useMemo)(()=>n?.proxy_url??null,[n?.proxy_url]),ce=(0,b.useMemo)(()=>{if(!se)return`*`;try{return new URL(se).origin}catch{return`*`}},[se]),le=(0,b.useMemo)(()=>n?.detected_url??n?.proxy_url??null,[n?.detected_url,n?.proxy_url]),ue=r===`responsive`?null:TD[r],de=DD.find(e=>e.value===r)?.label??`Responsive`,K=ED.findIndex(e=>e===i),fe=r===`responsive`,pe=!fe&&K>0,me=!fe&&K>=0&&K<ED.length-1,he=t===`expanded`,{mode:ge,ref:_e}=Zb({compactAt:he?860:700,tightAt:he?680:520}),ve=a!==null,ye=L.length,be=(0,b.useMemo)(()=>zD(o),[o]),xe=(0,b.useMemo)(()=>hx({projectId:e.id,reviewCapabilityContextKey:be}),[e.id,be]),Se=(0,b.useMemo)(()=>k?VD(k.anchorRect,F):null,[F,k]),Ce=(0,b.useMemo)(()=>RD({previewUrl:se,reviewCapability:o,status:n}),[se,o,n]),we=!!o?.submitPrompt&&ye>0&&!B&&!W,Te=ie?`compact`:`full`,Ee=j?`edit`:`add`,De=(0,b.useMemo)(()=>eO(o),[o]),Oe=!!o?.target,ke=o?.promptMode??null,Ae=!!o?.submitPrompt&&!W&&!B,je=(0,b.useMemo)(()=>L.map(e=>({id:e.id,pagePath:e.pagePath,selectorHint:e.selectorHint})),[L]),Me=(0,b.useCallback)(e=>{g.current=e,_e(e)},[_e]),Ne=(0,b.useCallback)(()=>{let e=p.current;if(e)try{e.src=`about:blank`}catch{}},[]),Pe=(0,b.useCallback)(e=>{p.current?.contentWindow&&p.current.contentWindow.postMessage({source:kD,...e},ce)},[ce]),Fe=(0,b.useCallback)(()=>{Pe({type:`sync-comments`,comments:je})},[je,Pe]),Ie=(0,b.useCallback)(e=>L.find(t=>qD(e,t))??null,[L]),Le=(0,b.useCallback)(()=>{A(null),M(null),P(``),Pe({type:`clear-selection`})},[Pe]),Re=(0,b.useCallback)((e={})=>{let{resetIframe:t=!1,bumpIframeKey:n=!1}=e;O(!1),A(null),M(null),P(``),ee(!1),Pe({type:`clear-selection`}),Pe({type:`set-enabled`,enabled:!1}),t&&(Ne(),n&&E(e=>e+1))},[Ne,Pe]),ze=(0,b.useCallback)(()=>{Re()},[Re]),Be=(0,b.useCallback)(()=>{Re(),R([])},[Re]);(0,b.useEffect)(()=>{Ce!==null&&D&&ze()},[ze,Ce,D]),(0,b.useEffect)(()=>{let e=vx(xe);R(t=>_x(t,e)?t:e)},[xe]),(0,b.useEffect)(()=>{yx({contextKey:xe,drafts:L})},[L,xe]),(0,b.useEffect)(()=>{Fe()},[Fe]),(0,b.useEffect)(()=>{x.current=D},[D]),(0,b.useEffect)(()=>{S.current=k},[k]),(0,b.useEffect)(()=>{L.length>0||ee(!1)},[L.length]),(0,b.useEffect)(()=>{he||te(!1)},[he]),(0,b.useEffect)(()=>{Oe||te(!1)},[Oe]),(0,b.useEffect)(()=>{ne(``),re(!1)},[be]),(0,b.useEffect)(()=>{let e=h.current;if(!e||!he||!H)return;let t=requestAnimationFrame(()=>{e.focus(),Cx(e)});return()=>{cancelAnimationFrame(t)}},[he,H]),(0,b.useEffect)(()=>{let e=h.current;!e||!he||!H||Cx(e)},[he,H,U]);let Ve=(0,b.useRef)({contextKey:a?.context_key??null,previewUrl:se,state:n?.state??null});(0,b.useEffect)(()=>{let e=Ve.current,t={contextKey:a?.context_key??null,previewUrl:se,state:n?.state??null},r=e.contextKey!==null&&e.contextKey!==t.contextKey,i=e.previewUrl!==null&&e.previewUrl!==t.previewUrl,o=e.state===`ready`&&t.state!==`ready`;(r||i||o)&&Re({resetIframe:!0,bumpIframeKey:r||i}),Ve.current=t},[a?.context_key,Re,se,n?.state]),(0,b.useEffect)(()=>()=>{Ne()},[Ne]),(0,b.useLayoutEffect)(()=>{let e=g.current,t=_.current,n=v.current,r=y.current;if(!e||!t||!n||!r)return;let i=()=>{let i=Math.round(e.getBoundingClientRect().width),a=Math.round(r.getBoundingClientRect().width),o=Array.from(t.children).filter(e=>e instanceof HTMLElement),s=o.reduce((e,t)=>t===n?e:e+Math.round(t.getBoundingClientRect().width),0),c=JD(n,ID),l=s+c+Math.max(0,o.length-1)*FD;if(i<=0||a<=0||c<=0){let e=ge!==`wide`,t=ge===`tight`;ae(t=>t===e?t:e),oe(e=>e===t?e:t);return}ie?w.current=a:C.current=a;let u=a,d=C.current??u,f=w.current??u,p=Math.max(0,i-d-PD),m=Math.max(0,i-f-PD),h=l>p,g=h&&w.current!==null&&l>m;ae(e=>e===h?e:h),oe(e=>e===g?e:g)};if(i(),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(()=>{i()});return a.observe(e),a.observe(t),a.observe(n),a.observe(r),Array.from(t.children).forEach(e=>{e instanceof HTMLElement&&a.observe(e)}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&a.observe(e)}),()=>{a.disconnect()}},[ge,ie]),(0,b.useLayoutEffect)(()=>{if(!k||!m.current)return;let e=()=>{if(!m.current)return;let e=m.current.getBoundingClientRect(),t=Math.max(AD,Math.ceil(e.width)||AD),n=Math.max(1,window.innerHeight-ND*2),r=Math.ceil(e.height)||jD,i=Math.min(r,n);I(e=>e.width===t&&e.height===i?e:{width:t,height:i})};e();let t=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{e()});return t?.observe(m.current),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t?.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[N,k]),(0,b.useEffect)(()=>{let e=e=>{let t=e.source===p.current?.contentWindow,n=ce!==`*`&&e.origin===ce;if(!t&&!n||!e.data||typeof e.data!=`object`)return;let r=e.data;if(r.source!==OD)return;let i=r.type;if(i!==`element-selected`&&i!==`comment-marker-clicked`||i===`element-selected`&&(!x.current||!p.current)||!p.current||i===`element-selected`&&S.current)return;let a=r.payload;if(!a||typeof a!=`object`)return;let o=a,s=Ie(o);A({...o,anchorRect:BD(p.current,o)}),M(s?.id??null),P(s?.comment??``)};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[Ie,ce]);let He=(0,b.useCallback)(()=>{A(null),M(null),P(``),Pe({type:`clear-selection`}),Pe({type:`sync-comments`,comments:je}),D&&Ce===null&&Pe({type:`set-enabled`,enabled:!0})},[je,Pe,Ce,D]),Ue=(0,b.useCallback)(()=>{if(Ce===null){if(D){ze();return}O(!0),Pe({type:`set-enabled`,enabled:!0})}},[ze,Pe,Ce,D]),We=(0,b.useCallback)(()=>{Re(),E(e=>e+1)},[Re]),Ge=(0,b.useCallback)(()=>{Re({resetIframe:!0}),c()},[Re,c]),Ke=(0,b.useCallback)(()=>{Re({resetIframe:!0,bumpIframeKey:!0}),l()},[Re,l]),qe=(0,b.useCallback)(()=>{if(!k)return;let e=N.trim();e&&(R(t=>{let n=t.find(e=>e.id===j||qD(k,e)),r={id:n?.id??LD(),pagePath:k.pagePath,pageUrl:k.pageUrl,elementLabel:k.elementLabel,selectorHint:k.selectorHint,textSnippet:k.textSnippet,href:k.href,src:k.src,comment:e};return n?t.map(e=>e.id===n.id?r:e):[...t,r]}),Le())},[Le,N,j,k]),Je=(0,b.useCallback)(e=>{j===e&&Le(),R(t=>t.filter(t=>t.id!==e))},[Le,j]),Ye=(0,b.useCallback)(async()=>{if(!(!o?.submitPrompt||!we)){V(!0);try{await o.submitPrompt(wD({drafts:[],findings:[],githubComments:[],previewComments:L})),Be(),X.success(`Fixes submitted.`,{id:`preview-review-submit-success`})}catch(e){X.error(e instanceof Error?e.message:`Unable to submit the preview review right now.`,{id:`preview-review-submit-error`})}finally{V(!1)}}},[we,L,Be,o]),Xe=(0,b.useCallback)(async()=>{if(!o?.submitPrompt||!Ae)return;let e=U.trim();if(e){re(!0);try{await o.submitPrompt(e),ne(``),X.success(`Prompt sent.`,{id:`preview-prompt-submit-success`})}catch(e){X.error(e instanceof Error?e.message:`Unable to send the preview prompt right now.`,{id:`preview-prompt-submit-error`})}finally{re(!1)}}},[Ae,U,o]),Ze=(0,b.useCallback)(e=>{e.key!==`Enter`||e.shiftKey||!Ae||!U.trim()||(e.preventDefault(),Xe())},[Ae,Xe,U]),Qe=n?n.state===`ready`?se?(0,q.jsx)(XD,{iframeKey:T,iframeRef:p,iframeSrc:se,onLoad:He,preset:ue,zoom:i}):(0,q.jsx)(YD,{title:`Preview error`,description:`Archon did not provide a preview URL for the active run.`}):n.state===`detecting`?(0,q.jsx)(YD,{title:`Detecting preview`,description:n.message??`Waiting for the preview service to report a browser URL.`,showSpinner:!0}):n.state===`unsupported`?(0,q.jsx)(YD,{title:`Preview unavailable`,description:n.message??`This run cannot be embedded as an in-app preview.`}):n.state===`error`?(0,q.jsx)(YD,{title:`Preview error`,description:n.message??`Archon could not load the current preview target.`}):(0,q.jsx)(YD,{title:`Preview idle`,description:n.message??`Start a run to load the in-app preview.`}):(0,q.jsx)(YD,{title:`Loading preview`,description:`Archon is loading the current preview state for this project.`,showSpinner:!0});return(0,q.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col overflow-hidden bg-[#11131a] ${he?`rounded-2xl border border-border/70 shadow-2xl shadow-black/50`:``}`,children:[(0,q.jsxs)(`div`,{ref:Me,"data-responsive-mode":ge,"data-testid":`project-preview-header`,className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-2 border-b border-border/70 px-3 py-3`,children:[(0,q.jsxs)(`div`,{ref:_,"data-testid":`preview-header-flow`,className:J(`flex min-w-0 items-center gap-2`,G?`flex-wrap`:`flex-nowrap`),children:[(0,q.jsx)(t_,{label:``,triggerLabel:de,triggerAriaLabel:`Preview viewport preset`,selectId:`preview-viewport-preset`,className:`w-[10.5rem] max-w-full shrink-0`,triggerClassName:`h-8 rounded-lg border-border/70 bg-background/70 px-2.5 text-xs`,contentClassName:`min-w-[10.5rem]`,groups:[{label:``,options:DD}],isSelected:e=>r===e,onSelect:e=>{(e===`responsive`||e===`phone`||e===`tablet`||e===`laptop`)&&d(e)}}),(0,q.jsxs)(`div`,{"data-testid":`preview-zoom-controls`,className:`flex shrink-0 items-center gap-1 rounded-lg border border-border/70 bg-background/50 p-1`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:!pe,className:`h-6 px-2 text-xs`,onClick:()=>{K>0&&f(ED[K-1]??i)},children:`-`}),(0,q.jsxs)(`span`,{className:`min-w-12 text-center text-xs text-muted-foreground`,children:[Math.round(i*100),`%`]}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:!me,className:`h-6 px-2 text-xs`,onClick:()=>{K>=0&&K<ED.length-1&&f(ED[K+1]??i)},children:`+`})]}),(0,q.jsxs)(`div`,{ref:v,"data-testid":`preview-action-chunk`,"data-action-chunk-wrapped":G?`true`:`false`,className:J(`flex shrink-0 items-center gap-2`,G&&`basis-full justify-start`),children:[(0,q.jsx)(ZD,{type:`button`,"aria-label":`Reload preview`,tooltip:`Reload`,size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,onClick:We,children:(0,q.jsx)(Ky,{className:`h-4 w-4`})}),(0,q.jsx)(ZD,{type:`button`,"aria-label":`Open preview in new tab`,tooltip:`Open in new tab`,size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,disabled:!le,onClick:()=>{le&&window.open(le,`_blank`,`noopener,noreferrer`)},children:(0,q.jsx)(fx,{className:`h-4 w-4`})}),(0,q.jsx)(ZD,{type:`button`,"aria-label":`Toggle preview selection mode`,"aria-pressed":D,"data-testid":`preview-selection-toggle`,tooltip:Ce??(D?`Disable selection mode`:`Enable selection mode`),size:`icon-sm`,variant:`outline`,className:D?`h-8 w-8 border-sky-500 bg-sky-500 text-white hover:bg-sky-600 hover:text-white`:`h-8 w-8`,disabled:Ce!==null,onClick:Ue,children:(0,q.jsx)(px,{className:`h-4 w-4`})}),ve&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Stop preview run`,variant:`destructive`,size:`sm`,className:`h-8 gap-2 px-3`,disabled:s,onClick:Ke,children:[s?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:s?`Stopping...`:`Stop`})]})]})]}),(0,q.jsxs)(`div`,{ref:y,"data-testid":`preview-anchor-actions`,className:`flex shrink-0 items-center gap-2 justify-self-end`,children:[he&&Oe?(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,"aria-label":`Toggle preview prompt`,"aria-pressed":H,"data-testid":`preview-prompt-toggle`,className:J(`h-8 gap-2 px-3`,H&&`border-sky-500 bg-sky-500 text-white hover:bg-sky-600 hover:text-white`),onClick:()=>{te(e=>!e)},children:[(0,q.jsx)(dx,{className:`h-4 w-4`}),`Prompt`]}):null,(0,q.jsx)(`div`,{className:`min-w-0`,children:(0,q.jsx)($D,{isOpen:z,canSendReview:we,comments:L,triggerMode:Te,disabledReason:o?.disabledReason,isSubmittingReview:B,onOpenChange:ee,onRemoveComment:Je,onClearPendingFixes:Be,onSubmitReview:()=>{Ye()}})}),(0,q.jsx)(ZD,{type:`button`,"aria-label":he?`Collapse preview`:`Expand preview`,tooltip:he?`Collapse`:`Expand`,size:`icon-sm`,variant:`outline`,className:`h-8 w-8`,onClick:u,children:he?(0,q.jsx)(Ny,{className:`h-4 w-4`}):(0,q.jsx)(Py,{className:`h-4 w-4`})}),(0,q.jsx)(ZD,{type:`button`,"aria-label":`Close preview`,tooltip:`Close`,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,onClick:Ge,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1`,children:Qe}),he&&Oe&&H?(0,q.jsx)(`div`,{"data-testid":`preview-prompt-overlay`,className:`pointer-events-none absolute inset-x-0 bottom-6 z-[80] flex justify-center px-4`,children:(0,q.jsxs)(`div`,{className:`pointer-events-auto flex w-full max-w-[36rem] flex-col gap-3`,children:[o?.promptComposerControls?(0,q.jsx)(`div`,{className:`flex items-center justify-start`,children:o.promptComposerControls}):null,(0,q.jsx)(ux,{projectId:e.id,value:U,placeholder:De,disabled:W,isSubmitDisabled:!Ae,isSending:W,disabledReason:o?.disabledReason??void 0,onValueChange:ne,onKeyDown:Ze,onSubmit:()=>{Xe()},textareaRef:h,composerInlineControls:o?.promptComposerInlineControls??null,composerTheme:ke??`default`,composerSize:`compact-on-laptop`,shellClassName:`w-full shadow-[0_22px_56px_rgba(0,0,0,0.42)] backdrop-blur supports-[backdrop-filter]:bg-card/80`})]})}):null,k&&Se&&(0,q.jsx)(tO,{comment:N,composerRef:m,disabled:N.trim().length===0,mode:Ee,onAddComment:qe,onCancel:Le,onCommentChange:P,position:Se,target:k})]})},rO=(e,t)=>O(C(`/projects/${e}/chat-sessions`),{signal:t,fallbackErrorMessage:`Unable to load chat sessions right now.`}),iO=(e,t)=>O(C(`/projects/${e}/chat-sessions`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create a chat session right now.`}),aO=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}`),{signal:n,fallbackErrorMessage:`Unable to load the chat session right now.`}),oO=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}`),{method:`PATCH`,body:n,fallbackErrorMessage:`Unable to update the chat session right now.`}),sO=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}/messages`),{method:`POST`,body:n,fallbackErrorMessage:`Unable to send the chat prompt right now.`}),cO=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}/stop`),{method:`POST`,fallbackErrorMessage:`Unable to interrupt the chat response right now.`}),lO=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}`),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the chat session right now.`}),uO=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}/diff`),{fallbackErrorMessage:`Unable to load the chat diff right now.`}),dO=(e,t)=>O(C(`/projects/${e}/chat-sessions/${t}/git-status`),{fallbackErrorMessage:`Unable to load the chat git status right now.`}),fO=(e,t,n)=>O(C(`/projects/${e}/chat-sessions/${t}/messages/${n}/create-tickets`),{method:`POST`,fallbackErrorMessage:`Unable to create tickets from the chat proposal right now.`}),pO=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function mO(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function hO(e){return`nodeType`in e}function gO(e){return e?mO(e)?e:hO(e)?e.ownerDocument?.defaultView??window:window:window}function _O(e){let{Document:t}=gO(e);return e instanceof t}function vO(e){return mO(e)?!1:e instanceof gO(e).HTMLElement}function yO(e){return e instanceof gO(e).SVGElement}function bO(e){return e?mO(e)?e.document:hO(e)?_O(e)?e:vO(e)||yO(e)?e.ownerDocument:document:document:document}var xO=pO?b.useLayoutEffect:b.useEffect;function SO(e){let t=(0,b.useRef)(e);return xO(()=>{t.current=e}),(0,b.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function CO(){let e=(0,b.useRef)(null);return[(0,b.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,b.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function wO(e,t){t===void 0&&(t=[e]);let n=(0,b.useRef)(e);return xO(()=>{n.current!==e&&(n.current=e)},t),n}function TO(e,t){let n=(0,b.useRef)();return(0,b.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function EO(e){let t=SO(e),n=(0,b.useRef)(null);return[n,(0,b.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function DO(e){let t=(0,b.useRef)();return(0,b.useEffect)(()=>{t.current=e},[e]),t.current}var OO={};function kO(e,t){return(0,b.useMemo)(()=>{if(t)return t;let n=OO[e]==null?0:OO[e]+1;return OO[e]=n,e+`-`+n},[e,t])}function AO(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var jO=AO(1),MO=AO(-1);function NO(e){return`clientX`in e&&`clientY`in e}function PO(e){if(!e)return!1;let{KeyboardEvent:t}=gO(e.target);return t&&e instanceof t}function FO(e){if(!e)return!1;let{TouchEvent:t}=gO(e.target);return t&&e instanceof t}function IO(e){if(FO(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return NO(e)?{x:e.clientX,y:e.clientY}:null}var LO=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[LO.Translate.toString(e),LO.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),RO=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function zO(e){return e.matches(RO)?e:e.querySelector(RO)}var BO={display:`none`};function VO(e){let{id:t,value:n}=e;return b.createElement(`div`,{id:t,style:BO},n)}function HO(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return b.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function UO(){let[e,t]=(0,b.useState)(``);return{announce:(0,b.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var WO=(0,b.createContext)(null);function GO(e){let t=(0,b.useContext)(WO);(0,b.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function KO(){let[e]=(0,b.useState)(()=>new Set),t=(0,b.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,b.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var qO={draggable:`
92
92
  To pick up a draggable item, press the space bar.
93
93
  While dragging, use the arrow keys to move the item.
94
94
  Press space again to drop the item in its new position, or press escape to cancel.
95
- `},MO={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function NO(e){let{announcements:t=MO,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=jO}=e,{announce:a,announcement:o}=DO(),s=pO(`DndLiveRegion`),[c,l]=(0,b.useState)(!1);if((0,b.useEffect)(()=>{l(!0)},[]),kO((0,b.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=b.createElement(b.Fragment,null,b.createElement(TO,{id:r,value:i.draggable}),b.createElement(EO,{id:s,announcement:o}));return n?(0,kt.createPortal)(u,n):u}var PO;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(PO||={});function FO(){}function IO(e,t){return(0,b.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function LO(){var e=[...arguments];return(0,b.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var RO=Object.freeze({x:0,y:0});function zO(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function BO(e,t){let n=bO(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function VO(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function HO(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function UO(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function WO(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function GO(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var KO=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=GO(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(HO)};function qO(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var JO=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&qO(r,a)){let n=UO(a).reduce((e,t)=>e+zO(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(VO)};function YO(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function XO(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:RO}function ZO(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var QO=ZO(1);function $O(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ek(e,t,n){let r=$O(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var tk={ignoreTransform:!1};function nk(e,t){t===void 0&&(t=tk);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=eO(e).getComputedStyle(e);t&&(n=ek(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function rk(e){return nk(e,{ignoreTransform:!0})}function ik(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ak(e,t){return t===void 0&&(t=eO(e).getComputedStyle(e)),t.position===`fixed`}function ok(e,t){t===void 0&&(t=eO(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function sk(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(tO(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!nO(i)||rO(i)||n.includes(i))return n;let a=eO(e).getComputedStyle(i);return i!==e&&ok(i,a)&&n.push(i),ak(i,a)?n:r(i.parentNode)}return e?r(e):n}function ck(e){let[t]=sk(e,1);return t??null}function lk(e){return!ZD||!e?null:QD(e)?e:$D(e)?tO(e)||e===iO(e).scrollingElement?window:nO(e)?e:null:null}function uk(e){return QD(e)?e.scrollX:e.scrollLeft}function dk(e){return QD(e)?e.scrollY:e.scrollTop}function fk(e){return{x:uk(e),y:dk(e)}}var pk;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(pk||={});function mk(e){return!ZD||!e?!1:e===document.scrollingElement}function hk(e){let t={x:0,y:0},n=mk(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var gk={x:.2,y:.2};function _k(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=gk);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=hk(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=pk.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=pk.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=pk.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=pk.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function vk(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function yk(e){return e.reduce((e,t)=>hO(e,fk(t)),RO)}function bk(e){return e.reduce((e,t)=>e+uk(t),0)}function xk(e){return e.reduce((e,t)=>e+dk(t),0)}function Sk(e,t){if(t===void 0&&(t=nk),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);ck(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Ck=[[`x`,[`left`,`right`],bk],[`y`,[`top`,`bottom`],xk]],wk=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=sk(t),r=yk(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Ck)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Tk=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Ek(e){let{EventTarget:t}=eO(e);return e instanceof t?e:iO(e)}function Dk(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Ok;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Ok||={});function kk(e){e.preventDefault()}function Ak(e){e.stopPropagation()}var jk;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(jk||={});var Mk={start:[jk.Space,jk.Enter],cancel:[jk.Esc],end:[jk.Space,jk.Enter,jk.Tab]},Nk=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case jk.Right:return{...n,x:n.x+25};case jk.Left:return{...n,x:n.x-25};case jk.Down:return{...n,y:n.y+25};case jk.Up:return{...n,y:n.y-25}}},Pk=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Tk(iO(t)),this.windowListeners=new Tk(eO(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ok.Resize,this.handleCancel),this.windowListeners.add(Ok.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ok.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Sk(n),t(RO)}handleKeyDown(e){if(vO(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Mk,coordinateGetter:a=Nk,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:RO;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=gO(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=hk(n),p=vk(n),m={x:Math.min(i===jk.Right?p.right-p.width/2:p.right,Math.max(i===jk.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===jk.Down?p.bottom-p.height/2:p.bottom,Math.max(i===jk.Down?p.top:p.top+p.height/2,u.y))},h=i===jk.Right&&!s||i===jk.Left&&!c,g=i===jk.Down&&!l||i===jk.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===jk.Right&&e<=d.x||i===jk.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===jk.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===jk.Down&&e<=d.y||i===jk.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===jk.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,hO(gO(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Pk.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Mk,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Fk(e){return!!(e&&`distance`in e)}function Ik(e){return!!(e&&`delay`in e)}var Lk=class{constructor(e,t,n){n===void 0&&(n=Ek(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=iO(i),this.documentListeners=new Tk(this.document),this.listeners=new Tk(n),this.windowListeners=new Tk(eO(i)),this.initialCoordinates=bO(r)??RO,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Ok.Resize,this.handleCancel),this.windowListeners.add(Ok.DragStart,kk),this.windowListeners.add(Ok.VisibilityChange,this.handleCancel),this.windowListeners.add(Ok.ContextMenu,kk),this.documentListeners.add(Ok.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ik(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Fk(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Ok.Click,Ak,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ok.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=bO(e)??RO,s=gO(n,o);if(!t&&a){if(Fk(a)){if(a.tolerance!=null&&Dk(s,a.tolerance))return this.handleCancel();if(Dk(s,a.distance))return this.handleStart()}if(Ik(a)&&Dk(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===jk.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Rk={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},zk=class extends Lk{constructor(e){let{event:t}=e,n=iO(t.target);super(e,Rk,n)}};zk.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Bk={move:{name:`mousemove`},end:{name:`mouseup`}},Vk;(function(e){e[e.RightClick=2]=`RightClick`})(Vk||={});var Hk=class extends Lk{constructor(e){super(e,Bk,iO(e.event.target))}};Hk.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Vk.RightClick?!1:(r?.({event:n}),!0)}}];var Uk={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Wk=class extends Lk{constructor(e){super(e,Uk)}static setup(){return window.addEventListener(Uk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Uk.move.name,e)};function e(){}}};Wk.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Gk;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Gk||={});var Kk;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Kk||={});function qk(e){let{acceleration:t,activator:n=Gk.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Kk.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Yk({delta:d,disabled:!a}),[m,h]=sO(),g=(0,b.useRef)({x:0,y:0}),_=(0,b.useRef)({x:0,y:0}),v=(0,b.useMemo)(()=>{switch(n){case Gk.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Gk.DraggableRect:return i}},[n,i,c]),y=(0,b.useRef)(null),x=(0,b.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),S=(0,b.useMemo)(()=>s===Kk.TreeOrder?[...l].reverse():l,[s,l]);(0,b.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=_k(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(x,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,x,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,S,u,JSON.stringify(f)])}var Jk={x:{[pk.Backward]:!1,[pk.Forward]:!1},y:{[pk.Backward]:!1,[pk.Forward]:!1}};function Yk(e){let{delta:t,disabled:n}=e,r=dO(t);return lO(e=>{if(n||!r||!e)return Jk;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[pk.Backward]:e.x[pk.Backward]||i.x===-1,[pk.Forward]:e.x[pk.Forward]||i.x===1},y:{[pk.Backward]:e.y[pk.Backward]||i.y===-1,[pk.Forward]:e.y[pk.Forward]||i.y===1}}},[n,t,r])}function Xk(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return lO(e=>t==null?null:r??e??null,[r,t])}function Zk(e,t){return(0,b.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Qk;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Qk||={});var $k;(function(e){e.Optimized=`optimized`})($k||={});var eA=new Map;function tA(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,b.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,b.useRef)(e),d=g(),f=cO(d),p=(0,b.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,b.useRef)(null),h=lO(t=>{if(d&&!n)return eA;if(!t||t===eA||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new wk(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,b.useEffect)(()=>{u.current=e},[e]),(0,b.useEffect)(()=>{d||p()},[n,d]),(0,b.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,b.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Qk.Always:return!1;case Qk.BeforeDragging:return n;default:return!n}}}function nA(e,t){return lO(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function rA(e,t){return nA(e,t)}function iA(e){let{callback:t,disabled:n}=e,r=oO(t),i=(0,b.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,b.useEffect)(()=>()=>i?.disconnect(),[i]),i}function aA(e){let{callback:t,disabled:n}=e,r=oO(t),i=(0,b.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,b.useEffect)(()=>()=>i?.disconnect(),[i]),i}function oA(e){return new wk(nk(e),e)}function sA(e,t,n){t===void 0&&(t=oA);let[r,i]=(0,b.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=iA({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=aA({callback:a});return aO(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function cA(e){return XO(e,nA(e))}var lA=[];function uA(e){let t=(0,b.useRef)(e),n=lO(n=>e?n&&n!==lA&&e&&t.current&&e.parentNode===t.current.parentNode?n:sk(e):lA,[e]);return(0,b.useEffect)(()=>{t.current=e},[e]),n}function dA(e){let[t,n]=(0,b.useState)(null),r=(0,b.useRef)(e),i=(0,b.useCallback)(e=>{let t=lk(e.target);t&&n(e=>e?(e.set(t,fk(t)),new Map(e)):null)},[]);return(0,b.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=lk(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,fk(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{lk(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,b.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>hO(e,t),RO):yk(e):RO,[e,t])}function fA(e,t){t===void 0&&(t=[]);let n=(0,b.useRef)(null);return(0,b.useEffect)(()=>{n.current=null},t),(0,b.useEffect)(()=>{let t=e!==RO;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?gO(e,n.current):RO}function pA(e){(0,b.useEffect)(()=>{if(!ZD)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function mA(e,t){return(0,b.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function hA(e){return(0,b.useMemo)(()=>e?ik(e):null,[e])}var gA=[];function _A(e,t){t===void 0&&(t=nk);let[n]=e,r=hA(n?eO(n):null),[i,a]=(0,b.useState)(gA);function o(){a(()=>e.length?e.map(e=>mk(e)?r:new wk(t(e),e)):gA)}let s=aA({callback:o});return aO(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function vA(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return nO(t)?t:e}function yA(e){let{measure:t}=e,[n,r]=(0,b.useState)(null),i=aA({callback:(0,b.useCallback)(e=>{for(let{target:n}of e)if(nO(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=uO((0,b.useCallback)(e=>{let n=vA(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,b.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var bA=[{sensor:zk,options:{}},{sensor:Pk,options:{}}],xA={current:{}},SA={draggable:{measure:rk},droppable:{measure:rk,strategy:Qk.WhileDragging,frequency:$k.Optimized},dragOverlay:{measure:nk}},CA=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},wA={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new CA,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:FO},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:SA,measureDroppableContainers:FO,windowRect:null,measuringScheduled:!1},TA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:FO,draggableNodes:new Map,over:null,measureDroppableContainers:FO},EA=(0,b.createContext)(TA),DA=(0,b.createContext)(wA);function OA(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new CA}}}function kA(e,t){switch(t.type){case PO.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case PO.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case PO.DragEnd:case PO.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case PO.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new CA(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case PO.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new CA(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case PO.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new CA(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function AA(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,b.useContext)(EA),a=dO(r),o=dO(n?.id);return(0,b.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!vO(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=CO(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function jA(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function MA(e){return(0,b.useMemo)(()=>({draggable:{...SA.draggable,...e?.draggable},droppable:{...SA.droppable,...e?.droppable},dragOverlay:{...SA.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function NA(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,b.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;aO(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=XO(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=ck(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var PA=(0,b.createContext)({...RO,scaleX:1,scaleY:1}),FA;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(FA||={});var IA=(0,b.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=bA,collisionDetection:o=KO,measuring:s,modifiers:c,...l}=e,[u,d]=(0,b.useReducer)(kA,void 0,OA),[f,p]=AO(),[m,h]=(0,b.useState)(FA.Uninitialized),g=m===FA.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:x}}=u,S=_==null?null:v.get(_),C=(0,b.useRef)({initial:null,translated:null}),w=(0,b.useMemo)(()=>_==null?null:{id:_,data:S?.data??xA,rect:C},[_,S]),T=(0,b.useRef)(null),[E,D]=(0,b.useState)(null),[O,k]=(0,b.useState)(null),A=cO(l,Object.values(l)),j=pO(`DndDescribedBy`,t),M=(0,b.useMemo)(()=>x.getEnabled(),[x]),N=MA(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=tA(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=Xk(v,_),R=(0,b.useMemo)(()=>O?bO(O):null,[O]),z=Ce(),ee=rA(L,N.draggable.measure);NA({activeNode:_==null?null:v.get(_),config:z.layoutShiftCompensation,initialRect:ee,measure:N.draggable.measure});let B=sA(L,N.draggable.measure,ee),V=sA(L?L.parentElement:null),H=(0,b.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:x,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),te=x.getNodeFor(H.current.over?.id),U=yA({measure:N.dragOverlay.measure}),ne=U.nodeRef.current??L,W=g?U.rect??B:null,re=!!(U.nodeRef.current&&U.rect),ie=cA(re?null:B),ae=hA(ne?eO(ne):null),G=uA(g?te??L:null),oe=_A(G),se=jA(c,{transform:{x:y.x-ie.x,y:y.y-ie.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:W,over:H.current.over,overlayNodeRect:U.rect,scrollableAncestors:G,scrollableAncestorRects:oe,windowRect:ae}),ce=R?hO(R,y):null,le=dA(G),ue=fA(le),de=fA(le,[B]),K=hO(se,ue),fe=W?QO(W,se):null,pe=w&&fe?o({active:w,collisionRect:fe,droppableRects:P,droppableContainers:M,pointerCoordinates:ce}):null,me=WO(pe,`id`),[he,ge]=(0,b.useState)(null),_e=YO(re?se:hO(se,de),he?.rect??null,B),ve=(0,b.useRef)(null),ye=(0,b.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;ve.current=new n({active:T.current,activeNode:i,event:a,options:r,context:H,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:C}};(0,kt.unstable_batchedUpdates)(()=>{r?.(i),h(FA.Initializing),d({type:PO.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(ve.current),k(a)})},onMove(e){d({type:PO.DragMove,coordinates:e})},onEnd:o(PO.DragEnd),onCancel:o(PO.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=H.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===PO.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=PO.DragCancel)}T.current=null,(0,kt.unstable_batchedUpdates)(()=>{d({type:e}),h(FA.Uninitialized),ge(null),D(null),k(null),ve.current=null;let t=e===PO.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),be=Zk(a,(0,b.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,ye(n,t))},[v,ye]));pA(a),aO(()=>{B&&m===FA.Initializing&&h(FA.Initialized)},[B,m]),(0,b.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=H.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:K.x,y:K.y},over:i};(0,kt.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[K.x,K.y]),(0,b.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=H.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(me),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,kt.unstable_batchedUpdates)(()=>{ge(s),a?.(c),f({type:`onDragOver`,event:c})})},[me]),aO(()=>{H.current={activatorEvent:O,active:w,activeNode:L,collisionRect:fe,collisions:pe,droppableRects:P,draggableNodes:v,draggingNode:ne,draggingNodeRect:W,droppableContainers:x,over:he,scrollableAncestors:G,scrollAdjustedTranslate:K},C.current={initial:W,translated:fe}},[w,L,pe,fe,v,ne,W,P,x,he,G,K]),qk({...z,delta:y,draggingRect:fe,pointerCoordinates:ce,scrollableAncestors:G,scrollableAncestorRects:oe});let xe=(0,b.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:B,activatorEvent:O,collisions:pe,containerNodeRect:V,dragOverlay:U,draggableNodes:v,droppableContainers:x,droppableRects:P,over:he,measureDroppableContainers:F,scrollableAncestors:G,scrollableAncestorRects:oe,measuringConfiguration:N,measuringScheduled:I,windowRect:ae}),[w,L,B,O,pe,V,U,v,x,P,he,F,G,oe,N,I,ae]),Se=(0,b.useMemo)(()=>({activatorEvent:O,activators:be,active:w,activeNodeRect:B,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:he,measureDroppableContainers:F}),[O,be,w,B,d,j,v,he,F]);return b.createElement(OO.Provider,{value:p},b.createElement(EA.Provider,{value:Se},b.createElement(DA.Provider,{value:xe},b.createElement(PA.Provider,{value:_e},i)),b.createElement(AA,{disabled:n?.restoreFocus===!1})),b.createElement(NO,{...n,hiddenTextDescribedById:j}));function Ce(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),LA=(0,b.createContext)(null),RA=`button`,zA=`Draggable`;function BA(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=pO(zA),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,b.useContext)(EA),{role:p=RA,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,b.useContext)(g?PA:LA),[v,y]=uO(),[x,S]=uO(),C=mA(o,t),w=cO(n);return aO(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:x,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,b.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===RA?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:v,over:f,setNodeRef:y,setActivatorNodeRef:S,transform:_}}function VA(){return(0,b.useContext)(DA)}var HA=`Droppable`,UA={timeout:25};function WA(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=pO(HA),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,b.useContext)(EA),u=(0,b.useRef)({disabled:n}),d=(0,b.useRef)(!1),f=(0,b.useRef)(null),p=(0,b.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...UA,...i},_=cO(h??r),v=aA({callback:(0,b.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,x]=uO((0,b.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),S=cO(t);return(0,b.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,b.useEffect)(()=>(s({type:PO.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:S}}),()=>s({type:PO.UnregisterDroppable,key:a,id:r})),[r]),(0,b.useEffect)(()=>{n!==u.current.disabled&&(s({type:PO.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:x}}function GA(e){let{animation:t,children:n}=e,[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),s=dO(n);return!n&&!r&&s&&i(s),aO(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),b.createElement(b.Fragment,null,n,r?(0,b.cloneElement)(r,{ref:o}):null)}var KA={x:0,y:0,scaleX:1,scaleY:1};function qA(e){let{children:t}=e;return b.createElement(EA.Provider,{value:TA},b.createElement(PA.Provider,{value:KA},t))}var JA={position:`fixed`,touchAction:`none`},YA=e=>vO(e)?`transform 250ms ease`:void 0,XA=(0,b.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=YA}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...JA,width:s.width,height:s.height,top:s.top,left:s.left,transform:xO.Transform.toString(d),transformOrigin:i&&r?BO(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return b.createElement(n,{className:o,style:f,ref:t},a)}),ZA={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:xO.Transform.toString(t)},{transform:xO.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function QA(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return oO((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=vA(a);if(!c)return;let{transform:l}=eO(a).getComputedStyle(a),u=$O(l);if(!u)return;let d=typeof t==`function`?t:$A(t);return Sk(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function $A(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...ZA,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var ej=0;function tj(e){return(0,b.useMemo)(()=>{if(e!=null)return ej++,ej},[e])}var nj=b.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:x,windowRect:S}=VA(),C=(0,b.useContext)(PA),w=tj(d?.id),T=jA(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:x,transform:C,windowRect:S}),E=nA(f),D=QA({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),O=E?g.setRef:void 0;return b.createElement(qA,null,b.createElement(GA,{animation:D},d&&w?b.createElement(XA,{key:w,id:d.id,ref:O,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:E,style:{zIndex:l,...i},transform:T},n):null))}),rj=async(e,t,n=null)=>{let r=new URLSearchParams({tool:e});n&&r.set(`project_id`,n);let i=await O(C(`/skills?${r.toString()}`),{signal:t,cache:`no-store`});return Array.isArray(i)?i.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.description==`string`}):[]},ij=e=>(0,q.jsx)(Iu,{"data-slot":`dropdown-menu`,...e}),aj=e=>(0,q.jsx)(Lu,{"data-slot":`dropdown-menu-trigger`,...e}),oj=({className:e,align:t=`end`,sideOffset:n=6,...r})=>(0,q.jsx)(Ru,{children:(0,q.jsx)(zu,{"data-slot":`dropdown-menu-content`,align:t,sideOffset:n,className:J(`z-50 min-w-44 overflow-hidden rounded-xl border border-border bg-popover p-1 text-sm text-popover-foreground shadow-2xl shadow-black/30 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r})}),sj=({className:e,inset:t=!1,...n})=>(0,q.jsx)(Bu,{"data-slot":`dropdown-menu-item`,"data-inset":t,className:J(`relative flex cursor-default select-none items-center gap-2 rounded-lg px-2.5 py-2 text-sm outline-hidden transition-colors data-[disabled]:opacity-50 data-[disabled]:text-muted-foreground focus:bg-accent focus:text-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}),cj={draft:`border-sky-400/30 bg-sky-500/15 text-sky-100`,open:`border-emerald-400/30 bg-emerald-500/15 text-emerald-100`,merged:`border-violet-400/30 bg-violet-500/15 text-violet-100`,closed:`border-slate-400/30 bg-slate-500/15 text-slate-200`},lj={draft:`PR Draft`,open:`PR Open`,merged:`PR Merged`,closed:`PR Closed`},uj=({pullRequest:e,asLink:t=!1,onClick:n,onPointerDown:r,showNumber:i=!1})=>{let a=i?`PR #${e.number} ${e.state}`:lj[e.state],o=(0,q.jsx)(Z,{variant:`outline`,className:cj[e.state],children:a});return t?(0,q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex underline underline-offset-2 decoration-current hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:n,onPointerDown:r,children:o}):o},dj=({className:e})=>(0,q.jsx)($m,{"aria-hidden":`true`,className:e}),fj=({className:e})=>(0,q.jsx)(Gm,{"aria-hidden":`true`,className:e}),pj={plan:0,build:1,review:2},mj={plan:`build`,build:`review`},hj=e=>mj[e]??null,gj=e=>e===`plan`?`plan`:e===`build`||e===`review`||e===`done`?`build`:`default`,_j=e=>e.worktree_bundle_id??e.id,vj=e=>e.state===`build`||e.state===`review`&&e.review_follow_up_active===!0,yj=e=>e.parked_at!==null,bj=e=>yj(e)?`done`:e.state,xj=e=>e.is_stale===!0,Sj=e=>e?e.files_changed===0&&e.additions===0&&e.deletions===0:!1,Cj=(e,t)=>!t||e===`plan`?!1:!(e===`done`&&Sj(t)),wj=e=>yj(e)||e.agent_status===`running`?!1:e.state===`build`?e.agent_status===`done`:e.state===`review`,Tj=(e,t)=>yj(e)&&e.state===t,Ej=(e,t)=>e.agent_status===`running`?!1:t===`done`?wj(e):!(t!==`trash`&&pj[t]<=pj[e.state]||t===`review`&&(e.state!==`build`||e.agent_status!==`done`)),Dj=(e,t)=>{let n=e.created_at.localeCompare(t.created_at);if(n!==0)return n;let r=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return r===0?e.id.localeCompare(t.id):r},Oj=12,kj=e=>({x:e.left+e.width/2,y:e.top+e.height/2}),Aj=e=>`${e.blocker_ticket_id}:${e.dependent_ticket_id}`,jj=(e,t)=>e.filter(e=>e.blocker_ticket_id!==t&&e.dependent_ticket_id!==t),Mj=(e,t)=>{let n=e.filter(e=>Aj(e)!==Aj(t));return n.push(t),n.sort((e,t)=>Aj(e).localeCompare(Aj(t))),n},Nj=(e,t,n)=>e.filter(e=>!(e.blocker_ticket_id===t&&e.dependent_ticket_id===n)),Pj=(e,t,n)=>{let r=[n],i=new Set;for(;r.length>0;){let n=r.shift();if(!(!n||i.has(n))){if(n===t)return!0;i.add(n);for(let t of e)t.blocker_ticket_id===n&&r.push(t.dependent_ticket_id)}}return!1},Fj=(e,t,n)=>t===n?{valid:!1,reason:`self`}:e.some(e=>e.blocker_ticket_id===t&&e.dependent_ticket_id===n)?{valid:!1,reason:`duplicate`}:Pj(e,t,n)?{valid:!1,reason:`cycle`}:{valid:!0},Ij=e=>e===`self`?`A ticket cannot depend on itself.`:e===`duplicate`?`This dependency already exists.`:`This dependency would create a cycle.`,Lj=e=>e?e.build_completed_at!==null&&e.build_completed_at!==void 0||e.state===`review`?!0:e.state===`build`&&e.agent_status===`done`:!1,Rj=e=>!e||e.has_worktree===!1?!1:e.run_setup_status===`ready`?!0:Lj(e),zj=e=>{if(!(!e||e.has_worktree===!1)){if(e.run_setup_status===`preparing`)return`Setting up worktree...`;if(!Rj(e))return`Run unlocks after setup finishes.`}},Bj=(e,t,n)=>n.filter(t=>t.dependent_ticket_id===e.id).map(e=>t.get(e.blocker_ticket_id)).filter(e=>!!e&&!Lj(e)),Vj=(e,t)=>{let n=[e],r=new Set,i=new Set;for(;n.length>0;){let e=n.shift();if(!(!e||r.has(e))){r.add(e);for(let r of t)r.blocker_ticket_id===e&&(i.add(r.dependent_ticket_id),n.push(r.dependent_ticket_id))}}return i},Hj=(e,t,n)=>{let r=n.get(t);if(!r){e.push(t);return}let i=!1;for(let a=0;a<e.length;a+=1){let o=n.get(e[a]);if(o&&Dj(r,o)<0){e.splice(a,0,t),i=!0;break}}i||e.push(t)},Uj=(e,t,n)=>{if(!t.get(e))return[];let r=Vj(e,n);if(r.size===0)return[];let i=[e,...r],a=new Set(i),o=new Map,s=new Map;for(let e of i)o.set(e,0),s.set(e,[]);for(let e of n)!a.has(e.blocker_ticket_id)||!a.has(e.dependent_ticket_id)||(s.get(e.blocker_ticket_id)?.push(e.dependent_ticket_id),o.set(e.dependent_ticket_id,(o.get(e.dependent_ticket_id)??0)+1));let c=[];for(let e of i)(o.get(e)??0)===0&&Hj(c,e,t);let l=[];for(;c.length>0;){let e=c.shift();if(e){l.push(e);for(let n of s.get(e)??[]){let e=(o.get(n)??0)-1;o.set(n,e),e===0&&Hj(c,n,t)}}}return l.map(e=>t.get(e)).filter(e=>!!e)},Wj=(e,t,n)=>{let r=Uj(e.id,t,n),i=r.filter(e=>!Lj(e)),a=r.length>1,o=Bj(e,t,n).length>0,s=e.state===`plan`&&a&&!o;return{buildChainOrder:r,pendingBuildChainOrder:i,hasDependents:a,hasOpenBlockers:o,canStartBuildChain:s,isVisibleStartPoint:e.build_chain?.is_root===!0||s,skippedBuildChainCount:r.length-i.length}},Gj=(e,t)=>{let n=kj(e),r=kj(t),i=e.left+e.width,a=t.left+t.width,o=e.top+e.height,s=t.top+t.height;return e.left<a&&i>t.left?r.y>=n.y?{start:{x:n.x,y:o-Oj},end:{x:r.x,y:t.top+Oj}}:{start:{x:n.x,y:e.top+Oj},end:{x:r.x,y:s-Oj}}:r.x>=n.x?{start:{x:i-Oj,y:n.y},end:{x:t.left+Oj,y:r.y}}:{start:{x:e.left+Oj,y:n.y},end:{x:a-Oj,y:r.y}}},Kj=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;if(Math.abs(n)>=Math.abs(r)){let r=Math.max(64,Math.abs(n)*.6),i={x:e.x+Math.sign(n||1)*r,y:e.y},a={x:t.x-Math.sign(n||1)*r,y:t.y};return{path:`M ${e.x} ${e.y} C ${i.x} ${i.y}, ${a.x} ${a.y}, ${t.x} ${t.y}`,angle:Math.atan2(t.y-a.y,t.x-a.x)}}let i=Math.max(18,Math.round(Math.abs(r)*.4)),a=Math.max(24,Math.min(36,Math.round(Math.abs(r)*.18+Math.abs(n)*.1))),o=Math.round(a*.35),s=n>=0?1:-1,c={x:e.x+s*a,y:e.y+Math.sign(r||1)*i},l={x:t.x+s*o,y:t.y-Math.sign(r||1)*i};return{path:`M ${e.x} ${e.y} C ${c.x} ${c.y}, ${l.x} ${l.y}, ${t.x} ${t.y}`,angle:Math.atan2(t.y-l.y,t.x-l.x)}},qj=({className:e})=>(0,q.jsx)(Hm,{"aria-hidden":`true`,className:e}),Jj=({className:e})=>(0,q.jsx)(Wm,{"aria-hidden":`true`,className:e}),Yj=({label:e,className:t})=>(0,q.jsxs)(Z,{className:J(`inline-flex w-fit items-center gap-2 px-3 py-1 text-xs font-medium text-primary-foreground`,t),children:[(0,q.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-violet-300`}),e]}),Xj=({status:e,showBuildGlyph:t=!1})=>e===null?null:e===`queued`?(0,q.jsx)(Z,{variant:`outline`,children:`Queued`}):e===`planning`?(0,q.jsx)(Yj,{label:`Planning...`}):e===`building`?(0,q.jsx)(Z,{variant:`warning`,children:t?`⏳ Building`:`Building`}):e===`reviewing`?(0,q.jsx)(Z,{variant:`warning`,children:`Reviewing`}):e===`done`?(0,q.jsx)(Z,{variant:`success`,children:`✓ Done`}):e===`error`?(0,q.jsx)(Z,{variant:`destructive`,children:`✗ Error`}):(0,q.jsx)(Z,{variant:`warning`,children:`Stopped`}),Zj=({title:e,stage:t,subjectLabel:n=`ticket`,onConfirm:r,onCancel:i})=>{(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let a=t===`review`?`Undo review`:`Undo build`,o=t===`review`?`This will revert the current review-step changes and move the ${n} back to build-done.`:`This will revert the current build-step changes and move the ${n} back to plan.`;return(0,q.jsxs)(Iv,{onClose:i,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:a}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:o}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:r,children:`Undo`})]})]})},Qj=({isRunning:e,isRunPending:t=!1,isStopPending:n=!1,runDisabled:r=!1,runDisabledReason:i,onRun:a,onStop:o,className:s})=>e?o?(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`destructive`,disabled:n,"aria-busy":n,"aria-label":n?`Stopping run`:`Stop`,title:n?`Stopping run...`:void 0,className:s,onClick:e=>{e.stopPropagation(),o()},onPointerDown:e=>e.stopPropagation(),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 flex-shrink-0 rounded-full bg-emerald-400 animate-pulse`}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3.5 justify-center`,children:n?(0,q.jsx)(C_,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(E_,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`min-w-[2.25rem] text-left`,children:`Stop`})]}):null:a?(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`secondary`,disabled:t||r,"aria-busy":t,"aria-label":t?`Starting run`:`Run`,title:r?i??`Stop the currently running ticket before starting another run.`:t?`Starting run...`:void 0,className:J(`bg-sky-700 text-sky-50 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,s),onClick:e=>{e.stopPropagation(),!r&&a()},onPointerDown:e=>e.stopPropagation(),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 flex-shrink-0 rounded-full invisible`}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3.5 justify-center`,children:t?(0,q.jsx)(C_,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(w_,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`min-w-[2.25rem] text-left`,children:`Run`})]}):null,$j=e=>e.length===0?null:e.some(e=>e.agent_status===`running`)?`reviewing`:e.some(e=>e.agent_status===`error`)?`error`:e.some(e=>e.agent_status===`stopped`)?`stopped`:e.some(e=>e.agent_status===`done`)&&e.every(e=>e.agent_status===null||e.agent_status===`done`)?`done`:e.every(e=>e.agent_status===null)?`queued`:null,eM=(e,{allTickets:t=[],preferBundleReviewStatus:n=!1}={})=>{if(e.parked_at!==null)return null;if(e.state===`plan`){if(e.agent_status===`running`)return`planning`;if(e.agent_status===null)return null;if(e.agent_status===`done`)return`done`;if(e.agent_status===`error`)return`error`;if(e.agent_status===`stopped`)return`stopped`}if(n&&e.worktree_bundle_id){let n=t.filter(t=>t.worktree_bundle_id===e.worktree_bundle_id),r=$j((n.length>0?n:[e]).filter(e=>e.state===`review`));if(r)return r}return e.agent_status===null?`queued`:e.agent_status===`running`?e.state===`review`?`reviewing`:`building`:e.agent_status===`done`?`done`:e.agent_status===`error`?`error`:e.agent_status===`stopped`?`stopped`:null},tM=(e,t)=>{if(t===`done`||e.every(e=>e.parked_at!==null))return null;let n=e.filter(e=>e.state===`review`);if(t===`review`){let e=$j(n);if(e)return e}return n.some(e=>e.agent_status===`running`)?`reviewing`:t===`plan`&&e.some(e=>e.state===`plan`&&e.agent_status===`running`)?`planning`:e.some(e=>e.agent_status===`running`)?`building`:e.some(e=>e.agent_status===`error`)?`error`:e.some(e=>e.agent_status===`stopped`)?`stopped`:e.length>0&&e.every(e=>e.agent_status===`done`)?`done`:e.some(e=>e.state===`build`)?`queued`:null},nM=({bundleName:e,ticketCount:t,onConfirm:n,onCancel:r})=>((0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,q.jsxs)(Iv,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete bundle`}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsxs)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:[`This deletes the `,t,` ticket`,t===1?``:`s`,` `,`currently inside this wrapper.`]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:n,children:`Delete`})]})]})),rM=e=>e.find(e=>e.state===`review`&&e.undo?.stage===`review`&&e.undo.can_undo)??e.find(e=>e.state===`review`&&e.undo?.stage===`review`)??null,iM=(e,t)=>t?.diff_stats===void 0?e.find(e=>e.diff_stats!==void 0)?.diff_stats:t.diff_stats,aM=e=>e.length>0&&e.every(e=>xj(e)),oM=({group:e,renderTicket:t,runDisabled:n=!1,onStopBuildTicket:r,onResumeBuildTicket:i,onBuildBundle:a,onReviewBundle:o,onUndoBundleReview:s,onRunBundle:c,onStopBundle:l,onParkBundleWrapper:u,onUnparkBundleWrapper:d,bundleActionState:f,onOpenBundleDetails:p,onOpenBundleChanges:m,onOpenBundleIde:h,onRequestBundleRefresh:g,onDeleteBundleWrapper:_,undoInProgress:v=!1,overlay:y=!1})=>{let[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(!1),{attributes:T,listeners:E,setNodeRef:D,isDragging:O}=BA({id:pv(e),disabled:y||v}),k=(0,b.useMemo)(()=>tM(e.tickets,e.column),[e.column,e.tickets]),A=(0,b.useMemo)(()=>(0,q.jsx)(Xj,{status:k}),[k]),j=e.column===`plan`,M=e.column===`build`&&e.tickets.every(e=>e.agent_status===`done`),N=(0,b.useMemo)(()=>rM(e.tickets),[e.tickets]),P=e.column===`review`&&N!==null,F=N?.undo?.can_undo??!1,I=N?.undo?.reason??void 0,L=f??{build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1},R=L.review||L.followUp,z=e.column===`review`&&!e.tickets.some(e=>e.agent_status===`running`)&&!R&&e.tickets.some(e=>e.can_re_review),ee=z?`Re-run review`:`Review Bundle`,B=e.tickets.find(e=>e.is_running)??e.tickets.find(e=>e.session_id)??e.tickets.find(e=>e.has_worktree)??e.tickets[0],V=(0,b.useMemo)(()=>iM(e.tickets,B),[B,e.tickets]),H=(0,b.useMemo)(()=>aM(e.tickets),[e.tickets]),te=(0,b.useMemo)(()=>e.column!==`plan`&&V===void 0&&e.tickets.some(e=>e.diff_stats===void 0),[V,e.column,e.tickets]),U=H||e.column===`done`,ne=e.tickets.some(e=>e.is_running),W=e.tickets.some(e=>e.has_run_config&&Rj(e)),re=(0,b.useMemo)(()=>[...new Set(e.tickets.map(e=>e.model??``).filter(e=>e.length>0))],[e.tickets]),ie=re.length===1?re[0]:null,ae=e.tickets.find(e=>vj(e)&&e.agent_status===`running`&&!!e.session_id)??null,G=e.tickets.find(e=>vj(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,oe=ae!==null,se=!oe&&G!==null,ce=e.tickets.length>0&&e.tickets.every(e=>Ej(e,`trash`)),le=e.column!==`done`&&e.tickets.length>0&&e.tickets.every(e=>Ej(e,`done`)),ue=e.column===`done`&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),de=e.tickets.length===1?`Return to ${e.tickets[0]?.state.charAt(0).toUpperCase()}${e.tickets[0]?.state.slice(1)}`:`Return to original columns`,K=y?`border-violet-400`:U?`border-border/80 hover:border-border`:`border-border hover:border-primary/40`,fe=y||v?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,pe=O?`opacity-30`:U?`opacity-90`:`opacity-100`,me=U?`bg-card/60`:`bg-secondary/60`,he=U?`rounded-lg border border-border/60 bg-background/25 p-2.5`:`rounded-lg border border-border/60 bg-background/35 p-2.5`,ge=U?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,_e=U?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,ve=e.column===`done`;return(0,q.jsxs)(zv,{ref:D,"data-testid":`bundle-card-${e.bundle.id}-${e.column}`,className:`relative shrink-0 select-none transition-colors ${K} ${fe} ${pe} ${me} gap-0 rounded-xl border shadow-none`,onClick:()=>{y||v||(g?.(e.bundle.id),p?.(e.bundle.id,e.column))},...E,...T,children:[v&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,q.jsxs)(Z,{variant:`warning`,className:`gap-1.5`,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,q.jsxs)(Wv,{className:`p-3`,children:[(0,q.jsxs)(`div`,{className:`group/bundle mb-3 flex items-start justify-between gap-2 border-b pb-3 border-border/70`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 text-left`,children:[(0,q.jsx)(`div`,{className:`min-w-0`,children:(0,q.jsx)(`div`,{className:`${ge} min-w-0`,children:hv(e.bundle)})}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`shrink-0 ${_e}`,children:[e.tickets.length,` ticket`,e.tickets.length===1?``:`s`]}),A,e.bundle.pull_request&&(0,q.jsx)(uj,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()}),H&&(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]}),(Cj(e.column,V)||te||ie)&&(0,q.jsxs)(`div`,{"data-testid":`bundle-card-metadata-${e.bundle.id}-${e.column}`,className:`mt-2 flex flex-col gap-1`,children:[(Cj(e.column,V)||te)&&(0,q.jsx)(b_,{stats:V,isLoading:te,showFiles:!0,className:_e}),ie&&(0,q.jsx)(`div`,{className:_e,children:(0,q.jsx)(`span`,{className:`truncate`,children:ie})})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,q.jsx)(`div`,{className:`mr-1`,children:(0,q.jsx)(Qj,{isRunning:ne,isRunPending:L.run,isStopPending:L.stop,runDisabled:n,onRun:!W||ve||!c?void 0:()=>c(e.bundle.id),onStop:l?()=>l(e.bundle.id):void 0})}),(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`size-7`}),(0,q.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:(0,q.jsxs)(ij,{children:[(0,q.jsx)(aj,{asChild:!0,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Open actions menu for bundle ${hv(e.bundle)}`,variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/bundle:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,q.jsx)(dj,{className:`h-4 w-4`})})}),(0,q.jsxs)(oj,{side:`right`,align:`start`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[ce&&_&&(0,q.jsxs)(sj,{className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{S(!0)},children:[(0,q.jsx)(qv,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Delete bundle`})]}),ue&&d&&(0,q.jsxs)(sj,{onSelect:()=>{d(e)},children:[(0,q.jsx)(Jj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:de})]}),j&&a&&(0,q.jsxs)(sj,{disabled:L.build,onSelect:()=>{a(e.bundle.id)},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.build?`Building Bundle...`:`Build Bundle`})]}),(M||z)&&o&&(0,q.jsxs)(sj,{disabled:R,onSelect:()=>{o(e.bundle.id)},children:[(0,q.jsx)(fj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:R?`Reviewing Bundle...`:ee})]}),P&&s&&(0,q.jsxs)(sj,{disabled:L.undoReview||!F,title:F?void 0:I,onSelect:()=>{F&&w(!0)},children:[(0,q.jsx)(Ky,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.undoReview?`Undoing...`:`Undo Review`})]}),!ne&&c&&(0,q.jsxs)(sj,{disabled:L.run||n,onSelect:()=>{n||c(e.bundle.id)},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.run?`Starting Run...`:`Run`})]}),ne&&l&&(0,q.jsxs)(sj,{disabled:L.stop,onSelect:()=>{l(e.bundle.id)},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.stop?`Stopping...`:`Stop Run`})]}),oe&&ae&&r&&(0,q.jsxs)(sj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,disabled:L.stopBuild,onSelect:()=>{r(ae.id)},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.stopBuild?`Pausing Build...`:`Pause Build`})]}),se&&G&&i&&(0,q.jsxs)(sj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,disabled:L.resumeBuild,onSelect:()=>{i(G.id)},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.resumeBuild?`Resuming Build...`:`Resume Build`})]}),(0,q.jsxs)(sj,{disabled:!m,onSelect:()=>{m?.(e.bundle.id)},children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),(0,q.jsxs)(sj,{disabled:!h,onSelect:()=>{h?.(e.bundle.id)},children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),le&&u&&(0,q.jsxs)(sj,{onSelect:()=>{u(e)},children:[(0,q.jsx)(qj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Done`})]})]})]})})]})]}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 ${he}`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:e.tickets.map(e=>(0,q.jsx)(b.Fragment,{children:t(e)},e.id))}),x&&(0,q.jsx)(nM,{bundleName:hv(e.bundle),ticketCount:e.tickets.length,onConfirm:()=>{S(!1),_?.(e)},onCancel:()=>S(!1)}),C&&N?.undo?.stage&&(0,q.jsx)(Zj,{title:hv(e.bundle),stage:N.undo.stage,subjectLabel:`bundle`,onConfirm:()=>{w(!1),s?.(e.bundle.id)},onCancel:()=>w(!1)})]})]})},sM=({className:e})=>(0,q.jsx)(ih,{"aria-hidden":`true`,className:e}),cM=({title:e,canDelete:t,undo:n,undoInProgress:r,runDisabled:i,isRunPending:a,isStopPending:o,showOpenChangesAction:s,showOpenIdeAction:c,showRunAction:l,showStopRunAction:u,showAdvanceAction:d,advanceLabel:f,canAdvance:p,showParkAction:m,showReturnAction:h,returnLabel:g,showBuildChainAction:_,showPauseBuildAction:v,showResumeBuildAction:y,showStopBuildChainAction:b,onDelete:x,onConfirmDelete:S,onConfirmUndo:C,onOpenChanges:w,onOpenIde:T,onAdvance:E,onPark:D,onUnpark:O,onBuildChain:k,onRun:A,onStop:j,onStopBuild:M,onResumeBuild:N,onStopBuildChain:P})=>(0,q.jsxs)(ij,{children:[(0,q.jsx)(aj,{asChild:!0,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Open actions menu for ${e}`,variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/card:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,q.jsx)(dj,{className:`h-4 w-4`})})}),(0,q.jsxs)(oj,{side:`right`,align:`start`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[x&&(0,q.jsxs)(sj,{disabled:!t,className:`text-red-200 focus:bg-destructive/20 focus:text-red-100 data-[disabled]:text-muted-foreground`,onSelect:()=>{t&&S()},children:[(0,q.jsx)(qv,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Delete`})]}),n?.stage&&(0,q.jsxs)(sj,{disabled:!n.can_undo,title:n.can_undo?void 0:n.reason??void 0,onSelect:()=>{r||!n.can_undo||C()},children:[(0,q.jsx)(Ky,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:n.stage===`review`?`Undo Review`:`Undo Build`})]}),d&&f&&(0,q.jsxs)(sj,{disabled:!p,onSelect:()=>{p&&E?.()},children:[(0,q.jsx)(fj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:f})]}),h&&g&&(0,q.jsxs)(sj,{onSelect:()=>{O?.()},children:[(0,q.jsx)(Jj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:g})]}),_&&(0,q.jsxs)(sj,{onSelect:()=>{k?.()},children:[(0,q.jsx)(sM,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Build Chain`})]}),l&&(0,q.jsxs)(sj,{disabled:i||a,onSelect:()=>{i||a||A?.()},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:a?`Starting Run...`:`Run`})]}),u&&(0,q.jsxs)(sj,{disabled:o,className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{o||j?.()},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:o?`Stopping...`:`Stop Run`})]}),v&&(0,q.jsxs)(sj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,onSelect:()=>M?.(),children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Pause Build`})]}),y&&(0,q.jsxs)(sj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,onSelect:()=>N?.(),children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Resume Build`})]}),s&&(0,q.jsxs)(sj,{onSelect:()=>w?.(),children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),c&&(0,q.jsxs)(sj,{onSelect:()=>T?.(),children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),b&&(0,q.jsxs)(sj,{className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{P?.()},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Stop Build Chain`})]}),m&&(0,q.jsxs)(sj,{onSelect:()=>{D?.()},children:[(0,q.jsx)(qj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Done`})]})]})]}),lM=({title:e,bundleName:t=null,onConfirm:n,onCancel:r})=>((0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,q.jsxs)(Iv,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete ticket`}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:t?`This removes the ticket from bundle "${t}". The bundle and shared worktree stay available.`:`This will also remove the worktree if one exists.`}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:n,children:`Delete`})]})]})),uM=({description:e,descriptionClass:t,isExpanded:n,collapsedState:r,useStaleLikeStyling:i,onExpand:a,onCollapse:o})=>{if(!e)return null;let s=`ml-1 inline h-auto px-0 py-0 align-baseline text-xs lowercase ${i?`text-foreground/75`:`text-foreground/70`}`;return(0,q.jsx)(`div`,{className:`mb-2 text-xs leading-relaxed ${i?`text-foreground/55`:`text-muted-foreground`}`,children:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:t,children:e}),(0,q.jsx)(Y,{type:`button`,variant:`link`,size:`xs`,className:s,onClick:e=>{e.stopPropagation(),o()},onPointerDown:e=>e.stopPropagation(),children:`show less`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:t,children:r.text}),r.truncated&&(0,q.jsx)(Y,{type:`button`,variant:`link`,size:`xs`,className:s,onClick:e=>{e.stopPropagation(),a()},onPointerDown:e=>e.stopPropagation(),children:`show more`})]})})},dM=({ticket:e,hideStatusBadge:t,isStale:n,runControl:r,onRetry:i,undoInProgress:a,isChainStart:o})=>{let s=(e.planning_context?.open_questions.length??0)>0,c=eM(e),l=t||e.state===`plan`&&e.agent_status===null;return(0,q.jsxs)(q.Fragment,{children:[n&&(0,q.jsx)(`div`,{className:`mb-2`,children:(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})}),!t&&c!==null&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Xj,{status:c,showBuildGlyph:!0}),c===`error`&&i&&!a&&(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e=>{e.stopPropagation(),i()},onPointerDown:e=>e.stopPropagation(),children:(0,q.jsx)(Ky,{className:`w-3.5 h-3.5`})}),r]}),l&&r,s&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(Z,{variant:`warning`,children:`Open questions`})}),o&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsxs)(Z,{variant:`secondary`,className:`gap-1.5 border-violet-500/25 bg-violet-500/12 text-violet-200`,children:[(0,q.jsx)(sM,{className:`h-3.5 w-3.5`}),`Chain start`]})})]})},fM=(e,t)=>O(w(`/tickets/${e}/terminal`,t),{method:`POST`,fallbackErrorMessage:`Unable to open the terminal right now.`}),pM=e=>O(C(`/projects/${e}/terminal`),{method:`POST`,fallbackErrorMessage:`Unable to open the project terminal right now.`}),mM=e=>{let t=C(`/terminals/${e}/destroy`);if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([`{}`],{type:`application/json`});if(navigator.sendBeacon(t,e))return}fetch(t,{method:`POST`,keepalive:!0,headers:{"Content-Type":`application/json`},body:`{}`}).catch(()=>{})},hM=({model:e,variant:t,skills:n})=>e||t||n.length>0?(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e||`Default model`}),t&&(0,q.jsx)(Z,{variant:`ghost`,className:`text-[11px] text-muted-foreground`,children:t}),n.length>0&&(0,q.jsxs)(Z,{variant:`info`,className:`text-[11px]`,children:[n.length,` skill`,n.length===1?``:`s`]})]}):(0,q.jsx)(Z,{variant:`ghost`,className:`px-0 text-[11px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Using defaults`}),gM=e=>e===`claude`?`Claude`:`OpenCode`,_M=({tool:e,className:t})=>{if(!e)return null;let n=gM(e),r=`Locked to ${n}`;return(0,q.jsx)(u_,{content:r,children:(0,q.jsx)(Z,{variant:`outline`,"aria-label":r,className:J(`border-violet-500/25 bg-violet-500/10 text-violet-100`,e===`claude`&&`border-orange-500/25 bg-orange-500/10 text-orange-100`,t),children:n})})},vM=({externalSource:e=null,className:t})=>{if(!e||e.provider!==`jira`)return null;let n=e.external_key;return(0,q.jsxs)(`div`,{className:J(`inline-flex w-fit max-w-full flex-wrap items-center gap-x-1 self-start rounded-md border border-sky-500/20 bg-sky-500/10 px-2.5 py-1 text-[11px] leading-5 text-sky-100`,t),children:[(0,q.jsx)(`span`,{children:`Imported from Jira issue`}),e.external_url?(0,q.jsx)(`a`,{href:e.external_url,target:`_blank`,rel:`noreferrer`,className:`font-medium underline underline-offset-2 hover:text-white`,children:n}):(0,q.jsx)(`span`,{className:`font-medium`,children:n})]})},yM=({className:e})=>(0,q.jsx)(Zm,{"aria-hidden":`true`,className:e}),bM=({label:e,value:t,variant:n=`default`,className:r})=>{let[i,a]=(0,b.useState)(!1),o=()=>{navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),2e3)};return n===`compact`?(0,q.jsx)(`div`,{className:J(`min-w-0`,r),children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg border border-border/80 bg-card/70 px-2.5 py-1.5`,children:[(0,q.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground/80`,children:t}),(0,q.jsx)(Y,{type:`button`,onClick:o,variant:`ghost`,size:`icon-xs`,"aria-label":i?`${e} copied`:`Copy ${e}`,className:J(`flex-shrink-0 text-muted-foreground hover:text-foreground`,i&&`text-emerald-300`),children:(0,q.jsx)(yM,{className:`h-3 w-3`})})]})}):(0,q.jsxs)(`div`,{className:J(`flex flex-col gap-1.5`,r),children:[(0,q.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-input/30 px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs text-muted-foreground`,children:t}),(0,q.jsxs)(Y,{type:`button`,onClick:o,variant:`ghost`,size:`xs`,className:`flex-shrink-0`,children:[(0,q.jsx)(yM,{className:`h-3.5 w-3.5`}),i?`Copied`:`Copy`]})]})]})},xM=({ariaLabel:e,items:t,className:n})=>{let r=t.filter(e=>e.value.trim().length>0);return r.length===0?null:(0,q.jsx)(`section`,{"aria-label":e,className:J(`flex flex-wrap items-center gap-2`,n),children:r.map(e=>(0,q.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,q.jsx)(bM,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`))})},SM=new Set([`step started`,`step finished`]),CM=e=>SM.has(e.trim().toLowerCase()),wM=e=>CM(e.content)?!1:e.kind===`description`?e.content.trim().length>0:!0,TM=({summary:e,detail:t=null})=>(0,q.jsxs)(`section`,{"aria-label":`Build chain`,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Build chain`}),(0,q.jsx)(`p`,{className:`text-sm text-foreground`,children:e}),t&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]});function EM(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var DM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,OM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kM={};function AM(e,t){return((t||kM).jsx?OM:DM).test(e)}var jM=/[ \t\n\f\r]/g;function MM(e){return typeof e==`object`?e.type===`text`?NM(e.value):!1:NM(e)}function NM(e){return e.replace(jM,``)===``}var PM=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};PM.prototype.normal={},PM.prototype.property={},PM.prototype.space=void 0;function FM(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new PM(n,r,t)}function IM(e){return e.toLowerCase()}var LM=class{constructor(e,t){this.attribute=t,this.property=e}};LM.prototype.attribute=``,LM.prototype.booleanish=!1,LM.prototype.boolean=!1,LM.prototype.commaOrSpaceSeparated=!1,LM.prototype.commaSeparated=!1,LM.prototype.defined=!1,LM.prototype.mustUseProperty=!1,LM.prototype.number=!1,LM.prototype.overloadedBoolean=!1,LM.prototype.property=``,LM.prototype.spaceSeparated=!1,LM.prototype.space=void 0;var RM=c({boolean:()=>BM,booleanish:()=>VM,commaOrSpaceSeparated:()=>GM,commaSeparated:()=>WM,number:()=>Q,overloadedBoolean:()=>HM,spaceSeparated:()=>UM}),zM=0,BM=KM(),VM=KM(),HM=KM(),Q=KM(),UM=KM(),WM=KM(),GM=KM();function KM(){return 2**++zM}var qM=Object.keys(RM),JM=class extends LM{constructor(e,t,n,r){let i=-1;if(super(e,t),YM(this,`space`,r),typeof n==`number`)for(;++i<qM.length;){let e=qM[i];YM(this,qM[i],(n&RM[e])===RM[e])}}};JM.prototype.defined=!0;function YM(e,t,n){n&&(e[t]=n)}function XM(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new JM(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[IM(r)]=r,n[IM(a.attribute)]=r}return new PM(t,n,e.space)}var ZM=XM({properties:{ariaActiveDescendant:null,ariaAtomic:VM,ariaAutoComplete:null,ariaBusy:VM,ariaChecked:VM,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:UM,ariaCurrent:null,ariaDescribedBy:UM,ariaDetails:null,ariaDisabled:VM,ariaDropEffect:UM,ariaErrorMessage:null,ariaExpanded:VM,ariaFlowTo:UM,ariaGrabbed:VM,ariaHasPopup:null,ariaHidden:VM,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:UM,ariaLevel:Q,ariaLive:null,ariaModal:VM,ariaMultiLine:VM,ariaMultiSelectable:VM,ariaOrientation:null,ariaOwns:UM,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:VM,ariaReadOnly:VM,ariaRelevant:null,ariaRequired:VM,ariaRoleDescription:UM,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:VM,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function QM(e,t){return t in e?e[t]:t}function $M(e,t){return QM(e,t.toLowerCase())}var eN=XM({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:WM,acceptCharset:UM,accessKey:UM,action:null,allow:null,allowFullScreen:BM,allowPaymentRequest:BM,allowUserMedia:BM,alt:null,as:null,async:BM,autoCapitalize:null,autoComplete:UM,autoFocus:BM,autoPlay:BM,blocking:UM,capture:null,charSet:null,checked:BM,cite:null,className:UM,cols:Q,colSpan:null,content:null,contentEditable:VM,controls:BM,controlsList:UM,coords:Q|WM,crossOrigin:null,data:null,dateTime:null,decoding:null,default:BM,defer:BM,dir:null,dirName:null,disabled:BM,download:HM,draggable:VM,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:BM,formTarget:null,headers:UM,height:Q,hidden:HM,high:Q,href:null,hrefLang:null,htmlFor:UM,httpEquiv:UM,id:null,imageSizes:null,imageSrcSet:null,inert:BM,inputMode:null,integrity:null,is:null,isMap:BM,itemId:null,itemProp:UM,itemRef:UM,itemScope:BM,itemType:UM,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:BM,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:BM,muted:BM,name:null,nonce:null,noModule:BM,noValidate:BM,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:BM,optimum:Q,pattern:null,ping:UM,placeholder:null,playsInline:BM,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:BM,referrerPolicy:null,rel:UM,required:BM,reversed:BM,rows:Q,rowSpan:Q,sandbox:UM,scope:null,scoped:BM,seamless:BM,selected:BM,shadowRootClonable:BM,shadowRootDelegatesFocus:BM,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:VM,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:BM,useMap:null,value:VM,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:UM,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:BM,declare:BM,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:BM,noHref:BM,noShade:BM,noWrap:BM,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:VM,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:BM,disableRemotePlayback:BM,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:$M}),tN=XM({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:GM,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:UM,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:BM,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:WM,g2:WM,glyphName:WM,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:GM,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:UM,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:GM,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:GM,rev:GM,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:GM,requiredFeatures:GM,requiredFonts:GM,requiredFormats:GM,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:GM,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:GM,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:GM,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:QM}),nN=XM({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),rN=XM({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:$M}),iN=XM({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),aN={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},oN=/[A-Z]/g,sN=/-[a-z]/g,cN=/^data[-\w.:]+$/i;function lN(e,t){let n=IM(t),r=t,i=LM;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&cN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(sN,dN);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!sN.test(e)){let n=e.replace(oN,uN);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=JM}return new i(r,t)}function uN(e){return`-`+e.toLowerCase()}function dN(e){return e.charAt(1).toUpperCase()}var fN=FM([ZM,eN,nN,rN,iN],`html`),pN=FM([ZM,tN,nN,rN,iN],`svg`);function mN(e){return e.join(` `).trim()}var hN=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
96
- `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),gN=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(hN());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),_N=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),vN=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(gN()),r=_N();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),yN=xN(`end`),bN=xN(`start`);function xN(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function SN(e){let t=bN(e),n=yN(e);if(t&&n)return{start:t,end:n}}function CN(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?TN(e.position):`start`in e||`end`in e?TN(e):`line`in e||`column`in e?wN(e):``}function wN(e){return EN(e&&e.line)+`:`+EN(e&&e.column)}function TN(e){return wN(e&&e.start)+`-`+wN(e&&e.end)}function EN(e){return e&&typeof e==`number`?e:1}var DN=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=CN(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};DN.prototype.file=``,DN.prototype.name=``,DN.prototype.reason=``,DN.prototype.message=``,DN.prototype.stack=``,DN.prototype.column=void 0,DN.prototype.line=void 0,DN.prototype.ancestors=void 0,DN.prototype.cause=void 0,DN.prototype.fatal=void 0,DN.prototype.place=void 0,DN.prototype.ruleId=void 0,DN.prototype.source=void 0;var ON=u(vN(),1),kN={}.hasOwnProperty,AN=new Map,jN=/[A-Z]/g,MN=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),NN=new Set([`td`,`th`]),PN=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function FN(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=KN(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=GN(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?pN:fN,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=IN(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function IN(e,t,n){if(t.type===`element`)return LN(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return RN(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return BN(e,t,n);if(t.type===`mdxjsEsm`)return zN(e,t);if(t.type===`root`)return VN(e,t,n);if(t.type===`text`)return HN(e,t)}function LN(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=pN,e.schema=i),e.ancestors.push(t);let a=QN(e,t.tagName,!1),o=qN(e,t),s=YN(e,t);return MN.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!MM(e):!0})),UN(e,o,a,t),WN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function RN(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}$N(e,t.position)}function zN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);$N(e,t.position)}function BN(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=pN,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:QN(e,t.name,!0),o=JN(e,t),s=YN(e,t);return UN(e,o,a,t),WN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function VN(e,t,n){let r={};return WN(r,YN(e,t)),e.create(t,e.Fragment,r,n)}function HN(e,t){return t.value}function UN(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function WN(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function GN(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function KN(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=bN(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function qN(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&kN.call(t.properties,i)){let a=XN(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&NN.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function JN(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else $N(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else $N(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function YN(e,t){let n=[],r=-1,i=e.passKeys?new Map:AN;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=IN(e,a,o);s!==void 0&&n.push(s)}return n}function XN(e,t,n){let r=lN(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?EM(n):mN(n)),r.property===`style`){let t=typeof n==`object`?n:ZN(e,String(n));return e.stylePropertyNameCase===`css`&&(t=eP(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?aN[r.property]||r.property:r.attribute,n]}}function ZN(e,t){try{return(0,ON.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new DN("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=PN+`#cannot-parse-style-attribute`,r}}function QN(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=AM(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=AM(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return kN.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);$N(e)}function $N(e,t){let n=new DN("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=PN+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function eP(e){let t={},n;for(n in e)kN.call(e,n)&&(t[tP(n)]=e[n]);return t}function tP(e){let t=e.replace(jN,nP);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function nP(e){return`-`+e.toLowerCase()}var rP={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},iP={};function aP(e,t){let n=t||iP;return oP(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function oP(e,t,n){if(cP(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return sP(e.children,t,n)}return Array.isArray(e)?sP(e,t,n):``}function sP(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=oP(e[i],t,n);return r.join(``)}function cP(e){return!!(e&&typeof e==`object`)}var lP=document.createElement(`i`);function uP(e){let t=`&`+e+`;`;lP.innerHTML=t;let n=lP.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function dP(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function fP(e,t){return e.length>0?(dP(e,e.length,0,t),e):t}var pP={}.hasOwnProperty;function mP(e){let t={},n=-1;for(;++n<e.length;)hP(t,e[n]);return t}function hP(e,t){let n;for(n in t){let r=(pP.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){pP.call(r,a)||(r[a]=[]);let e=i[a];gP(r[a],Array.isArray(e)?e:e?[e]:[])}}}function gP(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);dP(e,0,0,r)}function _P(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function vP(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var yP=jP(/[A-Za-z]/),bP=jP(/[\dA-Za-z]/),xP=jP(/[#-'*+\--9=?A-Z^-~]/);function SP(e){return e!==null&&(e<32||e===127)}var CP=jP(/\d/),wP=jP(/[\dA-Fa-f]/),TP=jP(/[!-/:-@[-`{-~]/);function EP(e){return e!==null&&e<-2}function DP(e){return e!==null&&(e<0||e===32)}function OP(e){return e===-2||e===-1||e===32}var kP=jP(/\p{P}|\p{S}/u),AP=jP(/\s/);function jP(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function MP(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&bP(e.charCodeAt(n+1))&&bP(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function NP(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return OP(r)?(e.enter(n),s(r)):t(r)}function s(r){return OP(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var PP={tokenize:FP};function FP(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),NP(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return EP(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var IP={tokenize:RP},LP={tokenize:zP};function RP(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return dP(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(LP,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(LP,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return EP(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;dP(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function zP(e,t,n){return NP(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function BP(e){if(e===null||DP(e)||AP(e))return 1;if(kP(e))return 2}function VP(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var HP={name:`attention`,resolveAll:UP,tokenize:WP};function UP(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};GP(d,-c),GP(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=fP(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=fP(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=fP(l,VP(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=fP(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=fP(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,dP(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function WP(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=BP(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=BP(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function GP(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var KP={name:`autolink`,tokenize:qP};function qP(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return yP(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||bP(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||bP(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||SP(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):xP(t)?(e.consume(t),l):n(t)}function u(e){return bP(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||bP(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var JP={partial:!0,tokenize:YP};function YP(e,t,n){return r;function r(t){return OP(t)?NP(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||EP(e)?t(e):n(e)}}var XP={continuation:{tokenize:QP},exit:$P,name:`blockQuote`,tokenize:ZP};function ZP(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return OP(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function QP(e,t,n){let r=this;return i;function i(t){return OP(t)?NP(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(XP,t,n)(r)}}function $P(e){e.exit(`blockQuote`)}var eF={name:`characterEscape`,tokenize:tF};function tF(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return TP(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var nF={name:`characterReference`,tokenize:rF};function rF(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=bP,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=wP,u):(e.enter(`characterReferenceValue`),a=7,o=CP,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===bP&&!uP(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var iF={partial:!0,tokenize:sF},aF={concrete:!0,name:`codeFenced`,tokenize:oF};function oF(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),OP(t)?NP(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||EP(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(iF,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||EP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):OP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),NP(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||EP(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||EP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&OP(t)?NP(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||EP(t)?e.check(iF,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||EP(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),OP(t)?NP(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),OP(t)?NP(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||EP(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function sF(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var cF={name:`codeIndented`,tokenize:uF},lF={partial:!0,tokenize:dF};function uF(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),NP(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):EP(t)?e.attempt(lF,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||EP(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function dF(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):EP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):NP(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):EP(e)?i(e):n(e)}}var fF={name:`codeText`,previous:mF,resolve:pF,tokenize:hF};function pF(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function mF(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function hF(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):EP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||EP(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var gF=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&_F(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),_F(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),_F(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);_F(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);_F(this.left,t.reverse())}}};function _F(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function vF(e){let t={},n=-1,r,i,a,o,s,c,l,u=new gF(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,yF(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return dP(e,0,1/0,u.slice(0)),!l}function yF(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var bF={resolve:SF,tokenize:CF},xF={partial:!0,tokenize:wF};function SF(e){return vF(e),e}function CF(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):EP(t)?e.check(xF,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function wF(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),NP(e,a,`linePrefix`)}function a(i){if(i===null||EP(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function TF(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||SP(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||EP(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||DP(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||SP(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function EF(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):EP(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||EP(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!OP(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function DF(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):EP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),NP(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||EP(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function OF(e,t){let n;return r;function r(i){return EP(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):OP(i)?NP(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var kF={name:`definition`,tokenize:jF},AF={partial:!0,tokenize:MF};function jF(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return EF.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=vP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return DP(t)?OF(e,l)(t):l(t)}function l(t){return TF(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(AF,d,d)(t)}function d(t){return OP(t)?NP(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||EP(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function MF(e,t,n){return r;function r(t){return DP(t)?OF(e,i)(t):n(t)}function i(t){return DF(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return OP(t)?NP(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||EP(e)?t(e):n(e)}}var NF={name:`hardBreakEscape`,tokenize:PF};function PF(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return EP(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var FF={name:`headingAtx`,resolve:IF,tokenize:LF};function IF(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},dP(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function LF(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||DP(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||EP(n)?(e.exit(`atxHeading`),t(n)):OP(n)?NP(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||DP(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var RF=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),zF=[`pre`,`script`,`style`,`textarea`],BF={concrete:!0,name:`htmlFlow`,resolveTo:UF,tokenize:WF},VF={partial:!0,tokenize:KF},HF={partial:!0,tokenize:GF};function UF(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function WF(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):yP(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):yP(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return yP(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||DP(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&zF.includes(l)?(i=1,r.interrupt?t(s):O(s)):RF.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||bP(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return OP(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||yP(t)?(e.consume(t),b):OP(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||bP(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):OP(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):OP(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||EP(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||DP(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||OP(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||EP(t)?O(t):OP(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):EP(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(VF,R,k)(t)):t===null||EP(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(HF,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||EP(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return zF.includes(n)?(e.consume(t),L):O(t)}return yP(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||EP(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function GF(e,t,n){let r=this;return i;function i(t){return EP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function KF(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(JP,t,n)}}var qF={name:`htmlText`,tokenize:JF};function JF(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):yP(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):yP(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):EP(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):EP(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):EP(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):EP(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return yP(t)?(e.consume(t),S):n(t)}function S(t){return t===45||bP(t)?(e.consume(t),S):C(t)}function C(t){return EP(t)?(o=C,N(t)):OP(t)?(e.consume(t),C):M(t)}function w(t){return t===45||bP(t)?(e.consume(t),w):t===47||t===62||DP(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||yP(t)?(e.consume(t),E):EP(t)?(o=T,N(t)):OP(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||bP(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):EP(t)?(o=D,N(t)):OP(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):EP(t)?(o=O,N(t)):OP(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):EP(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||DP(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||DP(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return OP(t)?NP(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var YF={name:`labelEnd`,resolveAll:$F,resolveTo:eI,tokenize:tI},XF={tokenize:nI},ZF={tokenize:rI},QF={tokenize:iI};function $F(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&dP(e,0,e.length,n),e}function eI(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=fP(s,e.slice(a+1,a+r+3)),s=fP(s,[[`enter`,u,t]]),s=fP(s,VP(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=fP(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=fP(s,e.slice(o+1)),s=fP(s,[[`exit`,c,t]]),dP(e,a,e.length,s),e}function tI(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(vP(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(XF,u,o?u:d)(t):t===91?e.attempt(ZF,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(QF,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function nI(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return DP(t)?OF(e,a)(t):a(t)}function a(t){return t===41?u(t):TF(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return DP(t)?OF(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?DF(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return DP(t)?OF(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function rI(e,t,n){let r=this;return i;function i(t){return EF.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(vP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function iI(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var aI={name:`labelStartImage`,resolveAll:YF.resolveAll,tokenize:oI};function oI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var sI={name:`labelStartLink`,resolveAll:YF.resolveAll,tokenize:cI};function cI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var lI={name:`lineEnding`,tokenize:uI};function uI(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),NP(e,t,`linePrefix`)}}var dI={name:`thematicBreak`,tokenize:fI};function fI(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||EP(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),OP(t)?NP(e,s,`whitespace`)(t):s(t))}}var pI={continuation:{tokenize:_I},exit:yI,name:`list`,tokenize:gI},mI={partial:!0,tokenize:bI},hI={partial:!0,tokenize:vI};function gI(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:CP(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(dI,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return CP(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(JP,r.interrupt?n:u,e.attempt(mI,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return OP(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function _I(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(JP,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,NP(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!OP(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(hI,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,NP(e,e.attempt(pI,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function vI(e,t,n){let r=this;return NP(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function yI(e){e.exit(this.containerState.type)}function bI(e,t,n){let r=this;return NP(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!OP(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var xI={name:`setextUnderline`,resolveTo:SI,tokenize:CI};function SI(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function CI(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),OP(t)?NP(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||EP(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var wI={tokenize:TI};function TI(e){let t=this,n=e.attempt(JP,r,e.attempt(this.parser.constructs.flowInitial,i,NP(e,e.attempt(this.parser.constructs.flow,i,e.attempt(bF,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var EI={resolveAll:AI()},DI=kI(`string`),OI=kI(`text`);function kI(e){return{resolveAll:AI(e===`text`?jI:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function AI(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function jI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var MI=c({attentionMarkers:()=>BI,contentInitial:()=>PI,disable:()=>VI,document:()=>NI,flow:()=>II,flowInitial:()=>FI,insideSpan:()=>zI,string:()=>LI,text:()=>RI}),NI={42:pI,43:pI,45:pI,48:pI,49:pI,50:pI,51:pI,52:pI,53:pI,54:pI,55:pI,56:pI,57:pI,62:XP},PI={91:kF},FI={[-2]:cF,[-1]:cF,32:cF},II={35:FF,42:dI,45:[xI,dI],60:BF,61:xI,95:dI,96:aF,126:aF},LI={38:nF,92:eF},RI={[-5]:lI,[-4]:lI,[-3]:lI,33:aI,38:nF,42:HP,60:[KP,qF],91:sI,92:[NF,eF],93:YF,95:HP,96:fF},zI={null:[HP,EI]},BI={null:[42,95]},VI={null:[]};function HI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=fP(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=VP(a,l.events,l),l.events):[]}function f(e,t){return WI(p(e),t)}function p(e){return UI(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){EP(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&dP(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function UI(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function WI(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
95
+ `},JO={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function YO(e){let{announcements:t=JO,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=qO}=e,{announce:a,announcement:o}=UO(),s=kO(`DndLiveRegion`),[c,l]=(0,b.useState)(!1);if((0,b.useEffect)(()=>{l(!0)},[]),GO((0,b.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=b.createElement(b.Fragment,null,b.createElement(VO,{id:r,value:i.draggable}),b.createElement(HO,{id:s,announcement:o}));return n?(0,kt.createPortal)(u,n):u}var XO;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(XO||={});function ZO(){}function QO(e,t){return(0,b.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function $O(){var e=[...arguments];return(0,b.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var ek=Object.freeze({x:0,y:0});function tk(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function nk(e,t){let n=IO(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function rk(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ik(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function ak(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function ok(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function sk(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var ck=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=sk(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(ik)};function lk(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var uk=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&lk(r,a)){let n=ak(a).reduce((e,t)=>e+tk(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(rk)};function dk(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function fk(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ek}function pk(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var mk=pk(1);function hk(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function gk(e,t,n){let r=hk(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var _k={ignoreTransform:!1};function vk(e,t){t===void 0&&(t=_k);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=gO(e).getComputedStyle(e);t&&(n=gk(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function yk(e){return vk(e,{ignoreTransform:!0})}function bk(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function xk(e,t){return t===void 0&&(t=gO(e).getComputedStyle(e)),t.position===`fixed`}function Sk(e,t){t===void 0&&(t=gO(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function Ck(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(_O(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!vO(i)||yO(i)||n.includes(i))return n;let a=gO(e).getComputedStyle(i);return i!==e&&Sk(i,a)&&n.push(i),xk(i,a)?n:r(i.parentNode)}return e?r(e):n}function wk(e){let[t]=Ck(e,1);return t??null}function Tk(e){return!pO||!e?null:mO(e)?e:hO(e)?_O(e)||e===bO(e).scrollingElement?window:vO(e)?e:null:null}function Ek(e){return mO(e)?e.scrollX:e.scrollLeft}function Dk(e){return mO(e)?e.scrollY:e.scrollTop}function Ok(e){return{x:Ek(e),y:Dk(e)}}var kk;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(kk||={});function Ak(e){return!pO||!e?!1:e===document.scrollingElement}function jk(e){let t={x:0,y:0},n=Ak(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Mk={x:.2,y:.2};function Nk(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Mk);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=jk(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=kk.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=kk.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=kk.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=kk.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Pk(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Fk(e){return e.reduce((e,t)=>jO(e,Ok(t)),ek)}function Ik(e){return e.reduce((e,t)=>e+Ek(t),0)}function Lk(e){return e.reduce((e,t)=>e+Dk(t),0)}function Rk(e,t){if(t===void 0&&(t=vk),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);wk(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var zk=[[`x`,[`left`,`right`],Ik],[`y`,[`top`,`bottom`],Lk]],Bk=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Ck(t),r=Fk(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of zk)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Vk=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Hk(e){let{EventTarget:t}=gO(e);return e instanceof t?e:bO(e)}function Uk(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Wk;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Wk||={});function Gk(e){e.preventDefault()}function Kk(e){e.stopPropagation()}var qk;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(qk||={});var Jk={start:[qk.Space,qk.Enter],cancel:[qk.Esc],end:[qk.Space,qk.Enter,qk.Tab]},Yk=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case qk.Right:return{...n,x:n.x+25};case qk.Left:return{...n,x:n.x-25};case qk.Down:return{...n,y:n.y+25};case qk.Up:return{...n,y:n.y-25}}},Xk=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Vk(bO(t)),this.windowListeners=new Vk(gO(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Wk.Resize,this.handleCancel),this.windowListeners.add(Wk.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Wk.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Rk(n),t(ek)}handleKeyDown(e){if(PO(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Jk,coordinateGetter:a=Yk,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:ek;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=MO(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=jk(n),p=Pk(n),m={x:Math.min(i===qk.Right?p.right-p.width/2:p.right,Math.max(i===qk.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===qk.Down?p.bottom-p.height/2:p.bottom,Math.max(i===qk.Down?p.top:p.top+p.height/2,u.y))},h=i===qk.Right&&!s||i===qk.Left&&!c,g=i===qk.Down&&!l||i===qk.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===qk.Right&&e<=d.x||i===qk.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===qk.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===qk.Down&&e<=d.y||i===qk.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===qk.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,jO(MO(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Xk.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Jk,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Zk(e){return!!(e&&`distance`in e)}function Qk(e){return!!(e&&`delay`in e)}var $k=class{constructor(e,t,n){n===void 0&&(n=Hk(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=bO(i),this.documentListeners=new Vk(this.document),this.listeners=new Vk(n),this.windowListeners=new Vk(gO(i)),this.initialCoordinates=IO(r)??ek,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Wk.Resize,this.handleCancel),this.windowListeners.add(Wk.DragStart,Gk),this.windowListeners.add(Wk.VisibilityChange,this.handleCancel),this.windowListeners.add(Wk.ContextMenu,Gk),this.documentListeners.add(Wk.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Qk(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Zk(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Wk.Click,Kk,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Wk.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=IO(e)??ek,s=MO(n,o);if(!t&&a){if(Zk(a)){if(a.tolerance!=null&&Uk(s,a.tolerance))return this.handleCancel();if(Uk(s,a.distance))return this.handleStart()}if(Qk(a)&&Uk(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===qk.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},eA={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},tA=class extends $k{constructor(e){let{event:t}=e,n=bO(t.target);super(e,eA,n)}};tA.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var nA={move:{name:`mousemove`},end:{name:`mouseup`}},rA;(function(e){e[e.RightClick=2]=`RightClick`})(rA||={});var iA=class extends $k{constructor(e){super(e,nA,bO(e.event.target))}};iA.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===rA.RightClick?!1:(r?.({event:n}),!0)}}];var aA={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},oA=class extends $k{constructor(e){super(e,aA)}static setup(){return window.addEventListener(aA.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(aA.move.name,e)};function e(){}}};oA.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var sA;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(sA||={});var cA;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(cA||={});function lA(e){let{acceleration:t,activator:n=sA.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=cA.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=dA({delta:d,disabled:!a}),[m,h]=CO(),g=(0,b.useRef)({x:0,y:0}),_=(0,b.useRef)({x:0,y:0}),v=(0,b.useMemo)(()=>{switch(n){case sA.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case sA.DraggableRect:return i}},[n,i,c]),y=(0,b.useRef)(null),x=(0,b.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),S=(0,b.useMemo)(()=>s===cA.TreeOrder?[...l].reverse():l,[s,l]);(0,b.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Nk(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(x,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,x,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,S,u,JSON.stringify(f)])}var uA={x:{[kk.Backward]:!1,[kk.Forward]:!1},y:{[kk.Backward]:!1,[kk.Forward]:!1}};function dA(e){let{delta:t,disabled:n}=e,r=DO(t);return TO(e=>{if(n||!r||!e)return uA;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[kk.Backward]:e.x[kk.Backward]||i.x===-1,[kk.Forward]:e.x[kk.Forward]||i.x===1},y:{[kk.Backward]:e.y[kk.Backward]||i.y===-1,[kk.Forward]:e.y[kk.Forward]||i.y===1}}},[n,t,r])}function fA(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return TO(e=>t==null?null:r??e??null,[r,t])}function pA(e,t){return(0,b.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var mA;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(mA||={});var hA;(function(e){e.Optimized=`optimized`})(hA||={});var gA=new Map;function _A(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,b.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,b.useRef)(e),d=g(),f=wO(d),p=(0,b.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,b.useRef)(null),h=TO(t=>{if(d&&!n)return gA;if(!t||t===gA||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Bk(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,b.useEffect)(()=>{u.current=e},[e]),(0,b.useEffect)(()=>{d||p()},[n,d]),(0,b.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,b.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case mA.Always:return!1;case mA.BeforeDragging:return n;default:return!n}}}function vA(e,t){return TO(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function yA(e,t){return vA(e,t)}function bA(e){let{callback:t,disabled:n}=e,r=SO(t),i=(0,b.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,b.useEffect)(()=>()=>i?.disconnect(),[i]),i}function xA(e){let{callback:t,disabled:n}=e,r=SO(t),i=(0,b.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,b.useEffect)(()=>()=>i?.disconnect(),[i]),i}function SA(e){return new Bk(vk(e),e)}function CA(e,t,n){t===void 0&&(t=SA);let[r,i]=(0,b.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=bA({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=xA({callback:a});return xO(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function wA(e){return fk(e,vA(e))}var TA=[];function EA(e){let t=(0,b.useRef)(e),n=TO(n=>e?n&&n!==TA&&e&&t.current&&e.parentNode===t.current.parentNode?n:Ck(e):TA,[e]);return(0,b.useEffect)(()=>{t.current=e},[e]),n}function DA(e){let[t,n]=(0,b.useState)(null),r=(0,b.useRef)(e),i=(0,b.useCallback)(e=>{let t=Tk(e.target);t&&n(e=>e?(e.set(t,Ok(t)),new Map(e)):null)},[]);return(0,b.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Tk(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Ok(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Tk(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,b.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>jO(e,t),ek):Fk(e):ek,[e,t])}function OA(e,t){t===void 0&&(t=[]);let n=(0,b.useRef)(null);return(0,b.useEffect)(()=>{n.current=null},t),(0,b.useEffect)(()=>{let t=e!==ek;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?MO(e,n.current):ek}function kA(e){(0,b.useEffect)(()=>{if(!pO)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function AA(e,t){return(0,b.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function jA(e){return(0,b.useMemo)(()=>e?bk(e):null,[e])}var MA=[];function NA(e,t){t===void 0&&(t=vk);let[n]=e,r=jA(n?gO(n):null),[i,a]=(0,b.useState)(MA);function o(){a(()=>e.length?e.map(e=>Ak(e)?r:new Bk(t(e),e)):MA)}let s=xA({callback:o});return xO(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function PA(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return vO(t)?t:e}function FA(e){let{measure:t}=e,[n,r]=(0,b.useState)(null),i=xA({callback:(0,b.useCallback)(e=>{for(let{target:n}of e)if(vO(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=EO((0,b.useCallback)(e=>{let n=PA(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,b.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var IA=[{sensor:tA,options:{}},{sensor:Xk,options:{}}],LA={current:{}},RA={draggable:{measure:yk},droppable:{measure:yk,strategy:mA.WhileDragging,frequency:hA.Optimized},dragOverlay:{measure:vk}},zA=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},BA={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new zA,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ZO},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:RA,measureDroppableContainers:ZO,windowRect:null,measuringScheduled:!1},VA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:ZO,draggableNodes:new Map,over:null,measureDroppableContainers:ZO},HA=(0,b.createContext)(VA),UA=(0,b.createContext)(BA);function WA(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new zA}}}function GA(e,t){switch(t.type){case XO.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case XO.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case XO.DragEnd:case XO.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case XO.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new zA(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case XO.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new zA(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case XO.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new zA(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function KA(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,b.useContext)(HA),a=DO(r),o=DO(n?.id);return(0,b.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!PO(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=zO(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function qA(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function JA(e){return(0,b.useMemo)(()=>({draggable:{...RA.draggable,...e?.draggable},droppable:{...RA.droppable,...e?.droppable},dragOverlay:{...RA.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function YA(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,b.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;xO(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=fk(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=wk(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var XA=(0,b.createContext)({...ek,scaleX:1,scaleY:1}),ZA;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(ZA||={});var QA=(0,b.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=IA,collisionDetection:o=ck,measuring:s,modifiers:c,...l}=e,[u,d]=(0,b.useReducer)(GA,void 0,WA),[f,p]=KO(),[m,h]=(0,b.useState)(ZA.Uninitialized),g=m===ZA.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:x}}=u,S=_==null?null:v.get(_),C=(0,b.useRef)({initial:null,translated:null}),w=(0,b.useMemo)(()=>_==null?null:{id:_,data:S?.data??LA,rect:C},[_,S]),T=(0,b.useRef)(null),[E,D]=(0,b.useState)(null),[O,k]=(0,b.useState)(null),A=wO(l,Object.values(l)),j=kO(`DndDescribedBy`,t),M=(0,b.useMemo)(()=>x.getEnabled(),[x]),N=JA(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=_A(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=fA(v,_),R=(0,b.useMemo)(()=>O?IO(O):null,[O]),z=Ce(),ee=yA(L,N.draggable.measure);YA({activeNode:_==null?null:v.get(_),config:z.layoutShiftCompensation,initialRect:ee,measure:N.draggable.measure});let B=CA(L,N.draggable.measure,ee),V=CA(L?L.parentElement:null),H=(0,b.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:x,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),te=x.getNodeFor(H.current.over?.id),U=FA({measure:N.dragOverlay.measure}),ne=U.nodeRef.current??L,W=g?U.rect??B:null,re=!!(U.nodeRef.current&&U.rect),ie=wA(re?null:B),ae=jA(ne?gO(ne):null),G=EA(g?te??L:null),oe=NA(G),se=qA(c,{transform:{x:y.x-ie.x,y:y.y-ie.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:W,over:H.current.over,overlayNodeRect:U.rect,scrollableAncestors:G,scrollableAncestorRects:oe,windowRect:ae}),ce=R?jO(R,y):null,le=DA(G),ue=OA(le),de=OA(le,[B]),K=jO(se,ue),fe=W?mk(W,se):null,pe=w&&fe?o({active:w,collisionRect:fe,droppableRects:P,droppableContainers:M,pointerCoordinates:ce}):null,me=ok(pe,`id`),[he,ge]=(0,b.useState)(null),_e=dk(re?se:jO(se,de),he?.rect??null,B),ve=(0,b.useRef)(null),ye=(0,b.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;ve.current=new n({active:T.current,activeNode:i,event:a,options:r,context:H,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:C}};(0,kt.unstable_batchedUpdates)(()=>{r?.(i),h(ZA.Initializing),d({type:XO.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(ve.current),k(a)})},onMove(e){d({type:XO.DragMove,coordinates:e})},onEnd:o(XO.DragEnd),onCancel:o(XO.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=H.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===XO.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=XO.DragCancel)}T.current=null,(0,kt.unstable_batchedUpdates)(()=>{d({type:e}),h(ZA.Uninitialized),ge(null),D(null),k(null),ve.current=null;let t=e===XO.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),be=pA(a,(0,b.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,ye(n,t))},[v,ye]));kA(a),xO(()=>{B&&m===ZA.Initializing&&h(ZA.Initialized)},[B,m]),(0,b.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=H.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:K.x,y:K.y},over:i};(0,kt.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[K.x,K.y]),(0,b.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=H.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(me),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,kt.unstable_batchedUpdates)(()=>{ge(s),a?.(c),f({type:`onDragOver`,event:c})})},[me]),xO(()=>{H.current={activatorEvent:O,active:w,activeNode:L,collisionRect:fe,collisions:pe,droppableRects:P,draggableNodes:v,draggingNode:ne,draggingNodeRect:W,droppableContainers:x,over:he,scrollableAncestors:G,scrollAdjustedTranslate:K},C.current={initial:W,translated:fe}},[w,L,pe,fe,v,ne,W,P,x,he,G,K]),lA({...z,delta:y,draggingRect:fe,pointerCoordinates:ce,scrollableAncestors:G,scrollableAncestorRects:oe});let xe=(0,b.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:B,activatorEvent:O,collisions:pe,containerNodeRect:V,dragOverlay:U,draggableNodes:v,droppableContainers:x,droppableRects:P,over:he,measureDroppableContainers:F,scrollableAncestors:G,scrollableAncestorRects:oe,measuringConfiguration:N,measuringScheduled:I,windowRect:ae}),[w,L,B,O,pe,V,U,v,x,P,he,F,G,oe,N,I,ae]),Se=(0,b.useMemo)(()=>({activatorEvent:O,activators:be,active:w,activeNodeRect:B,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:he,measureDroppableContainers:F}),[O,be,w,B,d,j,v,he,F]);return b.createElement(WO.Provider,{value:p},b.createElement(HA.Provider,{value:Se},b.createElement(UA.Provider,{value:xe},b.createElement(XA.Provider,{value:_e},i)),b.createElement(KA,{disabled:n?.restoreFocus===!1})),b.createElement(YO,{...n,hiddenTextDescribedById:j}));function Ce(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),$A=(0,b.createContext)(null),ej=`button`,tj=`Draggable`;function nj(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=kO(tj),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,b.useContext)(HA),{role:p=ej,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,b.useContext)(g?XA:$A),[v,y]=EO(),[x,S]=EO(),C=AA(o,t),w=wO(n);return xO(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:x,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,b.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===ej?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:v,over:f,setNodeRef:y,setActivatorNodeRef:S,transform:_}}function rj(){return(0,b.useContext)(UA)}var ij=`Droppable`,aj={timeout:25};function oj(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=kO(ij),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,b.useContext)(HA),u=(0,b.useRef)({disabled:n}),d=(0,b.useRef)(!1),f=(0,b.useRef)(null),p=(0,b.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...aj,...i},_=wO(h??r),v=xA({callback:(0,b.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,x]=EO((0,b.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),S=wO(t);return(0,b.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,b.useEffect)(()=>(s({type:XO.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:S}}),()=>s({type:XO.UnregisterDroppable,key:a,id:r})),[r]),(0,b.useEffect)(()=>{n!==u.current.disabled&&(s({type:XO.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:x}}function sj(e){let{animation:t,children:n}=e,[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),s=DO(n);return!n&&!r&&s&&i(s),xO(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),b.createElement(b.Fragment,null,n,r?(0,b.cloneElement)(r,{ref:o}):null)}var cj={x:0,y:0,scaleX:1,scaleY:1};function lj(e){let{children:t}=e;return b.createElement(HA.Provider,{value:VA},b.createElement(XA.Provider,{value:cj},t))}var uj={position:`fixed`,touchAction:`none`},dj=e=>PO(e)?`transform 250ms ease`:void 0,fj=(0,b.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=dj}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...uj,width:s.width,height:s.height,top:s.top,left:s.left,transform:LO.Transform.toString(d),transformOrigin:i&&r?nk(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return b.createElement(n,{className:o,style:f,ref:t},a)}),pj={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:LO.Transform.toString(t)},{transform:LO.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function mj(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return SO((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=PA(a);if(!c)return;let{transform:l}=gO(a).getComputedStyle(a),u=hk(l);if(!u)return;let d=typeof t==`function`?t:hj(t);return Rk(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function hj(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...pj,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var gj=0;function _j(e){return(0,b.useMemo)(()=>{if(e!=null)return gj++,gj},[e])}var vj=b.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:x,windowRect:S}=rj(),C=(0,b.useContext)(XA),w=_j(d?.id),T=qA(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:x,transform:C,windowRect:S}),E=vA(f),D=mj({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),O=E?g.setRef:void 0;return b.createElement(lj,null,b.createElement(sj,{animation:D},d&&w?b.createElement(fj,{key:w,id:d.id,ref:O,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:E,style:{zIndex:l,...i},transform:T},n):null))}),yj=async(e,t,n=null)=>{let r=new URLSearchParams({tool:e});n&&r.set(`project_id`,n);let i=await O(C(`/skills?${r.toString()}`),{signal:t,cache:`no-store`});return Array.isArray(i)?i.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.description==`string`}):[]},bj=e=>(0,q.jsx)(Iu,{"data-slot":`dropdown-menu`,...e}),xj=e=>(0,q.jsx)(Lu,{"data-slot":`dropdown-menu-trigger`,...e}),Sj=({className:e,align:t=`end`,sideOffset:n=6,...r})=>(0,q.jsx)(Ru,{children:(0,q.jsx)(zu,{"data-slot":`dropdown-menu-content`,align:t,sideOffset:n,className:J(`z-50 min-w-44 overflow-hidden rounded-xl border border-border bg-popover p-1 text-sm text-popover-foreground shadow-2xl shadow-black/30 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r})}),Cj=({className:e,inset:t=!1,...n})=>(0,q.jsx)(Bu,{"data-slot":`dropdown-menu-item`,"data-inset":t,className:J(`relative flex cursor-default select-none items-center gap-2 rounded-lg px-2.5 py-2 text-sm outline-hidden transition-colors data-[disabled]:opacity-50 data-[disabled]:text-muted-foreground focus:bg-accent focus:text-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}),wj={draft:`border-sky-400/30 bg-sky-500/15 text-sky-100`,open:`border-emerald-400/30 bg-emerald-500/15 text-emerald-100`,merged:`border-violet-400/30 bg-violet-500/15 text-violet-100`,closed:`border-slate-400/30 bg-slate-500/15 text-slate-200`},Tj={draft:`PR Draft`,open:`PR Open`,merged:`PR Merged`,closed:`PR Closed`},Ej=({pullRequest:e,asLink:t=!1,onClick:n,onPointerDown:r,showNumber:i=!1})=>{let a=i?`PR #${e.number} ${e.state}`:Tj[e.state],o=(0,q.jsx)(Z,{variant:`outline`,className:wj[e.state],children:a});return t?(0,q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex underline underline-offset-2 decoration-current hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:n,onPointerDown:r,children:o}):o},Dj=({className:e})=>(0,q.jsx)($m,{"aria-hidden":`true`,className:e}),Oj=({className:e})=>(0,q.jsx)(Gm,{"aria-hidden":`true`,className:e}),kj={plan:0,build:1,review:2},Aj={plan:`build`,build:`review`},jj=e=>Aj[e]??null,Mj=e=>e===`plan`?`plan`:e===`build`||e===`review`||e===`done`?`build`:`default`,Nj=e=>e.worktree_bundle_id??e.id,Pj=e=>e.state===`build`||e.state===`review`&&e.review_follow_up_active===!0,Fj=e=>e.parked_at!==null,Ij=e=>Fj(e)?`done`:e.state,Lj=e=>e.is_stale===!0,Rj=e=>e?e.files_changed===0&&e.additions===0&&e.deletions===0:!1,zj=(e,t)=>!t||e===`plan`?!1:!(e===`done`&&Rj(t)),Bj=e=>Fj(e)||e.agent_status===`running`?!1:e.state===`build`?e.agent_status===`done`:e.state===`review`,Vj=(e,t)=>Fj(e)&&e.state===t,Hj=(e,t)=>e.agent_status===`running`?!1:t===`done`?Bj(e):!(t!==`trash`&&kj[t]<=kj[e.state]||t===`review`&&(e.state!==`build`||e.agent_status!==`done`)),Uj=(e,t)=>{let n=e.created_at.localeCompare(t.created_at);if(n!==0)return n;let r=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return r===0?e.id.localeCompare(t.id):r},Wj=12,Gj=e=>({x:e.left+e.width/2,y:e.top+e.height/2}),Kj=e=>`${e.blocker_ticket_id}:${e.dependent_ticket_id}`,qj=(e,t)=>e.filter(e=>e.blocker_ticket_id!==t&&e.dependent_ticket_id!==t),Jj=(e,t)=>{let n=e.filter(e=>Kj(e)!==Kj(t));return n.push(t),n.sort((e,t)=>Kj(e).localeCompare(Kj(t))),n},Yj=(e,t,n)=>e.filter(e=>!(e.blocker_ticket_id===t&&e.dependent_ticket_id===n)),Xj=(e,t,n)=>{let r=[n],i=new Set;for(;r.length>0;){let n=r.shift();if(!(!n||i.has(n))){if(n===t)return!0;i.add(n);for(let t of e)t.blocker_ticket_id===n&&r.push(t.dependent_ticket_id)}}return!1},Zj=(e,t,n)=>t===n?{valid:!1,reason:`self`}:e.some(e=>e.blocker_ticket_id===t&&e.dependent_ticket_id===n)?{valid:!1,reason:`duplicate`}:Xj(e,t,n)?{valid:!1,reason:`cycle`}:{valid:!0},Qj=e=>e===`self`?`A ticket cannot depend on itself.`:e===`duplicate`?`This dependency already exists.`:`This dependency would create a cycle.`,$j=e=>e?e.build_completed_at!==null&&e.build_completed_at!==void 0||e.state===`review`?!0:e.state===`build`&&e.agent_status===`done`:!1,eM=e=>!e||e.has_worktree===!1?!1:e.run_setup_status===`ready`?!0:$j(e),tM=e=>{if(!(!e||e.has_worktree===!1)){if(e.run_setup_status===`preparing`)return`Setting up worktree...`;if(!eM(e))return`Run unlocks after setup finishes.`}},nM=(e,t,n)=>n.filter(t=>t.dependent_ticket_id===e.id).map(e=>t.get(e.blocker_ticket_id)).filter(e=>!!e&&!$j(e)),rM=(e,t)=>{let n=[e],r=new Set,i=new Set;for(;n.length>0;){let e=n.shift();if(!(!e||r.has(e))){r.add(e);for(let r of t)r.blocker_ticket_id===e&&(i.add(r.dependent_ticket_id),n.push(r.dependent_ticket_id))}}return i},iM=(e,t,n)=>{let r=n.get(t);if(!r){e.push(t);return}let i=!1;for(let a=0;a<e.length;a+=1){let o=n.get(e[a]);if(o&&Uj(r,o)<0){e.splice(a,0,t),i=!0;break}}i||e.push(t)},aM=(e,t,n)=>{if(!t.get(e))return[];let r=rM(e,n);if(r.size===0)return[];let i=[e,...r],a=new Set(i),o=new Map,s=new Map;for(let e of i)o.set(e,0),s.set(e,[]);for(let e of n)!a.has(e.blocker_ticket_id)||!a.has(e.dependent_ticket_id)||(s.get(e.blocker_ticket_id)?.push(e.dependent_ticket_id),o.set(e.dependent_ticket_id,(o.get(e.dependent_ticket_id)??0)+1));let c=[];for(let e of i)(o.get(e)??0)===0&&iM(c,e,t);let l=[];for(;c.length>0;){let e=c.shift();if(e){l.push(e);for(let n of s.get(e)??[]){let e=(o.get(n)??0)-1;o.set(n,e),e===0&&iM(c,n,t)}}}return l.map(e=>t.get(e)).filter(e=>!!e)},oM=(e,t,n)=>{let r=aM(e.id,t,n),i=r.filter(e=>!$j(e)),a=r.length>1,o=nM(e,t,n).length>0,s=e.state===`plan`&&a&&!o;return{buildChainOrder:r,pendingBuildChainOrder:i,hasDependents:a,hasOpenBlockers:o,canStartBuildChain:s,isVisibleStartPoint:e.build_chain?.is_root===!0||s,skippedBuildChainCount:r.length-i.length}},sM=(e,t)=>{let n=Gj(e),r=Gj(t),i=e.left+e.width,a=t.left+t.width,o=e.top+e.height,s=t.top+t.height;return e.left<a&&i>t.left?r.y>=n.y?{start:{x:n.x,y:o-Wj},end:{x:r.x,y:t.top+Wj}}:{start:{x:n.x,y:e.top+Wj},end:{x:r.x,y:s-Wj}}:r.x>=n.x?{start:{x:i-Wj,y:n.y},end:{x:t.left+Wj,y:r.y}}:{start:{x:e.left+Wj,y:n.y},end:{x:a-Wj,y:r.y}}},cM=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;if(Math.abs(n)>=Math.abs(r)){let r=Math.max(64,Math.abs(n)*.6),i={x:e.x+Math.sign(n||1)*r,y:e.y},a={x:t.x-Math.sign(n||1)*r,y:t.y};return{path:`M ${e.x} ${e.y} C ${i.x} ${i.y}, ${a.x} ${a.y}, ${t.x} ${t.y}`,angle:Math.atan2(t.y-a.y,t.x-a.x)}}let i=Math.max(18,Math.round(Math.abs(r)*.4)),a=Math.max(24,Math.min(36,Math.round(Math.abs(r)*.18+Math.abs(n)*.1))),o=Math.round(a*.35),s=n>=0?1:-1,c={x:e.x+s*a,y:e.y+Math.sign(r||1)*i},l={x:t.x+s*o,y:t.y-Math.sign(r||1)*i};return{path:`M ${e.x} ${e.y} C ${c.x} ${c.y}, ${l.x} ${l.y}, ${t.x} ${t.y}`,angle:Math.atan2(t.y-l.y,t.x-l.x)}},lM=({className:e})=>(0,q.jsx)(Hm,{"aria-hidden":`true`,className:e}),uM=({className:e})=>(0,q.jsx)(Wm,{"aria-hidden":`true`,className:e}),dM=({label:e,className:t})=>(0,q.jsxs)(Z,{className:J(`inline-flex w-fit items-center gap-2 px-3 py-1 text-xs font-medium text-primary-foreground`,t),children:[(0,q.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-violet-300`}),e]}),fM=({status:e,showBuildGlyph:t=!1})=>e===null?null:e===`queued`?(0,q.jsx)(Z,{variant:`outline`,children:`Queued`}):e===`planning`?(0,q.jsx)(dM,{label:`Planning...`}):e===`building`?(0,q.jsx)(Z,{variant:`warning`,children:t?`⏳ Building`:`Building`}):e===`reviewing`?(0,q.jsx)(Z,{variant:`warning`,children:`Reviewing`}):e===`done`?(0,q.jsx)(Z,{variant:`success`,children:`✓ Done`}):e===`error`?(0,q.jsx)(Z,{variant:`destructive`,children:`✗ Error`}):(0,q.jsx)(Z,{variant:`warning`,children:`Stopped`}),pM=({title:e,stage:t,subjectLabel:n=`ticket`,onConfirm:r,onCancel:i})=>{(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let a=t===`review`?`Undo review`:`Undo build`,o=t===`review`?`This will revert the current review-step changes and move the ${n} back to build-done.`:`This will revert the current build-step changes and move the ${n} back to plan.`;return(0,q.jsxs)(Iv,{onClose:i,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:a}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:o}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:i,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:r,children:`Undo`})]})]})},mM=({isRunning:e,isRunPending:t=!1,isStopPending:n=!1,runDisabled:r=!1,runDisabledReason:i,onRun:a,onStop:o,className:s})=>e?o?(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`destructive`,disabled:n,"aria-busy":n,"aria-label":n?`Stopping run`:`Stop`,title:n?`Stopping run...`:void 0,className:s,onClick:e=>{e.stopPropagation(),o()},onPointerDown:e=>e.stopPropagation(),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 flex-shrink-0 rounded-full bg-emerald-400 animate-pulse`}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3.5 justify-center`,children:n?(0,q.jsx)(C_,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(E_,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`min-w-[2.25rem] text-left`,children:`Stop`})]}):null:a?(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`secondary`,disabled:t||r,"aria-busy":t,"aria-label":t?`Starting run`:`Run`,title:r?i??`Stop the currently running ticket before starting another run.`:t?`Starting run...`:void 0,className:J(`bg-sky-700 text-sky-50 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,s),onClick:e=>{e.stopPropagation(),!r&&a()},onPointerDown:e=>e.stopPropagation(),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 flex-shrink-0 rounded-full invisible`}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3.5 justify-center`,children:t?(0,q.jsx)(C_,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(w_,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`min-w-[2.25rem] text-left`,children:`Run`})]}):null,hM=e=>e.length===0?null:e.some(e=>e.agent_status===`running`)?`reviewing`:e.some(e=>e.agent_status===`error`)?`error`:e.some(e=>e.agent_status===`stopped`)?`stopped`:e.some(e=>e.agent_status===`done`)&&e.every(e=>e.agent_status===null||e.agent_status===`done`)?`done`:e.every(e=>e.agent_status===null)?`queued`:null,gM=(e,{allTickets:t=[],preferBundleReviewStatus:n=!1}={})=>{if(e.parked_at!==null)return null;if(e.state===`plan`){if(e.agent_status===`running`)return`planning`;if(e.agent_status===null)return null;if(e.agent_status===`done`)return`done`;if(e.agent_status===`error`)return`error`;if(e.agent_status===`stopped`)return`stopped`}if(n&&e.worktree_bundle_id){let n=t.filter(t=>t.worktree_bundle_id===e.worktree_bundle_id),r=hM((n.length>0?n:[e]).filter(e=>e.state===`review`));if(r)return r}return e.agent_status===null?`queued`:e.agent_status===`running`?e.state===`review`?`reviewing`:`building`:e.agent_status===`done`?`done`:e.agent_status===`error`?`error`:e.agent_status===`stopped`?`stopped`:null},_M=(e,t)=>{if(t===`done`||e.every(e=>e.parked_at!==null))return null;let n=e.filter(e=>e.state===`review`);if(t===`review`){let e=hM(n);if(e)return e}return n.some(e=>e.agent_status===`running`)?`reviewing`:t===`plan`&&e.some(e=>e.state===`plan`&&e.agent_status===`running`)?`planning`:e.some(e=>e.agent_status===`running`)?`building`:e.some(e=>e.agent_status===`error`)?`error`:e.some(e=>e.agent_status===`stopped`)?`stopped`:e.length>0&&e.every(e=>e.agent_status===`done`)?`done`:e.some(e=>e.state===`build`)?`queued`:null},vM=({bundleName:e,ticketCount:t,onConfirm:n,onCancel:r})=>((0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,q.jsxs)(Iv,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete bundle`}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsxs)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:[`This deletes the `,t,` ticket`,t===1?``:`s`,` `,`currently inside this wrapper.`]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:n,children:`Delete`})]})]})),yM=e=>e.find(e=>e.state===`review`&&e.undo?.stage===`review`&&e.undo.can_undo)??e.find(e=>e.state===`review`&&e.undo?.stage===`review`)??null,bM=(e,t)=>t?.diff_stats===void 0?e.find(e=>e.diff_stats!==void 0)?.diff_stats:t.diff_stats,xM=e=>e.length>0&&e.every(e=>Lj(e)),SM=({group:e,renderTicket:t,runDisabled:n=!1,onStopBuildTicket:r,onResumeBuildTicket:i,onBuildBundle:a,onReviewBundle:o,onUndoBundleReview:s,onRunBundle:c,onStopBundle:l,onParkBundleWrapper:u,onUnparkBundleWrapper:d,bundleActionState:f,onOpenBundleDetails:p,onOpenBundleChanges:m,onOpenBundleIde:h,onRequestBundleRefresh:g,onDeleteBundleWrapper:_,undoInProgress:v=!1,overlay:y=!1})=>{let[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(!1),{attributes:T,listeners:E,setNodeRef:D,isDragging:O}=nj({id:pv(e),disabled:y||v}),k=(0,b.useMemo)(()=>_M(e.tickets,e.column),[e.column,e.tickets]),A=(0,b.useMemo)(()=>(0,q.jsx)(fM,{status:k}),[k]),j=e.column===`plan`,M=e.column===`build`&&e.tickets.every(e=>e.agent_status===`done`),N=(0,b.useMemo)(()=>yM(e.tickets),[e.tickets]),P=e.column===`review`&&N!==null,F=N?.undo?.can_undo??!1,I=N?.undo?.reason??void 0,L=f??{build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1},R=L.review||L.followUp,z=e.column===`review`&&!e.tickets.some(e=>e.agent_status===`running`)&&!R&&e.tickets.some(e=>e.can_re_review),ee=z?`Re-run review`:`Review Bundle`,B=e.tickets.find(e=>e.is_running)??e.tickets.find(e=>e.session_id)??e.tickets.find(e=>e.has_worktree)??e.tickets[0],V=(0,b.useMemo)(()=>bM(e.tickets,B),[B,e.tickets]),H=(0,b.useMemo)(()=>xM(e.tickets),[e.tickets]),te=(0,b.useMemo)(()=>e.column!==`plan`&&V===void 0&&e.tickets.some(e=>e.diff_stats===void 0),[V,e.column,e.tickets]),U=H||e.column===`done`,ne=e.tickets.some(e=>e.is_running),W=e.tickets.some(e=>e.has_run_config&&eM(e)),re=(0,b.useMemo)(()=>[...new Set(e.tickets.map(e=>e.model??``).filter(e=>e.length>0))],[e.tickets]),ie=re.length===1?re[0]:null,ae=e.tickets.find(e=>Pj(e)&&e.agent_status===`running`&&!!e.session_id)??null,G=e.tickets.find(e=>Pj(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,oe=ae!==null,se=!oe&&G!==null,ce=e.tickets.length>0&&e.tickets.every(e=>Hj(e,`trash`)),le=e.column!==`done`&&e.tickets.length>0&&e.tickets.every(e=>Hj(e,`done`)),ue=e.column===`done`&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),de=e.tickets.length===1?`Return to ${e.tickets[0]?.state.charAt(0).toUpperCase()}${e.tickets[0]?.state.slice(1)}`:`Return to original columns`,K=y?`border-violet-400`:U?`border-border/80 hover:border-border`:`border-border hover:border-primary/40`,fe=y||v?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,pe=O?`opacity-30`:U?`opacity-90`:`opacity-100`,me=U?`bg-card/60`:`bg-secondary/60`,he=U?`rounded-lg border border-border/60 bg-background/25 p-2.5`:`rounded-lg border border-border/60 bg-background/35 p-2.5`,ge=U?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,_e=U?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,ve=e.column===`done`;return(0,q.jsxs)(zv,{ref:D,"data-testid":`bundle-card-${e.bundle.id}-${e.column}`,className:`relative shrink-0 select-none transition-colors ${K} ${fe} ${pe} ${me} gap-0 rounded-xl border shadow-none`,onClick:()=>{y||v||(g?.(e.bundle.id),p?.(e.bundle.id,e.column))},...E,...T,children:[v&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,q.jsxs)(Z,{variant:`warning`,className:`gap-1.5`,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,q.jsxs)(Wv,{className:`p-3`,children:[(0,q.jsxs)(`div`,{className:`group/bundle mb-3 flex items-start justify-between gap-2 border-b pb-3 border-border/70`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 text-left`,children:[(0,q.jsx)(`div`,{className:`min-w-0`,children:(0,q.jsx)(`div`,{className:`${ge} min-w-0`,children:hv(e.bundle)})}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`shrink-0 ${_e}`,children:[e.tickets.length,` ticket`,e.tickets.length===1?``:`s`]}),A,e.bundle.pull_request&&(0,q.jsx)(Ej,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()}),H&&(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]}),(zj(e.column,V)||te||ie)&&(0,q.jsxs)(`div`,{"data-testid":`bundle-card-metadata-${e.bundle.id}-${e.column}`,className:`mt-2 flex flex-col gap-1`,children:[(zj(e.column,V)||te)&&(0,q.jsx)(b_,{stats:V,isLoading:te,showFiles:!0,className:_e}),ie&&(0,q.jsx)(`div`,{className:_e,children:(0,q.jsx)(`span`,{className:`truncate`,children:ie})})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,q.jsx)(`div`,{className:`mr-1`,children:(0,q.jsx)(mM,{isRunning:ne,isRunPending:L.run,isStopPending:L.stop,runDisabled:n,onRun:!W||ve||!c?void 0:()=>c(e.bundle.id),onStop:l?()=>l(e.bundle.id):void 0})}),(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`size-7`}),(0,q.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:(0,q.jsxs)(bj,{children:[(0,q.jsx)(xj,{asChild:!0,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Open actions menu for bundle ${hv(e.bundle)}`,variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/bundle:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,q.jsx)(Dj,{className:`h-4 w-4`})})}),(0,q.jsxs)(Sj,{side:`right`,align:`start`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[ce&&_&&(0,q.jsxs)(Cj,{className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{S(!0)},children:[(0,q.jsx)(qv,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Delete bundle`})]}),ue&&d&&(0,q.jsxs)(Cj,{onSelect:()=>{d(e)},children:[(0,q.jsx)(uM,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:de})]}),j&&a&&(0,q.jsxs)(Cj,{disabled:L.build,onSelect:()=>{a(e.bundle.id)},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.build?`Building Bundle...`:`Build Bundle`})]}),(M||z)&&o&&(0,q.jsxs)(Cj,{disabled:R,onSelect:()=>{o(e.bundle.id)},children:[(0,q.jsx)(Oj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:R?`Reviewing Bundle...`:ee})]}),P&&s&&(0,q.jsxs)(Cj,{disabled:L.undoReview||!F,title:F?void 0:I,onSelect:()=>{F&&w(!0)},children:[(0,q.jsx)(Ky,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.undoReview?`Undoing...`:`Undo Review`})]}),!ne&&c&&(0,q.jsxs)(Cj,{disabled:L.run||n,onSelect:()=>{n||c(e.bundle.id)},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.run?`Starting Run...`:`Run`})]}),ne&&l&&(0,q.jsxs)(Cj,{disabled:L.stop,onSelect:()=>{l(e.bundle.id)},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.stop?`Stopping...`:`Stop Run`})]}),oe&&ae&&r&&(0,q.jsxs)(Cj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,disabled:L.stopBuild,onSelect:()=>{r(ae.id)},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.stopBuild?`Pausing Build...`:`Pause Build`})]}),se&&G&&i&&(0,q.jsxs)(Cj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,disabled:L.resumeBuild,onSelect:()=>{i(G.id)},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:L.resumeBuild?`Resuming Build...`:`Resume Build`})]}),(0,q.jsxs)(Cj,{disabled:!m,onSelect:()=>{m?.(e.bundle.id)},children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),(0,q.jsxs)(Cj,{disabled:!h,onSelect:()=>{h?.(e.bundle.id)},children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),le&&u&&(0,q.jsxs)(Cj,{onSelect:()=>{u(e)},children:[(0,q.jsx)(lM,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Done`})]})]})]})})]})]}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 ${he}`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:e.tickets.map(e=>(0,q.jsx)(b.Fragment,{children:t(e)},e.id))}),x&&(0,q.jsx)(vM,{bundleName:hv(e.bundle),ticketCount:e.tickets.length,onConfirm:()=>{S(!1),_?.(e)},onCancel:()=>S(!1)}),C&&N?.undo?.stage&&(0,q.jsx)(pM,{title:hv(e.bundle),stage:N.undo.stage,subjectLabel:`bundle`,onConfirm:()=>{w(!1),s?.(e.bundle.id)},onCancel:()=>w(!1)})]})]})},CM=({className:e})=>(0,q.jsx)(ih,{"aria-hidden":`true`,className:e}),wM=({title:e,canDelete:t,undo:n,undoInProgress:r,runDisabled:i,isRunPending:a,isStopPending:o,showOpenChangesAction:s,showOpenIdeAction:c,showRunAction:l,showStopRunAction:u,showAdvanceAction:d,advanceLabel:f,canAdvance:p,showParkAction:m,showReturnAction:h,returnLabel:g,showBuildChainAction:_,showPauseBuildAction:v,showResumeBuildAction:y,showStopBuildChainAction:b,onDelete:x,onConfirmDelete:S,onConfirmUndo:C,onOpenChanges:w,onOpenIde:T,onAdvance:E,onPark:D,onUnpark:O,onBuildChain:k,onRun:A,onStop:j,onStopBuild:M,onResumeBuild:N,onStopBuildChain:P})=>(0,q.jsxs)(bj,{children:[(0,q.jsx)(xj,{asChild:!0,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Open actions menu for ${e}`,variant:`ghost`,size:`icon-xs`,className:`opacity-0 transition-all group-hover/card:opacity-100 data-[state=open]:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,q.jsx)(Dj,{className:`h-4 w-4`})})}),(0,q.jsxs)(Sj,{side:`right`,align:`start`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[x&&(0,q.jsxs)(Cj,{disabled:!t,className:`text-red-200 focus:bg-destructive/20 focus:text-red-100 data-[disabled]:text-muted-foreground`,onSelect:()=>{t&&S()},children:[(0,q.jsx)(qv,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Delete`})]}),n?.stage&&(0,q.jsxs)(Cj,{disabled:!n.can_undo,title:n.can_undo?void 0:n.reason??void 0,onSelect:()=>{r||!n.can_undo||C()},children:[(0,q.jsx)(Ky,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:n.stage===`review`?`Undo Review`:`Undo Build`})]}),d&&f&&(0,q.jsxs)(Cj,{disabled:!p,onSelect:()=>{p&&E?.()},children:[(0,q.jsx)(Oj,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:f})]}),h&&g&&(0,q.jsxs)(Cj,{onSelect:()=>{O?.()},children:[(0,q.jsx)(uM,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:g})]}),_&&(0,q.jsxs)(Cj,{onSelect:()=>{k?.()},children:[(0,q.jsx)(CM,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Build Chain`})]}),l&&(0,q.jsxs)(Cj,{disabled:i||a,onSelect:()=>{i||a||A?.()},children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:a?`Starting Run...`:`Run`})]}),u&&(0,q.jsxs)(Cj,{disabled:o,className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{o||j?.()},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:o?`Stopping...`:`Stop Run`})]}),v&&(0,q.jsxs)(Cj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,onSelect:()=>M?.(),children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Pause Build`})]}),y&&(0,q.jsxs)(Cj,{className:`text-amber-200 focus:bg-amber-500/20 focus:text-amber-100`,onSelect:()=>N?.(),children:[(0,q.jsx)(w_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Resume Build`})]}),s&&(0,q.jsxs)(Cj,{onSelect:()=>w?.(),children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),c&&(0,q.jsxs)(Cj,{onSelect:()=>T?.(),children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),b&&(0,q.jsxs)(Cj,{className:`text-red-200 focus:bg-destructive/20 focus:text-red-100`,onSelect:()=>{P?.()},children:[(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Stop Build Chain`})]}),m&&(0,q.jsxs)(Cj,{onSelect:()=>{D?.()},children:[(0,q.jsx)(lM,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Done`})]})]})]}),TM=({title:e,bundleName:t=null,onConfirm:n,onCancel:r})=>((0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,q.jsxs)(Iv,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete ticket`}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:t?`This removes the ticket from bundle "${t}". The bundle and shared worktree stay available.`:`This will also remove the worktree if one exists.`}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:n,children:`Delete`})]})]})),EM=({description:e,descriptionClass:t,isExpanded:n,collapsedState:r,useStaleLikeStyling:i,onExpand:a,onCollapse:o})=>{if(!e)return null;let s=`ml-1 inline h-auto px-0 py-0 align-baseline text-xs lowercase ${i?`text-foreground/75`:`text-foreground/70`}`;return(0,q.jsx)(`div`,{className:`mb-2 text-xs leading-relaxed ${i?`text-foreground/55`:`text-muted-foreground`}`,children:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:t,children:e}),(0,q.jsx)(Y,{type:`button`,variant:`link`,size:`xs`,className:s,onClick:e=>{e.stopPropagation(),o()},onPointerDown:e=>e.stopPropagation(),children:`show less`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:t,children:r.text}),r.truncated&&(0,q.jsx)(Y,{type:`button`,variant:`link`,size:`xs`,className:s,onClick:e=>{e.stopPropagation(),a()},onPointerDown:e=>e.stopPropagation(),children:`show more`})]})})},DM=({ticket:e,hideStatusBadge:t,isStale:n,runControl:r,onRetry:i,undoInProgress:a,isChainStart:o})=>{let s=(e.planning_context?.open_questions.length??0)>0,c=gM(e),l=t||e.state===`plan`&&e.agent_status===null;return(0,q.jsxs)(q.Fragment,{children:[n&&(0,q.jsx)(`div`,{className:`mb-2`,children:(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})}),!t&&c!==null&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(fM,{status:c,showBuildGlyph:!0}),c===`error`&&i&&!a&&(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e=>{e.stopPropagation(),i()},onPointerDown:e=>e.stopPropagation(),children:(0,q.jsx)(Ky,{className:`w-3.5 h-3.5`})}),r]}),l&&r,s&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(Z,{variant:`warning`,children:`Open questions`})}),o&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsxs)(Z,{variant:`secondary`,className:`gap-1.5 border-violet-500/25 bg-violet-500/12 text-violet-200`,children:[(0,q.jsx)(CM,{className:`h-3.5 w-3.5`}),`Chain start`]})})]})},OM=(e,t)=>O(w(`/tickets/${e}/terminal`,t),{method:`POST`,fallbackErrorMessage:`Unable to open the terminal right now.`}),kM=e=>O(C(`/projects/${e}/terminal`),{method:`POST`,fallbackErrorMessage:`Unable to open the project terminal right now.`}),AM=e=>{let t=C(`/terminals/${e}/destroy`);if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([`{}`],{type:`application/json`});if(navigator.sendBeacon(t,e))return}fetch(t,{method:`POST`,keepalive:!0,headers:{"Content-Type":`application/json`},body:`{}`}).catch(()=>{})},jM=({model:e,variant:t,skills:n})=>e||t||n.length>0?(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e||`Default model`}),t&&(0,q.jsx)(Z,{variant:`ghost`,className:`text-[11px] text-muted-foreground`,children:t}),n.length>0&&(0,q.jsxs)(Z,{variant:`info`,className:`text-[11px]`,children:[n.length,` skill`,n.length===1?``:`s`]})]}):(0,q.jsx)(Z,{variant:`ghost`,className:`px-0 text-[11px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Using defaults`}),MM=e=>e===`claude`?`Claude`:`OpenCode`,NM=({tool:e,className:t})=>{if(!e)return null;let n=MM(e),r=`Locked to ${n}`;return(0,q.jsx)(u_,{content:r,children:(0,q.jsx)(Z,{variant:`outline`,"aria-label":r,className:J(`border-violet-500/25 bg-violet-500/10 text-violet-100`,e===`claude`&&`border-orange-500/25 bg-orange-500/10 text-orange-100`,t),children:n})})},PM=({externalSource:e=null,className:t})=>{if(!e||e.provider!==`jira`)return null;let n=e.external_key;return(0,q.jsxs)(`div`,{className:J(`inline-flex w-fit max-w-full flex-wrap items-center gap-x-1 self-start rounded-md border border-sky-500/20 bg-sky-500/10 px-2.5 py-1 text-[11px] leading-5 text-sky-100`,t),children:[(0,q.jsx)(`span`,{children:`Imported from Jira issue`}),e.external_url?(0,q.jsx)(`a`,{href:e.external_url,target:`_blank`,rel:`noreferrer`,className:`font-medium underline underline-offset-2 hover:text-white`,children:n}):(0,q.jsx)(`span`,{className:`font-medium`,children:n})]})},FM=({className:e})=>(0,q.jsx)(Zm,{"aria-hidden":`true`,className:e}),IM=({label:e,value:t,variant:n=`default`,className:r})=>{let[i,a]=(0,b.useState)(!1),o=()=>{navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),2e3)};return n===`compact`?(0,q.jsx)(`div`,{className:J(`min-w-0`,r),children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg border border-border/80 bg-card/70 px-2.5 py-1.5`,children:[(0,q.jsx)(`span`,{className:`shrink-0 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground/80`,children:t}),(0,q.jsx)(Y,{type:`button`,onClick:o,variant:`ghost`,size:`icon-xs`,"aria-label":i?`${e} copied`:`Copy ${e}`,className:J(`flex-shrink-0 text-muted-foreground hover:text-foreground`,i&&`text-emerald-300`),children:(0,q.jsx)(FM,{className:`h-3 w-3`})})]})}):(0,q.jsxs)(`div`,{className:J(`flex flex-col gap-1.5`,r),children:[(0,q.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-input/30 px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`flex-1 truncate font-mono text-xs text-muted-foreground`,children:t}),(0,q.jsxs)(Y,{type:`button`,onClick:o,variant:`ghost`,size:`xs`,className:`flex-shrink-0`,children:[(0,q.jsx)(FM,{className:`h-3.5 w-3.5`}),i?`Copied`:`Copy`]})]})]})},LM=({ariaLabel:e,items:t,className:n})=>{let r=t.filter(e=>e.value.trim().length>0);return r.length===0?null:(0,q.jsx)(`section`,{"aria-label":e,className:J(`flex flex-wrap items-center gap-2`,n),children:r.map(e=>(0,q.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,q.jsx)(IM,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`))})},RM=new Set([`step started`,`step finished`]),zM=e=>RM.has(e.trim().toLowerCase()),BM=e=>zM(e.content)?!1:e.kind===`description`?e.content.trim().length>0:!0,VM=({summary:e,detail:t=null})=>(0,q.jsxs)(`section`,{"aria-label":`Build chain`,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Build chain`}),(0,q.jsx)(`p`,{className:`text-sm text-foreground`,children:e}),t&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]});function HM(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var UM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,WM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GM={};function KM(e,t){return((t||GM).jsx?WM:UM).test(e)}var qM=/[ \t\n\f\r]/g;function JM(e){return typeof e==`object`?e.type===`text`?YM(e.value):!1:YM(e)}function YM(e){return e.replace(qM,``)===``}var XM=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};XM.prototype.normal={},XM.prototype.property={},XM.prototype.space=void 0;function ZM(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new XM(n,r,t)}function QM(e){return e.toLowerCase()}var $M=class{constructor(e,t){this.attribute=t,this.property=e}};$M.prototype.attribute=``,$M.prototype.booleanish=!1,$M.prototype.boolean=!1,$M.prototype.commaOrSpaceSeparated=!1,$M.prototype.commaSeparated=!1,$M.prototype.defined=!1,$M.prototype.mustUseProperty=!1,$M.prototype.number=!1,$M.prototype.overloadedBoolean=!1,$M.prototype.property=``,$M.prototype.spaceSeparated=!1,$M.prototype.space=void 0;var eN=c({boolean:()=>nN,booleanish:()=>rN,commaOrSpaceSeparated:()=>sN,commaSeparated:()=>oN,number:()=>Q,overloadedBoolean:()=>iN,spaceSeparated:()=>aN}),tN=0,nN=cN(),rN=cN(),iN=cN(),Q=cN(),aN=cN(),oN=cN(),sN=cN();function cN(){return 2**++tN}var lN=Object.keys(eN),uN=class extends $M{constructor(e,t,n,r){let i=-1;if(super(e,t),dN(this,`space`,r),typeof n==`number`)for(;++i<lN.length;){let e=lN[i];dN(this,lN[i],(n&eN[e])===eN[e])}}};uN.prototype.defined=!0;function dN(e,t,n){n&&(e[t]=n)}function fN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new uN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[QM(r)]=r,n[QM(a.attribute)]=r}return new XM(t,n,e.space)}var pN=fN({properties:{ariaActiveDescendant:null,ariaAtomic:rN,ariaAutoComplete:null,ariaBusy:rN,ariaChecked:rN,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:aN,ariaCurrent:null,ariaDescribedBy:aN,ariaDetails:null,ariaDisabled:rN,ariaDropEffect:aN,ariaErrorMessage:null,ariaExpanded:rN,ariaFlowTo:aN,ariaGrabbed:rN,ariaHasPopup:null,ariaHidden:rN,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:aN,ariaLevel:Q,ariaLive:null,ariaModal:rN,ariaMultiLine:rN,ariaMultiSelectable:rN,ariaOrientation:null,ariaOwns:aN,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:rN,ariaReadOnly:rN,ariaRelevant:null,ariaRequired:rN,ariaRoleDescription:aN,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:rN,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function mN(e,t){return t in e?e[t]:t}function hN(e,t){return mN(e,t.toLowerCase())}var gN=fN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:oN,acceptCharset:aN,accessKey:aN,action:null,allow:null,allowFullScreen:nN,allowPaymentRequest:nN,allowUserMedia:nN,alt:null,as:null,async:nN,autoCapitalize:null,autoComplete:aN,autoFocus:nN,autoPlay:nN,blocking:aN,capture:null,charSet:null,checked:nN,cite:null,className:aN,cols:Q,colSpan:null,content:null,contentEditable:rN,controls:nN,controlsList:aN,coords:Q|oN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:nN,defer:nN,dir:null,dirName:null,disabled:nN,download:iN,draggable:rN,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:nN,formTarget:null,headers:aN,height:Q,hidden:iN,high:Q,href:null,hrefLang:null,htmlFor:aN,httpEquiv:aN,id:null,imageSizes:null,imageSrcSet:null,inert:nN,inputMode:null,integrity:null,is:null,isMap:nN,itemId:null,itemProp:aN,itemRef:aN,itemScope:nN,itemType:aN,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:nN,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:nN,muted:nN,name:null,nonce:null,noModule:nN,noValidate:nN,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:nN,optimum:Q,pattern:null,ping:aN,placeholder:null,playsInline:nN,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:nN,referrerPolicy:null,rel:aN,required:nN,reversed:nN,rows:Q,rowSpan:Q,sandbox:aN,scope:null,scoped:nN,seamless:nN,selected:nN,shadowRootClonable:nN,shadowRootDelegatesFocus:nN,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:rN,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:nN,useMap:null,value:rN,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:aN,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:nN,declare:nN,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:nN,noHref:nN,noShade:nN,noWrap:nN,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:rN,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:nN,disableRemotePlayback:nN,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:hN}),_N=fN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:sN,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:aN,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:nN,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:oN,g2:oN,glyphName:oN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:sN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:aN,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sN,rev:sN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sN,requiredFeatures:sN,requiredFonts:sN,requiredFormats:sN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:sN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sN,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:mN}),vN=fN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),yN=fN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:hN}),bN=fN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),xN={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},SN=/[A-Z]/g,CN=/-[a-z]/g,wN=/^data[-\w.:]+$/i;function TN(e,t){let n=QM(t),r=t,i=$M;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&wN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(CN,DN);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!CN.test(e)){let n=e.replace(SN,EN);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=uN}return new i(r,t)}function EN(e){return`-`+e.toLowerCase()}function DN(e){return e.charAt(1).toUpperCase()}var ON=ZM([pN,gN,vN,yN,bN],`html`),kN=ZM([pN,_N,vN,yN,bN],`svg`);function AN(e){return e.join(` `).trim()}var jN=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
96
+ `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),MN=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(jN());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),NN=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),PN=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(MN()),r=NN();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),FN=LN(`end`),IN=LN(`start`);function LN(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function RN(e){let t=IN(e),n=FN(e);if(t&&n)return{start:t,end:n}}function zN(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?VN(e.position):`start`in e||`end`in e?VN(e):`line`in e||`column`in e?BN(e):``}function BN(e){return HN(e&&e.line)+`:`+HN(e&&e.column)}function VN(e){return BN(e&&e.start)+`-`+BN(e&&e.end)}function HN(e){return e&&typeof e==`number`?e:1}var UN=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=zN(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};UN.prototype.file=``,UN.prototype.name=``,UN.prototype.reason=``,UN.prototype.message=``,UN.prototype.stack=``,UN.prototype.column=void 0,UN.prototype.line=void 0,UN.prototype.ancestors=void 0,UN.prototype.cause=void 0,UN.prototype.fatal=void 0,UN.prototype.place=void 0,UN.prototype.ruleId=void 0,UN.prototype.source=void 0;var WN=u(PN(),1),GN={}.hasOwnProperty,KN=new Map,qN=/[A-Z]/g,JN=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),YN=new Set([`td`,`th`]),XN=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function ZN(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=cP(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=sP(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?kN:ON,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=QN(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function QN(e,t,n){if(t.type===`element`)return $N(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return eP(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return nP(e,t,n);if(t.type===`mdxjsEsm`)return tP(e,t);if(t.type===`root`)return rP(e,t,n);if(t.type===`text`)return iP(e,t)}function $N(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=kN,e.schema=i),e.ancestors.push(t);let a=mP(e,t.tagName,!1),o=lP(e,t),s=dP(e,t);return JN.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!JM(e):!0})),aP(e,o,a,t),oP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function eP(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}hP(e,t.position)}function tP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);hP(e,t.position)}function nP(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=kN,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:mP(e,t.name,!0),o=uP(e,t),s=dP(e,t);return aP(e,o,a,t),oP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function rP(e,t,n){let r={};return oP(r,dP(e,t)),e.create(t,e.Fragment,r,n)}function iP(e,t){return t.value}function aP(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function oP(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function sP(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function cP(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=IN(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function lP(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&GN.call(t.properties,i)){let a=fP(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&YN.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function uP(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else hP(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else hP(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function dP(e,t){let n=[],r=-1,i=e.passKeys?new Map:KN;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=QN(e,a,o);s!==void 0&&n.push(s)}return n}function fP(e,t,n){let r=TN(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?HM(n):AN(n)),r.property===`style`){let t=typeof n==`object`?n:pP(e,String(n));return e.stylePropertyNameCase===`css`&&(t=gP(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?xN[r.property]||r.property:r.attribute,n]}}function pP(e,t){try{return(0,WN.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new UN("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=XN+`#cannot-parse-style-attribute`,r}}function mP(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=KM(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=KM(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return GN.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);hP(e)}function hP(e,t){let n=new UN("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=XN+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function gP(e){let t={},n;for(n in e)GN.call(e,n)&&(t[_P(n)]=e[n]);return t}function _P(e){let t=e.replace(qN,vP);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function vP(e){return`-`+e.toLowerCase()}var yP={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},bP={};function xP(e,t){let n=t||bP;return SP(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function SP(e,t,n){if(wP(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return CP(e.children,t,n)}return Array.isArray(e)?CP(e,t,n):``}function CP(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=SP(e[i],t,n);return r.join(``)}function wP(e){return!!(e&&typeof e==`object`)}var TP=document.createElement(`i`);function EP(e){let t=`&`+e+`;`;TP.innerHTML=t;let n=TP.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function DP(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function OP(e,t){return e.length>0?(DP(e,e.length,0,t),e):t}var kP={}.hasOwnProperty;function AP(e){let t={},n=-1;for(;++n<e.length;)jP(t,e[n]);return t}function jP(e,t){let n;for(n in t){let r=(kP.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){kP.call(r,a)||(r[a]=[]);let e=i[a];MP(r[a],Array.isArray(e)?e:e?[e]:[])}}}function MP(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);DP(e,0,0,r)}function NP(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function PP(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var FP=qP(/[A-Za-z]/),IP=qP(/[\dA-Za-z]/),LP=qP(/[#-'*+\--9=?A-Z^-~]/);function RP(e){return e!==null&&(e<32||e===127)}var zP=qP(/\d/),BP=qP(/[\dA-Fa-f]/),VP=qP(/[!-/:-@[-`{-~]/);function HP(e){return e!==null&&e<-2}function UP(e){return e!==null&&(e<0||e===32)}function WP(e){return e===-2||e===-1||e===32}var GP=qP(/\p{P}|\p{S}/u),KP=qP(/\s/);function qP(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function JP(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&IP(e.charCodeAt(n+1))&&IP(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function YP(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return WP(r)?(e.enter(n),s(r)):t(r)}function s(r){return WP(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var XP={tokenize:ZP};function ZP(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),YP(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return HP(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var QP={tokenize:eF},$P={tokenize:tF};function eF(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return DP(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check($P,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt($P,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return HP(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;DP(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tF(e,t,n){return YP(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function nF(e){if(e===null||UP(e)||KP(e))return 1;if(GP(e))return 2}function rF(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var iF={name:`attention`,resolveAll:aF,tokenize:oF};function aF(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};sF(d,-c),sF(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=OP(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=OP(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=OP(l,rF(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=OP(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=OP(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,DP(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function oF(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nF(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=nF(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function sF(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var cF={name:`autolink`,tokenize:lF};function lF(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return FP(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||IP(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||IP(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||RP(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):LP(t)?(e.consume(t),l):n(t)}function u(e){return IP(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||IP(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var uF={partial:!0,tokenize:dF};function dF(e,t,n){return r;function r(t){return WP(t)?YP(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||HP(e)?t(e):n(e)}}var fF={continuation:{tokenize:mF},exit:hF,name:`blockQuote`,tokenize:pF};function pF(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return WP(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function mF(e,t,n){let r=this;return i;function i(t){return WP(t)?YP(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(fF,t,n)(r)}}function hF(e){e.exit(`blockQuote`)}var gF={name:`characterEscape`,tokenize:_F};function _F(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return VP(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var vF={name:`characterReference`,tokenize:yF};function yF(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=IP,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=BP,u):(e.enter(`characterReferenceValue`),a=7,o=zP,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===IP&&!EP(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var bF={partial:!0,tokenize:CF},xF={concrete:!0,name:`codeFenced`,tokenize:SF};function SF(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),WP(t)?YP(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||HP(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(bF,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||HP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):WP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),YP(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||HP(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||HP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&WP(t)?YP(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||HP(t)?e.check(bF,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||HP(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),WP(t)?YP(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),WP(t)?YP(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||HP(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function CF(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var wF={name:`codeIndented`,tokenize:EF},TF={partial:!0,tokenize:DF};function EF(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),YP(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):HP(t)?e.attempt(TF,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||HP(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function DF(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):HP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):YP(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):HP(e)?i(e):n(e)}}var OF={name:`codeText`,previous:AF,resolve:kF,tokenize:jF};function kF(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function AF(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function jF(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):HP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||HP(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var MF=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&NF(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),NF(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),NF(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);NF(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);NF(this.left,t.reverse())}}};function NF(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function PF(e){let t={},n=-1,r,i,a,o,s,c,l,u=new MF(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,FF(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return DP(e,0,1/0,u.slice(0)),!l}function FF(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var IF={resolve:RF,tokenize:zF},LF={partial:!0,tokenize:BF};function RF(e){return PF(e),e}function zF(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):HP(t)?e.check(LF,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function BF(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),YP(e,a,`linePrefix`)}function a(i){if(i===null||HP(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function VF(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||RP(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||HP(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||UP(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||RP(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function HF(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):HP(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||HP(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!WP(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function UF(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):HP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),YP(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||HP(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function WF(e,t){let n;return r;function r(i){return HP(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):WP(i)?YP(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var GF={name:`definition`,tokenize:qF},KF={partial:!0,tokenize:JF};function qF(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return HF.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=PP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return UP(t)?WF(e,l)(t):l(t)}function l(t){return VF(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(KF,d,d)(t)}function d(t){return WP(t)?YP(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||HP(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function JF(e,t,n){return r;function r(t){return UP(t)?WF(e,i)(t):n(t)}function i(t){return UF(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return WP(t)?YP(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||HP(e)?t(e):n(e)}}var YF={name:`hardBreakEscape`,tokenize:XF};function XF(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return HP(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var ZF={name:`headingAtx`,resolve:QF,tokenize:$F};function QF(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},DP(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function $F(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||UP(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||HP(n)?(e.exit(`atxHeading`),t(n)):WP(n)?YP(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||UP(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var eI=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),tI=[`pre`,`script`,`style`,`textarea`],nI={concrete:!0,name:`htmlFlow`,resolveTo:aI,tokenize:oI},rI={partial:!0,tokenize:cI},iI={partial:!0,tokenize:sI};function aI(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function oI(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):FP(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):FP(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return FP(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||UP(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&tI.includes(l)?(i=1,r.interrupt?t(s):O(s)):eI.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||IP(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return WP(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||FP(t)?(e.consume(t),b):WP(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||IP(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):WP(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):WP(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||HP(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||UP(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||WP(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||HP(t)?O(t):WP(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):HP(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(rI,R,k)(t)):t===null||HP(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(iI,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||HP(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return tI.includes(n)?(e.consume(t),L):O(t)}return FP(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||HP(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function sI(e,t,n){let r=this;return i;function i(t){return HP(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function cI(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(uF,t,n)}}var lI={name:`htmlText`,tokenize:uI};function uI(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):FP(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):FP(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):HP(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):HP(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):HP(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):HP(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return FP(t)?(e.consume(t),S):n(t)}function S(t){return t===45||IP(t)?(e.consume(t),S):C(t)}function C(t){return HP(t)?(o=C,N(t)):WP(t)?(e.consume(t),C):M(t)}function w(t){return t===45||IP(t)?(e.consume(t),w):t===47||t===62||UP(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||FP(t)?(e.consume(t),E):HP(t)?(o=T,N(t)):WP(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||IP(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):HP(t)?(o=D,N(t)):WP(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):HP(t)?(o=O,N(t)):WP(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):HP(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||UP(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||UP(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return WP(t)?YP(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var dI={name:`labelEnd`,resolveAll:hI,resolveTo:gI,tokenize:_I},fI={tokenize:vI},pI={tokenize:yI},mI={tokenize:bI};function hI(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&DP(e,0,e.length,n),e}function gI(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=OP(s,e.slice(a+1,a+r+3)),s=OP(s,[[`enter`,u,t]]),s=OP(s,rF(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=OP(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=OP(s,e.slice(o+1)),s=OP(s,[[`exit`,c,t]]),DP(e,a,e.length,s),e}function _I(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(PP(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(fI,u,o?u:d)(t):t===91?e.attempt(pI,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(mI,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function vI(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return UP(t)?WF(e,a)(t):a(t)}function a(t){return t===41?u(t):VF(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return UP(t)?WF(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?UF(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return UP(t)?WF(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function yI(e,t,n){let r=this;return i;function i(t){return HF.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(PP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function bI(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var xI={name:`labelStartImage`,resolveAll:dI.resolveAll,tokenize:SI};function SI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var CI={name:`labelStartLink`,resolveAll:dI.resolveAll,tokenize:wI};function wI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var TI={name:`lineEnding`,tokenize:EI};function EI(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),YP(e,t,`linePrefix`)}}var DI={name:`thematicBreak`,tokenize:OI};function OI(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||HP(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),WP(t)?YP(e,s,`whitespace`)(t):s(t))}}var kI={continuation:{tokenize:NI},exit:FI,name:`list`,tokenize:MI},AI={partial:!0,tokenize:II},jI={partial:!0,tokenize:PI};function MI(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:zP(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(DI,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return zP(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(uF,r.interrupt?n:u,e.attempt(AI,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return WP(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function NI(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(uF,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,YP(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!WP(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(jI,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,YP(e,e.attempt(kI,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function PI(e,t,n){let r=this;return YP(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function FI(e){e.exit(this.containerState.type)}function II(e,t,n){let r=this;return YP(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!WP(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var LI={name:`setextUnderline`,resolveTo:RI,tokenize:zI};function RI(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function zI(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),WP(t)?YP(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||HP(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var BI={tokenize:VI};function VI(e){let t=this,n=e.attempt(uF,r,e.attempt(this.parser.constructs.flowInitial,i,YP(e,e.attempt(this.parser.constructs.flow,i,e.attempt(IF,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var HI={resolveAll:KI()},UI=GI(`string`),WI=GI(`text`);function GI(e){return{resolveAll:KI(e===`text`?qI:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function KI(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function qI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var JI=c({attentionMarkers:()=>nL,contentInitial:()=>XI,disable:()=>rL,document:()=>YI,flow:()=>QI,flowInitial:()=>ZI,insideSpan:()=>tL,string:()=>$I,text:()=>eL}),YI={42:kI,43:kI,45:kI,48:kI,49:kI,50:kI,51:kI,52:kI,53:kI,54:kI,55:kI,56:kI,57:kI,62:fF},XI={91:GF},ZI={[-2]:wF,[-1]:wF,32:wF},QI={35:ZF,42:DI,45:[LI,DI],60:nI,61:LI,95:DI,96:xF,126:xF},$I={38:vF,92:gF},eL={[-5]:TI,[-4]:TI,[-3]:TI,33:xI,38:vF,42:iF,60:[cF,lI],91:CI,92:[YF,gF],93:dI,95:iF,96:OF},tL={null:[iF,HI]},nL={null:[42,95]},rL={null:[]};function iL(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=OP(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=rF(a,l.events,l),l.events):[]}function f(e,t){return oL(p(e),t)}function p(e){return aL(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){HP(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&DP(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function aL(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function oL(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
97
97
  `;break;case-3:o=`\r
98
- `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function GI(e){let t={constructs:mP([MI,...(e||{}).extensions||[]]),content:n(PP),defined:[],document:n(IP),flow:n(wI),lazy:{},string:n(DI),text:n(OI)};return t;function n(e){return n;function n(n){return HI(t,e,n)}}}function KI(e){for(;!vF(e););return e}var qI=/[\0\t\n\r]/g;function JI(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(qI.lastIndex=u,c=qI.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var YI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function XI(e){return e.replace(YI,ZI)}function ZI(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return _P(n.slice(t?2:1),t?16:10)}return uP(n)||e}var QI={}.hasOwnProperty;function $I(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),eL(n)(KI(GI(n).document().write(JI()(e,t,!0))))}function eL(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(le),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(G),blockQuote:a(ne),characterEscape:T,characterReference:T,codeFenced:a(W),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(W,o),codeText:a(re,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ie),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ae),hardBreakEscape:a(oe),hardBreakTrailing:a(oe),htmlFlow:a(se,o),htmlFlowData:T,htmlText:a(se,o),htmlTextData:T,image:a(ce),label:o,link:a(le),listItem:a(de),listItemValue:f,listOrdered:a(ue,d),listUnordered:a(ue),paragraph:a(K),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(G),strong:a(fe),thematicBreak:a(me)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:U,autolinkProtocol:te,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:V,characterReference:H,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ee,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};nL(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];QI.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||iL).call(a,void 0,e[0])}for(r.position={start:tL(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tL(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:tL(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||iL).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+CN({start:e.start,end:e.end})+`): it’s not open`);n.position.end=tL(e.end)}function u(){return aP(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=vP(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=pe(),n.position={start:tL(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=tL(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=tL(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=XI(t),n.identifier=vP(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function ee(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=vP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function B(e){this.data.characterReferenceType=e.type}function V(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=_P(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=uP(t);let i=this.stack[this.stack.length-1];i.value+=r}function H(e){let t=this.stack.pop();t.position.end=tL(e.end)}function te(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function U(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ne(){return{type:`blockquote`,children:[]}}function W(){return{type:`code`,lang:null,meta:null,value:``}}function re(){return{type:`inlineCode`,value:``}}function ie(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ae(){return{type:`emphasis`,children:[]}}function G(){return{type:`heading`,depth:0,children:[]}}function oe(){return{type:`break`}}function se(){return{type:`html`,value:``}}function ce(){return{type:`image`,title:null,url:``,alt:null}}function le(){return{type:`link`,title:null,url:``,children:[]}}function ue(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function de(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function K(){return{type:`paragraph`,children:[]}}function fe(){return{type:`strong`,children:[]}}function pe(){return{type:`text`,value:``}}function me(){return{type:`thematicBreak`}}}function tL(e){return{line:e.line,column:e.column,offset:e.offset}}function nL(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?nL(e,r):rL(e,r)}}function rL(e,t){let n;for(n in t)if(QI.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function iL(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+CN({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+CN({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+CN({start:t.start,end:t.end})+`) is still open`)}function aL(e){let t=this;t.parser=n;function n(n){return $I(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function oL(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function sL(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
99
- `}]}function cL(e,t){let n=t.value?t.value+`
100
- `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function lL(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uL(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dL(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=MP(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function fL(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pL(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function mL(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function hL(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return mL(e,t);let i={src:MP(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function gL(e,t){let n={src:MP(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function _L(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function vL(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return mL(e,t);let i={href:MP(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function yL(e,t){let n={href:MP(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function bL(e,t,n){let r=e.all(t),i=n?xL(n):SL(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
98
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function sL(e){let t={constructs:AP([JI,...(e||{}).extensions||[]]),content:n(XP),defined:[],document:n(QP),flow:n(BI),lazy:{},string:n(UI),text:n(WI)};return t;function n(e){return n;function n(n){return iL(t,e,n)}}}function cL(e){for(;!PF(e););return e}var lL=/[\0\t\n\r]/g;function uL(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(lL.lastIndex=u,c=lL.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var dL=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fL(e){return e.replace(dL,pL)}function pL(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return NP(n.slice(t?2:1),t?16:10)}return EP(n)||e}var mL={}.hasOwnProperty;function hL(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),gL(n)(cL(sL(n).document().write(uL()(e,t,!0))))}function gL(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(le),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(G),blockQuote:a(ne),characterEscape:T,characterReference:T,codeFenced:a(W),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(W,o),codeText:a(re,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ie),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ae),hardBreakEscape:a(oe),hardBreakTrailing:a(oe),htmlFlow:a(se,o),htmlFlowData:T,htmlText:a(se,o),htmlTextData:T,image:a(ce),label:o,link:a(le),listItem:a(de),listItemValue:f,listOrdered:a(ue,d),listUnordered:a(ue),paragraph:a(K),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(G),strong:a(fe),thematicBreak:a(me)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:U,autolinkProtocol:te,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:V,characterReference:H,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ee,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};vL(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];mL.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||bL).call(a,void 0,e[0])}for(r.position={start:_L(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:_L(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:_L(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||bL).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+zN({start:e.start,end:e.end})+`): it’s not open`);n.position.end=_L(e.end)}function u(){return xP(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=PP(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=pe(),n.position={start:_L(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=_L(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=_L(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=fL(t),n.identifier=PP(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function ee(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=PP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function B(e){this.data.characterReferenceType=e.type}function V(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=NP(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=EP(t);let i=this.stack[this.stack.length-1];i.value+=r}function H(e){let t=this.stack.pop();t.position.end=_L(e.end)}function te(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function U(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ne(){return{type:`blockquote`,children:[]}}function W(){return{type:`code`,lang:null,meta:null,value:``}}function re(){return{type:`inlineCode`,value:``}}function ie(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ae(){return{type:`emphasis`,children:[]}}function G(){return{type:`heading`,depth:0,children:[]}}function oe(){return{type:`break`}}function se(){return{type:`html`,value:``}}function ce(){return{type:`image`,title:null,url:``,alt:null}}function le(){return{type:`link`,title:null,url:``,children:[]}}function ue(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function de(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function K(){return{type:`paragraph`,children:[]}}function fe(){return{type:`strong`,children:[]}}function pe(){return{type:`text`,value:``}}function me(){return{type:`thematicBreak`}}}function _L(e){return{line:e.line,column:e.column,offset:e.offset}}function vL(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?vL(e,r):yL(e,r)}}function yL(e,t){let n;for(n in t)if(mL.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function bL(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+zN({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zN({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+zN({start:t.start,end:t.end})+`) is still open`)}function xL(e){let t=this;t.parser=n;function n(n){return hL(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function SL(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function CL(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
99
+ `}]}function wL(e,t){let n=t.value?t.value+`
100
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function TL(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EL(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DL(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=JP(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function OL(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kL(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function AL(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function jL(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AL(e,t);let i={src:JP(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function ML(e,t){let n={src:JP(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function NL(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function PL(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AL(e,t);let i={href:JP(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function FL(e,t){let n={href:JP(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function IL(e,t,n){let r=e.all(t),i=n?LL(n):RL(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
101
101
  `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
102
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function xL(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=SL(n[r])}return t}function SL(e){return e.spread??e.children.length>1}function CL(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function wL(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TL(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function EL(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DL(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=bN(t.children[1]),o=yN(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function OL(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function kL(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var AL=9,jL=32;function ML(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(NL(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(NL(t.slice(i),i>0,!1)),a.join(``)}function NL(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===AL||t===jL;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===AL||t===jL;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function PL(e,t){let n={type:`text`,value:ML(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function FL(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var IL={blockquote:oL,break:sL,code:cL,delete:lL,emphasis:uL,footnoteReference:dL,heading:fL,html:pL,imageReference:hL,image:gL,inlineCode:_L,linkReference:vL,link:yL,listItem:bL,list:CL,paragraph:wL,root:TL,strong:EL,table:DL,tableCell:kL,tableRow:OL,text:PL,thematicBreak:FL,toml:LL,yaml:LL,definition:LL,footnoteDefinition:LL};function LL(){}var RL=typeof self==`object`?self:globalThis,zL=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new RL[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new RL[a](o),i)};return r},BL=e=>zL(new Map,e)(0),VL=``,{toString:HL}={},{keys:UL}=Object,WL=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=HL.call(e).slice(8,-1);switch(n){case`Array`:return[1,VL];case`Object`:return[2,VL];case`Date`:return[3,VL];case`RegExp`:return[4,VL];case`Map`:return[5,VL];case`Set`:return[6,VL];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},GL=([e,t])=>e===0&&(t===`function`||t===`symbol`),KL=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=WL(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of UL(r))(e||!GL(WL(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(GL(WL(n))||GL(WL(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!GL(WL(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},qL=(e,{json:t,lossy:n}={})=>{let r=[];return KL(!(t||n),!!t,new Map,r)(e),r},JL=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?BL(qL(e,t)):structuredClone(e):(e,t)=>BL(qL(e,t));function YL(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function XL(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function ZL(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||YL,r=e.options.footnoteBackLabel||XL,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=MP(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...JL(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
102
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function LL(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=RL(n[r])}return t}function RL(e){return e.spread??e.children.length>1}function zL(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function BL(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function VL(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function HL(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function UL(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=IN(t.children[1]),o=FN(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function WL(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function GL(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var KL=9,qL=32;function JL(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(YL(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(YL(t.slice(i),i>0,!1)),a.join(``)}function YL(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===KL||t===qL;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===KL||t===qL;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function XL(e,t){let n={type:`text`,value:JL(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function ZL(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var QL={blockquote:SL,break:CL,code:wL,delete:TL,emphasis:EL,footnoteReference:DL,heading:OL,html:kL,imageReference:jL,image:ML,inlineCode:NL,linkReference:PL,link:FL,listItem:IL,list:zL,paragraph:BL,root:VL,strong:HL,table:UL,tableCell:GL,tableRow:WL,text:XL,thematicBreak:ZL,toml:$L,yaml:$L,definition:$L,footnoteDefinition:$L};function $L(){}var eR=typeof self==`object`?self:globalThis,tR=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new eR[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new eR[a](o),i)};return r},nR=e=>tR(new Map,e)(0),rR=``,{toString:iR}={},{keys:aR}=Object,oR=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=iR.call(e).slice(8,-1);switch(n){case`Array`:return[1,rR];case`Object`:return[2,rR];case`Date`:return[3,rR];case`RegExp`:return[4,rR];case`Map`:return[5,rR];case`Set`:return[6,rR];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},sR=([e,t])=>e===0&&(t===`function`||t===`symbol`),cR=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=oR(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of aR(r))(e||!sR(oR(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(sR(oR(n))||sR(oR(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!sR(oR(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},lR=(e,{json:t,lossy:n}={})=>{let r=[];return cR(!(t||n),!!t,new Map,r)(e),r},uR=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?nR(lR(e,t)):structuredClone(e):(e,t)=>nR(lR(e,t));function dR(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function fR(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function pR(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||dR,r=e.options.footnoteBackLabel||fR,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=JP(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...uR(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
103
103
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
104
- `}]}}var QL=(function(e){if(e==null)return rR;if(typeof e==`function`)return nR(e);if(typeof e==`object`)return Array.isArray(e)?$L(e):eR(e);if(typeof e==`string`)return tR(e);throw Error(`Expected function, string, or object as test`)});function $L(e){let t=[],n=-1;for(;++n<e.length;)t[n]=QL(e[n]);return nR(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function eR(e){let t=e;return nR(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function tR(e){return nR(t);function t(t){return t&&t.type===e}}function nR(e){return t;function t(t,n,r){return!!(iR(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function rR(){return!0}function iR(e){return typeof e==`object`&&!!e&&`type`in e}function aR(e){return e}var oR=[];function sR(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=QL(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+aR(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=oR,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=cR(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function cR(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?oR:[e]}function lR(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),sR(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var uR={}.hasOwnProperty,dR={};function fR(e,t){let n=t||dR,r=new Map,i=new Map,a={all:s,applyData:mR,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...IL,...n.handlers},one:o,options:n,patch:pR,wrap:gR};return lR(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(uR.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=JL(n);return r.children=a.all(e),r}return JL(e)}return(a.options.unknownHandler||hR)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=_R(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=_R(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function pR(e,t){e.position&&(t.position=SN(e))}function mR(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,JL(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function hR(e,t){let n=t.data||{},r=`value`in t&&!(uR.call(n,`hProperties`)||uR.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function gR(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
104
+ `}]}}var mR=(function(e){if(e==null)return yR;if(typeof e==`function`)return vR(e);if(typeof e==`object`)return Array.isArray(e)?hR(e):gR(e);if(typeof e==`string`)return _R(e);throw Error(`Expected function, string, or object as test`)});function hR(e){let t=[],n=-1;for(;++n<e.length;)t[n]=mR(e[n]);return vR(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function gR(e){let t=e;return vR(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function _R(e){return vR(t);function t(t){return t&&t.type===e}}function vR(e){return t;function t(t,n,r){return!!(bR(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function yR(){return!0}function bR(e){return typeof e==`object`&&!!e&&`type`in e}function xR(e){return e}var SR=[];function CR(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=mR(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+xR(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=SR,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=wR(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function wR(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?SR:[e]}function TR(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),CR(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var ER={}.hasOwnProperty,DR={};function OR(e,t){let n=t||DR,r=new Map,i=new Map,a={all:s,applyData:AR,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...QL,...n.handlers},one:o,options:n,patch:kR,wrap:MR};return TR(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(ER.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=uR(n);return r.children=a.all(e),r}return uR(e)}return(a.options.unknownHandler||jR)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=NR(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=NR(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function kR(e,t){e.position&&(t.position=RN(e))}function AR(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,uR(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function jR(e,t){let n=t.data||{},r=`value`in t&&!(ER.call(n,`hProperties`)||ER.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function MR(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
105
105
  `});++r<e.length;)r&&n.push({type:`text`,value:`
106
106
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
107
- `}),n}function _R(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function vR(e,t){let n=fR(e,t),r=n.one(e,void 0),i=ZL(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
108
- `},i)),a}function yR(e,t){return e&&`run`in e?async function(n,r){let i=vR(n,{file:r,...t});await e.run(i,r)}:function(n,r){return vR(n,{file:r,...e||t})}}function bR(e){if(e)throw e}var xR=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function SR(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function CR(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?wR(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function wR(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var TR={basename:ER,dirname:DR,extname:OR,join:kR,sep:`/`};function ER(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);MR(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function DR(e){if(MR(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function OR(e){MR(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function kR(...e){let t=-1,n;for(;++t<e.length;)MR(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:AR(n)}function AR(e){MR(e);let t=e.codePointAt(0)===47,n=jR(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function jR(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function MR(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var NR={cwd:PR};function PR(){return`/`}function FR(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function IR(e){if(typeof e==`string`)e=new URL(e);else if(!FR(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return LR(e)}function LR(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var RR=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],zR=class{constructor(e){let t;t=e?FR(e)?{path:e}:typeof e==`string`||UR(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:NR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<RR.length;){let e=RR[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)RR.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?TR.basename(this.path):void 0}set basename(e){VR(e,`basename`),BR(e,`basename`),this.path=TR.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?TR.dirname(this.path):void 0}set dirname(e){HR(this.basename,`dirname`),this.path=TR.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?TR.extname(this.path):void 0}set extname(e){if(BR(e,`extname`),HR(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=TR.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){FR(e)&&(e=IR(e)),VR(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?TR.basename(this.path,this.extname):void 0}set stem(e){VR(e,`stem`),BR(e,`stem`),this.path=TR.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new DN(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function BR(e,t){if(e&&e.includes(TR.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+TR.sep+"`")}function VR(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function HR(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function UR(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var WR=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),GR=u(xR(),1),KR={}.hasOwnProperty,qR=new class e extends WR{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=CR()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,GR.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(XR(`data`,this.frozen),this.namespace[e]=t,this):KR.call(this.namespace,e)&&this.namespace[e]||void 0:e?(XR(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=$R(e),n=this.parser||this.Parser;return JR(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),JR(`process`,this.parser||this.Parser),YR(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=$R(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);tz(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),JR(`processSync`,this.parser||this.Parser),YR(`processSync`,this.compiler||this.Compiler),this.process(e,r),QR(`processSync`,`process`,t),n;function r(e,r){t=!0,bR(e),n=r}}run(e,t,n){ZR(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=$R(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),QR(`runSync`,`run`,n),r;function i(e,t){bR(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=$R(t),r=this.compiler||this.Compiler;return YR(`stringify`,r),ZR(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(XR(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,GR.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];SR(o)&&SR(r)&&(r=(0,GR.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function JR(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function YR(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function XR(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ZR(e){if(!SR(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function QR(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function $R(e){return ez(e)?e:new zR(e)}function ez(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function tz(e){return typeof e==`string`||nz(e)}function nz(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var rz=[],iz={allowDangerousHtml:!0},az=/^(https?|ircs?|mailto|xmpp)$/i,oz=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function sz(e){let t=cz(e),n=lz(e);return uz(t.runSync(t.parse(n),n),e)}function cz(e){let t=e.rehypePlugins||rz,n=e.remarkPlugins||rz,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...iz}:iz;return qR().use(aL).use(n).use(yR,r).use(t)}function lz(e){let t=e.children||``,n=new zR;return typeof t==`string`?n.value=t:``+t,n}function uz(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||dz;for(let e of oz)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return lR(e,l),FN(e,{Fragment:q.Fragment,components:i,ignoreInvalidStyle:!0,jsx:q.jsx,jsxs:q.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in rP)if(Object.hasOwn(rP,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=rP[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function dz(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||az.test(e.slice(0,t))?e:``}function fz(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function pz(e,t,n){let r=QL((n||{}).ignore||[]),i=mz(t),a=-1;for(;++a<i.length;)sR(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function mz(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([hz(e[0]),gz(e[1])])}return t}function hz(e){return typeof e==`string`?new RegExp(fz(e),`g`):e}function gz(e){return typeof e==`function`?e:function(){return e}}function _z(e){pz(e,[/\r?\n|\r/g,vz])}function vz(){return{type:`break`}}function yz(){return function(e){_z(e)}}var bz=RegExp(`\x1B\\[[\\d;]*m|\\[[\\d;]*m`,`g`),xz=`apply_patch`,Sz=`[[archon-apply-patch]]`,Cz=`[[/archon-apply-patch]]`,wz=e=>{let t=Dz(e).trim();if(!t)return null;let n=t.split(`
109
- `);if(n[0]?.trim()===Sz&&n[n.length-1]?.trim()===Cz)return n.slice(1,-1).join(`
110
- `);if(n[0]?.trim()===xz)return n.slice(1).join(`
111
- `).trim()||null;let r=n[0]?.trim()??``;return r.startsWith(`apply_patch `)&&r.includes(`*** Begin Patch`)?r:null},Tz=e=>{let t=[],n=null;for(let r of e.split(`
112
- `)){if(!r.startsWith(` `)&&!r.startsWith(`+`)&&!r.startsWith(`-`)){n&&t.push(n),n={filePath:r,lines:[]};continue}n||={filePath:`Patch`,lines:[]},n.lines.push(r)}return n&&t.push(n),t},Ez=({content:e})=>{let t=Tz(e);return t.length===0?(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{children:e})}):(0,q.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border/70 bg-background/60`,children:t.map((e,t)=>(0,q.jsxs)(`div`,{className:J(t>0&&`border-t border-border/70`),children:[(0,q.jsx)(`div`,{className:`border-b border-border/70 bg-muted/40 px-3 py-2 font-mono text-[11px] font-medium text-foreground/90`,children:e.filePath}),(0,q.jsx)(`div`,{className:`py-1`,children:e.lines.map((e,t)=>{let n=e[0]??` `,r=e.length>0?e.slice(1):``,i=n===`+`,a=n===`-`,o=i?`bg-emerald-500/12 text-emerald-100`:a?`bg-rose-500/12 text-rose-100`:`text-foreground/90`,s=i?`text-emerald-300`:a?`text-rose-300`:`text-muted-foreground`;return(0,q.jsxs)(`div`,{className:J(`flex gap-3 px-3 py-1 font-mono text-xs leading-5`,o),children:[(0,q.jsx)(`span`,{className:J(`w-3 shrink-0 text-center`,s),children:n===` `?` `:n}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:r||`\xA0`})]},t)})})]},`${e.filePath}-${t}`))})},Dz=e=>e.replace(/\r\n/g,`
113
- `).replace(bz,``),Oz=e=>{let t=wz(e);if(t)return[{kind:`apply_patch`,content:t}];let n=[],r=[],i=()=>{let e=r.join(`
114
- `);if(!e.trim()){r.length=0;return}n.push({kind:`markdown`,content:e}),r.length=0};for(let t of Dz(e).split(`
115
- `))r.push(t);return i(),n},kz=({content:e,className:t})=>{let n=Oz(e);return(0,q.jsx)(`div`,{className:J(`prose prose-invert prose-sm max-w-none break-words text-sm text-foreground [overflow-wrap:anywhere] [&_code]:break-words [&_code]:text-violet-300 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-base [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-base [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:my-1 [&_li>p]:my-1 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-secondary [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_p]:mb-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5 [&_br+br]:mt-3 [&_br+br]:block`,t),children:n.map((e,t)=>e.kind===`apply_patch`?(0,q.jsx)(Ez,{content:e.content},`apply-patch-${t}`):e.kind===`code`?(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{children:e.content})},`code-${t}`):(0,q.jsx)(sz,{remarkPlugins:[yz],children:e.content},`markdown-${t}`))})},Az=120,jz=160,Mz=(e,t)=>t===0?0:e<0?t-1:e>=t?0:e,Nz=e=>({start:e.selectionStart??0,end:e.selectionEnd??0}),Pz=e=>e?`${e.replaceStart}:${e.replaceEnd}:${e.query}`:null,Fz=({value:e,selection:t})=>{if(t.start!==t.end)return null;let n=t.start;for(;n>0&&!/\s/.test(e[n-1]??``);)--n;let r=t.end;for(;r<e.length&&!/\s/.test(e[r]??``);)r+=1;return!e.slice(n,r).startsWith(`@`)||n>0&&!/\s/.test(e[n-1]??``)?null:{query:e.slice(n+1,t.start),replaceStart:n,replaceEnd:r}},Iz=(e,t)=>{if(e){if(typeof e==`function`){e(t);return}e.current=t}},Lz=e=>{let t=Number.parseFloat(e);return Number.isNaN(t)?0:t},Rz=e=>{let t=Lz(e.lineHeight);if(t>0)return t;let n=Lz(e.fontSize);return n>0?n*1.2:20},zz=(e,t)=>{let n=window.getComputedStyle(e),r=document.createElement(`div`),i=document.createElement(`span`),a=e.value.slice(0,t),o=`borderBottomWidth.borderLeftWidth.borderRightWidth.borderTopWidth.boxSizing.fontFamily.fontFeatureSettings.fontKerning.fontSize.fontStretch.fontStyle.fontVariant.fontVariationSettings.fontWeight.letterSpacing.lineHeight.paddingBottom.paddingLeft.paddingRight.paddingTop.tabSize.textIndent.textTransform.whiteSpace.width.wordBreak.wordSpacing.overflowWrap`.split(`.`);r.setAttribute(`aria-hidden`,`true`),Object.assign(r.style,{position:`absolute`,visibility:`hidden`,top:`0`,left:`-9999px`,overflow:`hidden`,whiteSpace:`pre-wrap`,wordWrap:`break-word`,pointerEvents:`none`}),o.forEach(e=>{r.style[e]=n[e]}),r.textContent=a,i.textContent=`​`,r.append(i),document.body.append(r);let s=Lz(n.borderTopWidth),c=Rz(n),l=i.offsetTop+s-e.scrollTop;return r.remove(),{top:l,lineHeight:c}},Bz=(0,b.forwardRef)(({projectId:e,suggestionTicketId:t=null,value:n,onValueChange:r,onKeyDown:i,onBlur:a,onFocus:o,onScroll:s,onSelect:c,suggestionAnchor:l=`edge`,suggestionPlacement:u=`below`,wrapperClassName:d,className:f,...p},m)=>{let h=(0,b.useRef)(null),g=(0,b.useRef)(null),[_,v]=(0,b.useState)({start:0,end:0}),[y,x]=(0,b.useState)([]),[S,C]=(0,b.useState)(0),[w,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(null),N=(0,b.useId)(),P=(0,b.useMemo)(()=>Fz({value:n,selection:_}),[_,n]),F=Pz(P),I=y.length>0,L=k===F,R=D&&I&&!L,z=!!e&&!!F&&w!==F&&(I||D||L);(0,b.useEffect)(()=>{let e=g.current;if(e===null)return;let t=h.current;if(!t)return;let n=requestAnimationFrame(()=>{let n=Math.min(e,t.value.length);t.focus(),t.setSelectionRange(n,n),v({start:n,end:n}),g.current=null});return()=>{cancelAnimationFrame(n)}},[n]),(0,b.useEffect)(()=>{if(!e||!F){E(null),x([]),A(null),O(!1),C(0);return}if(w===F)return;O(!0);let n=new AbortController,r=window.setTimeout(async()=>{try{let r=await We(e,P?.query??``,{signal:n.signal,ticketId:t});if(n.signal.aborted)return;x(r),A(F),C(0)}catch(e){T(e)||(x([]),A(F),C(0))}finally{n.signal.aborted||O(!1)}},Az);return()=>{n.abort(),window.clearTimeout(r)}},[P?.query,F,w,e,t]),(0,b.useEffect)(()=>{C(e=>Mz(e,y.length))},[y]),(0,b.useLayoutEffect)(()=>{if(!z||l!==`caret`){M(null);return}let e=h.current;if(!e){M(null);return}let{top:t,lineHeight:n}=zz(e,_.start),r=t,i=e.clientHeight-(t+n),a=r>=jz||r>=i?`above`:`below`,o=a===`above`?Math.max(t-8,0):t+n+8;M(e=>e&&e.placement===a&&Math.abs(e.top-o)<1?e:{placement:a,top:o})},[_.start,z,l,n]),(0,b.useEffect)(()=>{!z||y.length===0||document.getElementById(`${N}-option-${S}`)?.scrollIntoView({block:`nearest`})},[S,N,y.length,z]);let ee=()=>{F&&E(F)},B=e=>{if(!e||!P||!L)return;let t=n.slice(P.replaceEnd),i=t.length===0||!/^\s/.test(t),a=`@${e.path}${i?` `:``}`,o=n.slice(0,P.replaceStart)+a+t,s=P.replaceStart+a.length,c=`${P.replaceStart}:${s}:${e.path}`;g.current=s,E(c),A(null),x([]),r(o)},V=e=>{v(Nz(e.currentTarget)),r(e.target.value)},H=e=>{ee(),a?.(e)},te=e=>{v(Nz(e.currentTarget)),o?.(e)},U=e=>{v(Nz(e.currentTarget)),c?.(e)},ne=e=>{v(Nz(e.currentTarget)),s?.(e)},W=l===`caret`&&j,re=W?{top:`${j.top}px`,transform:j.placement===`above`?`translateY(-100%)`:void 0}:void 0,ie=e=>{if(z){if(!L&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`)){e.preventDefault();return}if(e.key===`ArrowDown`){e.preventDefault(),C(e=>Mz(e+1,y.length));return}if(e.key===`ArrowUp`){e.preventDefault(),C(e=>Mz(e-1,y.length));return}if(e.key===`Enter`){e.preventDefault();let t=y[S]??null;t&&B(t);return}if(e.key===`Escape`){e.preventDefault(),ee();return}}i?.(e)};return(0,q.jsxs)(`div`,{className:J(`relative min-w-0`,d),children:[(0,q.jsx)(Og,{...p,ref:e=>{h.current=e,Iz(m,e)},value:n,onChange:V,onBlur:H,onFocus:te,onKeyDown:ie,onScroll:ne,onSelect:U,"aria-activedescendant":z&&y[S]?`${N}-option-${S}`:void 0,"aria-controls":z?N:void 0,"aria-expanded":z,className:f}),z?(0,q.jsxs)(`div`,{id:N,role:`listbox`,"aria-busy":D,"data-testid":`file-mention-suggestions`,"data-suggestion-anchor":W?`caret`:`edge`,"data-suggestion-placement":W?j.placement:u,className:J(`absolute inset-x-0 z-20 overflow-hidden rounded-xl border border-border bg-popover shadow-2xl shadow-black/30`,!W&&(u===`above`?`bottom-full mb-2`:`top-full mt-2`)),style:re,children:[R?(0,q.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 rounded-full border border-border/80 bg-popover/95 px-2 py-0.5 text-[11px] font-medium text-muted-foreground shadow-sm`,children:`Updating...`}):null,(0,q.jsx)(`div`,{className:`max-h-72 overflow-y-auto p-1`,children:D&&!I?(0,q.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`Loading file suggestions...`}):I?y.map((e,t)=>{let n=t===S,r=e.directory?`${e.directory}/`:``;return(0,q.jsx)(`button`,{id:`${N}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,disabled:!L,className:J(`flex w-full rounded-lg px-3 py-1.5 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`hover:bg-accent/60`,!L&&`cursor-wait opacity-80 disabled:pointer-events-none`),onMouseDown:e=>{e.preventDefault()},onMouseEnter:()=>{L&&C(t)},onClick:()=>{B(e)},children:(0,q.jsxs)(`span`,{className:`min-w-0 truncate text-sm`,children:[r?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:r}):null,(0,q.jsx)(`span`,{className:`font-medium`,children:e.name})]})},e.path)}):(0,q.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`No matching files found.`})})]}):null]})});Bz.displayName=`ProjectFileMentionTextarea`;var Vz=({item:e,index:t})=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-sky-500/20 bg-background/40 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.source===`archon_review_finding`?`Finding ${e.findingNumber??t}`:e.source===`external_review_comment`?`External fix ${t}`:e.source===`preview_comment`?`Preview comment ${t}`:`Comment ${t}`}),(0,q.jsx)(`div`,{className:`mt-1 font-mono text-xs text-foreground`,children:e.filePath??e.page??`Unknown target`})]}),e.line&&(0,q.jsx)(`div`,{className:`rounded-full border border-border bg-background/60 px-2 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.line})]}),(e.title||e.element)&&(0,q.jsx)(`div`,{className:`mt-3 text-sm font-medium text-foreground`,children:e.title??e.element}),e.selectorHint&&(0,q.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.selectorHint}),(0,q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.comment}),e.text&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Text`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 text-xs text-foreground`,children:e.text})]}),e.href&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Href`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.href})]}),e.src&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Src`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.src})]}),e.lineContent&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Changed line`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground`,children:e.lineContent})]})]}),Hz=({content:e,parsed:t})=>{let[n,r]=(0,b.useState)(!1),i=t.items.length===1?`fix`:`fixes`,a=t.locationLabel===`file`?t.locationCount===1?`file`:`files`:t.locationLabel===`page`?t.locationCount===1?`page`:`pages`:t.locationCount===1?`target`:`targets`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Selected fixes`}),(0,q.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[t.items.length,` `,i,` across `,t.locationCount,` `,a]})]}),(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`ghost`,className:`gap-1.5 self-start`,onClick:()=>{r(e=>!e)},children:[(0,q.jsx)(m_,{className:`h-3.5 w-3.5 transition-transform ${n?`rotate-180`:``}`}),n?`Hide raw prompt`:`Show raw prompt`]})]}),(0,q.jsx)(`div`,{className:`space-y-3`,children:t.items.map((e,t)=>(0,q.jsx)(Vz,{item:e,index:t+1},`${e.filePath??e.page??`target`}:${e.line??e.element??t}:${t+1}`))}),n&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/40 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-widest text-muted-foreground`,children:`Raw prompt`}),(0,q.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap text-xs leading-relaxed text-foreground`,children:e})]})]})},Uz=({className:e})=>(0,q.jsx)(qm,{"aria-hidden":`true`,className:e}),Wz=2,Gz=18,Kz=288,qz=(e,t)=>{let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t).trimEnd()}...`},Jz=e=>{if(typeof document>`u`)return{text:e,truncated:!1};let t=document.createElement(`span`);t.setAttribute(`aria-hidden`,`true`),t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.pointerEvents=`none`,t.style.whiteSpace=`pre-wrap`,t.style.wordBreak=`break-word`,t.style.overflowWrap=`anywhere`,t.style.width=`${Kz}px`,t.style.fontSize=`12px`,t.style.lineHeight=`${Gz}px`,t.style.fontFamily=`inherit`,t.textContent=e,document.body.appendChild(t);let n=Gz*Wz;if(!(t.getBoundingClientRect().height>n+.5))return document.body.removeChild(t),{text:e,truncated:!1};let r=0,i=e.length,a=qz(e,Math.max(1,Math.floor(e.length/2)));for(;r<=i;){let o=Math.floor((r+i)/2),s=qz(e,o);t.textContent=s,t.getBoundingClientRect().height<=n+.5?(a=s,r=o+1):i=o-1}return document.body.removeChild(t),{text:a,truncated:!0}},Yz=`Please address the following review comments in the current diff.`,Xz=`Please address the following selected fixes in the current diff.`,Zz=`Please address the following selected fixes from the current preview.`,Qz=`Please address the following selected fixes from the current diff and preview.`,$z=e=>{let t=e.trimEnd(),n=t.indexOf(`
107
+ `}),n}function NR(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function PR(e,t){let n=OR(e,t),r=n.one(e,void 0),i=pR(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
108
+ `},i)),a}function FR(e,t){return e&&`run`in e?async function(n,r){let i=PR(n,{file:r,...t});await e.run(i,r)}:function(n,r){return PR(n,{file:r,...e||t})}}function IR(e){if(e)throw e}var LR=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function RR(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function zR(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?BR(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function BR(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var VR={basename:HR,dirname:UR,extname:WR,join:GR,sep:`/`};function HR(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);JR(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function UR(e){if(JR(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function WR(e){JR(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function GR(...e){let t=-1,n;for(;++t<e.length;)JR(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:KR(n)}function KR(e){JR(e);let t=e.codePointAt(0)===47,n=qR(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function qR(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function JR(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var YR={cwd:XR};function XR(){return`/`}function ZR(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function QR(e){if(typeof e==`string`)e=new URL(e);else if(!ZR(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return $R(e)}function $R(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var ez=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],tz=class{constructor(e){let t;t=e?ZR(e)?{path:e}:typeof e==`string`||az(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:YR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<ez.length;){let e=ez[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)ez.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?VR.basename(this.path):void 0}set basename(e){rz(e,`basename`),nz(e,`basename`),this.path=VR.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?VR.dirname(this.path):void 0}set dirname(e){iz(this.basename,`dirname`),this.path=VR.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?VR.extname(this.path):void 0}set extname(e){if(nz(e,`extname`),iz(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=VR.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){ZR(e)&&(e=QR(e)),rz(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?VR.basename(this.path,this.extname):void 0}set stem(e){rz(e,`stem`),nz(e,`stem`),this.path=VR.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new UN(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function nz(e,t){if(e&&e.includes(VR.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+VR.sep+"`")}function rz(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function iz(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function az(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var oz=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),sz=u(LR(),1),cz={}.hasOwnProperty,lz=new class e extends oz{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=zR()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,sz.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(fz(`data`,this.frozen),this.namespace[e]=t,this):cz.call(this.namespace,e)&&this.namespace[e]||void 0:e?(fz(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=hz(e),n=this.parser||this.Parser;return uz(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),uz(`process`,this.parser||this.Parser),dz(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=hz(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);_z(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),uz(`processSync`,this.parser||this.Parser),dz(`processSync`,this.compiler||this.Compiler),this.process(e,r),mz(`processSync`,`process`,t),n;function r(e,r){t=!0,IR(e),n=r}}run(e,t,n){pz(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=hz(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),mz(`runSync`,`run`,n),r;function i(e,t){IR(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=hz(t),r=this.compiler||this.Compiler;return dz(`stringify`,r),pz(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(fz(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,sz.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];RR(o)&&RR(r)&&(r=(0,sz.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function uz(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function dz(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function fz(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function pz(e){if(!RR(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function mz(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function hz(e){return gz(e)?e:new tz(e)}function gz(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function _z(e){return typeof e==`string`||vz(e)}function vz(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var yz=[],bz={allowDangerousHtml:!0},xz=/^(https?|ircs?|mailto|xmpp)$/i,Sz=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function Cz(e){let t=wz(e),n=Tz(e);return Ez(t.runSync(t.parse(n),n),e)}function wz(e){let t=e.rehypePlugins||yz,n=e.remarkPlugins||yz,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...bz}:bz;return lz().use(xL).use(n).use(FR,r).use(t)}function Tz(e){let t=e.children||``,n=new tz;return typeof t==`string`?n.value=t:``+t,n}function Ez(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Dz;for(let e of Sz)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return TR(e,l),ZN(e,{Fragment:q.Fragment,components:i,ignoreInvalidStyle:!0,jsx:q.jsx,jsxs:q.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in yP)if(Object.hasOwn(yP,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=yP[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Dz(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||xz.test(e.slice(0,t))?e:``}function Oz(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function kz(e,t,n){let r=mR((n||{}).ignore||[]),i=Az(t),a=-1;for(;++a<i.length;)CR(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Az(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([jz(e[0]),Mz(e[1])])}return t}function jz(e){return typeof e==`string`?new RegExp(Oz(e),`g`):e}function Mz(e){return typeof e==`function`?e:function(){return e}}function Nz(e){kz(e,[/\r?\n|\r/g,Pz])}function Pz(){return{type:`break`}}function Fz(){return function(e){Nz(e)}}var Iz=RegExp(`\x1B\\[[\\d;]*m|\\[[\\d;]*m`,`g`),Lz=`apply_patch`,Rz=`[[archon-apply-patch]]`,zz=`[[/archon-apply-patch]]`,Bz=e=>{let t=Uz(e).trim();if(!t)return null;let n=t.split(`
109
+ `);if(n[0]?.trim()===Rz&&n[n.length-1]?.trim()===zz)return n.slice(1,-1).join(`
110
+ `);if(n[0]?.trim()===Lz)return n.slice(1).join(`
111
+ `).trim()||null;let r=n[0]?.trim()??``;return r.startsWith(`apply_patch `)&&r.includes(`*** Begin Patch`)?r:null},Vz=e=>{let t=[],n=null;for(let r of e.split(`
112
+ `)){if(!r.startsWith(` `)&&!r.startsWith(`+`)&&!r.startsWith(`-`)){n&&t.push(n),n={filePath:r,lines:[]};continue}n||={filePath:`Patch`,lines:[]},n.lines.push(r)}return n&&t.push(n),t},Hz=({content:e})=>{let t=Vz(e);return t.length===0?(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{children:e})}):(0,q.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border/70 bg-background/60`,children:t.map((e,t)=>(0,q.jsxs)(`div`,{className:J(t>0&&`border-t border-border/70`),children:[(0,q.jsx)(`div`,{className:`border-b border-border/70 bg-muted/40 px-3 py-2 font-mono text-[11px] font-medium text-foreground/90`,children:e.filePath}),(0,q.jsx)(`div`,{className:`py-1`,children:e.lines.map((e,t)=>{let n=e[0]??` `,r=e.length>0?e.slice(1):``,i=n===`+`,a=n===`-`,o=i?`bg-emerald-500/12 text-emerald-100`:a?`bg-rose-500/12 text-rose-100`:`text-foreground/90`,s=i?`text-emerald-300`:a?`text-rose-300`:`text-muted-foreground`;return(0,q.jsxs)(`div`,{className:J(`flex gap-3 px-3 py-1 font-mono text-xs leading-5`,o),children:[(0,q.jsx)(`span`,{className:J(`w-3 shrink-0 text-center`,s),children:n===` `?` `:n}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:r||`\xA0`})]},t)})})]},`${e.filePath}-${t}`))})},Uz=e=>e.replace(/\r\n/g,`
113
+ `).replace(Iz,``),Wz=e=>{let t=Bz(e);if(t)return[{kind:`apply_patch`,content:t}];let n=[],r=[],i=()=>{let e=r.join(`
114
+ `);if(!e.trim()){r.length=0;return}n.push({kind:`markdown`,content:e}),r.length=0};for(let t of Uz(e).split(`
115
+ `))r.push(t);return i(),n},Gz=({content:e,className:t})=>{let n=Wz(e);return(0,q.jsx)(`div`,{className:J(`prose prose-invert prose-sm max-w-none break-words text-sm text-foreground [overflow-wrap:anywhere] [&_code]:break-words [&_code]:text-violet-300 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-base [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-base [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:my-1 [&_li>p]:my-1 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-secondary [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_p]:mb-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5 [&_br+br]:mt-3 [&_br+br]:block`,t),children:n.map((e,t)=>e.kind===`apply_patch`?(0,q.jsx)(Hz,{content:e.content},`apply-patch-${t}`):e.kind===`code`?(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{children:e.content})},`code-${t}`):(0,q.jsx)(Cz,{remarkPlugins:[Fz],children:e.content},`markdown-${t}`))})},Kz=({item:e,index:t})=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-sky-500/20 bg-background/40 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.source===`archon_review_finding`?`Finding ${e.findingNumber??t}`:e.source===`external_review_comment`?`External fix ${t}`:e.source===`preview_comment`?`Preview comment ${t}`:`Comment ${t}`}),(0,q.jsx)(`div`,{className:`mt-1 font-mono text-xs text-foreground`,children:e.filePath??e.page??`Unknown target`})]}),e.line&&(0,q.jsx)(`div`,{className:`rounded-full border border-border bg-background/60 px-2 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.line})]}),(e.title||e.element)&&(0,q.jsx)(`div`,{className:`mt-3 text-sm font-medium text-foreground`,children:e.title??e.element}),e.selectorHint&&(0,q.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.selectorHint}),(0,q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.comment}),e.text&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Text`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 text-xs text-foreground`,children:e.text})]}),e.href&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Href`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.href})]}),e.src&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Src`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.src})]}),e.lineContent&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Changed line`}),(0,q.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground`,children:e.lineContent})]})]}),qz=({content:e,parsed:t})=>{let[n,r]=(0,b.useState)(!1),i=t.items.length===1?`fix`:`fixes`,a=t.locationLabel===`file`?t.locationCount===1?`file`:`files`:t.locationLabel===`page`?t.locationCount===1?`page`:`pages`:t.locationCount===1?`target`:`targets`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Selected fixes`}),(0,q.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[t.items.length,` `,i,` across `,t.locationCount,` `,a]})]}),(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`ghost`,className:`gap-1.5 self-start`,onClick:()=>{r(e=>!e)},children:[(0,q.jsx)(m_,{className:`h-3.5 w-3.5 transition-transform ${n?`rotate-180`:``}`}),n?`Hide raw prompt`:`Show raw prompt`]})]}),(0,q.jsx)(`div`,{className:`space-y-3`,children:t.items.map((e,t)=>(0,q.jsx)(Kz,{item:e,index:t+1},`${e.filePath??e.page??`target`}:${e.line??e.element??t}:${t+1}`))}),n&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/40 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-widest text-muted-foreground`,children:`Raw prompt`}),(0,q.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap text-xs leading-relaxed text-foreground`,children:e})]})]})},Jz=2,Yz=18,Xz=288,Zz=(e,t)=>{let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t).trimEnd()}...`},Qz=e=>{if(typeof document>`u`)return{text:e,truncated:!1};let t=document.createElement(`span`);t.setAttribute(`aria-hidden`,`true`),t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.pointerEvents=`none`,t.style.whiteSpace=`pre-wrap`,t.style.wordBreak=`break-word`,t.style.overflowWrap=`anywhere`,t.style.width=`${Xz}px`,t.style.fontSize=`12px`,t.style.lineHeight=`${Yz}px`,t.style.fontFamily=`inherit`,t.textContent=e,document.body.appendChild(t);let n=Yz*Jz;if(!(t.getBoundingClientRect().height>n+.5))return document.body.removeChild(t),{text:e,truncated:!1};let r=0,i=e.length,a=Zz(e,Math.max(1,Math.floor(e.length/2)));for(;r<=i;){let o=Math.floor((r+i)/2),s=Zz(e,o);t.textContent=s,t.getBoundingClientRect().height<=n+.5?(a=s,r=o+1):i=o-1}return document.body.removeChild(t),{text:a,truncated:!0}},$z=`Please address the following review comments in the current diff.`,eB=`Please address the following selected fixes in the current diff.`,tB=`Please address the following selected fixes from the current preview.`,nB=`Please address the following selected fixes from the current diff and preview.`,rB=e=>{let t=e.trimEnd(),n=t.indexOf(`
116
116
  Context:
117
117
  \`\`\`diff
118
118
  `);if(n===-1)return null;let r=t.slice(0,n),i=t.slice(n+18);if(!i.endsWith("\n```"))return null;let a=r.split(`
119
119
  `);if(a.length<5)return null;let[o,s,c,l,...u]=a;return!/^\d+\. File: /.test(o)||!s.startsWith(`Line: `)||!c.startsWith(`Hunk: `)||!l.startsWith(`Changed line: `)||u.length===0||!u[0].startsWith(`Comment: `)?null:{source:`manual_comment`,filePath:o.replace(/^\d+\. File: /,``),page:null,line:s.slice(6),element:null,selectorHint:null,text:null,href:null,src:null,hunk:c.slice(6),lineContent:l.slice(14),comment:[u[0].slice(9),...u.slice(1)].join(`
120
- `),diffSnippet:i.slice(0,-4)}},eB=e=>{let t=e.trimEnd(),n=t.split(`
120
+ `),diffSnippet:i.slice(0,-4)}},iB=e=>{let t=e.trimEnd(),n=t.split(`
121
121
  `)[0];if(!/^\d+\. Source: /.test(n))return null;let r=n.replace(/^\d+\. Source: /,``).trim().toLowerCase(),i=r===`archon review finding`?`archon_review_finding`:r===`external review comment`||r.startsWith(`github review `)?`external_review_comment`:r===`preview comment`?`preview_comment`:`manual_comment`,a=new Map,o=null,s=t.indexOf(`
122
122
  Context:
123
123
  \`\`\`diff
124
124
  `),c=s===-1?t:t.slice(0,s);if(s!==-1){let e=t.slice(s+18);o=e.endsWith("\n```")?e.slice(0,-4):null}for(let e of c.split(`
125
- `).slice(1)){let t=e.indexOf(`: `);t!==-1&&a.set(e.slice(0,t),e.slice(t+2))}let l=a.get(`Comment`)??a.get(`What`)??``;return l?i===`preview_comment`?{source:i,filePath:null,page:a.get(`Page`)??null,line:null,element:a.get(`Element`)??null,selectorHint:a.get(`Selector hint`)??null,text:a.get(`Text`)??null,href:a.get(`Href`)??null,src:a.get(`Src`)??null,hunk:null,lineContent:null,comment:l,diffSnippet:null,severity:null,title:null,findingNumber:null}:{source:i,filePath:a.get(`File`)??`Unknown file`,page:null,line:a.get(`Line`)??`line unavailable`,element:null,selectorHint:null,text:null,href:null,src:null,hunk:a.get(`Hunk`)??null,lineContent:a.get(`Changed line`)??null,comment:l,diffSnippet:o,severity:a.get(`Severity`)??null,title:a.get(`Title`)??null,findingNumber:a.has(`Finding`)&&Number(a.get(`Finding`))||null}:null},tB=e=>{let t=e.trim(),n=t.startsWith(Yz),r=[Xz,Zz,Qz].find(e=>t.startsWith(e));if(!n&&!r)return null;let i=n?Yz:r??Xz,a=t.slice(i.length).trim();if(!a)return null;let o=(n?a.split(/\n(?=\d+\. File: )/):a.replace(/\nApply only the selected fixes\. Keep unrelated changes intact\.$/,``).trim().split(/\n(?=\d+\. Source: )/)).map(n?$z:eB);if(o.some(e=>e===null))return null;let s=o.filter(e=>e!==null);return s.length===0?null:{items:s,locationCount:new Set(s.map(e=>e.filePath??e.page??`Unknown target`)).size,locationLabel:s.every(e=>e.page&&!e.filePath)?`page`:s.every(e=>e.filePath&&!e.page)?`file`:`target`}},nB=24,rB=`archon.show-thinking`,iB=12,aB=20,oB=new Set([`step started`,`step finished`]),sB=`[[archon-apply-patch]]`,cB=`[[/archon-apply-patch]]`,lB=[/(^|\n)\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*(?=\n|$)/g,/(^|\n)\s*<archon-[a-z0-9-]+>[\s\S]*?<\/archon-[a-z0-9-]+>\s*(?=\n|$)/g,/(^|\n)\s*<selected_skills>[\s\S]*?<\/selected_skills>\s*(?=\n|$)/g,/(^|\n)\s*<ticket>[\s\S]*?<\/ticket>\s*(?=\n|$)/g,/(^|\n)\s*<follow_up_instruction>[\s\S]*?<\/follow_up_instruction>\s*(?=\n|$)/g,/(^|\n)\s*<review_findings>[\s\S]*?<\/review_findings>\s*(?=\n|$)/g,/(^|\n)\s*<diff>[\s\S]*?<\/diff>\s*(?=\n|$)/g],uB=/(^|\n)\s*<(system-reminder|archon-[a-z0-9-]+|selected_skills|ticket|follow_up_instruction|review_findings|diff)>\s*[\s\S]*$/,dB=()=>{try{return window.localStorage.getItem(rB)===`true`}catch{return!1}},fB=e=>{if(typeof queueMicrotask==`function`){queueMicrotask(e);return}Promise.resolve().then(e)},pB=e=>{e.scrollTop=e.scrollHeight},mB=e=>{let t=Number.parseFloat(e);return Number.isNaN(t)?0:t},hB=e=>{let t=window.getComputedStyle(e),n=(mB(t.lineHeight)||aB)*iB+mB(t.paddingTop)+mB(t.paddingBottom)+mB(t.borderTopWidth)+mB(t.borderBottomWidth);e.style.height=`auto`;let r=Math.min(e.scrollHeight,n);e.style.height=`${r}px`,e.style.overflowY=e.scrollHeight>n?`auto`:`hidden`},gB=e=>e.scrollHeight-e.clientHeight-e.scrollTop<=nB,_B=e=>e.replace(/\r\n/g,`
126
- `).trim(),vB=e=>lB.reduce((e,t)=>e.replace(t,`$1`),e),yB=e=>e.replace(uB,`$1`),bB=e=>{let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return!1;try{let e=JSON.parse(t);return Object.keys(e).length===1&&Array.isArray(e.open_questions)}catch{return!1}},xB=e=>{let t=_B(yB(vB(e??``)));return t?t.split(`
127
- `).filter(e=>{let t=e.trim();return!oB.has(t.toLowerCase())&&!bB(t)}).join(`
125
+ `).slice(1)){let t=e.indexOf(`: `);t!==-1&&a.set(e.slice(0,t),e.slice(t+2))}let l=a.get(`Comment`)??a.get(`What`)??``;return l?i===`preview_comment`?{source:i,filePath:null,page:a.get(`Page`)??null,line:null,element:a.get(`Element`)??null,selectorHint:a.get(`Selector hint`)??null,text:a.get(`Text`)??null,href:a.get(`Href`)??null,src:a.get(`Src`)??null,hunk:null,lineContent:null,comment:l,diffSnippet:null,severity:null,title:null,findingNumber:null}:{source:i,filePath:a.get(`File`)??`Unknown file`,page:null,line:a.get(`Line`)??`line unavailable`,element:null,selectorHint:null,text:null,href:null,src:null,hunk:a.get(`Hunk`)??null,lineContent:a.get(`Changed line`)??null,comment:l,diffSnippet:o,severity:a.get(`Severity`)??null,title:a.get(`Title`)??null,findingNumber:a.has(`Finding`)&&Number(a.get(`Finding`))||null}:null},aB=e=>{let t=e.trim(),n=t.startsWith($z),r=[eB,tB,nB].find(e=>t.startsWith(e));if(!n&&!r)return null;let i=n?$z:r??eB,a=t.slice(i.length).trim();if(!a)return null;let o=(n?a.split(/\n(?=\d+\. File: )/):a.replace(/\nApply only the selected fixes\. Keep unrelated changes intact\.$/,``).trim().split(/\n(?=\d+\. Source: )/)).map(n?rB:iB);if(o.some(e=>e===null))return null;let s=o.filter(e=>e!==null);return s.length===0?null:{items:s,locationCount:new Set(s.map(e=>e.filePath??e.page??`Unknown target`)).size,locationLabel:s.every(e=>e.page&&!e.filePath)?`page`:s.every(e=>e.filePath&&!e.page)?`file`:`target`}},oB=24,sB=`archon.show-thinking`,cB=new Set([`step started`,`step finished`]),lB=`[[archon-apply-patch]]`,uB=`[[/archon-apply-patch]]`,dB=[/(^|\n)\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*(?=\n|$)/g,/(^|\n)\s*<archon-[a-z0-9-]+>[\s\S]*?<\/archon-[a-z0-9-]+>\s*(?=\n|$)/g,/(^|\n)\s*<selected_skills>[\s\S]*?<\/selected_skills>\s*(?=\n|$)/g,/(^|\n)\s*<ticket>[\s\S]*?<\/ticket>\s*(?=\n|$)/g,/(^|\n)\s*<follow_up_instruction>[\s\S]*?<\/follow_up_instruction>\s*(?=\n|$)/g,/(^|\n)\s*<review_findings>[\s\S]*?<\/review_findings>\s*(?=\n|$)/g,/(^|\n)\s*<diff>[\s\S]*?<\/diff>\s*(?=\n|$)/g],fB=/(^|\n)\s*<(system-reminder|archon-[a-z0-9-]+|selected_skills|ticket|follow_up_instruction|review_findings|diff)>\s*[\s\S]*$/,pB=()=>{try{return window.localStorage.getItem(sB)===`true`}catch{return!1}},mB=e=>{if(typeof queueMicrotask==`function`){queueMicrotask(e);return}Promise.resolve().then(e)},hB=e=>{e.scrollTop=e.scrollHeight},gB=e=>e.scrollHeight-e.clientHeight-e.scrollTop<=oB,_B=e=>e.replace(/\r\n/g,`
126
+ `).trim(),vB=e=>dB.reduce((e,t)=>e.replace(t,`$1`),e),yB=e=>e.replace(fB,`$1`),bB=e=>{let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return!1;try{let e=JSON.parse(t);return Object.keys(e).length===1&&Array.isArray(e.open_questions)}catch{return!1}},xB=e=>{let t=_B(yB(vB(e??``)));return t?t.split(`
127
+ `).filter(e=>{let t=e.trim();return!cB.has(t.toLowerCase())&&!bB(t)}).join(`
128
128
  `):``},SB=e=>{let t=_B(xB(e));if(!t)return[];let n=[],r=[],i=!1,a=()=>{let e=r.join(`
129
129
  `).trim();r.length=0,e&&n.push(e)};for(let e of t.split(`
130
- `)){if(e===sB){a(),r.push(e),i=!0;continue}if(i){r.push(e),e===cB&&(a(),i=!1);continue}if(!e.trim()){a();continue}r.push(e)}return a(),n},CB=({visibleContent:e,internalLog:t,showThinking:n})=>{let r=SB(e);if(!n||!t||t.trim().length===0)return r.map(e=>({tone:`primary`,content:e}));let i=SB(t);if(i.length===0)return r.map(e=>({tone:`primary`,content:e}));let a=[],o=0;for(let e of i){let t=r[o];if(t&&_B(t)===_B(e)){a.push({tone:`primary`,content:e}),o+=1;continue}a.push({tone:`secondary`,content:e})}for(;o<r.length;)a.push({tone:`primary`,content:r[o]}),o+=1;return a},wB=(0,b.memo)(({visibleContent:e,internalLog:t,showThinking:n})=>{let r=(0,b.useMemo)(()=>CB({visibleContent:e,internalLog:t,showThinking:n}),[t,n,e]);return r.length===0?null:(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>(0,q.jsx)(kz,{content:e.content,className:e.tone===`secondary`?`text-muted-foreground [&_code]:text-violet-200 [&_pre]:bg-background/70`:void 0},`${e.tone}:${t+1}`))})});wB.displayName=`AssistantMessageContent`;var TB=(0,b.memo)(({message:e,showThinking:t=!1,internalLog:n=null,footer:r=null})=>{let i=e.role===`user`,a=i&&e.kind===`description`,[o,s]=(0,b.useState)(!1),c=i?tB(e.content):null,l=(0,b.useMemo)(()=>!a||!e.content?{text:e.content,truncated:!1}:Jz(e.content),[a,e.content]);return(0,q.jsx)(`div`,{"data-message-role":e.role,className:`flex ${i?`justify-end`:`justify-start`}`,children:(0,q.jsxs)(zv,{className:i?`max-w-[85%] border-sky-500/30 bg-sky-500/10 shadow-none`:`max-w-[85%] border-slate-400/30 bg-slate-400/10 shadow-none`,size:`sm`,children:[(0,q.jsxs)(Wv,{className:`flex flex-col gap-2 px-4 py-4`,children:[e.displayTitle&&(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.displayTitle}),i?c?(0,q.jsx)(Hz,{content:e.content,parsed:c}):a?(0,q.jsx)(uM,{description:e.content,descriptionClass:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,isExpanded:o,collapsedState:l,useStaleLikeStyling:!1,onExpand:()=>s(!0),onCollapse:()=>s(!1)}):(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.content}):(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(cy,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(wB,{visibleContent:e.content,internalLog:n,showThinking:t})})]})]}),r?(0,q.jsx)(Gv,{className:`border-t border-border/60 px-4 py-3`,children:r}):null]})})});TB.displayName=`MessageBubble`;var EB=()=>(0,q.jsxs)(`div`,{role:`status`,"aria-label":`Agent activity indicator`,"aria-live":`polite`,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_infinite_backwards] motion-reduce:animate-none`}),(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.3s_infinite_backwards] motion-reduce:animate-none`}),(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.6s_infinite_backwards] motion-reduce:animate-none`})]}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Agent is working`})]}),DB=(0,b.memo)(({ticketTitle:e,streamingResponse:t,internalLog:n,showThinking:r,statusLabel:i=`Working...`,showActivity:a=!0})=>(0,q.jsx)(`div`,{className:`flex justify-start`,children:(0,q.jsx)(zv,{className:`w-full max-w-[85%] border-slate-400/30 bg-slate-400/10 shadow-none`,size:`sm`,children:(0,q.jsxs)(Wv,{className:`flex flex-col gap-3 px-4 py-4`,children:[(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(cy,{className:`h-4 w-4 text-muted-foreground`}),(0,q.jsx)(`span`,{children:i})]}),t||r&&n?(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(cy,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(wB,{visibleContent:t,internalLog:n,showThinking:r})})]}):null,a?(0,q.jsx)(EB,{}):null]})})}));DB.displayName=`PendingAgentMessage`;var OB=(0,b.memo)(({messages:e,latestAssistantMessageId:t,effectiveShowThinking:n,internalLog:r,pendingAgentTitle:i,streamingResponse:a,isRunning:o,isPendingAgentVisible:s,interruptedPendingSnapshot:c,isLoading:l,emptyStateText:u,renderMessageFooter:d})=>{let f=c?e.findIndex(e=>e.id===c.latestMessageIdAtCapture):-1,p=f>=0?e.slice(0,f+1):e,m=f>=0?e.slice(f+1):[],h=e=>(0,q.jsx)(TB,{message:e,footer:d?.(e)??null,showThinking:n&&e.id===t,internalLog:n&&e.id===t?r:null},`${e.ticket_id}:${e.id}`);return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-5`,children:[e.length===0&&!o&&u&&(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground`,children:l?`Loading conversation...`:u}),p.map(h),o&&s&&i&&(0,q.jsx)(DB,{ticketTitle:i,streamingResponse:a,internalLog:r,showThinking:n}),!o&&c?(0,q.jsx)(DB,{ticketTitle:c.ticketTitle,streamingResponse:c.streamingResponse,internalLog:c.internalLog,showThinking:c.showThinking,statusLabel:`Interrupted`,showActivity:!1}):null,m.map(h)]})});OB.displayName=`ConversationTranscript`;var kB=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,thinkingTicketId:i=null,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c=!1,autoScrollBehavior:l=`sticky`,surfaceVariant:u=`default`,canShowComposer:d,header:f,composerControls:p,composerInlineControls:m,composerTheme:h=`default`,composerSize:g=`default`,showThinkingPlacement:_=`body`,pinComposerToBottom:v=!1,isExternallyResizing:y=!1,pendingAgentRevealKey:x=null,pendingAgentRevealDelayMs:S=0,composerFocusNonce:C=0,layoutKey:w,scrollLayoutKey:T,followUpPrompt:E,followUpPlaceholder:D,emptyStateText:O=`No messages yet.`,autoFocusComposer:k=!1,renderMessageFooter:A,isSendingFollowUp:j,followUpDisabledReason:M,onFollowUpPromptChange:N,onFollowUpKeyDown:P,onFollowUpSubmit:F})=>{let I=(0,b.useRef)(null),L=(0,b.useRef)(null),R=(0,b.useRef)(!1),z=(0,b.useRef)(null),ee=(0,b.useRef)(r),B=(0,b.useRef)(T),V=(0,b.useRef)(!1),H=(0,b.useRef)(E),te=(0,b.useRef)(C),U=(0,b.useRef)(y),ne=(0,b.useRef)(!0),W=(0,b.useRef)(!1),re=(0,b.useRef)(!1),ie=(0,b.useRef)(j),ae=(0,b.useRef)(null),G=(0,b.useRef)(null),[oe,se]=(0,b.useState)(dB),[ce,le]=(0,b.useState)(null),[ue,de]=(0,b.useState)(null),K=(0,b.useId)(),fe=n.length>0?n[n.length-1].id:null,pe=!s||!x||ce===x,me=!!(r&&r.trim().length>0),he=oe&&me,ge=!!(o||he&&r),_e=u===`chat`,ve=h===`plan`?`rounded-l-none border-l-3 border-l-sky-300/25 focus-within:border-l-sky-300/55`:h===`build`?`rounded-l-none border-l-3 border-l-emerald-400/30 focus-within:border-l-emerald-400/65`:null,ye=g===`compact-on-laptop`?`min-h-[4.5rem] sm:min-h-16 2xl:min-h-20`:`min-h-[4.5rem] sm:min-h-20`,be=g===`compact-on-laptop`?`px-4 py-2 2xl:py-2.5`:`px-4 py-2.5`,xe=g===`compact-on-laptop`?`absolute top-1/2 right-2.5 h-8 w-9 -translate-y-1/2 rounded-lg border-border/80 bg-secondary/80 px-0 text-foreground shadow-sm hover:bg-secondary 2xl:right-3 2xl:h-9 2xl:w-10`:`absolute top-1/2 right-3 h-9 w-10 -translate-y-1/2 rounded-lg border-border/80 bg-secondary/80 px-0 text-foreground shadow-sm hover:bg-secondary`,Se=(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(sy,{id:K,"aria-label":`Show thinking`,checked:oe,onCheckedChange:se}),(0,q.jsx)(Vg,{htmlFor:K,className:`text-sm text-muted-foreground`,children:`Show thinking`})]}),Ce=!!m,we=typeof f==`function`?f({showThinkingControl:Se}):f,Te=_===`header`&&!!we&&typeof f!=`function`,Ee=!Te&&typeof f!=`function`,De=(0,b.useMemo)(()=>s?null:[...n].reverse().find(e=>e.role===`assistant`?i?e.ticket_id===i:!0:!1)?.id??null,[s,n,i]),Oe=e=>{fB(()=>{de(e)})};return(0,b.useEffect)(()=>{Oe(null)},[w]),(0,b.useEffect)(()=>{s&&Oe(null)},[s]),(0,b.useEffect)(()=>{!s||!pe||!a||!ge||Oe(e=>e&&e.latestMessageIdAtCapture===fe&&e.internalLog===r&&e.showThinking===he&&e.streamingResponse===o&&e.ticketTitle===a?e:{latestMessageIdAtCapture:fe,internalLog:r,showThinking:he,streamingResponse:o,ticketTitle:a})},[he,ge,r,pe,s,fe,a,o]),(0,b.useEffect)(()=>{Oe(e=>e&&(fe!==e.latestMessageIdAtCapture&&n[n.length-1]?.role===`assistant`?null:e))},[fe,n]),(0,b.useEffect)(()=>{try{if(oe){window.localStorage.setItem(rB,`true`);return}window.localStorage.removeItem(rB)}catch{}},[oe]),(0,b.useEffect)(()=>()=>{ae.current!==null&&window.clearTimeout(ae.current)},[]),(0,b.useEffect)(()=>{ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null),!(!x||S<=0||ce===x)&&(ae.current=window.setTimeout(()=>{ae.current=null,le(x)},S))},[S,x,ce]),(0,b.useEffect)(()=>{let e=I.current;if(!e)return;let t=null,n=L.current===null,i=L.current!==fe,a=!R.current&&s,c=z.current!==o,u=ee.current!==r,d=B.current!==T,f=V.current!==he,p=gB(e),m=l===`always`||n||ne.current,h=m||p;return d&&(ne.current=h),m&&(n||i||a||c||f||he&&u)&&pB(e),d&&h&&(pB(e),t=window.requestAnimationFrame(()=>{pB(e)})),L.current=fe,R.current=s,z.current=o,ee.current=r,B.current=T,V.current=he,()=>{t!==null&&window.cancelAnimationFrame(t)}},[he,r,s,T,fe,o,l]),(0,b.useEffect)(()=>{let e=I.current,t=!ie.current&&j;e&&t&&(ne.current=!0,pB(e)),ie.current=j},[j]),(0,b.useEffect)(()=>{let e=I.current;if(!e){U.current=y;return}let t=!U.current&&y,n=U.current&&!y;t&&(W.current=ne.current||gB(e)),n&&(ne.current=gB(e),W.current=!1),U.current=y},[y]),(0,b.useEffect)(()=>{let e=I.current;if(!e||typeof ResizeObserver!=`function`)return;let t=new ResizeObserver(()=>{(ne.current||W.current||re.current)&&pB(e)});return t.observe(e),()=>{t.disconnect()}},[]),(0,b.useEffect)(()=>{let e=I.current;!e||!pe||!s||(l===`always`||ne.current)&&pB(e)},[l,pe,s]),(0,b.useEffect)(()=>{let e=te.current!==C;if(te.current=C,!k&&!e||!d||j)return;let t=G.current;if(!t)return;let n=requestAnimationFrame(()=>{t.focus()});return()=>{cancelAnimationFrame(n)}},[k,d,C,j,w]),(0,b.useEffect)(()=>{let e=G.current;if(!e||!d){H.current=E;return}let t=I.current,n=H.current!==E;H.current=E;let r=!!(n&&t&&(ne.current||gB(t)));if(re.current=r,hB(e),!t||!r){re.current=!1;return}let i=requestAnimationFrame(()=>{ne.current=!0,pB(t),re.current=!1});return()=>{cancelAnimationFrame(i),re.current=!1}},[d,E,w]),(0,q.jsx)(`section`,{"aria-label":`Ticket conversation`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,q.jsxs)(zv,{size:`sm`,className:J(`min-h-0 flex-1 gap-0 overflow-hidden border-border/80 bg-card/70 shadow-none`,_e&&`rounded-none`),children:[we&&(0,q.jsxs)(`div`,{className:J(`flex items-start justify-between gap-3 border-b border-border/80 px-4`,_e?`pt-3 pb-1`:`py-3`),children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:we}),Te&&Se]}),Ee&&(0,q.jsx)(`div`,{className:`flex justify-end px-4 pt-3`,children:Se}),(0,q.jsx)(Wv,{"aria-label":`Ticket conversation content`,ref:I,onScroll:e=>{y&&W.current||re.current||(ne.current=gB(e.currentTarget))},className:J(`min-h-0 flex-1 overflow-y-auto px-4`,_e?`border-b border-border/80 pt-0 !pb-2.5 data-[size=sm]:!pb-2.5`:`border-b border-border/80 py-4`),children:(0,q.jsx)(`div`,{className:`flex min-h-0 flex-col`,children:(0,q.jsx)(OB,{messages:n,latestAssistantMessageId:De,effectiveShowThinking:he,internalLog:r,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isPendingAgentVisible:pe,interruptedPendingSnapshot:ue,isLoading:c,emptyStateText:O,renderMessageFooter:A})})}),d&&(0,q.jsx)(Gv,{className:J(`mt-auto`,_e?`pt-1`:v&&`border-t border-border/80 bg-card/95 pt-4 backdrop-blur supports-[backdrop-filter]:bg-card/80`),children:(0,q.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[p?(0,q.jsx)(`div`,{children:p}):null,(0,q.jsxs)(`div`,{"data-testid":`conversation-composer-shell`,className:J(`relative overflow-visible rounded-[1.35rem] border border-border/80 bg-card/65 transition-[border-color,box-shadow,background-color] shadow-[0_10px_30px_rgba(0,0,0,0.16)]`,`focus-within:border-ring/60 focus-within:bg-card/85 focus-within:ring-2 focus-within:ring-ring/15`,ve),children:[(0,q.jsxs)(`div`,{className:J(`relative`,ye,be),children:[(0,q.jsx)(Bz,{ref:G,projectId:e,suggestionTicketId:t,value:E,onValueChange:N,onKeyDown:P,suggestionPlacement:`above`,wrapperClassName:`pr-12`,placeholder:D,disabled:j,"aria-label":`Follow-up prompt`,className:J(ye,`border-0 bg-transparent px-0 py-0 text-[15px] leading-6 shadow-none focus-visible:border-transparent focus-visible:ring-0`)}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`secondary`,"aria-label":j?`Sending prompt`:`Send prompt`,disabled:!E.trim()||j||s,title:M,className:J(xe,Ce&&`top-[calc(50%+0.5rem)]`),onClick:F,children:j?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(Uz,{className:`h-4 w-4`})})]}),m?(0,q.jsx)(`div`,{className:`px-3 pb-2.5`,children:m}):null]})]})})]})})},AB=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,streamingResponse:i,isRunning:a,canShowComposer:o,header:s,followUpComposerControls:c,composerTheme:l=`default`,followUpPlaceholder:u=`Follow up on this ticket`,emptyStateText:d,autoFocusComposer:f=!1,pendingAgentTitle:p=null,followUpPrompt:m,isSendingFollowUp:h,followUpDisabledReason:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y})=>(0,q.jsx)(kB,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,pendingAgentTitle:p,streamingResponse:i,isRunning:a,autoScrollBehavior:`sticky`,canShowComposer:o,header:s,composerInlineControls:c,composerTheme:l,followUpPrompt:m,followUpPlaceholder:u,emptyStateText:d,autoFocusComposer:f,isSendingFollowUp:h,followUpDisabledReason:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y}),jB=({title:e,items:t,resolveTicket:n,resolveOtherTicketId:r,onDeleteDependency:i})=>t.length===0?null:(0,q.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(e=>(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 truncate text-sm text-foreground`,children:n(r(e))?.title??`Unknown ticket`}),i&&(0,q.jsx)(Y,{type:`button`,onClick:()=>{i(e)},variant:`destructive`,size:`xs`,children:`Remove`})]},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`))})]}),MB=({items:e,resolveTicket:t,onDeleteDependency:n})=>{if(e.length===0)return null;let r=e.map(e=>{let n=t(e.blocker_ticket_id);return{dependency:e,ready:Lj(n),title:n?.title??`Unknown ticket`}}),i=r.filter(e=>!e.ready),a=i.length===0?`All blockers have finished build.`:`${i.length} blocker${i.length===1?` is`:`s are`} still waiting on build.`;return(0,q.jsxs)(`section`,{"aria-label":`Build readiness`,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Build readiness`}),(0,q.jsx)(Z,{variant:i.length===0?`success`:`warning`,children:i.length===0?`Ready`:`Blocked`})]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.title}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Z,{variant:e.ready?`success`:`warning`,children:e.ready?`Build done`:`Waiting on build`}),n&&(0,q.jsx)(Y,{type:`button`,onClick:()=>{n(e.dependency)},variant:`destructive`,size:`xs`,children:`Remove`})]})]},`${e.dependency.blocker_ticket_id}:${e.dependency.dependent_ticket_id}`))})]})},NB=({blocks:e,blockedBy:t,resolveTicket:n,onDeleteDependency:r})=>{let[i,a]=(0,b.useState)(!1);return e.length===0&&t.length===0?null:(0,q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>{a(e=>!e)},className:`flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/60`,children:[(0,q.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Dependency details`}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i?`Hide`:`Show`})]}),i&&(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border px-4 py-3 lg:grid-cols-2`,children:[(0,q.jsx)(jB,{title:`Blocks`,items:e,resolveTicket:n,resolveOtherTicketId:e=>e.dependent_ticket_id,onDeleteDependency:r}),(0,q.jsx)(MB,{items:t,resolveTicket:n,onDeleteDependency:r})]})]})},PB=({initialTitle:e=``,initialDescription:t=``,initialModel:n=``,initialVariant:r=``,initialSkills:i=[],initialWorktreeBundleId:a=null,validWorktreeBundleIds:o,availableModels:s=[],availableSkills:c=[],showModelSelector:l=!1,showSkillsSelector:u=!1,disableEscapeClose:d=!1,onDirtyChange:f,onAgentSettingsChange:p,onSubmit:m,onCancel:h,children:g})=>{let[_,v]=(0,b.useState)(e),[y,x]=(0,b.useState)(t),[S,C]=(0,b.useState)(n),[w,T]=(0,b.useState)(r),[E,D]=(0,b.useState)(i),[O,k]=(0,b.useState)({worktree_bundle_id:a});Pv(h,{disabled:d});let A=O.worktree_bundle_id!==null&&o&&!o.includes(O.worktree_bundle_id)?null:O.worktree_bundle_id,j=_.trim()&&y.trim(),M=_!==e||y!==t||S!==n||w!==r||E.length!==i.length||E.some((e,t)=>e!==i[t])||A!==a;(0,b.useEffect)(()=>{f?.(M)},[M,f]),(0,b.useEffect)(()=>{p?.({model:S.trim()||null,variant:w.trim()||null,skills:E})},[S,p,E,w]);let N=(0,b.useCallback)(()=>{j&&m?.({title:_.trim(),description:y.trim(),model:S.trim()||null,variant:w.trim()||null,skills:E,worktree_bundle_id:A})},[y,j,S,m,A,E,_,w]),P={title:_,description:y,model:S,variant:w,skills:E,extra:{worktree_bundle_id:A},availableModels:s,availableSkills:c,showModelSelector:l,showSkillsSelector:u,setTitle:v,setDescription:x,setModel:C,setVariant:T,setSkills:D,setExtra:k,isValid:!!j,onSubmit:N,onCancel:h};return g?(0,q.jsx)(q.Fragment,{children:g(P)}):null},FB=2,IB=e=>e.length===0?`No skills`:e.length<=FB?e.join(`, `):`${e.slice(0,FB).join(`, `)} +${e.length-FB}`,LB=({skills:e,availableSkills:t,onSkillsChange:n,selectId:r,label:i=`Skills`,triggerAriaLabel:a,disabled:o=!1,className:s,triggerClassName:c,showSelectedBadges:l=!0})=>{let u=e.map(e=>t.find(t=>t.name===e)?.name??e).filter(Boolean),d=u.slice(0,FB),f=Math.max(0,u.length-d.length);return(0,q.jsxs)(`div`,{className:J(`flex flex-col gap-2`,s),children:[(0,q.jsx)(dy,{label:i,triggerLabel:IB(u),triggerAriaLabel:a??`Skills`,selectId:r,selectedValues:e,onToggle:t=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},disabled:o,contentClassName:`min-w-[22rem]`,triggerClassName:c,groups:[{label:``,options:t.map(e=>({value:e.name,label:e.name}))}]}),l&&u.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[d.map(e=>(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e},e)),f>0&&(0,q.jsxs)(Z,{variant:`ghost`,className:`px-1.5 text-[11px] text-muted-foreground`,children:[`+`,f,` more`]})]})]})},RB=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h,layout:g=`wrap`})=>{let _=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,q.jsx)(`section`,{className:J(`rounded-2xl border border-border/70 bg-secondary/20 p-3`,h),"aria-label":`AI settings`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`}),(0,q.jsx)(hM,{model:e,variant:t,skills:n})]}),(0,q.jsxs)(`div`,{className:J(`gap-3`,g===`stacked`?`flex flex-col`:`flex flex-wrap`),children:[(0,q.jsx)(r_,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[10rem] flex-[1.35_1_10rem]`}),_&&(0,q.jsx)(i_,{variant:t,selectedModel:s,showVariantSelector:_,onVariantChange:l,selectId:f,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[7rem] flex-[0.7_1_7rem]`}),i&&(0,q.jsx)(LB,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[8rem] flex-[0.95_1_8rem]`,showSelectedBadges:!1})]})]})})},zB=({model:e,variant:t,skills:n,selectedModel:r})=>{let i=[];return e&&i.push(r?.label??e),t&&i.push(t),n.length>0&&i.push(`${n.length} skill${n.length===1?``:`s`}`),i.length===0?`AI defaults`:i.join(` / `)},BB=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0,_=zB({model:e,variant:t,skills:n,selectedModel:s});return!r&&!i?null:(0,q.jsxs)(Hg,{children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`outline`,disabled:m,className:J(`max-w-full w-fit justify-start gap-2 text-left sm:max-w-80`,h),"aria-label":`AI settings`,children:[(0,q.jsx)(cy,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate`,children:_})]})}),(0,q.jsx)(Wg,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)] p-3`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(r_,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m}),(0,q.jsx)(i_,{variant:t,selectedModel:s,showVariantSelector:g,onVariantChange:l,selectId:f,disabled:m}),i&&(0,q.jsx)(LB,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,showSelectedBadges:!1})]})]})})]})},VB=({jiraImportState:e,onImportFromJira:t,onImported:n,inputId:r,className:i})=>{let[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1);if(e!==`enabled`)return null;let l=!!t,u=async()=>{if(!(!t||!a.trim())){c(!0);try{n(await t(a.trim())),o(``)}catch(e){X.error(e instanceof Error?e.message:`Unable to load the Jira issue right now.`,{id:`jira-import-error`})}finally{c(!1)}}};return(0,q.jsx)(Kv,{label:`Import from Jira`,htmlFor:r,className:i,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(Dg,{id:r,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!l||(e.preventDefault(),u())},placeholder:`PROJ-123 or issue URL`,disabled:!l||s})}),(0,q.jsxs)(Y,{type:`button`,variant:`outline`,disabled:!l||!a.trim()||s,onClick:()=>{u()},className:`sm:min-w-[7.5rem]`,children:[(0,q.jsx)(Gy,{className:`h-4 w-4`}),s?`Importing...`:`Import`]})]})})},HB=({bundles:e,value:t,onChange:n,label:r=`Bundle`,selectId:i=`bundle-selector`,emptyLabel:a=`No bundle`,showEmptyOption:o=!0,disabled:s=!1,hideProjectRootBundles:c=!1,projectRootWarning:l=null,projectRootUnavailableReason:u=null,className:d,contentClassName:f,triggerClassName:p})=>{let m=[...c?e.filter(e=>e.kind!==`project_root`):e].sort((e,t)=>e.kind===`project_root`&&t.kind!==`project_root`?-1:+(e.kind!==`project_root`&&t.kind===`project_root`)),h=m.find(e=>e.id===t),g=h?gv(h):a,_=h?.kind===`project_root`;return(0,q.jsxs)(`div`,{className:J(`space-y-2`,d),children:[_&&l&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs font-medium text-amber-100`,children:l}),(0,q.jsx)(n_,{label:r,triggerLabel:g,selectId:i,selectedValue:t,onChange:n,disabled:s,contentClassName:f,triggerClassName:p,groups:[{label:``,options:[...o?[{value:``,label:a}]:[],...m.map(e=>({value:e.id,label:gv(e),disabled:e.kind===`project_root`&&!!u}))]}]}),u&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:u})]})},UB=e=>{let t=e.trim();return t?t.replace(/[^a-zA-Z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).slice(0,60)||`bundle`:null},WB={subtle:`outline`,brand:`default`},GB=({heading:e,bundles:t,stackConfigurationSections:n=!1,showModelSelector:r=!1,agentSettingsPresentation:i=`panel`,preferWideBundleSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialTitle:c=``,initialDescription:l=``,initialModel:u=``,initialVariant:d=``,initialSkills:f=[],initialWorktreeBundleId:p=null,projectId:m=null,jiraImportState:h=`hidden`,onImportFromJira:g,onCancel:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:x,titleInputId:S,descriptionInputId:C,bundleSelectId:w,modelSelectId:T,variantSelectId:E,skillsSelectId:D,showEmptyBundleOption:O=!0,primaryAction:k,secondaryAction:A,tertiaryAction:j,planAction:M,beforeActionsContent:N,footerLeadingContent:P,onPlanActiveChange:F,onDirtyChange:I,onAgentSettingsChange:L})=>{let[R,z]=(0,b.useState)([]),[ee,B]=(0,b.useState)([]),[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(!1),[ne,W]=(0,b.useState)(null),re=(0,b.useRef)(null),ie=O?`Create automatically`:`No bundle`,ae=[...R.filter(e=>!ee.includes(e.id)),...t.filter(e=>!ee.includes(e.id)&&!R.some(t=>t.id===e.id))],G=h!==`hidden`;return(0,q.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsx)(PB,{initialTitle:c,initialDescription:l,initialModel:u,initialVariant:d,initialSkills:f,initialWorktreeBundleId:p,validWorktreeBundleIds:ae.map(e=>e.id),showModelSelector:r,availableModels:o,availableSkills:s,showSkillsSelector:r,onCancel:_,disableEscapeClose:V,onDirtyChange:I,onAgentSettingsChange:L,children:({title:e,description:t,model:r,variant:o,skills:s,extra:c,availableModels:l,availableSkills:u,showModelSelector:d,showSkillsSelector:f,setTitle:p,setDescription:b,setModel:I,setVariant:L,setSkills:R,setExtra:ee,isValid:oe})=>{let se=l.find(e=>e.id===r)??null,ce=c.worktree_bundle_id?null:UB(e),le={title:e.trim(),description:t.trim(),model:r.trim()||null,variant:o.trim()||null,skills:s,worktree_bundle_id:c.worktree_bundle_id,...ne?{external_source:ne}:{}},ue=async()=>{if(!M)return;U(!0);let e=new AbortController;re.current=e,F?.(!0);try{await M.onClick(le),F?.(!1)}catch(t){e.signal.aborted||(F?.(!1),X.error(t instanceof Error?t.message:`Planning failed. Please try again.`,{id:`ticket-planning-error`}))}finally{re.current=null,U(!1)}},de=async e=>{if(!v)throw Error(`Bundle creation is unavailable.`);let t=await v(e);return z(e=>[t,...e.filter(e=>e.id!==t.id)]),B(e=>e.filter(e=>e!==t.id)),ee({worktree_bundle_id:t.id}),H(!1),t},K=async e=>{y&&(await y(e),B(t=>t.includes(e)?t:[...t,e]),z(t=>t.filter(t=>t.id!==e)),c.worktree_bundle_id===e&&ee({worktree_bundle_id:null}))},fe=()=>{oe&&(te&&re.current?.abort(),k.onClick(le))},pe=i===`popover`&&!n,me=a&&i===`popover`,he=n?`flex flex-col gap-3`:pe?`grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_max-content]`:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,0.82fr)_minmax(0,1.18fr)]`,ge=n?`flex items-end gap-3`:pe?`flex flex-col gap-2 sm:grid sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end sm:gap-3`:`flex flex-col gap-2 sm:flex-row sm:items-end`,_e=i===`popover`?(0,q.jsx)(BB,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:se,onModelChange:I,onVariantChange:L,onSkillsChange:R,modelSelectId:T,variantSelectId:E,skillsSelectId:D,className:`h-10 self-end`}):(0,q.jsx)(RB,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:se,onModelChange:I,onVariantChange:L,onSkillsChange:R,modelSelectId:T,variantSelectId:E,skillsSelectId:D,layout:n?`stacked`:`wrap`});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),fe()},className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:G?`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_22rem]`:`grid grid-cols-1 gap-3`,children:[(0,q.jsx)(Kv,{label:`Title`,htmlFor:S,children:(0,q.jsx)(Dg,{id:S,type:`text`,value:e,onChange:e=>p(e.target.value),placeholder:`What needs to be done?`,autoFocus:!0})}),G&&(0,q.jsx)(VB,{jiraImportState:h,onImportFromJira:g,onImported:e=>{p(e.title),b(e.description),W(e.external_source)},inputId:`jira-import-reference`,className:`lg:min-h-[90px]`})]}),(0,q.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2`,children:[(0,q.jsx)(Kv,{label:`Description`,htmlFor:C,className:`gap-0`,children:(0,q.jsx)(q.Fragment,{})}),(0,q.jsx)(Bz,{projectId:m,suggestionAnchor:`caret`,wrapperClassName:`flex flex-1 min-h-0`,id:C,value:t,onValueChange:b,placeholder:`Describe the task, acceptance criteria, context...`,disabled:te,className:te?`flex-1 min-h-0 animate-pulse`:`flex-1 min-h-0`})]}),(0,q.jsxs)(`div`,{className:he,children:[(0,q.jsxs)(`div`,{className:ge,children:[(0,q.jsxs)(`div`,{className:me?`min-w-0 flex-1 sm:min-w-[19rem]`:`min-w-0 flex-1`,children:[(0,q.jsx)(HB,{bundles:ae,value:c.worktree_bundle_id??``,onChange:e=>ee({worktree_bundle_id:e||null}),label:n?``:void 0,selectId:w,emptyLabel:ie,showEmptyOption:O,hideProjectRootBundles:!0,triggerClassName:me?`sm:min-w-[19rem]`:void 0,contentClassName:me?`w-[min(30rem,calc(100vw-2rem))] min-w-[24rem] max-w-[calc(100vw-2rem)]`:void 0}),ce&&(0,q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground absolute max-w-80`,children:[`Bundle preview: `,(0,q.jsx)(`span`,{className:`text-foreground`,children:ce})]})]}),v&&y&&(0,q.jsx)(Y,{type:`button`,onClick:()=>{(async()=>{try{x&&await x()}catch{}H(!0)})()},variant:`outline`,size:n?`sm`:`default`,className:n?`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`:`h-10 whitespace-nowrap border-sky-500/35 bg-sky-500/12 px-4 text-sky-100 hover:border-sky-400 hover:bg-sky-500/20 hover:text-white`,children:`Manage bundles`})]}),_e]})]}),N,(0,q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`flex min-h-8 items-center`,children:P}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,onClick:_,variant:`ghost`,children:`Cancel`}),M&&(te?(0,q.jsx)(Yj,{label:`Planning...`}):(0,q.jsxs)(Y,{type:`button`,disabled:!oe,variant:`outline`,onClick:()=>{oe&&ue()},children:[(0,q.jsx)(cy,{className:`h-4 w-4`}),M.label]})),(0,q.jsxs)(Y,{type:`submit`,disabled:!oe||te,variant:WB[k.variant],children:[k.label,k.showAdvanceIcon&&(0,q.jsx)(fj,{className:`h-3.5 w-3.5`})]}),A&&(0,q.jsxs)(Y,{type:`button`,disabled:!oe||te,onClick:()=>{!oe||te||A.onClick(le)},variant:WB[A.variant],children:[A.label,A.showAdvanceIcon&&(0,q.jsx)(fj,{className:`h-3.5 w-3.5`})]}),j&&(0,q.jsxs)(Y,{type:`button`,disabled:!oe||te,onClick:()=>{!oe||te||j.onClick(le)},variant:WB[j.variant],children:[j.label,j.showAdvanceIcon&&(0,q.jsx)(fj,{className:`h-3.5 w-3.5`})]})]})]})]}),V&&v&&y&&(0,q.jsx)(Xv,{bundles:ae,selectedBundleId:c.worktree_bundle_id,onSelectBundle:e=>ee({worktree_bundle_id:e}),onCreateBundle:de,onDeleteBundle:K,onClose:()=>H(!1)})]})}})]})},KB=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
130
+ `)){if(e===lB){a(),r.push(e),i=!0;continue}if(i){r.push(e),e===uB&&(a(),i=!1);continue}if(!e.trim()){a();continue}r.push(e)}return a(),n},CB=({visibleContent:e,internalLog:t,showThinking:n})=>{let r=SB(e);if(!n||!t||t.trim().length===0)return r.map(e=>({tone:`primary`,content:e}));let i=SB(t);if(i.length===0)return r.map(e=>({tone:`primary`,content:e}));let a=[],o=0;for(let e of i){let t=r[o];if(t&&_B(t)===_B(e)){a.push({tone:`primary`,content:e}),o+=1;continue}a.push({tone:`secondary`,content:e})}for(;o<r.length;)a.push({tone:`primary`,content:r[o]}),o+=1;return a},wB=(0,b.memo)(({visibleContent:e,internalLog:t,showThinking:n})=>{let r=(0,b.useMemo)(()=>CB({visibleContent:e,internalLog:t,showThinking:n}),[t,n,e]);return r.length===0?null:(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>(0,q.jsx)(Gz,{content:e.content,className:e.tone===`secondary`?`text-muted-foreground [&_code]:text-violet-200 [&_pre]:bg-background/70`:void 0},`${e.tone}:${t+1}`))})});wB.displayName=`AssistantMessageContent`;var TB=(0,b.memo)(({message:e,showThinking:t=!1,internalLog:n=null,footer:r=null})=>{let i=e.role===`user`,a=i&&e.kind===`description`,[o,s]=(0,b.useState)(!1),c=i?aB(e.content):null,l=(0,b.useMemo)(()=>!a||!e.content?{text:e.content,truncated:!1}:Qz(e.content),[a,e.content]);return(0,q.jsx)(`div`,{"data-message-role":e.role,className:`flex ${i?`justify-end`:`justify-start`}`,children:(0,q.jsxs)(zv,{className:i?`max-w-[85%] border-sky-500/30 bg-sky-500/10 shadow-none`:`max-w-[85%] border-slate-400/30 bg-slate-400/10 shadow-none`,size:`sm`,children:[(0,q.jsxs)(Wv,{className:`flex flex-col gap-2 px-4 py-4`,children:[e.displayTitle&&(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.displayTitle}),i?c?(0,q.jsx)(qz,{content:e.content,parsed:c}):a?(0,q.jsx)(EM,{description:e.content,descriptionClass:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,isExpanded:o,collapsedState:l,useStaleLikeStyling:!1,onExpand:()=>s(!0),onCollapse:()=>s(!1)}):(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.content}):(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(cy,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(wB,{visibleContent:e.content,internalLog:n,showThinking:t})})]})]}),r?(0,q.jsx)(Gv,{className:`border-t border-border/60 px-4 py-3`,children:r}):null]})})});TB.displayName=`MessageBubble`;var EB=()=>(0,q.jsxs)(`div`,{role:`status`,"aria-label":`Agent activity indicator`,"aria-live":`polite`,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_infinite_backwards] motion-reduce:animate-none`}),(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.3s_infinite_backwards] motion-reduce:animate-none`}),(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.6s_infinite_backwards] motion-reduce:animate-none`})]}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Agent is working`})]}),DB=(0,b.memo)(({ticketTitle:e,streamingResponse:t,internalLog:n,showThinking:r,statusLabel:i=`Working...`,showActivity:a=!0})=>(0,q.jsx)(`div`,{className:`flex justify-start`,children:(0,q.jsx)(zv,{className:`w-full max-w-[85%] border-slate-400/30 bg-slate-400/10 shadow-none`,size:`sm`,children:(0,q.jsxs)(Wv,{className:`flex flex-col gap-3 px-4 py-4`,children:[(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(cy,{className:`h-4 w-4 text-muted-foreground`}),(0,q.jsx)(`span`,{children:i})]}),t||r&&n?(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(cy,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(wB,{visibleContent:t,internalLog:n,showThinking:r})})]}):null,a?(0,q.jsx)(EB,{}):null]})})}));DB.displayName=`PendingAgentMessage`;var OB=(0,b.memo)(({messages:e,latestAssistantMessageId:t,effectiveShowThinking:n,internalLog:r,pendingAgentTitle:i,streamingResponse:a,isRunning:o,isPendingAgentVisible:s,interruptedPendingSnapshot:c,isLoading:l,emptyStateText:u,renderMessageFooter:d})=>{let f=c?e.findIndex(e=>e.id===c.latestMessageIdAtCapture):-1,p=f>=0?e.slice(0,f+1):e,m=f>=0?e.slice(f+1):[],h=e=>(0,q.jsx)(TB,{message:e,footer:d?.(e)??null,showThinking:n&&e.id===t,internalLog:n&&e.id===t?r:null},`${e.ticket_id}:${e.id}`);return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-5`,children:[e.length===0&&!o&&u&&(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground`,children:l?`Loading conversation...`:u}),p.map(h),o&&s&&i&&(0,q.jsx)(DB,{ticketTitle:i,streamingResponse:a,internalLog:r,showThinking:n}),!o&&c?(0,q.jsx)(DB,{ticketTitle:c.ticketTitle,streamingResponse:c.streamingResponse,internalLog:c.internalLog,showThinking:c.showThinking,statusLabel:`Interrupted`,showActivity:!1}):null,m.map(h)]})});OB.displayName=`ConversationTranscript`;var kB=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,thinkingTicketId:i=null,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c=!1,autoScrollBehavior:l=`sticky`,surfaceVariant:u=`default`,canShowComposer:d,header:f,composerControls:p,composerInlineControls:m,composerTheme:h=`default`,composerSize:g=`default`,showThinkingPlacement:_=`body`,pinComposerToBottom:v=!1,isExternallyResizing:y=!1,pendingAgentRevealKey:x=null,pendingAgentRevealDelayMs:S=0,composerFocusNonce:C=0,layoutKey:w,scrollLayoutKey:T,followUpPrompt:E,followUpPlaceholder:D,emptyStateText:O=`No messages yet.`,autoFocusComposer:k=!1,renderMessageFooter:A,isSendingFollowUp:j,followUpDisabledReason:M,onFollowUpPromptChange:N,onFollowUpKeyDown:P,onFollowUpSubmit:F})=>{let I=(0,b.useRef)(null),L=(0,b.useRef)(null),R=(0,b.useRef)(!1),z=(0,b.useRef)(null),ee=(0,b.useRef)(r),B=(0,b.useRef)(T),V=(0,b.useRef)(!1),H=(0,b.useRef)(E),te=(0,b.useRef)(C),U=(0,b.useRef)(y),ne=(0,b.useRef)(!0),W=(0,b.useRef)(!1),re=(0,b.useRef)(!1),ie=(0,b.useRef)(j),ae=(0,b.useRef)(null),G=(0,b.useRef)(null),[oe,se]=(0,b.useState)(pB),[ce,le]=(0,b.useState)(null),[ue,de]=(0,b.useState)(null),K=(0,b.useId)(),fe=n.length>0?n[n.length-1].id:null,pe=!s||!x||ce===x,me=!!(r&&r.trim().length>0),he=oe&&me,ge=!!(o||he&&r),_e=u===`chat`,ve=(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(sy,{id:K,"aria-label":`Show thinking`,checked:oe,onCheckedChange:se}),(0,q.jsx)(Vg,{htmlFor:K,className:`text-sm text-muted-foreground`,children:`Show thinking`})]}),ye=typeof f==`function`?f({showThinkingControl:ve}):f,be=_===`header`&&!!ye&&typeof f!=`function`,xe=!be&&typeof f!=`function`,Se=(0,b.useMemo)(()=>s?null:[...n].reverse().find(e=>e.role===`assistant`?i?e.ticket_id===i:!0:!1)?.id??null,[s,n,i]),Ce=e=>{mB(()=>{de(e)})};return(0,b.useEffect)(()=>{Ce(null)},[w]),(0,b.useEffect)(()=>{s&&Ce(null)},[s]),(0,b.useEffect)(()=>{!s||!pe||!a||!ge||Ce(e=>e&&e.latestMessageIdAtCapture===fe&&e.internalLog===r&&e.showThinking===he&&e.streamingResponse===o&&e.ticketTitle===a?e:{latestMessageIdAtCapture:fe,internalLog:r,showThinking:he,streamingResponse:o,ticketTitle:a})},[he,ge,r,pe,s,fe,a,o]),(0,b.useEffect)(()=>{Ce(e=>e&&(fe!==e.latestMessageIdAtCapture&&n[n.length-1]?.role===`assistant`?null:e))},[fe,n]),(0,b.useEffect)(()=>{try{if(oe){window.localStorage.setItem(sB,`true`);return}window.localStorage.removeItem(sB)}catch{}},[oe]),(0,b.useEffect)(()=>()=>{ae.current!==null&&window.clearTimeout(ae.current)},[]),(0,b.useEffect)(()=>{ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null),!(!x||S<=0||ce===x)&&(ae.current=window.setTimeout(()=>{ae.current=null,le(x)},S))},[S,x,ce]),(0,b.useEffect)(()=>{let e=I.current;if(!e)return;let t=null,n=L.current===null,i=L.current!==fe,a=!R.current&&s,c=z.current!==o,u=ee.current!==r,d=B.current!==T,f=V.current!==he,p=gB(e),m=l===`always`||n||ne.current,h=m||p;return d&&(ne.current=h),m&&(n||i||a||c||f||he&&u)&&hB(e),d&&h&&(hB(e),t=window.requestAnimationFrame(()=>{hB(e)})),L.current=fe,R.current=s,z.current=o,ee.current=r,B.current=T,V.current=he,()=>{t!==null&&window.cancelAnimationFrame(t)}},[he,r,s,T,fe,o,l]),(0,b.useEffect)(()=>{let e=I.current,t=!ie.current&&j;e&&t&&(ne.current=!0,hB(e)),ie.current=j},[j]),(0,b.useEffect)(()=>{let e=I.current;if(!e){U.current=y;return}let t=!U.current&&y,n=U.current&&!y;t&&(W.current=ne.current||gB(e)),n&&(ne.current=gB(e),W.current=!1),U.current=y},[y]),(0,b.useEffect)(()=>{let e=I.current;if(!e||typeof ResizeObserver!=`function`)return;let t=new ResizeObserver(()=>{(ne.current||W.current||re.current)&&hB(e)});return t.observe(e),()=>{t.disconnect()}},[]),(0,b.useEffect)(()=>{let e=I.current;!e||!pe||!s||(l===`always`||ne.current)&&hB(e)},[l,pe,s]),(0,b.useEffect)(()=>{let e=te.current!==C;if(te.current=C,!k&&!e||!d||j)return;let t=G.current;if(!t)return;let n=requestAnimationFrame(()=>{t.focus()});return()=>{cancelAnimationFrame(n)}},[k,d,C,j,w]),(0,b.useEffect)(()=>{let e=G.current;if(!e||!d){H.current=E;return}let t=I.current,n=H.current!==E;H.current=E;let r=!!(n&&t&&(ne.current||gB(t)));if(re.current=r,Cx(e),!t||!r){re.current=!1;return}let i=requestAnimationFrame(()=>{ne.current=!0,hB(t),re.current=!1});return()=>{cancelAnimationFrame(i),re.current=!1}},[d,E,w]),(0,q.jsx)(`section`,{"aria-label":`Ticket conversation`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,q.jsxs)(zv,{size:`sm`,className:J(`min-h-0 flex-1 gap-0 overflow-hidden border-border/80 bg-card/70 shadow-none`,_e&&`rounded-none`),children:[ye&&(0,q.jsxs)(`div`,{className:J(`flex items-start justify-between gap-3 border-b border-border/80 px-4`,_e?`pt-3 pb-1`:`py-3`),children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:ye}),be&&ve]}),xe&&(0,q.jsx)(`div`,{className:`flex justify-end px-4 pt-3`,children:ve}),(0,q.jsx)(Wv,{"aria-label":`Ticket conversation content`,ref:I,onScroll:e=>{y&&W.current||re.current||(ne.current=gB(e.currentTarget))},className:J(`min-h-0 flex-1 overflow-y-auto px-4`,_e?`border-b border-border/80 pt-0 !pb-2.5 data-[size=sm]:!pb-2.5`:`border-b border-border/80 py-4`),children:(0,q.jsx)(`div`,{className:`flex min-h-0 flex-col`,children:(0,q.jsx)(OB,{messages:n,latestAssistantMessageId:Se,effectiveShowThinking:he,internalLog:r,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isPendingAgentVisible:pe,interruptedPendingSnapshot:ue,isLoading:c,emptyStateText:O,renderMessageFooter:A})})}),d&&(0,q.jsx)(Gv,{className:J(`mt-auto`,_e?`pt-1`:v&&`border-t border-border/80 bg-card/95 pt-4 backdrop-blur supports-[backdrop-filter]:bg-card/80`),children:(0,q.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[p?(0,q.jsx)(`div`,{children:p}):null,(0,q.jsx)(ux,{projectId:e,suggestionTicketId:t,value:E,placeholder:D,disabled:j,isSubmitDisabled:s,isSending:j,disabledReason:M,onValueChange:N,onKeyDown:P,onSubmit:F,textareaRef:G,composerInlineControls:m,composerTheme:h,composerSize:g})]})})]})})},AB=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,streamingResponse:i,isRunning:a,canShowComposer:o,header:s,followUpComposerControls:c,composerTheme:l=`default`,followUpPlaceholder:u=`Follow up on this ticket`,emptyStateText:d,autoFocusComposer:f=!1,pendingAgentTitle:p=null,followUpPrompt:m,isSendingFollowUp:h,followUpDisabledReason:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y})=>(0,q.jsx)(kB,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,pendingAgentTitle:p,streamingResponse:i,isRunning:a,autoScrollBehavior:`sticky`,canShowComposer:o,header:s,composerInlineControls:c,composerTheme:l,followUpPrompt:m,followUpPlaceholder:u,emptyStateText:d,autoFocusComposer:f,isSendingFollowUp:h,followUpDisabledReason:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y}),jB=({title:e,items:t,resolveTicket:n,resolveOtherTicketId:r,onDeleteDependency:i})=>t.length===0?null:(0,q.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(e=>(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 truncate text-sm text-foreground`,children:n(r(e))?.title??`Unknown ticket`}),i&&(0,q.jsx)(Y,{type:`button`,onClick:()=>{i(e)},variant:`destructive`,size:`xs`,children:`Remove`})]},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`))})]}),MB=({items:e,resolveTicket:t,onDeleteDependency:n})=>{if(e.length===0)return null;let r=e.map(e=>{let n=t(e.blocker_ticket_id);return{dependency:e,ready:$j(n),title:n?.title??`Unknown ticket`}}),i=r.filter(e=>!e.ready),a=i.length===0?`All blockers have finished build.`:`${i.length} blocker${i.length===1?` is`:`s are`} still waiting on build.`;return(0,q.jsxs)(`section`,{"aria-label":`Build readiness`,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Build readiness`}),(0,q.jsx)(Z,{variant:i.length===0?`success`:`warning`,children:i.length===0?`Ready`:`Blocked`})]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.title}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Z,{variant:e.ready?`success`:`warning`,children:e.ready?`Build done`:`Waiting on build`}),n&&(0,q.jsx)(Y,{type:`button`,onClick:()=>{n(e.dependency)},variant:`destructive`,size:`xs`,children:`Remove`})]})]},`${e.dependency.blocker_ticket_id}:${e.dependency.dependent_ticket_id}`))})]})},NB=({blocks:e,blockedBy:t,resolveTicket:n,onDeleteDependency:r})=>{let[i,a]=(0,b.useState)(!1);return e.length===0&&t.length===0?null:(0,q.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>{a(e=>!e)},className:`flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/60`,children:[(0,q.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Dependency details`}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i?`Hide`:`Show`})]}),i&&(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border px-4 py-3 lg:grid-cols-2`,children:[(0,q.jsx)(jB,{title:`Blocks`,items:e,resolveTicket:n,resolveOtherTicketId:e=>e.dependent_ticket_id,onDeleteDependency:r}),(0,q.jsx)(MB,{items:t,resolveTicket:n,onDeleteDependency:r})]})]})},PB=({initialTitle:e=``,initialDescription:t=``,initialModel:n=``,initialVariant:r=``,initialSkills:i=[],initialWorktreeBundleId:a=null,validWorktreeBundleIds:o,availableModels:s=[],availableSkills:c=[],showModelSelector:l=!1,showSkillsSelector:u=!1,disableEscapeClose:d=!1,onDirtyChange:f,onAgentSettingsChange:p,onSubmit:m,onCancel:h,children:g})=>{let[_,v]=(0,b.useState)(e),[y,x]=(0,b.useState)(t),[S,C]=(0,b.useState)(n),[w,T]=(0,b.useState)(r),[E,D]=(0,b.useState)(i),[O,k]=(0,b.useState)({worktree_bundle_id:a});Pv(h,{disabled:d});let A=O.worktree_bundle_id!==null&&o&&!o.includes(O.worktree_bundle_id)?null:O.worktree_bundle_id,j=_.trim()&&y.trim(),M=_!==e||y!==t||S!==n||w!==r||E.length!==i.length||E.some((e,t)=>e!==i[t])||A!==a;(0,b.useEffect)(()=>{f?.(M)},[M,f]),(0,b.useEffect)(()=>{p?.({model:S.trim()||null,variant:w.trim()||null,skills:E})},[S,p,E,w]);let N=(0,b.useCallback)(()=>{j&&m?.({title:_.trim(),description:y.trim(),model:S.trim()||null,variant:w.trim()||null,skills:E,worktree_bundle_id:A})},[y,j,S,m,A,E,_,w]),P={title:_,description:y,model:S,variant:w,skills:E,extra:{worktree_bundle_id:A},availableModels:s,availableSkills:c,showModelSelector:l,showSkillsSelector:u,setTitle:v,setDescription:x,setModel:C,setVariant:T,setSkills:D,setExtra:k,isValid:!!j,onSubmit:N,onCancel:h};return g?(0,q.jsx)(q.Fragment,{children:g(P)}):null},FB=2,IB=e=>e.length===0?`No skills`:e.length<=FB?e.join(`, `):`${e.slice(0,FB).join(`, `)} +${e.length-FB}`,LB=({skills:e,availableSkills:t,onSkillsChange:n,selectId:r,label:i=`Skills`,triggerAriaLabel:a,disabled:o=!1,className:s,triggerClassName:c,showSelectedBadges:l=!0})=>{let u=e.map(e=>t.find(t=>t.name===e)?.name??e).filter(Boolean),d=u.slice(0,FB),f=Math.max(0,u.length-d.length);return(0,q.jsxs)(`div`,{className:J(`flex flex-col gap-2`,s),children:[(0,q.jsx)(dy,{label:i,triggerLabel:IB(u),triggerAriaLabel:a??`Skills`,selectId:r,selectedValues:e,onToggle:t=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},disabled:o,contentClassName:`min-w-[22rem]`,triggerClassName:c,groups:[{label:``,options:t.map(e=>({value:e.name,label:e.name}))}]}),l&&u.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[d.map(e=>(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e},e)),f>0&&(0,q.jsxs)(Z,{variant:`ghost`,className:`px-1.5 text-[11px] text-muted-foreground`,children:[`+`,f,` more`]})]})]})},RB=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h,layout:g=`wrap`})=>{let _=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,q.jsx)(`section`,{className:J(`rounded-2xl border border-border/70 bg-secondary/20 p-3`,h),"aria-label":`AI settings`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`}),(0,q.jsx)(jM,{model:e,variant:t,skills:n})]}),(0,q.jsxs)(`div`,{className:J(`gap-3`,g===`stacked`?`flex flex-col`:`flex flex-wrap`),children:[(0,q.jsx)(r_,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[10rem] flex-[1.35_1_10rem]`}),_&&(0,q.jsx)(i_,{variant:t,selectedModel:s,showVariantSelector:_,onVariantChange:l,selectId:f,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[7rem] flex-[0.7_1_7rem]`}),i&&(0,q.jsx)(LB,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[8rem] flex-[0.95_1_8rem]`,showSelectedBadges:!1})]})]})})},zB=({model:e,variant:t,skills:n,selectedModel:r})=>{let i=[];return e&&i.push(r?.label??e),t&&i.push(t),n.length>0&&i.push(`${n.length} skill${n.length===1?``:`s`}`),i.length===0?`AI defaults`:i.join(` / `)},BB=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0,_=zB({model:e,variant:t,skills:n,selectedModel:s});return!r&&!i?null:(0,q.jsxs)(Hg,{children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`outline`,disabled:m,className:J(`max-w-full w-fit justify-start gap-2 text-left sm:max-w-80`,h),"aria-label":`AI settings`,children:[(0,q.jsx)(cy,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate`,children:_})]})}),(0,q.jsx)(Wg,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)] p-3`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(r_,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m}),(0,q.jsx)(i_,{variant:t,selectedModel:s,showVariantSelector:g,onVariantChange:l,selectId:f,disabled:m}),i&&(0,q.jsx)(LB,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,showSelectedBadges:!1})]})]})})]})},VB=({jiraImportState:e,onImportFromJira:t,onImported:n,inputId:r,className:i})=>{let[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1);if(e!==`enabled`)return null;let l=!!t,u=async()=>{if(!(!t||!a.trim())){c(!0);try{n(await t(a.trim())),o(``)}catch(e){X.error(e instanceof Error?e.message:`Unable to load the Jira issue right now.`,{id:`jira-import-error`})}finally{c(!1)}}};return(0,q.jsx)(Kv,{label:`Import from Jira`,htmlFor:r,className:i,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(Dg,{id:r,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!l||(e.preventDefault(),u())},placeholder:`PROJ-123 or issue URL`,disabled:!l||s})}),(0,q.jsxs)(Y,{type:`button`,variant:`outline`,disabled:!l||!a.trim()||s,onClick:()=>{u()},className:`sm:min-w-[7.5rem]`,children:[(0,q.jsx)(Gy,{className:`h-4 w-4`}),s?`Importing...`:`Import`]})]})})},HB=({bundles:e,value:t,onChange:n,label:r=`Bundle`,selectId:i=`bundle-selector`,emptyLabel:a=`No bundle`,showEmptyOption:o=!0,disabled:s=!1,hideProjectRootBundles:c=!1,projectRootWarning:l=null,projectRootUnavailableReason:u=null,className:d,contentClassName:f,triggerClassName:p})=>{let m=[...c?e.filter(e=>e.kind!==`project_root`):e].sort((e,t)=>e.kind===`project_root`&&t.kind!==`project_root`?-1:+(e.kind!==`project_root`&&t.kind===`project_root`)),h=m.find(e=>e.id===t),g=h?gv(h):a,_=h?.kind===`project_root`;return(0,q.jsxs)(`div`,{className:J(`space-y-2`,d),children:[_&&l&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs font-medium text-amber-100`,children:l}),(0,q.jsx)(n_,{label:r,triggerLabel:g,selectId:i,selectedValue:t,onChange:n,disabled:s,contentClassName:f,triggerClassName:p,groups:[{label:``,options:[...o?[{value:``,label:a}]:[],...m.map(e=>({value:e.id,label:gv(e),disabled:e.kind===`project_root`&&!!u}))]}]}),u&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:u})]})},UB=e=>{let t=e.trim();return t?t.replace(/[^a-zA-Z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).slice(0,60)||`bundle`:null},WB={subtle:`outline`,brand:`default`},GB=({heading:e,bundles:t,stackConfigurationSections:n=!1,showModelSelector:r=!1,agentSettingsPresentation:i=`panel`,preferWideBundleSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialTitle:c=``,initialDescription:l=``,initialModel:u=``,initialVariant:d=``,initialSkills:f=[],initialWorktreeBundleId:p=null,projectId:m=null,jiraImportState:h=`hidden`,onImportFromJira:g,onCancel:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:x,titleInputId:S,descriptionInputId:C,bundleSelectId:w,modelSelectId:T,variantSelectId:E,skillsSelectId:D,showEmptyBundleOption:O=!0,primaryAction:k,secondaryAction:A,tertiaryAction:j,planAction:M,beforeActionsContent:N,footerLeadingContent:P,onPlanActiveChange:F,onDirtyChange:I,onAgentSettingsChange:L})=>{let[R,z]=(0,b.useState)([]),[ee,B]=(0,b.useState)([]),[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(!1),[ne,W]=(0,b.useState)(null),re=(0,b.useRef)(null),ie=O?`Create automatically`:`No bundle`,ae=[...R.filter(e=>!ee.includes(e.id)),...t.filter(e=>!ee.includes(e.id)&&!R.some(t=>t.id===e.id))],G=h!==`hidden`;return(0,q.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,q.jsx)(PB,{initialTitle:c,initialDescription:l,initialModel:u,initialVariant:d,initialSkills:f,initialWorktreeBundleId:p,validWorktreeBundleIds:ae.map(e=>e.id),showModelSelector:r,availableModels:o,availableSkills:s,showSkillsSelector:r,onCancel:_,disableEscapeClose:V,onDirtyChange:I,onAgentSettingsChange:L,children:({title:e,description:t,model:r,variant:o,skills:s,extra:c,availableModels:l,availableSkills:u,showModelSelector:d,showSkillsSelector:f,setTitle:p,setDescription:b,setModel:I,setVariant:L,setSkills:R,setExtra:ee,isValid:oe})=>{let se=l.find(e=>e.id===r)??null,ce=c.worktree_bundle_id?null:UB(e),le={title:e.trim(),description:t.trim(),model:r.trim()||null,variant:o.trim()||null,skills:s,worktree_bundle_id:c.worktree_bundle_id,...ne?{external_source:ne}:{}},ue=async()=>{if(!M)return;U(!0);let e=new AbortController;re.current=e,F?.(!0);try{await M.onClick(le),F?.(!1)}catch(t){e.signal.aborted||(F?.(!1),X.error(t instanceof Error?t.message:`Planning failed. Please try again.`,{id:`ticket-planning-error`}))}finally{re.current=null,U(!1)}},de=async e=>{if(!v)throw Error(`Bundle creation is unavailable.`);let t=await v(e);return z(e=>[t,...e.filter(e=>e.id!==t.id)]),B(e=>e.filter(e=>e!==t.id)),ee({worktree_bundle_id:t.id}),H(!1),t},K=async e=>{y&&(await y(e),B(t=>t.includes(e)?t:[...t,e]),z(t=>t.filter(t=>t.id!==e)),c.worktree_bundle_id===e&&ee({worktree_bundle_id:null}))},fe=()=>{oe&&(te&&re.current?.abort(),k.onClick(le))},pe=i===`popover`&&!n,me=a&&i===`popover`,he=n?`flex flex-col gap-3`:pe?`grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_max-content]`:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,0.82fr)_minmax(0,1.18fr)]`,ge=n?`flex items-end gap-3`:pe?`flex flex-col gap-2 sm:grid sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end sm:gap-3`:`flex flex-col gap-2 sm:flex-row sm:items-end`,_e=i===`popover`?(0,q.jsx)(BB,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:se,onModelChange:I,onVariantChange:L,onSkillsChange:R,modelSelectId:T,variantSelectId:E,skillsSelectId:D,className:`h-10 self-end`}):(0,q.jsx)(RB,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:se,onModelChange:I,onVariantChange:L,onSkillsChange:R,modelSelectId:T,variantSelectId:E,skillsSelectId:D,layout:n?`stacked`:`wrap`});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),fe()},className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:G?`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_22rem]`:`grid grid-cols-1 gap-3`,children:[(0,q.jsx)(Kv,{label:`Title`,htmlFor:S,children:(0,q.jsx)(Dg,{id:S,type:`text`,value:e,onChange:e=>p(e.target.value),placeholder:`What needs to be done?`,autoFocus:!0})}),G&&(0,q.jsx)(VB,{jiraImportState:h,onImportFromJira:g,onImported:e=>{p(e.title),b(e.description),W(e.external_source)},inputId:`jira-import-reference`,className:`lg:min-h-[90px]`})]}),(0,q.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2`,children:[(0,q.jsx)(Kv,{label:`Description`,htmlFor:C,className:`gap-0`,children:(0,q.jsx)(q.Fragment,{})}),(0,q.jsx)(cx,{projectId:m,suggestionAnchor:`caret`,wrapperClassName:`flex flex-1 min-h-0`,id:C,value:t,onValueChange:b,placeholder:`Describe the task, acceptance criteria, context...`,disabled:te,className:te?`flex-1 min-h-0 animate-pulse`:`flex-1 min-h-0`})]}),(0,q.jsxs)(`div`,{className:he,children:[(0,q.jsxs)(`div`,{className:ge,children:[(0,q.jsxs)(`div`,{className:me?`min-w-0 flex-1 sm:min-w-[19rem]`:`min-w-0 flex-1`,children:[(0,q.jsx)(HB,{bundles:ae,value:c.worktree_bundle_id??``,onChange:e=>ee({worktree_bundle_id:e||null}),label:n?``:void 0,selectId:w,emptyLabel:ie,showEmptyOption:O,hideProjectRootBundles:!0,triggerClassName:me?`sm:min-w-[19rem]`:void 0,contentClassName:me?`w-[min(30rem,calc(100vw-2rem))] min-w-[24rem] max-w-[calc(100vw-2rem)]`:void 0}),ce&&(0,q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground absolute max-w-80`,children:[`Bundle preview: `,(0,q.jsx)(`span`,{className:`text-foreground`,children:ce})]})]}),v&&y&&(0,q.jsx)(Y,{type:`button`,onClick:()=>{(async()=>{try{x&&await x()}catch{}H(!0)})()},variant:`outline`,size:n?`sm`:`default`,className:n?`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`:`h-10 whitespace-nowrap border-sky-500/35 bg-sky-500/12 px-4 text-sky-100 hover:border-sky-400 hover:bg-sky-500/20 hover:text-white`,children:`Manage bundles`})]}),_e]})]}),N,(0,q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`flex min-h-8 items-center`,children:P}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,onClick:_,variant:`ghost`,children:`Cancel`}),M&&(te?(0,q.jsx)(dM,{label:`Planning...`}):(0,q.jsxs)(Y,{type:`button`,disabled:!oe,variant:`outline`,onClick:()=>{oe&&ue()},children:[(0,q.jsx)(cy,{className:`h-4 w-4`}),M.label]})),(0,q.jsxs)(Y,{type:`submit`,disabled:!oe||te,variant:WB[k.variant],children:[k.label,k.showAdvanceIcon&&(0,q.jsx)(Oj,{className:`h-3.5 w-3.5`})]}),A&&(0,q.jsxs)(Y,{type:`button`,disabled:!oe||te,onClick:()=>{!oe||te||A.onClick(le)},variant:WB[A.variant],children:[A.label,A.showAdvanceIcon&&(0,q.jsx)(Oj,{className:`h-3.5 w-3.5`})]}),j&&(0,q.jsxs)(Y,{type:`button`,disabled:!oe||te,onClick:()=>{!oe||te||j.onClick(le)},variant:WB[j.variant],children:[j.label,j.showAdvanceIcon&&(0,q.jsx)(Oj,{className:`h-3.5 w-3.5`})]})]})]})]}),V&&v&&y&&(0,q.jsx)(Xv,{bundles:ae,selectedBundleId:c.worktree_bundle_id,onSelectBundle:e=>ee({worktree_bundle_id:e}),onCreateBundle:de,onDeleteBundle:K,onClose:()=>H(!1)})]})}})]})},KB=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
131
131
  `),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
132
132
  `),stages:``,priority:`normal`},qB=e=>e.split(`
133
- `).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),JB=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},YB=e=>(e?.decisions.length??0)>0?`decisions`:(e?.conventions.length??0)>0?`conventions`:`generated-context`,XB=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=a?`Save as new decision`:`Accept`,s=e.kind===`decision`?e.decision:e.instruction;return(0,q.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,q.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,q.jsxs)(Z,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:[`Suggested `,e.kind]}),a&&(0,q.jsx)(Z,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:`Possible duplicate`})]}),(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:`Dismiss`})]})]})})},ZB=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?`Save as new decision`:`Accept as ${e.kind}`;return(0,q.jsx)(vg,{open:t,onOpenChange:a,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:e.title}),(0,q.jsx)(Eg,{children:`Review this suggestion before saving it into project memory.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,q.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,q.jsxs)(`p`,{children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}),n?(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Suggestion title`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion title`,value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Content`}),(0,q.jsx)(`textarea`,{"aria-label":`Suggestion content`,value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Scope`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion scope`,value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Rationale`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion rationale`,value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Implications`}),(0,q.jsx)(`textarea`,{"aria-label":`Suggestion implications`,value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:4,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Stages`}),(0,q.jsx)(`textarea`,{"aria-label":`Suggestion stages`,value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Priority`}),(0,q.jsxs)(`select`,{"aria-label":`Suggestion priority`,value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,q.jsx)(`option`,{value:`critical`,children:`Critical`}),(0,q.jsx)(`option`,{value:`normal`,children:`Normal`}),(0,q.jsx)(`option`,{value:`low`,children:`Low`})]})]})]})]}):(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.kind===`decision`?e.decision:e.instruction}),(0,q.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Scope:`}),` `,e.scope]}),e.rationale&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Why:`}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Implications:`}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Stages:`}),` `,e.stages.join(`, `)]}),e.kind===`convention`&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Priority:`}),` `,e.priority]})]})]})]}),(0,q.jsx)(wg,{className:`border-t border-border pt-4`,children:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:`Cancel edit`}),(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:[`Dismiss `,e.kind]}),d&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}),(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:`Close`}),(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:[`Dismiss `,e.kind]}),(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:`Edit`}),d&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}),(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})})]})})},QB=({activeTab:e,isLoading:t,memory:n,onActiveTabChange:r,onOpenChange:i,open:a})=>(0,q.jsx)(vg,{open:a,onOpenChange:i,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-4xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:`Project memory`}),(0,q.jsx)(Eg,{children:`Review the saved project context Archon can use while working on this ticket.`})]}),(0,q.jsxs)(Zv,{value:e,onValueChange:e=>r(e),className:`flex flex-col gap-4`,children:[(0,q.jsxs)(Qv,{className:`flex h-auto w-full flex-wrap justify-start`,children:[(0,q.jsx)($v,{value:`decisions`,children:`Decisions`}),(0,q.jsx)($v,{value:`conventions`,children:`Conventions`}),(0,q.jsx)($v,{value:`generated-context`,children:`Generated context`})]}),(0,q.jsx)(ey,{value:`decisions`,className:`mt-0 outline-none`,children:t?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading project memory...`}):n&&n.decisions.length>0?(0,q.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.decisions.map(e=>(0,q.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.decision]},e.id))}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accepted decisions saved yet.`})}),(0,q.jsx)(ey,{value:`conventions`,className:`mt-0 outline-none`,children:t?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading project memory...`}):n&&n.conventions.length>0?(0,q.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.conventions.map(e=>(0,q.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.instruction]},e.id))}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No conventions saved yet.`})}),(0,q.jsx)(ey,{value:`generated-context`,className:`mt-0 outline-none`,children:t?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading project memory...`}):n?.generated_context?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[n.generated_context.is_stale&&(0,q.jsx)(`p`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:`Generated scan context may be outdated relative to the current repo HEAD.`}),n.generated_context.architecture_summary&&(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2 text-sm text-foreground`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Architecture:`}),` `,n.generated_context.architecture_summary]}),n.generated_context.key_areas.length>0?(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`h5`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Relevant areas`}),(0,q.jsx)(`ul`,{className:`mt-2 space-y-2 text-sm text-foreground`,children:n.generated_context.key_areas.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No relevant areas were captured in the latest scan.`})]}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No generated context saved yet.`})})]}),(0,q.jsx)(wg,{className:`border-t border-border pt-4`,showCloseButton:!0})]})}),$B=({projectId:e,ticketId:t,memoryEnabled:n,refreshKey:r,onSuggestionsChanged:i})=>{let[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[p,m]=(0,b.useState)(`decisions`),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(null),[y,x]=(0,b.useState)({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(0);if((0,b.useEffect)(()=>{if(!e||!n){u(!1),o(null),c([]);return}let r=new AbortController;return u(!0),o(null),c([]),Promise.all([lt(e,t,r.signal),ut(e,t,r.signal)]).then(([e,t])=>{r.signal.aborted||(o(e),c(t.suggestions),v(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e),g(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e))}).catch(e=>{if(!r.signal.aborted){if(e instanceof S&&(e.status===404||e.status===409)){o(null),c([]);return}o(null),c([])}}).finally(()=>{r.signal.aborted||u(!1)}),()=>{r.abort()}},[n,e,r,T,t]),!n||!e)return null;let D=s.length>0,O=a?.decisions.length??0,k=a?.conventions.length??0,A=!!a?.generated_context,j=l?`Loading saved project memory for this ticket.`:O>0||k>0||A?`Saved decisions, conventions and generated context`:`No saved project memory yet. Suggestions will still appear here when Archon finds them.`,M=h?s.find(e=>e.id===h)??null:null,N=e=>{e&&m(YB(a)),f(e)},P=e=>{g(e.id),v(e.id),x(KB(e))},F=()=>{v(null),x({title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`})},I=e=>{_&&_!==e.id&&F(),g(e.id)},L=e=>{e||(g(null),_&&F())},R=async(t,n)=>{if(!e)return;let r=_===t.id?y:KB(t),a=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:qB(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:JB(r.stages),priority:r.priority};w(t.id);try{if(n){if(t.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let n=t.duplicate_match?.decision;if(!n)throw Error(`No existing decision is available for this suggestion.`);await pt(e,t.id,n.id,a)}else await dt(e,t.id,a);F(),g(null),E(e=>e+1),i?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{w(null)}},z=async t=>{if(e){w(t.id);try{await ft(e,t.id),_===t.id&&F(),h===t.id&&g(null),E(e=>e+1),i?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{w(null)}}};return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Project memory`}),l&&(0,q.jsx)(Z,{variant:`outline`,children:`Loading`}),!l&&a?.generated_context?.is_stale&&(0,q.jsx)(Z,{variant:`outline`,className:`border-amber-500/40 bg-amber-500/10 text-amber-100`,children:`Scan stale`})]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:justify-end`,children:[!l&&(0,q.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 whitespace-nowrap`,children:[(0,q.jsxs)(Z,{variant:`outline`,children:[O,` decision`,O===1?``:`s`]}),(0,q.jsxs)(Z,{variant:`outline`,children:[k,` convention`,k===1?``:`s`]}),(0,q.jsx)(Z,{variant:`outline`,children:A?`1 scan`:`0 scans`})]}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>N(!0),children:`View details`})]})]})}),D&&(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:[`Memory suggestions (`,s.length,`)`]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Review before saving`})]}),(0,q.jsx)(`ul`,{className:`space-y-2`,children:s.map(e=>(0,q.jsx)(XB,{suggestion:e,isPending:C===e.id,onReview:I,onAccept:e=>R(e,!1),onDismiss:z},e.id))})]}),(0,q.jsx)(QB,{open:d,onOpenChange:N,isLoading:l,memory:a,activeTab:p,onActiveTabChange:m}),(0,q.jsx)(ZB,{suggestion:M,isOpen:!!M,isEditing:_===M?.id,isPending:C===M?.id,draft:_===M?.id?y:M?KB(M):y,onOpenChange:L,onStartEdit:P,onDraftChange:x,onCancelEdit:F,onAccept:R,onDismiss:z})]})},eV=({content:e,externalSource:t=null})=>(0,q.jsxs)(`section`,{"aria-label":`Ticket description`,className:`min-h-0 flex-1 overflow-y-auto rounded-xl border border-border/80 bg-card/70 px-4 py-4`,children:[(0,q.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-widest text-muted-foreground`,children:`Description`}),(0,q.jsx)(vM,{externalSource:t,className:`mt-3`}),(0,q.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e})]}),tV=[`h-7 w-auto max-w-full rounded-md border-border/70 bg-transparent px-2.5 text-[11px] text-muted-foreground shadow-none`,`hover:border-border hover:bg-background/60 hover:text-foreground`,`focus-visible:border-ring/70 focus-visible:ring-2 focus-visible:ring-ring/20`,`disabled:border-border/40 disabled:bg-transparent disabled:text-muted-foreground/50`,`[&_svg]:ml-1 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-muted-foreground`].join(` `),nV=[`flex h-7 shrink-0 items-center rounded-md border border-border/70 bg-transparent px-2.5`].join(` `),rV=[`h-2 rounded-full`,`h-2 rounded-full`,`h-2 rounded-full`],iV=[`w-[4.75rem]`,`w-[4.25rem]`,`w-[3.5rem]`],aV=({className:e,dataTestId:t})=>(0,q.jsx)(`div`,{"data-testid":t,className:J(`flex min-w-0 flex-wrap items-center gap-1.5`,e),children:iV.map((e,t)=>(0,q.jsx)(`div`,{className:nV,children:(0,q.jsx)(y_,{className:J(rV[t],e)})},e))}),oV=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,q.jsxs)(`div`,{className:J(`flex min-w-0 flex-wrap items-center gap-1.5`,h),children:[r?(0,q.jsx)(r_,{model:e,showModelSelector:!0,availableModels:a,onModelChange:c,selectId:d,label:``,triggerAriaLabel:`Choose model`,disabled:m,className:`min-w-0`,triggerClassName:tV}):null,g?(0,q.jsx)(i_,{variant:t,selectedModel:s,showVariantSelector:!0,onVariantChange:l,selectId:f,label:``,triggerAriaLabel:`Choose model variant`,disabled:m,className:`min-w-0`,triggerClassName:tV}):null,i?(0,q.jsx)(LB,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,label:``,triggerAriaLabel:`Choose skills`,disabled:m,className:`min-w-0`,triggerClassName:tV,showSelectedBadges:!1}):null]})},sV=2,cV=1,lV=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(sV,Math.floor(u/e.css.cell.width)),rows:Math.max(cV,Math.floor(l/e.css.cell.height))}}},uV=Object.defineProperty,dV=Object.getOwnPropertyDescriptor,fV=(e,t)=>{for(var n in t)uV(e,n,{get:t[n],enumerable:!0})},pV=(e,t,n,r)=>{for(var i=r>1?void 0:r?dV(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&uV(t,n,i),i},mV=(e,t)=>(n,r)=>t(n,r,e),hV=`Terminal input`,gV={get:()=>hV,set:e=>hV=e},_V=`Too much output to announce, navigate to rows manually to read`,vV={get:()=>_V,set:e=>_V=e};function yV(e){return e.replace(/\r?\n/g,`\r`)}function bV(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function xV(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function SV(e,t,n,r){e.stopPropagation(),e.clipboardData&&CV(e.clipboardData.getData(`text/plain`),t,n,r)}function CV(e,t,n,r){e=yV(e),e=bV(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function wV(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function TV(e,t,n,r,i){wV(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function EV(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function DV(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var OV=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},kV=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},AV=``,jV=` `,MV=class e{constructor(){this.fg=0,this.bg=0,this.extended=new NV}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},NV=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},PV=class e extends MV{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new NV,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?EV(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},FV=`di$target`,IV=`di$dependencies`,LV=new Map;function RV(e){return e[IV]||[]}function zV(e){if(LV.has(e))return LV.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);BV(t,e,r)};return t._id=e,LV.set(e,t),t}function BV(e,t,n){t[FV]===t?t[IV].push({id:e,index:n}):(t[IV]=[{id:e,index:n}],t[FV]=t)}var VV=zV(`BufferService`),HV=zV(`CoreMouseService`),UV=zV(`CoreService`),WV=zV(`CharsetService`),GV=zV(`InstantiationService`),KV=zV(`LogService`),qV=zV(`OptionsService`),JV=zV(`OscLinkService`),YV=zV(`UnicodeService`),XV=zV(`DecorationService`),ZV=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new PV,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):QV(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ZV=pV([mV(0,VV),mV(1,qV),mV(2,JV)],ZV);function QV(e,t){if(confirm(`Do you want to navigate to ${t}?
133
+ `).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),JB=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},YB=e=>(e?.decisions.length??0)>0?`decisions`:(e?.conventions.length??0)>0?`conventions`:`generated-context`,XB=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=a?`Save as new decision`:`Accept`,s=e.kind===`decision`?e.decision:e.instruction;return(0,q.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,q.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,q.jsxs)(Z,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:[`Suggested `,e.kind]}),a&&(0,q.jsx)(Z,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:`Possible duplicate`})]}),(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:`Dismiss`})]})]})})},ZB=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?`Save as new decision`:`Accept as ${e.kind}`;return(0,q.jsx)(vg,{open:t,onOpenChange:a,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:e.title}),(0,q.jsx)(Eg,{children:`Review this suggestion before saving it into project memory.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,q.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,q.jsxs)(`p`,{children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}),n?(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Suggestion title`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion title`,value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Content`}),(0,q.jsx)(`textarea`,{"aria-label":`Suggestion content`,value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Scope`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion scope`,value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Rationale`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion rationale`,value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Implications`}),(0,q.jsx)(`textarea`,{"aria-label":`Suggestion implications`,value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:4,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Stages`}),(0,q.jsx)(`textarea`,{"aria-label":`Suggestion stages`,value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Priority`}),(0,q.jsxs)(`select`,{"aria-label":`Suggestion priority`,value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,q.jsx)(`option`,{value:`critical`,children:`Critical`}),(0,q.jsx)(`option`,{value:`normal`,children:`Normal`}),(0,q.jsx)(`option`,{value:`low`,children:`Low`})]})]})]})]}):(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.kind===`decision`?e.decision:e.instruction}),(0,q.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Scope:`}),` `,e.scope]}),e.rationale&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Why:`}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Implications:`}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Stages:`}),` `,e.stages.join(`, `)]}),e.kind===`convention`&&(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Priority:`}),` `,e.priority]})]})]})]}),(0,q.jsx)(wg,{className:`border-t border-border pt-4`,children:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:`Cancel edit`}),(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:[`Dismiss `,e.kind]}),d&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}),(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:`Close`}),(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:[`Dismiss `,e.kind]}),(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:`Edit`}),d&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}),(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})})]})})},QB=({activeTab:e,isLoading:t,memory:n,onActiveTabChange:r,onOpenChange:i,open:a})=>(0,q.jsx)(vg,{open:a,onOpenChange:i,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-4xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:`Project memory`}),(0,q.jsx)(Eg,{children:`Review the saved project context Archon can use while working on this ticket.`})]}),(0,q.jsxs)(Zv,{value:e,onValueChange:e=>r(e),className:`flex flex-col gap-4`,children:[(0,q.jsxs)(Qv,{className:`flex h-auto w-full flex-wrap justify-start`,children:[(0,q.jsx)($v,{value:`decisions`,children:`Decisions`}),(0,q.jsx)($v,{value:`conventions`,children:`Conventions`}),(0,q.jsx)($v,{value:`generated-context`,children:`Generated context`})]}),(0,q.jsx)(ey,{value:`decisions`,className:`mt-0 outline-none`,children:t?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading project memory...`}):n&&n.decisions.length>0?(0,q.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.decisions.map(e=>(0,q.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.decision]},e.id))}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accepted decisions saved yet.`})}),(0,q.jsx)(ey,{value:`conventions`,className:`mt-0 outline-none`,children:t?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading project memory...`}):n&&n.conventions.length>0?(0,q.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.conventions.map(e=>(0,q.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.instruction]},e.id))}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No conventions saved yet.`})}),(0,q.jsx)(ey,{value:`generated-context`,className:`mt-0 outline-none`,children:t?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading project memory...`}):n?.generated_context?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[n.generated_context.is_stale&&(0,q.jsx)(`p`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:`Generated scan context may be outdated relative to the current repo HEAD.`}),n.generated_context.architecture_summary&&(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2 text-sm text-foreground`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Architecture:`}),` `,n.generated_context.architecture_summary]}),n.generated_context.key_areas.length>0?(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,q.jsx)(`h5`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Relevant areas`}),(0,q.jsx)(`ul`,{className:`mt-2 space-y-2 text-sm text-foreground`,children:n.generated_context.key_areas.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No relevant areas were captured in the latest scan.`})]}):(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No generated context saved yet.`})})]}),(0,q.jsx)(wg,{className:`border-t border-border pt-4`,showCloseButton:!0})]})}),$B=({projectId:e,ticketId:t,memoryEnabled:n,refreshKey:r,onSuggestionsChanged:i})=>{let[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[p,m]=(0,b.useState)(`decisions`),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(null),[y,x]=(0,b.useState)({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(0);if((0,b.useEffect)(()=>{if(!e||!n){u(!1),o(null),c([]);return}let r=new AbortController;return u(!0),o(null),c([]),Promise.all([lt(e,t,r.signal),ut(e,t,r.signal)]).then(([e,t])=>{r.signal.aborted||(o(e),c(t.suggestions),v(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e),g(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e))}).catch(e=>{if(!r.signal.aborted){if(e instanceof S&&(e.status===404||e.status===409)){o(null),c([]);return}o(null),c([])}}).finally(()=>{r.signal.aborted||u(!1)}),()=>{r.abort()}},[n,e,r,T,t]),!n||!e)return null;let D=s.length>0,O=a?.decisions.length??0,k=a?.conventions.length??0,A=!!a?.generated_context,j=l?`Loading saved project memory for this ticket.`:O>0||k>0||A?`Saved decisions, conventions and generated context`:`No saved project memory yet. Suggestions will still appear here when Archon finds them.`,M=h?s.find(e=>e.id===h)??null:null,N=e=>{e&&m(YB(a)),f(e)},P=e=>{g(e.id),v(e.id),x(KB(e))},F=()=>{v(null),x({title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`})},I=e=>{_&&_!==e.id&&F(),g(e.id)},L=e=>{e||(g(null),_&&F())},R=async(t,n)=>{if(!e)return;let r=_===t.id?y:KB(t),a=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:qB(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:JB(r.stages),priority:r.priority};w(t.id);try{if(n){if(t.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let n=t.duplicate_match?.decision;if(!n)throw Error(`No existing decision is available for this suggestion.`);await pt(e,t.id,n.id,a)}else await dt(e,t.id,a);F(),g(null),E(e=>e+1),i?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{w(null)}},z=async t=>{if(e){w(t.id);try{await ft(e,t.id),_===t.id&&F(),h===t.id&&g(null),E(e=>e+1),i?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{w(null)}}};return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Project memory`}),l&&(0,q.jsx)(Z,{variant:`outline`,children:`Loading`}),!l&&a?.generated_context?.is_stale&&(0,q.jsx)(Z,{variant:`outline`,className:`border-amber-500/40 bg-amber-500/10 text-amber-100`,children:`Scan stale`})]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:justify-end`,children:[!l&&(0,q.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 whitespace-nowrap`,children:[(0,q.jsxs)(Z,{variant:`outline`,children:[O,` decision`,O===1?``:`s`]}),(0,q.jsxs)(Z,{variant:`outline`,children:[k,` convention`,k===1?``:`s`]}),(0,q.jsx)(Z,{variant:`outline`,children:A?`1 scan`:`0 scans`})]}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>N(!0),children:`View details`})]})]})}),D&&(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:[`Memory suggestions (`,s.length,`)`]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Review before saving`})]}),(0,q.jsx)(`ul`,{className:`space-y-2`,children:s.map(e=>(0,q.jsx)(XB,{suggestion:e,isPending:C===e.id,onReview:I,onAccept:e=>R(e,!1),onDismiss:z},e.id))})]}),(0,q.jsx)(QB,{open:d,onOpenChange:N,isLoading:l,memory:a,activeTab:p,onActiveTabChange:m}),(0,q.jsx)(ZB,{suggestion:M,isOpen:!!M,isEditing:_===M?.id,isPending:C===M?.id,draft:_===M?.id?y:M?KB(M):y,onOpenChange:L,onStartEdit:P,onDraftChange:x,onCancelEdit:F,onAccept:R,onDismiss:z})]})},eV=({content:e,externalSource:t=null})=>(0,q.jsxs)(`section`,{"aria-label":`Ticket description`,className:`min-h-0 flex-1 overflow-y-auto rounded-xl border border-border/80 bg-card/70 px-4 py-4`,children:[(0,q.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-widest text-muted-foreground`,children:`Description`}),(0,q.jsx)(PM,{externalSource:t,className:`mt-3`}),(0,q.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e})]}),tV=[`h-7 w-auto max-w-full rounded-md border-border/70 bg-transparent px-2.5 text-[11px] text-muted-foreground shadow-none`,`hover:border-border hover:bg-background/60 hover:text-foreground`,`focus-visible:border-ring/70 focus-visible:ring-2 focus-visible:ring-ring/20`,`disabled:border-border/40 disabled:bg-transparent disabled:text-muted-foreground/50`,`[&_svg]:ml-1 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-muted-foreground`].join(` `),nV=[`flex h-7 shrink-0 items-center rounded-md border border-border/70 bg-transparent px-2.5`].join(` `),rV=[`h-2 rounded-full`,`h-2 rounded-full`,`h-2 rounded-full`],iV=[`w-[4.75rem]`,`w-[4.25rem]`,`w-[3.5rem]`],aV=({className:e,dataTestId:t})=>(0,q.jsx)(`div`,{"data-testid":t,className:J(`flex min-w-0 flex-wrap items-center gap-1.5`,e),children:iV.map((e,t)=>(0,q.jsx)(`div`,{className:nV,children:(0,q.jsx)(y_,{className:J(rV[t],e)})},e))}),oV=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,q.jsxs)(`div`,{className:J(`flex min-w-0 flex-wrap items-center gap-1.5`,h),children:[r?(0,q.jsx)(r_,{model:e,showModelSelector:!0,availableModels:a,onModelChange:c,selectId:d,label:``,triggerAriaLabel:`Choose model`,disabled:m,className:`min-w-0`,triggerClassName:tV}):null,g?(0,q.jsx)(i_,{variant:t,selectedModel:s,showVariantSelector:!0,onVariantChange:l,selectId:f,label:``,triggerAriaLabel:`Choose model variant`,disabled:m,className:`min-w-0`,triggerClassName:tV}):null,i?(0,q.jsx)(LB,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,label:``,triggerAriaLabel:`Choose skills`,disabled:m,className:`min-w-0`,triggerClassName:tV,showSelectedBadges:!1}):null]})},sV=2,cV=1,lV=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(sV,Math.floor(u/e.css.cell.width)),rows:Math.max(cV,Math.floor(l/e.css.cell.height))}}},uV=Object.defineProperty,dV=Object.getOwnPropertyDescriptor,fV=(e,t)=>{for(var n in t)uV(e,n,{get:t[n],enumerable:!0})},pV=(e,t,n,r)=>{for(var i=r>1?void 0:r?dV(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&uV(t,n,i),i},mV=(e,t)=>(n,r)=>t(n,r,e),hV=`Terminal input`,gV={get:()=>hV,set:e=>hV=e},_V=`Too much output to announce, navigate to rows manually to read`,vV={get:()=>_V,set:e=>_V=e};function yV(e){return e.replace(/\r?\n/g,`\r`)}function bV(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function xV(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function SV(e,t,n,r){e.stopPropagation(),e.clipboardData&&CV(e.clipboardData.getData(`text/plain`),t,n,r)}function CV(e,t,n,r){e=yV(e),e=bV(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function wV(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function TV(e,t,n,r,i){wV(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function EV(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function DV(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var OV=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},kV=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},AV=``,jV=` `,MV=class e{constructor(){this.fg=0,this.bg=0,this.extended=new NV}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},NV=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},PV=class e extends MV{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new NV,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?EV(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},FV=`di$target`,IV=`di$dependencies`,LV=new Map;function RV(e){return e[IV]||[]}function zV(e){if(LV.has(e))return LV.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);BV(t,e,r)};return t._id=e,LV.set(e,t),t}function BV(e,t,n){t[FV]===t?t[IV].push({id:e,index:n}):(t[IV]=[{id:e,index:n}],t[FV]=t)}var VV=zV(`BufferService`),HV=zV(`CoreMouseService`),UV=zV(`CoreService`),WV=zV(`CharsetService`),GV=zV(`InstantiationService`),KV=zV(`LogService`),qV=zV(`OptionsService`),JV=zV(`OscLinkService`),YV=zV(`UnicodeService`),XV=zV(`DecorationService`),ZV=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new PV,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):QV(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ZV=pV([mV(0,VV),mV(1,qV),mV(2,JV)],ZV);function QV(e,t){if(confirm(`Do you want to navigate to ${t}?
134
134
 
135
135
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var $V=zV(`CharSizeService`),eH=zV(`CoreBrowserService`),tH=zV(`MouseService`),nH=zV(`RenderService`),rH=zV(`SelectionService`),iH=zV(`CharacterJoinerService`),aH=zV(`ThemeService`),oH=zV(`LinkProviderService`),sH=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?pH.isErrorNoTelemetry(e)?new pH(e.message+`
136
136
 
@@ -165,12 +165,12 @@ ${s.join(`
165
165
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),JK&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=_q(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=MK(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-vq),vq),t/=vq,t/Math.abs(t)+Math.round(t*(yq-1)))}shouldForceSelection(e){return WK?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),bq)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(WK&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<xq&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=rq(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=_q(n,this._bufferService.cols)}};Cq=pV([mV(3,VV),mV(4,UV),mV(5,tH),mV(6,qV),mV(7,nH),mV(8,eH)],Cq);var wq=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Tq=class{constructor(){this._color=new wq,this._css=new wq}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Eq=Object.freeze((()=>{let e=[eK.toColor(`#2e3436`),eK.toColor(`#cc0000`),eK.toColor(`#4e9a06`),eK.toColor(`#c4a000`),eK.toColor(`#3465a4`),eK.toColor(`#75507b`),eK.toColor(`#06989a`),eK.toColor(`#d3d7cf`),eK.toColor(`#555753`),eK.toColor(`#ef2929`),eK.toColor(`#8ae234`),eK.toColor(`#fce94f`),eK.toColor(`#729fcf`),eK.toColor(`#ad7fa8`),eK.toColor(`#34e2e2`),eK.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:QG.toCss(r,i,a),rgba:QG.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:QG.toCss(n,n,n),rgba:QG.toRgba(n,n,n)})}return e})()),Dq=eK.toColor(`#ffffff`),Oq=eK.toColor(`#000000`),kq=eK.toColor(`#ffffff`),Aq=Oq,jq={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},Mq=Dq,Nq=class extends BH{constructor(e){super(),this._optionsService=e,this._contrastCache=new Tq,this._halfContrastCache=new Tq,this._onChangeColors=this._register(new dU),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Dq,background:Oq,cursor:kq,cursorAccent:Aq,selectionForeground:void 0,selectionBackgroundTransparent:jq,selectionBackgroundOpaque:$G.blend(Oq,jq),selectionInactiveBackgroundTransparent:jq,selectionInactiveBackgroundOpaque:$G.blend(Oq,jq),scrollbarSliderBackground:$G.opacity(Dq,.2),scrollbarSliderHoverBackground:$G.opacity(Dq,.4),scrollbarSliderActiveBackground:$G.opacity(Dq,.5),overviewRulerBorder:Dq,ansi:Eq.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Pq(e.foreground,Dq),t.background=Pq(e.background,Oq),t.cursor=$G.blend(t.background,Pq(e.cursor,kq)),t.cursorAccent=$G.blend(t.background,Pq(e.cursorAccent,Aq)),t.selectionBackgroundTransparent=Pq(e.selectionBackground,jq),t.selectionBackgroundOpaque=$G.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Pq(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=$G.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Pq(e.selectionForeground,ZG):void 0,t.selectionForeground===ZG&&(t.selectionForeground=void 0),$G.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=$G.opacity(t.selectionBackgroundTransparent,.3)),$G.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=$G.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Pq(e.scrollbarSliderBackground,$G.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Pq(e.scrollbarSliderHoverBackground,$G.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Pq(e.scrollbarSliderActiveBackground,$G.opacity(t.foreground,.5)),t.overviewRulerBorder=Pq(e.overviewRulerBorder,Mq),t.ansi=Eq.slice(),t.ansi[0]=Pq(e.black,Eq[0]),t.ansi[1]=Pq(e.red,Eq[1]),t.ansi[2]=Pq(e.green,Eq[2]),t.ansi[3]=Pq(e.yellow,Eq[3]),t.ansi[4]=Pq(e.blue,Eq[4]),t.ansi[5]=Pq(e.magenta,Eq[5]),t.ansi[6]=Pq(e.cyan,Eq[6]),t.ansi[7]=Pq(e.white,Eq[7]),t.ansi[8]=Pq(e.brightBlack,Eq[8]),t.ansi[9]=Pq(e.brightRed,Eq[9]),t.ansi[10]=Pq(e.brightGreen,Eq[10]),t.ansi[11]=Pq(e.brightYellow,Eq[11]),t.ansi[12]=Pq(e.brightBlue,Eq[12]),t.ansi[13]=Pq(e.brightMagenta,Eq[13]),t.ansi[14]=Pq(e.brightCyan,Eq[14]),t.ansi[15]=Pq(e.brightWhite,Eq[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=Pq(e.extendedAnsi[r],Eq[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Nq=pV([mV(0,qV)],Nq);function Pq(e,t){if(e!==void 0)try{return eK.toColor(e)}catch{}return t}var Fq=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Iq=class{constructor(){this._services=new Fq,this._services.set(GV,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=RV(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Lq={trace:0,debug:1,info:2,warn:3,error:4,off:5},Rq=`xterm.js: `,zq=class extends BH{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Bq=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Lq[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:Rq)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};zq=pV([mV(0,qV)],zq);var Bq,Vq=class extends BH{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new dU),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new dU),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new dU),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Hq=3,Uq=Object.freeze(new MV),Wq=0,Gq=2,Kq=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Hq);let r=t||PV.fromCharData([0,AV,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*Hq+0],n=t&2097151;return[this._data[e*Hq+1],t&2097152?this._combined[e]:n?EV(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*Hq+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*Hq+0]=e|2097152|t[2]<<22):this._data[e*Hq+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*Hq+0]>>22}hasWidth(e){return this._data[e*Hq+0]&12582912}getFg(e){return this._data[e*Hq+1]}getBg(e){return this._data[e*Hq+2]}hasContent(e){return this._data[e*Hq+0]&4194303}getCodePoint(e){let t=this._data[e*Hq+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*Hq+0]&2097152}getString(e){let t=this._data[e*Hq+0];return t&2097152?this._combined[e]:t&2097151?EV(t&2097151):``}isProtected(e){return this._data[e*Hq+2]&536870912}loadCell(e,t){return Wq=e*Hq,t.content=this._data[Wq+0],t.fg=this._data[Wq+1],t.bg=this._data[Wq+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*Hq+0]=t.content,this._data[e*Hq+1]=t.fg,this._data[e*Hq+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Hq+0]=t|n<<22,this._data[e*Hq+1]=r.fg,this._data[e*Hq+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*Hq+0];r&2097152?this._combined[e]+=EV(t):r&2097151?(this._combined[e]=EV(r&2097151)+EV(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Hq+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new PV;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new PV;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*Gq<this._data.buffer.byteLength;let n=e*Hq;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*Gq<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Gq<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Hq+0]&4194303)return e+(this._data[e*Hq+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Hq+0]&4194303||this._data[e*Hq+2]&50331648)return e+(this._data[e*Hq+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<Hq;e++)this._data[(n+i)*Hq+e]=a[(t+i)*Hq+e];a[(t+i)*Hq+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<Hq;e++)this._data[(n+i)*Hq+e]=a[(t+i)*Hq+e];a[(t+i)*Hq+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*Hq+0],n=e&2097151,a=e&2097152?this._combined[t]:n?EV(n):jV;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function qq(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=Zq(u,d,t),p=1,m=0;for(;p<u.length;){let e=Zq(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function Jq(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function Yq(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function Xq(e,t,n){let r=[],i=e.map((n,r)=>Zq(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=Zq(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function Zq(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var Qq=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new dU),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),FH(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Qq._nextId=1;var $q=Qq,eJ={},tJ=eJ.B;eJ[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},eJ.A={"#":`£`},eJ.B=void 0,eJ[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},eJ.C=eJ[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},eJ.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},eJ.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},eJ.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},eJ.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},eJ.E=eJ[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},eJ.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},eJ.H=eJ[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},eJ[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var nJ=4294967295,rJ=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Uq.clone(),this.savedCharset=tJ,this.markers=[],this._nullCell=PV.fromCharData([0,AV,1,0]),this._whitespaceCell=PV.fromCharData([0,jV,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new $K,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Vq(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new NV),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new NV),this._whitespaceCell}getBlankLine(e,t){return new Kq(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>nJ?nJ:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Uq);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Vq(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Uq),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Kq(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new Kq(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=qq(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Uq),n);if(r.length>0){let n=Jq(this.lines,r);Yq(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Uq),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Kq(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Uq),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=Xq(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(Uq,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=Zq(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new $q(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},iJ=class extends BH{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new dU),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new rJ(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new rJ(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},aJ=2,oJ=1,sJ=class extends BH{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new dU),this.onResize=this._onResize.event,this._onScroll=this._register(new dU),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,aJ),this.rows=Math.max(e.rawOptions.rows||0,oJ),this.buffers=this._register(new iJ(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sJ=pV([mV(0,qV)],sJ);var cJ={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:WK,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},lJ=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],uJ=class extends BH{constructor(e){super(),this._onOptionChange=this._register(new dU),this.onOptionChange=this._onOptionChange.event;let t={...cJ};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(LH(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in cJ))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in cJ))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=cJ[e],!dJ(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=cJ[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=lJ.includes(t)?t:cJ[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function dJ(e){return e===`block`||e===`underline`||e===`bar`}function fJ(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&fJ(e[r],t-1);return n}var pJ=Object.freeze({insertMode:!1}),mJ=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),hJ=class extends BH{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new dU),this.onData=this._onData.event,this._onUserInput=this._register(new dU),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new dU),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new dU),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fJ(pJ),this.decPrivateModes=fJ(mJ)}reset(){this.modes=fJ(pJ),this.decPrivateModes=fJ(mJ)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};hJ=pV([mV(0,VV),mV(1,KV),mV(2,qV)],hJ);var gJ={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function _J(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var vJ=String.fromCharCode,yJ={DEFAULT:e=>{let t=[_J(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${vJ(t[0])}${vJ(t[1])}${vJ(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${_J(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${_J(e,!0)};${e.x};${e.y}${t}`}},bJ=class extends BH{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new dU),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(gJ))this.addProtocol(e,gJ[e]);for(let e of Object.keys(yJ))this.addEncoding(e,yJ[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};bJ=pV([mV(0,VV),mV(1,UV),mV(2,qV)],bJ);var xJ=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],SJ=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],CJ;function wJ(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var TJ=class{constructor(){if(this.version=`6`,!CJ){CJ=new Uint8Array(65536),CJ.fill(1),CJ[0]=0,CJ.fill(0,1,32),CJ.fill(0,127,160),CJ.fill(2,4352,4448),CJ[9001]=2,CJ[9002]=2,CJ.fill(2,11904,42192),CJ[12351]=1,CJ.fill(2,44032,55204),CJ.fill(2,63744,64256),CJ.fill(2,65040,65050),CJ.fill(2,65072,65136),CJ.fill(2,65280,65377),CJ.fill(2,65504,65511);for(let e=0;e<xJ.length;++e)CJ.fill(0,xJ[e][0],xJ[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?CJ[e]:wJ(e,SJ)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=EJ.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return EJ.createPropertyValue(0,n,r)}},EJ=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new dU,this.onChange=this._onChange.event;let e=new TJ;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},DJ=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function OJ(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var kJ=2147483647,AJ=256,jJ=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>AJ)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>kJ?kJ:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>kJ?kJ:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,kJ):e}},MJ=[],NJ=class{constructor(){this._state=0,this._active=MJ,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=MJ}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=MJ,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||MJ,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,DV(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=MJ,this._id=-1,this._state=0}}},PJ=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=DV(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},FJ=[],IJ=class{constructor(){this._handlers=Object.create(null),this._active=FJ,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=FJ}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=FJ,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||FJ,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,DV(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=FJ,this._ident=0}},LJ=new jJ;LJ.addParam(0);var RJ=class{constructor(e){this._handler=e,this._data=``,this._params=LJ,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():LJ,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=DV(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=LJ,this._data=``,this._hitLimit=!1,e));return this._params=LJ,this._data=``,this._hitLimit=!1,t}},zJ=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},BJ=160,VJ=function(){let e=new zJ(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(BJ,0,2,0),e.add(BJ,8,5,8),e.add(BJ,6,0,6),e.add(BJ,11,0,11),e.add(BJ,13,13,13),e}(),HJ=class extends BH{constructor(e=VJ){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new jJ,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(LH(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new NJ),this._dcsParser=this._register(new IJ),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:BJ)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<BJ){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<BJ){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<BJ){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<BJ){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<BJ){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<BJ){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},UJ=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,WJ=/^[\da-f]+$/;function GJ(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=UJ.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),WJ.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function KJ(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function qJ(e,t=16){let[n,r,i]=e;return`rgb:${KJ(n,t)}/${KJ(r,t)}/${KJ(i,t)}`}var JJ={"(":0,")":1,"*":2,"+":3,"-":1,".":2},YJ=131072,XJ=10;function ZJ(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var QJ=5e3,$J=0,eY=class extends BH{constructor(e,t,n,r,i,a,o,s,c=new HJ){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new OV,this._utf8Decoder=new kV,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Uq.clone(),this._eraseAttrDataInternal=Uq.clone(),this._onRequestBell=this._register(new dU),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new dU),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new dU),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new dU),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new dU),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new dU),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new dU),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new dU),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new dU),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new dU),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new dU),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new dU),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new dU),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new tY(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(WG.IND,()=>this.index()),this._parser.setExecuteHandler(WG.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(WG.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new PJ(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new PJ(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new PJ(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new PJ(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new PJ(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new PJ(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new PJ(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new PJ(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new PJ(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new PJ(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new PJ(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new PJ(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in eJ)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new RJ((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),QJ))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${QJ} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>YJ&&(a=this._parseStack.position+YJ)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<YJ&&(this._parseBuffer=new Uint32Array(Math.min(e.length,YJ))),o||this._dirtyRowTracker.clearRange(),e.length>YJ)for(let t=a;t<e.length;t+=YJ){let a=t+YJ<e.length?t+YJ:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=EJ.extractWidth(t);let n=EJ.extractShouldJoin(t),m=n?EJ.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(EV(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof Kq&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>ZJ(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new RJ(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new PJ(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Uq));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=EJ.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,tJ),this._charsetService.setgCharset(1,tJ),this._charsetService.setgCharset(2,tJ),this._charsetService.setgCharset(3,tJ);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=MV.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Uq.fg,e.bg=Uq.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Uq.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Uq.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Uq.fg&16777215,r.bg&=-67108864,r.bg|=Uq.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Uq.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ZJ(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>XJ&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>XJ&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(nY(n))if(r===`?`)t.push({type:0,index:n});else{let e=GJ(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=GJ(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);nY(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,tJ),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(JJ[e[0]],eJ[e[1]]||tJ),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Uq.clone(),this._eraseAttrDataInternal=Uq.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new PV;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},tY=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&($J=e,e=t,t=$J),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};tY=pV([mV(0,VV)],tY);function nY(e){return 0<=e&&e<256}var rY=5e7,iY=12,aY=50,oY=class extends BH{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new dU),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>rY)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=iY?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=iY)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>aY&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},sY=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};sY=pV([mV(0,VV)],sY);var cY=!1,lY=class extends BH{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new VH),this._onBinary=this._register(new dU),this.onBinary=this._onBinary.event,this._onData=this._register(new dU),this.onData=this._onData.event,this._onLineFeed=this._register(new dU),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new dU),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new dU),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new dU),this._instantiationService=new Iq,this.optionsService=this._register(new uJ(e)),this._instantiationService.setService(qV,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sJ)),this._instantiationService.setService(VV,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(zq)),this._instantiationService.setService(KV,this._logService),this.coreService=this._register(this._instantiationService.createInstance(hJ)),this._instantiationService.setService(UV,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(bJ)),this._instantiationService.setService(HV,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(EJ)),this._instantiationService.setService(YV,this.unicodeService),this._charsetService=this._instantiationService.createInstance(DJ),this._instantiationService.setService(WV,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(sY),this._instantiationService.setService(JV,this._oscLinkService),this._inputHandler=this._register(new eY(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ZH.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ZH.forward(this._bufferService.onResize,this._onResize)),this._register(ZH.forward(this.coreService.onData,this._onData)),this._register(ZH.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new oY((e,t)=>this._inputHandler.parse(e,t))),this._register(ZH.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new dU),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!cY&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),cY=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,aJ),t=Math.max(t,oJ),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(OJ.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(OJ(this._bufferService),!1))),this._windowsWrappingHeuristics.value=LH(()=>{for(let t of e)t.dispose()})}}},uY={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function dY(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`D`:t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`C`:t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`A`:t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`B`:t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:a?i.key=$.ESC+`[3;`+(a+1)+`~`:i.key=$.ESC+`[3~`;break;case 36:a?i.key=$.ESC+`[1;`+(a+1)+`H`:t?i.key=$.ESC+`OH`:i.key=$.ESC+`[H`;break;case 35:a?i.key=$.ESC+`[1;`+(a+1)+`F`:t?i.key=$.ESC+`OF`:i.key=$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+`[5;`+(a+1)+`~`:i.key=$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+`[6;`+(a+1)+`~`:i.key=$.ESC+`[6~`;break;case 112:a?i.key=$.ESC+`[1;`+(a+1)+`P`:i.key=$.ESC+`OP`;break;case 113:a?i.key=$.ESC+`[1;`+(a+1)+`Q`:i.key=$.ESC+`OQ`;break;case 114:a?i.key=$.ESC+`[1;`+(a+1)+`R`:i.key=$.ESC+`OR`;break;case 115:a?i.key=$.ESC+`[1;`+(a+1)+`S`:i.key=$.ESC+`OS`;break;case 116:a?i.key=$.ESC+`[15;`+(a+1)+`~`:i.key=$.ESC+`[15~`;break;case 117:a?i.key=$.ESC+`[17;`+(a+1)+`~`:i.key=$.ESC+`[17~`;break;case 118:a?i.key=$.ESC+`[18;`+(a+1)+`~`:i.key=$.ESC+`[18~`;break;case 119:a?i.key=$.ESC+`[19;`+(a+1)+`~`:i.key=$.ESC+`[19~`;break;case 120:a?i.key=$.ESC+`[20;`+(a+1)+`~`:i.key=$.ESC+`[20~`;break;case 121:a?i.key=$.ESC+`[21;`+(a+1)+`~`:i.key=$.ESC+`[21~`;break;case 122:a?i.key=$.ESC+`[23;`+(a+1)+`~`:i.key=$.ESC+`[23~`;break;case 123:a?i.key=$.ESC+`[24;`+(a+1)+`~`:i.key=$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=uY[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL));break}return i}var fY=0,pY=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new $K,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new $K,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(fY=this._search(t),fY===-1)||this._getKey(this._array[fY])!==t)return!1;do if(this._array[fY]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(fY),!0;while(++fY<this._array.length&&this._getKey(this._array[fY])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(fY=this._search(e),!(fY<0||fY>=this._array.length)&&this._getKey(this._array[fY])===e))do yield this._array[fY];while(++fY<this._array.length&&this._getKey(this._array[fY])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(fY=this._search(e),!(fY<0||fY>=this._array.length)&&this._getKey(this._array[fY])===e))do t(this._array[fY]);while(++fY<this._array.length&&this._getKey(this._array[fY])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},mY=0,hY=0,gY=class extends BH{constructor(){super(),this._decorations=new pY(e=>e?.marker.line),this._onDecorationRegistered=this._register(new dU),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new dU),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(LH(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new _Y(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{mY=t.options.x??0,hY=mY+(t.options.width??1),e>=mY&&e<hY&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},_Y=class extends zH{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new dU),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new dU),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=eK.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=eK.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},vY=1e3,yY=class{constructor(e,t=vY){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},bY=20,xY=!1,SY=class extends BH{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new yY(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);xY?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
166
166
  `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(WW(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(LH(()=>{xY?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<bY+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
167
167
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===bY+1&&(this._liveRegion.textContent+=vV.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};SY=pV([mV(1,GV),mV(2,eH),mV(3,nH)],SY);var CY=class extends BH{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new dU),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new dU),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(LH(()=>{FH(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(WW(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(WW(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(WW(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(WW(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&wY(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,FH(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};CY=pV([mV(1,tH),mV(2,nH),mV(3,VV),mV(4,oH)],CY);function wY(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var TY=class extends lY{constructor(e={}){super(e),this._linkifier=this._register(new VH),this.browser=IK,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new VH),this._onCursorMove=this._register(new dU),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new dU),this.onKey=this._onKey.event,this._onRender=this._register(new dU),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new dU),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new dU),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new dU),this.onBell=this._onBell.event,this._onFocus=this._register(new dU),this._onBlur=this._register(new dU),this._onA11yCharEmitter=this._register(new dU),this._onA11yTabEmitter=this._register(new dU),this._onWillOpen=this._register(new dU),this._setup(),this._decorationService=this._instantiationService.createInstance(gY),this._instantiationService.setService(XV,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jK),this._instantiationService.setService(oH,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ZV)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(ZH.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ZH.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ZH.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ZH.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(LH(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=$G.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${qJ(r)}${GG.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=QG.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=QG.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(SY,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(WW(this.element,`copy`,e=>{this.hasSelection()&&xV(e,this._selectionService)}));let e=e=>SV(e,this.textarea,this.coreService,this.optionsService);this._register(WW(this.textarea,`paste`,e)),this._register(WW(this.element,`paste`,e)),BK?this._register(WW(this.element,`mousedown`,e=>{e.button===2&&TV(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(WW(this.element,`contextmenu`,e=>{TV(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),JK&&this._register(WW(this.element,`auxclick`,e=>{e.button===1&&wV(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(WW(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(WW(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(WW(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(WW(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(WW(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(WW(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(WW(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(WW(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,gV.get()),YK||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(kK,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(eH,this._coreBrowserService),this._register(WW(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(WW(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(TK,this._document,this._helperContainer),this._instantiationService.setService($V,this._charSizeService),this._themeService=this._instantiationService.createInstance(Nq),this._instantiationService.setService(aH,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(oK),this._instantiationService.setService(iH,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(tq,this.rows,this.screenElement)),this._instantiationService.setService(nH,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(KG,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(PK),this._instantiationService.setService(tH,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(CY,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(LG,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Cq,this.element,this.screenElement,r)),this._instantiationService.setService(rH,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(ZH.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(RG,this.screenElement)),this._register(WW(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(SY,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(UG,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(UG,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(wK,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(WW(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(WW(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){CV(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=dY(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(EY(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Uq));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function EY(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var DY=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},OY=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new PV)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},kY=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new OY(t)}getNullCell(){return new PV}},AY=class extends BH{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new dU),this.onBufferChange=this._onBufferChange.event,this._normal=new kY(this._core.buffers.normal,`normal`),this._alternate=new kY(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},jY=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},MY=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},NY=[`cols`,`rows`],PY=0,FY=class extends BH{constructor(e){super(),this._core=this._register(new TY(e)),this._addonManager=this._register(new DY),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(NY.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new jY(this._core),this._parser}get unicode(){return this._checkProposedApi(),new MY(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new AY(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
168
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return gV.get()},set promptLabel(e){gV.set(e)},get tooMuchOutput(){return vV.get()},set tooMuchOutput(e){vV.set(e)}}}_verifyIntegers(...e){for(PY of e)if(PY===1/0||isNaN(PY)||PY%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(PY of e)if(PY&&(PY===1/0||isNaN(PY)||PY%1!=0||PY<0))throw Error(`This API only accepts positive integers`)}},IY=Object.create(null);IY.open=`0`,IY.close=`1`,IY.ping=`2`,IY.pong=`3`,IY.message=`4`,IY.upgrade=`5`,IY.noop=`6`;var LY=Object.create(null);Object.keys(IY).forEach(e=>{LY[IY[e]]=e});var RY={type:`error`,data:`parser error`},zY=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,BY=typeof ArrayBuffer==`function`,VY=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,HY=({type:e,data:t},n,r)=>zY&&t instanceof Blob?n?r(t):UY(t,r):BY&&(t instanceof ArrayBuffer||VY(t))?n?r(t):UY(new Blob([t]),r):r(IY[e]+(t||``)),UY=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function WY(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var GY;function KY(e,t){if(zY&&e.data instanceof Blob)return e.data.arrayBuffer().then(WY).then(t);if(BY&&(e.data instanceof ArrayBuffer||VY(e.data)))return t(WY(e.data));HY(e,!1,e=>{GY||=new TextEncoder,t(GY.encode(e))})}var qY=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,JY=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)JY[qY.charCodeAt(e)]=e;var YY=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=JY[e.charCodeAt(r)],o=JY[e.charCodeAt(r+1)],s=JY[e.charCodeAt(r+2)],c=JY[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},XY=typeof ArrayBuffer==`function`,ZY=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:$Y(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:QY(e.substring(1),t)}:LY[n]?e.length>1?{type:LY[n],data:e.substring(1)}:{type:LY[n]}:RY},QY=(e,t)=>XY?$Y(YY(e),t):{base64:!0,data:e},$Y=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},eX=``,tX=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{HY(e,!1,e=>{r[a]=e,++i===n&&t(r.join(eX))})})},nX=(e,t)=>{let n=e.split(eX),r=[];for(let e=0;e<n.length;e++){let i=ZY(n[e],t);if(r.push(i),i.type===`error`)break}return r};function rX(){return new TransformStream({transform(e,t){KY(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var iX;function aX(e){return e.reduce((e,t)=>e+t.length,0)}function oX(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function sX(e,t){iX||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(aX(n)<1)break;let e=oX(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(aX(n)<2)break;let e=oX(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(aX(n)<8)break;let e=oX(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(RY);break}i=a*2**32+t.getUint32(4),r=3}else{if(aX(n)<i)break;let e=oX(n,i);s.enqueue(ZY(a?e:iX.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(RY);break}}}})}function cX(e){if(e)return lX(e)}function lX(e){for(var t in cX.prototype)e[t]=cX.prototype[t];return e}cX.prototype.on=cX.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},cX.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},cX.prototype.off=cX.prototype.removeListener=cX.prototype.removeAllListeners=cX.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},cX.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},cX.prototype.emitReserved=cX.prototype.emit,cX.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},cX.prototype.hasListeners=function(e){return!!this.listeners(e).length};var uX=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),dX=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),fX=`arraybuffer`;function pX(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var mX=dX.setTimeout,hX=dX.clearTimeout;function gX(e,t){t.useNativeTimers?(e.setTimeoutFn=mX.bind(dX),e.clearTimeoutFn=hX.bind(dX)):(e.setTimeoutFn=dX.setTimeout.bind(dX),e.clearTimeoutFn=dX.clearTimeout.bind(dX))}var _X=1.33;function vX(e){return typeof e==`string`?yX(e):Math.ceil((e.byteLength||e.size)*_X)}function yX(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function bX(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function xX(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function SX(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var CX=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},wX=class extends cX{constructor(e){super(),this.writable=!1,gX(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new CX(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=ZY(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=xX(e);return t.length?`?`+t:``}},TX=class extends wX{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){nX(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,tX(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=bX()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},EX=!1;try{EX=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var DX=EX;function OX(){}var kX=class extends TX{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},AX=class e extends cX{constructor(e,t,n){super(),this.createRequest=e,gX(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=pX(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=OX,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(AX.requestsCount=0,AX.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,jX);else if(typeof addEventListener==`function`){let e=`onpagehide`in dX?`pagehide`:`unload`;addEventListener(e,jX,!1)}}function jX(){for(let e in AX.requests)AX.requests.hasOwnProperty(e)&&AX.requests[e].abort()}var MX=(function(){let e=PX({xdomain:!1});return e&&e.responseType!==null})(),NX=class extends kX{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=MX&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new AX(PX,this.uri(),e)}};function PX(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||DX))return new XMLHttpRequest}catch{}if(!t)try{return new dX[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var FX=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,IX=class extends wX{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=FX?{}:pX(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;HY(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&uX(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=bX()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},LX=dX.WebSocket||dX.MozWebSocket,RX={websocket:class extends IX{createSocket(e,t,n){return FX?new LX(e,t,n):t?new LX(e,t):new LX(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends wX{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=sX(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=rX();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&uX(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:NX},zX=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,BX=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function VX(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=zX.exec(e||``),a={},o=14;for(;o--;)a[BX[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=HX(a,a.path),a.queryKey=UX(a,a.query),a}function HX(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function UX(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var WX=typeof addEventListener==`function`&&typeof removeEventListener==`function`,GX=[];WX&&addEventListener(`offline`,()=>{GX.forEach(e=>e())},!1);var KX=class e extends cX{constructor(e,t){if(super(),this.binaryType=fX,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=VX(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=VX(t.host).host);gX(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=SX(this.opts.query)),WX&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},GX.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=vX(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,uX(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),WX&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=GX.indexOf(this._offlineEventListener);e!==-1&&GX.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};KX.protocol=4;var qX=class extends KX{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;KX.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;KX.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},JX=class extends qX{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>RX[e]).filter(e=>!!e)),super(e,n)}};JX.protocol;function YX(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=VX(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var XX=typeof ArrayBuffer==`function`,ZX=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,QX=Object.prototype.toString,$X=typeof Blob==`function`||typeof Blob<`u`&&QX.call(Blob)===`[object BlobConstructor]`,eZ=typeof File==`function`||typeof File<`u`&&QX.call(File)===`[object FileConstructor]`;function tZ(e){return XX&&(e instanceof ArrayBuffer||ZX(e))||$X&&e instanceof Blob||eZ&&e instanceof File}function nZ(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(nZ(e[t]))return!0;return!1}if(tZ(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return nZ(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&nZ(e[t]))return!0;return!1}function rZ(e){let t=[],n=e.data,r=e;return r.data=iZ(n,t),r.attachments=t.length,{packet:r,buffers:t}}function iZ(e,t){if(!e)return e;if(tZ(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=iZ(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=iZ(e[r],t));return n}return e}function aZ(e,t){return e.data=oZ(e.data,t),delete e.attachments,e}function oZ(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=oZ(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=oZ(e[n],t));return e}var sZ=c({Decoder:()=>dZ,Encoder:()=>uZ,PacketType:()=>lZ,isPacketValid:()=>vZ,protocol:()=>5}),cZ=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],lZ;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(lZ||={});var uZ=class{constructor(e){this.replacer=e}encode(e){return(e.type===lZ.EVENT||e.type===lZ.ACK)&&nZ(e)?this.encodeAsBinary({type:e.type===lZ.EVENT?lZ.BINARY_EVENT:lZ.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===lZ.BINARY_EVENT||e.type===lZ.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=rZ(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},dZ=class e extends cX{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===lZ.BINARY_EVENT;n||t.type===lZ.BINARY_ACK?(t.type=n?lZ.EVENT:lZ.ACK,this.reconstructor=new fZ(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(tZ(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(lZ[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===lZ.BINARY_EVENT||r.type===lZ.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!mZ(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case lZ.CONNECT:return gZ(t);case lZ.DISCONNECT:return t===void 0;case lZ.CONNECT_ERROR:return typeof t==`string`||gZ(t);case lZ.EVENT:case lZ.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&cZ.indexOf(t[0])===-1);case lZ.ACK:case lZ.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},fZ=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=aZ(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function pZ(e){return typeof e==`string`}var mZ=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function hZ(e){return e===void 0||mZ(e)}function gZ(e){return Object.prototype.toString.call(e)===`[object Object]`}function _Z(e,t){switch(e){case lZ.CONNECT:return t===void 0||gZ(t);case lZ.DISCONNECT:return t===void 0;case lZ.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&cZ.indexOf(t[0])===-1);case lZ.ACK:return Array.isArray(t);case lZ.CONNECT_ERROR:return typeof t==`string`||gZ(t);default:return!1}}function vZ(e){return pZ(e.nsp)&&hZ(e.id)&&_Z(e.type,e.data)}function yZ(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var bZ=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),xZ=class extends cX{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[yZ(e,`open`,this.onopen.bind(this)),yZ(e,`packet`,this.onpacket.bind(this)),yZ(e,`error`,this.onerror.bind(this)),yZ(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(bZ.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:lZ.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:lZ.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case lZ.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case lZ.EVENT:case lZ.BINARY_EVENT:this.onevent(e);break;case lZ.ACK:case lZ.BINARY_ACK:this.onack(e);break;case lZ.DISCONNECT:this.ondisconnect();break;case lZ.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:lZ.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:lZ.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function SZ(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}SZ.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},SZ.prototype.reset=function(){this.attempts=0},SZ.prototype.setMin=function(e){this.ms=e},SZ.prototype.setMax=function(e){this.max=e},SZ.prototype.setJitter=function(e){this.jitter=e};var CZ=class extends cX{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,gX(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new SZ({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||sZ;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new JX(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=yZ(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=yZ(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(yZ(e,`ping`,this.onping.bind(this)),yZ(e,`data`,this.ondata.bind(this)),yZ(e,`error`,this.onerror.bind(this)),yZ(e,`close`,this.onclose.bind(this)),yZ(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){uX(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new xZ(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},wZ={};function TZ(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=YX(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=wZ[i]&&a in wZ[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new CZ(r,t):(wZ[i]||(wZ[i]=new CZ(r,t)),c=wZ[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(TZ,{Manager:CZ,Socket:xZ,io:TZ,connect:TZ});var EZ=TZ(x),DZ=({label:e,onClick:t,children:n})=>(0,q.jsx)(Y,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),OZ=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,kZ=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,b.useRef)(null),d=(0,b.useRef)(null),f=(0,b.useRef)(null),p=(0,b.useRef)(null),m=(0,b.useRef)(e),h=(0,b.useRef)(!1),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(!0);return(0,b.useEffect)(()=>{m.current=e},[e]),(0,b.useEffect)(()=>{if(!u.current)return;let e=new FY({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new lV,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,mM(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&EZ.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(OZ(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};EZ.on(`terminal:ready`,s),EZ.on(`terminal:data`,c),EZ.on(`terminal:exit`,l),EZ.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&EZ.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,EZ.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||EZ.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),EZ.off(`terminal:ready`,s),EZ.off(`terminal:data`,c),EZ.off(`terminal:exit`,l),EZ.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,b.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(EZ.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,q.jsxs)(zv,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,q.jsx)(D_,{className:`h-4 w-4`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,q.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,q.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,q.jsx)(DZ,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,q.jsx)(Ny,{className:`h-4 w-4`}):(0,q.jsx)(Py,{className:`h-4 w-4`})}),(0,q.jsx)(DZ,{label:c,onClick:r,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]})]}),(0,q.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},AZ=`modulepreload`,jZ=function(e){return`/`+e},MZ={},NZ=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}))))}r=o(t.map(t=>{if(t=jZ(t,n),t in MZ)return;MZ[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:AZ,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}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)})},PZ=(0,b.lazy)(()=>NZ(()=>Promise.resolve().then(()=>V1).then(e=>({default:e.TicketChangesModal})),void 0)),FZ=`(min-width: 1280px)`,IZ=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,LZ=e=>{let[t,n]=(0,b.useState)(()=>IZ(e));return(0,b.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},RZ=({onClose:e})=>(0,q.jsx)(Iv,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading diff...`})}),zZ=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,q.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,q.jsx)(AB,{...s,header:({showThinkingControl:e})=>(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]})})]}),BZ=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,VZ=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],showModelSelector:i=!1,availableModels:a=[],availableSkills:o=[],projectBranchState:s=null,projectMemoryEnabled:c=!1,runDisabled:l=!1,runDisabledReason:u,onClose:d,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onUpdate:h,onDeleteDependency:g,onAdvance:_,onBuildChain:v,onRun:y,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)(!1),[L,R]=(0,b.useState)(!1),[z,ee]=(0,b.useState)(!1),[B,V]=(0,b.useState)(``),[H,te]=(0,b.useState)(!1),[U,ne]=(0,b.useState)(!1),[W,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(0),[G,oe]=(0,b.useState)(!1),[se,le]=(0,b.useState)(!1),[ue,de]=(0,b.useState)(null),K=k??e,[fe,pe]=(0,b.useState)(K.model??``),[me,he]=(0,b.useState)(K.variant??``),[ge,_e]=(0,b.useState)(K.skills??[]),[ve,ye]=(0,b.useState)(()=>BZ(K.model,a)??`Agent`),be=(0,b.useRef)(K.id),xe=(0,b.useRef)(null),Se=(0,b.useRef)(null),Ce=(0,b.useRef)(!1),we=(0,b.useRef)(K.id),Te=(0,b.useRef)(K.build_completed_at),Ee=LZ(FZ),[De,Oe]=(0,b.useState)(!1),[ke,Ae]=(0,b.useState)({model:K.model,variant:K.variant,skills:K.skills??[]}),Ne=K.state===`plan`,Pe=gj(K.state),Fe=K.worktree_bundle_id!==null,Ie=Ne&&K.agent_status===`running`,Le=Ne&&K.agent_status===`error`,Re=Ne&&!Ie||j,ze=hj(K.state),Be=ze?Ej(K,ze):!1,Ve=ze?ze===`review`?`Review Bundle`:ze.charAt(0).toUpperCase()+ze.slice(1):null,He=async e=>{let t=await ce(K.id,K.project_id,e);return A(t),h?.(t),m&&await m(),t},Ue=async e=>{try{await He(e),d()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},We=async e=>{try{if(await He(e),!_){d();return}await _(),d()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ge=async()=>{!_||!Be||(await _(),d())},Ke=async e=>{try{if(await He(e),!v){d();return}await v(),d()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},qe=Ne?K.planning_session_id:K.session_id,Je=qe?qe.startsWith(`ses_`)?`opencode --session ${qe}`:`claude --resume ${qe}`:null,Ye=K.bundle?.branch??K.branch,Xe=K.has_worktree??!!Ye,Ze=!Re&&vj(K)&&K.agent_status===`running`&&!!K.session_id&&!!C,Qe=!Re&&vj(K)&&K.agent_status===`stopped`&&!!K.session_id&&!!T,$e=`Pause Build`,et=`Stop Build Chain`,tt=`Stop Run`,nt=new Map(t.map(e=>[e.id,e])),rt=n.filter(e=>e.blocker_ticket_id===K.id),it=n.filter(e=>e.dependent_ticket_id===K.id),at=Wj(K,nt,n),ot=at.pendingBuildChainOrder.length>0?`Will build in order: ${at.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,st=at.skippedBuildChainCount>0?`Skips ${at.skippedBuildChainCount} ticket${at.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,ct=at.hasOpenBlockers,lt=xj(K),ut=K.build_chain?.active_ticket_id?`Currently building ${nt.get(K.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,dt=K.build_chain&&K.build_chain.queued_ticket_ids.length>0?`Queued next: ${K.build_chain.queued_ticket_ids.map(e=>nt.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,ft=Ne&&!!_&&!at.hasOpenBlockers,pt=Ne&&!!v&&at.canStartBuildChain,mt=!!K.project_id&&!Ne&&!Fe,ht=Ne,gt=Fe&&!Ne,_t=!!K.project_id&&!!Ye&&Xe&&!Re&&!Ie&&!Fe,vt=!!K.project_id&&Xe&&!Re&&!Ie&&!!x&&!Fe,yt=mt&&!F,bt=mt&&z,xt=B.trim(),St=!Re&&!Ie&&K.state!==`plan`&&Xe&&!!E,Ct=ht&&U,wt=gt&&W,Tt=(K.planning_context?.open_questions.length??0)>0,Et=St&&i&&K.tool===`opencode`,Dt=a.find(e=>e.id===fe)??null,Ot=K.agent_status===`running`,kt=eM(K,{allTickets:t,preferBundleReviewStatus:!0}),At=K.skills??[],jt=Ot?`Wait for the current build to finish before sending a follow-up prompt.`:void 0,Mt=Ie?`Wait for planning to finish before sending another message.`:void 0,Nt=[...Ie?[]:[{label:`Worktree`,value:Ye??``}],{label:`Session`,value:Je??``},...Ie?[{label:K.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:K.bundle?.kind===`project_root`?K.bundle?hv(K.bundle):``:K.bundle?.name??``}]:Ne?[{label:`Bundle`,value:K.bundle?.name??``},{label:`Model`,value:K.model??``},{label:`Variant`,value:K.variant??``},{label:`Skills`,value:At.length>0?`${At.length} skill${At.length===1?``:`s`}`:``},{label:`Initiative`,value:K.planning_context?.initiative_prompt??``}]:[]],Pt=Ie?{model:K.model??``,variant:K.variant??``,skills:At}:null,Ft=ht&&U,It=gt&&W,Lt=(Ft||It)&&!Ee,Rt=Ft&&!Lt,zt=Rt||It&&!Lt,Bt=Ne&&(Ft||!Ee),Vt=F?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:zt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Lt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ht=F&&!L?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:zt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Ut=()=>{ee(!0),I(e=>(e&&R(!1),!e))},Wt=()=>{I(!1),R(!1),ee(!1),D?.(K.id)},Gt=()=>{le(!1),de(null)},Kt=()=>{le(!1),ue===`cancel_edit`&&!Ne?M(!1):d(),de(null)},qt=()=>{if(!Re){d();return}if(!G){d();return}de(`close_modal`),le(!0)},Jt=()=>{if(Ne){qt();return}if(!G){M(!1);return}de(`cancel_edit`),le(!0)};(0,b.useEffect)(()=>{A(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,b.useEffect)(()=>{if(we.current!==K.id){we.current=K.id,Te.current=K.build_completed_at;return}if(Te.current===K.build_completed_at)return;let e=Te.current;Te.current=K.build_completed_at,K.build_completed_at&&K.build_completed_at!==e&&ae(e=>e+1)},[K.build_completed_at,K.id]),(0,b.useEffect)(()=>{pe(K.model??``),he(K.variant??``),_e(K.skills??[])},[K.model,K.skills,K.variant]),(0,b.useEffect)(()=>{be.current!==K.id&&(be.current=K.id,ye(BZ(K.model,a)??`Agent`))},[a,K.id,K.model]),(0,b.useEffect)(()=>{let e=BZ(K.model,a);e&&ye(e)},[a,K.model]),(0,b.useEffect)(()=>{Ae({model:K.model,variant:K.variant,skills:K.skills??[]})},[K.id,K.model,K.skills,K.variant]),(0,b.useEffect)(()=>{Re||(oe(!1),le(!1),de(null))},[Re]),(0,b.useEffect)(()=>{G||(le(!1),de(null))},[G]),(0,b.useEffect)(()=>{if(!Ne){xe.current=null,Ce.current=!1;return}let e=xe.current!==K.id,t=!Ce.current&&Tt;(e&&Tt||t)&&ne(!0),xe.current=K.id,Ce.current=Tt},[Tt,Ne,K.id]),(0,b.useEffect)(()=>{if(!gt){Se.current=null;return}Se.current!==K.id&&re(!1),Se.current=K.id},[gt,K.id]);let Yt=async(e,t,n)=>{Oe(!0);try{let r=await ce(K.id,K.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});A(r),h?.(r)}catch(e){pe(K.model??``),he(K.variant??``),_e(K.skills??[]),X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Oe(!1)}},Xt=e=>{let t=(a.find(t=>t.id===e)??null)?.variants.includes(me)?me:``;pe(e),he(t),Yt(e,t,ge)},Zt=e=>{he(e),Yt(fe,e,ge)},Qt=e=>{_e(e),Yt(fe,me,e)},$t=async()=>{if(!(!E||H||Ot||!xt)){te(!0);try{await E(xt),V(``)}finally{te(!1)}}},en=async()=>{if(!(H||Ie||!xt||!Ct)){te(!0);try{let e=K.skills??[];if(ke.model!==K.model||ke.variant!==K.variant||ke.skills.length!==e.length||ke.skills.some((t,n)=>t!==e[n])){let e=await ce(K.id,K.project_id,{model:ke.model,variant:ke.variant,skills:ke.skills});A(e),h?.(e)}let t=await je(K.id,K.project_id,xt);A(t),h?.(t),V(``)}finally{te(!1)}}},tn=(K.messages??[]).filter(wM).map(e=>e.role===`assistant`?{...e,displayTitle:ve}:e.kind===`follow_up`?{...e,displayTitle:`You`}:e),nn=(K.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&wM(e)).map(e=>e.role===`assistant`?{...e,displayTitle:ve}:e.kind===`planning_follow_up`?{...e,displayTitle:`You`}:e),rn=Ft?(0,q.jsx)(zZ,{ariaLabel:`Planning chat`,title:`Planning Chat`,closeAriaLabel:`Close planning chat`,className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,description:Tt?(0,q.jsxs)(`p`,{children:[K.planning_context?.open_questions.length,` open question`,K.planning_context?.open_questions.length===1?``:`s`]}):void 0,projectId:K.project_id,followUpTicketId:null,messages:nn,internalLog:K.agent_log??null,streamingResponse:K.streaming_response??null,isRunning:K.agent_status===`running`,canShowComposer:Ct,pendingAgentTitle:ve,composerTheme:Pe,followUpPlaceholder:`Ask the agent to refine this plan`,emptyStateText:null,autoFocusComposer:U,followUpPrompt:B,isSendingFollowUp:H,followUpDisabledReason:Mt,onFollowUpPromptChange:V,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ie||H||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()},onClose:()=>{ne(!1)}}):It?(0,q.jsx)(zZ,{ariaLabel:`Ticket chat`,title:`Ticket Chat`,closeAriaLabel:`Close ticket chat`,className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,projectId:K.project_id,followUpTicketId:K.id,messages:tn,internalLog:K.agent_log??null,streamingResponse:K.streaming_response??null,isRunning:K.agent_status===`running`,canShowComposer:wt,pendingAgentTitle:ve,composerTheme:Pe,autoFocusComposer:W,followUpPrompt:B,isSendingFollowUp:H,followUpDisabledReason:jt,followUpComposerControls:Et?(0,q.jsx)(oV,{model:fe,variant:me,skills:ge,showModelSelector:!0,showSkillsSelector:!0,availableModels:a,availableSkills:o,selectedModel:Dt,onModelChange:Xt,onVariantChange:Zt,onSkillsChange:Qt,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:De}):void 0,onFollowUpPromptChange:V,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ot||H||(e.preventDefault(),$t())},onFollowUpSubmit:()=>{$t()},onClose:()=>{re(!1)}}):null;return(0,q.jsx)(Iv,{onClose:qt,overlayClassName:`bg-black/60`,panelClassName:Vt,renderContent:({closeButton:e})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[_t&&K.diff_stats&&(0,q.jsx)(b_,{stats:K.diff_stats,showFiles:!0,className:`text-xs`}),_t&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Changes`,onClick:()=>{D?.(K.id),P(!0)},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),vt&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open IDE`,onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),yt&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open terminal`,"aria-pressed":F,onClick:Ut,variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(D_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Terminal`})]}),(ht||gt)&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Chat`,"aria-pressed":Ne?U:W,onClick:()=>{if(Ne){ne(e=>!e);return}re(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(Qb,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Chat`})]}),e]}),(0,q.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":F?L?`expanded`:`split`:`closed`,"data-side-chat-mode":zt?`inline`:Lt?`overlay`:`closed`,className:Ht,children:[(0,q.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Re?(0,q.jsxs)(q.Fragment,{children:[Le&&K.agent_log&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,q.jsx)(`span`,{className:`font-semibold`,children:`Planning failed: `}),K.agent_log]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(_M,{tool:K.tool,className:`text-[11px]`})}),(0,q.jsx)(vM,{externalSource:K.external_source}),(0,q.jsx)(GB,{heading:`Edit Ticket`,bundles:r,initialTitle:K.title,initialDescription:K.description??``,initialModel:K.model??``,initialVariant:K.variant??``,initialSkills:K.skills??[],initialWorktreeBundleId:K.worktree_bundle_id,projectBranchState:s,projectId:K.project_id,stackConfigurationSections:Rt&&!Bt,preferWideBundleSelector:Rt&&Bt,agentSettingsPresentation:Bt?`popover`:`panel`,showModelSelector:i,availableModels:a,availableSkills:o,onAgentSettingsChange:Ae,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onCancel:Jt,onDirtyChange:oe,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await ce(K.id,K.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});h?.(o),d(),await Me(K.id,K.project_id)}},primaryAction:{label:`Save`,variant:ft?`subtle`:`brand`,onClick:Ue},secondaryAction:ft?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:We}:void 0,tertiaryAction:pt?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:Ke}:void 0,beforeActionsContent:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)($B,{projectId:K.project_id,ticketId:K.id,memoryEnabled:c,refreshKey:ie,onSuggestionsChanged:O}),at.hasDependents&&(0,q.jsx)(TM,{summary:ot,detail:st}),(0,q.jsx)(NB,{blocks:rt,blockedBy:it,resolveTicket:e=>nt.get(e),onDeleteDependency:g})]}),footerLeadingContent:G?(0,q.jsx)(Z,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${K.id}:${K.updated_at}:${K.title}:${K.description}`)]}):(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:K.title}),(0,q.jsx)(_M,{tool:K.tool,className:`text-[11px]`}),(kt===`building`||kt===`done`)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[K.is_running&&(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,q.jsx)(Xj,{status:kt,showBuildGlyph:!0})]}),kt!==null&&kt!==`building`&&kt!==`done`&&(0,q.jsx)(Xj,{status:kt,showBuildGlyph:!0}),Tt&&(0,q.jsx)(Z,{variant:`warning`,children:`Open questions`}),lt&&(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Fe?(0,q.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,q.jsx)(eV,{content:K.description,externalSource:K.external_source})}):(0,q.jsx)(q.Fragment,{children:Ne?(0,q.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Ie?` mt-3`:``}`,children:(0,q.jsx)(eV,{content:K.description,externalSource:K.external_source})}):(0,q.jsx)(AB,{projectId:K.project_id,followUpTicketId:K.id,messages:tn,internalLog:K.agent_log??null,streamingResponse:K.streaming_response??null,isRunning:K.agent_status===`running`,canShowComposer:St,pendingAgentTitle:ve,composerTheme:Pe,followUpComposerControls:Et?(0,q.jsx)(oV,{model:fe,variant:me,skills:ge,showModelSelector:!0,showSkillsSelector:!0,availableModels:a,availableSkills:o,selectedModel:Dt,onModelChange:Xt,onVariantChange:Zt,onSkillsChange:Qt,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:De}):void 0,followUpPrompt:B,isSendingFollowUp:H,followUpDisabledReason:jt,onFollowUpPromptChange:V,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ot||H||(e.preventDefault(),$t())},onFollowUpSubmit:()=>{$t()}})}),Ie&&(0,q.jsxs)(`section`,{"aria-label":`Ticket metadata`,className:`flex flex-wrap items-center gap-2`,children:[Nt.filter(e=>e.value.trim().length>0).map(e=>(0,q.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,q.jsx)(bM,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,q.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,q.jsx)(hM,{model:Pt.model,variant:Pt.variant,skills:Pt.skills})})]}),!Ie&&!zt&&(0,q.jsx)(xM,{ariaLabel:`Ticket metadata`,items:Nt}),(0,q.jsx)($B,{projectId:K.project_id,ticketId:K.id,memoryEnabled:c,refreshKey:ie,onSuggestionsChanged:O}),(0,q.jsx)(NB,{blocks:rt,blockedBy:it,resolveTicket:e=>nt.get(e),onDeleteDependency:g}),K.build_chain&&(0,q.jsx)(TM,{summary:ut,detail:dt})]}),!Re&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,onClick:d,variant:`ghost`,children:`Close`}),Ze&&(0,q.jsxs)(Y,{type:`button`,onClick:C,title:`Pause the build session. You can resume it later.`,"aria-label":$e,variant:`warning`,children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),$e]}),K.build_chain&&w&&(0,q.jsxs)(Y,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":et,variant:`destructive`,children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),et]}),Qe&&(0,q.jsxs)(Y,{type:`button`,onClick:T,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),`Resume`]}),Ye&&!Re&&!Fe&&K.is_running&&S&&(0,q.jsxs)(Y,{type:`button`,onClick:S,title:`Stop the currently running ticket.`,"aria-label":tt,variant:`destructive`,children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),tt]}),Ye&&Xe&&!Ie&&!Re&&!Fe&&!K.is_running&&y&&(0,q.jsxs)(Y,{type:`button`,disabled:l,title:l?u??`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{l||y()},variant:`secondary`,className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),`Run`]}),!Re&&K.state===`build`&&!ct&&Ve&&_&&(0,q.jsxs)(Y,{type:`button`,disabled:!Be,onClick:()=>{Ge()},children:[Ve,(0,q.jsx)(fj,{className:`w-3.5 h-3.5`})]})]})]})]}),zt&&rn,bt&&(0,q.jsx)(`div`,{className:F?L?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,q.jsx)(kZ,{createSession:()=>fM(K.id,K.project_id),isExpanded:L,isVisible:F,ariaLabel:`Ticket terminal`,className:L?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:Wt,onToggleExpanded:()=>{R(e=>!e)}})})]}),Lt&&rn,N&&(0,q.jsx)(b.Suspense,{fallback:(0,q.jsx)(RZ,{onClose:()=>{P(!1),D?.(K.id)}}),children:(0,q.jsx)(PZ,{ticketId:K.id,projectId:K.project_id,title:K.title,onTicketUpdate:h,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!Ot,reviewSubmitDisabledReason:jt,onClose:()=>{P(!1),D?.(K.id)}})}),se&&(0,q.jsx)(Lv,{title:`Discard unsaved edits?`,description:`Any changes made will be lost.`,confirmLabel:`Discard`,cancelLabel:`Keep editing`,confirmVariant:`destructive`,onConfirm:Kt,onCancel:Gt})]})})},HZ=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:x,onRetry:S,onAdvance:C,onPark:w,onUnpark:T,onBuildChain:E,onRun:D,onOpenChanges:O,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P,onOpenBundleDetails:F,onOpenTicketDetails:I,preferBundleDetailsOnClick:L=!1,hideBundleScopedControls:R=!1,hideStatusBadge:z=!1,onRequestTicketRefresh:ee,undoInProgress:B=!1})=>{let[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(!1),[ne,W]=(0,b.useState)(!1),[re,ie]=(0,b.useState)(!1),[ae,G]=(0,b.useState)(null),[oe,se]=(0,b.useState)(!1),[ce,le]=(0,b.useState)(!1),ue=e.agent_status===`running`||B,de=R,K=e.bundle?.branch??e.branch,fe=e.has_worktree??(e.state===`plan`?!1:!!K),pe=!R&&fe,me=Wj(e,new Map(t.map(e=>[e.id,e])),n),he=hj(e.state),ge=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,_e=yj(e),ve=bj(e),ye=xj(e),be=!R&&ve!==`plan`&&e.diff_stats===void 0,xe=(ye||_e)&&!a,Se=he?he===`review`?`Review Bundle`:he.charAt(0).toUpperCase()+he.slice(1):ge?`Re-run review`:null,Ce=Ej(e,`trash`),we=e.undo,Te=!!x&&we?.stage!==null,Ee=ge||(he?Ej(e,he):!1),De=!_e&&!!C&&!!Se&&!me.hasOpenBlockers,Oe=!!w&&wj(e),ke=_e&&typeof e.state==`string`?`Return to ${e.state.charAt(0).toUpperCase()}${e.state.slice(1)}`:null,Ae=!!T&&ke!==null&&e.state!==`plan`,je=!_e&&!!E&&me.canStartBuildChain,Me=vj(e)&&e.agent_status===`running`&&!!e.session_id&&!!j,Ne=vj(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!N,Pe=pe&&!!O,Fe=pe&&!!k,Ie=!de&&fe&&!!K&&!e.is_running&&!!D,Le=!de&&fe&&!!K&&!!e.is_running&&!!A,Re=!!e.build_chain&&!!M,ze=!!y||Te||De||Oe||Ae||je||Me||Ne||Ie||Le||Pe||Fe||Re,Be=_e&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,Ve=async()=>{if(!(!D||c||oe)){se(!0);try{await D()}finally{se(!1)}}},He=async()=>{if(!(!A||ce)){le(!0);try{await A()}finally{le(!1)}}},Ue=!de&&fe&&K&&e.is_running&&A&&!B?(0,q.jsx)(Qj,{isRunning:!0,isStopPending:ce,onStop:He}):!de&&fe&&K&&!e.is_running&&D?(0,q.jsx)(Qj,{isRunning:!1,isRunPending:oe,runDisabled:c,runDisabledReason:l,onRun:Ve,className:Be}):null;(0,b.useEffect)(()=>{if(!re)return;let e=()=>{ie(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[re]);let We=()=>{if(a||re||B){ie(!1);return}if(L&&F){F();return}if(I){I();return}ee?.(e.id),W(!0)},{attributes:Ge,listeners:Ke,setNodeRef:qe,isDragging:Je}=BA({id:e.id,disabled:a||ue}),Ye=(0,b.useRef)(qe);(0,b.useEffect)(()=>{Ye.current=qe},[qe]);let Xe=(0,b.useCallback)(t=>{if(a){m?.(t);return}Ye.current(t),p?.(e.id,t)},[p,m,a,e.id]),Ze=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:me.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,Qe=a||B?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,$e=Je?`opacity-30`:xe?`opacity-90`:`opacity-100`,et=xe?`bg-card/60`:`bg-secondary/30`,tt=xe?`p-3 text-foreground/70`:`p-3`,nt=xe?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,rt=xe?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,it=xe?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,at=e.model??``,ot=!!e.bundle&&!R,st=!!e.bundle?.pull_request&&!R,ct=ot||st,lt=ct||at.length>0,ut=ae===e.id,dt=(0,b.useMemo)(()=>{let t=e.description??``;return t?Jz(t):{text:``,truncated:!1}},[e.description]);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(zv,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${Ze} ${Qe} ${$e} ${et} gap-0 rounded-xl border shadow-none`,ref:Xe,onClick:We,...Ke,...Ge,children:[B&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,q.jsxs)(Z,{variant:`warning`,className:`gap-1.5`,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,q.jsxs)(Wv,{className:tt,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(`div`,{className:nt,children:e.title})}),(0,q.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,q.jsx)(`div`,{className:`mr-1`,children:Ue}),(0,q.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,q.jsx)(u_,{content:`Draw dependency`,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Create dependency from ${e.title}`,variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),ie(!0),d(e.id,t)},children:(0,q.jsx)(uy,{className:`h-4 w-4`})})})}),(0,q.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:ze&&(0,q.jsx)(cM,{title:e.title,canDelete:Ce,undo:we,undoInProgress:B,runDisabled:c,isRunPending:oe,isStopPending:ce,showOpenChangesAction:Pe,showOpenIdeAction:Fe,showRunAction:Ie,showStopRunAction:Le,showAdvanceAction:De,advanceLabel:Se,canAdvance:Ee,showParkAction:Oe,showReturnAction:Ae,returnLabel:ke,showBuildChainAction:je,showPauseBuildAction:Me,showResumeBuildAction:Ne,showStopBuildChainAction:Re,onDelete:y,onConfirmDelete:()=>H(!0),onConfirmUndo:()=>U(!0),onOpenChanges:O,onOpenIde:k,onAdvance:C,onPark:w,onUnpark:T,onBuildChain:E,onRun:Ve,onStop:He,onStopBuild:j,onResumeBuild:N,onStopBuildChain:M})})]})]}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(dM,{ticket:e,hideStatusBadge:z,hideBundleScopedControls:R,isStale:ye,runControl:null,onRetry:S,undoInProgress:B,isChainStart:me.isVisibleStartPoint})}),lt&&(0,q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[ct&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${rt}`,children:[ot&&(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:hv(e.bundle)}),st&&e.bundle?.pull_request&&(0,q.jsx)(uj,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),at.length>0&&(0,q.jsx)(`div`,{className:rt,children:(0,q.jsx)(`span`,{className:`truncate`,children:at})})]}),e.description&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(uM,{description:e.description,descriptionClass:it,isExpanded:ut,collapsedState:dt,useStaleLikeStyling:xe,onExpand:()=>G(e.id),onCollapse:()=>G(null)})}),!R&&(Cj(ve,e.diff_stats)||be)&&(0,q.jsx)(b_,{stats:e.diff_stats,isLoading:be,showFiles:!0,className:`mt-2`})]})]}),ne&&(0,q.jsx)(VZ,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{W(!1),ee?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:C,onBuildChain:E,onRun:D,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P}),V&&(0,q.jsx)(lM,{title:e.title,bundleName:e.bundle?.name,onConfirm:()=>{H(!1),y?.()},onCancel:()=>H(!1)}),te&&we?.stage&&(0,q.jsx)(Zj,{title:e.title,stage:we.stage,onConfirm:()=>{U(!1),x?.()},onCancel:()=>U(!1)})]})},UZ=({index:e})=>(0,q.jsx)(zv,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(y_,{className:`h-3.5 w-3/5 rounded-full`}),(0,q.jsx)(y_,{className:`h-5 w-11 rounded-full`})]}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(y_,{className:`h-3 w-full rounded-full`}),(0,q.jsx)(y_,{className:`h-3 w-11/12 rounded-full`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(y_,{className:`h-4 w-14 rounded-full`}),(0,q.jsx)(y_,{className:`h-4 w-10 rounded-full`})]}),(0,q.jsxs)(`span`,{className:`sr-only`,children:[`Loading card `,e+1]})]})}),WZ=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:x,onUpdateTicket:S,onDeleteTicket:C,onUndoTicket:w,undoingColumn:T=null,onRetryTicket:E,onAdvanceTicket:D,onParkTicket:O,onUnparkTicket:k,onBuildChainTicket:A,onRunTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:z,onFollowUpTicket:ee,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:H,onRunBundle:te,onStopBundle:U,onParkBundleWrapper:ne,onUnparkBundleWrapper:W,bundleActionState:re,onOpenTicketDetails:ie,onOpenBundleDetails:ae,onOpenBundleChanges:G,onOpenBundleIde:oe,onDeleteBundleWrapper:se,onRequestBundleRefresh:ce,onRequestTicketRefresh:le,className:ue=``,headerAccessory:de=null,loadingSkeletonCount:K=0})=>{let{setNodeRef:fe,isOver:pe}=WA({id:e}),me=(0,b.useRef)(null),[he,ge]=(0,b.useState)(!1),[_e,ve]=(0,b.useState)(!1),ye=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),be=pe?`border-primary`:`border-border`,xe=T===e&&(e===`build`||e===`review`),Se=(0,b.useCallback)(()=>{let e=me.current;if(!e){ge(!1),ve(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){ge(!1),ve(!1);return}let t=e.scrollHeight-e.clientHeight;ge(e.scrollTop>1),ve(e.scrollTop<t-1)},[]);(0,b.useEffect)(()=>{let e=window.requestAnimationFrame(Se),t=me.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,Se),window.addEventListener(`resize`,Se),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,Se),window.removeEventListener(`resize`,Se)}},[n.length,K,Se]);let Ce=(0,b.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,b=zj(t),T=u||l!==null&&l!==_j(t)?`Stop the currently running ticket before starting another run.`:b;return(0,q.jsx)(HZ,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:T!==void 0,runDisabledReason:T,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:x,onUpdate:S,onDelete:()=>C(t.id),onUndo:w?()=>w(t.id):void 0,undoInProgress:!1,onRetry:()=>E(t.id),onAdvance:D?()=>D(t.id):void 0,onPark:O?()=>O(t.id):void 0,onUnpark:k?()=>k(t.id):void 0,onBuildChain:A?()=>A(t.id):void 0,onRun:ye(t)&&t.has_run_config&&j?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:z?()=>z(t.id):void 0,onFollowUp:ee?e=>ee(t.id,e):void 0,onOpenBundleDetails:_&&ae?()=>ae(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>ie(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:le})},[l,a,c,f,M,P,o,p,e,u,D,A,v,y,h,C,m,ee,ae,N,F,ie,O,x,g,le,z,E,j,R,L,I,w,k,S,s]);return(0,q.jsxs)(zv,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${ue} ${be}`,ref:fe,children:[(0,q.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[de,(0,q.jsx)(Z,{variant:`outline`,children:r}),_&&(0,q.jsxs)(Y,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,q.jsx)(`span`,{children:`+ New ticket`}),(0,q.jsx)(Z,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,q.jsxs)(`div`,{ref:me,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,q.jsx)(oM,{group:e.group,renderTicket:t=>Ce(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:H,onRunBundle:te,onStopBundle:U,onParkBundleWrapper:ne,onUnparkBundleWrapper:W,bundleActionState:re,onStopBuildTicket:L,onResumeBuildTicket:z,onOpenBundleDetails:ae,onOpenBundleChanges:G,onOpenBundleIde:oe,onDeleteBundleWrapper:se,onRequestBundleRefresh:ce},e.group.id);let t=e.ticket;return(0,q.jsx)(b.Fragment,{children:Ce(t)},t.id)}),Array.from({length:K},(t,n)=>(0,q.jsx)(UZ,{index:n},`loading-card-${e}-${n}`))]}),xe&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,q.jsxs)(Z,{variant:`warning`,className:`gap-1.5`,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),he&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),_e&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},GZ=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let i=e===1?`1 done ticket`:`${e} done tickets`;return(0,q.jsxs)(Iv,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Empty Done`}),(0,q.jsxs)(`p`,{className:`mb-2 text-sm text-foreground`,children:[`Delete `,i,` from the Done column?`]}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`Standalone ticket worktrees will be removed when applicable. Deleting the last parked ticket in a bundle also removes that shared bundle worktree.`}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:t?`Deleting...`:`Delete all`})]})]})},KZ=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,thinkingTicketId:i=null,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c=!1,canShowComposer:l,composerControls:u,composerTheme:d=`default`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h=`Follow up on this bundle`,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b})=>(0,q.jsx)(kB,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,thinkingTicketId:i,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c,autoScrollBehavior:`sticky`,canShowComposer:l,composerInlineControls:u,composerTheme:d,composerSize:`compact-on-laptop`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b}),qZ=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,q.jsxs)(Y,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,q.jsxs)(Y,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,q.jsxs)(Y,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,q.jsxs)(Y,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,q.jsx)(fj,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},JZ=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,YZ=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,q.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,q.jsx)(Z,{variant:`outline`,children:e.length}),i>0&&(0,q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,q.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,q.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,q.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:J(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:J(`h-2 w-2 shrink-0 rounded-full`,JZ(e))}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,q.jsx)(_M,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,q.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,q.jsx)(Z,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,q.jsx)(Z,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},XZ=(0,b.lazy)(()=>NZ(()=>Promise.resolve().then(()=>V1).then(e=>({default:e.TicketChangesModal})),void 0)),ZZ=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,QZ=e=>e.replace(/\r\n/g,`
169
- `).trim(),$Z=(e,t)=>e.ticket_id===t.ticket_id&&e.role===`user`&&t.role===`user`&&e.kind===`follow_up`&&t.kind===`follow_up`&&QZ(e.content)===QZ(t.content),eQ=(e,t)=>{if(t.length===0)return e;let n=new Set,r=new Set,i=new Map,a=[];for(let a of t){let t=[...e].reverse().find(e=>!r.has(e.id)&&!n.has(a.id)&&$Z(a,e));t&&(r.add(t.id),n.add(a.id),i.set(t.id,a))}for(let t of e){let e=i.get(t.id);if(e){a.push(e);continue}a.push(t)}for(let e of t)n.has(e.id)||a.push(e);return a},tQ=(e,t)=>e?t.get(e)??e:null,nQ=(e,t=[])=>{let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??e.bundle_execution_position??2**53-1,i=n.get(t.id)??t.bundle_execution_position??2**53-1;if(r!==i)return r-i;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let a=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return a===0?e.id.localeCompare(t.id):a})},rQ=(e,t)=>tQ(e,t)??`Agent`,iQ=(e,t)=>{let n={};for(let r of e){let e=tQ(r.model,t);e&&(n[r.id]=e)}return n},aQ=e=>e.kind===`planning_follow_up`||e.kind===`planning_response`?0:e.kind===`description`?1:2,oQ=(e,t,n,r=[])=>{let i=nQ(e,r),a=new Map(i.map((e,t)=>[e.id,t]));return i.flatMap(e=>{let r=e.messages??[],i=e.agent_status!==null||e.session_id!==null||r.some(e=>e.kind!==`description`&&wM(e)),o=r.filter(e=>wM(e)&&(i||e.kind!==`description`)),s=n[e.id]??rQ(e.model,t);return o.map(t=>t.role===`assistant`?{...t,displayTitle:s,ticketOrder:a.get(e.id)??2**53-1}:t.kind===`follow_up`?{...t,displayTitle:`You`,ticketOrder:a.get(e.id)??2**53-1}:{...t,displayTitle:e.title,ticketOrder:a.get(e.id)??2**53-1})}).sort((e,t)=>{if(e.ticket_id===t.ticket_id){let n=aQ(e)-aQ(t);if(n!==0)return n}let n=ZZ(e),r=ZZ(t);if(n!==r)return n.localeCompare(r);if(e.ticket_id!==t.ticket_id&&e.ticketOrder!==t.ticketOrder)return e.ticketOrder-t.ticketOrder;let i=aQ(e)-aQ(t);return i===0?e.id.localeCompare(t.id):i}).map(e=>{let{ticketOrder:t,...n}=e;return n})},sQ=e=>dv(e.tickets,{targetTicketId:e.target_ticket_id,reviewOwnerTicketId:e.review_owner_ticket_id,latestSessionTicketId:e.latest_session_ticket_id}),cQ=e=>e?e.startsWith(`ses_`)?`opencode --session ${e}`:`claude --resume ${e}`:null,lQ=(e,t)=>e.latest_session_id?cQ(e.latest_session_id):cQ(t?.session_id??null),uQ=(e,t)=>t?.diff_stats?t.diff_stats:e.find(e=>e.diff_stats)?.diff_stats??null,dQ=({details:e,activeColumn:t=null,isLoading:n=!1,actionState:r,canOpenIde:i,projectMemoryEnabled:a=!1,memorySuggestionsRefreshKey:o=0,runDisabled:s=!1,showModelSelector:c=!1,availableModels:l=[],availableSkills:u=[],onClose:d,onOpenTicketDetails:f,onOpenIde:p,onRefresh:m,onUpdateTicket:h,onBuildBundle:g,onStopBuildTicket:_,onResumeBuildTicket:v,onReviewBundle:y,onRunBundle:x,onStopBundle:C,onFollowUpBundle:w})=>{let[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)(``),[L,R]=(0,b.useState)(``),[z,ee]=(0,b.useState)([]),[B,V]=(0,b.useState)(null),[H,te]=(0,b.useState)(!1),[U,ne]=(0,b.useState)(!1),[W,re]=(0,b.useState)({}),[ie,ae]=(0,b.useState)([]),G=(0,b.useMemo)(()=>sQ(e),[e]),oe=(0,b.useMemo)(()=>new Map(l.map(e=>[e.id,e.label])),[l]),[se,le]=(0,b.useState)(()=>iQ(e.tickets,oe)),ue=(0,b.useMemo)(()=>nQ(e.tickets,e.execution_order_ticket_ids),[e.execution_order_ticket_ids,e.tickets]),de=t??G?.state??null,K=de===`plan`,fe=(0,b.useMemo)(()=>eQ(oQ(e.tickets,oe,se,e.execution_order_ticket_ids),ie),[oe,e.execution_order_ticket_ids,e.tickets,ie,se]),pe=(0,b.useMemo)(()=>tM(e.tickets,de),[de,e.tickets]),me=(0,b.useMemo)(()=>(0,q.jsx)(Xj,{status:pe}),[pe]),he=(0,b.useMemo)(()=>lQ(e,G),[e,G]),ge=(0,b.useMemo)(()=>uQ(e.tickets,G),[e.tickets,G]),_e=!K&&!!(G?.project_id&&G&&uv(G)),ve=!K&&!!(G?.project_id&&G),ye=ve&&!k,be=ve&&N&&G!==null,xe=de===`plan`&&e.tickets.some(e=>e.state===`plan`),Se=ue.find(e=>vj(e)&&e.agent_status===`running`&&!!e.session_id)??null,Ce=ue.find(e=>vj(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,we=Se!==null,Te=!we&&Ce!==null,Ee=de===`build`&&e.tickets.some(e=>e.state===`build`)&&e.tickets.filter(e=>e.state===`build`).every(e=>e.agent_status===`done`),De=r.review||r.followUp,Oe=de===`review`&&e.can_re_review===!0&&!e.tickets.some(e=>e.agent_status===`running`)&&!De,ke=Ee||Oe,Ae=Oe?`Re-run review`:`Review Bundle`,je=e.tickets.some(e=>e.has_run_config&&Rj(e)),Me=e.tickets.some(e=>e.is_running),Ne=e.tickets.find(e=>e.agent_status===`running`)??G,Pe=Ne?.streaming_response??null,Fe=Ne?.agent_log??null,Ie=Ne?.id??G?.id??null,Le=l.find(e=>e.id===F)??null,Re=G?.project_id??e.tickets.find(e=>e.project_id)?.project_id??null,ze=(0,b.useMemo)(()=>e.tickets.map(e=>e.id).sort().join(`|`),[e.tickets]),Be=(0,b.useMemo)(()=>new Set(ze.length>0?ze.split(`|`):[]),[ze]),Ve=(0,b.useMemo)(()=>e.tickets.map(e=>`${e.id}:${e.build_completed_at??``}`).sort().join(`|`),[e.tickets]),He=Ne??G??e.tickets[0]??null,Ue=He??G,We=Ue?.id??null,Ge=Ne?se[Ne.id]??rQ(Ne.model,oe):`Agent`,Ke=Ne?.agent_status===`running`?Ge:null,qe=!K&&!!(G&&uv(G)),Je=gj(t??G?.state??null),Ye=qe&&c&&Ue?.tool===`opencode`,Xe=r.followUp||U,Ze=e.tickets.some(e=>e.agent_status===`running`),Qe=Ze?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,$e=He?`Follow up on: ${He.title}`:`Follow up on this bundle`,et=[{label:e.bundle.kind===`project_root`?`Project root branch`:`Worktree`,value:e.bundle.branch},{label:`Session`,value:he??``}],tt=!K,nt=k&&!j,rt=e.bundle.id,it=k?j?`expanded`:`split`:`closed`,at=nt?`flex h-[92vh] w-[98vw] max-w-[110rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,ot=nt?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)_minmax(30rem,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)_minmax(30rem,1fr)]`:tt?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)]`:`flex min-h-0 flex-1 flex-col`,st=j?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`fixed inset-4 z-[70] flex items-stretch justify-end bg-black/30 backdrop-blur-sm 2xl:hidden sm:inset-6 lg:inset-8`;(0,b.useEffect)(()=>{if(!a||K||!Re||ze.length===0){re({});return}let e=new AbortController;return ut(Re,null,e.signal).then(t=>{e.signal.aborted||re(t.suggestions.reduce((e,t)=>(!t.ticket_id||!Be.has(t.ticket_id)||(e[t.ticket_id]=(e[t.ticket_id]??0)+1),e),{}))}).catch(t=>{if(!e.signal.aborted){if(t instanceof S&&(t.status===404||t.status===409)){re({});return}re({})}}),()=>{e.abort()}},[Ve,Re,Be,ze,K,o,a]),(0,b.useEffect)(()=>{le(t=>{let n={...t},r=!1,i=new Set(e.tickets.map(e=>e.id));for(let t of e.tickets){let e=tQ(t.model,oe);!e||n[t.id]===e||(n[t.id]=e,r=!0)}for(let e of Object.keys(n))i.has(e)||(delete n[e],r=!0);return r?n:t})},[oe,e.tickets]),(0,b.useEffect)(()=>{if(We!==null&&B?.ticketId===We)if((Ue?.model??``)===B.model&&(Ue?.variant??``)===B.variant&&(Ue?.skills.length??0)===B.skills.length&&(Ue?.skills??[]).every((e,t)=>e===B.skills[t]))V(null);else return;I(Ue?.model??``),R(Ue?.variant??``),ee(Ue?.skills??[])},[Ue?.model,Ue?.skills,Ue?.variant,We,B]);let ct=async(e,t,n)=>{if(Ue){V({ticketId:Ue.id,model:e,variant:t,skills:n}),te(!0);try{let r=await ce(Ue.id,Ue.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});h?.(r)}catch(e){V(null),I(Ue.model??``),R(Ue.variant??``),ee(Ue.skills),X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{te(!1)}}},lt=async()=>{let t=D.trim();if(!t||Xe||Ze)return;let n=He?{id:`optimistic-follow-up-${Date.now()}`,ticket_id:He.id,role:`user`,kind:`follow_up`,content:t,created_at:new Date().toISOString(),displayTitle:`You`}:null;ne(!0),O(``),n&&ae(e=>[...e,n]);try{await w(e.bundle.id,t)}catch{n&&ae(e=>e.filter(e=>e.id!==n.id)),O(t)}finally{ne(!1)}},dt=Ye?(0,q.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:Ye&&(0,q.jsx)(oV,{model:F,variant:L,skills:z,showModelSelector:!0,showSkillsSelector:!0,availableModels:l,availableSkills:u,selectedModel:Le,onModelChange:e=>{let t=(l.find(t=>t.id===e)??null)?.variants.includes(L)?L:``;I(e),R(t),ct(e,t,z)},onVariantChange:e=>{R(e),ct(F,e,z)},onSkillsChange:e=>{ee(e),ct(F,L,e)},modelSelectId:`bundle-follow-up-model`,variantSelectId:`bundle-follow-up-variant`,skillsSelectId:`bundle-follow-up-skills`,disabled:H})}):void 0;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Iv,{onClose:d,overlayClassName:`bg-black/60 !z-40`,panelClassName:at,renderContent:({closeButton:t})=>(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(`div`,{"data-testid":`bundle-modal-layout`,"data-terminal-mode":it,className:`min-h-0 flex flex-1 flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:hv(e.bundle)}),me,e.bundle.pull_request&&(0,q.jsx)(uj,{pullRequest:e.bundle.pull_request,asLink:!0}),(0,q.jsxs)(Z,{variant:`outline`,children:[e.tickets.length,` tickets`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!K&&ge&&(0,q.jsx)(b_,{stats:ge,showFiles:!0,className:`text-xs`}),_e&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Changes`,onClick:()=>E(!0),variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),!K&&i&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open IDE`,onClick:p,variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),ye&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open terminal`,onClick:()=>{P(!0),A(!0)},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(D_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Terminal`})]}),t]})]}),(0,q.jsxs)(`div`,{className:ot,children:[tt&&(0,q.jsxs)(`aside`,{"data-testid":`bundle-modal-sidebar`,className:`flex min-h-0 flex-col gap-4`,children:[(0,q.jsx)(xM,{ariaLabel:`Ticket metadata`,items:et,className:`flex-col items-stretch gap-3`}),(0,q.jsx)(YZ,{tickets:e.tickets,onOpenTicketDetails:f,highlightedTicketId:He?.id??null,pendingMemorySuggestionCounts:W})]}),(0,q.jsxs)(`div`,{"data-testid":`bundle-modal-main`,className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[!K&&(0,q.jsx)(KZ,{projectId:G?.project_id??null,followUpTicketId:e.target_ticket_id,messages:fe,internalLog:Fe,thinkingTicketId:Ie,pendingAgentTitle:Ke,streamingResponse:Pe,isRunning:Ne?.agent_status===`running`,isLoading:n,canShowComposer:qe,layoutKey:rt,scrollLayoutKey:it,composerControls:dt,composerTheme:Je,followUpPrompt:D,followUpPlaceholder:$e,isSendingFollowUp:Xe,followUpDisabledReason:Qe,onFollowUpPromptChange:O,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ze||Xe||(e.preventDefault(),lt())},onFollowUpSubmit:()=>{lt()}}),K&&(0,q.jsx)(YZ,{tickets:e.tickets,onOpenTicketDetails:f,pendingMemorySuggestionCounts:W}),(0,q.jsx)(qZ,{bundleId:e.bundle.id,actionState:r,runDisabled:s,canBuild:xe,canStopBuild:we,runningBuildTicketId:Se?.id??null,canResumeBuild:Te,resumableBuildTicketId:Ce?.id??null,isRunning:Me,canRun:je,canReview:ke,reviewActionLabel:Ae,onClose:d,onBuildBundle:g,onStopBuildTicket:_,onResumeBuildTicket:v,onRunBundle:x,onStopBundle:C,onReviewBundle:y})]}),be&&G&&(0,q.jsx)(`div`,{className:k?nt?`min-h-0 flex flex-col overflow-hidden`:st:`hidden`,children:(0,q.jsx)(kZ,{createSession:()=>fM(G.id,G.project_id),isExpanded:j,isVisible:k,ariaLabel:`Bundle terminal`,title:`Terminal`,className:nt||j?`h-full w-full max-w-none rounded-2xl shadow-2xl`:`h-full w-full max-w-5xl rounded-2xl shadow-2xl`,onClose:()=>{A(!1),M(!1),P(!1),m(e.bundle.id)},onToggleExpanded:()=>{M(e=>!e)}})})]})]})})}),T&&G&&(0,q.jsx)(b.Suspense,{fallback:null,children:(0,q.jsx)(XZ,{ticketId:G.id,projectId:G.project_id,reviewCommentsBundleId:e.bundle.id,title:hv(e.bundle),onSubmitReviewPrompt:t=>w(e.bundle.id,t),canSubmitReviewPrompt:!Ze,reviewSubmitDisabledReason:Qe,canAddReviewComments:!Ze,canModifyChanges:!Ze,changesDisabledReason:Qe,onClose:()=>{E(!1),m(e.bundle.id)}})})]})},fQ=Ct(`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-3xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-9 min-w-9 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5`,sm:`h-8 min-w-8 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,lg:`h-10 min-w-10 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`}},defaultVariants:{variant:`default`,size:`default`}}),pQ=b.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function mQ({className:e,variant:t,size:n,spacing:r=0,orientation:i=`horizontal`,children:a,...o}){return(0,q.jsx)(gf,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:J(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-3xl data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,q.jsx)(pQ.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function hQ({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=b.useContext(pQ);return(0,q.jsx)(_f,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:J(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-3xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-3xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-3xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-3xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,fQ({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var gQ=`border-sky-400/30 bg-sky-400/10 text-sky-100`,_Q=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,vQ=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,yQ=e=>e.subject_type===`file`,bQ=({reviewComments:e,reviewFindings:t=[],githubComments:n=[],pendingFixCount:r,triggerMode:i=`full`,canSendReview:a,isSubmittingReview:o,reviewSubmitDisabledReason:s,onClearPendingFixes:c,onSubmitReview:l})=>(0,q.jsxs)(Hg,{children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,className:i===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":`Pending fixes`,disabled:r===0,children:[i===`compact`?(0,q.jsx)(Qb,{className:`h-4 w-4`}):(0,q.jsx)(`span`,{children:`Pending fixes`}),(0,q.jsx)(Z,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:r}),(0,q.jsx)(m_,{className:`h-4 w-4`})]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,q.jsxs)(Gg,{className:`flex-row items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Kg,{children:`Pending fixes`}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review selected comments and findings before sending them back to the agent.`})]}),(0,q.jsx)(Z,{variant:`outline`,children:r})]}),r===0?(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`No pending fixes selected yet.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:[e.map(e=>(0,q.jsx)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 px-3 py-3 shadow-sm`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(Qb,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-sky-200`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Manual comment`}),(0,q.jsx)(Z,{variant:`outline`,className:gQ,children:`Manual`})]}),(0,q.jsxs)(`div`,{className:`mt-1 text-xs text-sky-100/70`,children:[XE(e.scope),` · `,e.filePath,` · `,YE(e)]}),(0,q.jsx)(`div`,{className:`mt-2 rounded-lg border border-sky-500/15 bg-background/60 px-3 py-2`,children:(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-foreground`,children:e.comment})})]})]})},`${e.filePath}:${e.changeKey}`)),t.map(e=>(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(cy,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[`Finding `,e.ordinal]}),(0,q.jsx)(Z,{variant:`outline`,className:`capitalize`,children:e.severity})]}),(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,_Q(e)].filter(Boolean).join(` · `)}),(0,q.jsx)(`div`,{className:`mt-2 text-xs font-medium text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]})]})},e.id)),n.map(e=>(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(T_,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.kind===`review`?`GitHub review summary`:`GitHub review comment`}),(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,e.kind===`inline`&&!yQ(e)?vQ(e):e.author].filter(Boolean).join(` · `)}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]})]})},e.id))]}),(0,q.jsxs)(`div`,{className:`flex justify-between gap-2 pt-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:r===0||o,onClick:c,children:`Clear`}),(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`default`,disabled:!a,title:s,onClick:l,className:`gap-2`,children:[(0,q.jsx)(fj,{className:`h-4 w-4`}),o?`Sending...`:`Send fixes (${r})`]})]})]})]})]}),xQ=({commitMessage:e,onCommitMessageChange:t,commitMessageRef:n,selectedFileCount:r,changesDisabledReason:i,canEditCommitMessage:a=!0,canGenerateCommitMessage:o,canCommit:s,isGeneratingCommitMessage:c,isCommitting:l,onGenerateCommitMessage:u,onCommit:d})=>{let f=e.trim()===``;return(0,q.jsx)(`div`,{className:`rounded-2xl border border-border bg-background/40 px-4 py-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 xl:flex-row xl:items-center xl:gap-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 xl:w-56`,children:[(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Commit selected files`}),(0,q.jsx)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-muted-foreground`,children:(0,q.jsxs)(Z,{variant:`outline`,children:[r,` file`,r===1?``:`s`,` selected`]})})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,q.jsxs)(kg,{"data-disabled":!a,className:`flex-1`,children:[(0,q.jsx)(Pg,{"aria-label":`Commit message`,id:`ticket-changes-commit-message`,ref:n,value:e,onChange:e=>{t(e.target.value)},placeholder:`Commit message`,disabled:!a||c,title:i}),f&&(0,q.jsx)(jg,{align:`inline-end`,children:(0,q.jsx)(Ng,{"aria-label":`Generate commit message`,disabled:!o,onClick:u,title:i,children:c?`Generating...`:`Generate`})})]}),(0,q.jsxs)(Y,{type:`button`,onClick:d,disabled:!s,title:i,className:`w-full gap-2 sm:w-auto sm:min-w-32`,children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),l?`Committing...`:`Commit`]})]})]})})},SQ=({isCommitsLoading:e,commitsError:t,unpushedCommits:n,canUndoLatestCommit:r,isUndoing:i,aheadCount:a,onUndoLatestCommit:o})=>{if(!e&&n.length===0&&!t)return null;let s=n.length||a;return(0,q.jsxs)(Hg,{children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`gap-2`,children:[(0,q.jsx)(`span`,{children:`Local commits`}),(0,q.jsx)(Z,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:s}),(0,q.jsx)(m_,{className:`h-4 w-4`})]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[28rem] p-4`,children:[(0,q.jsxs)(Gg,{className:`flex-row items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Kg,{children:`Local commits`}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review what will be pushed from this branch.`})]}),!e&&!t&&(0,q.jsx)(Z,{variant:`outline`,children:n.length})]}),e?(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`Loading branch commits...`}):t?(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:o,disabled:!r,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5`}),i?`Undoing...`:`Undo latest commit`]})}),(0,q.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto`,children:n.map(e=>(0,q.jsxs)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.subject}),(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(Z,{variant:`outline`,className:`font-mono`,children:e.short_hash}),(0,q.jsx)(`span`,{children:new Date(e.committed_at).toLocaleString()})]})]},e.hash))})]})]})]})};function CQ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
168
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return gV.get()},set promptLabel(e){gV.set(e)},get tooMuchOutput(){return vV.get()},set tooMuchOutput(e){vV.set(e)}}}_verifyIntegers(...e){for(PY of e)if(PY===1/0||isNaN(PY)||PY%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(PY of e)if(PY&&(PY===1/0||isNaN(PY)||PY%1!=0||PY<0))throw Error(`This API only accepts positive integers`)}},IY=Object.create(null);IY.open=`0`,IY.close=`1`,IY.ping=`2`,IY.pong=`3`,IY.message=`4`,IY.upgrade=`5`,IY.noop=`6`;var LY=Object.create(null);Object.keys(IY).forEach(e=>{LY[IY[e]]=e});var RY={type:`error`,data:`parser error`},zY=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,BY=typeof ArrayBuffer==`function`,VY=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,HY=({type:e,data:t},n,r)=>zY&&t instanceof Blob?n?r(t):UY(t,r):BY&&(t instanceof ArrayBuffer||VY(t))?n?r(t):UY(new Blob([t]),r):r(IY[e]+(t||``)),UY=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function WY(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var GY;function KY(e,t){if(zY&&e.data instanceof Blob)return e.data.arrayBuffer().then(WY).then(t);if(BY&&(e.data instanceof ArrayBuffer||VY(e.data)))return t(WY(e.data));HY(e,!1,e=>{GY||=new TextEncoder,t(GY.encode(e))})}var qY=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,JY=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)JY[qY.charCodeAt(e)]=e;var YY=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=JY[e.charCodeAt(r)],o=JY[e.charCodeAt(r+1)],s=JY[e.charCodeAt(r+2)],c=JY[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},XY=typeof ArrayBuffer==`function`,ZY=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:$Y(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:QY(e.substring(1),t)}:LY[n]?e.length>1?{type:LY[n],data:e.substring(1)}:{type:LY[n]}:RY},QY=(e,t)=>XY?$Y(YY(e),t):{base64:!0,data:e},$Y=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},eX=``,tX=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{HY(e,!1,e=>{r[a]=e,++i===n&&t(r.join(eX))})})},nX=(e,t)=>{let n=e.split(eX),r=[];for(let e=0;e<n.length;e++){let i=ZY(n[e],t);if(r.push(i),i.type===`error`)break}return r};function rX(){return new TransformStream({transform(e,t){KY(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var iX;function aX(e){return e.reduce((e,t)=>e+t.length,0)}function oX(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function sX(e,t){iX||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(aX(n)<1)break;let e=oX(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(aX(n)<2)break;let e=oX(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(aX(n)<8)break;let e=oX(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(RY);break}i=a*2**32+t.getUint32(4),r=3}else{if(aX(n)<i)break;let e=oX(n,i);s.enqueue(ZY(a?e:iX.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(RY);break}}}})}function cX(e){if(e)return lX(e)}function lX(e){for(var t in cX.prototype)e[t]=cX.prototype[t];return e}cX.prototype.on=cX.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},cX.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},cX.prototype.off=cX.prototype.removeListener=cX.prototype.removeAllListeners=cX.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},cX.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},cX.prototype.emitReserved=cX.prototype.emit,cX.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},cX.prototype.hasListeners=function(e){return!!this.listeners(e).length};var uX=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),dX=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),fX=`arraybuffer`;function pX(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var mX=dX.setTimeout,hX=dX.clearTimeout;function gX(e,t){t.useNativeTimers?(e.setTimeoutFn=mX.bind(dX),e.clearTimeoutFn=hX.bind(dX)):(e.setTimeoutFn=dX.setTimeout.bind(dX),e.clearTimeoutFn=dX.clearTimeout.bind(dX))}var _X=1.33;function vX(e){return typeof e==`string`?yX(e):Math.ceil((e.byteLength||e.size)*_X)}function yX(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function bX(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function xX(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function SX(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var CX=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},wX=class extends cX{constructor(e){super(),this.writable=!1,gX(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new CX(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=ZY(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=xX(e);return t.length?`?`+t:``}},TX=class extends wX{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){nX(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,tX(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=bX()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},EX=!1;try{EX=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var DX=EX;function OX(){}var kX=class extends TX{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},AX=class e extends cX{constructor(e,t,n){super(),this.createRequest=e,gX(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=pX(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=OX,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(AX.requestsCount=0,AX.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,jX);else if(typeof addEventListener==`function`){let e=`onpagehide`in dX?`pagehide`:`unload`;addEventListener(e,jX,!1)}}function jX(){for(let e in AX.requests)AX.requests.hasOwnProperty(e)&&AX.requests[e].abort()}var MX=(function(){let e=PX({xdomain:!1});return e&&e.responseType!==null})(),NX=class extends kX{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=MX&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new AX(PX,this.uri(),e)}};function PX(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||DX))return new XMLHttpRequest}catch{}if(!t)try{return new dX[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var FX=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,IX=class extends wX{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=FX?{}:pX(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;HY(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&uX(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=bX()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},LX=dX.WebSocket||dX.MozWebSocket,RX={websocket:class extends IX{createSocket(e,t,n){return FX?new LX(e,t,n):t?new LX(e,t):new LX(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends wX{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=sX(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=rX();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&uX(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:NX},zX=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,BX=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function VX(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=zX.exec(e||``),a={},o=14;for(;o--;)a[BX[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=HX(a,a.path),a.queryKey=UX(a,a.query),a}function HX(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function UX(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var WX=typeof addEventListener==`function`&&typeof removeEventListener==`function`,GX=[];WX&&addEventListener(`offline`,()=>{GX.forEach(e=>e())},!1);var KX=class e extends cX{constructor(e,t){if(super(),this.binaryType=fX,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=VX(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=VX(t.host).host);gX(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=SX(this.opts.query)),WX&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},GX.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=vX(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,uX(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),WX&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=GX.indexOf(this._offlineEventListener);e!==-1&&GX.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};KX.protocol=4;var qX=class extends KX{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;KX.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;KX.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},JX=class extends qX{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>RX[e]).filter(e=>!!e)),super(e,n)}};JX.protocol;function YX(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=VX(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var XX=typeof ArrayBuffer==`function`,ZX=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,QX=Object.prototype.toString,$X=typeof Blob==`function`||typeof Blob<`u`&&QX.call(Blob)===`[object BlobConstructor]`,eZ=typeof File==`function`||typeof File<`u`&&QX.call(File)===`[object FileConstructor]`;function tZ(e){return XX&&(e instanceof ArrayBuffer||ZX(e))||$X&&e instanceof Blob||eZ&&e instanceof File}function nZ(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(nZ(e[t]))return!0;return!1}if(tZ(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return nZ(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&nZ(e[t]))return!0;return!1}function rZ(e){let t=[],n=e.data,r=e;return r.data=iZ(n,t),r.attachments=t.length,{packet:r,buffers:t}}function iZ(e,t){if(!e)return e;if(tZ(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=iZ(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=iZ(e[r],t));return n}return e}function aZ(e,t){return e.data=oZ(e.data,t),delete e.attachments,e}function oZ(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=oZ(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=oZ(e[n],t));return e}var sZ=c({Decoder:()=>dZ,Encoder:()=>uZ,PacketType:()=>lZ,isPacketValid:()=>vZ,protocol:()=>5}),cZ=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],lZ;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(lZ||={});var uZ=class{constructor(e){this.replacer=e}encode(e){return(e.type===lZ.EVENT||e.type===lZ.ACK)&&nZ(e)?this.encodeAsBinary({type:e.type===lZ.EVENT?lZ.BINARY_EVENT:lZ.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===lZ.BINARY_EVENT||e.type===lZ.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=rZ(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},dZ=class e extends cX{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===lZ.BINARY_EVENT;n||t.type===lZ.BINARY_ACK?(t.type=n?lZ.EVENT:lZ.ACK,this.reconstructor=new fZ(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(tZ(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(lZ[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===lZ.BINARY_EVENT||r.type===lZ.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!mZ(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case lZ.CONNECT:return gZ(t);case lZ.DISCONNECT:return t===void 0;case lZ.CONNECT_ERROR:return typeof t==`string`||gZ(t);case lZ.EVENT:case lZ.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&cZ.indexOf(t[0])===-1);case lZ.ACK:case lZ.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},fZ=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=aZ(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function pZ(e){return typeof e==`string`}var mZ=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function hZ(e){return e===void 0||mZ(e)}function gZ(e){return Object.prototype.toString.call(e)===`[object Object]`}function _Z(e,t){switch(e){case lZ.CONNECT:return t===void 0||gZ(t);case lZ.DISCONNECT:return t===void 0;case lZ.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&cZ.indexOf(t[0])===-1);case lZ.ACK:return Array.isArray(t);case lZ.CONNECT_ERROR:return typeof t==`string`||gZ(t);default:return!1}}function vZ(e){return pZ(e.nsp)&&hZ(e.id)&&_Z(e.type,e.data)}function yZ(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var bZ=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),xZ=class extends cX{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[yZ(e,`open`,this.onopen.bind(this)),yZ(e,`packet`,this.onpacket.bind(this)),yZ(e,`error`,this.onerror.bind(this)),yZ(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(bZ.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:lZ.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:lZ.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case lZ.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case lZ.EVENT:case lZ.BINARY_EVENT:this.onevent(e);break;case lZ.ACK:case lZ.BINARY_ACK:this.onack(e);break;case lZ.DISCONNECT:this.ondisconnect();break;case lZ.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:lZ.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:lZ.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function SZ(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}SZ.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},SZ.prototype.reset=function(){this.attempts=0},SZ.prototype.setMin=function(e){this.ms=e},SZ.prototype.setMax=function(e){this.max=e},SZ.prototype.setJitter=function(e){this.jitter=e};var CZ=class extends cX{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,gX(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new SZ({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||sZ;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new JX(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=yZ(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=yZ(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(yZ(e,`ping`,this.onping.bind(this)),yZ(e,`data`,this.ondata.bind(this)),yZ(e,`error`,this.onerror.bind(this)),yZ(e,`close`,this.onclose.bind(this)),yZ(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){uX(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new xZ(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},wZ={};function TZ(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=YX(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=wZ[i]&&a in wZ[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new CZ(r,t):(wZ[i]||(wZ[i]=new CZ(r,t)),c=wZ[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(TZ,{Manager:CZ,Socket:xZ,io:TZ,connect:TZ});var EZ=TZ(x),DZ=({label:e,onClick:t,children:n})=>(0,q.jsx)(Y,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),OZ=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,kZ=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,b.useRef)(null),d=(0,b.useRef)(null),f=(0,b.useRef)(null),p=(0,b.useRef)(null),m=(0,b.useRef)(e),h=(0,b.useRef)(!1),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(!0);return(0,b.useEffect)(()=>{m.current=e},[e]),(0,b.useEffect)(()=>{if(!u.current)return;let e=new FY({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new lV,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,AM(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&EZ.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(OZ(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};EZ.on(`terminal:ready`,s),EZ.on(`terminal:data`,c),EZ.on(`terminal:exit`,l),EZ.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&EZ.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,EZ.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||EZ.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),EZ.off(`terminal:ready`,s),EZ.off(`terminal:data`,c),EZ.off(`terminal:exit`,l),EZ.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,b.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(EZ.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,q.jsxs)(zv,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,q.jsx)(D_,{className:`h-4 w-4`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,q.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,q.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,q.jsx)(DZ,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,q.jsx)(Ny,{className:`h-4 w-4`}):(0,q.jsx)(Py,{className:`h-4 w-4`})}),(0,q.jsx)(DZ,{label:c,onClick:r,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]})]}),(0,q.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},AZ=`modulepreload`,jZ=function(e){return`/`+e},MZ={},NZ=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}))))}r=o(t.map(t=>{if(t=jZ(t,n),t in MZ)return;MZ[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:AZ,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}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)})},PZ=(0,b.lazy)(()=>NZ(()=>Promise.resolve().then(()=>V1).then(e=>({default:e.TicketChangesModal})),void 0)),FZ=`(min-width: 1280px)`,IZ=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,LZ=e=>{let[t,n]=(0,b.useState)(()=>IZ(e));return(0,b.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},RZ=({onClose:e})=>(0,q.jsx)(Iv,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading diff...`})}),zZ=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,q.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,q.jsx)(AB,{...s,header:({showThinkingControl:e})=>(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]})})]}),BZ=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,VZ=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],showModelSelector:i=!1,availableModels:a=[],availableSkills:o=[],projectBranchState:s=null,projectMemoryEnabled:c=!1,runDisabled:l=!1,runDisabledReason:u,onClose:d,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onUpdate:h,onDeleteDependency:g,onAdvance:_,onBuildChain:v,onRun:y,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)(!1),[L,R]=(0,b.useState)(!1),[z,ee]=(0,b.useState)(!1),[B,V]=(0,b.useState)(``),[H,te]=(0,b.useState)(!1),[U,ne]=(0,b.useState)(!1),[W,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(0),[G,oe]=(0,b.useState)(!1),[se,le]=(0,b.useState)(!1),[ue,de]=(0,b.useState)(null),K=k??e,[fe,pe]=(0,b.useState)(K.model??``),[me,he]=(0,b.useState)(K.variant??``),[ge,_e]=(0,b.useState)(K.skills??[]),[ve,ye]=(0,b.useState)(()=>BZ(K.model,a)??`Agent`),be=(0,b.useRef)(K.id),xe=(0,b.useRef)(null),Se=(0,b.useRef)(null),Ce=(0,b.useRef)(!1),we=(0,b.useRef)(K.id),Te=(0,b.useRef)(K.build_completed_at),Ee=LZ(FZ),[De,Oe]=(0,b.useState)(!1),[ke,Ae]=(0,b.useState)({model:K.model,variant:K.variant,skills:K.skills??[]}),Ne=K.state===`plan`,Pe=Mj(K.state),Fe=K.worktree_bundle_id!==null,Ie=Ne&&K.agent_status===`running`,Le=Ne&&K.agent_status===`error`,Re=Ne&&!Ie||j,ze=jj(K.state),Be=ze?Hj(K,ze):!1,Ve=ze?ze===`review`?`Review Bundle`:ze.charAt(0).toUpperCase()+ze.slice(1):null,He=async e=>{let t=await ce(K.id,K.project_id,e);return A(t),h?.(t),m&&await m(),t},Ue=async e=>{try{await He(e),d()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},We=async e=>{try{if(await He(e),!_){d();return}await _(),d()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ge=async()=>{!_||!Be||(await _(),d())},Ke=async e=>{try{if(await He(e),!v){d();return}await v(),d()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},qe=Ne?K.planning_session_id:K.session_id,Je=qe?qe.startsWith(`ses_`)?`opencode --session ${qe}`:`claude --resume ${qe}`:null,Ye=K.bundle?.branch??K.branch,Xe=K.has_worktree??!!Ye,Ze=!Re&&Pj(K)&&K.agent_status===`running`&&!!K.session_id&&!!C,Qe=!Re&&Pj(K)&&K.agent_status===`stopped`&&!!K.session_id&&!!T,$e=`Pause Build`,et=`Stop Build Chain`,tt=`Stop Run`,nt=new Map(t.map(e=>[e.id,e])),rt=n.filter(e=>e.blocker_ticket_id===K.id),it=n.filter(e=>e.dependent_ticket_id===K.id),at=oM(K,nt,n),ot=at.pendingBuildChainOrder.length>0?`Will build in order: ${at.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,st=at.skippedBuildChainCount>0?`Skips ${at.skippedBuildChainCount} ticket${at.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,ct=at.hasOpenBlockers,lt=Lj(K),ut=K.build_chain?.active_ticket_id?`Currently building ${nt.get(K.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,dt=K.build_chain&&K.build_chain.queued_ticket_ids.length>0?`Queued next: ${K.build_chain.queued_ticket_ids.map(e=>nt.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,ft=Ne&&!!_&&!at.hasOpenBlockers,pt=Ne&&!!v&&at.canStartBuildChain,mt=!!K.project_id&&!Ne&&!Fe,ht=Ne,gt=Fe&&!Ne,_t=!!K.project_id&&!!Ye&&Xe&&!Re&&!Ie&&!Fe,vt=!!K.project_id&&Xe&&!Re&&!Ie&&!!x&&!Fe,yt=mt&&!F,bt=mt&&z,xt=B.trim(),St=!Re&&!Ie&&K.state!==`plan`&&Xe&&!!E,Ct=ht&&U,wt=gt&&W,Tt=(K.planning_context?.open_questions.length??0)>0,Et=St&&i&&K.tool===`opencode`,Dt=a.find(e=>e.id===fe)??null,Ot=K.agent_status===`running`,kt=gM(K,{allTickets:t,preferBundleReviewStatus:!0}),At=K.skills??[],jt=Ot?`Wait for the current build to finish before sending a follow-up prompt.`:void 0,Mt=Ie?`Wait for planning to finish before sending another message.`:void 0,Nt=[...Ie?[]:[{label:`Worktree`,value:Ye??``}],{label:`Session`,value:Je??``},...Ie?[{label:K.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:K.bundle?.kind===`project_root`?K.bundle?hv(K.bundle):``:K.bundle?.name??``}]:Ne?[{label:`Bundle`,value:K.bundle?.name??``},{label:`Model`,value:K.model??``},{label:`Variant`,value:K.variant??``},{label:`Skills`,value:At.length>0?`${At.length} skill${At.length===1?``:`s`}`:``},{label:`Initiative`,value:K.planning_context?.initiative_prompt??``}]:[]],Pt=Ie?{model:K.model??``,variant:K.variant??``,skills:At}:null,Ft=ht&&U,It=gt&&W,Lt=(Ft||It)&&!Ee,Rt=Ft&&!Lt,zt=Rt||It&&!Lt,Bt=Ne&&(Ft||!Ee),Vt=F?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:zt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Lt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ht=F&&!L?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:zt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Ut=()=>{ee(!0),I(e=>(e&&R(!1),!e))},Wt=()=>{I(!1),R(!1),ee(!1),D?.(K.id)},Gt=()=>{le(!1),de(null)},Kt=()=>{le(!1),ue===`cancel_edit`&&!Ne?M(!1):d(),de(null)},qt=()=>{if(!Re){d();return}if(!G){d();return}de(`close_modal`),le(!0)},Jt=()=>{if(Ne){qt();return}if(!G){M(!1);return}de(`cancel_edit`),le(!0)};(0,b.useEffect)(()=>{A(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,b.useEffect)(()=>{if(we.current!==K.id){we.current=K.id,Te.current=K.build_completed_at;return}if(Te.current===K.build_completed_at)return;let e=Te.current;Te.current=K.build_completed_at,K.build_completed_at&&K.build_completed_at!==e&&ae(e=>e+1)},[K.build_completed_at,K.id]),(0,b.useEffect)(()=>{pe(K.model??``),he(K.variant??``),_e(K.skills??[])},[K.model,K.skills,K.variant]),(0,b.useEffect)(()=>{be.current!==K.id&&(be.current=K.id,ye(BZ(K.model,a)??`Agent`))},[a,K.id,K.model]),(0,b.useEffect)(()=>{let e=BZ(K.model,a);e&&ye(e)},[a,K.model]),(0,b.useEffect)(()=>{Ae({model:K.model,variant:K.variant,skills:K.skills??[]})},[K.id,K.model,K.skills,K.variant]),(0,b.useEffect)(()=>{Re||(oe(!1),le(!1),de(null))},[Re]),(0,b.useEffect)(()=>{G||(le(!1),de(null))},[G]),(0,b.useEffect)(()=>{if(!Ne){xe.current=null,Ce.current=!1;return}let e=xe.current!==K.id,t=!Ce.current&&Tt;(e&&Tt||t)&&ne(!0),xe.current=K.id,Ce.current=Tt},[Tt,Ne,K.id]),(0,b.useEffect)(()=>{if(!gt){Se.current=null;return}Se.current!==K.id&&re(!1),Se.current=K.id},[gt,K.id]);let Yt=async(e,t,n)=>{Oe(!0);try{let r=await ce(K.id,K.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});A(r),h?.(r)}catch(e){pe(K.model??``),he(K.variant??``),_e(K.skills??[]),X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Oe(!1)}},Xt=e=>{let t=(a.find(t=>t.id===e)??null)?.variants.includes(me)?me:``;pe(e),he(t),Yt(e,t,ge)},Zt=e=>{he(e),Yt(fe,e,ge)},Qt=e=>{_e(e),Yt(fe,me,e)},$t=async()=>{if(!(!E||H||Ot||!xt)){te(!0);try{await E(xt),V(``)}finally{te(!1)}}},en=async()=>{if(!(H||Ie||!xt||!Ct)){te(!0);try{let e=K.skills??[];if(ke.model!==K.model||ke.variant!==K.variant||ke.skills.length!==e.length||ke.skills.some((t,n)=>t!==e[n])){let e=await ce(K.id,K.project_id,{model:ke.model,variant:ke.variant,skills:ke.skills});A(e),h?.(e)}let t=await je(K.id,K.project_id,xt);A(t),h?.(t),V(``)}finally{te(!1)}}},tn=(K.messages??[]).filter(BM).map(e=>e.role===`assistant`?{...e,displayTitle:ve}:e.kind===`follow_up`?{...e,displayTitle:`You`}:e),nn=(K.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&BM(e)).map(e=>e.role===`assistant`?{...e,displayTitle:ve}:e.kind===`planning_follow_up`?{...e,displayTitle:`You`}:e),rn=Ft?(0,q.jsx)(zZ,{ariaLabel:`Planning chat`,title:`Planning Chat`,closeAriaLabel:`Close planning chat`,className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,description:Tt?(0,q.jsxs)(`p`,{children:[K.planning_context?.open_questions.length,` open question`,K.planning_context?.open_questions.length===1?``:`s`]}):void 0,projectId:K.project_id,followUpTicketId:null,messages:nn,internalLog:K.agent_log??null,streamingResponse:K.streaming_response??null,isRunning:K.agent_status===`running`,canShowComposer:Ct,pendingAgentTitle:ve,composerTheme:Pe,followUpPlaceholder:`Ask the agent to refine this plan`,emptyStateText:null,autoFocusComposer:U,followUpPrompt:B,isSendingFollowUp:H,followUpDisabledReason:Mt,onFollowUpPromptChange:V,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ie||H||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()},onClose:()=>{ne(!1)}}):It?(0,q.jsx)(zZ,{ariaLabel:`Ticket chat`,title:`Ticket Chat`,closeAriaLabel:`Close ticket chat`,className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,projectId:K.project_id,followUpTicketId:K.id,messages:tn,internalLog:K.agent_log??null,streamingResponse:K.streaming_response??null,isRunning:K.agent_status===`running`,canShowComposer:wt,pendingAgentTitle:ve,composerTheme:Pe,autoFocusComposer:W,followUpPrompt:B,isSendingFollowUp:H,followUpDisabledReason:jt,followUpComposerControls:Et?(0,q.jsx)(oV,{model:fe,variant:me,skills:ge,showModelSelector:!0,showSkillsSelector:!0,availableModels:a,availableSkills:o,selectedModel:Dt,onModelChange:Xt,onVariantChange:Zt,onSkillsChange:Qt,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:De}):void 0,onFollowUpPromptChange:V,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ot||H||(e.preventDefault(),$t())},onFollowUpSubmit:()=>{$t()},onClose:()=>{re(!1)}}):null;return(0,q.jsx)(Iv,{onClose:qt,overlayClassName:`bg-black/60`,panelClassName:Vt,renderContent:({closeButton:e})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[_t&&K.diff_stats&&(0,q.jsx)(b_,{stats:K.diff_stats,showFiles:!0,className:`text-xs`}),_t&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Changes`,onClick:()=>{D?.(K.id),P(!0)},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),vt&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open IDE`,onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),yt&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open terminal`,"aria-pressed":F,onClick:Ut,variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(D_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Terminal`})]}),(ht||gt)&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Chat`,"aria-pressed":Ne?U:W,onClick:()=>{if(Ne){ne(e=>!e);return}re(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(dx,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Chat`})]}),e]}),(0,q.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":F?L?`expanded`:`split`:`closed`,"data-side-chat-mode":zt?`inline`:Lt?`overlay`:`closed`,className:Ht,children:[(0,q.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Re?(0,q.jsxs)(q.Fragment,{children:[Le&&K.agent_log&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,q.jsx)(`span`,{className:`font-semibold`,children:`Planning failed: `}),K.agent_log]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(NM,{tool:K.tool,className:`text-[11px]`})}),(0,q.jsx)(PM,{externalSource:K.external_source}),(0,q.jsx)(GB,{heading:`Edit Ticket`,bundles:r,initialTitle:K.title,initialDescription:K.description??``,initialModel:K.model??``,initialVariant:K.variant??``,initialSkills:K.skills??[],initialWorktreeBundleId:K.worktree_bundle_id,projectBranchState:s,projectId:K.project_id,stackConfigurationSections:Rt&&!Bt,preferWideBundleSelector:Rt&&Bt,agentSettingsPresentation:Bt?`popover`:`panel`,showModelSelector:i,availableModels:a,availableSkills:o,onAgentSettingsChange:Ae,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onCancel:Jt,onDirtyChange:oe,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await ce(K.id,K.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});h?.(o),d(),await Me(K.id,K.project_id)}},primaryAction:{label:`Save`,variant:ft?`subtle`:`brand`,onClick:Ue},secondaryAction:ft?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:We}:void 0,tertiaryAction:pt?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:Ke}:void 0,beforeActionsContent:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)($B,{projectId:K.project_id,ticketId:K.id,memoryEnabled:c,refreshKey:ie,onSuggestionsChanged:O}),at.hasDependents&&(0,q.jsx)(VM,{summary:ot,detail:st}),(0,q.jsx)(NB,{blocks:rt,blockedBy:it,resolveTicket:e=>nt.get(e),onDeleteDependency:g})]}),footerLeadingContent:G?(0,q.jsx)(Z,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${K.id}:${K.updated_at}:${K.title}:${K.description}`)]}):(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:K.title}),(0,q.jsx)(NM,{tool:K.tool,className:`text-[11px]`}),(kt===`building`||kt===`done`)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[K.is_running&&(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,q.jsx)(fM,{status:kt,showBuildGlyph:!0})]}),kt!==null&&kt!==`building`&&kt!==`done`&&(0,q.jsx)(fM,{status:kt,showBuildGlyph:!0}),Tt&&(0,q.jsx)(Z,{variant:`warning`,children:`Open questions`}),lt&&(0,q.jsx)(Z,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Fe?(0,q.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,q.jsx)(eV,{content:K.description,externalSource:K.external_source})}):(0,q.jsx)(q.Fragment,{children:Ne?(0,q.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Ie?` mt-3`:``}`,children:(0,q.jsx)(eV,{content:K.description,externalSource:K.external_source})}):(0,q.jsx)(AB,{projectId:K.project_id,followUpTicketId:K.id,messages:tn,internalLog:K.agent_log??null,streamingResponse:K.streaming_response??null,isRunning:K.agent_status===`running`,canShowComposer:St,pendingAgentTitle:ve,composerTheme:Pe,followUpComposerControls:Et?(0,q.jsx)(oV,{model:fe,variant:me,skills:ge,showModelSelector:!0,showSkillsSelector:!0,availableModels:a,availableSkills:o,selectedModel:Dt,onModelChange:Xt,onVariantChange:Zt,onSkillsChange:Qt,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:De}):void 0,followUpPrompt:B,isSendingFollowUp:H,followUpDisabledReason:jt,onFollowUpPromptChange:V,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ot||H||(e.preventDefault(),$t())},onFollowUpSubmit:()=>{$t()}})}),Ie&&(0,q.jsxs)(`section`,{"aria-label":`Ticket metadata`,className:`flex flex-wrap items-center gap-2`,children:[Nt.filter(e=>e.value.trim().length>0).map(e=>(0,q.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,q.jsx)(IM,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,q.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,q.jsx)(jM,{model:Pt.model,variant:Pt.variant,skills:Pt.skills})})]}),!Ie&&!zt&&(0,q.jsx)(LM,{ariaLabel:`Ticket metadata`,items:Nt}),(0,q.jsx)($B,{projectId:K.project_id,ticketId:K.id,memoryEnabled:c,refreshKey:ie,onSuggestionsChanged:O}),(0,q.jsx)(NB,{blocks:rt,blockedBy:it,resolveTicket:e=>nt.get(e),onDeleteDependency:g}),K.build_chain&&(0,q.jsx)(VM,{summary:ut,detail:dt})]}),!Re&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,onClick:d,variant:`ghost`,children:`Close`}),Ze&&(0,q.jsxs)(Y,{type:`button`,onClick:C,title:`Pause the build session. You can resume it later.`,"aria-label":$e,variant:`warning`,children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),$e]}),K.build_chain&&w&&(0,q.jsxs)(Y,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":et,variant:`destructive`,children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),et]}),Qe&&(0,q.jsxs)(Y,{type:`button`,onClick:T,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),`Resume`]}),Ye&&!Re&&!Fe&&K.is_running&&S&&(0,q.jsxs)(Y,{type:`button`,onClick:S,title:`Stop the currently running ticket.`,"aria-label":tt,variant:`destructive`,children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),tt]}),Ye&&Xe&&!Ie&&!Re&&!Fe&&!K.is_running&&y&&(0,q.jsxs)(Y,{type:`button`,disabled:l,title:l?u??`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{l||y()},variant:`secondary`,className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),`Run`]}),!Re&&K.state===`build`&&!ct&&Ve&&_&&(0,q.jsxs)(Y,{type:`button`,disabled:!Be,onClick:()=>{Ge()},children:[Ve,(0,q.jsx)(Oj,{className:`w-3.5 h-3.5`})]})]})]})]}),zt&&rn,bt&&(0,q.jsx)(`div`,{className:F?L?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,q.jsx)(kZ,{createSession:()=>OM(K.id,K.project_id),isExpanded:L,isVisible:F,ariaLabel:`Ticket terminal`,className:L?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:Wt,onToggleExpanded:()=>{R(e=>!e)}})})]}),Lt&&rn,N&&(0,q.jsx)(b.Suspense,{fallback:(0,q.jsx)(RZ,{onClose:()=>{P(!1),D?.(K.id)}}),children:(0,q.jsx)(PZ,{ticketId:K.id,projectId:K.project_id,title:K.title,onTicketUpdate:h,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!Ot,reviewSubmitDisabledReason:jt,onClose:()=>{P(!1),D?.(K.id)}})}),se&&(0,q.jsx)(Lv,{title:`Discard unsaved edits?`,description:`Any changes made will be lost.`,confirmLabel:`Discard`,cancelLabel:`Keep editing`,confirmVariant:`destructive`,onConfirm:Kt,onCancel:Gt})]})})},HZ=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:x,onRetry:S,onAdvance:C,onPark:w,onUnpark:T,onBuildChain:E,onRun:D,onOpenChanges:O,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P,onOpenBundleDetails:F,onOpenTicketDetails:I,preferBundleDetailsOnClick:L=!1,hideBundleScopedControls:R=!1,hideStatusBadge:z=!1,onRequestTicketRefresh:ee,undoInProgress:B=!1})=>{let[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(!1),[ne,W]=(0,b.useState)(!1),[re,ie]=(0,b.useState)(!1),[ae,G]=(0,b.useState)(null),[oe,se]=(0,b.useState)(!1),[ce,le]=(0,b.useState)(!1),ue=e.agent_status===`running`||B,de=R,K=e.bundle?.branch??e.branch,fe=e.has_worktree??(e.state===`plan`?!1:!!K),pe=!R&&fe,me=oM(e,new Map(t.map(e=>[e.id,e])),n),he=jj(e.state),ge=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,_e=Fj(e),ve=Ij(e),ye=Lj(e),be=!R&&ve!==`plan`&&e.diff_stats===void 0,xe=(ye||_e)&&!a,Se=he?he===`review`?`Review Bundle`:he.charAt(0).toUpperCase()+he.slice(1):ge?`Re-run review`:null,Ce=Hj(e,`trash`),we=e.undo,Te=!!x&&we?.stage!==null,Ee=ge||(he?Hj(e,he):!1),De=!_e&&!!C&&!!Se&&!me.hasOpenBlockers,Oe=!!w&&Bj(e),ke=_e&&typeof e.state==`string`?`Return to ${e.state.charAt(0).toUpperCase()}${e.state.slice(1)}`:null,Ae=!!T&&ke!==null&&e.state!==`plan`,je=!_e&&!!E&&me.canStartBuildChain,Me=Pj(e)&&e.agent_status===`running`&&!!e.session_id&&!!j,Ne=Pj(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!N,Pe=pe&&!!O,Fe=pe&&!!k,Ie=!de&&fe&&!!K&&!e.is_running&&!!D,Le=!de&&fe&&!!K&&!!e.is_running&&!!A,Re=!!e.build_chain&&!!M,ze=!!y||Te||De||Oe||Ae||je||Me||Ne||Ie||Le||Pe||Fe||Re,Be=_e&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,Ve=async()=>{if(!(!D||c||oe)){se(!0);try{await D()}finally{se(!1)}}},He=async()=>{if(!(!A||ce)){le(!0);try{await A()}finally{le(!1)}}},Ue=!de&&fe&&K&&e.is_running&&A&&!B?(0,q.jsx)(mM,{isRunning:!0,isStopPending:ce,onStop:He}):!de&&fe&&K&&!e.is_running&&D?(0,q.jsx)(mM,{isRunning:!1,isRunPending:oe,runDisabled:c,runDisabledReason:l,onRun:Ve,className:Be}):null;(0,b.useEffect)(()=>{if(!re)return;let e=()=>{ie(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[re]);let We=()=>{if(a||re||B){ie(!1);return}if(L&&F){F();return}if(I){I();return}ee?.(e.id),W(!0)},{attributes:Ge,listeners:Ke,setNodeRef:qe,isDragging:Je}=nj({id:e.id,disabled:a||ue}),Ye=(0,b.useRef)(qe);(0,b.useEffect)(()=>{Ye.current=qe},[qe]);let Xe=(0,b.useCallback)(t=>{if(a){m?.(t);return}Ye.current(t),p?.(e.id,t)},[p,m,a,e.id]),Ze=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:me.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,Qe=a||B?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,$e=Je?`opacity-30`:xe?`opacity-90`:`opacity-100`,et=xe?`bg-card/60`:`bg-secondary/30`,tt=xe?`p-3 text-foreground/70`:`p-3`,nt=xe?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,rt=xe?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,it=xe?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,at=e.model??``,ot=!!e.bundle&&!R,st=!!e.bundle?.pull_request&&!R,ct=ot||st,lt=ct||at.length>0,ut=ae===e.id,dt=(0,b.useMemo)(()=>{let t=e.description??``;return t?Qz(t):{text:``,truncated:!1}},[e.description]);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(zv,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${Ze} ${Qe} ${$e} ${et} gap-0 rounded-xl border shadow-none`,ref:Xe,onClick:We,...Ke,...Ge,children:[B&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,q.jsxs)(Z,{variant:`warning`,className:`gap-1.5`,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,q.jsxs)(Wv,{className:tt,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(`div`,{className:nt,children:e.title})}),(0,q.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,q.jsx)(`div`,{className:`mr-1`,children:Ue}),(0,q.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,q.jsx)(u_,{content:`Draw dependency`,children:(0,q.jsx)(Y,{type:`button`,"aria-label":`Create dependency from ${e.title}`,variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),ie(!0),d(e.id,t)},children:(0,q.jsx)(uy,{className:`h-4 w-4`})})})}),(0,q.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:ze&&(0,q.jsx)(wM,{title:e.title,canDelete:Ce,undo:we,undoInProgress:B,runDisabled:c,isRunPending:oe,isStopPending:ce,showOpenChangesAction:Pe,showOpenIdeAction:Fe,showRunAction:Ie,showStopRunAction:Le,showAdvanceAction:De,advanceLabel:Se,canAdvance:Ee,showParkAction:Oe,showReturnAction:Ae,returnLabel:ke,showBuildChainAction:je,showPauseBuildAction:Me,showResumeBuildAction:Ne,showStopBuildChainAction:Re,onDelete:y,onConfirmDelete:()=>H(!0),onConfirmUndo:()=>U(!0),onOpenChanges:O,onOpenIde:k,onAdvance:C,onPark:w,onUnpark:T,onBuildChain:E,onRun:Ve,onStop:He,onStopBuild:j,onResumeBuild:N,onStopBuildChain:M})})]})]}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(DM,{ticket:e,hideStatusBadge:z,hideBundleScopedControls:R,isStale:ye,runControl:null,onRetry:S,undoInProgress:B,isChainStart:me.isVisibleStartPoint})}),lt&&(0,q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[ct&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${rt}`,children:[ot&&(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:hv(e.bundle)}),st&&e.bundle?.pull_request&&(0,q.jsx)(Ej,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),at.length>0&&(0,q.jsx)(`div`,{className:rt,children:(0,q.jsx)(`span`,{className:`truncate`,children:at})})]}),e.description&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(EM,{description:e.description,descriptionClass:it,isExpanded:ut,collapsedState:dt,useStaleLikeStyling:xe,onExpand:()=>G(e.id),onCollapse:()=>G(null)})}),!R&&(zj(ve,e.diff_stats)||be)&&(0,q.jsx)(b_,{stats:e.diff_stats,isLoading:be,showFiles:!0,className:`mt-2`})]})]}),ne&&(0,q.jsx)(VZ,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{W(!1),ee?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:C,onBuildChain:E,onRun:D,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P}),V&&(0,q.jsx)(TM,{title:e.title,bundleName:e.bundle?.name,onConfirm:()=>{H(!1),y?.()},onCancel:()=>H(!1)}),te&&we?.stage&&(0,q.jsx)(pM,{title:e.title,stage:we.stage,onConfirm:()=>{U(!1),x?.()},onCancel:()=>U(!1)})]})},UZ=({index:e})=>(0,q.jsx)(zv,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(y_,{className:`h-3.5 w-3/5 rounded-full`}),(0,q.jsx)(y_,{className:`h-5 w-11 rounded-full`})]}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(y_,{className:`h-3 w-full rounded-full`}),(0,q.jsx)(y_,{className:`h-3 w-11/12 rounded-full`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(y_,{className:`h-4 w-14 rounded-full`}),(0,q.jsx)(y_,{className:`h-4 w-10 rounded-full`})]}),(0,q.jsxs)(`span`,{className:`sr-only`,children:[`Loading card `,e+1]})]})}),WZ=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:x,onUpdateTicket:S,onDeleteTicket:C,onUndoTicket:w,undoingColumn:T=null,onRetryTicket:E,onAdvanceTicket:D,onParkTicket:O,onUnparkTicket:k,onBuildChainTicket:A,onRunTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:z,onFollowUpTicket:ee,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:H,onRunBundle:te,onStopBundle:U,onParkBundleWrapper:ne,onUnparkBundleWrapper:W,bundleActionState:re,onOpenTicketDetails:ie,onOpenBundleDetails:ae,onOpenBundleChanges:G,onOpenBundleIde:oe,onDeleteBundleWrapper:se,onRequestBundleRefresh:ce,onRequestTicketRefresh:le,className:ue=``,headerAccessory:de=null,loadingSkeletonCount:K=0})=>{let{setNodeRef:fe,isOver:pe}=oj({id:e}),me=(0,b.useRef)(null),[he,ge]=(0,b.useState)(!1),[_e,ve]=(0,b.useState)(!1),ye=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),be=pe?`border-primary`:`border-border`,xe=T===e&&(e===`build`||e===`review`),Se=(0,b.useCallback)(()=>{let e=me.current;if(!e){ge(!1),ve(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){ge(!1),ve(!1);return}let t=e.scrollHeight-e.clientHeight;ge(e.scrollTop>1),ve(e.scrollTop<t-1)},[]);(0,b.useEffect)(()=>{let e=window.requestAnimationFrame(Se),t=me.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,Se),window.addEventListener(`resize`,Se),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,Se),window.removeEventListener(`resize`,Se)}},[n.length,K,Se]);let Ce=(0,b.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,b=tM(t),T=u||l!==null&&l!==Nj(t)?`Stop the currently running ticket before starting another run.`:b;return(0,q.jsx)(HZ,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:T!==void 0,runDisabledReason:T,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:x,onUpdate:S,onDelete:()=>C(t.id),onUndo:w?()=>w(t.id):void 0,undoInProgress:!1,onRetry:()=>E(t.id),onAdvance:D?()=>D(t.id):void 0,onPark:O?()=>O(t.id):void 0,onUnpark:k?()=>k(t.id):void 0,onBuildChain:A?()=>A(t.id):void 0,onRun:ye(t)&&t.has_run_config&&j?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:z?()=>z(t.id):void 0,onFollowUp:ee?e=>ee(t.id,e):void 0,onOpenBundleDetails:_&&ae?()=>ae(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>ie(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:le})},[l,a,c,f,M,P,o,p,e,u,D,A,v,y,h,C,m,ee,ae,N,F,ie,O,x,g,le,z,E,j,R,L,I,w,k,S,s]);return(0,q.jsxs)(zv,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${ue} ${be}`,ref:fe,children:[(0,q.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[de,(0,q.jsx)(Z,{variant:`outline`,children:r}),_&&(0,q.jsxs)(Y,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,q.jsx)(`span`,{children:`+ New ticket`}),(0,q.jsx)(Z,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,q.jsxs)(`div`,{ref:me,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,q.jsx)(SM,{group:e.group,renderTicket:t=>Ce(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:H,onRunBundle:te,onStopBundle:U,onParkBundleWrapper:ne,onUnparkBundleWrapper:W,bundleActionState:re,onStopBuildTicket:L,onResumeBuildTicket:z,onOpenBundleDetails:ae,onOpenBundleChanges:G,onOpenBundleIde:oe,onDeleteBundleWrapper:se,onRequestBundleRefresh:ce},e.group.id);let t=e.ticket;return(0,q.jsx)(b.Fragment,{children:Ce(t)},t.id)}),Array.from({length:K},(t,n)=>(0,q.jsx)(UZ,{index:n},`loading-card-${e}-${n}`))]}),xe&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,q.jsxs)(Z,{variant:`warning`,className:`gap-1.5`,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),he&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),_e&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},GZ=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let i=e===1?`1 done ticket`:`${e} done tickets`;return(0,q.jsxs)(Iv,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Empty Done`}),(0,q.jsxs)(`p`,{className:`mb-2 text-sm text-foreground`,children:[`Delete `,i,` from the Done column?`]}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`Standalone ticket worktrees will be removed when applicable. Deleting the last parked ticket in a bundle also removes that shared bundle worktree.`}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:t?`Deleting...`:`Delete all`})]})]})},KZ=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,thinkingTicketId:i=null,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c=!1,canShowComposer:l,composerControls:u,composerTheme:d=`default`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h=`Follow up on this bundle`,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b})=>(0,q.jsx)(kB,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,thinkingTicketId:i,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c,autoScrollBehavior:`sticky`,canShowComposer:l,composerInlineControls:u,composerTheme:d,composerSize:`compact-on-laptop`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b}),qZ=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,q.jsxs)(Y,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,q.jsxs)(Y,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,q.jsx)(E_,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,q.jsxs)(Y,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,q.jsx)(w_,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,q.jsxs)(Y,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,q.jsx)(Oj,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},JZ=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,YZ=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,q.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,q.jsx)(Z,{variant:`outline`,children:e.length}),i>0&&(0,q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,q.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,q.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,q.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:J(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:J(`h-2 w-2 shrink-0 rounded-full`,JZ(e))}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,q.jsx)(NM,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,q.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,q.jsx)(Z,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,q.jsx)(Z,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},XZ=(0,b.lazy)(()=>NZ(()=>Promise.resolve().then(()=>V1).then(e=>({default:e.TicketChangesModal})),void 0)),ZZ=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,QZ=e=>e.replace(/\r\n/g,`
169
+ `).trim(),$Z=(e,t)=>e.ticket_id===t.ticket_id&&e.role===`user`&&t.role===`user`&&e.kind===`follow_up`&&t.kind===`follow_up`&&QZ(e.content)===QZ(t.content),eQ=(e,t)=>{if(t.length===0)return e;let n=new Set,r=new Set,i=new Map,a=[];for(let a of t){let t=[...e].reverse().find(e=>!r.has(e.id)&&!n.has(a.id)&&$Z(a,e));t&&(r.add(t.id),n.add(a.id),i.set(t.id,a))}for(let t of e){let e=i.get(t.id);if(e){a.push(e);continue}a.push(t)}for(let e of t)n.has(e.id)||a.push(e);return a},tQ=(e,t)=>e?t.get(e)??e:null,nQ=(e,t=[])=>{let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??e.bundle_execution_position??2**53-1,i=n.get(t.id)??t.bundle_execution_position??2**53-1;if(r!==i)return r-i;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let a=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return a===0?e.id.localeCompare(t.id):a})},rQ=(e,t)=>tQ(e,t)??`Agent`,iQ=(e,t)=>{let n={};for(let r of e){let e=tQ(r.model,t);e&&(n[r.id]=e)}return n},aQ=e=>e.kind===`planning_follow_up`||e.kind===`planning_response`?0:e.kind===`description`?1:2,oQ=(e,t,n,r=[])=>{let i=nQ(e,r),a=new Map(i.map((e,t)=>[e.id,t]));return i.flatMap(e=>{let r=e.messages??[],i=e.agent_status!==null||e.session_id!==null||r.some(e=>e.kind!==`description`&&BM(e)),o=r.filter(e=>BM(e)&&(i||e.kind!==`description`)),s=n[e.id]??rQ(e.model,t);return o.map(t=>t.role===`assistant`?{...t,displayTitle:s,ticketOrder:a.get(e.id)??2**53-1}:t.kind===`follow_up`?{...t,displayTitle:`You`,ticketOrder:a.get(e.id)??2**53-1}:{...t,displayTitle:e.title,ticketOrder:a.get(e.id)??2**53-1})}).sort((e,t)=>{if(e.ticket_id===t.ticket_id){let n=aQ(e)-aQ(t);if(n!==0)return n}let n=ZZ(e),r=ZZ(t);if(n!==r)return n.localeCompare(r);if(e.ticket_id!==t.ticket_id&&e.ticketOrder!==t.ticketOrder)return e.ticketOrder-t.ticketOrder;let i=aQ(e)-aQ(t);return i===0?e.id.localeCompare(t.id):i}).map(e=>{let{ticketOrder:t,...n}=e;return n})},sQ=e=>dv(e.tickets,{targetTicketId:e.target_ticket_id,reviewOwnerTicketId:e.review_owner_ticket_id,latestSessionTicketId:e.latest_session_ticket_id}),cQ=e=>e?e.startsWith(`ses_`)?`opencode --session ${e}`:`claude --resume ${e}`:null,lQ=(e,t)=>e.latest_session_id?cQ(e.latest_session_id):cQ(t?.session_id??null),uQ=(e,t)=>t?.diff_stats?t.diff_stats:e.find(e=>e.diff_stats)?.diff_stats??null,dQ=({details:e,activeColumn:t=null,isLoading:n=!1,actionState:r,canOpenIde:i,projectMemoryEnabled:a=!1,memorySuggestionsRefreshKey:o=0,runDisabled:s=!1,showModelSelector:c=!1,availableModels:l=[],availableSkills:u=[],onClose:d,onOpenTicketDetails:f,onOpenIde:p,onRefresh:m,onUpdateTicket:h,onBuildBundle:g,onStopBuildTicket:_,onResumeBuildTicket:v,onReviewBundle:y,onRunBundle:x,onStopBundle:C,onFollowUpBundle:w})=>{let[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)(``),[L,R]=(0,b.useState)(``),[z,ee]=(0,b.useState)([]),[B,V]=(0,b.useState)(null),[H,te]=(0,b.useState)(!1),[U,ne]=(0,b.useState)(!1),[W,re]=(0,b.useState)({}),[ie,ae]=(0,b.useState)([]),G=(0,b.useMemo)(()=>sQ(e),[e]),oe=(0,b.useMemo)(()=>new Map(l.map(e=>[e.id,e.label])),[l]),[se,le]=(0,b.useState)(()=>iQ(e.tickets,oe)),ue=(0,b.useMemo)(()=>nQ(e.tickets,e.execution_order_ticket_ids),[e.execution_order_ticket_ids,e.tickets]),de=t??G?.state??null,K=de===`plan`,fe=(0,b.useMemo)(()=>eQ(oQ(e.tickets,oe,se,e.execution_order_ticket_ids),ie),[oe,e.execution_order_ticket_ids,e.tickets,ie,se]),pe=(0,b.useMemo)(()=>_M(e.tickets,de),[de,e.tickets]),me=(0,b.useMemo)(()=>(0,q.jsx)(fM,{status:pe}),[pe]),he=(0,b.useMemo)(()=>lQ(e,G),[e,G]),ge=(0,b.useMemo)(()=>uQ(e.tickets,G),[e.tickets,G]),_e=!K&&!!(G?.project_id&&G&&uv(G)),ve=!K&&!!(G?.project_id&&G),ye=ve&&!k,be=ve&&N&&G!==null,xe=de===`plan`&&e.tickets.some(e=>e.state===`plan`),Se=ue.find(e=>Pj(e)&&e.agent_status===`running`&&!!e.session_id)??null,Ce=ue.find(e=>Pj(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,we=Se!==null,Te=!we&&Ce!==null,Ee=de===`build`&&e.tickets.some(e=>e.state===`build`)&&e.tickets.filter(e=>e.state===`build`).every(e=>e.agent_status===`done`),De=r.review||r.followUp,Oe=de===`review`&&e.can_re_review===!0&&!e.tickets.some(e=>e.agent_status===`running`)&&!De,ke=Ee||Oe,Ae=Oe?`Re-run review`:`Review Bundle`,je=e.tickets.some(e=>e.has_run_config&&eM(e)),Me=e.tickets.some(e=>e.is_running),Ne=e.tickets.find(e=>e.agent_status===`running`)??G,Pe=Ne?.streaming_response??null,Fe=Ne?.agent_log??null,Ie=Ne?.id??G?.id??null,Le=l.find(e=>e.id===F)??null,Re=G?.project_id??e.tickets.find(e=>e.project_id)?.project_id??null,ze=(0,b.useMemo)(()=>e.tickets.map(e=>e.id).sort().join(`|`),[e.tickets]),Be=(0,b.useMemo)(()=>new Set(ze.length>0?ze.split(`|`):[]),[ze]),Ve=(0,b.useMemo)(()=>e.tickets.map(e=>`${e.id}:${e.build_completed_at??``}`).sort().join(`|`),[e.tickets]),He=Ne??G??e.tickets[0]??null,Ue=He??G,We=Ue?.id??null,Ge=Ne?se[Ne.id]??rQ(Ne.model,oe):`Agent`,Ke=Ne?.agent_status===`running`?Ge:null,qe=!K&&!!(G&&uv(G)),Je=Mj(t??G?.state??null),Ye=qe&&c&&Ue?.tool===`opencode`,Xe=r.followUp||U,Ze=e.tickets.some(e=>e.agent_status===`running`),Qe=Ze?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,$e=He?`Follow up on: ${He.title}`:`Follow up on this bundle`,et=[{label:e.bundle.kind===`project_root`?`Project root branch`:`Worktree`,value:e.bundle.branch},{label:`Session`,value:he??``}],tt=!K,nt=k&&!j,rt=e.bundle.id,it=k?j?`expanded`:`split`:`closed`,at=nt?`flex h-[92vh] w-[98vw] max-w-[110rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,ot=nt?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)_minmax(30rem,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)_minmax(30rem,1fr)]`:tt?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)]`:`flex min-h-0 flex-1 flex-col`,st=j?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`fixed inset-4 z-[70] flex items-stretch justify-end bg-black/30 backdrop-blur-sm 2xl:hidden sm:inset-6 lg:inset-8`;(0,b.useEffect)(()=>{if(!a||K||!Re||ze.length===0){re({});return}let e=new AbortController;return ut(Re,null,e.signal).then(t=>{e.signal.aborted||re(t.suggestions.reduce((e,t)=>(!t.ticket_id||!Be.has(t.ticket_id)||(e[t.ticket_id]=(e[t.ticket_id]??0)+1),e),{}))}).catch(t=>{if(!e.signal.aborted){if(t instanceof S&&(t.status===404||t.status===409)){re({});return}re({})}}),()=>{e.abort()}},[Ve,Re,Be,ze,K,o,a]),(0,b.useEffect)(()=>{le(t=>{let n={...t},r=!1,i=new Set(e.tickets.map(e=>e.id));for(let t of e.tickets){let e=tQ(t.model,oe);!e||n[t.id]===e||(n[t.id]=e,r=!0)}for(let e of Object.keys(n))i.has(e)||(delete n[e],r=!0);return r?n:t})},[oe,e.tickets]),(0,b.useEffect)(()=>{if(We!==null&&B?.ticketId===We)if((Ue?.model??``)===B.model&&(Ue?.variant??``)===B.variant&&(Ue?.skills.length??0)===B.skills.length&&(Ue?.skills??[]).every((e,t)=>e===B.skills[t]))V(null);else return;I(Ue?.model??``),R(Ue?.variant??``),ee(Ue?.skills??[])},[Ue?.model,Ue?.skills,Ue?.variant,We,B]);let ct=async(e,t,n)=>{if(Ue){V({ticketId:Ue.id,model:e,variant:t,skills:n}),te(!0);try{let r=await ce(Ue.id,Ue.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});h?.(r)}catch(e){V(null),I(Ue.model??``),R(Ue.variant??``),ee(Ue.skills),X.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{te(!1)}}},lt=async()=>{let t=D.trim();if(!t||Xe||Ze)return;let n=He?{id:`optimistic-follow-up-${Date.now()}`,ticket_id:He.id,role:`user`,kind:`follow_up`,content:t,created_at:new Date().toISOString(),displayTitle:`You`}:null;ne(!0),O(``),n&&ae(e=>[...e,n]);try{await w(e.bundle.id,t)}catch{n&&ae(e=>e.filter(e=>e.id!==n.id)),O(t)}finally{ne(!1)}},dt=Ye?(0,q.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:Ye&&(0,q.jsx)(oV,{model:F,variant:L,skills:z,showModelSelector:!0,showSkillsSelector:!0,availableModels:l,availableSkills:u,selectedModel:Le,onModelChange:e=>{let t=(l.find(t=>t.id===e)??null)?.variants.includes(L)?L:``;I(e),R(t),ct(e,t,z)},onVariantChange:e=>{R(e),ct(F,e,z)},onSkillsChange:e=>{ee(e),ct(F,L,e)},modelSelectId:`bundle-follow-up-model`,variantSelectId:`bundle-follow-up-variant`,skillsSelectId:`bundle-follow-up-skills`,disabled:H})}):void 0;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Iv,{onClose:d,overlayClassName:`bg-black/60 !z-40`,panelClassName:at,renderContent:({closeButton:t})=>(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(`div`,{"data-testid":`bundle-modal-layout`,"data-terminal-mode":it,className:`min-h-0 flex flex-1 flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:hv(e.bundle)}),me,e.bundle.pull_request&&(0,q.jsx)(Ej,{pullRequest:e.bundle.pull_request,asLink:!0}),(0,q.jsxs)(Z,{variant:`outline`,children:[e.tickets.length,` tickets`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!K&&ge&&(0,q.jsx)(b_,{stats:ge,showFiles:!0,className:`text-xs`}),_e&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Changes`,onClick:()=>E(!0),variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Changes`})]}),!K&&i&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open IDE`,onClick:p,variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(S_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Open IDE`})]}),ye&&(0,q.jsxs)(Y,{type:`button`,"aria-label":`Open terminal`,onClick:()=>{P(!0),A(!0)},variant:`outline`,className:`gap-2`,children:[(0,q.jsx)(D_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`Terminal`})]}),t]})]}),(0,q.jsxs)(`div`,{className:ot,children:[tt&&(0,q.jsxs)(`aside`,{"data-testid":`bundle-modal-sidebar`,className:`flex min-h-0 flex-col gap-4`,children:[(0,q.jsx)(LM,{ariaLabel:`Ticket metadata`,items:et,className:`flex-col items-stretch gap-3`}),(0,q.jsx)(YZ,{tickets:e.tickets,onOpenTicketDetails:f,highlightedTicketId:He?.id??null,pendingMemorySuggestionCounts:W})]}),(0,q.jsxs)(`div`,{"data-testid":`bundle-modal-main`,className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[!K&&(0,q.jsx)(KZ,{projectId:G?.project_id??null,followUpTicketId:e.target_ticket_id,messages:fe,internalLog:Fe,thinkingTicketId:Ie,pendingAgentTitle:Ke,streamingResponse:Pe,isRunning:Ne?.agent_status===`running`,isLoading:n,canShowComposer:qe,layoutKey:rt,scrollLayoutKey:it,composerControls:dt,composerTheme:Je,followUpPrompt:D,followUpPlaceholder:$e,isSendingFollowUp:Xe,followUpDisabledReason:Qe,onFollowUpPromptChange:O,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ze||Xe||(e.preventDefault(),lt())},onFollowUpSubmit:()=>{lt()}}),K&&(0,q.jsx)(YZ,{tickets:e.tickets,onOpenTicketDetails:f,pendingMemorySuggestionCounts:W}),(0,q.jsx)(qZ,{bundleId:e.bundle.id,actionState:r,runDisabled:s,canBuild:xe,canStopBuild:we,runningBuildTicketId:Se?.id??null,canResumeBuild:Te,resumableBuildTicketId:Ce?.id??null,isRunning:Me,canRun:je,canReview:ke,reviewActionLabel:Ae,onClose:d,onBuildBundle:g,onStopBuildTicket:_,onResumeBuildTicket:v,onRunBundle:x,onStopBundle:C,onReviewBundle:y})]}),be&&G&&(0,q.jsx)(`div`,{className:k?nt?`min-h-0 flex flex-col overflow-hidden`:st:`hidden`,children:(0,q.jsx)(kZ,{createSession:()=>OM(G.id,G.project_id),isExpanded:j,isVisible:k,ariaLabel:`Bundle terminal`,title:`Terminal`,className:nt||j?`h-full w-full max-w-none rounded-2xl shadow-2xl`:`h-full w-full max-w-5xl rounded-2xl shadow-2xl`,onClose:()=>{A(!1),M(!1),P(!1),m(e.bundle.id)},onToggleExpanded:()=>{M(e=>!e)}})})]})]})})}),T&&G&&(0,q.jsx)(b.Suspense,{fallback:null,children:(0,q.jsx)(XZ,{ticketId:G.id,projectId:G.project_id,reviewCommentsBundleId:e.bundle.id,title:hv(e.bundle),onSubmitReviewPrompt:t=>w(e.bundle.id,t),canSubmitReviewPrompt:!Ze,reviewSubmitDisabledReason:Qe,canAddReviewComments:!Ze,canModifyChanges:!Ze,changesDisabledReason:Qe,onClose:()=>{E(!1),m(e.bundle.id)}})})]})},fQ=Ct(`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-3xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-9 min-w-9 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5`,sm:`h-8 min-w-8 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,lg:`h-10 min-w-10 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`}},defaultVariants:{variant:`default`,size:`default`}}),pQ=b.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function mQ({className:e,variant:t,size:n,spacing:r=0,orientation:i=`horizontal`,children:a,...o}){return(0,q.jsx)(gf,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:J(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-3xl data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,q.jsx)(pQ.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function hQ({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=b.useContext(pQ);return(0,q.jsx)(_f,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:J(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-3xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-3xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-3xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-3xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,fQ({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var gQ=`border-sky-400/30 bg-sky-400/10 text-sky-100`,_Q=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,vQ=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,yQ=e=>e.subject_type===`file`,bQ=({reviewComments:e,reviewFindings:t=[],githubComments:n=[],pendingFixCount:r,triggerMode:i=`full`,canSendReview:a,isSubmittingReview:o,reviewSubmitDisabledReason:s,onClearPendingFixes:c,onSubmitReview:l})=>(0,q.jsxs)(Hg,{children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,className:i===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":`Pending fixes`,disabled:r===0,children:[i===`compact`?(0,q.jsx)(dx,{className:`h-4 w-4`}):(0,q.jsx)(`span`,{children:`Pending fixes`}),(0,q.jsx)(Z,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:r}),(0,q.jsx)(m_,{className:`h-4 w-4`})]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,q.jsxs)(Gg,{className:`flex-row items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Kg,{children:`Pending fixes`}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review selected comments and findings before sending them back to the agent.`})]}),(0,q.jsx)(Z,{variant:`outline`,children:r})]}),r===0?(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`No pending fixes selected yet.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:[e.map(e=>(0,q.jsx)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 px-3 py-3 shadow-sm`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(dx,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-sky-200`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Manual comment`}),(0,q.jsx)(Z,{variant:`outline`,className:gQ,children:`Manual`})]}),(0,q.jsxs)(`div`,{className:`mt-1 text-xs text-sky-100/70`,children:[pD(e.scope),` · `,e.filePath,` · `,fD(e)]}),(0,q.jsx)(`div`,{className:`mt-2 rounded-lg border border-sky-500/15 bg-background/60 px-3 py-2`,children:(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-foreground`,children:e.comment})})]})]})},`${e.filePath}:${e.changeKey}`)),t.map(e=>(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(cy,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[`Finding `,e.ordinal]}),(0,q.jsx)(Z,{variant:`outline`,className:`capitalize`,children:e.severity})]}),(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,_Q(e)].filter(Boolean).join(` · `)}),(0,q.jsx)(`div`,{className:`mt-2 text-xs font-medium text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]})]})},e.id)),n.map(e=>(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(T_,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.kind===`review`?`GitHub review summary`:`GitHub review comment`}),(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,e.kind===`inline`&&!yQ(e)?vQ(e):e.author].filter(Boolean).join(` · `)}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]})]})},e.id))]}),(0,q.jsxs)(`div`,{className:`flex justify-between gap-2 pt-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:r===0||o,onClick:c,children:`Clear`}),(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`default`,disabled:!a,title:s,onClick:l,className:`gap-2`,children:[(0,q.jsx)(Oj,{className:`h-4 w-4`}),o?`Sending...`:`Send fixes (${r})`]})]})]})]})]}),xQ=({commitMessage:e,onCommitMessageChange:t,commitMessageRef:n,selectedFileCount:r,changesDisabledReason:i,canEditCommitMessage:a=!0,canGenerateCommitMessage:o,canCommit:s,isGeneratingCommitMessage:c,isCommitting:l,onGenerateCommitMessage:u,onCommit:d})=>{let f=e.trim()===``;return(0,q.jsx)(`div`,{className:`rounded-2xl border border-border bg-background/40 px-4 py-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 xl:flex-row xl:items-center xl:gap-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 xl:w-56`,children:[(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Commit selected files`}),(0,q.jsx)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-muted-foreground`,children:(0,q.jsxs)(Z,{variant:`outline`,children:[r,` file`,r===1?``:`s`,` selected`]})})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,q.jsxs)(kg,{"data-disabled":!a,className:`flex-1`,children:[(0,q.jsx)(Pg,{"aria-label":`Commit message`,id:`ticket-changes-commit-message`,ref:n,value:e,onChange:e=>{t(e.target.value)},placeholder:`Commit message`,disabled:!a||c,title:i}),f&&(0,q.jsx)(jg,{align:`inline-end`,children:(0,q.jsx)(Ng,{"aria-label":`Generate commit message`,disabled:!o,onClick:u,title:i,children:c?`Generating...`:`Generate`})})]}),(0,q.jsxs)(Y,{type:`button`,onClick:d,disabled:!s,title:i,className:`w-full gap-2 sm:w-auto sm:min-w-32`,children:[(0,q.jsx)(x_,{className:`h-4 w-4`}),l?`Committing...`:`Commit`]})]})]})})},SQ=({isCommitsLoading:e,commitsError:t,unpushedCommits:n,canUndoLatestCommit:r,isUndoing:i,aheadCount:a,onUndoLatestCommit:o})=>{if(!e&&n.length===0&&!t)return null;let s=n.length||a;return(0,q.jsxs)(Hg,{children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`gap-2`,children:[(0,q.jsx)(`span`,{children:`Local commits`}),(0,q.jsx)(Z,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:s}),(0,q.jsx)(m_,{className:`h-4 w-4`})]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[28rem] p-4`,children:[(0,q.jsxs)(Gg,{className:`flex-row items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Kg,{children:`Local commits`}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review what will be pushed from this branch.`})]}),!e&&!t&&(0,q.jsx)(Z,{variant:`outline`,children:n.length})]}),e?(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`Loading branch commits...`}):t?(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:o,disabled:!r,children:[(0,q.jsx)(Ky,{className:`h-3.5 w-3.5`}),i?`Undoing...`:`Undo latest commit`]})}),(0,q.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto`,children:n.map(e=>(0,q.jsxs)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.subject}),(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(Z,{variant:`outline`,className:`font-mono`,children:e.short_hash}),(0,q.jsx)(`span`,{children:new Date(e.committed_at).toLocaleString()})]})]},e.hash))})]})]})]})};function CQ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
170
170
  font-size: .6rem;
171
171
  font-weight: bold;
172
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function wQ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var TQ=(e,t)=>Math.abs(e-t)<1.01,EQ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},DQ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},OQ=e=>e,kQ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},AQ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(DQ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(DQ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},jQ={passive:!0},MQ=typeof window>`u`?!0:`onscrollend`in window,NQ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&MQ?()=>void 0:EQ(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,jQ);let l=e.options.useScrollendEvent&&MQ;return l&&n.addEventListener(`scrollend`,c,jQ),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},PQ=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},FQ=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},IQ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:OQ,rangeExtractor:kQ,onChange:()=>{},measureElement:PQ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=CQ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=CQ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=CQ(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=CQ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?RQ({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=CQ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=CQ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return wQ(t[LQ(0,t.length-1,e=>wQ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&TQ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},LQ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function RQ({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=LQ(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var zQ=typeof document<`u`?b.useLayoutEffect:b.useEffect;function BQ({useFlushSync:e=!0,...t}){let n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,kt.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=b.useState(()=>new IQ(r));return i.setOptions(r),zQ(()=>i._didMount(),[]),zQ(()=>i._willUpdate()),i}function VQ(e){return BQ({observeElementRect:AQ,observeElementOffset:NQ,scrollToFn:FQ,...e})}var HQ=8,UQ=520,WQ=2,GQ=()=>(0,q.jsx)(`div`,{"data-testid":`ticket-diff-resize-placeholder`,className:`space-y-4 px-3 py-3`,children:[{gutter:`w-8`,code:`w-[68%]`},{gutter:`w-10`,code:`w-[54%]`},{gutter:`w-8`,code:`w-[74%]`},{gutter:`w-6`,code:`w-[38%]`},{gutter:`w-10`,code:`w-[82%]`},{gutter:`w-7`,code:`w-[61%]`},{gutter:`w-9`,code:`w-[48%]`},{gutter:`w-8`,code:`w-[71%]`},{gutter:`w-11`,code:`w-[57%]`},{gutter:`w-7`,code:`w-[66%]`},{gutter:`w-9`,code:`w-[43%]`},{gutter:`w-8`,code:`w-[76%]`}].map((e,t)=>(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-resize-placeholder-row`,className:`flex items-center gap-4`,children:[(0,q.jsx)(`div`,{className:J(`h-4 rounded bg-muted/80`,e.gutter)}),(0,q.jsx)(`div`,{className:J(`h-4 rounded bg-muted/60`,e.code)})]},`${e.gutter}-${e.code}-${t}`))}),KQ=({additions:e,deletions:t,fileCount:n})=>n===null?[{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}]:[{key:`files`,content:`${n} file${n===1?``:`s`}`,className:`text-muted-foreground`},{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}],qQ=({control:e,mode:t})=>typeof e==`function`?e(t):e??null,JQ=e=>e.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+t.changes.length,0),0),YQ=e=>UE(e),XQ=(e,t)=>{let n=`oldPath`in e&&typeof e.oldPath==`string`?t(e.oldPath):``,r=`newPath`in e&&typeof e.newPath==`string`?t(e.newPath):``;return[...new Set([r,n].filter(e=>e&&e!==`/dev/null`))]},ZQ=e=>e.subject_type===`file`,QQ=e=>e.subject_type===`line`,$Q=`border-sky-400/30 bg-sky-400/10 text-sky-100`,e$=({context:e,comment:t,reviewDraftInput:n,canEdit:r,autoFocus:i,isReadOnly:a,hasSavedComment:o,onReviewDraftInputChange:s,onCancelReviewDraft:c,onEditReviewDraft:l,onRemoveReviewDraft:u,onSaveReviewDraft:d})=>{let f=(0,b.useRef)(null),[p,m]=(0,b.useState)(()=>n),h=YQ(e.change);return(0,b.useEffect)(()=>{!i||a||f.current?.focus({preventScroll:!0})},[i,a]),(0,q.jsxs)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 p-3 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(Z,{variant:`outline`,className:$Q,children:`Manual`}),(0,q.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-sky-100/80`,children:o?`Comment on line ${h}`:`Add a comment to line ${h}`})]}),(0,q.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[a?(0,q.jsx)(`div`,{className:`whitespace-pre-wrap rounded-xl border border-sky-500/15 bg-background/70 px-3 py-2.5 text-xs text-foreground`,children:t}):(0,q.jsx)(Og,{ref:f,"aria-label":`Review comment for ${e.filePath}`,value:p,onChange:e=>{m(e.target.value),s(e.target.value)},disabled:!r,className:`min-h-20 text-xs`,placeholder:`Add a review comment for this change`}),(0,q.jsx)(`div`,{className:`flex gap-2`,children:a?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{l(e.commentKey)},disabled:!r,children:[(0,q.jsx)(Uy,{className:`h-3.5 w-3.5`}),`Edit`]}),(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{u(e.commentKey)},disabled:!r,children:`Remove`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,size:`xs`,onClick:()=>{d(e,p)},disabled:!r||!p.trim(),children:`Add comment`}),(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:c,children:`Cancel`})]})})]})]})},t$=e=>e===`high`?`destructive`:e===`medium`?`warning`:`outline`,n$=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,r$=({finding:e,isSelected:t,onToggle:n})=>{let[r,i]=(0,b.useState)(!1);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-slate-400/30 bg-slate-400/10 p-3 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,q.jsx)(cy,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,q.jsx)(`div`,{children:`Finding ${e.ordinal}`}),(0,q.jsx)(Z,{variant:t$(e.severity),className:`normal-case`,children:e.severity})]}),(0,q.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]}),(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,q.jsx)(Ev,{className:`h-3.5 w-3.5`}),t?`Selected`:`Fix`]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:n$(e)}),e.file_path&&(0,q.jsx)(`span`,{children:e.file_path})]}),(e.why_text||e.fix_text)&&(0,q.jsxs)(`div`,{className:`mt-3`,children:[(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{i(e=>!e)},children:r?`Hide details`:`Details`}),r&&(0,q.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-xl border border-border bg-background/60 p-3 text-xs text-foreground`,children:[e.why_text&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Why it matters`}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.why_text})]}),e.fix_text&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Requested fix`}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.fix_text})]})]})]})]})},i$=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,a$=e=>e.old_line_number!==null||e.new_line_number!==null,o$=e=>e.kind===`review`?`Review summary`:ZQ(e)?`File comment`:a$(e)||QQ(e)?`Inline comment`:`File comment`,s$=({comment:e,isSelected:t,onToggle:n})=>(0,q.jsxs)(`div`,{className:`rounded-xl border border-violet-400/30 bg-violet-400/10 p-3 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,q.jsx)(Z,{variant:`outline`,className:`border-violet-400/40 bg-violet-400/10 text-violet-100`,children:`GitHub`}),(0,q.jsx)(`span`,{children:o$(e)}),e.is_outdated&&(0,q.jsx)(Z,{variant:`warning`,className:`normal-case`,children:`Outdated`})]}),(0,q.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.author}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]}),(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,q.jsx)(Ev,{className:`h-3.5 w-3.5`}),t?`Selected`:`Fix`]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[e.file_path&&(0,q.jsx)(`span`,{children:e.file_path}),e.kind===`inline`&&!ZQ(e)&&a$(e)&&(0,q.jsx)(`span`,{children:i$(e)}),(0,q.jsx)(`span`,{children:new Date(e.updated_at).toLocaleString()}),(0,q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-violet-200 underline underline-offset-2 transition-colors hover:text-violet-100`,children:`Open on GitHub`})]})]}),c$=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,reviewFindings:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of XQ(t,n))s.has(e)||s.set(e,t);for(let e of r){let n=e.file_path,r=n?s.get(n):null;if(!r||!n){o.push(e);continue}let c=t(r),l=null;for(let t of r.hunks){for(let n of t.changes)if(GE(e,n)){l=tT(n);break}if(l)break}if(l){let t=i.get(c)??new Map,n=t.get(l)??[];t.set(l,[...n,e]),i.set(c,t);continue}a.set(c,[...a.get(c)??[],e])}return{inlineByFilePath:i,fileLevelByFilePath:a,globalFindings:o}},l$=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,githubComments:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of XQ(t,n))s.has(e)||s.set(e,t);for(let e of r){if(e.kind===`review`||!e.file_path){o.push(e);continue}let n=s.get(e.file_path);if(!n){o.push(e);continue}let r=t(n);if(ZQ(e)||!e.subject_type&&!a$(e)){a.set(r,[...a.get(r)??[],e]);continue}let c=null;for(let t of n.hunks){for(let n of t.changes)if(WE(e,n)){c=tT(n);break}if(c)break}if(!c){o.push(e);continue}let l=i.get(r)??new Map,u=l.get(c)??[];l.set(c,[...u,e]),i.set(r,l)}return{inlineByFilePath:i,fileLevelByFilePath:a,fallbackComments:o}},u$=({filePath:e,hunks:t,activeReviewTarget:n,editingReviewCommentKey:r,reviewDraftInstanceKey:i,reviewDraftInput:a,reviewComments:o,reviewFindingsByChangeKey:s,githubCommentsByChangeKey:c,selectedReviewFindingIds:l,selectedGitHubCommentIds:u,canEditActiveReviewDraft:d,onToggleReviewFindingSelection:f,onToggleGitHubCommentSelection:p,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v})=>{let y=new Map(o.map(e=>[ZE(e.filePath,e.changeKey),e]));return t.reduce((t,o)=>{for(let b of o.changes){let x=tT(b),S=ZE(e,x),C=n?.commentKey===S,w=y.get(S),T=r===S,E=s.get(x)??[],D=c.get(x)??[];if(!C&&!w&&E.length===0&&D.length===0)continue;let O={filePath:e,changeKey:x,commentKey:S,hunk:o,change:b},k=!!w&&!T&&!C,A=k?w?.comment??``:a;t[x]=(0,q.jsxs)(`div`,{className:`space-y-3`,children:[E.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:l.includes(e.id),onToggle:()=>{f(e.id)}},e.id)),D.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:u.includes(e.id),onToggle:()=>{p(e.id)}},e.id)),(C||w)&&(0,q.jsx)(e$,{context:O,comment:w?.comment??``,reviewDraftInput:A,canEdit:d,autoFocus:C||T,isReadOnly:k,hasSavedComment:!!w,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v},`${i??O.commentKey}:${k?`readonly`:`editable`}`)]})}return t},{})},d$=e=>e.reduce((e,t)=>{for(let n of t.changes)e.set(tT(n),{hunk:t,change:n});return e},new Map),f$=(0,b.memo)(({selectedDiffPath:e,sidebarFiles:t,diffResponse:n,isDiffLoading:r,diffError:i,allDiffFiles:a,renderedFiles:o,viewType:s,onViewTypeChange:c,onRetry:l,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindings:h,githubComments:g,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canSelectReviewTarget:y,canEditActiveReviewDraft:x,reviewFindingsError:S,gitHubCommentsError:C,hasStaleReviewFindings:w,onSelectReviewTarget:T,onToggleReviewFindingSelection:E,onToggleGitHubCommentSelection:D,onReviewDraftInputChange:O,onCancelReviewDraft:k,onEditReviewDraft:A,onRemoveReviewDraft:j,onSaveReviewDraft:M,diffThemeClassName:N,resolveFilePath:P,normalizeDiffPath:F,emptyStateTitle:I=`No changes to show.`,emptyStateDescription:L=null,filePickerControl:R,reviewSummaryControl:z,extraHeaderControl:ee,headerLayout:B=`stacked`,surfaceVariant:V=`default`,showViewTypeToggle:H=!0,gutterVariant:te=`default`,isResizing:U=!1,resizePlaceholderLineThreshold:ne=1/0,onVisibleFilePathsChange:W})=>{let re=(0,b.useRef)(null),{mode:ie,ref:ae}=Zb({compactAt:V===`flat`?460:620,tightAt:V===`flat`?360:500}),G=!!n?.diff?.trim()||o.length>0||(n?.files.length??0)>0,oe=(0,b.useMemo)(()=>JQ(o),[o]),se=e===`all`&&o.length>=HQ,ce=U&&oe>ne,le=VQ({count:se?o.length:0,getScrollElement:()=>re.current,estimateSize:()=>UQ,overscan:WQ,initialRect:{width:0,height:900}}),ue=(0,b.useMemo)(()=>new Map(n?.files.map(e=>[e.path,e])??[]),[n?.files]),de=(0,b.useMemo)(()=>c$({allDiffFiles:a,resolveFilePath:P,normalizeDiffPath:F,reviewFindings:w?[]:h}),[a,w,F,P,h]),K=(0,b.useMemo)(()=>l$({allDiffFiles:a,resolveFilePath:P,normalizeDiffPath:F,githubComments:g}),[a,g,F,P]);(0,b.useEffect)(()=>{let e=re.current;e&&(e.scrollTop=0)},[e]),(0,b.useEffect)(()=>{let e=re.current;return()=>{let t=le;t.elementsCache?.forEach(e=>e.remove()),t.elementsCache?.clear(),window.getSelection()?.removeAllRanges(),e?.replaceChildren()}},[le]);let fe=le.getVirtualItems(),pe=(0,b.useMemo)(()=>se?fe.map(e=>P(o[e.index])):o.map(e=>P(e)),[o,P,se,fe]);(0,b.useEffect)(()=>{W?.(pe)},[W,pe]);let me=se&&fe.length>0?fe[0]?.start??0:0,he=se&&fe.length>0?Math.max(0,le.getTotalSize()-(fe[fe.length-1]?.end??0)):0,ge=se?fe.map(e=>({file:o[e.index],virtualItem:e})):o.map(e=>({file:e,virtualItem:null})),_e=e===`all`?null:t.find(t=>t.path===e)??null,ve=e===`all`?KQ({additions:n?.stats?.additions??0,deletions:n?.stats?.deletions??0,fileCount:n?.stats?.files_changed??null}):_e?KQ({additions:_e.additions,deletions:_e.deletions,fileCount:null}):[],ye=(0,b.useMemo)(()=>H?(0,q.jsxs)(mQ,{type:`single`,size:`sm`,variant:`outline`,value:s,onValueChange:e=>{(e===`split`||e===`unified`)&&c(e)},children:[(0,q.jsx)(hQ,{value:`unified`,children:`Unified`}),(0,q.jsx)(hQ,{value:`split`,children:`Split`})]}):null,[c,H,s]),be=(0,b.useMemo)(()=>[qQ({control:R,mode:ie}),qQ({control:z,mode:ie})].filter(Boolean),[R,ie,z]),xe=ye||be.length>0||ee;return(0,q.jsxs)(`section`,{className:J(`flex min-h-0 flex-1 flex-col overflow-hidden`,V===`default`?`rounded-2xl border border-border bg-background/30`:`bg-transparent`),children:[(0,q.jsx)(`div`,{ref:ae,"data-responsive-mode":ie,"data-testid":`ticket-diff-header`,className:J(`grid min-w-0 items-start gap-x-3 gap-y-2 border-b px-4 py-3`,V===`default`?`border-border`:`border-border/70 px-3`,B===`stacked`?ee?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`:xe?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:B===`stacked`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-left`,className:`grid min-w-0 gap-2`,children:[(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?`All changes`:e}),ve.length>0&&(0,q.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:ve.map(e=>(0,q.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),ye||be.length>0?(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-controls`,className:`flex min-w-0 flex-wrap items-center gap-2 justify-start`,children:[ye?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:ye}):null,be.length>0?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 items-center gap-2 justify-start`,children:be.map((e,t)=>(0,q.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null]}):null]}),ee?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:ee}):null]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?`All changes`:e}),ve.length>0&&(0,q.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:ve.map(e=>(0,q.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),xe?(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-inline-controls`,className:`flex min-w-0 flex-wrap items-start justify-end gap-2`,children:[ye?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:ye}):null,be.length>0?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:be.map((e,t)=>(0,q.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null,ee?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:ee}):null]}):null]})}),(0,q.jsx)(`div`,{ref:re,"data-testid":`ticket-diff-scroll-region`,className:`min-h-0 flex-1 overflow-auto`,children:(0,q.jsxs)(`div`,{className:J(`min-h-full pb-4 pt-4`,V===`default`?`px-4`:`px-0`),children:[r&&(0,q.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading diff...`}),!r&&i&&(0,q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-4 text-center`,children:[(0,q.jsx)(`p`,{className:`max-w-md text-sm text-rose-300`,children:i}),(0,q.jsx)(Y,{type:`button`,variant:`outline`,onClick:l,children:`Retry`})]}),!r&&!i&&n&&!G&&(0,q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 text-center`,children:[(0,q.jsx)(`div`,{className:`text-sm text-foreground`,children:I}),L&&(0,q.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:L})]}),!r&&!i&&n&&G&&e!==`all`&&o.length===0&&(0,q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 text-center`,children:[(0,q.jsx)(`div`,{className:`text-sm text-foreground`,children:`No renderable diff for this file in the UI.`}),(0,q.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:e})]}),!r&&!i&&n&&G&&o.length>0&&ce&&(0,q.jsx)(GQ,{}),!r&&!i&&n&&G&&o.length>0&&!ce&&(0,q.jsxs)(`div`,{className:J(`archon-diff-viewer`,te===`compact`&&`archon-diff-viewer--compact-gutter`,e===`all`&&V===`default`&&`space-y-6`,e===`all`&&V===`flat`&&`space-y-0`,N),children:[S&&(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:S}),C&&(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:C}),de.globalFindings.length>0&&(0,q.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:`Review findings`}),(0,q.jsx)(`div`,{className:`space-y-3`,children:de.globalFindings.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{E(e.id)}},e.id))})]}),e===`all`&&K.fallbackComments.length>0&&(0,q.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:`GitHub review comments`}),(0,q.jsx)(`div`,{className:`space-y-3`,children:K.fallbackComments.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{D(e.id)}},e.id))})]}),me>0&&(0,q.jsx)(`div`,{style:{height:me}}),ge.map(({file:t,virtualItem:n})=>{let r=P(t),i=ue.get(r),a=d$(t.hunks),o=de.inlineByFilePath.get(r)??new Map,c=K.inlineByFilePath.get(r)??new Map,l=de.fileLevelByFilePath.get(r)??[],h=K.fileLevelByFilePath.get(r)??[],g=d?m.find(e=>ZE(e.filePath,e.changeKey)===d)??null:null,b=[...m.filter(e=>e.filePath===r).map(e=>e.changeKey),...u?.filePath===r?[u.changeKey]:[],...g?.filePath===r?[g.changeKey]:[]],S=u$({filePath:r,hunks:t.hunks,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindingsByChangeKey:o,githubCommentsByChangeKey:c,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canEditActiveReviewDraft:x,onToggleReviewFindingSelection:E,onToggleGitHubCommentSelection:D,onReviewDraftInputChange:O,onCancelReviewDraft:k,onEditReviewDraft:A,onRemoveReviewDraft:j,onSaveReviewDraft:M}),C=(0,q.jsx)(VT,{diffType:t.type,hunks:t.hunks,tokens:t.tokens,viewType:s,selectedChanges:[...new Set(b)],widgets:S,renderGutter:({change:e,side:t,renderDefault:n,wrapInAnchor:r,inHoverState:i})=>{if(!e)return r(n());let a=tT(e),o=t===`new`,c=y&&t===`new`,l=s===`unified`&&e.type===`normal`&&t===`new`?null:r(n());return(0,q.jsxs)(`div`,{className:J(`flex items-center justify-end pr-1`,te===`compact`?`gap-1 pr-0.5`:`gap-2`),children:[l,o&&(0,q.jsx)(`span`,{"data-diff-gutter-action-slot":`true`,className:[te===`compact`?`flex size-5 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`:`flex size-6 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`,c&&i?`border-emerald-200 bg-emerald-300 opacity-100`:`opacity-0`,!c&&`pointer-events-none`].join(` `),"aria-hidden":`true`,children:(0,q.jsx)(Ev,{className:te===`compact`?`h-3 w-3`:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`sr-only`,children:a})]})},gutterEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(tT(e));t&&T({filePath:r,changeKey:tT(e),commentKey:ZE(r,tT(e)),hunk:t.hunk,change:t.change})}},codeEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(tT(e));t&&T({filePath:r,changeKey:tT(e),commentKey:ZE(r,tT(e)),hunk:t.hunk,change:t.change})}},children:e=>e.map(e=>(0,q.jsx)(IT,{hunk:e},`${r}-${e.content}`))});return e===`all`?(0,q.jsx)(`div`,{"data-index":n?.index,ref:n?le.measureElement:void 0,children:(0,q.jsxs)(`section`,{className:J(V===`default`?`rounded-xl border border-border bg-card/70`:`border-t border-border/70 bg-transparent first:border-t-0`),children:[(0,q.jsxs)(`div`,{className:J(`sticky top-0 z-20 border-b text-xs font-medium text-foreground`,V===`default`?`rounded-t-xl border-border bg-card px-4 py-3`:`border-border/70 bg-background/95 px-3 py-2.5 backdrop-blur-sm`),children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[`oldPath`in t&&typeof t.oldPath==`string`&&F(t.oldPath)===`/dev/null`&&(0,q.jsx)(Z,{variant:`success`,className:`shrink-0`,children:`New file`}),(0,q.jsx)(`span`,{children:r})]}),i&&(0,q.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs`,children:[(0,q.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`+`,i.additions]}),(0,q.jsxs)(`span`,{className:`font-mono text-rose-400`,children:[`-`,i.deletions]})]})]}),(0,q.jsxs)(`div`,{className:J(`overflow-x-auto`,V===`default`?`p-3`:`px-0 py-3`),children:[l.length>0&&(0,q.jsx)(`div`,{className:J(`mb-3 space-y-3`,V===`flat`&&`px-3`),children:l.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),h.length>0&&(0,q.jsx)(`div`,{className:J(`mb-3 space-y-3`,V===`flat`&&`px-3`),children:h.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{D(e.id)}},e.id))}),C]})]})},`${r}-${t.type??`modify`}`):(0,q.jsxs)(`div`,{"data-index":n?.index,ref:n?le.measureElement:void 0,children:[l.length>0&&(0,q.jsx)(`div`,{className:`mb-3 space-y-3`,children:l.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),h.length>0&&(0,q.jsx)(`div`,{className:`mb-3 space-y-3`,children:h.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{D(e.id)}},e.id))}),C]},`${r}-${t.type??`modify`}`)}),he>0&&(0,q.jsx)(`div`,{style:{height:he}})]})]})})]})});f$.displayName=`TicketChangesDiffPanel`;var p$=e=>J(`group`,e?`border-sky-700 bg-card/95 shadow-sm`:`border-border/50 bg-transparent text-muted-foreground hover:border-border/80 hover:bg-accent/60 hover:text-accent-foreground hover:shadow-sm`),m$={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},h$={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},g$=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},_$=({selectionWarning:e,gitError:t,sidebarFiles:n,commentCountByPath:r,commentCountTone:i,isGitStatusLoading:a,selectedPaths:o,selectedDiffPath:s,allFilesSelected:c,diffStats:l,title:u=`Changed files`,allChangesDescription:d=`Review the full workspace diff.`,enableSelection:f=!0,onToggleSelectAll:p,onSelectDiffPath:m,onTogglePath:h})=>{let g=i===`bundle_diff`?`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`;return(0,q.jsxs)(`aside`,{className:`flex min-h-0 h-full flex-col between overflow-hidden rounded-2xl border border-border bg-background/40`,children:[(e||t)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-border p-4`,children:[e&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:e}),t&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:u}),(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.length,` file`,n.length===1?``:`s`,` changed`]})]}),f&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:n.length===0,children:c?`Unselect all`:`Select all`})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[a&&(0,q.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading file list...`}),!a&&n.length===0&&(0,q.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`No changes to review.`}),!a&&n.length>0&&(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>{m(`all`)},className:J(`flex w-full items-start justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors`,p$(s===`all`)),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`All changes`}),l&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[l.files_changed,` file`,l.files_changed===1?``:`s`]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,l.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,l.deletions]})]})]}),(0,q.jsx)(`div`,{className:`mt-1 flex w-full flex-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:d})]})}),n.map(e=>{let t=f&&o.has(e.path),n=s===e.path,i=r.get(e.path)??0;return(0,q.jsxs)(`div`,{className:J(`flex items-start gap-2.5 rounded-xl border px-2.5 py-2 transition-colors`,p$(n)),children:[f&&(0,q.jsx)(`input`,{type:`checkbox`,"aria-label":e.path,checked:t,onChange:()=>{h(e.path)},className:`mt-0.5 h-4 w-4 rounded border-border bg-background text-primary`}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.path)},className:`min-w-0 flex-1 text-left cursor-pointer`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-1 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:g$(e.path)}),i>0&&(0,q.jsx)(`span`,{"aria-label":`${i} comment${i===1?``:`s`} in ${e.path}`,className:g,children:i})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})]}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[e.status&&(0,q.jsx)(Z,{variant:`outline`,className:m$[e.status],children:h$[e.status]}),e.staged&&(0,q.jsx)(Z,{variant:`outline`,children:`Staged`}),e.unstaged&&(0,q.jsx)(Z,{variant:`outline`,children:`Unstaged`}),e.conflicted&&(0,q.jsx)(Z,{variant:`destructive`,children:`Conflicted`}),e.originalPath&&(0,q.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:e.status===`renamed`?`from ${e.originalPath}`:e.originalPath})]})]})]},`${e.path}:${e.originalPath??``}`)})]})]})]})},v$=[`[--diff-background-color:transparent]`,`[--diff-text-color:rgb(226_232_240)]`,`[--diff-selection-background-color:rgba(148,163,184,0.2)]`,`[--diff-gutter-insert-background-color:rgba(34,197,94,0.16)]`,`[--diff-gutter-delete-background-color:rgba(244,63,94,0.16)]`,`[--diff-gutter-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-code-insert-background-color:rgba(34,197,94,0.08)]`,`[--diff-code-delete-background-color:rgba(244,63,94,0.08)]`,`[--diff-code-insert-edit-background-color:rgba(34,197,94,0.22)]`,`[--diff-code-delete-edit-background-color:rgba(244,63,94,0.22)]`,`[--diff-code-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-font-family:var(--font-mono)]`,`[&_.diff]:w-full`,`[&_.diff]:border-collapse`,`[&_.diff]:font-mono`,`[&_.diff-code]:whitespace-pre-wrap`,`[&_.diff-code]:break-words`,`[&_.diff-gutter]:select-none`].join(` `),y$=25e4,b$=2e3,x$=new Map,S$=e=>e?e.split(`
173
- `).length:0,C$=e=>{let t=e.diff??``;return t?t.length<=y$&&S$(t)<=b$:!0},w$=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,T$=e=>e?x$.get(e)??null:null,E$=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!C$(t)){x$.delete(e);return}x$.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},D$=e=>{e&&x$.delete(e)},O$={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},k$=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return O$[a]??null},A$=new Set,j$=e=>{e&&A$.forEach(t=>t(e))},M$=e=>(A$.add(e),()=>{A$.delete(e)}),N$=300,P$=(e,t={})=>{let n=t.dedupeMs??N$,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},F$=s(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),I$=s(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),L$=s(((e,t)=>{var n=F$(),r=I$();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),R$=s(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),z$=s(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),B$=s((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),V$=s(((e,t)=>{var n=z$(),r=B$();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),H$=s(((e,t)=>{var n=R$(),r=I$(),i=V$();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),U$=s(((e,t)=>{t.exports=H$()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),W$=s(((e,t)=>{t.exports=H$()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),G$=s(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),K$=s(((e,t)=>{var n=G$();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),q$=s(((e,t)=>{t.exports=H$()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:K$(),properties:{xmlns:null,xmlnsXLink:null}})})),J$=s(((e,t)=>{var n=B$(),r=H$(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),Y$=s(((e,t)=>{var n=B$(),r=H$(),i=K$(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),X$=s(((e,t)=>{var n=L$(),r=U$();t.exports=n([W$(),r,q$(),J$(),Y$()])})),Z$=s(((e,t)=>{var n=R$(),r=V$(),i=z$(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),Q$=s(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),$$=s((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),e1=s((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),t1=s(((e,t)=>{var n=Z$(),r=R$(),i=Q$(),a=$$().parse,o=e1().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),n1=s(((e,t)=>{var n=X$(),r=t1()(n,`div`);r.displayName=`html`,t.exports=r})),r1=s(((e,t)=>{t.exports=n1()})),i1=c({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>a1,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>`­`,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),a1,o1=o((()=>{a1={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:`­`,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),s1=c({default:()=>c1}),c1,l1=o((()=>{c1={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),u1=s(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),d1=s(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),f1=s(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),p1=s(((e,t)=>{var n=f1(),r=u1();t.exports=i;function i(e){return n(e)||r(e)}})),m1=s(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),h1=s(((e,t)=>{var n=(o1(),d(i1).default),r=(l1(),d(s1).default),i=u1(),a=d1(),o=p1(),s=m1();t.exports=R;var c={}.hasOwnProperty,l=String.fromCharCode,u=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=o,k[D]=i,k[E]=a;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),z(e,n)}function z(e,t){var i=t.additional,a=t.nonTerminated,d=t.text,f=t.reference,R=t.warning,z=t.textContext,V=t.referenceContext,H=t.warningContext,te=t.position,U=t.indent||[],ne=e.length,W=0,re=-1,ie=te.column||1,ae=te.line||1,G=``,oe=[],se,ce,le,ue,de,K,fe,pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce,we;for(typeof i==`string`&&(i=i.charCodeAt(0)),xe=Te(),pe=R?Ee:u,W--,ne++;++W<ne;)if(de===m&&(ie=U[re]||1),de=e.charCodeAt(W),de===_){if(fe=e.charCodeAt(W+1),fe===p||fe===m||fe===h||fe===g||fe===_||fe===y||fe!==fe||i&&fe===i){G+=l(de),ie++;continue}for(ve=W+1,_e=ve,we=ve,fe===x?(we=++_e,fe=e.charCodeAt(we),fe===S||fe===C?(ye=E,we=++_e):ye=D):ye=T,se=``,ge=``,ue=``,be=k[ye],we--;++we<ne&&(fe=e.charCodeAt(we),be(fe));)ue+=l(fe),ye===T&&c.call(n,ue)&&(se=ue,ge=n[ue]);le=e.charCodeAt(we)===v,le&&(we++,ce=ye===T?s(ue):!1,ce&&(se=ue,ge=ce)),Ce=1+we-ve,!le&&!a||(ue?ye===T?(le&&!ge?pe(P,1):(se!==ue&&(we=_e+se.length,Ce=1+we-_e,le=!1),le||(me=se?A:M,t.attribute?(fe=e.charCodeAt(we),fe===b?(pe(me,Ce),ge=null):o(fe)?ge=null:pe(me,Ce)):pe(me,Ce))),K=ge):(le||pe(j,Ce),K=parseInt(ue,O[ye]),ee(K)?(pe(I,Ce),K=l(w)):K in r?(pe(F,Ce),K=r[K]):(he=``,B(K)&&pe(F,Ce),K>65535&&(K-=65536,he+=l(K>>>10|55296),K=56320|K&1023),K=he+l(K))):ye!==T&&pe(N,Ce)),K?(De(),xe=Te(),W=we-1,ie+=we-ve+1,oe.push(K),Se=Te(),Se.offset++,f&&f.call(V,K,{start:xe,end:Se},e.slice(ve-1,we)),xe=Se):(ue=e.slice(ve-1,we),G+=ue,ie+=ue.length,W=we-1)}else de===10&&(ae++,re++,ie=0),de===de?(G+=l(de),ie++):De();return oe.join(``);function Te(){return{line:ae,column:ie,offset:W+(te.offset||0)}}function Ee(e,t){var n=Te();n.column+=t,n.offset+=t,R.call(H,L[e],n,e)}function De(){G&&=(oe.push(G),d&&d.call(z,G,{start:xe,end:Te()}),``)}}function ee(e){return e>=55296&&e<=57343||e>1114111}function B(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),g1=s(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`&quot;`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),_1=s(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&amp;/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),v1=s(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),y1=s(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),b1=s(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),x1=s(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=r1(),a=h1(),o=g1(),s=_1(),c=v1(),l=y1(),u=b1();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),S1=s(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),C1=s(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),w1=s(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),T1=s(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),E1=s(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),D1=s(((e,t)=>{var n=w1(),r=E1();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),O1=s(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),k1=u(x1(),1),A1=u(S1(),1),j1=u(v1(),1),M1=u(b1(),1),N1=u(C1(),1),P1=u(w1(),1),F1=u(T1(),1),I1=u(_1(),1),L1=u(D1(),1),R1=u(E1(),1),z1=u(O1(),1),B1=e=>{let t=e.displayName;!t||k1.default.registered(t)||k1.default.register(e)};B1(I1.default),B1(j1.default),B1(M1.default),B1(R1.default),B1(L1.default),B1(N1.default),B1(P1.default),B1(F1.default),B1(z1.default),B1(A1.default);var V1=c({TicketChangesModal:()=>g0}),H1=4,U1=1500,W1=`archon.ticket-changes.review-comments`,G1=[],K1=[],q1=[],J1=e=>new Set(e.map(e=>e.path)),Y1=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},X1=e=>e.replace(/^[ab]\//,``),Z1=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?X1(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?X1(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},Q1=e=>{let[t,n]=Z1(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},$1=e=>{let[t,n]=Z1(e);return t??n??null},e0=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),t0=e=>{if(e0(e)>U1)return null;let t=k$($1(e));if(!t)return null;try{return VE(e.hunks,{highlight:!0,refractor:k1.default,language:t,enhancers:[zE(e.hunks)]})}catch{return null}},n0=(e,t)=>e instanceof Error?e.message:t,r0=(e,t)=>`${W1}:${e}:${t}`,i0=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),a0=()=>({uncommitted:i0(),bundle_diff:i0()}),o0=e=>({uncommitted:e(),bundle_diff:e()}),s0=()=>o0(()=>new Map),c0=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},l0=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},u0=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(l0).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},d0=e=>new Map(e.map(e=>[ZE(e.filePath,e.changeKey),e])),f0=(e,t)=>{e.set(t,(e.get(t)??0)+1)},p0=e=>e.find(e=>e.trim())||``,m0=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isGeneratingDescription:o,title:s,body:c,baseBranch:l,onOpenChange:u,onTitleChange:d,onBodyChange:f,onBaseBranchChange:p,showGenerateDescription:m,onGenerateDescription:h,onCreate:g})=>t?(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,children:`Loading PR...`}):e?(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,q.jsx)(uj,{pullRequest:e}),(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,q.jsxs)(Hg,{open:n,onOpenChange:u,children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(T_,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,q.jsx)(Gg,{children:(0,q.jsx)(Kg,{children:`Create pull request`})}),(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(Kv,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,q.jsx)(Dg,{id:`bundle-pr-title`,value:s,onChange:e=>d(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,q.jsx)(Kv,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,q.jsx)(Dg,{id:`bundle-pr-base-branch`,value:l,onChange:e=>p(e.target.value),placeholder:`main`,disabled:a})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),m&&(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||o,onClick:h,children:[o?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):null,o?`Generating...`:`Generate`]})]}),(0,q.jsx)(Og,{id:`bundle-pr-body`,value:c,onChange:e=>f(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:!s.trim()||a,onClick:g,children:a?`Creating...`:`Create PR`})})]})]})]}),h0=(e,t,n)=>{if(n)return J1(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},g0=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:u}=e,d=e.scope??`ticket`,{isGitHubConnected:f}=ky(t),p=e.scope===`project_root`?null:e.ticketId,m=e.scope===`project_root`?void 0:e.onTicketUpdate,h=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[g,_]=(0,b.useState)(`uncommitted`),[v,y]=(0,b.useState)(null),[x,S]=(0,b.useState)(null),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)([]),[D,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(`all`),[M,F]=(0,b.useState)(``),[I,L]=(0,b.useState)(null),[R,V]=(0,b.useState)(null),[H,te]=(0,b.useState)(null),[U,ne]=(0,b.useState)(null),[W,re]=(0,b.useState)(!0),[ie,ae]=(0,b.useState)(!1),[G,oe]=(0,b.useState)(!0),[se,ce]=(0,b.useState)(!1),[le,ge]=(0,b.useState)(!1),[_e,ve]=(0,b.useState)(!1),[ye,be]=(0,b.useState)(!1),[xe,Se]=(0,b.useState)(!1),[Ce,we]=(0,b.useState)(`unified`),[Te,Ee]=(0,b.useState)(new Map),[De,Oe]=(0,b.useState)(q1),[ke,Ae]=(0,b.useState)(a0),[je,Me]=(0,b.useState)(null),[Ne,Pe]=(0,b.useState)([]),[Fe,Ie]=(0,b.useState)(null),[Le,Re]=(0,b.useState)(null),[ze,Be]=(0,b.useState)(new Set),[Ve,He]=(0,b.useState)(new Set),[Ue,We]=(0,b.useState)(!1),[Ge,Ke]=(0,b.useState)(null),[Je,tt]=(0,b.useState)(!1),[nt,rt]=(0,b.useState)(!1),[it,at]=(0,b.useState)(``),[ot,st]=(0,b.useState)(``),[ct,lt]=(0,b.useState)(``),[ut,dt]=(0,b.useState)([]),[ft,pt]=(0,b.useState)(!1),[mt,ht]=(0,b.useState)(!1),gt=(0,b.useRef)(null),_t=(0,b.useRef)(!1),vt=(0,b.useRef)(null),yt=(0,b.useRef)(null),bt=(0,b.useRef)(0),xt=(0,b.useRef)(0),St=(0,b.useRef)(o0(()=>null)),Ct=(0,b.useRef)(s0()),wt=(0,b.useMemo)(()=>w$({scope:d,projectId:t,ticketId:p}),[t,d,p]),Tt=(0,b.useCallback)(()=>{if(!p)throw Error(`Ticket changes require a ticket id.`);return p},[p]),Et=(0,b.useCallback)(e=>{vt.current=e,y(e),L(null)},[]),Dt=(0,b.useCallback)((e,t)=>{E$({cacheKey:wt,diffResponse:e,gitStatus:t})},[wt]),Ot=(0,b.useCallback)(e=>{vt.current&&E$({cacheKey:wt,diffResponse:vt.current,gitStatus:e})},[wt]),kt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await qe(t)}return await ue(Tt(),t)},[t,Tt,d]),At=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ye(t)}return await de(Tt(),t)},[t,Tt,d]),jt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Xe(t)}return await me(Tt(),t)},[t,Tt,d]),Mt=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await z(t,n,e),[t,n,d]),Nt=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await j(t,n,e),[t,n,d]),Pt=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await ee(t,n,e),[t,n,d]),Ft=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await B(t,n,e),[t,n,d]),It=(0,b.useCallback)((e,t)=>{Ae(n=>({...n,[e]:t(n[e])}))},[]),Lt=(0,b.useCallback)(async e=>{if(d===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await P(t,n,e)},[t,n,d]),Rt=(0,b.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ze(t,e)}return await K(Tt(),t,e)},[t,Tt,d]),zt=(0,b.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Qe(t,e)}return await fe(Tt(),t,e)},[t,Tt,d]),Bt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await $e(t)}return await pe(Tt(),t)},[t,Tt,d]),Vt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await et(t)}return await he(Tt(),t)},[t,Tt,d]),Ht=(0,b.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=bt.current+1;bt.current=r,ce(!0),n||ne(null);try{let t=await jt();if(!e()||bt.current!==r)return;E(t.commits),ne(null)}catch(t){if(!e()||bt.current!==r)return;ne(n0(t,`Unable to load local commits right now.`)),n||E([])}finally{e()&&bt.current===r&&ce(!1)}},[jt]),Ut=(0,b.useCallback)(()=>{bt.current+=1,E([]),ne(null),ce(!1)},[]),Wt=(0,b.useCallback)((e,t={})=>{let n=t.resetSelection??!1;yt.current=e,w(e),te(null),O(t=>{let r=h0(t,e.files,n||!_t.current);return _t.current=!0,r})},[]),Gt=(0,b.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||L(null),re(!0);try{let e=await kt();Et(e),n&&Dt(e,n)}catch(e){n&&D$(wt),(!t||!vt.current)&&L(n0(e,`Unable to load the diff right now.`))}finally{re(!1)}},[Et,wt,kt,Dt]),Kt=(0,b.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(d===`project_root`||!n||!t){S(null),V(null),ae(!1);return}r||V(null),ae(!0);try{S(await Pt()),V(null)}catch(e){(!r||!x)&&V(n0(e,`Unable to load the branch diff right now.`))}finally{ae(!1)}},[x,t,Pt,n,d]),qt=(0,b.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?T$(wt):null;if(n||(L(null),te(null)),oe(!0),i){Et(i.diffResponse),Wt(i.gitStatus,{resetSelection:r}),re(!1);try{let t=await At();if(!e())return;Wt(t,{resetSelection:r}),oe(!1),(t.ahead??0)>0?Ht(e,{preserveContent:!0}):Ut();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){Dt(i.diffResponse,t);return}D$(wt),await Gt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;te(n0(t,`Unable to load git status right now.`)),w(null),oe(!1),Ut();return}}re(!0);let[a,o]=await Promise.allSettled([kt(),At()]);e()&&(a.status===`fulfilled`?Et(a.value):(!n||!vt.current)&&L(n0(a.reason,`Unable to load the diff right now.`)),re(!1),o.status===`fulfilled`?Wt(o.value,{resetSelection:r}):(te(n0(o.reason,`Unable to load git status right now.`)),n||w(null)),oe(!1),a.status===`fulfilled`&&o.status===`fulfilled`&&Dt(a.value,o.value),o.status===`fulfilled`&&(o.value.ahead??0)>0?Ht(e,{preserveContent:n}):Ut())},[Et,Wt,wt,Ut,Ht,Gt,kt,At,Dt]),Jt=(0,b.useCallback)(async()=>{if(!t)return;let e=xt.current+1;xt.current=e,oe(!0);try{let t=await At();if(xt.current!==e)return;let n=yt.current?.workspace_signature??null,r=t.workspace_signature??null,i=!vt.current||n!==r;if(Wt(t),(t.ahead??0)>0?Ht(()=>xt.current===e,{preserveContent:!0}):Ut(),!i){Ot(t);return}await Gt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{xt.current===e&&oe(!1)}},[Wt,Ut,Ht,Gt,t,At,Ot]);(0,b.useEffect)(()=>{vt.current=v},[v]),(0,b.useEffect)(()=>{yt.current=C},[C]),(0,b.useEffect)(()=>{let e=!0;return qt(()=>e,{resetSelection:!0}),()=>{e=!1}},[qt]),(0,b.useEffect)(()=>{if(t)return M$(e=>{e===t&&Jt()})},[t,Jt]),(0,b.useEffect)(()=>{if(!t)return;let e=P$(()=>{document.visibilityState===`visible`&&Jt()});return()=>{e()}},[t,Jt]),(0,b.useEffect)(()=>{if(d===`project_root`){Me(null),Ie(null),Be(new Set);return}let e=new AbortController,t=!0;return Ie(null),Mt(e.signal).then(e=>{t&&(Me(e),Be(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Ie(n0(n,`Unable to load review findings right now.`)),Me(null),Be(new Set))}),()=>{t=!1,e.abort()}},[v?.diff,Mt,d]),(0,b.useEffect)(()=>{_(`uncommitted`),St.current=o0(()=>null),Ct.current=s0(),Ae(a0()),S(null),V(null),ae(!1),Pe([]),Re(null),He(new Set),Ke(null),tt(!1),rt(!1),at(``),st(``),lt(``),dt([]),pt(!1),ht(!1)},[n]),(0,b.useEffect)(()=>{if(d===`project_root`||!n||!t){Ke(null),tt(!1);return}let e=new AbortController,i=!0;return tt(!0),Nt(e.signal).then(e=>{i&&(Ke(e),at(t=>t.trim()?t:e?.bundle?.name??r),st(t=>t.trim()?t:p0(e?.recent_commit_subjects??ut)),lt(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||Ke(null)}).finally(()=>{i&&tt(!1)}),()=>{i=!1,e.abort()}},[ut,t,Nt,n,d,r]),(0,b.useEffect)(()=>{if(d===`project_root`||!n||!t){S(null),V(null),ae(!1);return}let e=new AbortController,r=!0;return ae(!0),V(null),Pt(e.signal).then(e=>{r&&(S(e),V(null))}).catch(t=>{!r||e.signal.aborted||(V(n0(t,`Unable to load the branch diff right now.`)),S(null))}).finally(()=>{r&&ae(!1)}),()=>{r=!1,e.abort()}},[t,Pt,n,d]),(0,b.useEffect)(()=>{let e=Ge?.bundle.pull_request??null;if(d===`project_root`||!n||!t||!f||!e){Pe([]),Re(null),He(new Set);return}let r=new AbortController,i=!0;return Re(null),Ft(r.signal).then(e=>{!i||!e||(Pe(e.comments),Re(e.error),He(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(e=>{!i||r.signal.aborted||(Pe([]),Re(n0(e,`Unable to load GitHub review comments right now.`)),He(new Set))}),()=>{i=!1,r.abort()}},[Ge?.bundle.pull_request,f,t,Ft,n,d]),(0,b.useEffect)(()=>{G&&C===null||gt.current?.focus()},[C,G]);let Yt=(0,b.useMemo)(()=>{let e=typeof v?.diff==`string`?v.diff:``;return e.trim()?Mx(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:Z1(e)})):[]},[v]),Xt=(0,b.useMemo)(()=>{let e=typeof x?.diff==`string`?x.diff:``;return e.trim()?Mx(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:Z1(e)})):[]},[x]),Zt=(0,b.useMemo)(()=>{let e=v?.diff??``;return e?c0(e):null},[v?.diff]),Qt=(0,b.useMemo)(()=>{let e=x?.diff??``;return e?c0(e):null},[x?.diff]),$t=g===`bundle_diff`?x:v,en=g===`bundle_diff`?Xt:Yt,tn=(0,b.useMemo)(()=>n?{uncommitted:r0(n,`uncommitted`),bundle_diff:r0(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),nn=(0,b.useMemo)(()=>({uncommitted:Zt,bundle_diff:Qt}),[Qt,Zt]),rn=(0,b.useMemo)(()=>{let e=new Map;for(let t of $t?.files??[])e.set(t.path,t);return e},[$t]),an=(0,b.useMemo)(()=>{let e=new Map;for(let t of en)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[en]),on=(0,b.useCallback)(e=>{Oe(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),sn=(0,b.useMemo)(()=>g===`bundle_diff`?(x?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):C?(C.files??[]).map(e=>{let t=rn.get(e.path)??(e.original_path?rn.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(v?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[g,x?.files,rn,v?.files,C]);(0,b.useEffect)(()=>{k!==`all`&&(sn.some(e=>e.path===k)||A(`all`))},[k,sn]);let cn=g===`bundle_diff`?0:D.size,ln=g===`bundle_diff`?sn.length:C?.files?.length??sn.length,un=ln>0&&cn===ln,dn=(0,b.useMemo)(()=>g===`bundle_diff`?null:Y1(C,D),[g,C,D]),fn=g===`uncommitted`&&!G&&!le&&l&&!!C&&cn>0&&M.trim().length>0&&dn===null,pn=g===`uncommitted`&&!G&&!W&&!_e&&!le&&!ye&&l&&!Ue&&!!C&&cn>0,mn=!G&&(ye||!!C?.can_push&&(C?.ahead??0)>0),hn=mn&&l&&!ye&&!le,gn=l&&!se&&!xe&&!le&&!ye&&(T?.length??0)>0,_n=(C?.ahead??0)>0?`${C?.ahead??0} to push`:`Up to date`,vn=(C?.behind??0)>0?`${C?.behind??0} behind`:`In sync`,yn=C?.branch??null,bn=k===`all`?null:an.get(k)??null,xn=(0,b.useMemo)(()=>k===`all`?en:bn?[bn]:[],[en,k,bn]);(0,b.useEffect)(()=>{Ee(new Map),Oe(q1)},[g,en]),(0,b.useEffect)(()=>{let e={uncommitted:tn.uncommitted&&nn.uncommitted?`${tn.uncommitted}:${nn.uncommitted}`:null,bundle_diff:tn.bundle_diff&&nn.bundle_diff?`${tn.bundle_diff}:${nn.bundle_diff}`:null};St.current.uncommitted===e.uncommitted&&St.current.bundle_diff===e.bundle_diff||(St.current=e,Ct.current=s0(),Ae(e=>{let t={...e};return[`uncommitted`,`bundle_diff`].forEach(e=>{let n=nn[e],r=tn[e];if(!n){t[e]=i0();return}let i=new Map;if(r){let t=window.localStorage.getItem(r),a=t?u0(t):null;a?.diffSignature===n?i=d0(a.comments.map(t=>({...t,scope:e}))):t!==null&&window.localStorage.removeItem(r)}t[e]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:i,signature:n}}),t}))},[nn,tn]),(0,b.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=tn[e],n=nn[e],r=ke[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[nn,tn,ke]),(0,b.useEffect)(()=>{if(en.length===0)return;let e=!1,t=null,n=(()=>{if(!bn){let e=[],t=new Set;for(let n of De){let r=an.get(n);if(!r)continue;let i=Q1(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:en.slice(0,H1)}return[bn]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+H1);a.length!==0&&(Ee(e=>{let t=new Map(e);for(let e of a){let n=Q1(e);t.has(n)||t.set(n,t0(e))}return t}),r+=H1,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=H1?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[en,an,bn,De]);let Sn=(0,b.useMemo)(()=>xn.map(e=>({...e,tokens:Te.get(Q1(e))??null})),[Te,xn]),Cn=(0,b.useMemo)(()=>en.map(e=>({...e,tokens:null})),[en]),wn=(0,b.useMemo)(()=>{let e=new Map;for(let t of en){let n=Q1(t);e.set(n,n);for(let r of Z1(t))e.set(r,n)}return e},[en]),Tn=(0,b.useMemo)(()=>[...ke.uncommitted.comments.values()],[ke.uncommitted.comments]),En=(0,b.useMemo)(()=>[...ke.bundle_diff.comments.values()],[ke.bundle_diff.comments]),Dn=ke[g],On=Dn.activeTarget,kn=Dn.editingCommentKey,An=On?.commentKey??kn,jn=An?`${g}:${An}`:g,Mn=An?Ct.current[g].get(An)??Dn.draftInput:Dn.draftInput,Nn=g===`bundle_diff`?En:Tn,Pn=(0,b.useMemo)(()=>[...Tn,...En],[En,Tn]),Fn=(0,b.useMemo)(()=>je?.findings??[],[je]),In=(0,b.useMemo)(()=>je?.is_current_diff?Fn.filter(e=>ze.has(e.id)):[],[Fn,je?.is_current_diff,ze]),Ln=(0,b.useMemo)(()=>[...ze],[ze]),Rn=(0,b.useMemo)(()=>Ne.filter(e=>Ve.has(e.id)),[Ne,Ve]),zn=(0,b.useMemo)(()=>[...Ve],[Ve]),Bn=Pn.length+In.length+Rn.length,Vn=!!(je?.review_run&&Fn.length>0&&!je.is_current_diff),Hn=Ge?.bundle.pull_request??null,Un=(0,b.useMemo)(()=>ut.length>0?ut:Ge?.recent_commit_subjects??[],[Ge?.recent_commit_subjects,ut]),Wn=Ge?.has_helper_model===!0,Gn=d!==`project_root`&&!!n&&!!t,Kn=g===`bundle_diff`?R:I,qn=W&&v===null,Jn=ie&&x===null,Yn=G&&C===null,Xn=Je&&Ge===null,Zn=g===`bundle_diff`?Jn:qn,Qn=g===`uncommitted`?Fn:G1,$n=g===`uncommitted`?Ln:q1,er=g===`bundle_diff`?Ne:K1,tr=g===`bundle_diff`?zn:q1,nr=g===`bundle_diff`?`bundle_diff`:`uncommitted`,rr=(0,b.useMemo)(()=>{let e=new Map,t=e=>e?wn.get(e)??e:null;for(let n of Nn){let r=t(n.filePath);r&&f0(e,r)}if(g===`uncommitted`){if(Vn)return e;for(let n of Fn){let r=t(n.file_path);r&&f0(e,r)}return e}for(let n of Ne){let r=t(n.file_path);r&&f0(e,r)}return e},[g,wn,Nn,Ne,Vn,Fn]),ir=(Vn?0:Fn.length)+Tn.length,ar=Ne.length+En.length,or=g===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,sr=g===`uncommitted`&&(x?.files.length??0)>0?`Switch to Branch diff to review the full branch diff.`:null,cr=Gn&&!Xn&&!!Ge&&Ge?.bundle.kind!==`project_root`&&C?.has_upstream===!0&&f,lr=cr&&!Hn&&!ft&&!mt&&!Ue&&!ye&&!le&&!xe&&(C?.ahead??0)===0&&!!C?.branch,ur=(0,b.useMemo)(()=>{if(cr)return(C?.ahead??0)>0?`Push the branch before creating a pull request.`:C?.branch?u:`Bundle branch information is not available right now.`},[u,C?.ahead,C?.branch,cr]),dr=c&&!Zn&&(g===`bundle_diff`||!Yn)&&!le&&!ye&&!xe,fr=On?dr||Dn.comments.has(On.commentKey):dr,pr=!!a&&o&&Bn>0&&!Ue,mr=(0,b.useCallback)(e=>{Be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),hr=(0,b.useCallback)(e=>{He(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),gr=(0,b.useCallback)(()=>{Ct.current=s0(),Ae(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),_r=(0,b.useCallback)(()=>{gr(),Be(new Set),He(new Set)},[gr]),vr=(0,b.useCallback)(async()=>{if(!(!t||!n||!lr)){pt(!0);try{let e=await N(t,n,{title:it.trim(),body:ot.trim(),base_branch:ct.trim()||null});Ke(e),lt(e.bundle.pull_request?.base_branch??ct.trim()),rt(!1),X.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){X.error(n0(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{pt(!1)}}},[lr,t,ct,ot,it,n]),yr=(0,b.useCallback)(async()=>{if(!(!t||!n||!cr||mt)){ht(!0);try{st((await Lt({title:it.trim(),commit_subjects:Un})).description)}catch(e){X.error(n0(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{ht(!1)}}},[mt,t,Un,it,Lt,n,cr]),br=(0,b.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=Dn.comments.get(n),i=Ct.current[g].get(n)??r?.comment??``;if(r){A(r.filePath),It(g,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}dr&&It(g,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[g,Dn.comments,dr,It]),xr=(0,b.useCallback)(()=>{An&&Ct.current[g].delete(An),It(g,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[g,An,It]),Sr=(0,b.useCallback)(e=>{An&&Ct.current[g].set(An,e)},[g,An]),Cr=(0,b.useCallback)((e,t)=>{let n=Dn.comments.has(e.commentKey);if(!dr&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;It(g,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:g,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:QE(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),Ct.current[g].delete(e.commentKey)},[g,Dn.comments,dr,It]),wr=(0,b.useCallback)(e=>{let t=Dn.comments.get(e);if(!t)return;A(t.filePath);let n=Ct.current[g].get(e)??t.comment;It(g,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[g,Dn.comments,It]),Tr=(0,b.useCallback)(e=>{Ct.current[g].delete(e),It(g,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[g,It]),Er=(0,b.useCallback)(async()=>{if(!a||!pr)return;We(!0);let e=sD({drafts:Pn,findings:In,githubComments:Rn,uncommittedFiles:Yt,bundleFiles:Xt});try{await a(e),gr(),Be(new Set),He(new Set),Me(e=>e&&{...e,findings:[],is_current_diff:!1}),X.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){X.error(n0(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{We(!1)}},[Pn,Xt,pr,gr,i,a,Rn,In,Yt]),Dr=(0,b.useCallback)(()=>{if(g===`bundle_diff`){Kt();return}qt(()=>!0,{allowCache:!1,resetSelection:!_t.current})},[g,Kt,qt]),Or=(0,b.useMemo)(()=>a?(0,q.jsx)(bQ,{reviewComments:Pn,reviewFindings:In,githubComments:Rn,pendingFixCount:Bn,canSendReview:pr,isSubmittingReview:Ue,reviewSubmitDisabledReason:s,onClearPendingFixes:_r,onSubmitReview:()=>{Er()}}):null,[Pn,pr,_r,Er,Ue,a,Bn,s,Rn,In]),kr=e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ar=()=>{C&&O(un?new Set:J1(C.files))},jr=async()=>{if(fn){ge(!0);try{let e=await Rt({message:M.trim(),selected_paths:[...D]});e.ticket&&m?.(e.ticket),Wt(e.git_status,{resetSelection:!0}),F(``),d===`project_root`&&j$(t),p&&h?.(p),await Gt({preserveContent:!0,gitStatusForCache:e.git_status}),await Kt({preserveContent:!0}),(e.git_status.ahead??0)>0?await Ht(()=>!0):Ut(),X.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){X.error(n0(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ge(!1)}}},Mr=async()=>{if(pn){ve(!0);try{F((await zt({selected_paths:[...D]})).message),gt.current?.focus()}catch(e){X.error(n0(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{ve(!1)}}},Nr=async()=>{if(hn){be(!0);try{let e=T.map(e=>e.subject.trim()).filter(Boolean),a=await Bt();if(a.ticket&&m?.(a.ticket),Wt(a.git_status,{resetSelection:!0}),Ot(a.git_status),dt(e),Ut(),d===`project_root`&&j$(t),p&&h?.(p),X.success(a.git_status.ahead===0?`Branch pushed.`:`Push completed.`,{id:`ticket-git-push-success`}),a.git_status.ahead===0)if(d!==`project_root`&&t&&n)try{let i=await j(t,n);Ke(i),at(e=>e.trim()?e:i.bundle.name??r),st(t=>t.trim()?t:p0(e)),lt(e=>e.trim()?e:i.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(e){X.error(n0(e,`Unable to push the branch right now.`),{id:`ticket-git-push-error`})}finally{be(!1)}}},Pr=async()=>{if(gn){Se(!0);try{let e=await Vt();e.ticket&&m?.(e.ticket),Wt(e.git_status,{resetSelection:!0}),E(e.commits),ne(null),ce(!1),d===`project_root`&&j$(t),p&&h?.(p),await Gt({preserveContent:!0,gitStatusForCache:e.git_status}),await Kt({preserveContent:!0}),X.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){X.error(n0(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{Se(!1)}}};return(0,q.jsx)(Iv,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,q.jsxs)(q.Fragment,{children:[ye&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}),(0,q.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),yn?(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:yn}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(Z,{variant:(C?.ahead??0)>0?`info`:`outline`,children:_n}),(0,q.jsx)(Z,{variant:(C?.behind??0)>0?`warning`:`outline`,children:vn}),(0,q.jsx)(Z,{variant:C?.is_dirty?`warning`:`success`,children:C?.is_dirty?`Dirty`:`Clean`})]})]}):(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(Hn||cr)&&(0,q.jsx)(m0,{pullRequest:Hn,isLoading:Xn,isOpen:nt,canCreate:lr,disabledReason:ur,isCreating:ft,isGeneratingDescription:mt,title:it,body:ot,baseBranch:ct,onOpenChange:rt,onTitleChange:at,onBodyChange:st,onBaseBranchChange:lt,showGenerateDescription:Wn,onGenerateDescription:()=>{yr()},onCreate:()=>{vr()}}),(0,q.jsx)(SQ,{isCommitsLoading:se,commitsError:U,unpushedCommits:T,canUndoLatestCommit:gn,isUndoing:xe,aheadCount:C?.ahead??0,onUndoLatestCommit:()=>{Pr()}}),mn&&(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Nr()},disabled:!hn,title:u,className:`gap-2`,children:[ye?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(T_,{className:`h-4 w-4`}),ye?`Pushing...`:`Push branch`]}),e]})]}),(0,q.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,q.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[Gn&&(0,q.jsxs)(mQ,{type:`single`,size:`sm`,variant:`outline`,value:g,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&_(e)},className:`mb-3 self-start`,children:[(0,q.jsxs)(hQ,{value:`uncommitted`,className:`gap-2`,children:[(0,q.jsx)(`span`,{children:`Uncommitted`}),ir>0&&(0,q.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:ir})]}),(0,q.jsxs)(hQ,{value:`bundle_diff`,className:`gap-2`,children:[(0,q.jsx)(`span`,{children:`Branch diff`}),ar>0&&(0,q.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:ar})]})]}),(0,q.jsx)(_$,{selectionWarning:g===`uncommitted`?dn:null,gitError:g===`uncommitted`?H:R,sidebarFiles:sn,commentCountByPath:rr,commentCountTone:nr,isGitStatusLoading:g===`bundle_diff`?Jn:Yn,selectedPaths:D,selectedDiffPath:k,allFilesSelected:un,diffStats:$t?.stats??null,title:g===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:g===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:g===`uncommitted`,onToggleSelectAll:Ar,onSelectDiffPath:A,onTogglePath:kr})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,q.jsx)(f$,{selectedDiffPath:k,sidebarFiles:sn,diffResponse:$t,isDiffLoading:Zn,diffError:Kn,allDiffFiles:Cn,renderedFiles:Sn,viewType:Ce,onViewTypeChange:we,onRetry:Dr,activeReviewTarget:On,editingReviewCommentKey:kn,reviewDraftInstanceKey:jn,reviewDraftInput:Mn,reviewComments:Nn,reviewFindings:Qn,githubComments:er,selectedReviewFindingIds:$n,selectedGitHubCommentIds:tr,canSelectReviewTarget:dr,canEditActiveReviewDraft:fr,reviewFindingsError:g===`uncommitted`?Fe:null,gitHubCommentsError:g===`bundle_diff`?Le:null,hasStaleReviewFindings:g===`uncommitted`?Vn:!1,onSelectReviewTarget:br,onToggleReviewFindingSelection:mr,onToggleGitHubCommentSelection:hr,onReviewDraftInputChange:Sr,onCancelReviewDraft:xr,onEditReviewDraft:wr,onRemoveReviewDraft:Tr,onSaveReviewDraft:Cr,diffThemeClassName:v$,resolveFilePath:Q1,normalizeDiffPath:X1,onVisibleFilePathsChange:on,emptyStateTitle:or,emptyStateDescription:sr,reviewSummaryControl:Or,headerLayout:`inline-controls`}),g===`uncommitted`&&(0,q.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,q.jsx)(xQ,{commitMessage:M,onCommitMessageChange:F,commitMessageRef:gt,selectedFileCount:cn,changesDisabledReason:u,canEditCommitMessage:l&&!Ue,canGenerateCommitMessage:pn,canCommit:fn,isGeneratingCommitMessage:_e,isCommitting:le,onGenerateCommitMessage:()=>{Mr()},onCommit:()=>{jr()}})})]})]})]})]})})},_0={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},v0=e=>Lj(e)?`ready`:`blocked`,y0=180,b0=560,x0=88,S0=12,C0=18,w0=(e,t,n)=>Math.min(Math.max(e,t),n),T0=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),E0=(e,t)=>{let n=w0(Math.round(e.length*7.2)+24,y0,b0),r=Math.max(y0,t-S0*2);return Math.min(n,r)},D0=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=Gj(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=T0(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=E0(c,d.width);return{text:c,x:o&&s?w0(f.x-p/2,S0,Math.max(S0,d.width-p-S0)):(()=>{let e=f.x+C0,t=f.x-C0-p;return e+p<=d.width-S0?e:t>=S0?t:w0(e,S0,Math.max(S0,d.width-p-S0))})(),y:w0(f.y,S0,Math.max(S0,d.height-x0-S0)),width:p}},O0=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=Gj(e,t),{path:s}=Kj(a,o);return(0,q.jsx)(`g`,{"data-testid":r,children:(0,q.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},k0=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=D0(e,i,n,t,r);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O0,{blockerRect:i,dependentRect:a,className:_0.preview.className,testId:`dependency-preview`,markerEnd:`url(#${_0.preview.markerId})`}),(e=>o?(0,q.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:x0,"data-testid":`dependency-preview-label`,children:e}):null)((0,q.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,q.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},A0=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,q.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,q.jsx)(`defs`,{children:Object.values(_0).map(e=>(0,q.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,q.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=_0[v0(n)];return!a||!o?null:(0,q.jsx)(O0,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,q.jsx)(k0,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),j0=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,onClose:m})=>{let{jiraImportState:h,importFromJira:g}=My(n);return(0,q.jsx)(Iv,{onClose:m,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:_})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:_}),(0,q.jsx)(GB,{heading:`New Ticket`,bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,projectBranchState:r,jiraImportState:h,onImportFromJira:g,onCancel:m,onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:`Plan`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}:void 0,primaryAction:{label:`Create Ticket`,variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}},secondaryAction:{label:`Create & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}})]})})},M0=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},N0=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,P0=({run:e})=>(0,q.jsxs)(zv,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${N0(e)}`,children:[e.status===`running`&&(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,q.jsxs)(Wv,{className:`space-y-3 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,q.jsx)(Yj,{label:`Planning...`}):e.status===`done`?(0,q.jsx)(Yj,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,q.jsx)(Yj,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,q.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:M0(e.submittedAt)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),F0={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},I0=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,L0=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},R0=({status:e})=>e===`running`?(0,q.jsx)(Yj,{label:`Planning...`,className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,q.jsx)(Z,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:`Done`}):(0,q.jsx)(Z,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:`Failed`}),z0=({heading:e,runs:t})=>t.length===0?null:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,q.jsx)(zv,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,q.jsxs)(Wv,{className:`space-y-2 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,q.jsx)(R0,{status:e.status})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:L0(e.submittedAt)}),e.summary&&(0,q.jsxs)(`span`,{children:[e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]})]}),e.error&&(0,q.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]}),B0=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let m=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:h,importFromJira:g}=My(t.isOpen?e:null),_=(0,b.useRef)(null),v=(0,b.useRef)(t.isOpen),y=(0,b.useRef)(t.isOpen),x=I0(t.runs),S=t.runs.filter(e=>e.status===`running`),C=t.runs.filter(e=>e.status!==`running`),w=t.composer.description.trim().length>0;(0,b.useEffect)(()=>{if(t.isOpen&&!v.current&&(y.current=!0),t.isOpen||(y.current=!1),v.current=t.isOpen,!t.isOpen||!y.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==_.current&&!t){y.current=!1;return}_.current?.focus({preventScroll:!0}),y.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,b.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let T=(0,q.jsxs)(Y,{type:`button`,"aria-label":t.isOpen?`Close planning agent`:`Open planning agent`,"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,q.jsx)(cy,{className:`size-5`}),(0,q.jsx)(__,{"aria-hidden":`true`,children:`A`}),(0,q.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${F0[x]}`})]});return(0,q.jsxs)(`aside`,{"aria-label":`Planning agent sidebar`,className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,q.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?T:(0,q.jsx)(u_,{content:`Planning agent`,children:T})}),(0,q.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:J(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,q.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Planning agent`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Turn a larger initiative into plan-stage tickets with dependencies and bundle context.`})]}),(0,q.jsx)(Y,{type:`button`,"aria-label":`Close planning agent panel`,onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]}),(0,q.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,q.jsx)(VB,{jiraImportState:h,onImportFromJira:g,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,q.jsx)(Kv,{label:`Description`,htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,q.jsx)(`div`,{className:`relative`,children:(0,q.jsx)(Bz,{ref:_,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":`Planning description`,value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:`Describe the task, acceptance criteria, context...`})})}),(0,q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(HB,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:`Auto-create bundle`,hideProjectRootBundles:!0,label:``})}),o&&(0,q.jsx)(Y,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:`Manage bundles`})]}),(0,q.jsx)(`div`,{className:`space-y-3`,children:(0,q.jsx)(RB,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:m,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,q.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(z0,{heading:`Active planning runs`,runs:S}),(0,q.jsx)(z0,{heading:`Recent runs`,runs:C})]})})]})}),(0,q.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,q.jsx)(Y,{type:`button`,onClick:p,disabled:!w,className:`w-full`,children:`Plan tickets`})})]})})]})},V0=({className:e=``})=>{let{setNodeRef:t,isOver:n}=WA({id:`trash`});return(0,q.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(Z,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,q.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,q.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,q.jsx)(qv,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},H0=(e,t)=>O(w(`/ticket-dependencies`,e),{signal:t}),U0=(e,t)=>O(w(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),W0=(e,t,n)=>D(w(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),G0=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},K0=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,q0=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,b.useState)({}),[l,u]=(0,b.useState)({width:0,height:0}),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useRef)(null),v=(0,b.useRef)(new Map),y=(0,b.useRef)({}),x=(0,b.useRef)(null),C=(0,b.useRef)(null),w=(0,b.useRef)(null),T=(0,b.useRef)(null),E=(0,b.useRef)(null),D=(0,b.useRef)(null),O=(0,b.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,b.useEffect)(()=>{T.current=p},[p]),(0,b.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let k=(0,b.useCallback)(()=>{x.current===null&&(x.current=window.requestAnimationFrame(()=>{x.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>G0(e,n)?e:n)}))},[]);(0,b.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{k()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[k]),(0,b.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{k()});C.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),C.current===e&&(C.current=null)}},[k]),(0,b.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{k()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[k]),(0,b.useEffect)(()=>(k(),()=>{x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null)}),[n,k,t]);let A=(0,b.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),C.current?.observe(t)}else{if(!n)return;v.current.delete(e),C.current?.unobserve(n)}k()},[k]),j=(0,b.useCallback)(e=>{K0(T.current,e)||(T.current=e,m(e))},[]),M=(0,b.useCallback)(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),D.current=null},[]),N=(0,b.useCallback)(e=>{D.current=e,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;let e=D.current;D.current=null,j(e)}))},[j]),P=(0,b.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),F=(0,b.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),I=(0,b.useCallback)(async t=>{if(e)try{await W0(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>Nj(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){X.error(e instanceof S?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),L=(0,b.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),w.current?.();let a=(n,r,i=!1)=>{let a=P(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:F(a.x,a.y,t),pointer:a};if(i){M(),j(o);return}N(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=P(i.clientX,i.clientY),o=F(a.x,a.y,t),s=o?Fj(n,t,o):null;if(w.current?.(),w.current=null,j(null),!(!o||!s)){if(!s.valid){X.error(Ij(s.reason),{id:`board-dependency-error`});return}try{let n=await U0(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>Mj(e,n))}catch(e){X.error(e instanceof S?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};w.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),M()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,M,n,F,P,N,r,j]);(0,b.useEffect)(()=>{w.current?.(),w.current=null,M(),T.current=null},[e,M]),(0,b.useEffect)(()=>()=>{w.current?.(),E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null)},[]);let R=(0,b.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!O.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=Fj(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,O,t]),z=(0,b.useCallback)(e=>{if(!R||!p)return`idle`;let t=R.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[R,p]),ee=(0,b.useMemo)(()=>!p||p.projectId!==e||!O.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,O]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:A,measuredCardRects:(0,b.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:ee,overlaySize:l,getDependencyTargetState:z,handleDependencyStart:L,handleDeleteDependency:I}},J0=`[data-terminal-pane="true"]`,Y0=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},X0=e=>e instanceof HTMLElement?e.closest(J0)!==null:!1,Z0=e=>Y0(e)||X0(e),Q0=(e,t={})=>{let{isBlocked:n}=t;(0,b.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},$0=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),e2=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,t2=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},n2=(e,t)=>{let n=e=>yj(t)?yj(e):e.state===t.state&&!yj(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},r2=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},i2=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=t2(n,t);return e.map(e=>e.id===t.id?r:e)},a2=(e,t)=>{let n=t2(e.find(e=>e.id===t.id),t);return n2(s2(e,t.id),n)},o2=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=e2(n.find(t=>t.id===e.id),e)?a2(n,e):i2(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},s2=(e,t)=>e.filter(e=>e.id!==t),c2=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=s2(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return n2(s,o)},l2=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},u2=(0,b.createContext)(null),d2=15*1e3,f2=1e3,p2=async e=>l2(`Ticket done`,e),m2=e=>$0(e),h2=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,g2=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)([]),[d,f]=(0,b.useState)([]),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(null),[y,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),w=(0,b.useRef)(0),E=(0,b.useRef)(0),D=(0,b.useRef)(new Map),O=(0,b.useRef)(new Map),A=(0,b.useRef)(e),j=(0,b.useRef)(new Map),M=(0,b.useRef)(new Map),N=(0,b.useRef)(new Map),P=(0,b.useCallback)((e,t)=>{let n=M.current.get(t.id);return!n||!e||t.state===n?t:e},[]),F=(0,b.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(M.current);for(let r of e)n.set(r,t);M.current=n},[]),I=(0,b.useCallback)(e=>{if(e.length===0||M.current.size===0)return;let t=new Map(M.current);for(let n of e)t.delete(n);M.current=t},[]),L=(0,b.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(N.current);for(let r of e)n.set(r,t);N.current=n},[]),R=(0,b.useCallback)(e=>{if(e.length===0||N.current.size===0)return;let t=new Map(N.current);for(let n of e)t.delete(n);N.current=t},[]),z=(0,b.useCallback)((e,t)=>{if(j.current.has(t.id))return null;let n=P(e,t);return N.current.has(t.id)?{...n,parked_at:N.current.get(t.id)??null}:n},[P]),ee=(0,b.useCallback)((e,t)=>{if(j.current.size===0&&M.current.size===0&&N.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=z(n.get(e.id),e);return t?[t]:[]})},[z]),B=(0,b.useCallback)(async(e,t)=>{let n=await ie(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&A.current===e&&c(e=>o2(e,ee(e,n).map(m2))),n):null},[ee]),V=(0,b.useCallback)(async(e,t)=>{await B(e,t)},[B]),H=(0,b.useCallback)(async(e,t)=>{let n=++E.current,r=await ae(e,t);if(!Array.isArray(r)||t?.aborted||A.current!==e||E.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));c(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),te=(0,b.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),U=(0,b.useCallback)(async e=>{let t=A.current;if(!t)return null;try{let n=await G(e,t);if(A.current!==t)return null;let r=O.current.get(n.id),i=z(r,n);if(!i)return null;let a=m2(i),o=e2(r,a);return c(e=>o?a2(e,a):i2(e,a)),n}catch{return null}},[z]),ne=(0,b.useCallback)(async t=>{if(!e){f([]);return}f(await k(e,t))},[e]),W=(0,b.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),re=(0,b.useMemo)(()=>{let e=s.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:S}},[S,s]);(0,b.useEffect)(()=>{O.current=W},[W]),(0,b.useEffect)(()=>{A.current=e,j.current.clear(),M.current.clear(),N.current.clear(),C(null),m(null),D.current.clear()},[e]),(0,b.useEffect)(()=>{n?.(_?null:h)},[h,_,n]),(0,b.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(h!==e){i(e,[]);return}i(e,d)}},[e,d,h,i]),(0,b.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,y===e)}},[e,y,a]),(0,b.useEffect)(()=>{let t=new AbortController,n=++w.current,r=null,i=async()=>{try{if(!e){c([]),u([]),f([]),g(null),v(null);return}c([]),u([]),f([]),g(null),v(e),x(e);let[n,i,a]=await Promise.allSettled([B(e,t.signal),H0(e,t.signal),k(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!T(n.reason)&&c([]),i.status===`fulfilled`?u(i.value):T(i.reason)||u([]),a.status===`fulfilled`?f(a.value):T(a.reason)||f([]),g(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&te(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||H(e,t.signal)},f2))}finally{!t.signal.aborted&&w.current===n&&(v(null),x(null))}},a=t=>{t.project_id===e&&(m(t),!j.current.has(t.id)&&(t.bundle&&f(e=>r2(e,t.bundle)),c(e=>a2(e,m2(t)))))},o=t=>{if(t.project_id===e&&m(t),c(n=>{if(t.project_id!==e)return s2(n,t.id);let r=n.find(e=>e.id===t.id),i=z(r,t);if(!i)return n;let a=m2(i);return e2(r,a)?a2(n,a):i2(n,a)}),t.project_id!==e){u(e=>jj(e,t.id));return}t.bundle&&f(e=>r2(e,t.bundle))},s=({id:e})=>{j.current.delete(e),N.current.delete(e),M.current.delete(e),c(t=>s2(t,e)),u(t=>jj(t,e))},l=e=>{if(!e)return;let t=O.current.get(e.blocker_ticket_id),n=O.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==A.current||n.project_id!==A.current||u(t=>Mj(t,e))},d=e=>{u(t=>Nj(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),EZ.on(`ticket:created`,a),EZ.on(`ticket:updated`,o),EZ.on(`ticket:deleted`,s),EZ.on(`ticket-dependency:created`,l),EZ.on(`ticket-dependency:deleted`,d),()=>{t.abort(),r!==null&&window.clearTimeout(r),EZ.off(`ticket:created`,a),EZ.off(`ticket:updated`,o),EZ.off(`ticket:deleted`,s),EZ.off(`ticket-dependency:created`,l),EZ.off(`ticket-dependency:deleted`,d)}},[e,H,t,te,B,z]),(0,b.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([B(e,t.signal),ne(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&te(n[0].value)&&H(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,d2),i=P$(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,ne,H,te,B]),(0,b.useEffect)(()=>{if(!e||!r||h!==e)return;let t=s.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:s.length,worktreeCount:t,repoPathLocked:s.length>0||t>0||d.length>0})},[e,d.length,h,r,s]),(0,b.useEffect)(()=>{for(let e of s){let t=D.current.get(e.id),n=h2(e,t);n&&C(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&p2(e.title),D.current.set(e.id,e.agent_status)}},[s]);let oe=(0,b.useCallback)(()=>{m(null)},[]),se=(0,b.useMemo)(()=>({tickets:s,setTickets:c,dependencies:l,setDependencies:u,bundles:d,setBundles:f,latestDetailedTicketUpdate:p,clearLatestDetailedTicketUpdate:oe,loadedProjectId:h,loadingProjectId:_,activeProjectIdRef:A,pendingDeletedTicketsRef:j,pendingOptimisticMovesRef:M,pendingParkedTicketsRef:N,refreshTickets:V,requestSingleTicketRefresh:U,refreshBundles:ne,resolvePendingTicket:z,resolvePendingTickets:ee,markPendingOptimisticMoves:F,clearPendingOptimisticMoves:I,markPendingParkedTickets:L,clearPendingParkedTickets:R,liveActivity:re}),[d,oe,I,R,l,re,h,p,_,F,L,ne,V,U,z,ee,s]);return(0,q.jsx)(u2.Provider,{value:se,children:o})},_2=()=>{let e=(0,b.useContext)(u2);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},v2=e=>e===1?`1 ticket created`:`${e} tickets created`,y2=async e=>l2(`Planning done`,v2(e)),b2=`archon.last-model-selection`,x2=`archon.last-variant-selection`,S2=`archon.last-skills-selection`,C2=()=>{try{let e=window.localStorage.getItem(S2),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},w2=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),T2=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},E2=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,D2=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=w2(t);return n.every(e=>r.some(t=>t.includes(e)))},O2=[`plan`,`build`,`review`],k2=`done`,A2=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),j2=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,M2=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?_j(n):e.ticket_id},N2=()=>({description:``,model:window.localStorage.getItem(b2)??``,variant:window.localStorage.getItem(x2)??``,skills:C2(),worktreeBundleId:``}),P2=()=>({isOpen:!1,composer:N2(),runs:[]}),F2=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,I2=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),L2=(e,t,n)=>e.map(e=>e.id===t?n(e):e),R2=(e,t,n)=>{e?window.localStorage.setItem(b2,e):window.localStorage.removeItem(b2),t?window.localStorage.setItem(x2,t):window.localStorage.removeItem(x2),n.length>0?window.localStorage.setItem(S2,JSON.stringify(n)):window.localStorage.removeItem(S2)},z2=(e,t={})=>dv(e,t),B2=()=>({model:window.localStorage.getItem(b2)??``,variant:window.localStorage.getItem(x2)??``,skills:C2()}),V2=(e,t)=>{let n=s2(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},H2=e=>e.tickets.length>0&&e.tickets.every(e=>Ej(e,`trash`)),U2=e=>e.tickets.length>0&&e.tickets.every(e=>Ej(e,k2)),W2=e=>e.column===k2&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),G2=(e,t,n)=>n||t!==null&&t!==_j(e)?`Stop the currently running ticket before starting another run.`:zj(e),K2=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},q2=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,J2=(e,t,n)=>t===`review`&&n===`build`?{}:K2(e,n),Y2=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let l=LO(IO(zk,{activationConstraint:{distance:5}})),{tickets:u,setTickets:d,dependencies:f,setDependencies:p,bundles:m,setBundles:h,latestDetailedTicketUpdate:g,clearLatestDetailedTicketUpdate:_,loadedProjectId:v,loadingProjectId:y,activeProjectIdRef:x,pendingDeletedTicketsRef:C,requestSingleTicketRefresh:w,refreshBundles:E,resolvePendingTicket:D,markPendingOptimisticMoves:O,clearPendingOptimisticMoves:k,markPendingParkedTickets:N,clearPendingParkedTickets:P}=_2(),[z,ee]=(0,b.useState)(null),[B,U]=(0,b.useState)(null),[ne,W]=(0,b.useState)(null),[re,ie]=(0,b.useState)({x:0,y:0}),[ae,G]=(0,b.useState)(!1),[ce,ue]=(0,b.useState)(!1),[de,K]=(0,b.useState)([]),[fe,pe]=(0,b.useState)([]),[me,he]=(0,b.useState)(!1),[Ne,Pe]=(0,b.useState)({}),[Fe,Ie]=(0,b.useState)(!1),[Le,Re]=(0,b.useState)(!1),[ze,Be]=(0,b.useState)(null),[Ve,He]=(0,b.useState)(null),[Ue,We]=(0,b.useState)(null),[Ge,Ke]=(0,b.useState)(null),[qe,Je]=(0,b.useState)(null),[Ye,Xe]=(0,b.useState)(null),[Ze,Qe]=(0,b.useState)(null),[$e,et]=(0,b.useState)(null),[tt,nt]=(0,b.useState)(!1),[rt,it]=(0,b.useState)(A2()),[at,ot]=(0,b.useState)(0),[st,ct]=(0,b.useState)(``),[lt,ut]=(0,b.useState)(!1),dt=i===`opencode`||Ue?.tool===`opencode`||!!Ye?.tickets.some(e=>e.tool===`opencode`),ft=i===`opencode`&&de.length>0,pt=Ue?.tool===`opencode`&&de.length>0,mt=!!Ye?.tickets.some(e=>e.tool===`opencode`)&&de.length>0,ht=(0,b.useRef)(e),_t=(0,b.useRef)(null),vt=(0,b.useRef)(null),yt=u.find(e=>e.is_running)??null,bt=yt?_j(yt):null,xt=r?.context_key??null,St=r?.kind===`ticket`?M2(r,u)??bt:bt,Ct=r?.kind===`project`,wt=(0,b.useCallback)(e=>j2({bundleId:e,activeRunContextKey:St,isProjectRootRunActive:Ct}),[St,Ct]),Tt=z!==null&&Ej(z,`trash`)||B!==null&&H2(B),Et=y===e,Dt=(0,b.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]);(0,b.useEffect)(()=>{if(!Ve){We(null);return}let e=Dt.get(Ve)??null;e&&We(t=>!t||t.id!==Ve?e:E2(t,e))},[Ve,Dt]),(0,b.useEffect)(()=>{g&&(We(e=>!e||e.id!==g.id?e:E2(e,g)),Xe(e=>{if(!e)return e;let t=g.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===g.id)?e.tickets.map(e=>e.id===g.id?E2(e,g):e):[...e.tickets,g];return{...e,tickets:n}}))},[g]),(0,b.useEffect)(()=>{g===null||Ve!==null||Ge!==null||_()},[_,g,Ge,Ve]);let Ot=(0,b.useCallback)(async e=>{let t=await w(e);if(!t)return null;let n=Dt.get(e),r=n?E2(t,n):t;return We(t=>t&&t.id!==e||Ve&&Ve!==e?t:r),r},[w,Ve,Dt]),kt=(0,b.useCallback)(e=>{We(e),He(e.id),Ot(e.id)},[Ot]),At=(0,b.useMemo)(()=>new Map(m.map(e=>[e.id,e])),[m]),jt=(0,b.useMemo)(()=>{if(!Ye)return null;let e=Ye.bundle.id,t=g?.worktree_bundle_id===e?g:null,n=u.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=Ye.tickets.filter(e=>!C.current.has(e.id)).map(e=>t&&e.id===t.id?E2(e,t):e);t&&!i.some(e=>e.id===t.id)&&!C.current.has(t.id)&&i.push(t);let a=i.map(e=>E2(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(T2);let o=Ye.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),d=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!d&&n.some(e=>e.can_re_review===!0)},p=cv(a),m=a.find(e=>e.id===Ye.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=dv(a,{targetTicketId:Ye.target_ticket_id,reviewOwnerTicketId:m?.id??Ye.review_owner_ticket_id,latestSessionTicketId:p?.id??Ye.latest_session_ticket_id});return{...Ye,bundle:At.get(e)??Ye.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:Ye.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:Ye.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:Ye.can_re_review}},[At,g,C,Ye,u]),Mt=(0,b.useMemo)(()=>u.filter(e=>lt&&xj(e)?!1:D2(st,e)),[lt,st,u]),Nt=(0,b.useMemo)(()=>Mt.filter(e=>yj(e)),[Mt]),Pt=(0,b.useMemo)(()=>fv(Nt,m,k2),[m,Nt]),{boardViewportRef:Ft,boardContentRef:It,registerTicketNode:Lt,measuredCardRects:Rt,overlayPreview:zt,overlaySize:Bt,getDependencyTargetState:Vt,handleDependencyStart:Ht,handleDeleteDependency:Ut}=q0({activeProjectId:e,tickets:u,dependencies:f,setDependencies:p,activeTicket:z,activeOverlayNode:ne,dragOffset:re}),Wt=e?Ne[e]??P2():P2(),Gt=Wt.composer.worktreeBundleId&&m.some(e=>e.id===Wt.composer.worktreeBundleId)?Wt.composer.worktreeBundleId:``,Kt=Gt===Wt.composer.worktreeBundleId?Wt:{...Wt,composer:{...Wt.composer,worktreeBundleId:Gt}},qt=B2(),Jt=!!t?.run_ide?.trim(),Yt=Kt.runs.filter(e=>e.boardVisible),Xt=(0,b.useCallback)((e,t,n=u)=>{let r=fv(n,m,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[m,u]),Zt=(0,b.useCallback)(e=>(0,q.jsx)(HZ,{ticket:e,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&de.length>0,availableModels:de,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,de,m,f,u]),Qt=Yt.length>0?(0,q.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:Yt.map(e=>(0,q.jsx)(P0,{run:e},e.id))}):null,$t=(0,b.useCallback)(t=>uv(t)?t.project_id===e?Jt:!!t.has_run_ide:!1,[Jt,e]),en=(0,b.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&uv(e),[]),tn=(0,b.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?$t(t):!1},[$t]),nn=(0,b.useCallback)(e=>{let t=u.filter(t=>t.worktree_bundle_id===e).sort(T2);return Ye?.bundle.id===e?z2(Ye.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(T2),{targetTicketId:Ye.target_ticket_id,reviewOwnerTicketId:Ye.review_owner_ticket_id,latestSessionTicketId:Ye.latest_session_ticket_id}):z2(t)},[Ye,u]),rn=(0,b.useCallback)((e,t)=>{Pe(n=>({...n,[e]:t(n[e]??P2())}))},[]);(0,b.useEffect)(()=>{Ie(!1),Re(!1),ht.current!==e&&(_t.current=e),e||(_t.current=null,ct(``)),ht.current=e},[e,c]),(0,b.useLayoutEffect)(()=>{!e||v!==e||_t.current===e&&(_t.current=null,ct(``))},[e,v]),(0,b.useEffect)(()=>{if(!dt){pe([]);return}let t=new AbortController;return(async()=>{try{K(await gt(`opencode`,t.signal))}catch(e){T(e)||K(e=>e)}})(),(async()=>{try{pe(await rj(`opencode`,t.signal,e))}catch(e){T(e)||pe([])}})(),()=>{t.abort()}},[e,dt]);let an=({active:e})=>{he(!1),W(null),ie({x:0,y:0});let t=mv(String(e.id));if(t){U(Xt(t.bundleId,t.column)),ee(null);return}U(null),ee(u.find(t=>t.id===e.id)??null)},on=()=>{he(!1),W(null),ie({x:0,y:0}),ee(null),U(null)},sn=(0,b.useCallback)(e=>{d(t=>e.reduce((e,t)=>a2(e,t),t))},[d]),cn=(0,b.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&d(r=>e.reduce((e,r)=>c2(e,r.id,t,J2(r,n,t)),r))},[d]),ln=(0,b.useCallback)((e,t=u)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(T2),[u]),un=async({active:e,over:t})=>{let n=mv(String(e.id)),r=u.find(t=>t.id===e.id),i=n?Xt(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&Ej(r,`trash`)||i!==null&&H2(i)),o=t?.id&&O2.includes(t.id)?t.id:null;if(he(a),W(null),ie({x:0,y:0}),ee(null),U(null),t){if(n){if(t.id===`trash`){if(!i||!H2(i))return;await Sn(i);return}if(t.id===k2){if(!i||!U2(i))return;await yn(i);return}if(o){if(n.column===k2){if(!i||!W2(i))return;await bn(i);return}await Yn(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!Ej(r,`trash`))return;Tn(e.id);return}if(t.id===k2){if(!r||!Ej(r,k2))return;await _n(e.id);return}if(o){if(r&&Tj(r,o)){await vn(e.id);return}if(!(!r||!Ej(r,o)))try{await hn(r,o,{optimistic:!0})}catch(e){X.error(e instanceof S?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}}}},dn=async(t,n,r,a,o,s,c)=>{let l=await oe({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(R2(a,o,s),d(e=>a2(e,$0(l))),l.bundle&&h(e=>r2(e,l.bundle)),r===`build`)try{await hn(l,`build`)}catch(e){X.error(e instanceof S?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}r===`plan`&&Me(l.id,l.project_id)},fn=async t=>{if(!e)throw Error(`Cannot create a bundle without an active project.`);let n=await A(e,{name:t,prepare:!0});return h(e=>r2(e,n)),n},pn=e=>{d(t=>[...e.tickets].reverse().reduce((e,t)=>a2(e,$0(t)),t)),p(t=>e.dependencies.reduce((e,t)=>Mj(e,t),t));for(let t of e.tickets)t.bundle&&h(e=>r2(e,t.bundle))},mn=(0,b.useCallback)((e,t={})=>{let n=$0(e);d(e=>t.reorderInState?a2(e,n):i2(e,n)),We(t=>!t||t.id!==e.id?t:E2(e,n)),e.bundle&&h(t=>r2(t,e.bundle))},[h,d]),hn=async(e,t,n={})=>{let r=u.findIndex(t=>t.id===e.id),i=t===`review`?ln(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(O(o,t),a?cn(i,t):d(n=>c2(n,e.id,t,K2(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await I(e.project_id,e.worktree_bundle_id);Rn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(`Requested ticket was not returned from the bundle review response.`);return k(o),n}let n=await le(e.id,e.project_id,t);return d(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:e2(i,n)?a2(r,n):i2(r,n)}),n.bundle&&h(e=>r2(e,n.bundle)),k(o),n}catch(t){throw n.optimistic&&(a?sn(i):d(t=>c2(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),k(o)),t}},gn=(e,t)=>{d(n=>n.map(n=>n.id===e?{...n,...t}:n))},_n=async t=>{let n=u.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();N([t],r),gn(t,{parked_at:r}),mn(await be(t,n.project_id??e),{reorderInState:!0}),P([t])}catch(e){P([t]),gn(t,{parked_at:n.parked_at}),X.error(e instanceof S?e.message:`Unable to park the ticket right now.`,{id:`board-park-error`})}},vn=async t=>{let n=u.find(e=>e.id===t);if(n)try{N([t],null),gn(t,{parked_at:null}),mn(await xe(t,n.project_id??e),{reorderInState:!0}),P([t])}catch(e){P([t]),gn(t,{parked_at:n.parked_at}),X.error(e instanceof S?e.message:`Unable to return the ticket right now.`,{id:`board-unpark-error`})}},yn=(0,b.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();N(e.tickets.map(e=>e.id),r),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>be(e.id,e.project_id??x.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){P([t.value.id]),mn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;P([...a]),d(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof S?o.reason.message:`Unable to move the bundle to Done right now.`:`Moved ${e.tickets.length-a.size} of ${e.tickets.length} bundle tickets to Done.`;X.error(s,{id:`board-bundle-park-error`})},[x,mn,P,N,d]),bn=(0,b.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));N(e.tickets.map(e=>e.id),null),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>xe(e.id,e.project_id??x.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){P([t.value.id]),mn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;P([...i]),d(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof S?a.reason.message:`Unable to restore the bundle right now.`:`Restored ${e.tickets.length-i.size} of ${e.tickets.length} bundle tickets.`;X.error(o,{id:`board-bundle-unpark-error`})},[x,mn,P,N,d]),xn=async t=>{e&&(await te(e,t),h(e=>e.filter(e=>e.id!==t)))},Sn=(0,b.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:u.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)C.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));d(e=>e.filter(e=>!r.has(e.id))),p(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await ve(t.ticket.id,t.ticket.project_id??e),C.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===x.current)&&E().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)C.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===x.current)&&d(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>V2(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof S?o.reason.message:`Unable to delete the bundle tickets right now.`:`Deleted ${n.length-a.length} of ${n.length} bundle tickets.`;X.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,x,C,E,p,d,u]),Cn=e=>{let t=Dt.get(e.id);mn(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&h(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===x.current&&E().catch(()=>{})},wn=async()=>{if(!e)return;let t=e,n=Wt.composer.description.trim();if(!n)return;let r=F2(),a=ft?Wt.composer.model.trim():``,o=ft&&a?Wt.composer.variant.trim():``,s=ft?Wt.composer.skills:[],c=Date.now();rn(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:Gt,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await se({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:Gt||null});R2(a||null,a&&o||null,s);let c=I2(e);rn(t,e=>({...e,runs:L2(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),X.success(`${c.ticketCount} ${c.ticketCount===1?`card`:`cards`} created`,{id:`planning-agent-success-${r}`}),y2(e.tickets.length),x.current===t&&pn(e)}catch(e){let n=e instanceof S?e.message:`Unable to generate tickets right now.`;rn(t,e=>({...e,runs:L2(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),X.error(n,{id:`planning-agent-error`})}},Tn=async t=>{let n=u.find(e=>e.id===t),r=u.findIndex(e=>e.id===t);if(!(!n||r===-1)){C.current.set(t,{ticket:n,index:r}),d(e=>s2(e,t)),p(e=>jj(e,t));try{await ve(t,n.project_id??e),n.project_id===x.current&&E().catch(()=>{}),C.current.delete(t)}catch(e){let n=C.current.get(t);C.current.delete(t),n&&n.ticket.project_id===x.current&&(d(e=>V2(e,n)),X.error(e instanceof S?e.message:`Unable to delete the ticket right now.`,{id:`board-delete-error`}))}}},En=async t=>{let n=u.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(Be(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Rn(await L(n.project_id,n.worktree_bundle_id));return}mn(await ye(t,n.project_id??e),{reorderInState:!0})}catch(e){throw X.error(e instanceof S?e.message:`Unable to undo the ticket right now.`,{id:`board-undo-error`}),e}finally{Be(e=>e===r?null:e)}},Dn=t=>{Ce(t,u.find(e=>e.id===t)?.project_id??e)},On=async t=>{let n=u.find(e=>e.id===t);try{await we(t,n?.project_id??e),s?.()}catch(e){X.error(e instanceof S?e.message:`Unable to start the run right now.`,{id:`board-run-error`})}},kn=(0,b.useCallback)(async t=>{let n=u.find(e=>e.id===t);try{await Te(t,n?.project_id??e)}catch(e){X.error(e instanceof S?e.message:`Unable to open the IDE right now.`,{id:`board-open-ide-error`})}},[e,u]),An=async t=>{let n=u.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&St===_j(n)?xt:null;try{await Ee(t,n?.project_id??e),o?.(i),s?.()}catch{}},jn=t=>{De(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Mn=t=>{Oe(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},Nn=(0,b.useCallback)(e=>{let t=nn(e);!t||!$t(t)||kn(t.id)},[$t,nn,kn]),Pn=(0,b.useCallback)(e=>{let t=nn(e);t&&et({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?.name??t.title})},[nn]),Fn=(0,b.useCallback)(e=>{let t=u.find(t=>t.id===e);!t||!en(t)||Qe({ticketId:t.id,projectId:t.project_id,title:t.title})},[en,u]),In=(0,b.useCallback)(async(t,n)=>{let r=u.find(e=>e.id===t);if(r)try{mn(r.state===`plan`?await je(t,r.project_id??e,n):await ke(t,r.project_id??e,n))}catch(e){throw X.error(e instanceof S?e.message:`Unable to send the follow-up prompt right now.`,{id:`board-follow-up-error`}),e}},[e,mn,u]),Ln=(0,b.useCallback)(e=>{d(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=D(n,t);if(!r)return e;let i=$0(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return e2(n,i)?a2(e,i):i2(e,i)},t))},[D,d]),Rn=(0,b.useCallback)(e=>{Xe(e),h(t=>r2(t,e.bundle)),Ln(e.tickets)},[Ln,h]),zn=(0,b.useCallback)((e,t)=>{Array.isArray(t.tickets)&&Xe(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),Bn=(0,b.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await j(t,e);return x.current===t?(Rn(n),n):null},[x,Rn]),Vn=(0,b.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await M(t,e);return x.current===t?(zn(e,n),n):null},[x,zn]),Hn=(0,b.useCallback)(async(e,t=null)=>{let n=x.current;if(!n)return;He(null),We(null),Ke(e),Je(t),it(A2());let r=At.get(e)??null,i=u.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=cv(i),t=dv(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});Xe({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else Xe(null);nt(!0);try{await Vn(e)}catch{}finally{x.current===n&&nt(!1)}},[x,At,Vn,u]),Un=(0,b.useCallback)(async(e,t)=>{it(t=>({...t,[e]:!0}));try{return await t()}finally{it(t=>({...t,[e]:!1}))}},[]),Wn=(0,b.useCallback)(async t=>{await Un(`stopBuild`,async()=>{let n=u.find(e=>e.id===t);await De(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await Bn(n.worktree_bundle_id)})},[e,Bn,Un,d,u]),Gn=(0,b.useCallback)(async t=>{await Un(`resumeBuild`,async()=>{let n=u.find(e=>e.id===t);await Oe(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await Bn(n.worktree_bundle_id)})},[e,Bn,Un,d,u]),Kn=(0,b.useCallback)(async t=>{if(e)try{Rn(await Un(`build`,()=>F(e,t))),Ge===t&&Je(`build`),s?.()}catch(e){throw X.error(e instanceof S?e.message:`Unable to build the bundle right now.`,{id:`board-bundle-build-error`}),e}},[e,Rn,s,Un,Ge]),qn=(0,b.useCallback)(async t=>{if(e)try{Rn(await Un(`review`,()=>I(e,t))),Ge===t&&Je(`review`)}catch(e){throw X.error(e instanceof S?e.message:`Unable to review the bundle right now.`,{id:`board-bundle-review-error`}),e}},[e,Rn,Un,Ge]),Jn=(0,b.useCallback)(async t=>{if(e)try{Be(`review`),Rn(await Un(`undoReview`,()=>L(e,t))),Ge===t&&Je(`build`)}catch(e){throw X.error(e instanceof S?e.message:`Unable to undo the bundle review right now.`,{id:`board-bundle-undo-review-error`}),e}finally{Be(e=>e===`review`?null:e)}},[e,Rn,Un,Ge]),Yn=(0,b.useCallback)(async(e,t,n)=>{if(t===k2||n===k2)return;let r=q2(t,n);if(!r)return;let i=u.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);O(a,n),cn(i,n);try{if(r===`build`){await Kn(e),k(a);return}if(r===`review`){await qn(e),k(a);return}await Jn(e),k(a)}catch(e){sn(i),k(a),X.error(e instanceof S?e.message:`Unable to move the bundle right now.`,{id:`board-bundle-move-error`})}},[k,Kn,qn,Jn,O,cn,sn,u]),Xn=async t=>{e&&(Rn(await Un(`run`,()=>V(e,t))),s?.())},Zn=async t=>{if(!e)return;let n=r?.kind===`ticket`&&St===t?xt:null,i=await Un(`stop`,()=>H(e,t));o?.(n),Rn(i),s?.()},Qn=(0,b.useCallback)(async(t,n)=>{e&&Rn(await Un(`followUp`,()=>R(e,t,n)))},[e,Rn,Un]);(0,b.useEffect)(()=>()=>{a?.(null)},[a]),(0,b.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:`Preview selection is unavailable for project root runs.`,submitPrompt:null});return}let e=u.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:`Preview selection is only available for build-capable ticket runs.`,submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:`Preview selection is unavailable while this ticket is in Plan mode.`,submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,submitPrompt:t=>Qn(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,submitPrompt:t=>In(e.id,t)})},[r,In,Qn,a,u]);let $n=async t=>{let n=u.find(e=>e.id===t),r=n?hj(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await Ae(n.id,n.project_id??e);mn(t),t.worktree_bundle_id&&await Bn(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await qn(n.worktree_bundle_id);return}await hn(n,r)}catch(e){throw X.error(e instanceof S?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`}),e}},er=async t=>{let n=u.find(e=>e.id===t);try{mn(await ge(t,n?.project_id??e))}catch(e){throw X.error(e instanceof S?e.message:`Unable to start the build chain right now.`,{id:`board-build-chain-error`}),e}},tr=async t=>{let n=u.find(e=>e.id===t);try{await _e(t,n?.project_id??e)}catch(e){throw X.error(e instanceof S?e.message:`Unable to stop the build chain right now.`,{id:`board-stop-build-chain-error`}),e}},nr=async()=>{if(!(!e||Le)){Re(!0);try{let t=await Se(e);d(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),p(e=>t.deleted_ticket_ids.reduce(jj,e)),await E(),Ie(!1),t.failed_count>0?X.error(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}, but ${t.failed_count} failed.`,{id:`board-delete-parked-error`}):X.success(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}.`,{id:`board-delete-parked-success`})}catch(e){X.error(e instanceof S?e.message:`Unable to empty Done right now.`,{id:`board-delete-parked-error`})}finally{Re(!1)}}},rr=({delta:e})=>{ie(e)},ir=(0,b.useCallback)(()=>{e&&G(!0)},[e]),ar=(0,b.useCallback)(()=>{e&&rn(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,rn]),or=(0,b.useCallback)(()=>{vt.current?.focus({preventScroll:!0})},[]);return Q0([{key:`n`,onKeyDown:ir,disabled:!e},{key:`a`,onKeyDown:ar,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:or}],{isBlocked:Z0}),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(IA,{sensors:l,collisionDetection:JO,onDragStart:an,onDragMove:rr,onDragCancel:on,onDragEnd:un,children:[(0,q.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,q.jsx)(B0,{projectId:e,state:Kt,bundles:m,projectBranchState:n,showModelSelector:ft,availableModels:de,availableSkills:fe,onManageBundles:e?()=>{(async()=>{try{await E()}catch{}ue(!0)})()}:void 0,onToggle:()=>{e&&rn(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=de.find(e=>e.id===t)??null;rn(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{wn()}}),(0,q.jsx)(`div`,{"aria-hidden":`true`,className:J(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Kt.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,q.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,q.jsx)(Dg,{id:`board-ticket-search`,ref:vt,type:`search`,value:st,onChange:e=>ct(e.target.value),placeholder:`Search tickets`,"aria-label":`Search tickets`,className:`pr-32`}),st.length>0?(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Clear search`,className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{ct(``),vt.current?.focus()},children:(0,q.jsx)(kv,{className:`size-4`})}):(0,q.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,q.jsx)(__,{children:`CTRL`}),(0,q.jsx)(`span`,{children:`+`}),(0,q.jsx)(__,{children:`K`})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(sy,{id:`board-hide-stale-tickets`,checked:lt,onCheckedChange:ut,"aria-label":`Hide stale tickets`}),(0,q.jsx)(Vg,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:`Hide stale tickets`})]})]}),(0,q.jsx)(`div`,{ref:Ft,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,q.jsxs)(`div`,{ref:It,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,q.jsx)(A0,{dependencies:f,cardRects:Rt,preview:zt,ticketsById:Dt,overlaySize:Bt}),O2.map(t=>{let n=u.filter(e=>e.state===t&&!yj(e)),r=Mt.filter(e=>e.state===t&&!yj(e)),i=fv(r,m,t),a=Et&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,q.jsx)(WZ,{id:t,title:t.charAt(0).toUpperCase()+t.slice(1),pinnedContent:t===`plan`?Qt:null,items:i,ticketCount:r.length,allTickets:u,dependencies:f,showModelSelector:ft,availableModels:de,bundles:m,activeRunContextKey:St,isProjectRootRunActive:Ct,isBundleRunDisabled:wt,getDependencyTargetState:Vt,onDependencyStart:Ht,onDeleteDependency:Ut,onRegisterTicketNode:Lt,onAddTicket:t===`plan`&&e?ir:void 0,onCreateBundle:t===`plan`&&e?fn:void 0,onDeleteBundle:t===`plan`&&e?xn:void 0,onDeleteBundleWrapper:Sn,onRefreshBundles:t===`plan`&&e?E:void 0,onUpdateTicket:Cn,onDeleteTicket:Tn,onUndoTicket:En,undoingColumn:ze,onRetryTicket:Dn,onAdvanceTicket:$n,onParkTicket:_n,onUnparkTicket:vn,onBuildChainTicket:er,onRunTicket:On,canOpenChangesForTicket:en,onOpenChangesTicket:Fn,canOpenIdeForTicket:$t,onOpenIdeTicket:kn,onStopTicket:An,onStopBuildTicket:jn,onStopBuildChainTicket:tr,onResumeBuildTicket:Mn,onOpenBundleChanges:Pn,onOpenBundleIde:Nn,onFollowUpTicket:In,bundleActionState:rt,onBuildBundle:Kn,onReviewBundle:qn,onUndoBundleReview:Jn,onRunBundle:Xn,onStopBundle:Zn,onParkBundleWrapper:yn,onUnparkBundleWrapper:bn,onOpenTicketDetails:kt,onOpenBundleDetails:(e,t)=>{Hn(e,t)},onRequestBundleRefresh:e=>{Un(`bundleRefresh`,()=>Bn(e))},onRequestTicketRefresh:w,loadingSkeletonCount:a},t)}),(0,q.jsx)(WZ,{id:k2,title:`Done`,items:Pt,ticketCount:Nt.length,allTickets:u,dependencies:f,showModelSelector:ft,availableModels:de,bundles:m,activeRunContextKey:St,isProjectRootRunActive:Ct,isBundleRunDisabled:wt,getDependencyTargetState:Vt,onDependencyStart:Ht,onDeleteDependency:Ut,onRegisterTicketNode:Lt,onUpdateTicket:Cn,onDeleteTicket:Tn,onUndoTicket:En,undoingColumn:ze,onRetryTicket:Dn,onAdvanceTicket:$n,onParkTicket:_n,onUnparkTicket:vn,onBuildChainTicket:er,onRunTicket:On,canOpenChangesForTicket:en,onOpenChangesTicket:Fn,canOpenIdeForTicket:$t,onOpenIdeTicket:kn,onStopTicket:An,onStopBuildTicket:jn,onStopBuildChainTicket:tr,onResumeBuildTicket:Mn,onOpenBundleChanges:Pn,onOpenBundleIde:Nn,onFollowUpTicket:In,bundleActionState:rt,onBuildBundle:Kn,onReviewBundle:qn,onUndoBundleReview:Jn,onRunBundle:Xn,onStopBundle:Zn,onParkBundleWrapper:yn,onUnparkBundleWrapper:bn,onOpenTicketDetails:kt,onOpenBundleDetails:(e,t)=>{Hn(e,t)},onRequestBundleRefresh:e=>{Un(`bundleRefresh`,()=>Bn(e))},onRequestTicketRefresh:w,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:Nt.length===0||Le,onClick:()=>Ie(!0),children:[(0,q.jsx)(qv,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Empty`})]})})]})})]})]}),(0,q.jsxs)(nj,{zIndex:5,dropAnimation:me?null:void 0,children:[z&&(0,q.jsx)(HZ,{ticket:z,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:z.tool===`opencode`&&de.length>0,availableModels:de,runDisabled:G2(z,St,Ct)!==void 0,runDisabledReason:G2(z,St,Ct),onDependencyStart:Ht,onDeleteDependency:Ut,onRegisterOverlayNode:W,onCreateBundle:fn,onDeleteBundle:xn,onRefreshBundles:E,onUpdate:Cn,onDelete:()=>Tn(z.id),onUndo:()=>En(z.id),undoInProgress:ze===z.state&&(z.state===`build`||z.state===`review`),onRetry:()=>Dn(z.id),onAdvance:()=>$n(z.id),onPark:()=>_n(z.id),onUnpark:()=>vn(z.id),onBuildChain:()=>er(z.id),onRun:z.worktree_bundle_id===null&&uv(z)&&z.has_run_config?()=>On(z.id):void 0,onOpenIde:z.worktree_bundle_id===null&&$t(z)?()=>kn(z.id):void 0,onStop:z.worktree_bundle_id===null?()=>An(z.id):void 0,onStopBuild:()=>jn(z.id),onStopBuildChain:()=>tr(z.id),onResumeBuild:()=>Mn(z.id),onFollowUp:e=>In(z.id,e),onRequestTicketRefresh:w}),!z&&B&&(0,q.jsx)(oM,{group:B,overlay:!0,renderTicket:Zt})]}),Tt&&(0,q.jsx)(V0,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),ae&&(0,q.jsx)(j0,{onSubmit:dn,bundles:m,projectId:e,projectBranchState:n,tool:i,showModelSelector:ft,availableModels:de,availableSkills:fe,initialModel:ft?qt.model:``,initialVariant:ft&&qt.model?qt.variant:``,initialSkills:ft?qt.skills:[],onCreateBundle:fn,onDeleteBundle:xn,onRefreshBundles:E,onClose:()=>G(!1)}),ce&&e&&(0,q.jsx)(Xv,{bundles:m,selectedBundleId:Kt.composer.worktreeBundleId||null,onSelectBundle:t=>{rn(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:fn,onDeleteBundle:xn,onClose:()=>ue(!1)}),Fe&&(0,q.jsx)(GZ,{ticketCount:Nt.length,isDeleting:Le,onCancel:()=>Ie(!1),onConfirm:()=>{nr()}}),Ue&&(0,q.jsx)(VZ,{ticket:Ue,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=Ue.id;He(null),We(null),d(t=>t.map(t=>t.id===e?$0(t):t))},showModelSelector:pt,availableModels:de,availableSkills:fe,runDisabled:G2(Ue,St,Ct)!==void 0,runDisabledReason:G2(Ue,St,Ct),onDeleteDependency:Ut,onCreateBundle:fn,onDeleteBundle:xn,onRefreshBundles:E,onUpdate:Cn,onAdvance:()=>$n(Ue.id),onBuildChain:()=>er(Ue.id),onRun:uv(Ue)&&Ue.has_run_config?()=>On(Ue.id):void 0,onOpenIde:$t(Ue)?()=>kn(Ue.id):void 0,onStop:()=>An(Ue.id),onStopBuild:()=>jn(Ue.id),onStopBuildChain:()=>tr(Ue.id),onResumeBuild:()=>Mn(Ue.id),onFollowUp:e=>In(Ue.id,e),onProjectMemorySuggestionsChanged:()=>{ot(e=>e+1)},onRequestTicketRefresh:e=>{Ot(e)}}),$e&&(0,q.jsx)(g0,{ticketId:$e.ticketId,projectId:$e.projectId,reviewCommentsBundleId:$e.bundleId,title:$e.title,onSubmitReviewPrompt:e=>Qn($e.bundleId,e),canSubmitReviewPrompt:!u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,canAddReviewComments:!u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`),canModifyChanges:!u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`),changesDisabledReason:u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before modifying changes.`:void 0,onClose:()=>{let{bundleId:e}=$e;et(null),Bn(e)},onTicketUpdate:Cn,onRequestTicketRefresh:w}),Ze&&(0,q.jsx)(g0,{ticketId:Ze.ticketId,projectId:Ze.projectId,title:Ze.title,onClose:()=>{let{ticketId:e}=Ze;Qe(null),Ot(e)},onTicketUpdate:Cn,onRequestTicketRefresh:e=>{Ot(e)}}),Ge&&jt&&(0,q.jsx)(dQ,{details:jt,activeColumn:qe,isLoading:tt||rt.bundleRefresh,actionState:rt,canOpenIde:tn(jt),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:at,runDisabled:wt(jt.bundle.id),showModelSelector:mt,availableModels:de,availableSkills:fe,onClose:()=>{let e=jt.bundle.id;Ke(null),Je(null),Xe(null),nt(!1),it(A2()),d(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==Ve?$0(t):t))},onOpenTicketDetails:kt,onUpdateTicket:Cn,onOpenIde:()=>{let e=jt.tickets.find(e=>e.id===jt.target_ticket_id)??jt.tickets.find(e=>e.has_worktree);e&&kn(e.id)},onRefresh:e=>{Un(`bundleRefresh`,()=>Bn(e))},onBuildBundle:Kn,onStopBuildTicket:Wn,onResumeBuildTicket:Gn,onReviewBundle:qn,onUndoBundleReview:Jn,onRunBundle:Xn,onStopBundle:Zn,onFollowUpBundle:Qn})]})},X2=({className:e})=>(0,q.jsx)(dh,{"aria-hidden":`true`,className:e}),Z2=({className:e})=>(0,q.jsx)(fh,{"aria-hidden":`true`,className:e}),Q2=({state:e,className:t})=>e?(0,q.jsx)(`span`,{"aria-hidden":`true`,"data-activity-indicator":`true`,"data-state":e,"data-testid":`workspace-activity-indicator`,className:J(`h-2 w-2 flex-shrink-0 rounded-full`,e===`running`?`animate-pulse bg-amber-300`:e===`interrupted`?`bg-amber-400/80 ring-1 ring-amber-400/30`:e===`error`?`bg-rose-400/90 ring-1 ring-rose-400/30`:`bg-emerald-400/80 ring-1 ring-emerald-400/30`,t)}):null,$2=4,e4=5e3,t4=e=>e.replace(/^[ab]\//,``),n4=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?t4(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?t4(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},r4=e=>{let[t,n]=n4(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},i4=e=>{let t=k$((()=>{let[t,n]=n4(e);return t??n??null})());if(!t)return null;try{return VE(e.hunks,{highlight:!0,refractor:k1.default,language:t,enhancers:[zE(e.hunks)]})}catch{return null}},a4=(e,t)=>e instanceof Error?e.message:t,o4=(e,t)=>{if(!t)return e;let n=r4(t);return[t,...e.filter(e=>r4(e)!==n)]},s4=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),c4=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},l4=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},u4={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},d4={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},f4=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,b.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?`Diff`:s?l4(s.path):`File`:e===`all`?`All changes`:s?l4(s.path):e;return(0,q.jsxs)(Hg,{open:a,onOpenChange:o,children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,className:J(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":`Open changed files`,title:e===`all`?void 0:s?.path??e,children:[(0,q.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,q.jsxs)(Z,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:[t.length,` file`,t.length===1?``:`s`]}),(0,q.jsx)(m_,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,q.jsxs)(Wg,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Changed files`})}),(0,q.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:J(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,p$(e===`all`),`justify-between`),children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`All changes`}),(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:`Review the full workspace diff.`})]}),n&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[n.files_changed,` file`,n.files_changed===1?``:`s`]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:J(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,p$(e===t.path)),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:l4(t.path)}),(0,q.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,q.jsx)(Z,{variant:`outline`,className:u4[t.status],children:d4[t.status]}),t.staged&&(0,q.jsx)(Z,{variant:`outline`,children:`Staged`}),t.unstaged&&(0,q.jsx)(Z,{variant:`outline`,children:`Unstaged`}),t.conflicted&&(0,q.jsx)(Z,{variant:`destructive`,children:`Conflicted`}),t.originalPath&&(0,q.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?`from ${t.originalPath}`:t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},p4=(0,b.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(!1),[,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(new Map),[C,w]=(0,b.useState)(!1),T=(0,b.useRef)(0),E=(0,b.useRef)(0),D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=a.selectedDiffPath,A=a.activeReviewTarget,j=a.editingReviewCommentKey,M=A?.commentKey??j??`chat`,N=a.reviewDraftInput,P=(0,b.useMemo)(()=>new Map(a.reviewComments.map(e=>[ZE(e.filePath,e.changeKey),e])),[a.reviewComments]),F=(0,b.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await JD(e,t):await qe(e)},[t,e]),I=(0,b.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await YD(e,t):await Ye(e)},[t,e]);(0,b.useEffect)(()=>{D.current=d},[d]),(0,b.useEffect)(()=>{O.current=p},[p]);let L=(0,b.useCallback)(async()=>{if(!e){E.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=T.current+1,n=E.current+1;T.current=t,E.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([F(),I()]);T.current===t&&(r.status===`fulfilled`?(D.current=r.value,f(r.value),g(null)):g(a4(r.reason,`Unable to load the diff right now.`)),i.status===`fulfilled`&&(O.current=i.value,m(i.value)),E.current===n&&v(!1),y(!1))},[F,I,e]),R=(0,b.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=T.current+1;T.current=r,y(!0);try{let t=await I();if(T.current!==r)return;let i=O.current?.workspace_signature??null,a=t.workspace_signature??null,o=!D.current||i!==a;if(O.current=t,m(t),!o){E.current+=1,v(!1);return}let s=!D.current,c=E.current+1;E.current=c,s&&v(!0);try{let t=await F();if(T.current!==r)return;D.current=t,f(t),g(null),n&&i!==a&&j$(e)}catch(e){if(T.current!==r)return;D.current||g(a4(e,`Unable to load the diff right now.`))}finally{s&&E.current===c&&v(!1)}}catch{D.current||(E.current+=1,v(!1));return}finally{T.current===r&&y(!1)}},[F,I,e]);(0,b.useEffect)(()=>{L()},[L]),(0,b.useEffect)(()=>{if(e)return M$(t=>{t===e&&R()})},[e,R]),(0,b.useEffect)(()=>{if(!e)return;let t=P$(()=>{document.visibilityState===`visible`&&R({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,R]),(0,b.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&R({broadcastOnSignatureChange:!0})},e4);return()=>{window.clearInterval(t)}},[e,R]);let z=(0,b.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?Mx(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:n4(e)})):[]},[d]),ee=(0,b.useMemo)(()=>{let e=new Map;for(let t of z)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[z]),B=(0,b.useMemo)(()=>c4({diffResponse:d,gitStatus:p}),[d,p]);(0,b.useEffect)(()=>{if(k!==`all`&&!(!d&&!p)){if(B.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}B.some(e=>e.path===k)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,k,B]);let V=k===`all`?null:ee.get(k)??null,H=(0,b.useMemo)(()=>o4(z,V),[z,V]),te=(0,b.useMemo)(()=>k===`all`?z:V?[V]:[],[z,k,V]);(0,b.useEffect)(()=>{S(new Map)},[z]),(0,b.useEffect)(()=>{if(H.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=H.slice(n,n+$2);i.length!==0&&(S(e=>{let t=new Map(e);for(let e of i){let n=r4(e);t.has(n)||t.set(n,i4(e))}return t}),n+=$2,n<H.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[H]);let U=(0,b.useMemo)(()=>{let e=new Map;for(let t of H.slice(0,$2))e.set(r4(t),i4(t));return e},[H]),ne=(0,b.useMemo)(()=>te.map(e=>({...e,tokens:x.get(r4(e))??U.get(r4(e))??null})),[U,x,te]),W=(0,b.useMemo)(()=>z.map(e=>({...e,tokens:null})),[z]),re=(0,b.useMemo)(()=>s4(a.reviewComments),[a.reviewComments]),ie=re.length,ae=n&&!C&&ie>0,G=(0,b.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),oe=(0,b.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=P.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,P]),se=(0,b.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),ce=(0,b.useCallback)(e=>{let t=P.has(e.commentKey);if(!n&&!t)return;let r=N.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[ZE(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:QE(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,P,N]),le=(0,b.useCallback)(e=>{let t=P.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,P]),ue=(0,b.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>ZE(t.filePath,t.changeKey)!==e)}))},[o]),de=(0,b.useCallback)(async()=>{if(!ae)return;w(!0);let e=sD({drafts:re,findings:[],githubComments:[],uncommittedFiles:z});try{await i(e),G(),X.success(`Changes sent to chat.`,{id:`chat-diff-review-submit-success`})}catch(e){X.error(a4(e,`Unable to send the changes right now.`),{id:`chat-diff-review-submit-error`})}finally{w(!1)}},[ae,G,i,z,re]),K=(0,b.useCallback)(e=>(0,q.jsx)(bQ,{reviewComments:re,pendingFixCount:ie,triggerMode:e===`wide`?`full`:`compact`,canSendReview:ae,isSubmittingReview:C,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:G,onSubmitReview:()=>{de()}}),[ae,G,de,C,ie,re,r]),fe=c?(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close diff panel`,className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,q.jsx)(kv,{className:`h-4 w-4`})}):null,pe=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,q.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:pe,className:J(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,q.jsx)(f$,{selectedDiffPath:k,sidebarFiles:B,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:W,renderedFiles:ne,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{L()},activeReviewTarget:A,editingReviewCommentKey:j,reviewDraftInstanceKey:M,reviewDraftInput:N,reviewComments:re,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:oe,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:se,onEditReviewDraft:le,onRemoveReviewDraft:ue,onSaveReviewDraft:ce,diffThemeClassName:v$,resolveFilePath:r4,normalizeDiffPath:t4,emptyStateTitle:`No uncommitted changes.`,emptyStateDescription:`The current project branch is clean.`,filePickerControl:e=>(0,q.jsx)(f4,{selectedDiffPath:k,sidebarFiles:B,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:K,extraHeaderControl:fe,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});p4.displayName=`ChatChangesPanel`;var m4=({projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o=!1,canShowComposer:s,isExternallyResizing:c=!1,pendingAgentRevealKey:l=null,pendingAgentRevealDelayMs:u=0,composerFocusNonce:d=0,header:f,composerControls:p,composerInlineControls:m,composerTheme:h=`default`,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b=null,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E})=>(0,q.jsx)(kB,{projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:s,header:f,composerControls:p,composerInlineControls:m,composerTheme:h,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:c,pendingAgentRevealKey:l,pendingAgentRevealDelayMs:u,composerFocusNonce:d,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b,autoFocusComposer:!0,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E}),h4={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},g4=({tone:e=`default`,className:t,children:n,...r})=>(0,q.jsx)(Z,{variant:`outline`,className:J(h4[e],t),...r,children:n}),_4=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),v4=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
172
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function wQ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var TQ=(e,t)=>Math.abs(e-t)<1.01,EQ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},DQ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},OQ=e=>e,kQ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},AQ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(DQ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(DQ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},jQ={passive:!0},MQ=typeof window>`u`?!0:`onscrollend`in window,NQ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&MQ?()=>void 0:EQ(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,jQ);let l=e.options.useScrollendEvent&&MQ;return l&&n.addEventListener(`scrollend`,c,jQ),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},PQ=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},FQ=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},IQ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:OQ,rangeExtractor:kQ,onChange:()=>{},measureElement:PQ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=CQ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=CQ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=CQ(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=CQ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?RQ({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=CQ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=CQ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return wQ(t[LQ(0,t.length-1,e=>wQ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&TQ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},LQ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function RQ({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=LQ(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var zQ=typeof document<`u`?b.useLayoutEffect:b.useEffect;function BQ({useFlushSync:e=!0,...t}){let n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,kt.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=b.useState(()=>new IQ(r));return i.setOptions(r),zQ(()=>i._didMount(),[]),zQ(()=>i._willUpdate()),i}function VQ(e){return BQ({observeElementRect:AQ,observeElementOffset:NQ,scrollToFn:FQ,...e})}var HQ=8,UQ=520,WQ=2,GQ=()=>(0,q.jsx)(`div`,{"data-testid":`ticket-diff-resize-placeholder`,className:`space-y-4 px-3 py-3`,children:[{gutter:`w-8`,code:`w-[68%]`},{gutter:`w-10`,code:`w-[54%]`},{gutter:`w-8`,code:`w-[74%]`},{gutter:`w-6`,code:`w-[38%]`},{gutter:`w-10`,code:`w-[82%]`},{gutter:`w-7`,code:`w-[61%]`},{gutter:`w-9`,code:`w-[48%]`},{gutter:`w-8`,code:`w-[71%]`},{gutter:`w-11`,code:`w-[57%]`},{gutter:`w-7`,code:`w-[66%]`},{gutter:`w-9`,code:`w-[43%]`},{gutter:`w-8`,code:`w-[76%]`}].map((e,t)=>(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-resize-placeholder-row`,className:`flex items-center gap-4`,children:[(0,q.jsx)(`div`,{className:J(`h-4 rounded bg-muted/80`,e.gutter)}),(0,q.jsx)(`div`,{className:J(`h-4 rounded bg-muted/60`,e.code)})]},`${e.gutter}-${e.code}-${t}`))}),KQ=({additions:e,deletions:t,fileCount:n})=>n===null?[{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}]:[{key:`files`,content:`${n} file${n===1?``:`s`}`,className:`text-muted-foreground`},{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}],qQ=({control:e,mode:t})=>typeof e==`function`?e(t):e??null,JQ=e=>e.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+t.changes.length,0),0),YQ=e=>oD(e),XQ=(e,t)=>{let n=`oldPath`in e&&typeof e.oldPath==`string`?t(e.oldPath):``,r=`newPath`in e&&typeof e.newPath==`string`?t(e.newPath):``;return[...new Set([r,n].filter(e=>e&&e!==`/dev/null`))]},ZQ=e=>e.subject_type===`file`,QQ=e=>e.subject_type===`line`,$Q=`border-sky-400/30 bg-sky-400/10 text-sky-100`,e$=({context:e,comment:t,reviewDraftInput:n,canEdit:r,autoFocus:i,isReadOnly:a,hasSavedComment:o,onReviewDraftInputChange:s,onCancelReviewDraft:c,onEditReviewDraft:l,onRemoveReviewDraft:u,onSaveReviewDraft:d})=>{let f=(0,b.useRef)(null),[p,m]=(0,b.useState)(()=>n),h=YQ(e.change);return(0,b.useEffect)(()=>{!i||a||f.current?.focus({preventScroll:!0})},[i,a]),(0,q.jsxs)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 p-3 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(Z,{variant:`outline`,className:$Q,children:`Manual`}),(0,q.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-sky-100/80`,children:o?`Comment on line ${h}`:`Add a comment to line ${h}`})]}),(0,q.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[a?(0,q.jsx)(`div`,{className:`whitespace-pre-wrap rounded-xl border border-sky-500/15 bg-background/70 px-3 py-2.5 text-xs text-foreground`,children:t}):(0,q.jsx)(Og,{ref:f,"aria-label":`Review comment for ${e.filePath}`,value:p,onChange:e=>{m(e.target.value),s(e.target.value)},disabled:!r,className:`min-h-20 text-xs`,placeholder:`Add a review comment for this change`}),(0,q.jsx)(`div`,{className:`flex gap-2`,children:a?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{l(e.commentKey)},disabled:!r,children:[(0,q.jsx)(Uy,{className:`h-3.5 w-3.5`}),`Edit`]}),(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{u(e.commentKey)},disabled:!r,children:`Remove`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{type:`button`,size:`xs`,onClick:()=>{d(e,p)},disabled:!r||!p.trim(),children:`Add comment`}),(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:c,children:`Cancel`})]})})]})]})},t$=e=>e===`high`?`destructive`:e===`medium`?`warning`:`outline`,n$=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,r$=({finding:e,isSelected:t,onToggle:n})=>{let[r,i]=(0,b.useState)(!1);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-slate-400/30 bg-slate-400/10 p-3 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,q.jsx)(cy,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,q.jsx)(`div`,{children:`Finding ${e.ordinal}`}),(0,q.jsx)(Z,{variant:t$(e.severity),className:`normal-case`,children:e.severity})]}),(0,q.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]}),(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,q.jsx)(Ev,{className:`h-3.5 w-3.5`}),t?`Selected`:`Fix`]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:n$(e)}),e.file_path&&(0,q.jsx)(`span`,{children:e.file_path})]}),(e.why_text||e.fix_text)&&(0,q.jsxs)(`div`,{className:`mt-3`,children:[(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{i(e=>!e)},children:r?`Hide details`:`Details`}),r&&(0,q.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-xl border border-border bg-background/60 p-3 text-xs text-foreground`,children:[e.why_text&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Why it matters`}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.why_text})]}),e.fix_text&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Requested fix`}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.fix_text})]})]})]})]})},i$=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,a$=e=>e.old_line_number!==null||e.new_line_number!==null,o$=e=>e.kind===`review`?`Review summary`:ZQ(e)?`File comment`:a$(e)||QQ(e)?`Inline comment`:`File comment`,s$=({comment:e,isSelected:t,onToggle:n})=>(0,q.jsxs)(`div`,{className:`rounded-xl border border-violet-400/30 bg-violet-400/10 p-3 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,q.jsx)(Z,{variant:`outline`,className:`border-violet-400/40 bg-violet-400/10 text-violet-100`,children:`GitHub`}),(0,q.jsx)(`span`,{children:o$(e)}),e.is_outdated&&(0,q.jsx)(Z,{variant:`warning`,className:`normal-case`,children:`Outdated`})]}),(0,q.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.author}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]}),(0,q.jsxs)(Y,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,q.jsx)(Ev,{className:`h-3.5 w-3.5`}),t?`Selected`:`Fix`]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[e.file_path&&(0,q.jsx)(`span`,{children:e.file_path}),e.kind===`inline`&&!ZQ(e)&&a$(e)&&(0,q.jsx)(`span`,{children:i$(e)}),(0,q.jsx)(`span`,{children:new Date(e.updated_at).toLocaleString()}),(0,q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-violet-200 underline underline-offset-2 transition-colors hover:text-violet-100`,children:`Open on GitHub`})]})]}),c$=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,reviewFindings:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of XQ(t,n))s.has(e)||s.set(e,t);for(let e of r){let n=e.file_path,r=n?s.get(n):null;if(!r||!n){o.push(e);continue}let c=t(r),l=null;for(let t of r.hunks){for(let n of t.changes)if(cD(e,n)){l=vT(n);break}if(l)break}if(l){let t=i.get(c)??new Map,n=t.get(l)??[];t.set(l,[...n,e]),i.set(c,t);continue}a.set(c,[...a.get(c)??[],e])}return{inlineByFilePath:i,fileLevelByFilePath:a,globalFindings:o}},l$=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,githubComments:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of XQ(t,n))s.has(e)||s.set(e,t);for(let e of r){if(e.kind===`review`||!e.file_path){o.push(e);continue}let n=s.get(e.file_path);if(!n){o.push(e);continue}let r=t(n);if(ZQ(e)||!e.subject_type&&!a$(e)){a.set(r,[...a.get(r)??[],e]);continue}let c=null;for(let t of n.hunks){for(let n of t.changes)if(sD(e,n)){c=vT(n);break}if(c)break}if(!c){o.push(e);continue}let l=i.get(r)??new Map,u=l.get(c)??[];l.set(c,[...u,e]),i.set(r,l)}return{inlineByFilePath:i,fileLevelByFilePath:a,fallbackComments:o}},u$=({filePath:e,hunks:t,activeReviewTarget:n,editingReviewCommentKey:r,reviewDraftInstanceKey:i,reviewDraftInput:a,reviewComments:o,reviewFindingsByChangeKey:s,githubCommentsByChangeKey:c,selectedReviewFindingIds:l,selectedGitHubCommentIds:u,canEditActiveReviewDraft:d,onToggleReviewFindingSelection:f,onToggleGitHubCommentSelection:p,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v})=>{let y=new Map(o.map(e=>[mD(e.filePath,e.changeKey),e]));return t.reduce((t,o)=>{for(let b of o.changes){let x=vT(b),S=mD(e,x),C=n?.commentKey===S,w=y.get(S),T=r===S,E=s.get(x)??[],D=c.get(x)??[];if(!C&&!w&&E.length===0&&D.length===0)continue;let O={filePath:e,changeKey:x,commentKey:S,hunk:o,change:b},k=!!w&&!T&&!C,A=k?w?.comment??``:a;t[x]=(0,q.jsxs)(`div`,{className:`space-y-3`,children:[E.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:l.includes(e.id),onToggle:()=>{f(e.id)}},e.id)),D.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:u.includes(e.id),onToggle:()=>{p(e.id)}},e.id)),(C||w)&&(0,q.jsx)(e$,{context:O,comment:w?.comment??``,reviewDraftInput:A,canEdit:d,autoFocus:C||T,isReadOnly:k,hasSavedComment:!!w,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v},`${i??O.commentKey}:${k?`readonly`:`editable`}`)]})}return t},{})},d$=e=>e.reduce((e,t)=>{for(let n of t.changes)e.set(vT(n),{hunk:t,change:n});return e},new Map),f$=(0,b.memo)(({selectedDiffPath:e,sidebarFiles:t,diffResponse:n,isDiffLoading:r,diffError:i,allDiffFiles:a,renderedFiles:o,viewType:s,onViewTypeChange:c,onRetry:l,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindings:h,githubComments:g,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canSelectReviewTarget:y,canEditActiveReviewDraft:x,reviewFindingsError:S,gitHubCommentsError:C,hasStaleReviewFindings:w,onSelectReviewTarget:T,onToggleReviewFindingSelection:E,onToggleGitHubCommentSelection:D,onReviewDraftInputChange:O,onCancelReviewDraft:k,onEditReviewDraft:A,onRemoveReviewDraft:j,onSaveReviewDraft:M,diffThemeClassName:N,resolveFilePath:P,normalizeDiffPath:F,emptyStateTitle:I=`No changes to show.`,emptyStateDescription:L=null,filePickerControl:R,reviewSummaryControl:z,extraHeaderControl:ee,headerLayout:B=`stacked`,surfaceVariant:V=`default`,showViewTypeToggle:H=!0,gutterVariant:te=`default`,isResizing:U=!1,resizePlaceholderLineThreshold:ne=1/0,onVisibleFilePathsChange:W})=>{let re=(0,b.useRef)(null),{mode:ie,ref:ae}=Zb({compactAt:V===`flat`?460:620,tightAt:V===`flat`?360:500}),G=!!n?.diff?.trim()||o.length>0||(n?.files.length??0)>0,oe=(0,b.useMemo)(()=>JQ(o),[o]),se=e===`all`&&o.length>=HQ,ce=U&&oe>ne,le=VQ({count:se?o.length:0,getScrollElement:()=>re.current,estimateSize:()=>UQ,overscan:WQ,initialRect:{width:0,height:900}}),ue=(0,b.useMemo)(()=>new Map(n?.files.map(e=>[e.path,e])??[]),[n?.files]),de=(0,b.useMemo)(()=>c$({allDiffFiles:a,resolveFilePath:P,normalizeDiffPath:F,reviewFindings:w?[]:h}),[a,w,F,P,h]),K=(0,b.useMemo)(()=>l$({allDiffFiles:a,resolveFilePath:P,normalizeDiffPath:F,githubComments:g}),[a,g,F,P]);(0,b.useEffect)(()=>{let e=re.current;e&&(e.scrollTop=0)},[e]),(0,b.useEffect)(()=>{let e=re.current;return()=>{let t=le;t.elementsCache?.forEach(e=>e.remove()),t.elementsCache?.clear(),window.getSelection()?.removeAllRanges(),e?.replaceChildren()}},[le]);let fe=le.getVirtualItems(),pe=(0,b.useMemo)(()=>se?fe.map(e=>P(o[e.index])):o.map(e=>P(e)),[o,P,se,fe]);(0,b.useEffect)(()=>{W?.(pe)},[W,pe]);let me=se&&fe.length>0?fe[0]?.start??0:0,he=se&&fe.length>0?Math.max(0,le.getTotalSize()-(fe[fe.length-1]?.end??0)):0,ge=se?fe.map(e=>({file:o[e.index],virtualItem:e})):o.map(e=>({file:e,virtualItem:null})),_e=e===`all`?null:t.find(t=>t.path===e)??null,ve=e===`all`?KQ({additions:n?.stats?.additions??0,deletions:n?.stats?.deletions??0,fileCount:n?.stats?.files_changed??null}):_e?KQ({additions:_e.additions,deletions:_e.deletions,fileCount:null}):[],ye=(0,b.useMemo)(()=>H?(0,q.jsxs)(mQ,{type:`single`,size:`sm`,variant:`outline`,value:s,onValueChange:e=>{(e===`split`||e===`unified`)&&c(e)},children:[(0,q.jsx)(hQ,{value:`unified`,children:`Unified`}),(0,q.jsx)(hQ,{value:`split`,children:`Split`})]}):null,[c,H,s]),be=(0,b.useMemo)(()=>[qQ({control:R,mode:ie}),qQ({control:z,mode:ie})].filter(Boolean),[R,ie,z]),xe=ye||be.length>0||ee;return(0,q.jsxs)(`section`,{className:J(`flex min-h-0 flex-1 flex-col overflow-hidden`,V===`default`?`rounded-2xl border border-border bg-background/30`:`bg-transparent`),children:[(0,q.jsx)(`div`,{ref:ae,"data-responsive-mode":ie,"data-testid":`ticket-diff-header`,className:J(`grid min-w-0 items-start gap-x-3 gap-y-2 border-b px-4 py-3`,V===`default`?`border-border`:`border-border/70 px-3`,B===`stacked`?ee?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`:xe?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:B===`stacked`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-left`,className:`grid min-w-0 gap-2`,children:[(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?`All changes`:e}),ve.length>0&&(0,q.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:ve.map(e=>(0,q.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),ye||be.length>0?(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-controls`,className:`flex min-w-0 flex-wrap items-center gap-2 justify-start`,children:[ye?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:ye}):null,be.length>0?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 items-center gap-2 justify-start`,children:be.map((e,t)=>(0,q.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null]}):null]}),ee?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:ee}):null]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?`All changes`:e}),ve.length>0&&(0,q.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:ve.map(e=>(0,q.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),xe?(0,q.jsxs)(`div`,{"data-testid":`ticket-diff-header-inline-controls`,className:`flex min-w-0 flex-wrap items-start justify-end gap-2`,children:[ye?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:ye}):null,be.length>0?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:be.map((e,t)=>(0,q.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null,ee?(0,q.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:ee}):null]}):null]})}),(0,q.jsx)(`div`,{ref:re,"data-testid":`ticket-diff-scroll-region`,className:`min-h-0 flex-1 overflow-auto`,children:(0,q.jsxs)(`div`,{className:J(`min-h-full pb-4 pt-4`,V===`default`?`px-4`:`px-0`),children:[r&&(0,q.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading diff...`}),!r&&i&&(0,q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-4 text-center`,children:[(0,q.jsx)(`p`,{className:`max-w-md text-sm text-rose-300`,children:i}),(0,q.jsx)(Y,{type:`button`,variant:`outline`,onClick:l,children:`Retry`})]}),!r&&!i&&n&&!G&&(0,q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 text-center`,children:[(0,q.jsx)(`div`,{className:`text-sm text-foreground`,children:I}),L&&(0,q.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:L})]}),!r&&!i&&n&&G&&e!==`all`&&o.length===0&&(0,q.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 text-center`,children:[(0,q.jsx)(`div`,{className:`text-sm text-foreground`,children:`No renderable diff for this file in the UI.`}),(0,q.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:e})]}),!r&&!i&&n&&G&&o.length>0&&ce&&(0,q.jsx)(GQ,{}),!r&&!i&&n&&G&&o.length>0&&!ce&&(0,q.jsxs)(`div`,{className:J(`archon-diff-viewer`,te===`compact`&&`archon-diff-viewer--compact-gutter`,e===`all`&&V===`default`&&`space-y-6`,e===`all`&&V===`flat`&&`space-y-0`,N),children:[S&&(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:S}),C&&(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:C}),de.globalFindings.length>0&&(0,q.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:`Review findings`}),(0,q.jsx)(`div`,{className:`space-y-3`,children:de.globalFindings.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{E(e.id)}},e.id))})]}),e===`all`&&K.fallbackComments.length>0&&(0,q.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:`GitHub review comments`}),(0,q.jsx)(`div`,{className:`space-y-3`,children:K.fallbackComments.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{D(e.id)}},e.id))})]}),me>0&&(0,q.jsx)(`div`,{style:{height:me}}),ge.map(({file:t,virtualItem:n})=>{let r=P(t),i=ue.get(r),a=d$(t.hunks),o=de.inlineByFilePath.get(r)??new Map,c=K.inlineByFilePath.get(r)??new Map,l=de.fileLevelByFilePath.get(r)??[],h=K.fileLevelByFilePath.get(r)??[],g=d?m.find(e=>mD(e.filePath,e.changeKey)===d)??null:null,b=[...m.filter(e=>e.filePath===r).map(e=>e.changeKey),...u?.filePath===r?[u.changeKey]:[],...g?.filePath===r?[g.changeKey]:[]],S=u$({filePath:r,hunks:t.hunks,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindingsByChangeKey:o,githubCommentsByChangeKey:c,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canEditActiveReviewDraft:x,onToggleReviewFindingSelection:E,onToggleGitHubCommentSelection:D,onReviewDraftInputChange:O,onCancelReviewDraft:k,onEditReviewDraft:A,onRemoveReviewDraft:j,onSaveReviewDraft:M}),C=(0,q.jsx)(iE,{diffType:t.type,hunks:t.hunks,tokens:t.tokens,viewType:s,selectedChanges:[...new Set(b)],widgets:S,renderGutter:({change:e,side:t,renderDefault:n,wrapInAnchor:r,inHoverState:i})=>{if(!e)return r(n());let a=vT(e),o=t===`new`,c=y&&t===`new`,l=s===`unified`&&e.type===`normal`&&t===`new`?null:r(n());return(0,q.jsxs)(`div`,{className:J(`flex items-center justify-end pr-1`,te===`compact`?`gap-1 pr-0.5`:`gap-2`),children:[l,o&&(0,q.jsx)(`span`,{"data-diff-gutter-action-slot":`true`,className:[te===`compact`?`flex size-5 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`:`flex size-6 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`,c&&i?`border-emerald-200 bg-emerald-300 opacity-100`:`opacity-0`,!c&&`pointer-events-none`].join(` `),"aria-hidden":`true`,children:(0,q.jsx)(Ev,{className:te===`compact`?`h-3 w-3`:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`sr-only`,children:a})]})},gutterEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(vT(e));t&&T({filePath:r,changeKey:vT(e),commentKey:mD(r,vT(e)),hunk:t.hunk,change:t.change})}},codeEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(vT(e));t&&T({filePath:r,changeKey:vT(e),commentKey:mD(r,vT(e)),hunk:t.hunk,change:t.change})}},children:e=>e.map(e=>(0,q.jsx)($T,{hunk:e},`${r}-${e.content}`))});return e===`all`?(0,q.jsx)(`div`,{"data-index":n?.index,ref:n?le.measureElement:void 0,children:(0,q.jsxs)(`section`,{className:J(V===`default`?`rounded-xl border border-border bg-card/70`:`border-t border-border/70 bg-transparent first:border-t-0`),children:[(0,q.jsxs)(`div`,{className:J(`sticky top-0 z-20 border-b text-xs font-medium text-foreground`,V===`default`?`rounded-t-xl border-border bg-card px-4 py-3`:`border-border/70 bg-background/95 px-3 py-2.5 backdrop-blur-sm`),children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[`oldPath`in t&&typeof t.oldPath==`string`&&F(t.oldPath)===`/dev/null`&&(0,q.jsx)(Z,{variant:`success`,className:`shrink-0`,children:`New file`}),(0,q.jsx)(`span`,{children:r})]}),i&&(0,q.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs`,children:[(0,q.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`+`,i.additions]}),(0,q.jsxs)(`span`,{className:`font-mono text-rose-400`,children:[`-`,i.deletions]})]})]}),(0,q.jsxs)(`div`,{className:J(`overflow-x-auto`,V===`default`?`p-3`:`px-0 py-3`),children:[l.length>0&&(0,q.jsx)(`div`,{className:J(`mb-3 space-y-3`,V===`flat`&&`px-3`),children:l.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),h.length>0&&(0,q.jsx)(`div`,{className:J(`mb-3 space-y-3`,V===`flat`&&`px-3`),children:h.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{D(e.id)}},e.id))}),C]})]})},`${r}-${t.type??`modify`}`):(0,q.jsxs)(`div`,{"data-index":n?.index,ref:n?le.measureElement:void 0,children:[l.length>0&&(0,q.jsx)(`div`,{className:`mb-3 space-y-3`,children:l.map(e=>(0,q.jsx)(r$,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),h.length>0&&(0,q.jsx)(`div`,{className:`mb-3 space-y-3`,children:h.map(e=>(0,q.jsx)(s$,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{D(e.id)}},e.id))}),C]},`${r}-${t.type??`modify`}`)}),he>0&&(0,q.jsx)(`div`,{style:{height:he}})]})]})})]})});f$.displayName=`TicketChangesDiffPanel`;var p$=e=>J(`group`,e?`border-sky-700 bg-card/95 shadow-sm`:`border-border/50 bg-transparent text-muted-foreground hover:border-border/80 hover:bg-accent/60 hover:text-accent-foreground hover:shadow-sm`),m$={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},h$={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},g$=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},_$=({selectionWarning:e,gitError:t,sidebarFiles:n,commentCountByPath:r,commentCountTone:i,isGitStatusLoading:a,selectedPaths:o,selectedDiffPath:s,allFilesSelected:c,diffStats:l,title:u=`Changed files`,allChangesDescription:d=`Review the full workspace diff.`,enableSelection:f=!0,onToggleSelectAll:p,onSelectDiffPath:m,onTogglePath:h})=>{let g=i===`bundle_diff`?`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`;return(0,q.jsxs)(`aside`,{className:`flex min-h-0 h-full flex-col between overflow-hidden rounded-2xl border border-border bg-background/40`,children:[(e||t)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-border p-4`,children:[e&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:e}),t&&(0,q.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:u}),(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.length,` file`,n.length===1?``:`s`,` changed`]})]}),f&&(0,q.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:n.length===0,children:c?`Unselect all`:`Select all`})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[a&&(0,q.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading file list...`}),!a&&n.length===0&&(0,q.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`No changes to review.`}),!a&&n.length>0&&(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>{m(`all`)},className:J(`flex w-full items-start justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors`,p$(s===`all`)),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`All changes`}),l&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[l.files_changed,` file`,l.files_changed===1?``:`s`]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,l.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,l.deletions]})]})]}),(0,q.jsx)(`div`,{className:`mt-1 flex w-full flex-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:d})]})}),n.map(e=>{let t=f&&o.has(e.path),n=s===e.path,i=r.get(e.path)??0;return(0,q.jsxs)(`div`,{className:J(`flex items-start gap-2.5 rounded-xl border px-2.5 py-2 transition-colors`,p$(n)),children:[f&&(0,q.jsx)(`input`,{type:`checkbox`,"aria-label":e.path,checked:t,onChange:()=>{h(e.path)},className:`mt-0.5 h-4 w-4 rounded border-border bg-background text-primary`}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.path)},className:`min-w-0 flex-1 text-left cursor-pointer`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex flex-1 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:g$(e.path)}),i>0&&(0,q.jsx)(`span`,{"aria-label":`${i} comment${i===1?``:`s`} in ${e.path}`,className:g,children:i})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})]}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[e.status&&(0,q.jsx)(Z,{variant:`outline`,className:m$[e.status],children:h$[e.status]}),e.staged&&(0,q.jsx)(Z,{variant:`outline`,children:`Staged`}),e.unstaged&&(0,q.jsx)(Z,{variant:`outline`,children:`Unstaged`}),e.conflicted&&(0,q.jsx)(Z,{variant:`destructive`,children:`Conflicted`}),e.originalPath&&(0,q.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:e.status===`renamed`?`from ${e.originalPath}`:e.originalPath})]})]})]},`${e.path}:${e.originalPath??``}`)})]})]})]})},v$=[`[--diff-background-color:transparent]`,`[--diff-text-color:rgb(226_232_240)]`,`[--diff-selection-background-color:rgba(148,163,184,0.2)]`,`[--diff-gutter-insert-background-color:rgba(34,197,94,0.16)]`,`[--diff-gutter-delete-background-color:rgba(244,63,94,0.16)]`,`[--diff-gutter-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-code-insert-background-color:rgba(34,197,94,0.08)]`,`[--diff-code-delete-background-color:rgba(244,63,94,0.08)]`,`[--diff-code-insert-edit-background-color:rgba(34,197,94,0.22)]`,`[--diff-code-delete-edit-background-color:rgba(244,63,94,0.22)]`,`[--diff-code-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-font-family:var(--font-mono)]`,`[&_.diff]:w-full`,`[&_.diff]:border-collapse`,`[&_.diff]:font-mono`,`[&_.diff-code]:whitespace-pre-wrap`,`[&_.diff-code]:break-words`,`[&_.diff-gutter]:select-none`].join(` `),y$=25e4,b$=2e3,x$=new Map,S$=e=>e?e.split(`
173
+ `).length:0,C$=e=>{let t=e.diff??``;return t?t.length<=y$&&S$(t)<=b$:!0},w$=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,T$=e=>e?x$.get(e)??null:null,E$=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!C$(t)){x$.delete(e);return}x$.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},D$=e=>{e&&x$.delete(e)},O$={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},k$=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return O$[a]??null},A$=new Set,j$=e=>{e&&A$.forEach(t=>t(e))},M$=e=>(A$.add(e),()=>{A$.delete(e)}),N$=300,P$=(e,t={})=>{let n=t.dedupeMs??N$,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},F$=s(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),I$=s(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),L$=s(((e,t)=>{var n=F$(),r=I$();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),R$=s(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),z$=s(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),B$=s((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),V$=s(((e,t)=>{var n=z$(),r=B$();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),H$=s(((e,t)=>{var n=R$(),r=I$(),i=V$();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),U$=s(((e,t)=>{t.exports=H$()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),W$=s(((e,t)=>{t.exports=H$()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),G$=s(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),K$=s(((e,t)=>{var n=G$();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),q$=s(((e,t)=>{t.exports=H$()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:K$(),properties:{xmlns:null,xmlnsXLink:null}})})),J$=s(((e,t)=>{var n=B$(),r=H$(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),Y$=s(((e,t)=>{var n=B$(),r=H$(),i=K$(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),X$=s(((e,t)=>{var n=L$(),r=U$();t.exports=n([W$(),r,q$(),J$(),Y$()])})),Z$=s(((e,t)=>{var n=R$(),r=V$(),i=z$(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),Q$=s(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),$$=s((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),e1=s((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),t1=s(((e,t)=>{var n=Z$(),r=R$(),i=Q$(),a=$$().parse,o=e1().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),n1=s(((e,t)=>{var n=X$(),r=t1()(n,`div`);r.displayName=`html`,t.exports=r})),r1=s(((e,t)=>{t.exports=n1()})),i1=c({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>a1,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>`­`,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),a1,o1=o((()=>{a1={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:`­`,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),s1=c({default:()=>c1}),c1,l1=o((()=>{c1={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),u1=s(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),d1=s(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),f1=s(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),p1=s(((e,t)=>{var n=f1(),r=u1();t.exports=i;function i(e){return n(e)||r(e)}})),m1=s(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),h1=s(((e,t)=>{var n=(o1(),d(i1).default),r=(l1(),d(s1).default),i=u1(),a=d1(),o=p1(),s=m1();t.exports=R;var c={}.hasOwnProperty,l=String.fromCharCode,u=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=o,k[D]=i,k[E]=a;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),z(e,n)}function z(e,t){var i=t.additional,a=t.nonTerminated,d=t.text,f=t.reference,R=t.warning,z=t.textContext,V=t.referenceContext,H=t.warningContext,te=t.position,U=t.indent||[],ne=e.length,W=0,re=-1,ie=te.column||1,ae=te.line||1,G=``,oe=[],se,ce,le,ue,de,K,fe,pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce,we;for(typeof i==`string`&&(i=i.charCodeAt(0)),xe=Te(),pe=R?Ee:u,W--,ne++;++W<ne;)if(de===m&&(ie=U[re]||1),de=e.charCodeAt(W),de===_){if(fe=e.charCodeAt(W+1),fe===p||fe===m||fe===h||fe===g||fe===_||fe===y||fe!==fe||i&&fe===i){G+=l(de),ie++;continue}for(ve=W+1,_e=ve,we=ve,fe===x?(we=++_e,fe=e.charCodeAt(we),fe===S||fe===C?(ye=E,we=++_e):ye=D):ye=T,se=``,ge=``,ue=``,be=k[ye],we--;++we<ne&&(fe=e.charCodeAt(we),be(fe));)ue+=l(fe),ye===T&&c.call(n,ue)&&(se=ue,ge=n[ue]);le=e.charCodeAt(we)===v,le&&(we++,ce=ye===T?s(ue):!1,ce&&(se=ue,ge=ce)),Ce=1+we-ve,!le&&!a||(ue?ye===T?(le&&!ge?pe(P,1):(se!==ue&&(we=_e+se.length,Ce=1+we-_e,le=!1),le||(me=se?A:M,t.attribute?(fe=e.charCodeAt(we),fe===b?(pe(me,Ce),ge=null):o(fe)?ge=null:pe(me,Ce)):pe(me,Ce))),K=ge):(le||pe(j,Ce),K=parseInt(ue,O[ye]),ee(K)?(pe(I,Ce),K=l(w)):K in r?(pe(F,Ce),K=r[K]):(he=``,B(K)&&pe(F,Ce),K>65535&&(K-=65536,he+=l(K>>>10|55296),K=56320|K&1023),K=he+l(K))):ye!==T&&pe(N,Ce)),K?(De(),xe=Te(),W=we-1,ie+=we-ve+1,oe.push(K),Se=Te(),Se.offset++,f&&f.call(V,K,{start:xe,end:Se},e.slice(ve-1,we)),xe=Se):(ue=e.slice(ve-1,we),G+=ue,ie+=ue.length,W=we-1)}else de===10&&(ae++,re++,ie=0),de===de?(G+=l(de),ie++):De();return oe.join(``);function Te(){return{line:ae,column:ie,offset:W+(te.offset||0)}}function Ee(e,t){var n=Te();n.column+=t,n.offset+=t,R.call(H,L[e],n,e)}function De(){G&&=(oe.push(G),d&&d.call(z,G,{start:xe,end:Te()}),``)}}function ee(e){return e>=55296&&e<=57343||e>1114111}function B(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),g1=s(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`&quot;`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),_1=s(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&amp;/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),v1=s(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),y1=s(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),b1=s(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),x1=s(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=r1(),a=h1(),o=g1(),s=_1(),c=v1(),l=y1(),u=b1();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),S1=s(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),C1=s(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),w1=s(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),T1=s(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),E1=s(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),D1=s(((e,t)=>{var n=w1(),r=E1();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),O1=s(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),k1=u(x1(),1),A1=u(S1(),1),j1=u(v1(),1),M1=u(b1(),1),N1=u(C1(),1),P1=u(w1(),1),F1=u(T1(),1),I1=u(_1(),1),L1=u(D1(),1),R1=u(E1(),1),z1=u(O1(),1),B1=e=>{let t=e.displayName;!t||k1.default.registered(t)||k1.default.register(e)};B1(I1.default),B1(j1.default),B1(M1.default),B1(R1.default),B1(L1.default),B1(N1.default),B1(P1.default),B1(F1.default),B1(z1.default),B1(A1.default);var V1=c({TicketChangesModal:()=>g0}),H1=4,U1=1500,W1=`archon.ticket-changes.review-comments`,G1=[],K1=[],q1=[],J1=e=>new Set(e.map(e=>e.path)),Y1=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},X1=e=>e.replace(/^[ab]\//,``),Z1=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?X1(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?X1(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},Q1=e=>{let[t,n]=Z1(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},$1=e=>{let[t,n]=Z1(e);return t??n??null},e0=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),t0=e=>{if(e0(e)>U1)return null;let t=k$($1(e));if(!t)return null;try{return iD(e.hunks,{highlight:!0,refractor:k1.default,language:t,enhancers:[nD(e.hunks)]})}catch{return null}},n0=(e,t)=>e instanceof Error?e.message:t,r0=(e,t)=>`${W1}:${e}:${t}`,i0=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),a0=()=>({uncommitted:i0(),bundle_diff:i0()}),o0=e=>({uncommitted:e(),bundle_diff:e()}),s0=()=>o0(()=>new Map),c0=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},l0=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},u0=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(l0).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},d0=e=>new Map(e.map(e=>[mD(e.filePath,e.changeKey),e])),f0=(e,t)=>{e.set(t,(e.get(t)??0)+1)},p0=e=>e.find(e=>e.trim())||``,m0=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isGeneratingDescription:o,title:s,body:c,baseBranch:l,onOpenChange:u,onTitleChange:d,onBodyChange:f,onBaseBranchChange:p,showGenerateDescription:m,onGenerateDescription:h,onCreate:g})=>t?(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,children:`Loading PR...`}):e?(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,q.jsx)(Ej,{pullRequest:e}),(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,q.jsxs)(Hg,{open:n,onOpenChange:u,children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(T_,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,q.jsxs)(Wg,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,q.jsx)(Gg,{children:(0,q.jsx)(Kg,{children:`Create pull request`})}),(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(Kv,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,q.jsx)(Dg,{id:`bundle-pr-title`,value:s,onChange:e=>d(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,q.jsx)(Kv,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,q.jsx)(Dg,{id:`bundle-pr-base-branch`,value:l,onChange:e=>p(e.target.value),placeholder:`main`,disabled:a})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),m&&(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||o,onClick:h,children:[o?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):null,o?`Generating...`:`Generate`]})]}),(0,q.jsx)(Og,{id:`bundle-pr-body`,value:c,onChange:e=>f(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:!s.trim()||a,onClick:g,children:a?`Creating...`:`Create PR`})})]})]})]}),h0=(e,t,n)=>{if(n)return J1(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},g0=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:u}=e,d=e.scope??`ticket`,{isGitHubConnected:f}=ky(t),p=e.scope===`project_root`?null:e.ticketId,m=e.scope===`project_root`?void 0:e.onTicketUpdate,h=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[g,_]=(0,b.useState)(`uncommitted`),[v,y]=(0,b.useState)(null),[x,S]=(0,b.useState)(null),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)([]),[D,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(`all`),[M,F]=(0,b.useState)(``),[I,L]=(0,b.useState)(null),[R,V]=(0,b.useState)(null),[H,te]=(0,b.useState)(null),[U,ne]=(0,b.useState)(null),[W,re]=(0,b.useState)(!0),[ie,ae]=(0,b.useState)(!1),[G,oe]=(0,b.useState)(!0),[se,ce]=(0,b.useState)(!1),[le,ge]=(0,b.useState)(!1),[_e,ve]=(0,b.useState)(!1),[ye,be]=(0,b.useState)(!1),[xe,Se]=(0,b.useState)(!1),[Ce,we]=(0,b.useState)(`unified`),[Te,Ee]=(0,b.useState)(new Map),[De,Oe]=(0,b.useState)(q1),[ke,Ae]=(0,b.useState)(a0),[je,Me]=(0,b.useState)(null),[Ne,Pe]=(0,b.useState)([]),[Fe,Ie]=(0,b.useState)(null),[Le,Re]=(0,b.useState)(null),[ze,Be]=(0,b.useState)(new Set),[Ve,He]=(0,b.useState)(new Set),[Ue,We]=(0,b.useState)(!1),[Ge,Ke]=(0,b.useState)(null),[Je,tt]=(0,b.useState)(!1),[nt,rt]=(0,b.useState)(!1),[it,at]=(0,b.useState)(``),[ot,st]=(0,b.useState)(``),[ct,lt]=(0,b.useState)(``),[ut,dt]=(0,b.useState)([]),[ft,pt]=(0,b.useState)(!1),[mt,ht]=(0,b.useState)(!1),gt=(0,b.useRef)(null),_t=(0,b.useRef)(!1),vt=(0,b.useRef)(null),yt=(0,b.useRef)(null),bt=(0,b.useRef)(0),xt=(0,b.useRef)(0),St=(0,b.useRef)(o0(()=>null)),Ct=(0,b.useRef)(s0()),wt=(0,b.useMemo)(()=>w$({scope:d,projectId:t,ticketId:p}),[t,d,p]),Tt=(0,b.useCallback)(()=>{if(!p)throw Error(`Ticket changes require a ticket id.`);return p},[p]),Et=(0,b.useCallback)(e=>{vt.current=e,y(e),L(null)},[]),Dt=(0,b.useCallback)((e,t)=>{E$({cacheKey:wt,diffResponse:e,gitStatus:t})},[wt]),Ot=(0,b.useCallback)(e=>{vt.current&&E$({cacheKey:wt,diffResponse:vt.current,gitStatus:e})},[wt]),kt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await qe(t)}return await ue(Tt(),t)},[t,Tt,d]),At=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ye(t)}return await de(Tt(),t)},[t,Tt,d]),jt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Xe(t)}return await me(Tt(),t)},[t,Tt,d]),Mt=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await z(t,n,e),[t,n,d]),Nt=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await j(t,n,e),[t,n,d]),Pt=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await ee(t,n,e),[t,n,d]),Ft=(0,b.useCallback)(async e=>d===`project_root`||!n||!t?null:await B(t,n,e),[t,n,d]),It=(0,b.useCallback)((e,t)=>{Ae(n=>({...n,[e]:t(n[e])}))},[]),Lt=(0,b.useCallback)(async e=>{if(d===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await P(t,n,e)},[t,n,d]),Rt=(0,b.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ze(t,e)}return await K(Tt(),t,e)},[t,Tt,d]),zt=(0,b.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Qe(t,e)}return await fe(Tt(),t,e)},[t,Tt,d]),Bt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await $e(t)}return await pe(Tt(),t)},[t,Tt,d]),Vt=(0,b.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await et(t)}return await he(Tt(),t)},[t,Tt,d]),Ht=(0,b.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=bt.current+1;bt.current=r,ce(!0),n||ne(null);try{let t=await jt();if(!e()||bt.current!==r)return;E(t.commits),ne(null)}catch(t){if(!e()||bt.current!==r)return;ne(n0(t,`Unable to load local commits right now.`)),n||E([])}finally{e()&&bt.current===r&&ce(!1)}},[jt]),Ut=(0,b.useCallback)(()=>{bt.current+=1,E([]),ne(null),ce(!1)},[]),Wt=(0,b.useCallback)((e,t={})=>{let n=t.resetSelection??!1;yt.current=e,w(e),te(null),O(t=>{let r=h0(t,e.files,n||!_t.current);return _t.current=!0,r})},[]),Gt=(0,b.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||L(null),re(!0);try{let e=await kt();Et(e),n&&Dt(e,n)}catch(e){n&&D$(wt),(!t||!vt.current)&&L(n0(e,`Unable to load the diff right now.`))}finally{re(!1)}},[Et,wt,kt,Dt]),Kt=(0,b.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(d===`project_root`||!n||!t){S(null),V(null),ae(!1);return}r||V(null),ae(!0);try{S(await Pt()),V(null)}catch(e){(!r||!x)&&V(n0(e,`Unable to load the branch diff right now.`))}finally{ae(!1)}},[x,t,Pt,n,d]),qt=(0,b.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?T$(wt):null;if(n||(L(null),te(null)),oe(!0),i){Et(i.diffResponse),Wt(i.gitStatus,{resetSelection:r}),re(!1);try{let t=await At();if(!e())return;Wt(t,{resetSelection:r}),oe(!1),(t.ahead??0)>0?Ht(e,{preserveContent:!0}):Ut();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){Dt(i.diffResponse,t);return}D$(wt),await Gt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;te(n0(t,`Unable to load git status right now.`)),w(null),oe(!1),Ut();return}}re(!0);let[a,o]=await Promise.allSettled([kt(),At()]);e()&&(a.status===`fulfilled`?Et(a.value):(!n||!vt.current)&&L(n0(a.reason,`Unable to load the diff right now.`)),re(!1),o.status===`fulfilled`?Wt(o.value,{resetSelection:r}):(te(n0(o.reason,`Unable to load git status right now.`)),n||w(null)),oe(!1),a.status===`fulfilled`&&o.status===`fulfilled`&&Dt(a.value,o.value),o.status===`fulfilled`&&(o.value.ahead??0)>0?Ht(e,{preserveContent:n}):Ut())},[Et,Wt,wt,Ut,Ht,Gt,kt,At,Dt]),Jt=(0,b.useCallback)(async()=>{if(!t)return;let e=xt.current+1;xt.current=e,oe(!0);try{let t=await At();if(xt.current!==e)return;let n=yt.current?.workspace_signature??null,r=t.workspace_signature??null,i=!vt.current||n!==r;if(Wt(t),(t.ahead??0)>0?Ht(()=>xt.current===e,{preserveContent:!0}):Ut(),!i){Ot(t);return}await Gt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{xt.current===e&&oe(!1)}},[Wt,Ut,Ht,Gt,t,At,Ot]);(0,b.useEffect)(()=>{vt.current=v},[v]),(0,b.useEffect)(()=>{yt.current=C},[C]),(0,b.useEffect)(()=>{let e=!0;return qt(()=>e,{resetSelection:!0}),()=>{e=!1}},[qt]),(0,b.useEffect)(()=>{if(t)return M$(e=>{e===t&&Jt()})},[t,Jt]),(0,b.useEffect)(()=>{if(!t)return;let e=P$(()=>{document.visibilityState===`visible`&&Jt()});return()=>{e()}},[t,Jt]),(0,b.useEffect)(()=>{if(d===`project_root`){Me(null),Ie(null),Be(new Set);return}let e=new AbortController,t=!0;return Ie(null),Mt(e.signal).then(e=>{t&&(Me(e),Be(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Ie(n0(n,`Unable to load review findings right now.`)),Me(null),Be(new Set))}),()=>{t=!1,e.abort()}},[v?.diff,Mt,d]),(0,b.useEffect)(()=>{_(`uncommitted`),St.current=o0(()=>null),Ct.current=s0(),Ae(a0()),S(null),V(null),ae(!1),Pe([]),Re(null),He(new Set),Ke(null),tt(!1),rt(!1),at(``),st(``),lt(``),dt([]),pt(!1),ht(!1)},[n]),(0,b.useEffect)(()=>{if(d===`project_root`||!n||!t){Ke(null),tt(!1);return}let e=new AbortController,i=!0;return tt(!0),Nt(e.signal).then(e=>{i&&(Ke(e),at(t=>t.trim()?t:e?.bundle?.name??r),st(t=>t.trim()?t:p0(e?.recent_commit_subjects??ut)),lt(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||Ke(null)}).finally(()=>{i&&tt(!1)}),()=>{i=!1,e.abort()}},[ut,t,Nt,n,d,r]),(0,b.useEffect)(()=>{if(d===`project_root`||!n||!t){S(null),V(null),ae(!1);return}let e=new AbortController,r=!0;return ae(!0),V(null),Pt(e.signal).then(e=>{r&&(S(e),V(null))}).catch(t=>{!r||e.signal.aborted||(V(n0(t,`Unable to load the branch diff right now.`)),S(null))}).finally(()=>{r&&ae(!1)}),()=>{r=!1,e.abort()}},[t,Pt,n,d]),(0,b.useEffect)(()=>{let e=Ge?.bundle.pull_request??null;if(d===`project_root`||!n||!t||!f||!e){Pe([]),Re(null),He(new Set);return}let r=new AbortController,i=!0;return Re(null),Ft(r.signal).then(e=>{!i||!e||(Pe(e.comments),Re(e.error),He(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(e=>{!i||r.signal.aborted||(Pe([]),Re(n0(e,`Unable to load GitHub review comments right now.`)),He(new Set))}),()=>{i=!1,r.abort()}},[Ge?.bundle.pull_request,f,t,Ft,n,d]),(0,b.useEffect)(()=>{G&&C===null||gt.current?.focus()},[C,G]);let Yt=(0,b.useMemo)(()=>{let e=typeof v?.diff==`string`?v.diff:``;return e.trim()?Yx(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:Z1(e)})):[]},[v]),Xt=(0,b.useMemo)(()=>{let e=typeof x?.diff==`string`?x.diff:``;return e.trim()?Yx(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:Z1(e)})):[]},[x]),Zt=(0,b.useMemo)(()=>{let e=v?.diff??``;return e?c0(e):null},[v?.diff]),Qt=(0,b.useMemo)(()=>{let e=x?.diff??``;return e?c0(e):null},[x?.diff]),$t=g===`bundle_diff`?x:v,en=g===`bundle_diff`?Xt:Yt,tn=(0,b.useMemo)(()=>n?{uncommitted:r0(n,`uncommitted`),bundle_diff:r0(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),nn=(0,b.useMemo)(()=>({uncommitted:Zt,bundle_diff:Qt}),[Qt,Zt]),rn=(0,b.useMemo)(()=>{let e=new Map;for(let t of $t?.files??[])e.set(t.path,t);return e},[$t]),an=(0,b.useMemo)(()=>{let e=new Map;for(let t of en)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[en]),on=(0,b.useCallback)(e=>{Oe(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),sn=(0,b.useMemo)(()=>g===`bundle_diff`?(x?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):C?(C.files??[]).map(e=>{let t=rn.get(e.path)??(e.original_path?rn.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(v?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[g,x?.files,rn,v?.files,C]);(0,b.useEffect)(()=>{k!==`all`&&(sn.some(e=>e.path===k)||A(`all`))},[k,sn]);let cn=g===`bundle_diff`?0:D.size,ln=g===`bundle_diff`?sn.length:C?.files?.length??sn.length,un=ln>0&&cn===ln,dn=(0,b.useMemo)(()=>g===`bundle_diff`?null:Y1(C,D),[g,C,D]),fn=g===`uncommitted`&&!G&&!le&&l&&!!C&&cn>0&&M.trim().length>0&&dn===null,pn=g===`uncommitted`&&!G&&!W&&!_e&&!le&&!ye&&l&&!Ue&&!!C&&cn>0,mn=!G&&(ye||!!C?.can_push&&(C?.ahead??0)>0),hn=mn&&l&&!ye&&!le,gn=l&&!se&&!xe&&!le&&!ye&&(T?.length??0)>0,_n=(C?.ahead??0)>0?`${C?.ahead??0} to push`:`Up to date`,vn=(C?.behind??0)>0?`${C?.behind??0} behind`:`In sync`,yn=C?.branch??null,bn=k===`all`?null:an.get(k)??null,xn=(0,b.useMemo)(()=>k===`all`?en:bn?[bn]:[],[en,k,bn]);(0,b.useEffect)(()=>{Ee(new Map),Oe(q1)},[g,en]),(0,b.useEffect)(()=>{let e={uncommitted:tn.uncommitted&&nn.uncommitted?`${tn.uncommitted}:${nn.uncommitted}`:null,bundle_diff:tn.bundle_diff&&nn.bundle_diff?`${tn.bundle_diff}:${nn.bundle_diff}`:null};St.current.uncommitted===e.uncommitted&&St.current.bundle_diff===e.bundle_diff||(St.current=e,Ct.current=s0(),Ae(e=>{let t={...e};return[`uncommitted`,`bundle_diff`].forEach(e=>{let n=nn[e],r=tn[e];if(!n){t[e]=i0();return}let i=new Map;if(r){let t=window.localStorage.getItem(r),a=t?u0(t):null;a?.diffSignature===n?i=d0(a.comments.map(t=>({...t,scope:e}))):t!==null&&window.localStorage.removeItem(r)}t[e]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:i,signature:n}}),t}))},[nn,tn]),(0,b.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=tn[e],n=nn[e],r=ke[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[nn,tn,ke]),(0,b.useEffect)(()=>{if(en.length===0)return;let e=!1,t=null,n=(()=>{if(!bn){let e=[],t=new Set;for(let n of De){let r=an.get(n);if(!r)continue;let i=Q1(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:en.slice(0,H1)}return[bn]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+H1);a.length!==0&&(Ee(e=>{let t=new Map(e);for(let e of a){let n=Q1(e);t.has(n)||t.set(n,t0(e))}return t}),r+=H1,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=H1?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[en,an,bn,De]);let Sn=(0,b.useMemo)(()=>xn.map(e=>({...e,tokens:Te.get(Q1(e))??null})),[Te,xn]),Cn=(0,b.useMemo)(()=>en.map(e=>({...e,tokens:null})),[en]),wn=(0,b.useMemo)(()=>{let e=new Map;for(let t of en){let n=Q1(t);e.set(n,n);for(let r of Z1(t))e.set(r,n)}return e},[en]),Tn=(0,b.useMemo)(()=>[...ke.uncommitted.comments.values()],[ke.uncommitted.comments]),En=(0,b.useMemo)(()=>[...ke.bundle_diff.comments.values()],[ke.bundle_diff.comments]),Dn=ke[g],On=Dn.activeTarget,kn=Dn.editingCommentKey,An=On?.commentKey??kn,jn=An?`${g}:${An}`:g,Mn=An?Ct.current[g].get(An)??Dn.draftInput:Dn.draftInput,Nn=g===`bundle_diff`?En:Tn,Pn=(0,b.useMemo)(()=>[...Tn,...En],[En,Tn]),Fn=(0,b.useMemo)(()=>je?.findings??[],[je]),In=(0,b.useMemo)(()=>je?.is_current_diff?Fn.filter(e=>ze.has(e.id)):[],[Fn,je?.is_current_diff,ze]),Ln=(0,b.useMemo)(()=>[...ze],[ze]),Rn=(0,b.useMemo)(()=>Ne.filter(e=>Ve.has(e.id)),[Ne,Ve]),zn=(0,b.useMemo)(()=>[...Ve],[Ve]),Bn=Pn.length+In.length+Rn.length,Vn=!!(je?.review_run&&Fn.length>0&&!je.is_current_diff),Hn=Ge?.bundle.pull_request??null,Un=(0,b.useMemo)(()=>ut.length>0?ut:Ge?.recent_commit_subjects??[],[Ge?.recent_commit_subjects,ut]),Wn=Ge?.has_helper_model===!0,Gn=d!==`project_root`&&!!n&&!!t,Kn=g===`bundle_diff`?R:I,qn=W&&v===null,Jn=ie&&x===null,Yn=G&&C===null,Xn=Je&&Ge===null,Zn=g===`bundle_diff`?Jn:qn,Qn=g===`uncommitted`?Fn:G1,$n=g===`uncommitted`?Ln:q1,er=g===`bundle_diff`?Ne:K1,tr=g===`bundle_diff`?zn:q1,nr=g===`bundle_diff`?`bundle_diff`:`uncommitted`,rr=(0,b.useMemo)(()=>{let e=new Map,t=e=>e?wn.get(e)??e:null;for(let n of Nn){let r=t(n.filePath);r&&f0(e,r)}if(g===`uncommitted`){if(Vn)return e;for(let n of Fn){let r=t(n.file_path);r&&f0(e,r)}return e}for(let n of Ne){let r=t(n.file_path);r&&f0(e,r)}return e},[g,wn,Nn,Ne,Vn,Fn]),ir=(Vn?0:Fn.length)+Tn.length,ar=Ne.length+En.length,or=g===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,sr=g===`uncommitted`&&(x?.files.length??0)>0?`Switch to Branch diff to review the full branch diff.`:null,cr=Gn&&!Xn&&!!Ge&&Ge?.bundle.kind!==`project_root`&&C?.has_upstream===!0&&f,lr=cr&&!Hn&&!ft&&!mt&&!Ue&&!ye&&!le&&!xe&&(C?.ahead??0)===0&&!!C?.branch,ur=(0,b.useMemo)(()=>{if(cr)return(C?.ahead??0)>0?`Push the branch before creating a pull request.`:C?.branch?u:`Bundle branch information is not available right now.`},[u,C?.ahead,C?.branch,cr]),dr=c&&!Zn&&(g===`bundle_diff`||!Yn)&&!le&&!ye&&!xe,fr=On?dr||Dn.comments.has(On.commentKey):dr,pr=!!a&&o&&Bn>0&&!Ue,mr=(0,b.useCallback)(e=>{Be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),hr=(0,b.useCallback)(e=>{He(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),gr=(0,b.useCallback)(()=>{Ct.current=s0(),Ae(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),_r=(0,b.useCallback)(()=>{gr(),Be(new Set),He(new Set)},[gr]),vr=(0,b.useCallback)(async()=>{if(!(!t||!n||!lr)){pt(!0);try{let e=await N(t,n,{title:it.trim(),body:ot.trim(),base_branch:ct.trim()||null});Ke(e),lt(e.bundle.pull_request?.base_branch??ct.trim()),rt(!1),X.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){X.error(n0(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{pt(!1)}}},[lr,t,ct,ot,it,n]),yr=(0,b.useCallback)(async()=>{if(!(!t||!n||!cr||mt)){ht(!0);try{st((await Lt({title:it.trim(),commit_subjects:Un})).description)}catch(e){X.error(n0(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{ht(!1)}}},[mt,t,Un,it,Lt,n,cr]),br=(0,b.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=Dn.comments.get(n),i=Ct.current[g].get(n)??r?.comment??``;if(r){A(r.filePath),It(g,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}dr&&It(g,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[g,Dn.comments,dr,It]),xr=(0,b.useCallback)(()=>{An&&Ct.current[g].delete(An),It(g,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[g,An,It]),Sr=(0,b.useCallback)(e=>{An&&Ct.current[g].set(An,e)},[g,An]),Cr=(0,b.useCallback)((e,t)=>{let n=Dn.comments.has(e.commentKey);if(!dr&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;It(g,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:g,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:hD(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),Ct.current[g].delete(e.commentKey)},[g,Dn.comments,dr,It]),wr=(0,b.useCallback)(e=>{let t=Dn.comments.get(e);if(!t)return;A(t.filePath);let n=Ct.current[g].get(e)??t.comment;It(g,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[g,Dn.comments,It]),Tr=(0,b.useCallback)(e=>{Ct.current[g].delete(e),It(g,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[g,It]),Er=(0,b.useCallback)(async()=>{if(!a||!pr)return;We(!0);let e=wD({drafts:Pn,findings:In,githubComments:Rn,uncommittedFiles:Yt,bundleFiles:Xt});try{await a(e),gr(),Be(new Set),He(new Set),Me(e=>e&&{...e,findings:[],is_current_diff:!1}),X.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){X.error(n0(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{We(!1)}},[Pn,Xt,pr,gr,i,a,Rn,In,Yt]),Dr=(0,b.useCallback)(()=>{if(g===`bundle_diff`){Kt();return}qt(()=>!0,{allowCache:!1,resetSelection:!_t.current})},[g,Kt,qt]),Or=(0,b.useMemo)(()=>a?(0,q.jsx)(bQ,{reviewComments:Pn,reviewFindings:In,githubComments:Rn,pendingFixCount:Bn,canSendReview:pr,isSubmittingReview:Ue,reviewSubmitDisabledReason:s,onClearPendingFixes:_r,onSubmitReview:()=>{Er()}}):null,[Pn,pr,_r,Er,Ue,a,Bn,s,Rn,In]),kr=e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ar=()=>{C&&O(un?new Set:J1(C.files))},jr=async()=>{if(fn){ge(!0);try{let e=await Rt({message:M.trim(),selected_paths:[...D]});e.ticket&&m?.(e.ticket),Wt(e.git_status,{resetSelection:!0}),F(``),d===`project_root`&&j$(t),p&&h?.(p),await Gt({preserveContent:!0,gitStatusForCache:e.git_status}),await Kt({preserveContent:!0}),(e.git_status.ahead??0)>0?await Ht(()=>!0):Ut(),X.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){X.error(n0(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ge(!1)}}},Mr=async()=>{if(pn){ve(!0);try{F((await zt({selected_paths:[...D]})).message),gt.current?.focus()}catch(e){X.error(n0(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{ve(!1)}}},Nr=async()=>{if(hn){be(!0);try{let e=T.map(e=>e.subject.trim()).filter(Boolean),a=await Bt();if(a.ticket&&m?.(a.ticket),Wt(a.git_status,{resetSelection:!0}),Ot(a.git_status),dt(e),Ut(),d===`project_root`&&j$(t),p&&h?.(p),X.success(a.git_status.ahead===0?`Branch pushed.`:`Push completed.`,{id:`ticket-git-push-success`}),a.git_status.ahead===0)if(d!==`project_root`&&t&&n)try{let i=await j(t,n);Ke(i),at(e=>e.trim()?e:i.bundle.name??r),st(t=>t.trim()?t:p0(e)),lt(e=>e.trim()?e:i.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(e){X.error(n0(e,`Unable to push the branch right now.`),{id:`ticket-git-push-error`})}finally{be(!1)}}},Pr=async()=>{if(gn){Se(!0);try{let e=await Vt();e.ticket&&m?.(e.ticket),Wt(e.git_status,{resetSelection:!0}),E(e.commits),ne(null),ce(!1),d===`project_root`&&j$(t),p&&h?.(p),await Gt({preserveContent:!0,gitStatusForCache:e.git_status}),await Kt({preserveContent:!0}),X.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){X.error(n0(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{Se(!1)}}};return(0,q.jsx)(Iv,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,q.jsxs)(q.Fragment,{children:[ye&&(0,q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}),(0,q.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),yn?(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:yn}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(Z,{variant:(C?.ahead??0)>0?`info`:`outline`,children:_n}),(0,q.jsx)(Z,{variant:(C?.behind??0)>0?`warning`:`outline`,children:vn}),(0,q.jsx)(Z,{variant:C?.is_dirty?`warning`:`success`,children:C?.is_dirty?`Dirty`:`Clean`})]})]}):(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(Hn||cr)&&(0,q.jsx)(m0,{pullRequest:Hn,isLoading:Xn,isOpen:nt,canCreate:lr,disabledReason:ur,isCreating:ft,isGeneratingDescription:mt,title:it,body:ot,baseBranch:ct,onOpenChange:rt,onTitleChange:at,onBodyChange:st,onBaseBranchChange:lt,showGenerateDescription:Wn,onGenerateDescription:()=>{yr()},onCreate:()=>{vr()}}),(0,q.jsx)(SQ,{isCommitsLoading:se,commitsError:U,unpushedCommits:T,canUndoLatestCommit:gn,isUndoing:xe,aheadCount:C?.ahead??0,onUndoLatestCommit:()=>{Pr()}}),mn&&(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Nr()},disabled:!hn,title:u,className:`gap-2`,children:[ye?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(T_,{className:`h-4 w-4`}),ye?`Pushing...`:`Push branch`]}),e]})]}),(0,q.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,q.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[Gn&&(0,q.jsxs)(mQ,{type:`single`,size:`sm`,variant:`outline`,value:g,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&_(e)},className:`mb-3 self-start`,children:[(0,q.jsxs)(hQ,{value:`uncommitted`,className:`gap-2`,children:[(0,q.jsx)(`span`,{children:`Uncommitted`}),ir>0&&(0,q.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:ir})]}),(0,q.jsxs)(hQ,{value:`bundle_diff`,className:`gap-2`,children:[(0,q.jsx)(`span`,{children:`Branch diff`}),ar>0&&(0,q.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:ar})]})]}),(0,q.jsx)(_$,{selectionWarning:g===`uncommitted`?dn:null,gitError:g===`uncommitted`?H:R,sidebarFiles:sn,commentCountByPath:rr,commentCountTone:nr,isGitStatusLoading:g===`bundle_diff`?Jn:Yn,selectedPaths:D,selectedDiffPath:k,allFilesSelected:un,diffStats:$t?.stats??null,title:g===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:g===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:g===`uncommitted`,onToggleSelectAll:Ar,onSelectDiffPath:A,onTogglePath:kr})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,q.jsx)(f$,{selectedDiffPath:k,sidebarFiles:sn,diffResponse:$t,isDiffLoading:Zn,diffError:Kn,allDiffFiles:Cn,renderedFiles:Sn,viewType:Ce,onViewTypeChange:we,onRetry:Dr,activeReviewTarget:On,editingReviewCommentKey:kn,reviewDraftInstanceKey:jn,reviewDraftInput:Mn,reviewComments:Nn,reviewFindings:Qn,githubComments:er,selectedReviewFindingIds:$n,selectedGitHubCommentIds:tr,canSelectReviewTarget:dr,canEditActiveReviewDraft:fr,reviewFindingsError:g===`uncommitted`?Fe:null,gitHubCommentsError:g===`bundle_diff`?Le:null,hasStaleReviewFindings:g===`uncommitted`?Vn:!1,onSelectReviewTarget:br,onToggleReviewFindingSelection:mr,onToggleGitHubCommentSelection:hr,onReviewDraftInputChange:Sr,onCancelReviewDraft:xr,onEditReviewDraft:wr,onRemoveReviewDraft:Tr,onSaveReviewDraft:Cr,diffThemeClassName:v$,resolveFilePath:Q1,normalizeDiffPath:X1,onVisibleFilePathsChange:on,emptyStateTitle:or,emptyStateDescription:sr,reviewSummaryControl:Or,headerLayout:`inline-controls`}),g===`uncommitted`&&(0,q.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,q.jsx)(xQ,{commitMessage:M,onCommitMessageChange:F,commitMessageRef:gt,selectedFileCount:cn,changesDisabledReason:u,canEditCommitMessage:l&&!Ue,canGenerateCommitMessage:pn,canCommit:fn,isGeneratingCommitMessage:_e,isCommitting:le,onGenerateCommitMessage:()=>{Mr()},onCommit:()=>{jr()}})})]})]})]})]})})},_0={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},v0=e=>$j(e)?`ready`:`blocked`,y0=180,b0=560,x0=88,S0=12,C0=18,w0=(e,t,n)=>Math.min(Math.max(e,t),n),T0=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),E0=(e,t)=>{let n=w0(Math.round(e.length*7.2)+24,y0,b0),r=Math.max(y0,t-S0*2);return Math.min(n,r)},D0=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=sM(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=T0(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=E0(c,d.width);return{text:c,x:o&&s?w0(f.x-p/2,S0,Math.max(S0,d.width-p-S0)):(()=>{let e=f.x+C0,t=f.x-C0-p;return e+p<=d.width-S0?e:t>=S0?t:w0(e,S0,Math.max(S0,d.width-p-S0))})(),y:w0(f.y,S0,Math.max(S0,d.height-x0-S0)),width:p}},O0=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=sM(e,t),{path:s}=cM(a,o);return(0,q.jsx)(`g`,{"data-testid":r,children:(0,q.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},k0=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=D0(e,i,n,t,r);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O0,{blockerRect:i,dependentRect:a,className:_0.preview.className,testId:`dependency-preview`,markerEnd:`url(#${_0.preview.markerId})`}),(e=>o?(0,q.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:x0,"data-testid":`dependency-preview-label`,children:e}):null)((0,q.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,q.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},A0=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,q.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,q.jsx)(`defs`,{children:Object.values(_0).map(e=>(0,q.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,q.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=_0[v0(n)];return!a||!o?null:(0,q.jsx)(O0,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,q.jsx)(k0,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),j0=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,onClose:m})=>{let{jiraImportState:h,importFromJira:g}=My(n);return(0,q.jsx)(Iv,{onClose:m,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:_})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:_}),(0,q.jsx)(GB,{heading:`New Ticket`,bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,projectBranchState:r,jiraImportState:h,onImportFromJira:g,onCancel:m,onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:`Plan`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}:void 0,primaryAction:{label:`Create Ticket`,variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}},secondaryAction:{label:`Create & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}})]})})},M0=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},N0=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,P0=({run:e})=>(0,q.jsxs)(zv,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${N0(e)}`,children:[e.status===`running`&&(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,q.jsxs)(Wv,{className:`space-y-3 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,q.jsx)(dM,{label:`Planning...`}):e.status===`done`?(0,q.jsx)(dM,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,q.jsx)(dM,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,q.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:M0(e.submittedAt)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),F0={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},I0=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,L0=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},R0=({status:e})=>e===`running`?(0,q.jsx)(dM,{label:`Planning...`,className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,q.jsx)(Z,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:`Done`}):(0,q.jsx)(Z,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:`Failed`}),z0=({heading:e,runs:t})=>t.length===0?null:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,q.jsx)(zv,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,q.jsxs)(Wv,{className:`space-y-2 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,q.jsx)(R0,{status:e.status})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:L0(e.submittedAt)}),e.summary&&(0,q.jsxs)(`span`,{children:[e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]})]}),e.error&&(0,q.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]}),B0=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let m=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:h,importFromJira:g}=My(t.isOpen?e:null),_=(0,b.useRef)(null),v=(0,b.useRef)(t.isOpen),y=(0,b.useRef)(t.isOpen),x=I0(t.runs),S=t.runs.filter(e=>e.status===`running`),C=t.runs.filter(e=>e.status!==`running`),w=t.composer.description.trim().length>0;(0,b.useEffect)(()=>{if(t.isOpen&&!v.current&&(y.current=!0),t.isOpen||(y.current=!1),v.current=t.isOpen,!t.isOpen||!y.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==_.current&&!t){y.current=!1;return}_.current?.focus({preventScroll:!0}),y.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,b.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let T=(0,q.jsxs)(Y,{type:`button`,"aria-label":t.isOpen?`Close planning agent`:`Open planning agent`,"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,q.jsx)(cy,{className:`size-5`}),(0,q.jsx)(__,{"aria-hidden":`true`,children:`A`}),(0,q.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${F0[x]}`})]});return(0,q.jsxs)(`aside`,{"aria-label":`Planning agent sidebar`,className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,q.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?T:(0,q.jsx)(u_,{content:`Planning agent`,children:T})}),(0,q.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:J(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,q.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Planning agent`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Turn a larger initiative into plan-stage tickets with dependencies and bundle context.`})]}),(0,q.jsx)(Y,{type:`button`,"aria-label":`Close planning agent panel`,onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(kv,{className:`h-4 w-4`})})]}),(0,q.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,q.jsx)(VB,{jiraImportState:h,onImportFromJira:g,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,q.jsx)(Kv,{label:`Description`,htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,q.jsx)(`div`,{className:`relative`,children:(0,q.jsx)(cx,{ref:_,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":`Planning description`,value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:`Describe the task, acceptance criteria, context...`})})}),(0,q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(HB,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:`Auto-create bundle`,hideProjectRootBundles:!0,label:``})}),o&&(0,q.jsx)(Y,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:`Manage bundles`})]}),(0,q.jsx)(`div`,{className:`space-y-3`,children:(0,q.jsx)(RB,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:m,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,q.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(z0,{heading:`Active planning runs`,runs:S}),(0,q.jsx)(z0,{heading:`Recent runs`,runs:C})]})})]})}),(0,q.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,q.jsx)(Y,{type:`button`,onClick:p,disabled:!w,className:`w-full`,children:`Plan tickets`})})]})})]})},V0=({className:e=``})=>{let{setNodeRef:t,isOver:n}=oj({id:`trash`});return(0,q.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(Z,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,q.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,q.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,q.jsx)(qv,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},H0=(e,t)=>O(w(`/ticket-dependencies`,e),{signal:t}),U0=(e,t)=>O(w(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),W0=(e,t,n)=>D(w(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),G0=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},K0=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,q0=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,b.useState)({}),[l,u]=(0,b.useState)({width:0,height:0}),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useRef)(null),v=(0,b.useRef)(new Map),y=(0,b.useRef)({}),x=(0,b.useRef)(null),C=(0,b.useRef)(null),w=(0,b.useRef)(null),T=(0,b.useRef)(null),E=(0,b.useRef)(null),D=(0,b.useRef)(null),O=(0,b.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,b.useEffect)(()=>{T.current=p},[p]),(0,b.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let k=(0,b.useCallback)(()=>{x.current===null&&(x.current=window.requestAnimationFrame(()=>{x.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>G0(e,n)?e:n)}))},[]);(0,b.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{k()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[k]),(0,b.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{k()});C.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),C.current===e&&(C.current=null)}},[k]),(0,b.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{k()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[k]),(0,b.useEffect)(()=>(k(),()=>{x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null)}),[n,k,t]);let A=(0,b.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),C.current?.observe(t)}else{if(!n)return;v.current.delete(e),C.current?.unobserve(n)}k()},[k]),j=(0,b.useCallback)(e=>{K0(T.current,e)||(T.current=e,m(e))},[]),M=(0,b.useCallback)(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),D.current=null},[]),N=(0,b.useCallback)(e=>{D.current=e,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;let e=D.current;D.current=null,j(e)}))},[j]),P=(0,b.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),F=(0,b.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),I=(0,b.useCallback)(async t=>{if(e)try{await W0(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>Yj(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){X.error(e instanceof S?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),L=(0,b.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),w.current?.();let a=(n,r,i=!1)=>{let a=P(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:F(a.x,a.y,t),pointer:a};if(i){M(),j(o);return}N(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=P(i.clientX,i.clientY),o=F(a.x,a.y,t),s=o?Zj(n,t,o):null;if(w.current?.(),w.current=null,j(null),!(!o||!s)){if(!s.valid){X.error(Qj(s.reason),{id:`board-dependency-error`});return}try{let n=await U0(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>Jj(e,n))}catch(e){X.error(e instanceof S?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};w.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),M()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,M,n,F,P,N,r,j]);(0,b.useEffect)(()=>{w.current?.(),w.current=null,M(),T.current=null},[e,M]),(0,b.useEffect)(()=>()=>{w.current?.(),E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null)},[]);let R=(0,b.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!O.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=Zj(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,O,t]),z=(0,b.useCallback)(e=>{if(!R||!p)return`idle`;let t=R.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[R,p]),ee=(0,b.useMemo)(()=>!p||p.projectId!==e||!O.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,O]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:A,measuredCardRects:(0,b.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:ee,overlaySize:l,getDependencyTargetState:z,handleDependencyStart:L,handleDeleteDependency:I}},J0=`[data-terminal-pane="true"]`,Y0=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},X0=e=>e instanceof HTMLElement?e.closest(J0)!==null:!1,Z0=e=>Y0(e)||X0(e),Q0=(e,t={})=>{let{isBlocked:n}=t;(0,b.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},$0=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),e2=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,t2=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},n2=(e,t)=>{let n=e=>Fj(t)?Fj(e):e.state===t.state&&!Fj(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},r2=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},i2=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=t2(n,t);return e.map(e=>e.id===t.id?r:e)},a2=(e,t)=>{let n=t2(e.find(e=>e.id===t.id),t);return n2(s2(e,t.id),n)},o2=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=e2(n.find(t=>t.id===e.id),e)?a2(n,e):i2(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},s2=(e,t)=>e.filter(e=>e.id!==t),c2=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=s2(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return n2(s,o)},l2=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},u2=(0,b.createContext)(null),d2=15*1e3,f2=1e3,p2=async e=>l2(`Ticket done`,e),m2=e=>$0(e),h2=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,g2=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)([]),[d,f]=(0,b.useState)([]),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(null),[y,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),w=(0,b.useRef)(0),E=(0,b.useRef)(0),D=(0,b.useRef)(new Map),O=(0,b.useRef)(new Map),A=(0,b.useRef)(e),j=(0,b.useRef)(new Map),M=(0,b.useRef)(new Map),N=(0,b.useRef)(new Map),P=(0,b.useCallback)((e,t)=>{let n=M.current.get(t.id);return!n||!e||t.state===n?t:e},[]),F=(0,b.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(M.current);for(let r of e)n.set(r,t);M.current=n},[]),I=(0,b.useCallback)(e=>{if(e.length===0||M.current.size===0)return;let t=new Map(M.current);for(let n of e)t.delete(n);M.current=t},[]),L=(0,b.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(N.current);for(let r of e)n.set(r,t);N.current=n},[]),R=(0,b.useCallback)(e=>{if(e.length===0||N.current.size===0)return;let t=new Map(N.current);for(let n of e)t.delete(n);N.current=t},[]),z=(0,b.useCallback)((e,t)=>{if(j.current.has(t.id))return null;let n=P(e,t);return N.current.has(t.id)?{...n,parked_at:N.current.get(t.id)??null}:n},[P]),ee=(0,b.useCallback)((e,t)=>{if(j.current.size===0&&M.current.size===0&&N.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=z(n.get(e.id),e);return t?[t]:[]})},[z]),B=(0,b.useCallback)(async(e,t)=>{let n=await ie(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&A.current===e&&c(e=>o2(e,ee(e,n).map(m2))),n):null},[ee]),V=(0,b.useCallback)(async(e,t)=>{await B(e,t)},[B]),H=(0,b.useCallback)(async(e,t)=>{let n=++E.current,r=await ae(e,t);if(!Array.isArray(r)||t?.aborted||A.current!==e||E.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));c(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),te=(0,b.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),U=(0,b.useCallback)(async e=>{let t=A.current;if(!t)return null;try{let n=await G(e,t);if(A.current!==t)return null;let r=O.current.get(n.id),i=z(r,n);if(!i)return null;let a=m2(i),o=e2(r,a);return c(e=>o?a2(e,a):i2(e,a)),n}catch{return null}},[z]),ne=(0,b.useCallback)(async t=>{if(!e){f([]);return}f(await k(e,t))},[e]),W=(0,b.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),re=(0,b.useMemo)(()=>{let e=s.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:S}},[S,s]);(0,b.useEffect)(()=>{O.current=W},[W]),(0,b.useEffect)(()=>{A.current=e,j.current.clear(),M.current.clear(),N.current.clear(),C(null),m(null),D.current.clear()},[e]),(0,b.useEffect)(()=>{n?.(_?null:h)},[h,_,n]),(0,b.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(h!==e){i(e,[]);return}i(e,d)}},[e,d,h,i]),(0,b.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,y===e)}},[e,y,a]),(0,b.useEffect)(()=>{let t=new AbortController,n=++w.current,r=null,i=async()=>{try{if(!e){c([]),u([]),f([]),g(null),v(null);return}c([]),u([]),f([]),g(null),v(e),x(e);let[n,i,a]=await Promise.allSettled([B(e,t.signal),H0(e,t.signal),k(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!T(n.reason)&&c([]),i.status===`fulfilled`?u(i.value):T(i.reason)||u([]),a.status===`fulfilled`?f(a.value):T(a.reason)||f([]),g(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&te(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||H(e,t.signal)},f2))}finally{!t.signal.aborted&&w.current===n&&(v(null),x(null))}},a=t=>{t.project_id===e&&(m(t),!j.current.has(t.id)&&(t.bundle&&f(e=>r2(e,t.bundle)),c(e=>a2(e,m2(t)))))},o=t=>{if(t.project_id===e&&m(t),c(n=>{if(t.project_id!==e)return s2(n,t.id);let r=n.find(e=>e.id===t.id),i=z(r,t);if(!i)return n;let a=m2(i);return e2(r,a)?a2(n,a):i2(n,a)}),t.project_id!==e){u(e=>qj(e,t.id));return}t.bundle&&f(e=>r2(e,t.bundle))},s=({id:e})=>{j.current.delete(e),N.current.delete(e),M.current.delete(e),c(t=>s2(t,e)),u(t=>qj(t,e))},l=e=>{if(!e)return;let t=O.current.get(e.blocker_ticket_id),n=O.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==A.current||n.project_id!==A.current||u(t=>Jj(t,e))},d=e=>{u(t=>Yj(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),EZ.on(`ticket:created`,a),EZ.on(`ticket:updated`,o),EZ.on(`ticket:deleted`,s),EZ.on(`ticket-dependency:created`,l),EZ.on(`ticket-dependency:deleted`,d),()=>{t.abort(),r!==null&&window.clearTimeout(r),EZ.off(`ticket:created`,a),EZ.off(`ticket:updated`,o),EZ.off(`ticket:deleted`,s),EZ.off(`ticket-dependency:created`,l),EZ.off(`ticket-dependency:deleted`,d)}},[e,H,t,te,B,z]),(0,b.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([B(e,t.signal),ne(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&te(n[0].value)&&H(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,d2),i=P$(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,ne,H,te,B]),(0,b.useEffect)(()=>{if(!e||!r||h!==e)return;let t=s.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:s.length,worktreeCount:t,repoPathLocked:s.length>0||t>0||d.length>0})},[e,d.length,h,r,s]),(0,b.useEffect)(()=>{for(let e of s){let t=D.current.get(e.id),n=h2(e,t);n&&C(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&p2(e.title),D.current.set(e.id,e.agent_status)}},[s]);let oe=(0,b.useCallback)(()=>{m(null)},[]),se=(0,b.useMemo)(()=>({tickets:s,setTickets:c,dependencies:l,setDependencies:u,bundles:d,setBundles:f,latestDetailedTicketUpdate:p,clearLatestDetailedTicketUpdate:oe,loadedProjectId:h,loadingProjectId:_,activeProjectIdRef:A,pendingDeletedTicketsRef:j,pendingOptimisticMovesRef:M,pendingParkedTicketsRef:N,refreshTickets:V,requestSingleTicketRefresh:U,refreshBundles:ne,resolvePendingTicket:z,resolvePendingTickets:ee,markPendingOptimisticMoves:F,clearPendingOptimisticMoves:I,markPendingParkedTickets:L,clearPendingParkedTickets:R,liveActivity:re}),[d,oe,I,R,l,re,h,p,_,F,L,ne,V,U,z,ee,s]);return(0,q.jsx)(u2.Provider,{value:se,children:o})},_2=()=>{let e=(0,b.useContext)(u2);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},v2=e=>e===1?`1 ticket created`:`${e} tickets created`,y2=async e=>l2(`Planning done`,v2(e)),b2=`archon.last-model-selection`,x2=`archon.last-variant-selection`,S2=`archon.last-skills-selection`,C2=()=>{try{let e=window.localStorage.getItem(S2),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},w2=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),T2=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},E2=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,D2=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=w2(t);return n.every(e=>r.some(t=>t.includes(e)))},O2=[`plan`,`build`,`review`],k2=`done`,A2=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),j2=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,M2=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?Nj(n):e.ticket_id},N2=()=>({description:``,model:window.localStorage.getItem(b2)??``,variant:window.localStorage.getItem(x2)??``,skills:C2(),worktreeBundleId:``}),P2=()=>({isOpen:!1,composer:N2(),runs:[]}),F2=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,I2=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),L2=(e,t,n)=>e.map(e=>e.id===t?n(e):e),R2=(e,t,n)=>{e?window.localStorage.setItem(b2,e):window.localStorage.removeItem(b2),t?window.localStorage.setItem(x2,t):window.localStorage.removeItem(x2),n.length>0?window.localStorage.setItem(S2,JSON.stringify(n)):window.localStorage.removeItem(S2)},z2=(e,t={})=>dv(e,t),B2=()=>({model:window.localStorage.getItem(b2)??``,variant:window.localStorage.getItem(x2)??``,skills:C2()}),V2=(e,t)=>{let n=s2(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},H2=e=>e.tickets.length>0&&e.tickets.every(e=>Hj(e,`trash`)),U2=e=>e.tickets.length>0&&e.tickets.every(e=>Hj(e,k2)),W2=e=>e.column===k2&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),G2=(e,t,n)=>n||t!==null&&t!==Nj(e)?`Stop the currently running ticket before starting another run.`:tM(e),K2=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},q2=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,J2=(e,t,n)=>t===`review`&&n===`build`?{}:K2(e,n),Y2=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let l=$O(QO(tA,{activationConstraint:{distance:5}})),{tickets:u,setTickets:d,dependencies:f,setDependencies:p,bundles:m,setBundles:h,latestDetailedTicketUpdate:g,clearLatestDetailedTicketUpdate:_,loadedProjectId:v,loadingProjectId:y,activeProjectIdRef:x,pendingDeletedTicketsRef:C,requestSingleTicketRefresh:w,refreshBundles:E,resolvePendingTicket:D,markPendingOptimisticMoves:O,clearPendingOptimisticMoves:k,markPendingParkedTickets:N,clearPendingParkedTickets:P}=_2(),[z,ee]=(0,b.useState)(null),[B,U]=(0,b.useState)(null),[ne,W]=(0,b.useState)(null),[re,ie]=(0,b.useState)({x:0,y:0}),[ae,G]=(0,b.useState)(!1),[ce,ue]=(0,b.useState)(!1),[de,K]=(0,b.useState)([]),[fe,pe]=(0,b.useState)([]),[me,he]=(0,b.useState)(!1),[Ne,Pe]=(0,b.useState)({}),[Fe,Ie]=(0,b.useState)(!1),[Le,Re]=(0,b.useState)(!1),[ze,Be]=(0,b.useState)(null),[Ve,He]=(0,b.useState)(null),[Ue,We]=(0,b.useState)(null),[Ge,Ke]=(0,b.useState)(null),[qe,Je]=(0,b.useState)(null),[Ye,Xe]=(0,b.useState)(null),[Ze,Qe]=(0,b.useState)(null),[$e,et]=(0,b.useState)(null),[tt,nt]=(0,b.useState)(!1),[rt,it]=(0,b.useState)(A2()),[at,ot]=(0,b.useState)(0),[st,ct]=(0,b.useState)(``),[lt,ut]=(0,b.useState)(!1),dt=i===`opencode`||Ue?.tool===`opencode`||!!Ye?.tickets.some(e=>e.tool===`opencode`),ft=i===`opencode`&&de.length>0,pt=Ue?.tool===`opencode`&&de.length>0,mt=!!Ye?.tickets.some(e=>e.tool===`opencode`)&&de.length>0,ht=(0,b.useRef)(e),_t=(0,b.useRef)(null),vt=(0,b.useRef)(null),yt=u.find(e=>e.is_running)??null,bt=yt?Nj(yt):null,xt=r?.context_key??null,St=r?.kind===`ticket`?M2(r,u)??bt:bt,Ct=r?.kind===`project`,wt=(0,b.useCallback)(e=>j2({bundleId:e,activeRunContextKey:St,isProjectRootRunActive:Ct}),[St,Ct]),Tt=z!==null&&Hj(z,`trash`)||B!==null&&H2(B),Et=y===e,Dt=(0,b.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]);(0,b.useEffect)(()=>{if(!Ve){We(null);return}let e=Dt.get(Ve)??null;e&&We(t=>!t||t.id!==Ve?e:E2(t,e))},[Ve,Dt]),(0,b.useEffect)(()=>{g&&(We(e=>!e||e.id!==g.id?e:E2(e,g)),Xe(e=>{if(!e)return e;let t=g.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===g.id)?e.tickets.map(e=>e.id===g.id?E2(e,g):e):[...e.tickets,g];return{...e,tickets:n}}))},[g]),(0,b.useEffect)(()=>{g===null||Ve!==null||Ge!==null||_()},[_,g,Ge,Ve]);let Ot=(0,b.useCallback)(async e=>{let t=await w(e);if(!t)return null;let n=Dt.get(e),r=n?E2(t,n):t;return We(t=>t&&t.id!==e||Ve&&Ve!==e?t:r),r},[w,Ve,Dt]),kt=(0,b.useCallback)(e=>{We(e),He(e.id),Ot(e.id)},[Ot]),At=(0,b.useMemo)(()=>new Map(m.map(e=>[e.id,e])),[m]),jt=(0,b.useMemo)(()=>{if(!Ye)return null;let e=Ye.bundle.id,t=g?.worktree_bundle_id===e?g:null,n=u.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=Ye.tickets.filter(e=>!C.current.has(e.id)).map(e=>t&&e.id===t.id?E2(e,t):e);t&&!i.some(e=>e.id===t.id)&&!C.current.has(t.id)&&i.push(t);let a=i.map(e=>E2(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(T2);let o=Ye.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),d=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!d&&n.some(e=>e.can_re_review===!0)},p=cv(a),m=a.find(e=>e.id===Ye.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=dv(a,{targetTicketId:Ye.target_ticket_id,reviewOwnerTicketId:m?.id??Ye.review_owner_ticket_id,latestSessionTicketId:p?.id??Ye.latest_session_ticket_id});return{...Ye,bundle:At.get(e)??Ye.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:Ye.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:Ye.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:Ye.can_re_review}},[At,g,C,Ye,u]),Mt=(0,b.useMemo)(()=>u.filter(e=>lt&&Lj(e)?!1:D2(st,e)),[lt,st,u]),Nt=(0,b.useMemo)(()=>Mt.filter(e=>Fj(e)),[Mt]),Pt=(0,b.useMemo)(()=>fv(Nt,m,k2),[m,Nt]),{boardViewportRef:Ft,boardContentRef:It,registerTicketNode:Lt,measuredCardRects:Rt,overlayPreview:zt,overlaySize:Bt,getDependencyTargetState:Vt,handleDependencyStart:Ht,handleDeleteDependency:Ut}=q0({activeProjectId:e,tickets:u,dependencies:f,setDependencies:p,activeTicket:z,activeOverlayNode:ne,dragOffset:re}),Wt=e?Ne[e]??P2():P2(),Gt=Wt.composer.worktreeBundleId&&m.some(e=>e.id===Wt.composer.worktreeBundleId)?Wt.composer.worktreeBundleId:``,Kt=Gt===Wt.composer.worktreeBundleId?Wt:{...Wt,composer:{...Wt.composer,worktreeBundleId:Gt}},qt=B2(),Jt=!!t?.run_ide?.trim(),Yt=Kt.runs.filter(e=>e.boardVisible),Xt=(0,b.useCallback)((e,t,n=u)=>{let r=fv(n,m,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[m,u]),Zt=(0,b.useCallback)(e=>(0,q.jsx)(HZ,{ticket:e,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&de.length>0,availableModels:de,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,de,m,f,u]),Qt=Yt.length>0?(0,q.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:Yt.map(e=>(0,q.jsx)(P0,{run:e},e.id))}):null,$t=(0,b.useCallback)(t=>uv(t)?t.project_id===e?Jt:!!t.has_run_ide:!1,[Jt,e]),en=(0,b.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&uv(e),[]),tn=(0,b.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?$t(t):!1},[$t]),nn=(0,b.useCallback)(e=>{let t=u.filter(t=>t.worktree_bundle_id===e).sort(T2);return Ye?.bundle.id===e?z2(Ye.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(T2),{targetTicketId:Ye.target_ticket_id,reviewOwnerTicketId:Ye.review_owner_ticket_id,latestSessionTicketId:Ye.latest_session_ticket_id}):z2(t)},[Ye,u]),rn=(0,b.useCallback)((e,t)=>{Pe(n=>({...n,[e]:t(n[e]??P2())}))},[]);(0,b.useEffect)(()=>{Ie(!1),Re(!1),ht.current!==e&&(_t.current=e),e||(_t.current=null,ct(``)),ht.current=e},[e,c]),(0,b.useLayoutEffect)(()=>{!e||v!==e||_t.current===e&&(_t.current=null,ct(``))},[e,v]),(0,b.useEffect)(()=>{if(!dt){pe([]);return}let t=new AbortController;return(async()=>{try{K(await gt(`opencode`,t.signal))}catch(e){T(e)||K(e=>e)}})(),(async()=>{try{pe(await yj(`opencode`,t.signal,e))}catch(e){T(e)||pe([])}})(),()=>{t.abort()}},[e,dt]);let an=({active:e})=>{he(!1),W(null),ie({x:0,y:0});let t=mv(String(e.id));if(t){U(Xt(t.bundleId,t.column)),ee(null);return}U(null),ee(u.find(t=>t.id===e.id)??null)},on=()=>{he(!1),W(null),ie({x:0,y:0}),ee(null),U(null)},sn=(0,b.useCallback)(e=>{d(t=>e.reduce((e,t)=>a2(e,t),t))},[d]),cn=(0,b.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&d(r=>e.reduce((e,r)=>c2(e,r.id,t,J2(r,n,t)),r))},[d]),ln=(0,b.useCallback)((e,t=u)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(T2),[u]),un=async({active:e,over:t})=>{let n=mv(String(e.id)),r=u.find(t=>t.id===e.id),i=n?Xt(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&Hj(r,`trash`)||i!==null&&H2(i)),o=t?.id&&O2.includes(t.id)?t.id:null;if(he(a),W(null),ie({x:0,y:0}),ee(null),U(null),t){if(n){if(t.id===`trash`){if(!i||!H2(i))return;await Sn(i);return}if(t.id===k2){if(!i||!U2(i))return;await yn(i);return}if(o){if(n.column===k2){if(!i||!W2(i))return;await bn(i);return}await Yn(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!Hj(r,`trash`))return;Tn(e.id);return}if(t.id===k2){if(!r||!Hj(r,k2))return;await _n(e.id);return}if(o){if(r&&Vj(r,o)){await vn(e.id);return}if(!(!r||!Hj(r,o)))try{await hn(r,o,{optimistic:!0})}catch(e){X.error(e instanceof S?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}}}},dn=async(t,n,r,a,o,s,c)=>{let l=await oe({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(R2(a,o,s),d(e=>a2(e,$0(l))),l.bundle&&h(e=>r2(e,l.bundle)),r===`build`)try{await hn(l,`build`)}catch(e){X.error(e instanceof S?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}r===`plan`&&Me(l.id,l.project_id)},fn=async t=>{if(!e)throw Error(`Cannot create a bundle without an active project.`);let n=await A(e,{name:t,prepare:!0});return h(e=>r2(e,n)),n},pn=e=>{d(t=>[...e.tickets].reverse().reduce((e,t)=>a2(e,$0(t)),t)),p(t=>e.dependencies.reduce((e,t)=>Jj(e,t),t));for(let t of e.tickets)t.bundle&&h(e=>r2(e,t.bundle))},mn=(0,b.useCallback)((e,t={})=>{let n=$0(e);d(e=>t.reorderInState?a2(e,n):i2(e,n)),We(t=>!t||t.id!==e.id?t:E2(e,n)),e.bundle&&h(t=>r2(t,e.bundle))},[h,d]),hn=async(e,t,n={})=>{let r=u.findIndex(t=>t.id===e.id),i=t===`review`?ln(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(O(o,t),a?cn(i,t):d(n=>c2(n,e.id,t,K2(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await I(e.project_id,e.worktree_bundle_id);Rn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(`Requested ticket was not returned from the bundle review response.`);return k(o),n}let n=await le(e.id,e.project_id,t);return d(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:e2(i,n)?a2(r,n):i2(r,n)}),n.bundle&&h(e=>r2(e,n.bundle)),k(o),n}catch(t){throw n.optimistic&&(a?sn(i):d(t=>c2(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),k(o)),t}},gn=(e,t)=>{d(n=>n.map(n=>n.id===e?{...n,...t}:n))},_n=async t=>{let n=u.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();N([t],r),gn(t,{parked_at:r}),mn(await be(t,n.project_id??e),{reorderInState:!0}),P([t])}catch(e){P([t]),gn(t,{parked_at:n.parked_at}),X.error(e instanceof S?e.message:`Unable to park the ticket right now.`,{id:`board-park-error`})}},vn=async t=>{let n=u.find(e=>e.id===t);if(n)try{N([t],null),gn(t,{parked_at:null}),mn(await xe(t,n.project_id??e),{reorderInState:!0}),P([t])}catch(e){P([t]),gn(t,{parked_at:n.parked_at}),X.error(e instanceof S?e.message:`Unable to return the ticket right now.`,{id:`board-unpark-error`})}},yn=(0,b.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();N(e.tickets.map(e=>e.id),r),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>be(e.id,e.project_id??x.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){P([t.value.id]),mn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;P([...a]),d(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof S?o.reason.message:`Unable to move the bundle to Done right now.`:`Moved ${e.tickets.length-a.size} of ${e.tickets.length} bundle tickets to Done.`;X.error(s,{id:`board-bundle-park-error`})},[x,mn,P,N,d]),bn=(0,b.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));N(e.tickets.map(e=>e.id),null),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>xe(e.id,e.project_id??x.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){P([t.value.id]),mn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;P([...i]),d(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof S?a.reason.message:`Unable to restore the bundle right now.`:`Restored ${e.tickets.length-i.size} of ${e.tickets.length} bundle tickets.`;X.error(o,{id:`board-bundle-unpark-error`})},[x,mn,P,N,d]),xn=async t=>{e&&(await te(e,t),h(e=>e.filter(e=>e.id!==t)))},Sn=(0,b.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:u.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)C.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));d(e=>e.filter(e=>!r.has(e.id))),p(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await ve(t.ticket.id,t.ticket.project_id??e),C.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===x.current)&&E().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)C.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===x.current)&&d(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>V2(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof S?o.reason.message:`Unable to delete the bundle tickets right now.`:`Deleted ${n.length-a.length} of ${n.length} bundle tickets.`;X.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,x,C,E,p,d,u]),Cn=e=>{let t=Dt.get(e.id);mn(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&h(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===x.current&&E().catch(()=>{})},wn=async()=>{if(!e)return;let t=e,n=Wt.composer.description.trim();if(!n)return;let r=F2(),a=ft?Wt.composer.model.trim():``,o=ft&&a?Wt.composer.variant.trim():``,s=ft?Wt.composer.skills:[],c=Date.now();rn(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:Gt,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await se({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:Gt||null});R2(a||null,a&&o||null,s);let c=I2(e);rn(t,e=>({...e,runs:L2(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),X.success(`${c.ticketCount} ${c.ticketCount===1?`card`:`cards`} created`,{id:`planning-agent-success-${r}`}),y2(e.tickets.length),x.current===t&&pn(e)}catch(e){let n=e instanceof S?e.message:`Unable to generate tickets right now.`;rn(t,e=>({...e,runs:L2(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),X.error(n,{id:`planning-agent-error`})}},Tn=async t=>{let n=u.find(e=>e.id===t),r=u.findIndex(e=>e.id===t);if(!(!n||r===-1)){C.current.set(t,{ticket:n,index:r}),d(e=>s2(e,t)),p(e=>qj(e,t));try{await ve(t,n.project_id??e),n.project_id===x.current&&E().catch(()=>{}),C.current.delete(t)}catch(e){let n=C.current.get(t);C.current.delete(t),n&&n.ticket.project_id===x.current&&(d(e=>V2(e,n)),X.error(e instanceof S?e.message:`Unable to delete the ticket right now.`,{id:`board-delete-error`}))}}},En=async t=>{let n=u.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(Be(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Rn(await L(n.project_id,n.worktree_bundle_id));return}mn(await ye(t,n.project_id??e),{reorderInState:!0})}catch(e){throw X.error(e instanceof S?e.message:`Unable to undo the ticket right now.`,{id:`board-undo-error`}),e}finally{Be(e=>e===r?null:e)}},Dn=t=>{Ce(t,u.find(e=>e.id===t)?.project_id??e)},On=async t=>{let n=u.find(e=>e.id===t);try{await we(t,n?.project_id??e),s?.()}catch(e){X.error(e instanceof S?e.message:`Unable to start the run right now.`,{id:`board-run-error`})}},kn=(0,b.useCallback)(async t=>{let n=u.find(e=>e.id===t);try{await Te(t,n?.project_id??e)}catch(e){X.error(e instanceof S?e.message:`Unable to open the IDE right now.`,{id:`board-open-ide-error`})}},[e,u]),An=async t=>{let n=u.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&St===Nj(n)?xt:null;try{await Ee(t,n?.project_id??e),o?.(i),s?.()}catch{}},jn=t=>{De(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Mn=t=>{Oe(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},Nn=(0,b.useCallback)(e=>{let t=nn(e);!t||!$t(t)||kn(t.id)},[$t,nn,kn]),Pn=(0,b.useCallback)(e=>{let t=nn(e);t&&et({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?.name??t.title})},[nn]),Fn=(0,b.useCallback)(e=>{let t=u.find(t=>t.id===e);!t||!en(t)||Qe({ticketId:t.id,projectId:t.project_id,title:t.title})},[en,u]),In=(0,b.useCallback)(async(t,n)=>{let r=u.find(e=>e.id===t);if(r)try{mn(r.state===`plan`?await je(t,r.project_id??e,n):await ke(t,r.project_id??e,n))}catch(e){throw X.error(e instanceof S?e.message:`Unable to send the follow-up prompt right now.`,{id:`board-follow-up-error`}),e}},[e,mn,u]),Ln=(0,b.useCallback)(e=>{d(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=D(n,t);if(!r)return e;let i=$0(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return e2(n,i)?a2(e,i):i2(e,i)},t))},[D,d]),Rn=(0,b.useCallback)(e=>{Xe(e),h(t=>r2(t,e.bundle)),Ln(e.tickets)},[Ln,h]),zn=(0,b.useCallback)((e,t)=>{Array.isArray(t.tickets)&&Xe(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),Bn=(0,b.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await j(t,e);return x.current===t?(Rn(n),n):null},[x,Rn]),Vn=(0,b.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await M(t,e);return x.current===t?(zn(e,n),n):null},[x,zn]),Hn=(0,b.useCallback)(async(e,t=null)=>{let n=x.current;if(!n)return;He(null),We(null),Ke(e),Je(t),it(A2());let r=At.get(e)??null,i=u.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=cv(i),t=dv(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});Xe({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else Xe(null);nt(!0);try{await Vn(e)}catch{}finally{x.current===n&&nt(!1)}},[x,At,Vn,u]),Un=(0,b.useCallback)(async(e,t)=>{it(t=>({...t,[e]:!0}));try{return await t()}finally{it(t=>({...t,[e]:!1}))}},[]),Wn=(0,b.useCallback)(async t=>{await Un(`stopBuild`,async()=>{let n=u.find(e=>e.id===t);await De(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await Bn(n.worktree_bundle_id)})},[e,Bn,Un,d,u]),Gn=(0,b.useCallback)(async t=>{await Un(`resumeBuild`,async()=>{let n=u.find(e=>e.id===t);await Oe(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await Bn(n.worktree_bundle_id)})},[e,Bn,Un,d,u]),Kn=(0,b.useCallback)(async t=>{if(e)try{Rn(await Un(`build`,()=>F(e,t))),Ge===t&&Je(`build`),s?.()}catch(e){throw X.error(e instanceof S?e.message:`Unable to build the bundle right now.`,{id:`board-bundle-build-error`}),e}},[e,Rn,s,Un,Ge]),qn=(0,b.useCallback)(async t=>{if(e)try{Rn(await Un(`review`,()=>I(e,t))),Ge===t&&Je(`review`)}catch(e){throw X.error(e instanceof S?e.message:`Unable to review the bundle right now.`,{id:`board-bundle-review-error`}),e}},[e,Rn,Un,Ge]),Jn=(0,b.useCallback)(async t=>{if(e)try{Be(`review`),Rn(await Un(`undoReview`,()=>L(e,t))),Ge===t&&Je(`build`)}catch(e){throw X.error(e instanceof S?e.message:`Unable to undo the bundle review right now.`,{id:`board-bundle-undo-review-error`}),e}finally{Be(e=>e===`review`?null:e)}},[e,Rn,Un,Ge]),Yn=(0,b.useCallback)(async(e,t,n)=>{if(t===k2||n===k2)return;let r=q2(t,n);if(!r)return;let i=u.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);O(a,n),cn(i,n);try{if(r===`build`){await Kn(e),k(a);return}if(r===`review`){await qn(e),k(a);return}await Jn(e),k(a)}catch(e){sn(i),k(a),X.error(e instanceof S?e.message:`Unable to move the bundle right now.`,{id:`board-bundle-move-error`})}},[k,Kn,qn,Jn,O,cn,sn,u]),Xn=async t=>{e&&(Rn(await Un(`run`,()=>V(e,t))),s?.())},Zn=async t=>{if(!e)return;let n=r?.kind===`ticket`&&St===t?xt:null,i=await Un(`stop`,()=>H(e,t));o?.(n),Rn(i),s?.()},Qn=(0,b.useCallback)(async(t,n)=>{e&&Rn(await Un(`followUp`,()=>R(e,t,n)))},[e,Rn,Un]);(0,b.useEffect)(()=>()=>{a?.(null)},[a]),(0,b.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:`Preview selection is unavailable for project root runs.`,submitPrompt:null});return}let e=u.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:`Preview selection is only available for build-capable ticket runs.`,submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:`Preview selection is unavailable while this ticket is in Plan mode.`,submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:`Follow up on this bundle`,submitPrompt:t=>Qn(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:`Follow up on this ticket`,submitPrompt:t=>In(e.id,t)})},[r,In,Qn,a,u]);let $n=async t=>{let n=u.find(e=>e.id===t),r=n?jj(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await Ae(n.id,n.project_id??e);mn(t),t.worktree_bundle_id&&await Bn(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await qn(n.worktree_bundle_id);return}await hn(n,r)}catch(e){throw X.error(e instanceof S?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`}),e}},er=async t=>{let n=u.find(e=>e.id===t);try{mn(await ge(t,n?.project_id??e))}catch(e){throw X.error(e instanceof S?e.message:`Unable to start the build chain right now.`,{id:`board-build-chain-error`}),e}},tr=async t=>{let n=u.find(e=>e.id===t);try{await _e(t,n?.project_id??e)}catch(e){throw X.error(e instanceof S?e.message:`Unable to stop the build chain right now.`,{id:`board-stop-build-chain-error`}),e}},nr=async()=>{if(!(!e||Le)){Re(!0);try{let t=await Se(e);d(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),p(e=>t.deleted_ticket_ids.reduce(qj,e)),await E(),Ie(!1),t.failed_count>0?X.error(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}, but ${t.failed_count} failed.`,{id:`board-delete-parked-error`}):X.success(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}.`,{id:`board-delete-parked-success`})}catch(e){X.error(e instanceof S?e.message:`Unable to empty Done right now.`,{id:`board-delete-parked-error`})}finally{Re(!1)}}},rr=({delta:e})=>{ie(e)},ir=(0,b.useCallback)(()=>{e&&G(!0)},[e]),ar=(0,b.useCallback)(()=>{e&&rn(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,rn]),or=(0,b.useCallback)(()=>{vt.current?.focus({preventScroll:!0})},[]);return Q0([{key:`n`,onKeyDown:ir,disabled:!e},{key:`a`,onKeyDown:ar,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:or}],{isBlocked:Z0}),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(QA,{sensors:l,collisionDetection:uk,onDragStart:an,onDragMove:rr,onDragCancel:on,onDragEnd:un,children:[(0,q.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,q.jsx)(B0,{projectId:e,state:Kt,bundles:m,projectBranchState:n,showModelSelector:ft,availableModels:de,availableSkills:fe,onManageBundles:e?()=>{(async()=>{try{await E()}catch{}ue(!0)})()}:void 0,onToggle:()=>{e&&rn(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=de.find(e=>e.id===t)??null;rn(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&rn(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{wn()}}),(0,q.jsx)(`div`,{"aria-hidden":`true`,className:J(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Kt.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,q.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,q.jsx)(Dg,{id:`board-ticket-search`,ref:vt,type:`search`,value:st,onChange:e=>ct(e.target.value),placeholder:`Search tickets`,"aria-label":`Search tickets`,className:`pr-32`}),st.length>0?(0,q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Clear search`,className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{ct(``),vt.current?.focus()},children:(0,q.jsx)(kv,{className:`size-4`})}):(0,q.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,q.jsx)(__,{children:`CTRL`}),(0,q.jsx)(`span`,{children:`+`}),(0,q.jsx)(__,{children:`K`})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(sy,{id:`board-hide-stale-tickets`,checked:lt,onCheckedChange:ut,"aria-label":`Hide stale tickets`}),(0,q.jsx)(Vg,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:`Hide stale tickets`})]})]}),(0,q.jsx)(`div`,{ref:Ft,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,q.jsxs)(`div`,{ref:It,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,q.jsx)(A0,{dependencies:f,cardRects:Rt,preview:zt,ticketsById:Dt,overlaySize:Bt}),O2.map(t=>{let n=u.filter(e=>e.state===t&&!Fj(e)),r=Mt.filter(e=>e.state===t&&!Fj(e)),i=fv(r,m,t),a=Et&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,q.jsx)(WZ,{id:t,title:t.charAt(0).toUpperCase()+t.slice(1),pinnedContent:t===`plan`?Qt:null,items:i,ticketCount:r.length,allTickets:u,dependencies:f,showModelSelector:ft,availableModels:de,bundles:m,activeRunContextKey:St,isProjectRootRunActive:Ct,isBundleRunDisabled:wt,getDependencyTargetState:Vt,onDependencyStart:Ht,onDeleteDependency:Ut,onRegisterTicketNode:Lt,onAddTicket:t===`plan`&&e?ir:void 0,onCreateBundle:t===`plan`&&e?fn:void 0,onDeleteBundle:t===`plan`&&e?xn:void 0,onDeleteBundleWrapper:Sn,onRefreshBundles:t===`plan`&&e?E:void 0,onUpdateTicket:Cn,onDeleteTicket:Tn,onUndoTicket:En,undoingColumn:ze,onRetryTicket:Dn,onAdvanceTicket:$n,onParkTicket:_n,onUnparkTicket:vn,onBuildChainTicket:er,onRunTicket:On,canOpenChangesForTicket:en,onOpenChangesTicket:Fn,canOpenIdeForTicket:$t,onOpenIdeTicket:kn,onStopTicket:An,onStopBuildTicket:jn,onStopBuildChainTicket:tr,onResumeBuildTicket:Mn,onOpenBundleChanges:Pn,onOpenBundleIde:Nn,onFollowUpTicket:In,bundleActionState:rt,onBuildBundle:Kn,onReviewBundle:qn,onUndoBundleReview:Jn,onRunBundle:Xn,onStopBundle:Zn,onParkBundleWrapper:yn,onUnparkBundleWrapper:bn,onOpenTicketDetails:kt,onOpenBundleDetails:(e,t)=>{Hn(e,t)},onRequestBundleRefresh:e=>{Un(`bundleRefresh`,()=>Bn(e))},onRequestTicketRefresh:w,loadingSkeletonCount:a},t)}),(0,q.jsx)(WZ,{id:k2,title:`Done`,items:Pt,ticketCount:Nt.length,allTickets:u,dependencies:f,showModelSelector:ft,availableModels:de,bundles:m,activeRunContextKey:St,isProjectRootRunActive:Ct,isBundleRunDisabled:wt,getDependencyTargetState:Vt,onDependencyStart:Ht,onDeleteDependency:Ut,onRegisterTicketNode:Lt,onUpdateTicket:Cn,onDeleteTicket:Tn,onUndoTicket:En,undoingColumn:ze,onRetryTicket:Dn,onAdvanceTicket:$n,onParkTicket:_n,onUnparkTicket:vn,onBuildChainTicket:er,onRunTicket:On,canOpenChangesForTicket:en,onOpenChangesTicket:Fn,canOpenIdeForTicket:$t,onOpenIdeTicket:kn,onStopTicket:An,onStopBuildTicket:jn,onStopBuildChainTicket:tr,onResumeBuildTicket:Mn,onOpenBundleChanges:Pn,onOpenBundleIde:Nn,onFollowUpTicket:In,bundleActionState:rt,onBuildBundle:Kn,onReviewBundle:qn,onUndoBundleReview:Jn,onRunBundle:Xn,onStopBundle:Zn,onParkBundleWrapper:yn,onUnparkBundleWrapper:bn,onOpenTicketDetails:kt,onOpenBundleDetails:(e,t)=>{Hn(e,t)},onRequestBundleRefresh:e=>{Un(`bundleRefresh`,()=>Bn(e))},onRequestTicketRefresh:w,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,q.jsxs)(Y,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:Nt.length===0||Le,onClick:()=>Ie(!0),children:[(0,q.jsx)(qv,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Empty`})]})})]})})]})]}),(0,q.jsxs)(vj,{zIndex:5,dropAnimation:me?null:void 0,children:[z&&(0,q.jsx)(HZ,{ticket:z,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:z.tool===`opencode`&&de.length>0,availableModels:de,runDisabled:G2(z,St,Ct)!==void 0,runDisabledReason:G2(z,St,Ct),onDependencyStart:Ht,onDeleteDependency:Ut,onRegisterOverlayNode:W,onCreateBundle:fn,onDeleteBundle:xn,onRefreshBundles:E,onUpdate:Cn,onDelete:()=>Tn(z.id),onUndo:()=>En(z.id),undoInProgress:ze===z.state&&(z.state===`build`||z.state===`review`),onRetry:()=>Dn(z.id),onAdvance:()=>$n(z.id),onPark:()=>_n(z.id),onUnpark:()=>vn(z.id),onBuildChain:()=>er(z.id),onRun:z.worktree_bundle_id===null&&uv(z)&&z.has_run_config?()=>On(z.id):void 0,onOpenIde:z.worktree_bundle_id===null&&$t(z)?()=>kn(z.id):void 0,onStop:z.worktree_bundle_id===null?()=>An(z.id):void 0,onStopBuild:()=>jn(z.id),onStopBuildChain:()=>tr(z.id),onResumeBuild:()=>Mn(z.id),onFollowUp:e=>In(z.id,e),onRequestTicketRefresh:w}),!z&&B&&(0,q.jsx)(SM,{group:B,overlay:!0,renderTicket:Zt})]}),Tt&&(0,q.jsx)(V0,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),ae&&(0,q.jsx)(j0,{onSubmit:dn,bundles:m,projectId:e,projectBranchState:n,tool:i,showModelSelector:ft,availableModels:de,availableSkills:fe,initialModel:ft?qt.model:``,initialVariant:ft&&qt.model?qt.variant:``,initialSkills:ft?qt.skills:[],onCreateBundle:fn,onDeleteBundle:xn,onRefreshBundles:E,onClose:()=>G(!1)}),ce&&e&&(0,q.jsx)(Xv,{bundles:m,selectedBundleId:Kt.composer.worktreeBundleId||null,onSelectBundle:t=>{rn(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:fn,onDeleteBundle:xn,onClose:()=>ue(!1)}),Fe&&(0,q.jsx)(GZ,{ticketCount:Nt.length,isDeleting:Le,onCancel:()=>Ie(!1),onConfirm:()=>{nr()}}),Ue&&(0,q.jsx)(VZ,{ticket:Ue,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=Ue.id;He(null),We(null),d(t=>t.map(t=>t.id===e?$0(t):t))},showModelSelector:pt,availableModels:de,availableSkills:fe,runDisabled:G2(Ue,St,Ct)!==void 0,runDisabledReason:G2(Ue,St,Ct),onDeleteDependency:Ut,onCreateBundle:fn,onDeleteBundle:xn,onRefreshBundles:E,onUpdate:Cn,onAdvance:()=>$n(Ue.id),onBuildChain:()=>er(Ue.id),onRun:uv(Ue)&&Ue.has_run_config?()=>On(Ue.id):void 0,onOpenIde:$t(Ue)?()=>kn(Ue.id):void 0,onStop:()=>An(Ue.id),onStopBuild:()=>jn(Ue.id),onStopBuildChain:()=>tr(Ue.id),onResumeBuild:()=>Mn(Ue.id),onFollowUp:e=>In(Ue.id,e),onProjectMemorySuggestionsChanged:()=>{ot(e=>e+1)},onRequestTicketRefresh:e=>{Ot(e)}}),$e&&(0,q.jsx)(g0,{ticketId:$e.ticketId,projectId:$e.projectId,reviewCommentsBundleId:$e.bundleId,title:$e.title,onSubmitReviewPrompt:e=>Qn($e.bundleId,e),canSubmitReviewPrompt:!u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,canAddReviewComments:!u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`),canModifyChanges:!u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`),changesDisabledReason:u.some(e=>e.worktree_bundle_id===$e.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before modifying changes.`:void 0,onClose:()=>{let{bundleId:e}=$e;et(null),Bn(e)},onTicketUpdate:Cn,onRequestTicketRefresh:w}),Ze&&(0,q.jsx)(g0,{ticketId:Ze.ticketId,projectId:Ze.projectId,title:Ze.title,onClose:()=>{let{ticketId:e}=Ze;Qe(null),Ot(e)},onTicketUpdate:Cn,onRequestTicketRefresh:e=>{Ot(e)}}),Ge&&jt&&(0,q.jsx)(dQ,{details:jt,activeColumn:qe,isLoading:tt||rt.bundleRefresh,actionState:rt,canOpenIde:tn(jt),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:at,runDisabled:wt(jt.bundle.id),showModelSelector:mt,availableModels:de,availableSkills:fe,onClose:()=>{let e=jt.bundle.id;Ke(null),Je(null),Xe(null),nt(!1),it(A2()),d(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==Ve?$0(t):t))},onOpenTicketDetails:kt,onUpdateTicket:Cn,onOpenIde:()=>{let e=jt.tickets.find(e=>e.id===jt.target_ticket_id)??jt.tickets.find(e=>e.has_worktree);e&&kn(e.id)},onRefresh:e=>{Un(`bundleRefresh`,()=>Bn(e))},onBuildBundle:Kn,onStopBuildTicket:Wn,onResumeBuildTicket:Gn,onReviewBundle:qn,onUndoBundleReview:Jn,onRunBundle:Xn,onStopBundle:Zn,onFollowUpBundle:Qn})]})},X2=({className:e})=>(0,q.jsx)(dh,{"aria-hidden":`true`,className:e}),Z2=({className:e})=>(0,q.jsx)(fh,{"aria-hidden":`true`,className:e}),Q2=({state:e,className:t})=>e?(0,q.jsx)(`span`,{"aria-hidden":`true`,"data-activity-indicator":`true`,"data-state":e,"data-testid":`workspace-activity-indicator`,className:J(`h-2 w-2 flex-shrink-0 rounded-full`,e===`running`?`animate-pulse bg-amber-300`:e===`interrupted`?`bg-amber-400/80 ring-1 ring-amber-400/30`:e===`error`?`bg-rose-400/90 ring-1 ring-rose-400/30`:`bg-emerald-400/80 ring-1 ring-emerald-400/30`,t)}):null,$2=4,e4=5e3,t4=e=>e.replace(/^[ab]\//,``),n4=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?t4(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?t4(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},r4=e=>{let[t,n]=n4(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},i4=e=>{let t=k$((()=>{let[t,n]=n4(e);return t??n??null})());if(!t)return null;try{return iD(e.hunks,{highlight:!0,refractor:k1.default,language:t,enhancers:[nD(e.hunks)]})}catch{return null}},a4=(e,t)=>e instanceof Error?e.message:t,o4=(e,t)=>{if(!t)return e;let n=r4(t);return[t,...e.filter(e=>r4(e)!==n)]},s4=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),c4=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},l4=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},u4={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},d4={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},f4=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,b.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?`Diff`:s?l4(s.path):`File`:e===`all`?`All changes`:s?l4(s.path):e;return(0,q.jsxs)(Hg,{open:a,onOpenChange:o,children:[(0,q.jsx)(Ug,{asChild:!0,children:(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,className:J(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":`Open changed files`,title:e===`all`?void 0:s?.path??e,children:[(0,q.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,q.jsxs)(Z,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:[t.length,` file`,t.length===1?``:`s`]}),(0,q.jsx)(m_,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,q.jsxs)(Wg,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Changed files`})}),(0,q.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:J(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,p$(e===`all`),`justify-between`),children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`All changes`}),(0,q.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:`Review the full workspace diff.`})]}),n&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[n.files_changed,` file`,n.files_changed===1?``:`s`]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:J(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,p$(e===t.path)),children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:l4(t.path)}),(0,q.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,q.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,q.jsx)(Z,{variant:`outline`,className:u4[t.status],children:d4[t.status]}),t.staged&&(0,q.jsx)(Z,{variant:`outline`,children:`Staged`}),t.unstaged&&(0,q.jsx)(Z,{variant:`outline`,children:`Unstaged`}),t.conflicted&&(0,q.jsx)(Z,{variant:`destructive`,children:`Conflicted`}),t.originalPath&&(0,q.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?`from ${t.originalPath}`:t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},p4=(0,b.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(!1),[,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(new Map),[C,w]=(0,b.useState)(!1),T=(0,b.useRef)(0),E=(0,b.useRef)(0),D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=a.selectedDiffPath,A=a.activeReviewTarget,j=a.editingReviewCommentKey,M=A?.commentKey??j??`chat`,N=a.reviewDraftInput,P=(0,b.useMemo)(()=>new Map(a.reviewComments.map(e=>[mD(e.filePath,e.changeKey),e])),[a.reviewComments]),F=(0,b.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await uO(e,t):await qe(e)},[t,e]),I=(0,b.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await dO(e,t):await Ye(e)},[t,e]);(0,b.useEffect)(()=>{D.current=d},[d]),(0,b.useEffect)(()=>{O.current=p},[p]);let L=(0,b.useCallback)(async()=>{if(!e){E.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=T.current+1,n=E.current+1;T.current=t,E.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([F(),I()]);T.current===t&&(r.status===`fulfilled`?(D.current=r.value,f(r.value),g(null)):g(a4(r.reason,`Unable to load the diff right now.`)),i.status===`fulfilled`&&(O.current=i.value,m(i.value)),E.current===n&&v(!1),y(!1))},[F,I,e]),R=(0,b.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=T.current+1;T.current=r,y(!0);try{let t=await I();if(T.current!==r)return;let i=O.current?.workspace_signature??null,a=t.workspace_signature??null,o=!D.current||i!==a;if(O.current=t,m(t),!o){E.current+=1,v(!1);return}let s=!D.current,c=E.current+1;E.current=c,s&&v(!0);try{let t=await F();if(T.current!==r)return;D.current=t,f(t),g(null),n&&i!==a&&j$(e)}catch(e){if(T.current!==r)return;D.current||g(a4(e,`Unable to load the diff right now.`))}finally{s&&E.current===c&&v(!1)}}catch{D.current||(E.current+=1,v(!1));return}finally{T.current===r&&y(!1)}},[F,I,e]);(0,b.useEffect)(()=>{L()},[L]),(0,b.useEffect)(()=>{if(e)return M$(t=>{t===e&&R()})},[e,R]),(0,b.useEffect)(()=>{if(!e)return;let t=P$(()=>{document.visibilityState===`visible`&&R({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,R]),(0,b.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&R({broadcastOnSignatureChange:!0})},e4);return()=>{window.clearInterval(t)}},[e,R]);let z=(0,b.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?Yx(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:n4(e)})):[]},[d]),ee=(0,b.useMemo)(()=>{let e=new Map;for(let t of z)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[z]),B=(0,b.useMemo)(()=>c4({diffResponse:d,gitStatus:p}),[d,p]);(0,b.useEffect)(()=>{if(k!==`all`&&!(!d&&!p)){if(B.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}B.some(e=>e.path===k)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,k,B]);let V=k===`all`?null:ee.get(k)??null,H=(0,b.useMemo)(()=>o4(z,V),[z,V]),te=(0,b.useMemo)(()=>k===`all`?z:V?[V]:[],[z,k,V]);(0,b.useEffect)(()=>{S(new Map)},[z]),(0,b.useEffect)(()=>{if(H.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=H.slice(n,n+$2);i.length!==0&&(S(e=>{let t=new Map(e);for(let e of i){let n=r4(e);t.has(n)||t.set(n,i4(e))}return t}),n+=$2,n<H.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[H]);let U=(0,b.useMemo)(()=>{let e=new Map;for(let t of H.slice(0,$2))e.set(r4(t),i4(t));return e},[H]),ne=(0,b.useMemo)(()=>te.map(e=>({...e,tokens:x.get(r4(e))??U.get(r4(e))??null})),[U,x,te]),W=(0,b.useMemo)(()=>z.map(e=>({...e,tokens:null})),[z]),re=(0,b.useMemo)(()=>s4(a.reviewComments),[a.reviewComments]),ie=re.length,ae=n&&!C&&ie>0,G=(0,b.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),oe=(0,b.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=P.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,P]),se=(0,b.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),ce=(0,b.useCallback)(e=>{let t=P.has(e.commentKey);if(!n&&!t)return;let r=N.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[mD(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:hD(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,P,N]),le=(0,b.useCallback)(e=>{let t=P.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,P]),ue=(0,b.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>mD(t.filePath,t.changeKey)!==e)}))},[o]),de=(0,b.useCallback)(async()=>{if(!ae)return;w(!0);let e=wD({drafts:re,findings:[],githubComments:[],uncommittedFiles:z});try{await i(e),G(),X.success(`Changes sent to chat.`,{id:`chat-diff-review-submit-success`})}catch(e){X.error(a4(e,`Unable to send the changes right now.`),{id:`chat-diff-review-submit-error`})}finally{w(!1)}},[ae,G,i,z,re]),K=(0,b.useCallback)(e=>(0,q.jsx)(bQ,{reviewComments:re,pendingFixCount:ie,triggerMode:e===`wide`?`full`:`compact`,canSendReview:ae,isSubmittingReview:C,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:G,onSubmitReview:()=>{de()}}),[ae,G,de,C,ie,re,r]),fe=c?(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close diff panel`,className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,q.jsx)(kv,{className:`h-4 w-4`})}):null,pe=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,q.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:pe,className:J(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,q.jsx)(f$,{selectedDiffPath:k,sidebarFiles:B,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:W,renderedFiles:ne,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{L()},activeReviewTarget:A,editingReviewCommentKey:j,reviewDraftInstanceKey:M,reviewDraftInput:N,reviewComments:re,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:oe,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:se,onEditReviewDraft:le,onRemoveReviewDraft:ue,onSaveReviewDraft:ce,diffThemeClassName:v$,resolveFilePath:r4,normalizeDiffPath:t4,emptyStateTitle:`No uncommitted changes.`,emptyStateDescription:`The current project branch is clean.`,filePickerControl:e=>(0,q.jsx)(f4,{selectedDiffPath:k,sidebarFiles:B,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:K,extraHeaderControl:fe,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});p4.displayName=`ChatChangesPanel`;var m4=({projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o=!1,canShowComposer:s,isExternallyResizing:c=!1,pendingAgentRevealKey:l=null,pendingAgentRevealDelayMs:u=0,composerFocusNonce:d=0,header:f,composerControls:p,composerInlineControls:m,composerTheme:h=`default`,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b=null,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E})=>(0,q.jsx)(kB,{projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:s,header:f,composerControls:p,composerInlineControls:m,composerTheme:h,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:c,pendingAgentRevealKey:l,pendingAgentRevealDelayMs:u,composerFocusNonce:d,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b,autoFocusComposer:!0,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E}),h4={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},g4=({tone:e=`default`,className:t,children:n,...r})=>(0,q.jsx)(Z,{variant:`outline`,className:J(h4[e],t),...r,children:n}),_4=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),v4=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
174
174
  `),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
175
175
  `),stages:``,priority:`normal`},y4=e=>e.split(`
176
- `).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),b4=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},x4=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=a?`Save as new decision`:`Accept`,s=e.kind===`decision`?e.decision:e.instruction;return(0,q.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,q.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,q.jsxs)(g4,{children:[`Suggested `,e.kind]}),a?(0,q.jsx)(g4,{tone:`muted`,children:`Possible duplicate`}):null]}),(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:`Dismiss`})]})]})})},S4=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?`Save as new decision`:`Accept as ${e.kind}`;return(0,q.jsx)(vg,{open:t,onOpenChange:a,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:e.title}),(0,q.jsx)(Eg,{children:`Review this suggestion before saving it into project memory.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,q.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,q.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,q.jsxs)(`p`,{children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Suggestion title`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion title`,value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Scope`}),(0,q.jsx)(`input`,{"aria-label":`Scope`,value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:i.kind===`decision`?`Decision`:`Instruction`}),(0,q.jsx)(`textarea`,{"aria-label":i.kind===`decision`?`Decision`:`Instruction`,value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Rationale`}),(0,q.jsx)(`textarea`,{"aria-label":`Rationale`,value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Implications (one per line)`}),(0,q.jsx)(`textarea`,{"aria-label":`Implications`,value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Stages (comma or newline separated)`}),(0,q.jsx)(`textarea`,{"aria-label":`Stages`,value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Priority`}),(0,q.jsxs)(`select`,{"aria-label":`Priority`,value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,q.jsx)(`option`,{value:`low`,children:`Low`}),(0,q.jsx)(`option`,{value:`normal`,children:`Normal`}),(0,q.jsx)(`option`,{value:`high`,children:`High`})]})]})]})]}):(0,q.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?`Decision`:`Instruction`}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Rationale`}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Implications`}),(0,q.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Stages`}),(0,q.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.join(`, `)||`None specified`})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Priority`}),(0,q.jsx)(`p`,{className:`text-muted-foreground`,children:e.priority})]})]}):null]})]}),(0,q.jsxs)(wg,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:`Cancel edits`}):(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:`Edit`}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:`Dismiss`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}):null,(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},C4=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(_4),[f,p]=(0,b.useState)(null);(0,b.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(_4())},g=e=>{s(e.id),l(e.id),d(v4(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},v=e=>{e||(s(null),c&&h())},y=async(t,n)=>{let r=c===t.id?u:v4(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:y4(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:b4(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let n=t.duplicate_match?.decision;if(!n)throw Error(`No existing decision is available for this suggestion.`);await pt(e,t.id,n.id,i)}else await dt(e,t.id,i);h(),s(null),a?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}},x=async t=>{p(t.id);try{await ft(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,q.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,q.jsxs)(`div`,{children:[n?(0,q.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,q.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,q.jsx)(x4,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>y(e,!1),onDismiss:x},e.id))}):i?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,q.jsx)(S4,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?v4(m):u,onOpenChange:v,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:y,onDismiss:x})]})},w4=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),T4=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],E4=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},D4=e=>e.activity_at??e.last_user_message_at??e.created_at,O4=(e,t)=>{let n=D4(e),r=D4(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},k4=e=>[...e].sort(O4),A4=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),j4=(e,t=new Date)=>{let n=E4(D4(e));if(!n)return`older`;let r=A4(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},M4=(e,t=new Date)=>{let n=new Map;for(let r of k4(e)){let e=j4(r,t);n.set(e,[...n.get(e)??[],r])}return T4.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},N4=1500,P4=`archon.chat-run-config`,F4=`archon.chat-changes-panel-layout`,I4=`archon.chat-session-list-layout`,L4=`archon.chat-draft`,R4=512,z4=360,B4=.6,V4=6,H4=`.`,U4=`/`,W4=`Slash`,G4=`NumpadDivide`,K4=600,q4=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):R4;if(!Number.isFinite(t))return Math.max(z4,n);let r=Math.max(z4,Math.round(t*B4));return Math.max(z4,Math.min(r,n))},J4=e=>e===`claude`?`Claude`:`OpenCode`,Y4=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,X4=e=>e===`plan`?`Plan`:`Build`,Z4=e=>e===`plan`?`Ask Archon to scope, sequence, or reason through project work`:`Ask Archon to build, change, or verify something in this project`,Q4=e=>`${e} pending memory suggestion${e===1?``:`s`}`,$4=e=>e===`plan`?`build`:`plan`,e3=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===H4,t3=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===U4||e.code===W4||e.code===G4),n3=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},r3=()=>n3()?`CMD`:`CTRL`,i3=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,q.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,q.jsx)(__,{"aria-hidden":n,children:e}),t.map(e=>(0,q.jsxs)(`span`,{className:`contents`,children:[(0,q.jsx)(`span`,{children:`+`}),(0,q.jsx)(__,{"aria-hidden":n,children:e})]},e))]}),a3=({label:e,modifierLabel:t,keys:n})=>(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{children:e}),(0,q.jsx)(i3,{modifierLabel:t,keys:n,ariaHidden:!0})]}),o3=({modelLabel:e,tool:t})=>e??J4(t),s3=()=>`You`,c3=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},l3=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),u3=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,d3=({projectId:e,tool:t})=>`${P4}:${e}:${t}`,f3=({projectId:e,tool:t,chatSessionId:n})=>n?`${L4}:${e}:session:${n}`:`${L4}:${e}:draft:${t}`,p3=e=>`${F4}:${e}`,m3=e=>`${I4}:${e}`,h3=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},g3=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},_3=e=>{if(!e)return{isOpen:!0,width:R4};try{let t=window.localStorage.getItem(p3(e));if(!t)return{isOpen:!0,width:R4};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(z4,Math.round(n.width)):R4;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:R4}}},v3=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(m3(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},y3=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(p3(e),JSON.stringify({isOpen:t,width:n}))}catch{}},b3=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(m3(e),JSON.stringify({isOpen:t}))}catch{}},x3=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem(d3({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},S3=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem(d3({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},C3=({projectId:e,tool:t})=>x3({projectId:e,tool:t})?.mode??`plan`,w3=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=x3({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},T3=e=>e&&e.replace(/\s+/g,` `).trim()||null,E3=e=>{let t=T3(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return T3(n)},D3=({chatSessionId:e,instruction:t,createdAt:n})=>({id:`optimistic:${e}:${n}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,created_at:n}),O3=({session:e,instruction:t,createdAt:n})=>({...e,messages:[...e.messages??[],D3({chatSessionId:e.id,instruction:t,createdAt:n})],activity_at:n,last_user_message_at:n,updated_at:n}),k3=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),A3=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:t?!n.target_branch_snapshot||t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot:!0,j3=e=>e.target_kind===`bundle`?e.target_label_snapshot||`Bundle target`:null,M3=e=>e.target_kind===`bundle`?j3(e)||`Bundle target`:e.target_branch_snapshot?`Repo root (${e.target_branch_snapshot})`:`Repo root`,N3=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?`selected bundle target`:t?.branch?`Repo root (${t.branch})`:`Repo root`:`current target`,P3=({title:e,isDeleting:t,onConfirm:n,onCancel:r})=>(0,q.jsxs)(Iv,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete chat session`}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`This permanently removes the transcript history for this chat session.`}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:r,disabled:t,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:n,disabled:t,children:t?`Deleting...`:`Delete`})]})]}),F3=({activeProject:e,activeSessionId:t,chatModeShortcutModifierLabel:n,confirmingDeleteSessionId:r,deletingSessionId:i,finishedBackgroundSessionIds:a,isCreatingSession:o,isDraftOpen:s,isLoadingSessions:c,isOpen:l,isSendingPrompt:u,sessionGroups:d,sessions:f,onConfirmDeleteSession:p,onDraftOpen:m,onSessionSelect:h,onToggleOpen:g})=>(0,q.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":l?`expanded`:`collapsed`,"aria-label":`Chat sessions sidebar`,className:J(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,l?`w-72`:`w-16`),children:l?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3`,children:[(0,q.jsxs)(Y,{type:`button`,size:`sm`,className:`gap-2`,onClick:m,disabled:o||u,children:[(0,q.jsx)(Ev,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`New session`}),(0,q.jsx)(i3,{modifierLabel:n,keys:[U4],ariaHidden:!0})]}),(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Collapse sessions panel`,"aria-expanded":l,className:`ml-auto`,onClick:g,children:(0,q.jsx)(X2,{className:`h-4 w-4`})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:c&&f.length===0?(0,q.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):f.length===0?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:`No chat sessions yet.`}):(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:d.map(n=>(0,q.jsxs)(`section`,{"aria-label":n.label,className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:n.label}),n.sessions.map(n=>{let o=!s&&n.id===t,c=E3(n),l=j3(n),u=n.agent_status===`running`?`Wait for the current chat response to finish before deleting this session.`:null,d=r===n.id||i===n.id,f=!!u||i===n.id,m=n.agent_status===`running`?`running`:n.agent_status===`stopped`?`interrupted`:a.has(n.id)?`finished`:null,g=m===`interrupted`?null:m;return(0,q.jsxs)(`div`,{className:J(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":[n.title,X4(n.mode),J4(n.tool),e?.memory_enabled&&n.pending_memory_suggestion_count>0?Q4(n.pending_memory_suggestion_count):null,m===`running`?`Running`:m===`interrupted`?`Interrupted`:m===`finished`?`Finished`:null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{h(n)},children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l?(0,q.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:l}):null,(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.title}),e?.memory_enabled&&n.pending_memory_suggestion_count>0?(0,q.jsx)(g4,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":Q4(n.pending_memory_suggestion_count),title:Q4(n.pending_memory_suggestion_count),children:n.pending_memory_suggestion_count}):null]}),c?(0,q.jsx)(`div`,{className:J(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:c}):null,n.target_available===!1?(0,q.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:n.target_unavailable_reason??`Target unavailable`}):null]}),(0,q.jsx)(Q2,{state:g,className:`mt-1`})]})}),(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Delete chat session`,className:J(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,f&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||d)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,u&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:u??`Delete ${n.title}`,disabled:f,onClick:e=>{e.stopPropagation(),p(n.id)},children:(0,q.jsx)(qv,{className:`h-4 w-4`})})]},n.id)})]},n.key))})})]}):(0,q.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,q.jsx)(u_,{content:(0,q.jsx)(a3,{label:`Start new session`,modifierLabel:n,keys:[U4]}),side:`right`,children:(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,"aria-label":`New session`,className:`h-9 w-9`,onClick:m,disabled:o||u,children:(0,q.jsx)(Ev,{className:`h-4 w-4`})})}),(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Open sessions panel`,"aria-expanded":l,className:`h-9 w-9`,onClick:g,children:(0,q.jsx)(Z2,{className:`h-4 w-4`})})]})}),I3=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,q.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:`Tickets created`}),(0,q.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Created `,e.created_tickets.length,` ticket`,e.created_tickets.length===1?``:`s`,` from this proposal.`]}),e.created_tickets.length>0?(0,q.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,q.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,q.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:`Proposed tickets`}),(0,q.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`Review these tickets before adding them to the board.`}),(0,q.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,q.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,q.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,q.jsxs)(`div`,{className:`mt-3 text-muted-foreground`,children:[`Dependencies: `,e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)]}):null,(0,q.jsx)(`div`,{className:`mt-3`,children:(0,q.jsx)(Y,{type:`button`,size:`sm`,onClick:n,disabled:t,children:t?`Creating tickets...`:`Create tickets`})})]}),L3=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let[c,l]=(0,b.useState)([]),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(null),[m,h]=(0,b.useState)(null),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(()=>C3({projectId:e,tool:r})),[x,S]=(0,b.useState)({}),[C,w]=(0,b.useState)([]),[E,D]=(0,b.useState)([]),[O,k]=(0,b.useState)(``),[A,j]=(0,b.useState)(``),[M,N]=(0,b.useState)([]),[P,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(!1),[R,z]=(0,b.useState)(!1),[ee,B]=(0,b.useState)(!1),[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(null),[ne,W]=(0,b.useState)(null),[re,ie]=(0,b.useState)(null),[ae,G]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(!1),[ce,le]=(0,b.useState)(null),[ue,de]=(0,b.useState)([]),[K,fe]=(0,b.useState)(!1),[pe,me]=(0,b.useState)(!1),[he,ge]=(0,b.useState)(0),[_e,ve]=(0,b.useState)(w4),[ye,be]=(0,b.useState)(()=>v3(e).isOpen),[xe,Se]=(0,b.useState)(()=>_3(e).isOpen),[Ce,we]=(0,b.useState)(!1),[Te,Ee]=(0,b.useState)(!1),[De,Oe]=(0,b.useState)(()=>_3(e).width),[ke,Ae]=(0,b.useState)(0),[je,Me]=(0,b.useState)(null),[Ne,Pe]=(0,b.useState)(()=>new Set),Fe=(0,b.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Ie=(0,b.useRef)(!1),Le=(0,b.useRef)(null),Re=(0,b.useRef)(null),ze=(0,b.useRef)(null),Be=(0,b.useRef)(null),Ve=(0,b.useRef)(null),He=(0,b.useRef)(null),Ue=(0,b.useRef)(null),We=(0,b.useRef)(!1),Ge=(0,b.useRef)(!1),Ke=(0,b.useRef)(0),qe=(0,b.useRef)(R4),Je=(0,b.useRef)(R4),Ye=(0,b.useRef)(!1),Xe=(0,b.useRef)(0),Ze=(0,b.useRef)({id:null,status:null}),Qe=(0,b.useRef)(new Map),$e=(0,b.useRef)({}),et=(0,b.useRef)(new Set),tt=(0,b.useRef)(!1),nt=e?f3({projectId:e,tool:g?r:f?.tool??r,chatSessionId:g?null:u}):null,rt=nt?x[nt]??``:``,it=g?r:f?.tool??r;(0,b.useEffect)(()=>{Ie.current=g},[g]),(0,b.useEffect)(()=>{$e.current=x},[x]),(0,b.useEffect)(()=>{if(!nt||et.current.has(nt))return;et.current.add(nt);let e=h3(nt);e&&S(t=>Object.prototype.hasOwnProperty.call(t,nt)?t:{...t,[nt]:e})},[nt]),(0,b.useEffect)(()=>{!nt||!Object.prototype.hasOwnProperty.call(x,nt)||g3({storageKey:nt,value:x[nt]??``})},[nt,x]),(0,b.useEffect)(()=>{Le.current=u},[u]),(0,b.useEffect)(()=>{if(!tt.current){tt.current=!0;return}let t=_3(e),n=v3(e);Ie.current=!1,Ye.current=!1,et.current=new Set,d(null),p(null),_(!1),S({}),U(null),W(null),ie(null),Me(null),de([]),me(!1),L(!1),ve(w4()),Pe(new Set),Qe.current=new Map,Je.current=t.width,be(n.isOpen),Oe(t.width),Se(t.isOpen)},[e]),(0,b.useEffect)(()=>{Ce||(Je.current=De,Be.current&&(Be.current.style.setProperty(`--chat-changes-panel-width`,`${De}px`),Be.current.setAttribute(`data-desktop-width`,String(De))))},[De,Ce]),(0,b.useEffect)(()=>{if(!s||!Re.current)return;let e=Re.current.getBoundingClientRect().width;if(e<=0)return;let t=q4(De,e);t!==De&&(Je.current=t,Oe(t))},[De,s]),(0,b.useEffect)(()=>{b3({projectId:e,isOpen:ye})},[e,ye]),(0,b.useEffect)(()=>{s&&y3({projectId:e,isOpen:xe,width:De})},[e,De,xe,s]),(0,b.useEffect)(()=>{me(!1)},[u,g]);let at=(0,b.useCallback)(e=>{l(t=>{let n=t.findIndex(t=>t.id===e.id);if(n===-1)return k4([...t,e]);let r=[...t];return r[n]=e,k4(r)})},[]),ot=(0,b.useCallback)(t=>{let n=Le.current,i=e?f3({projectId:e,tool:r,chatSessionId:t}):null;S(e=>{if(!i||!Object.prototype.hasOwnProperty.call(e,i))return e;let t={...e};return delete t[i],t}),g3({storageKey:i,value:``}),l(e=>{let r=e.filter(e=>e.id!==t);if(n===t){let e=r[0]??null;d(e?.id??null),p(null),_(e===null),de([]),fe(!1),me(!1)}return r}),Pe(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}),Me(e=>e?.sessionId===t?null:e),U(e=>e===t?null:e),W(e=>e===t?null:e),ie(e=>e===t?null:e)},[e,r]),st=(0,b.useCallback)((e,t)=>{e&&S(n=>n[e]===t?n:{...n,[e]:t})},[]),ct=(0,b.useCallback)(e=>{e&&(S(t=>t[e]===``?t:{...t,[e]:``}),g3({storageKey:e,value:``}))},[]),lt=(0,b.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call($e.current,e)?$e.current[e]??``:h3(e);S(r=>{let i={...r,[t]:n};return delete i[e],i}),g3({storageKey:t,value:n}),g3({storageKey:e,value:``})},[]),dt=(0,b.useCallback)((e,t)=>{l(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),p(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:{...n,pending_memory_suggestion_count:t})},[]),ft=(0,b.useCallback)(async r=>{if(!e){l([]),d(null),p(null),_(!1),L(!1);return}F(!0);try{let i=await VD(e,r);if(r?.aborted)return;let a=k4(i),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;l(a),d(e=>Ie.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:Ye.current?null:o?s?(Ye.current=!0,A3({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(Ye.current=!0,null)),a.length===0&&_(!0)}catch(e){T(e)||X.error(e instanceof Error?e.message:`Unable to load chat sessions right now.`)}finally{r?.aborted||(F(!1),L(!0))}},[t,n,e]),pt=(0,b.useCallback)(async(t,n)=>{if(!e){p(null);return}z(!0);try{let r=await UD(e,t,n);if(n?.aborted)return;p(r),at(r)}catch(e){T(e)||X.error(e instanceof Error?e.message:`Unable to load the chat session right now.`)}finally{n?.aborted||z(!1)}},[e,at]),mt=(0,b.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){de([]),fe(!1);return}fe(!0);try{let t=await ut(e,null,r,n);if(r?.aborted)return;de(t.suggestions),dt(n,t.suggestions.length)}catch(e){T(e)||X.error(e instanceof Error?e.message:`Unable to load chat memory suggestions right now.`)}finally{r?.aborted||fe(!1)}},[t?.memory_enabled,e,dt]),ht=(0,b.useCallback)(()=>{de(e=>{let t=e.length>0?e.slice(0,-1):e;return u&&dt(u,t.length),t}),ge(e=>e+1),ft(),u&&pt(u)},[u,pt,ft,dt]);(0,b.useEffect)(()=>{let e=new AbortController;return ft(e.signal),()=>{e.abort()}},[ft]),(0,b.useEffect)(()=>{if(Ie.current||g||u||Ye.current||c.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;Ye.current=!0;let e=c[0]??null;e&&A3({activeProject:t,activeProjectBranchState:n,session:e})&&d(e.id)},[t,n,u,g,c]),(0,b.useEffect)(()=>{if(it!==`opencode`){w([]),D([]),se(!1);return}let t=new AbortController;return(async()=>{se(!0);try{let[n,r]=await Promise.all([gt(it,t.signal),rj(it,t.signal,e)]);w(n),D(r)}catch(e){T(e)||(w(e=>e),D(e=>e))}finally{t.signal.aborted||se(!1)}})(),()=>{t.abort()}},[e,it]),(0,b.useEffect)(()=>{if(g||!u){p(null);return}if(f?.id===u)return;p(null);let e=new AbortController;return pt(u,e.signal),()=>{e.abort()}},[f,u,g,pt]),(0,b.useEffect)(()=>{if(!t?.memory_enabled||g||!u){de([]),fe(!1);return}let e=new AbortController;return mt(u,e.signal),()=>{e.abort()}},[t?.memory_enabled,u,g,mt,he]),(0,b.useEffect)(()=>{!pe||K||ue.length>0||me(!1)},[K,pe,ue.length]),(0,b.useEffect)(()=>{if(!u||f?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([ft(e.signal),pt(u,e.signal)])},N4);return()=>{e.abort(),window.clearInterval(t)}},[f?.agent_status,u,pt,ft]),(0,b.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===u&&p(t),k3(t)&&at(t))},n=t=>{!t||t.project_id!==e||ot(t.id)};return EZ.on(`chat-session:created`,t),EZ.on(`chat-session:updated`,t),EZ.on(`chat-session:deleted`,n),()=>{EZ.off(`chat-session:created`,t),EZ.off(`chat-session:updated`,t),EZ.off(`chat-session:deleted`,n)}},[e,u,ot,at]),(0,b.useEffect)(()=>{g&&y(C3({projectId:e,tool:r}))},[e,r,g]),(0,b.useEffect)(()=>{if(it!==`opencode`){k(``),j(``),N([]);return}if(g){let n=w3({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:it,availableModels:C});k(n.model),j(n.variant),N([]);return}k(f?.model??t?.helper_model??``),j(f?.variant??t?.helper_variant??``),N(f?.skills??[])},[e,t?.helper_model,t?.helper_variant,f?.id,f?.model,f?.skills,f?.variant,C,it,g]),(0,b.useEffect)(()=>{let e=C.find(e=>e.id===O)??null;j(t=>e?e.variants.includes(t)?t:``:t)},[C,O]),(0,b.useEffect)(()=>{if(it!==`opencode`||!g||!O||A)return;let n=w3({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:it,availableModels:C});n.model===O&&n.variant&&j(n.variant)},[e,t?.helper_model,t?.helper_variant,it,C,g,O,A]),(0,b.useEffect)(()=>{if(!te)return;let e=f?.id===te?f:c.find(e=>e.id===te)??null;(!e||e.agent_status!==`running`)&&U(null)},[f,te,c]),(0,b.useEffect)(()=>{let e=Ze.current,n=f?.id??null,r=f?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&ge(e=>e+1),Ze.current={id:n,status:r}},[t?.memory_enabled,e,f?.agent_status,f?.id,f?.title]),(0,b.useEffect)(()=>{u&&Pe(e=>{if(!e.has(u))return e;let t=new Set(e);return t.delete(u),t})},[u]),(0,b.useEffect)(()=>{je&&je.sessionId!==u&&Me(null)},[u,je]),(0,b.useEffect)(()=>{let e=Qe.current,t=new Map,n=[];for(let r of c){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==u&&n.push(r),t.set(r.id,a)}Qe.current=t,Pe(e=>{let t=new Set(e),r=!1,i=new Set(c.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of c){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===u||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,u,c]);let _t=(0,b.useMemo)(()=>new Map(C.map(e=>[e.id,e.label])),[C]),vt=(0,b.useMemo)(()=>M4(c),[c]),yt=(0,b.useMemo)(()=>ne?c.find(e=>e.id===ne)??(f?.id===ne?f:null):null,[f,ne,c]);(0,b.useEffect)(()=>{ne&&!yt&&W(null)},[ne,yt]);let bt=(0,b.useMemo)(()=>f?o3({modelLabel:Y4({availableModelsById:_t,model:f.model}),tool:f.tool}):null,[f,_t]),xt=(0,b.useMemo)(()=>f?(f.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?bt??J4(f.tool):s3()})):[],[f,bt]),St=f?.id&&f.agent_status===`running`&&je?.sessionId===f.id?je.turnKey:null,Ct=it===`opencode`&&C.length>0,wt=it===`opencode`&&!Ct&&oe;(0,b.useEffect)(()=>{Fe.current={model:O,variant:A,skills:M,showModelSelector:Ct}},[O,M,A,Ct]);let Tt=(0,b.useMemo)(()=>C.find(e=>e.id===O)??null,[C,O]),Et=g?v:f?.mode??`build`,Dt=g?`New chat`:f?.title??`Chat`,Ot=g?r:f?.tool??r,kt=(0,b.useMemo)(()=>r3(),[]),At=Ct?O||null:f?.model??null,jt=Y4({availableModelsById:_t,model:At}),Mt=(0,b.useMemo)(()=>{let e=f?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=u3({tool:Ot,model:At,availableModels:C,fallbackContextWindow:f?.usage_snapshot_context_window??null});if(t===null)return null;let n=l3({totalTokens:e,contextWindow:t});return n===null?null:`${c3(e)} (${n}%)`},[f?.usage_snapshot_context_window,f?.usage_snapshot_total_tokens,C,At,Ot]),Nt=g?`draft:${e??`none`}:${r}`:f?.id,Pt=(0,b.useCallback)(()=>{Ie.current=!0,_(!0),y(C3({projectId:e,tool:r})),h(null),d(null),p(null),U(null),Me(null)},[e,r]),Ft=(0,b.useCallback)((e,t=null)=>{Ie.current=!1,_(!1),h(null),d(e),p(t)},[]),It=(0,b.useCallback)(async()=>{if(!(!f||!i)){h(f.id);try{await i(f)}catch(e){X.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`)}finally{h(e=>e===f.id?null:e)}}},[f,i]),Lt=!!(f&&f.target_available!==!1&&!g&&!A3({activeProject:t,activeProjectBranchState:n,session:f})),Rt=Lt&&f?`This session targets ${M3(f)}, but the current target is ${N3({activeProject:t,activeProjectBranchState:n})}. Restore the session target to continue.`:null,zt=Lt&&m===null,Bt=(0,b.useCallback)(async r=>{h(r.id);let a=r;if(e)try{let t=await UD(e,r.id);a=t,at(t)}catch(e){X.error(e instanceof Error?e.message:`Unable to load the chat session right now.`),h(e=>e===r.id?null:e);return}if(a.target_available===!1){Ft(a.id,a);return}if(!A3({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){h(e=>e===a.id?null:e);return}}catch(e){X.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`),h(e=>e===a.id?null:e);return}Ft(a.id,a)},[t,n,e,i,Ft,at]),Vt=(0,b.useCallback)(()=>{Ae(e=>e+1)},[]),Ht=(0,b.useCallback)(async t=>{if(g){let n=Fe.current;y(t),S3({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),Vt();return}if(!(!e||!f||f.mode===t||ae)){G(!0);try{let n=await WD(e,f.id,{mode:t});S3({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),p(n),at(n),Vt()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the chat mode right now.`)}finally{G(!1)}}},[e,f,r,Vt,g,ae,at]),Ut=(0,b.useCallback)(async({instruction:t,targetSession:n})=>{if(!e)return null;let r=Fe.current;Xe.current+=1;let i={sessionId:n.id,turnKey:`${n.id}:${Xe.current}`};Me(i);try{let i=await GD(e,n.id,{instruction:t,tool:n.tool,model:r.showModelSelector&&r.model||null,variant:r.showModelSelector&&r.model&&r.variant||null,skills:r.showModelSelector?r.skills:[]});return S3({projectId:e,tool:i.tool,model:i.model,variant:i.variant,mode:i.mode}),Ie.current=!1,p(i),d(i.id),_(!1),at(i),i}catch(e){throw Me(e=>e?.turnKey===i.turnKey?null:e),e}},[e,at]),Wt=(0,b.useCallback)(async()=>{if(!e)return null;let t=Fe.current,n=await HD(e,{mode:Et,tool:r,model:t.showModelSelector&&t.model||null,variant:t.showModelSelector&&t.model&&t.variant||null,skills:t.showModelSelector?t.skills:[]});return Ie.current=!1,_(!1),d(n.id),p(n),n},[e,r,Et]),Gt=(0,b.useCallback)(async t=>{if(!e||V||ee||f?.agent_status===`running`||f?.target_available===!1||zt)return!1;let n=t.trim();if(!n)return!1;H(!0);let r=null,i=f,a=e&&f?f3({projectId:e,tool:f.tool,chatSessionId:f.id}):null;try{let t=f;if(t||(B(!0),r=await Wt(),t=r,a=e&&r?f3({projectId:e,tool:r.tool,chatSessionId:r.id}):null,lt({fromStorageKey:nt,toStorageKey:a})),!t)return!1;ct(a??nt);let i=O3({session:t,instruction:n,createdAt:new Date().toISOString()});p(i),d(i.id),at(i);let o=await Ut({instruction:n,targetSession:t});return ct(o&&e?f3({projectId:e,tool:o.tool,chatSessionId:o.id}):a),!0}catch(e){throw st(a??nt,n),r?(p(r),d(r.id),_(!1),at(r)):i&&(p(i),at(i)),e}finally{B(!1),H(!1)}},[e,f,ct,Wt,nt,ee,V,lt,Ut,st,zt,at]),Kt=(0,b.useCallback)(async e=>{await Gt(e)},[Gt]),qt=!!(e&&(g||f&&f.target_available!==!1&&!zt)),Jt=f?.agent_status===`running`,Yt=f?.agent_status===`stopped`,Xt=Jt&&te===f?.id,Zt=qt&&!Jt&&!V&&!ee,Qt=qt?f?.target_available===!1?f.target_unavailable_reason??`Target unavailable for this chat session.`:zt?Rt??`Restore the session target to continue.`:Jt?`Wait for the current chat turn to finish before sending review comments.`:ee||V?`Wait for the current chat prompt to finish sending before submitting review comments.`:null:`Open or create a chat session to send review comments.`,$t=(0,b.useCallback)(async()=>{if(!(!e||!f||f.agent_status!==`running`||Xt)){U(f.id);try{await KD(e,f.id)}catch(e){U(e=>e===f.id?null:e),X.error(e instanceof Error?e.message:`Unable to interrupt the chat response right now.`)}}},[e,f,Xt]),en=(0,b.useCallback)(async()=>{if(!(!e||!yt||re)){ie(yt.id);try{await qD(e,yt.id),ot(yt.id)}catch(e){X.error(e instanceof Error?e.message:`Unable to delete the chat session right now.`),ie(e=>e===yt.id?null:e)}}},[e,re,ot,yt]);(0,b.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,b.useEffect)(()=>{if(a){if(!e||!qt){a(null);return}a({chatSessionId:f?.id??null,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,submitPrompt:Kt})}},[e,f,Zt,Kt,qt,a,Qt]);let tn=async()=>{if(rt.trim())try{if(!await Gt(rt))return}catch(e){X.error(e instanceof Error?e.message:`Unable to send the chat prompt right now.`)}},nn=e=>{e.key!==`Enter`||e.shiftKey||f?.agent_status===`running`||ee||V||(e.preventDefault(),tn())};(0,b.useEffect)(()=>{let t=t=>{if(t3(t)){if(!e||ee||V)return;t.preventDefault(),Pt(),Vt();return}e3(t)&&(!e||!g&&!f||(t.preventDefault(),Ht($4(Et))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,f,Et,Vt,Pt,Ht,ee,g,V]);let rn=(0,b.useCallback)(async t=>{if(!(!e||!f)){le(t);try{let n=await XD(e,f.id,t);p(n.chatSession),at(n.chatSession),X.success(`Created ${n.created_tickets.length} ticket${n.created_tickets.length===1?``:`s`} from chat.`)}catch(e){X.error(e instanceof Error?e.message:`Unable to create tickets from the chat proposal right now.`)}finally{le(e=>e===t?null:e)}}},[e,f,at]),an=(0,b.useCallback)(e=>{if(!Re.current)return;let t=Re.current.getBoundingClientRect().width,n=q4(e,t);Je.current=n,Be.current&&(Be.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),Be.current.setAttribute(`data-desktop-width`,String(n)))},[]),on=(0,b.useCallback)(()=>{Ue.current?.(),Ue.current=null},[]),sn=(0,b.useCallback)(e=>{let t=Ve.current,n=He.current,r=We.current;if(t!==null){if(Ve.current=null,He.current=null,We.current=!1,we(!1),Ee(!1),on(),e!==null&&typeof ze.current?.hasPointerCapture==`function`&&ze.current.hasPointerCapture(e)&&typeof ze.current.releasePointerCapture==`function`&&ze.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;Oe(Je.current),Se(!0);return}Oe(Je.current)}},[on]),cn=(0,b.useCallback)((e,t)=>{if(Ve.current!==e)return;let n=t-Ke.current,r=qe.current-n;if(He.current===`collapsed`){if(!We.current&&r<V4)return;We.current||(We.current=!0,Ge.current=!0,Ee(!0),we(!0))}an(r)},[an]),ln=(0,b.useCallback)((e,t)=>{if(Ve.current===e){if(t!==null&&(He.current===`inline`||We.current)){let e=t-Ke.current;an(qe.current-e)}sn(e)}},[sn,an]),un=(0,b.useCallback)(e=>{if(!s)return;e.preventDefault(),Ve.current=e.pointerId,He.current=xe?`inline`:`collapsed`,We.current=!1,Ge.current=!1,Ke.current=e.clientX,qe.current=xe?Je.current:0,we(xe),on(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{cn(e.pointerId,e.clientX)},n=e=>{ln(e.pointerId,e.clientX)},r=e=>{ln(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),Ue.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[ln,cn,xe,s,on]),dn=(0,b.useCallback)(e=>{cn(e.pointerId,e.clientX)},[cn]),fn=(0,b.useCallback)(e=>{ln(e.pointerId,e.clientX)},[ln]),pn=(0,b.useCallback)(e=>{ln(e.pointerId,e.clientX)},[ln]),mn=(0,b.useCallback)(e=>{Ve.current===e.pointerId&&sn(e.pointerId)},[sn]),hn=(0,b.useCallback)(()=>{if(Ge.current){Ge.current=!1;return}Se(!0)},[]),gn=(0,b.useCallback)(()=>{Se(!1)},[]),_n=(0,b.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),hn())},[hn]);(0,b.useEffect)(()=>{s||(Ve.current=null,He.current=null,We.current=!1,Ge.current=!1,we(!1),Ee(!1),on())},[s,on]),(0,b.useEffect)(()=>()=>{on()},[on]);let vn=!!u,yn=f?.target_available===!1,bn=yn?f?.target_unavailable_reason??`Target unavailable for this chat session.`:null,xn=g||!!(f&&f.target_available!==!1&&!zt),Sn=!!(t?.memory_enabled&&f&&(ue.length>0||K)),Cn=s&&(g||vn)&&!yn&&!zt,wn=Cn&&!xe&&!Te,Tn=Cn&&(xe||Te),En=`${Nt??`none`}:${Cn?`changes-enabled`:`changes-disabled`}:${Tn?`panel-visible`:`panel-hidden`}`,Dn=f||g?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(m4,{projectId:e,messages:f?xt:[],internalLog:f?.agent_log??null,pendingAgentTitle:bt,streamingResponse:f?.streaming_response??null,isRunning:f?.agent_status===`running`,isLoading:!g&&R,canShowComposer:xn,isExternallyResizing:o||Ce,pendingAgentRevealKey:St,pendingAgentRevealDelayMs:K4,composerFocusNonce:ke,header:(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Dt}),(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[g?null:(0,q.jsx)(_M,{tool:f?.tool,className:`text-[11px]`}),jt?(0,q.jsx)(`p`,{children:jt}):null,Yt?(0,q.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:`Interrupted`}):null,Mt?(0,q.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:Mt}):null]})]}),Sn?(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>me(!0),children:K?`Loading memory...`:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:`Memory suggestions`}),(0,q.jsx)(g4,{children:ue.length})]})}):null]}),zt&&Rt?(0,q.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`div`,{children:Rt}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{It()},children:`Switch back`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,onClick:Pt,children:`New session`})]})]})}):null,yn&&bn?(0,q.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:bn}):null]}),composerControls:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(d_,{value:Et,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,q.jsx)(a3,{label:`Switch to Plan`,modifierLabel:kt,keys:[H4]})},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,q.jsx)(a3,{label:`Switch to Build`,modifierLabel:kt,keys:[H4]})}],disabled:ae,onChange:e=>{Ht(e)}}),Jt?(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:Xt,onClick:()=>{$t()},children:[Xt?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:Xt?`Interrupting...`:`Interrupt`})]}):null]}),composerInlineControls:Ct?(0,q.jsx)(oV,{model:O,variant:A,skills:M,showModelSelector:!0,showSkillsSelector:!0,availableModels:C,availableSkills:E,selectedModel:Tt,onModelChange:e=>{let t=C.find(t=>t.id===e)??null;k(e),j(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:j,onSkillsChange:N,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:V||ee||f?.agent_status===`running`}):wt?(0,q.jsx)(aV,{dataTestId:`chat-model-selector-skeleton`}):null,composerTheme:Et,layoutKey:Nt,scrollLayoutKey:En,followUpPrompt:rt,followUpPlaceholder:Z4(Et),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,q.jsx)(I3,{proposals:e.ticket_proposals,isApplying:ce===e.id,onApply:()=>{rn(e.id)}}):null,isSendingFollowUp:V||ee,followUpDisabledReason:yn?bn??void 0:f?.agent_status===`running`?`Wait for the current chat turn to finish.`:void 0,onFollowUpPromptChange:e=>{st(nt,e)},onFollowUpKeyDown:nn,onFollowUpSubmit:()=>{tn()}})}):vn?(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat session...`}):!I||P?(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,q.jsxs)(zv,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,q.jsxs)(Bv,{children:[(0,q.jsx)(Vv,{children:`No session selected`}),(0,q.jsx)(Hv,{children:`Select a chat session to restore its saved target, or start a new session on the current target.`})]}),(0,q.jsx)(Wv,{children:(0,q.jsx)(Y,{type:`button`,onClick:Pt,disabled:!e||ee||V,children:`Start new session`})})]})}),On=Cn?(0,q.jsx)(`div`,{ref:ze,"aria-label":wn?`Open diff`:`Resize diff panel`,"aria-orientation":wn?void 0:`vertical`,className:J(wn?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Ce&&!wn&&`bg-background`),"data-testid":wn?`collapsed-changes-rail`:void 0,onLostPointerCapture:mn,onPointerCancel:pn,onPointerDown:un,onPointerMove:dn,onPointerUp:fn,onClick:wn?hn:void 0,onKeyDown:wn?_n:void 0,role:wn?`button`:`separator`,tabIndex:wn?0:void 0,children:wn?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,q.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,q.jsx)(x_,{className:`h-3 w-3 shrink-0`})}),(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,q.jsx)(x_,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Diff`})]})]}):(0,q.jsx)(`div`,{className:J(`h-14 w-1.5 rounded-full transition-colors`,Ce?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,kn=pe&&e&&t?.memory_enabled?(0,q.jsx)(Iv,{onClose:()=>me(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,q.jsxs)(zv,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,q.jsxs)(Bv,{className:`border-b border-border/80 pb-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Vv,{children:`Memory suggestions`}),(0,q.jsx)(Hv,{children:`Review pending suggestions from this chat before saving them into project memory.`})]}),(0,q.jsx)(Uv,{children:t})]}),(0,q.jsx)(Wv,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,q.jsx)(C4,{projectId:e,suggestions:ue,emptyState:`No pending memory suggestions for this chat session.`,onSuggestionsChanged:ht})})]}),closeButtonLabel:`Close memory suggestions`}):null,An=yt?(0,q.jsx)(P3,{title:yt.title,isDeleting:re===yt.id,onConfirm:()=>{en()},onCancel:()=>{re!==yt.id&&W(null)}}):null;return(0,q.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,q.jsx)(F3,{activeProject:t,activeSessionId:u,chatModeShortcutModifierLabel:kt,confirmingDeleteSessionId:ne,deletingSessionId:re,finishedBackgroundSessionIds:Ne,isCreatingSession:ee||!e,isDraftOpen:g,isLoadingSessions:P,isOpen:ye,isSendingPrompt:V,sessionGroups:vt,sessions:c,onConfirmDeleteSession:e=>{W(e)},onDraftOpen:Pt,onSessionSelect:e=>{Bt(e)},onToggleOpen:()=>{be(e=>!e)}}),(0,q.jsxs)(`div`,{ref:Re,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,q.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:Dn}),Cn?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(u_,{content:`Open diff`,disabled:!wn,side:`left`,children:On}),Tn?(0,q.jsx)(p4,{projectId:e,chatSessionId:g?null:u,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,onSubmitReviewPrompt:Kt,state:_e,onStateChange:ve,isResizing:Ce,onClose:gn,desktopWidth:De,panelElementRef:Be}):null]}):null]}),kn,An]})},R3=({className:e})=>(0,q.jsx)(uh,{"aria-hidden":`true`,className:e}),z3=({activeProject:e})=>e?(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,q.jsx)(Ab,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),B3=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),V3=()=>({board:B3(),memory:B3(),chat:B3()}),H3=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},U3=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),W3=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,G3=(e,t)=>t?null:W3(e),K3=320,q3=.7,J3=28,Y3=6,X3=(e,t)=>{let n=Math.max(K3,Math.round(t*q3));return Math.max(K3,Math.min(n,Math.round(e)))},Z3=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},Q3=(e,t)=>{if(t.type===`reset`)return V3();if(t.type===`mark-workspace-visible`)return H3(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},$3=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=_2(),r=(0,b.useRef)(new Map);return(0,b.useEffect)(()=>{r.current=new Map},[e]),(0,b.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},e6=({activeProjectId:e,onActivity:t})=>{let[n,r]=(0,b.useState)([]),i=(0,b.useRef)(new Map);return(0,b.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await VD(e,t.signal);if(t.signal.aborted)return;r(n)}catch(e){T(e)}})(),()=>{t.abort()}},[e]),(0,b.useEffect)(()=>{if(!e)return;let t=new AbortController,n=P$(()=>{document.visibilityState===`visible`&&VD(e,t.signal).then(e=>{t.signal.aborted||r(e)}).catch(e=>{T(e)})});return()=>{t.abort(),n()}},[e]),(0,b.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||r(e=>Z3(e,t))},n=t=>{!t||t.project_id!==e||r(e=>e.filter(e=>e.id!==t.id))};return EZ.on(`chat-session:created`,t),EZ.on(`chat-session:updated`,t),EZ.on(`chat-session:deleted`,n),()=>{EZ.off(`chat-session:created`,t),EZ.off(`chat-session:updated`,t),EZ.off(`chat-session:deleted`,n)}},[e]),(0,b.useEffect)(()=>{let r=i.current,a=new Map,o=[],s=!1;for(let e of n){let t=r.get(e.id)??null,n=e.agent_status??null;t===`running`&&n===`done`&&o.push(e),t===`running`&&n===`error`&&(s=!0),a.set(e.id,n)}i.current=a;for(let e of o)e.title&&l2(`Chat response ready`,e.title);o.length>0&&e&&j$(e),t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,n]),null},t6=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:x,onRunStatusChange:S,onWorkspaceActivityChange:C,onWorkspaceActivityEvent:w,refreshKey:T=0})=>{let E=(0,b.useRef)(null),D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(null),A=(0,b.useRef)(!1),j=(0,b.useRef)(!1),M=(0,b.useRef)(0),N=(0,b.useRef)(u),P=(0,b.useRef)(u),F=p===`board`||p===`chat`,I=l!==null,[L,R]=(0,b.useState)(!1),[z,ee]=(0,b.useState)(!1),[B,V]=(0,b.useState)(u),[H,te]=(0,b.useReducer)(Q3,void 0,V3),U=F&&I&&c===`expanded`,ne=F&&I&&c===`inline`,W=F&&I&&c===`hidden`&&!z,re=(ne||z)&&!U,ie=U||re,ae=F&&I&&!U,G=L?B:u,oe=p!==`chat`||!re,se=e=>{let t=O.current,n=k.current,r=A.current;if(t!==null){if(O.current=null,k.current=null,A.current=!1,R(!1),ee(!1),e!==null&&D.current?.hasPointerCapture(e)&&D.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(P.current),v?.();return}y?.(P.current)}},ce=e=>{if(!E.current)return;let t=E.current.getBoundingClientRect().width,n=X3(e,t);P.current=n,V(n)},le=e=>{y&&(W&&d||(e.preventDefault(),O.current=e.pointerId,k.current=W?`collapsed`:`inline`,A.current=!1,j.current=!1,M.current=e.clientX,N.current=W?0:P.current,R(!W),e.currentTarget.setPointerCapture(e.pointerId)))},ue=e=>{if(O.current!==e.pointerId)return;let t=e.clientX-M.current,n=N.current-t;if(k.current===`collapsed`){if(!A.current&&n<Y3)return;A.current||(A.current=!0,j.current=!0,ee(!0),R(!0))}ce(n)},de=e=>{if(O.current===e.pointerId){if(k.current===`inline`||A.current){let t=e.clientX-M.current;ce(N.current-t)}se(e.pointerId)}},K=e=>{O.current===e.pointerId&&se(e.pointerId)},fe=(0,b.useCallback)((e,t)=>{w?.(e,t),te({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[w,p]);(0,b.useEffect)(()=>{te({type:`reset`})},[e]),(0,b.useEffect)(()=>{p!==`memory`&&te({type:`mark-workspace-visible`,workspace:p})},[p]),(0,b.useEffect)(()=>{C?.(H)},[C,H]),(0,b.useEffect)(()=>{L||(P.current=u),!I&&(O.current=null,k.current=null,A.current=!1,j.current=!1,P.current=u)},[I,L,u]);let pe=()=>{if(j.current){j.current=!1;return}d||v?.()};return(0,q.jsx)(g2,{activeProjectId:e,refreshKey:T,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,q.jsxs)(`div`,{ref:E,className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsx)($3,{activeProjectId:e,onActivity:e=>{fe(`board`,e)}}),(0,q.jsx)(e6,{activeProjectId:e,onActivity:e=>{fe(`chat`,e)}}),p===`memory`?(0,q.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,q.jsx)(z3,{activeProject:t})}):(0,q.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,q.jsx)(L3,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:L,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:oe}):(0,q.jsx)(Y2,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:x,onRunStatusChange:S,refreshKey:T})}),[ae?(0,q.jsx)(u_,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!W,side:`left`,children:(0,q.jsx)(`div`,{"aria-label":W?f??`Show preview`:`Resize preview pane`,"aria-orientation":W?void 0:`vertical`,className:W?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${L?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":W?`collapsed-preview-rail`:void 0,onLostPointerCapture:K,onPointerCancel:de,onPointerDown:le,onPointerMove:ue,onPointerUp:de,onClick:W?pe:void 0,onKeyDown:W?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),pe())}:void 0,ref:D,role:W?`button`:`separator`,style:W?{width:`${J3}px`}:void 0,tabIndex:W?d?-1:0:void 0,children:W?(0,q.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,q.jsx)(R3,{className:`h-3 w-3 shrink-0`})}),(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,q.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${L?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,ie?(0,q.jsx)(`div`,{className:U?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:U?void 0:{width:`${G}px`},children:(0,q.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},n6=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,q.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,q.jsx)(kZ,{createSession:()=>pM(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),r6=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,q.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=G3(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,q.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:J(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,q.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,q.jsx)(Q2,{state:a,className:`mt-0`})]})},n)})}),i6=32,a6=5.5,o6=2,s6=24,c6=8,l6=new Map,u6={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},d6=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),f6=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},p6=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=f6(n.getAttribute(`width`)),a=f6(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${i6} ${i6}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${d6(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${i6}"`,`height="${i6}"`,`viewBox="${d6(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},m6=async e=>{if(!e)return null;let t=l6.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return p6(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return p6(atob(e.slice(26)));let t=await fetch(e);return t.ok?p6(await t.text()):null}catch{return null}})();return l6.set(e,n),n},h6=async(e,t)=>{let{fill:n,stroke:r}=u6[e],i=await m6(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${i6}" height="${i6}" viewBox="0 0 ${i6} ${i6}">`,i,`<circle cx="${s6}" cy="${c6}" r="${a6}" fill="${n}" stroke="${r}" stroke-width="${o6}"/>`,`</svg>`].join(``):null},g6=async(e,t)=>{if(!e)return t;let n=await h6(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},_6=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},v6=({defaultHref:e,state:t})=>{let n=_6(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}g6(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},y6=`archon.active-project-id`,b6=`archon.workspace-by-project`,x6=`archon.preview-mode-by-project`,S6=`archon.dismissed-preview-run-context-by-project`,C6=5e3,w6=`archon.preview-pane-width`,T6=`archon.preview-viewport-preset`,E6=`archon.preview-zoom`,D6=480,O6=`responsive`,k6=1,A6={hasMounted:!1,isOpen:!1,isExpanded:!1},j6=`hidden`,M6=(0,b.lazy)(()=>NZ(()=>Promise.resolve().then(()=>V1).then(e=>({default:e.TicketChangesModal})),void 0)),N6=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},P6=e=>{let t=N6(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},F6=e=>{let t=N6(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},I6=e=>{let t=N6(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},L6=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:P6(e.run_setup),runServices:F6(e.run_services),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:I6(e.worktree_sync)}),R6=e=>{let t=e.previewServiceName?.trim()||null,n=e.previewPath?.trim()||``,r=n===``||n===`/`?null:n,i=t||r||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,run_ide:e.runIde||null,preview_service_name:t,preview_path:r,preview_capability_mode:i,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},z6=e=>e?P6(e.run_setup).length>0||F6(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,B6=(e,t,n)=>`${e} ${e===1?t:n}`,V6=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push(B6(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push(B6(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},H6=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push(B6(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push(B6(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push(B6(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},U6=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},W6=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),G6=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),K6=(e,t)=>t?e[t]??A6:A6,q6=(e,t)=>t?e[t]??j6:j6,J6=()=>{let e=window.localStorage.getItem(w6),t=Number(e);return Number.isFinite(t)&&t>=320?t:D6},Y6=()=>{let e=window.localStorage.getItem(T6);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:O6},X6=()=>{let e=Number(window.localStorage.getItem(E6));return Number.isFinite(e)&&e>0?e:k6},Z6=()=>{let e=N6(window.localStorage.getItem(b6));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},Q6=()=>{let e=N6(window.localStorage.getItem(x6));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},$6=()=>{let e=N6(window.localStorage.getItem(S6));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},e8=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,t8=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},n8=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:t8({activeRun:e,project:t})?e:null,r8=`Project root has uncommitted changes. Confirm branch switch to continue.`,i8=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,a8=()=>{let[e,t]=(0,b.useState)(`opencode`),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(()=>window.localStorage.getItem(y6)),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(null),[m,h]=(0,b.useState)({}),[g,_]=(0,b.useState)({}),[v,y]=(0,b.useState)({}),[x,C]=(0,b.useState)(null),[w,E]=(0,b.useState)({}),[D,O]=(0,b.useState)(Q6),[k,j]=(0,b.useState)($6),[M,N]=(0,b.useState)(J6),[P,F]=(0,b.useState)(Y6),[I,L]=(0,b.useState)(X6),[R,z]=(0,b.useState)(null),[ee,B]=(0,b.useState)([]),[V,H]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(``),[G,oe]=(0,b.useState)(``),[se,ce]=(0,b.useState)(!1),[le,ue]=(0,b.useState)(null),[de,K]=(0,b.useState)(null),[fe,pe]=(0,b.useState)({}),[me,he]=(0,b.useState)(Z6),[ge,_e]=(0,b.useState)(()=>V3()),[ve,ye]=(0,b.useState)(()=>B3()),[be,xe]=(0,b.useState)(0),[Se,Ce]=(0,b.useState)(null),[we,Te]=(0,b.useState)(null),[De,Oe]=(0,b.useState)({}),[ke,Ae]=(0,b.useState)({}),[je,Me]=(0,b.useState)({}),[Ne,We]=(0,b.useState)({}),[qe,Je]=(0,b.useState)(!1),[Xe,Ze]=(0,b.useState)(null),Qe=(0,b.useRef)(null),$e=(0,b.useRef)(null),et=(0,b.useRef)(null),tt=i.find(e=>e.id===o)??null,nt=!!tt?.memory_enabled,rt=o?me[o]??`board`:`board`,it=rt===`memory`?nt?`memory`:`board`:rt,at=tt!==null,ot=z6(tt),st=!!tt?.run_ide?.trim(),ct=o!==null&&u===o,lt=o!==null&&(!ot||f===o),ut=o?m[o]??G6(o):null,dt=o?g[o]??null:null,ft=o?!!v[o]:!1,pt=o?De[o]??[]:[],mt=o?!!ke[o]:!1,ht=o?je[o]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},yt=o?!!Ne[o]:!1,bt=o?w[o]??null:null,xt=q6(D,o),St=xt!==`hidden`,Ct=n8({activeRun:c,project:tt,projectId:o}),wt=Ct?.context_key??null,Tt=o?k[o]??null:null,Et=e8(tt),Dt=wt===R,Ot=(0,b.useMemo)(()=>U3(ge),[ge]),kt=(0,b.useMemo)(()=>W3({hasRunning:Ot.hasRunning,hasFinishedUnseen:ve.hasFinishedUnseen,hasErrorUnseen:ve.hasErrorUnseen}),[Ot.hasRunning,ve.hasErrorUnseen,ve.hasFinishedUnseen]);(0,b.useEffect)(()=>{Ce(null),Te(null),$e.current=null},[o]),(0,b.useEffect)(()=>{Te(null)},[it]),(0,b.useEffect)(()=>{St||($e.current=null)},[St]),(0,b.useEffect)(()=>{let e=Se?.target?.kind??null;if(e===`ticket`||e===`bundle`){$e.current=Se;return}(it===`board`||!St)&&($e.current=Se)},[St,Se,it]),(0,b.useEffect)(()=>{_e(V3())},[o]),(0,b.useEffect)(()=>{ye(B3())},[o]);let At=(0,b.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||ye(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,b.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&ye(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,b.useEffect)(()=>(Qe.current===null&&(Qe.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),v6({defaultHref:Qe.current,state:kt}),()=>{v6({defaultHref:Qe.current,state:null})}),[kt]);let jt=(0,b.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await Ge(e,r,{refreshRemote:n});if(r?.aborted)return;h(n=>({...n,[e]:W6(e,t)}))}catch(t){if(T(t))return;if(t instanceof S&&t.status===404){h(t=>({...t,[e]:{...G6(e),status:`unknown`}}));return}h(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),Mt=(0,b.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;y(t=>({...t,[e]:!0}));try{let t=await Ye(e,{refreshRemote:n,signal:r});if(r?.aborted)return;_(n=>({...n,[e]:t}))}catch(t){if(T(t))return;t instanceof S&&t.status===404&&_(t=>({...t,[e]:null}))}finally{r?.aborted||y(t=>({...t,[e]:!1}))}},[]);(0,b.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await _t(e.signal);t(n)}catch(e){T(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,b.useEffect)(()=>{if(!se||i.length>0&&le===null||V)return;let e=new AbortController;return(async()=>{try{B(await gt(`opencode`,e.signal))}catch(e){T(e)||B(e=>e)}finally{e.signal.aborted||H(!0)}})(),()=>{e.abort()}},[V,le,i.length,se]),(0,b.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(y6);return(async()=>{try{let n=await Pe(e.signal);if(e.signal.aborted)return;a(n);let r=n[0]?.id??null;s(n.some(e=>e.id===t)?t:r)}catch(e){T(e)||a([])}finally{e.signal.aborted||ce(!0)}})(),()=>{e.abort()}},[]),(0,b.useEffect)(()=>{if(se){if(o){window.localStorage.setItem(y6,o);return}window.localStorage.removeItem(y6)}},[o,se]),(0,b.useEffect)(()=>{window.localStorage.setItem(b6,JSON.stringify(me))},[me]),(0,b.useEffect)(()=>{window.localStorage.setItem(x6,JSON.stringify(D))},[D]),(0,b.useEffect)(()=>{window.localStorage.setItem(S6,JSON.stringify(k))},[k]),(0,b.useEffect)(()=>{h(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),_(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),y(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,b.useEffect)(()=>{pe(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,b.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Oe(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Ae(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Me(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),We(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,b.useEffect)(()=>{E(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),O(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),j(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,b.useEffect)(()=>{se&&he(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,se]),(0,b.useEffect)(()=>{if(!se||!o||!at)return;let e=!1,t=null,n=null;h(e=>e[o]?e:{...e,[o]:G6(o)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([jt(o,{refreshRemote:r,signal:a.signal}),Mt(o,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=P$(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[o,at,se,jt,Mt]),(0,b.useEffect)(()=>{if(o)return M$(e=>{e===o&&(jt(e),Mt(e))})},[o,jt,Mt]);let Nt=(0,b.useCallback)(async e=>{let t=o;if(!t){l(null),p(null);return}try{let n=await ne(t,e);e?.aborted||(l(n.active_run),p(t))}catch(e){T(e)}},[o]),Pt=(0,b.useCallback)(async e=>{let t=o;if(t)try{let n=await U(t,e);e?.aborted||E(e=>({...e,[t]:n}))}catch(e){T(e)}},[o]);(0,b.useEffect)(()=>{if(!se)return;if(!ot){l(null),p(null);return}if(!ct)return;let e=new AbortController;p(null),Nt(e.signal);let t=window.setInterval(()=>{Nt(e.signal)},C6),n=P$(()=>{document.visibilityState===`visible`&&Nt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[ct,ot,se,Nt]),(0,b.useEffect)(()=>{if(!se||!o||!ct||!Et)return;let e=new AbortController;Pt(e.signal);let t=window.setInterval(()=>{Pt(e.signal)},C6),n=P$(()=>{document.visibilityState===`visible`&&Pt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[o,ct,Et,se,Pt]),(0,b.useEffect)(()=>{window.localStorage.setItem(w6,String(M))},[M]),(0,b.useEffect)(()=>{window.localStorage.setItem(T6,P)},[P]),(0,b.useEffect)(()=>{window.localStorage.setItem(E6,String(I))},[I]),(0,b.useEffect)(()=>{o&&wt&&j(e=>{let t=e[o]??null;return!t||t===wt?e:{...e,[o]:null}})},[o,wt]),(0,b.useEffect)(()=>{!o||!Ct||!e8(tt)||Tt!==Ct.context_key&&O(e=>q6(e,o)===`hidden`?{...e,[o]:`inline`}:e)},[tt,o,Tt,Ct]);let Ft=async e=>{try{t((await vt(e)).tool)}catch{}},It=(0,b.useCallback)(e=>{a(t=>t.map(t=>t.id===e.id?e:t))},[]),Lt=(0,b.useCallback)((e,t)=>{Oe(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Rt=(0,b.useCallback)(async e=>{We(t=>({...t,[e]:!0}));try{let t=await ze(e);Me(n=>({...n,[e]:t}))}catch(e){X.error(e instanceof S?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{We(t=>({...t,[e]:!1}))}},[]),zt=async e=>{try{let t=await Fe(R6(e));return a(e=>[...e,t]),s(t.id),ue(null),null}catch(e){return e instanceof S?e.message:`Unable to create the project right now.`}},Bt=async e=>{if(!tt)return`Select a project before editing settings.`;try{let t=await Ie(tt.id,R6(e));return a(e=>e.map(e=>e.id===t.id?t:e)),xe(e=>e+1),ue(null),null}catch(e){return e instanceof S?e.message:`Unable to update the project right now.`}},Vt=async()=>{if(!tt)return`Select a project before deleting it.`;try{await Le(tt.id);let e=i.filter(e=>e.id!==tt.id);return a(e),s(e[0]?.id??null),ue(null),null}catch(e){return e instanceof S?e.message:`Unable to delete the project right now.`}},Ht=(0,b.useCallback)(e=>{a(t=>t.map(t=>U6(t,e)))},[]),Ut=(0,b.useCallback)((e,t)=>{e&&Oe(n=>({...n,[e]:t}))},[]),Wt=(0,b.useCallback)((e,t)=>{e&&Ae(n=>({...n,[e]:t}))},[]),Gt=async(e,t,n)=>await Ve({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Kt=async()=>(await He()).repo_path,qt=(0,b.useCallback)(async e=>{let t=await Ue({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error}},[]),Jt=(0,b.useCallback)((e,t)=>{O(t=>({...t,[e]:`hidden`})),t&&j(n=>({...n,[e]:t}))},[]),Yt=(0,b.useCallback)(()=>{o&&Jt(o,wt)},[o,Jt,wt]),Xt=(0,b.useCallback)(e=>{o&&(O(e=>({...e,[o]:`hidden`})),e&&l(t=>t?.context_key===e?null:t))},[o]),Zt=(0,b.useCallback)(async()=>{if(!Ct||R===Ct.context_key)return;let{context_key:e}=Ct;z(e);try{Ct.kind===`ticket`?await Ee(Ct.ticket_id,Ct.project_id):l((await re(Ct.project_id)).active_run),Xt(e),await Promise.all([Nt(),Pt()])}catch(e){X.error(e instanceof S?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{z(t=>t===e?null:t)}},[Xt,Ct,Pt,Nt,R]),Qt=(0,b.useCallback)(e=>{!e||!o||Rt(o)},[o,Rt]),$t=(0,b.useCallback)(e=>new Promise(t=>{et.current=t,Ze(e)}),[]),en=(0,b.useCallback)(e=>{let t=et.current;et.current=null,Ze(null),t?.(e)},[]),tn=(0,b.useCallback)(async e=>{if(!tt||!o)throw Error(`Select a project first.`);if(!i8({activeProject:tt,activeProjectBranchState:ut,nextTarget:e})||!c||c.kind!==`project`||c.project_id!==tt.id)return!0;if(!await $t({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=c.context_key,t=await re(tt.id);return Xt(e),l(t.active_run),await Pt(),!0}catch(e){return X.error(e instanceof S?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[tt,ut,o,c,Xt,Pt,$t]),nn=(0,b.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);return await tn({kind:`bundle`,bundleId:e})?(It(await Be(o,{kind:`bundle`,bundle_id:e})),_(e=>({...e,[o]:null})),await Promise.all([jt(o),Mt(o)]),!0):!1},[o,tn,jt,Mt,It]),rn=(0,b.useCallback)(async(e,t={})=>{if(!o)throw Error(`Select a project first.`);if(!await tn({kind:`repo_root`,branch:e}))return!1;let n=n=>Be(o,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof S&&e.status===409&&e.message===r8){if(!await $t({title:`Switch repo root branch?`,description:`${r8}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return It(r),_(e=>({...e,[o]:null})),await Promise.all([jt(o),Mt(o),Rt(o)]),!0},[o,tn,Rt,jt,Mt,It,$t]),an=(0,b.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await nn(e.target_bundle_id):!1:await rn(e.target_branch_snapshot??null,{createBranch:!1}),[nn,rn]),on=(0,b.useCallback)(()=>{Je(!0)},[]),sn=(0,b.useCallback)(()=>{Je(!1)},[]),cn=(0,b.useCallback)(e=>{if(e){nn(e);return}rn(null)},[nn,rn]),ln=(0,b.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);let t=await A(o,{name:e,prepare:!0});return Lt(o,t),xe(e=>e+1),t},[o,Lt]),un=(0,b.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);await te(o,e),Oe(t=>({...t,[o]:(t[o]??[]).filter(t=>t.id!==e)})),xe(e=>e+1)},[o]),dn=(0,b.useCallback)(async()=>{if(!tt)return;let e=tt.active_target_kind??`repo_root`,t=tt.active_target_bundle_id??null,n=c?.kind===`project`&&c.project_id===tt.id&&(c.target_kind??`repo_root`)===e&&((c.target_kind??`repo_root`)!==`bundle`||c.target_bundle_id===t),r=n?c?.context_key??null:null,i=!n&&e8(tt)&&xt===`hidden`;i&&(O(e=>({...e,[tt.id]:`inline`})),j(e=>({...e,[tt.id]:null})));try{let e=n?await re(tt.id):await W(tt.id);n&&Xt(r),l(e.active_run),Pt()}catch(e){i&&O(e=>({...e,[tt.id]:`hidden`})),X.error(e instanceof S?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[xt,tt,c,Xt,Pt]),fn=(0,b.useCallback)(async()=>{if(!(!tt||!st))try{await Re(tt.id)}catch(e){X.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[tt,st]),pn=(0,b.useCallback)(async()=>{if(tt){C(tt.id);try{let e=await Ke(tt.id);_(t=>({...t,[tt.id]:e})),tt.active_target_kind!==`bundle`&&await jt(tt.id),j$(tt.id),X.success(e.behind===0?`Project branch synced.`:`Project branch updated.`,{id:`app-project-pull-success`})}catch(e){X.error(e instanceof S?e.message:`Unable to sync the current branch right now.`,{id:`app-project-pull-error`})}finally{C(e=>e===tt.id?null:e)}}},[tt,jt]),mn=(0,b.useCallback)(()=>{tt&&K({projectId:tt.id,title:tt.name})},[tt]),hn=(0,b.useCallback)(()=>{if(!de)return;let{projectId:e}=de;K(null),jt(e),Mt(e)},[jt,Mt,de]),gn=K6(fe,o),_n=it===`chat`?we:null,vn=$e.current,yn=vn?.target?.kind??null,bn=it===`chat`?yn===`ticket`||yn===`bundle`?{target:vn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,submitPrompt:null}:_n?{target:{kind:`chat_session`,id:_n.chatSessionId??`draft:${o}`},canSelect:_n.canSubmitReviewPrompt,disabledReason:_n.canSubmitReviewPrompt?null:_n.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,submitPrompt:_n.canSubmitReviewPrompt?_n.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:Se,xn=_n?.canSubmitReviewPrompt??!1,Sn=it===`chat`?_n?_n.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,Cn=(0,b.useCallback)(()=>{o&&pe(e=>{let t=e[o]??A6;return{...e,[o]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[o]),wn=(0,b.useCallback)(e=>{pe(t=>{let n=t[e]??A6;return!n.hasMounted||!n.isOpen?t:{...t,[e]:A6}})},[]),Tn=(0,b.useCallback)(e=>{pe(t=>{let n=t[e]??A6;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),En=(0,b.useCallback)(()=>{o&&pe(e=>{let t=e[o]??A6;return t.isOpen?e:{...e,[o]:{hasMounted:!0,isOpen:!0,isExpanded:t.isExpanded}}})},[o]),Dn=(0,b.useCallback)(()=>{ue(`create`)},[]),On=(0,b.useCallback)(()=>{if(o){if(St){Yt();return}O(e=>({...e,[o]:`inline`})),j(e=>({...e,[o]:null}))}},[o,Yt,St]),kn=(0,b.useCallback)(()=>{o&&O(e=>{let t=q6(e,o);return{...e,[o]:t===`expanded`?`inline`:`expanded`}})},[o]),An=tt?tt.preview_service_name?.trim()?tt.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:bt?.state===`unsupported`?bt.message??`Preview is unavailable for this project.`:St?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,jn=!tt||!tt.preview_service_name?.trim()||tt.preview_capability_mode===`force_disabled`||bt?.state===`unsupported`,Mn=tt&&tt.preview_service_name?.trim()?(0,q.jsx)(BD,{project:tt,mode:xt===`expanded`?`expanded`:`inline`,status:bt,viewportPreset:P,zoom:I,activeRun:Ct,reviewCapability:bn,isStoppingActiveRun:Dt,onHide:Yt,onStopActiveRun:()=>{Zt()},onToggleExpanded:kn,onViewportPresetChange:F,onZoomChange:L}):null;return Q0([{key:`t`,onKeyDown:En}],{isBlocked:Z0}),(0,q.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,q.jsx)(Ov,{}),i.length>0&&(0,q.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,q.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,q.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,q.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,q.jsx)(g_,{activeProjectId:o,projects:i,onEditProject:()=>ue(`edit`),onProjectChange:s})})}),o&&(0,q.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,q.jsx)(r6,{activeWorkspace:it,activityByWorkspace:ge,memoryEnabled:nt,onWorkspaceChange:e=>{o&&(he(t=>({...t,[o]:e})),_e(t=>H3(t,e)))}})}),(0,q.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,q.jsx)(Dv,{activeTool:e,onCreateProject:Dn,onToolChange:Ft})})]})}),se?i.length===0?(0,q.jsx)(p_,{activeTool:e,availableHelperModels:ee,helperModel:ie,helperVariant:G,isHelperModelsLoaded:V,isToolLoaded:n,onCreateProject:Dn,onHelperModelChange:e=>{ae(e),oe(``)},onHelperVariantChange:oe,onToolChange:Ft}):(0,q.jsx)(t6,{activeProjectId:o,activeProject:tt,activeProjectBranchState:ut,activeRun:c,activeTool:e,onRestoreChatSessionTarget:an,onChatReviewCapabilityChange:Te,isPreviewButtonDisabled:jn,onPreviewReviewCapabilityChange:Ce,onPreviewToggle:On,onRunStopped:Xt,onWorkspaceActivityChange:_e,onWorkspaceActivityEvent:At,previewDisplayMode:xt,previewPane:Mn,previewPaneWidth:M,previewButtonTitle:An,visibleWorkspace:it,refreshKey:be,onBoardLoadedProjectIdChange:d,onBundlesChange:Ut,onBundlesLoadingChange:Wt,onPreviewPaneWidthChange:N,onProjectUsageChange:Ht,onRunStatusChange:()=>{Nt(),Pt()}},o??`no-project`):(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,q.jsx)(Tv,{activeProject:tt,activeRun:c,branchState:ut,targetGitStatus:dt,isBoardLoadedForActiveProject:ct,isProjectSyncing:x===o,isProjectIdeAvailable:st,isProjectRunAvailable:ot,isRunStatusLoadedForActiveProject:lt,isTerminalOpen:gn.isOpen,targetBundles:pt,targetBranchSuggestions:ht,isTargetBundleLoading:mt,isTargetSelectorLoading:yt,isTargetGitStatusLoading:ft,onProjectIdeOpen:()=>{fn()},onProjectPull:()=>{pn()},onProjectRunToggle:()=>{dn()},onProjectChangesOpen:mn,onTerminalToggle:Cn,onTargetSelectorOpenChange:Qt,onSelectBundleTarget:nn,onSelectRepoRootTarget:rn,onManageBundles:on}),qe&&tt&&(0,q.jsx)(Xv,{bundles:pt,selectedBundleId:tt.active_target_kind===`bundle`?tt.active_target_bundle_id??null:null,activeTargetBundleId:tt.active_target_kind===`bundle`?tt.active_target_bundle_id??null:null,onSelectBundle:cn,onCreateBundle:ln,onDeleteBundle:un,onClose:sn}),Xe&&(0,q.jsx)(Lv,{title:Xe.title,description:Xe.description,confirmLabel:Xe.confirmLabel,cancelLabel:Xe.cancelLabel,confirmVariant:Xe.confirmVariant,onConfirm:()=>en(!0),onCancel:()=>en(!1)}),i.map(e=>{let t=K6(fe,e.id);return t.hasMounted?(0,q.jsx)(n6,{project:e,isExpanded:t.isExpanded,isVisible:e.id===o&&t.isOpen,onClose:()=>wn(e.id),onToggleExpanded:()=>Tn(e.id)},e.id):null}),le&&(0,q.jsx)(Yb,{mode:le,projectId:le===`edit`&&tt?tt.id:null,availableHelperModels:ee,isLoadingHelperModels:!V,isAutoConfigReady:n,initialValues:le===`edit`&&tt?L6(tt):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:G,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==tt?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:le===`edit`&&tt?tt.repo_path_locked:!1,repoPathLockedMessage:le===`edit`&&tt?V6(tt):null,deleteBlockedMessage:le===`edit`&&tt?H6(tt,i):null,onDelete:le===`edit`?Vt:void 0,onAutoConfig:Gt,onBrowseRepoPath:Kt,onValidateRepoPath:qt,onClose:()=>ue(null),onSubmit:le===`edit`?Bt:zt}),de&&de.projectId===o&&(0,q.jsx)(b.Suspense,{fallback:null,children:(0,q.jsx)(M6,{scope:`project_root`,projectId:de.projectId,title:de.title,onSubmitReviewPrompt:_n?.submitPrompt,canSubmitReviewPrompt:xn,reviewSubmitDisabledReason:Sn??void 0,canAddReviewComments:xn,canModifyChanges:!0,onClose:hn})})]})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,y.createRoot)(document.getElementById(`root`)).render((0,q.jsx)(a8,{}));
176
+ `).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),b4=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},x4=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=a?`Save as new decision`:`Accept`,s=e.kind===`decision`?e.decision:e.instruction;return(0,q.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,q.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,q.jsxs)(g4,{children:[`Suggested `,e.kind]}),a?(0,q.jsx)(g4,{tone:`muted`,children:`Possible duplicate`}):null]}),(0,q.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:`Dismiss`})]})]})})},S4=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?`Save as new decision`:`Accept as ${e.kind}`;return(0,q.jsx)(vg,{open:t,onOpenChange:a,children:(0,q.jsxs)(Sg,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(Cg,{children:[(0,q.jsx)(Tg,{children:e.title}),(0,q.jsx)(Eg,{children:`Review this suggestion before saving it into project memory.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,q.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,q.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,q.jsxs)(`p`,{children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Suggestion title`}),(0,q.jsx)(`input`,{"aria-label":`Suggestion title`,value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Scope`}),(0,q.jsx)(`input`,{"aria-label":`Scope`,value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:i.kind===`decision`?`Decision`:`Instruction`}),(0,q.jsx)(`textarea`,{"aria-label":i.kind===`decision`?`Decision`:`Instruction`,value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Rationale`}),(0,q.jsx)(`textarea`,{"aria-label":`Rationale`,value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,q.jsx)(`span`,{children:`Implications (one per line)`}),(0,q.jsx)(`textarea`,{"aria-label":`Implications`,value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Stages (comma or newline separated)`}),(0,q.jsx)(`textarea`,{"aria-label":`Stages`,value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:`Priority`}),(0,q.jsxs)(`select`,{"aria-label":`Priority`,value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,q.jsx)(`option`,{value:`low`,children:`Low`}),(0,q.jsx)(`option`,{value:`normal`,children:`Normal`}),(0,q.jsx)(`option`,{value:`high`,children:`High`})]})]})]})]}):(0,q.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?`Decision`:`Instruction`}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Rationale`}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Implications`}),(0,q.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Stages`}),(0,q.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.join(`, `)||`None specified`})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Priority`}),(0,q.jsx)(`p`,{className:`text-muted-foreground`,children:e.priority})]})]}):null]})]}),(0,q.jsxs)(wg,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:`Cancel edits`}):(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:`Edit`}),(0,q.jsx)(Y,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:`Dismiss`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,q.jsx)(Y,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}):null,(0,q.jsx)(Y,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},C4=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(_4),[f,p]=(0,b.useState)(null);(0,b.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(_4())},g=e=>{s(e.id),l(e.id),d(v4(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},v=e=>{e||(s(null),c&&h())},y=async(t,n)=>{let r=c===t.id?u:v4(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:y4(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:b4(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let n=t.duplicate_match?.decision;if(!n)throw Error(`No existing decision is available for this suggestion.`);await pt(e,t.id,n.id,i)}else await dt(e,t.id,i);h(),s(null),a?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}},x=async t=>{p(t.id);try{await ft(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){X.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,q.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,q.jsxs)(`div`,{children:[n?(0,q.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,q.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,q.jsx)(x4,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>y(e,!1),onDismiss:x},e.id))}):i?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,q.jsx)(S4,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?v4(m):u,onOpenChange:v,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:y,onDismiss:x})]})},w4=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),T4=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],E4=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},D4=e=>e.activity_at??e.last_user_message_at??e.created_at,O4=(e,t)=>{let n=D4(e),r=D4(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},k4=e=>[...e].sort(O4),A4=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),j4=(e,t=new Date)=>{let n=E4(D4(e));if(!n)return`older`;let r=A4(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},M4=(e,t=new Date)=>{let n=new Map;for(let r of k4(e)){let e=j4(r,t);n.set(e,[...n.get(e)??[],r])}return T4.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},N4=1500,P4=`archon.chat-run-config`,F4=`archon.chat-changes-panel-layout`,I4=`archon.chat-session-list-layout`,L4=`archon.chat-draft`,R4=512,z4=360,B4=.6,V4=6,H4=`.`,U4=`/`,W4=`Slash`,G4=`NumpadDivide`,K4=600,q4=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):R4;if(!Number.isFinite(t))return Math.max(z4,n);let r=Math.max(z4,Math.round(t*B4));return Math.max(z4,Math.min(r,n))},J4=e=>e===`claude`?`Claude`:`OpenCode`,Y4=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,X4=e=>e===`plan`?`Plan`:`Build`,Z4=e=>e===`plan`?`Ask Archon to scope, sequence, or reason through project work`:`Ask Archon to build, change, or verify something in this project`,Q4=e=>`${e} pending memory suggestion${e===1?``:`s`}`,$4=e=>e===`plan`?`build`:`plan`,e3=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===H4,t3=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===U4||e.code===W4||e.code===G4),n3=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},r3=()=>n3()?`CMD`:`CTRL`,i3=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,q.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,q.jsx)(__,{"aria-hidden":n,children:e}),t.map(e=>(0,q.jsxs)(`span`,{className:`contents`,children:[(0,q.jsx)(`span`,{children:`+`}),(0,q.jsx)(__,{"aria-hidden":n,children:e})]},e))]}),a3=({label:e,modifierLabel:t,keys:n})=>(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{children:e}),(0,q.jsx)(i3,{modifierLabel:t,keys:n,ariaHidden:!0})]}),o3=({modelLabel:e,tool:t})=>e??J4(t),s3=()=>`You`,c3=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},l3=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),u3=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,d3=({projectId:e,tool:t})=>`${P4}:${e}:${t}`,f3=({projectId:e,tool:t,chatSessionId:n})=>n?`${L4}:${e}:session:${n}`:`${L4}:${e}:draft:${t}`,p3=e=>`${F4}:${e}`,m3=e=>`${I4}:${e}`,h3=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},g3=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},_3=e=>{if(!e)return{isOpen:!0,width:R4};try{let t=window.localStorage.getItem(p3(e));if(!t)return{isOpen:!0,width:R4};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(z4,Math.round(n.width)):R4;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:R4}}},v3=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(m3(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},y3=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(p3(e),JSON.stringify({isOpen:t,width:n}))}catch{}},b3=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(m3(e),JSON.stringify({isOpen:t}))}catch{}},x3=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem(d3({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},S3=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem(d3({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},C3=({projectId:e,tool:t})=>x3({projectId:e,tool:t})?.mode??`plan`,w3=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=x3({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},T3=e=>e&&e.replace(/\s+/g,` `).trim()||null,E3=e=>{let t=T3(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return T3(n)},D3=({chatSessionId:e,instruction:t,createdAt:n})=>({id:`optimistic:${e}:${n}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,created_at:n}),O3=({session:e,instruction:t,createdAt:n})=>({...e,messages:[...e.messages??[],D3({chatSessionId:e.id,instruction:t,createdAt:n})],activity_at:n,last_user_message_at:n,updated_at:n}),k3=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),A3=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:t?!n.target_branch_snapshot||t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot:!0,j3=e=>e.target_kind===`bundle`?e.target_label_snapshot||`Bundle target`:null,M3=e=>e.target_kind===`bundle`?j3(e)||`Bundle target`:e.target_branch_snapshot?`Repo root (${e.target_branch_snapshot})`:`Repo root`,N3=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?`selected bundle target`:t?.branch?`Repo root (${t.branch})`:`Repo root`:`current target`,P3=({title:e,isDeleting:t,onConfirm:n,onCancel:r})=>(0,q.jsxs)(Iv,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete chat session`}),(0,q.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`This permanently removes the transcript history for this chat session.`}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(Y,{type:`button`,variant:`ghost`,onClick:r,disabled:t,children:`Cancel`}),(0,q.jsx)(Y,{type:`button`,variant:`destructive`,onClick:n,disabled:t,children:t?`Deleting...`:`Delete`})]})]}),F3=({activeProject:e,activeSessionId:t,chatModeShortcutModifierLabel:n,confirmingDeleteSessionId:r,deletingSessionId:i,finishedBackgroundSessionIds:a,isCreatingSession:o,isDraftOpen:s,isLoadingSessions:c,isOpen:l,isSendingPrompt:u,sessionGroups:d,sessions:f,onConfirmDeleteSession:p,onDraftOpen:m,onSessionSelect:h,onToggleOpen:g})=>(0,q.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":l?`expanded`:`collapsed`,"aria-label":`Chat sessions sidebar`,className:J(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,l?`w-72`:`w-16`),children:l?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3`,children:[(0,q.jsxs)(Y,{type:`button`,size:`sm`,className:`gap-2`,onClick:m,disabled:o||u,children:[(0,q.jsx)(Ev,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:`New session`}),(0,q.jsx)(i3,{modifierLabel:n,keys:[U4],ariaHidden:!0})]}),(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Collapse sessions panel`,"aria-expanded":l,className:`ml-auto`,onClick:g,children:(0,q.jsx)(X2,{className:`h-4 w-4`})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:c&&f.length===0?(0,q.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):f.length===0?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:`No chat sessions yet.`}):(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:d.map(n=>(0,q.jsxs)(`section`,{"aria-label":n.label,className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:n.label}),n.sessions.map(n=>{let o=!s&&n.id===t,c=E3(n),l=j3(n),u=n.agent_status===`running`?`Wait for the current chat response to finish before deleting this session.`:null,d=r===n.id||i===n.id,f=!!u||i===n.id,m=n.agent_status===`running`?`running`:n.agent_status===`stopped`?`interrupted`:a.has(n.id)?`finished`:null,g=m===`interrupted`?null:m;return(0,q.jsxs)(`div`,{className:J(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":[n.title,X4(n.mode),J4(n.tool),e?.memory_enabled&&n.pending_memory_suggestion_count>0?Q4(n.pending_memory_suggestion_count):null,m===`running`?`Running`:m===`interrupted`?`Interrupted`:m===`finished`?`Finished`:null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{h(n)},children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l?(0,q.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:l}):null,(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.title}),e?.memory_enabled&&n.pending_memory_suggestion_count>0?(0,q.jsx)(g4,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":Q4(n.pending_memory_suggestion_count),title:Q4(n.pending_memory_suggestion_count),children:n.pending_memory_suggestion_count}):null]}),c?(0,q.jsx)(`div`,{className:J(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:c}):null,n.target_available===!1?(0,q.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:n.target_unavailable_reason??`Target unavailable`}):null]}),(0,q.jsx)(Q2,{state:g,className:`mt-1`})]})}),(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Delete chat session`,className:J(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,f&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||d)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,u&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:u??`Delete ${n.title}`,disabled:f,onClick:e=>{e.stopPropagation(),p(n.id)},children:(0,q.jsx)(qv,{className:`h-4 w-4`})})]},n.id)})]},n.key))})})]}):(0,q.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,q.jsx)(u_,{content:(0,q.jsx)(a3,{label:`Start new session`,modifierLabel:n,keys:[U4]}),side:`right`,children:(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,"aria-label":`New session`,className:`h-9 w-9`,onClick:m,disabled:o||u,children:(0,q.jsx)(Ev,{className:`h-4 w-4`})})}),(0,q.jsx)(Y,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Open sessions panel`,"aria-expanded":l,className:`h-9 w-9`,onClick:g,children:(0,q.jsx)(Z2,{className:`h-4 w-4`})})]})}),I3=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,q.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:`Tickets created`}),(0,q.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Created `,e.created_tickets.length,` ticket`,e.created_tickets.length===1?``:`s`,` from this proposal.`]}),e.created_tickets.length>0?(0,q.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,q.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,q.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:`Proposed tickets`}),(0,q.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`Review these tickets before adding them to the board.`}),(0,q.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,q.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,q.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,q.jsxs)(`div`,{className:`mt-3 text-muted-foreground`,children:[`Dependencies: `,e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)]}):null,(0,q.jsx)(`div`,{className:`mt-3`,children:(0,q.jsx)(Y,{type:`button`,size:`sm`,onClick:n,disabled:t,children:t?`Creating tickets...`:`Create tickets`})})]}),L3=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let[c,l]=(0,b.useState)([]),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(null),[m,h]=(0,b.useState)(null),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(()=>C3({projectId:e,tool:r})),[x,S]=(0,b.useState)({}),[C,w]=(0,b.useState)([]),[E,D]=(0,b.useState)([]),[O,k]=(0,b.useState)(``),[A,j]=(0,b.useState)(``),[M,N]=(0,b.useState)([]),[P,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(!1),[R,z]=(0,b.useState)(!1),[ee,B]=(0,b.useState)(!1),[V,H]=(0,b.useState)(!1),[te,U]=(0,b.useState)(null),[ne,W]=(0,b.useState)(null),[re,ie]=(0,b.useState)(null),[ae,G]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(!1),[ce,le]=(0,b.useState)(null),[ue,de]=(0,b.useState)([]),[K,fe]=(0,b.useState)(!1),[pe,me]=(0,b.useState)(!1),[he,ge]=(0,b.useState)(0),[_e,ve]=(0,b.useState)(w4),[ye,be]=(0,b.useState)(()=>v3(e).isOpen),[xe,Se]=(0,b.useState)(()=>_3(e).isOpen),[Ce,we]=(0,b.useState)(!1),[Te,Ee]=(0,b.useState)(!1),[De,Oe]=(0,b.useState)(()=>_3(e).width),[ke,Ae]=(0,b.useState)(0),[je,Me]=(0,b.useState)(null),[Ne,Pe]=(0,b.useState)(()=>new Set),Fe=(0,b.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Ie=(0,b.useRef)(!1),Le=(0,b.useRef)(null),Re=(0,b.useRef)(null),ze=(0,b.useRef)(null),Be=(0,b.useRef)(null),Ve=(0,b.useRef)(null),He=(0,b.useRef)(null),Ue=(0,b.useRef)(null),We=(0,b.useRef)(!1),Ge=(0,b.useRef)(!1),Ke=(0,b.useRef)(0),qe=(0,b.useRef)(R4),Je=(0,b.useRef)(R4),Ye=(0,b.useRef)(!1),Xe=(0,b.useRef)(0),Ze=(0,b.useRef)({id:null,status:null}),Qe=(0,b.useRef)(new Map),$e=(0,b.useRef)({}),et=(0,b.useRef)(new Set),tt=(0,b.useRef)(!1),nt=e?f3({projectId:e,tool:g?r:f?.tool??r,chatSessionId:g?null:u}):null,rt=nt?x[nt]??``:``,it=g?r:f?.tool??r;(0,b.useEffect)(()=>{Ie.current=g},[g]),(0,b.useEffect)(()=>{$e.current=x},[x]),(0,b.useEffect)(()=>{if(!nt||et.current.has(nt))return;et.current.add(nt);let e=h3(nt);e&&S(t=>Object.prototype.hasOwnProperty.call(t,nt)?t:{...t,[nt]:e})},[nt]),(0,b.useEffect)(()=>{!nt||!Object.prototype.hasOwnProperty.call(x,nt)||g3({storageKey:nt,value:x[nt]??``})},[nt,x]),(0,b.useEffect)(()=>{Le.current=u},[u]),(0,b.useEffect)(()=>{if(!tt.current){tt.current=!0;return}let t=_3(e),n=v3(e);Ie.current=!1,Ye.current=!1,et.current=new Set,d(null),p(null),_(!1),S({}),U(null),W(null),ie(null),Me(null),de([]),me(!1),L(!1),ve(w4()),Pe(new Set),Qe.current=new Map,Je.current=t.width,be(n.isOpen),Oe(t.width),Se(t.isOpen)},[e]),(0,b.useEffect)(()=>{Ce||(Je.current=De,Be.current&&(Be.current.style.setProperty(`--chat-changes-panel-width`,`${De}px`),Be.current.setAttribute(`data-desktop-width`,String(De))))},[De,Ce]),(0,b.useEffect)(()=>{if(!s||!Re.current)return;let e=Re.current.getBoundingClientRect().width;if(e<=0)return;let t=q4(De,e);t!==De&&(Je.current=t,Oe(t))},[De,s]),(0,b.useEffect)(()=>{b3({projectId:e,isOpen:ye})},[e,ye]),(0,b.useEffect)(()=>{s&&y3({projectId:e,isOpen:xe,width:De})},[e,De,xe,s]),(0,b.useEffect)(()=>{me(!1)},[u,g]);let at=(0,b.useCallback)(e=>{l(t=>{let n=t.findIndex(t=>t.id===e.id);if(n===-1)return k4([...t,e]);let r=[...t];return r[n]=e,k4(r)})},[]),ot=(0,b.useCallback)(t=>{let n=Le.current,i=e?f3({projectId:e,tool:r,chatSessionId:t}):null;S(e=>{if(!i||!Object.prototype.hasOwnProperty.call(e,i))return e;let t={...e};return delete t[i],t}),g3({storageKey:i,value:``}),l(e=>{let r=e.filter(e=>e.id!==t);if(n===t){let e=r[0]??null;d(e?.id??null),p(null),_(e===null),de([]),fe(!1),me(!1)}return r}),Pe(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}),Me(e=>e?.sessionId===t?null:e),U(e=>e===t?null:e),W(e=>e===t?null:e),ie(e=>e===t?null:e)},[e,r]),st=(0,b.useCallback)((e,t)=>{e&&S(n=>n[e]===t?n:{...n,[e]:t})},[]),ct=(0,b.useCallback)(e=>{e&&(S(t=>t[e]===``?t:{...t,[e]:``}),g3({storageKey:e,value:``}))},[]),lt=(0,b.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call($e.current,e)?$e.current[e]??``:h3(e);S(r=>{let i={...r,[t]:n};return delete i[e],i}),g3({storageKey:t,value:n}),g3({storageKey:e,value:``})},[]),dt=(0,b.useCallback)((e,t)=>{l(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),p(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:{...n,pending_memory_suggestion_count:t})},[]),ft=(0,b.useCallback)(async r=>{if(!e){l([]),d(null),p(null),_(!1),L(!1);return}F(!0);try{let i=await rO(e,r);if(r?.aborted)return;let a=k4(i),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;l(a),d(e=>Ie.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:Ye.current?null:o?s?(Ye.current=!0,A3({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(Ye.current=!0,null)),a.length===0&&_(!0)}catch(e){T(e)||X.error(e instanceof Error?e.message:`Unable to load chat sessions right now.`)}finally{r?.aborted||(F(!1),L(!0))}},[t,n,e]),pt=(0,b.useCallback)(async(t,n)=>{if(!e){p(null);return}z(!0);try{let r=await aO(e,t,n);if(n?.aborted)return;p(r),at(r)}catch(e){T(e)||X.error(e instanceof Error?e.message:`Unable to load the chat session right now.`)}finally{n?.aborted||z(!1)}},[e,at]),mt=(0,b.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){de([]),fe(!1);return}fe(!0);try{let t=await ut(e,null,r,n);if(r?.aborted)return;de(t.suggestions),dt(n,t.suggestions.length)}catch(e){T(e)||X.error(e instanceof Error?e.message:`Unable to load chat memory suggestions right now.`)}finally{r?.aborted||fe(!1)}},[t?.memory_enabled,e,dt]),ht=(0,b.useCallback)(()=>{de(e=>{let t=e.length>0?e.slice(0,-1):e;return u&&dt(u,t.length),t}),ge(e=>e+1),ft(),u&&pt(u)},[u,pt,ft,dt]);(0,b.useEffect)(()=>{let e=new AbortController;return ft(e.signal),()=>{e.abort()}},[ft]),(0,b.useEffect)(()=>{if(Ie.current||g||u||Ye.current||c.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;Ye.current=!0;let e=c[0]??null;e&&A3({activeProject:t,activeProjectBranchState:n,session:e})&&d(e.id)},[t,n,u,g,c]),(0,b.useEffect)(()=>{if(it!==`opencode`){w([]),D([]),se(!1);return}let t=new AbortController;return(async()=>{se(!0);try{let[n,r]=await Promise.all([gt(it,t.signal),yj(it,t.signal,e)]);w(n),D(r)}catch(e){T(e)||(w(e=>e),D(e=>e))}finally{t.signal.aborted||se(!1)}})(),()=>{t.abort()}},[e,it]),(0,b.useEffect)(()=>{if(g||!u){p(null);return}if(f?.id===u)return;p(null);let e=new AbortController;return pt(u,e.signal),()=>{e.abort()}},[f,u,g,pt]),(0,b.useEffect)(()=>{if(!t?.memory_enabled||g||!u){de([]),fe(!1);return}let e=new AbortController;return mt(u,e.signal),()=>{e.abort()}},[t?.memory_enabled,u,g,mt,he]),(0,b.useEffect)(()=>{!pe||K||ue.length>0||me(!1)},[K,pe,ue.length]),(0,b.useEffect)(()=>{if(!u||f?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([ft(e.signal),pt(u,e.signal)])},N4);return()=>{e.abort(),window.clearInterval(t)}},[f?.agent_status,u,pt,ft]),(0,b.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===u&&p(t),k3(t)&&at(t))},n=t=>{!t||t.project_id!==e||ot(t.id)};return EZ.on(`chat-session:created`,t),EZ.on(`chat-session:updated`,t),EZ.on(`chat-session:deleted`,n),()=>{EZ.off(`chat-session:created`,t),EZ.off(`chat-session:updated`,t),EZ.off(`chat-session:deleted`,n)}},[e,u,ot,at]),(0,b.useEffect)(()=>{g&&y(C3({projectId:e,tool:r}))},[e,r,g]),(0,b.useEffect)(()=>{if(it!==`opencode`){k(``),j(``),N([]);return}if(g){let n=w3({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:it,availableModels:C});k(n.model),j(n.variant),N([]);return}k(f?.model??t?.helper_model??``),j(f?.variant??t?.helper_variant??``),N(f?.skills??[])},[e,t?.helper_model,t?.helper_variant,f?.id,f?.model,f?.skills,f?.variant,C,it,g]),(0,b.useEffect)(()=>{let e=C.find(e=>e.id===O)??null;j(t=>e?e.variants.includes(t)?t:``:t)},[C,O]),(0,b.useEffect)(()=>{if(it!==`opencode`||!g||!O||A)return;let n=w3({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:it,availableModels:C});n.model===O&&n.variant&&j(n.variant)},[e,t?.helper_model,t?.helper_variant,it,C,g,O,A]),(0,b.useEffect)(()=>{if(!te)return;let e=f?.id===te?f:c.find(e=>e.id===te)??null;(!e||e.agent_status!==`running`)&&U(null)},[f,te,c]),(0,b.useEffect)(()=>{let e=Ze.current,n=f?.id??null,r=f?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&ge(e=>e+1),Ze.current={id:n,status:r}},[t?.memory_enabled,e,f?.agent_status,f?.id,f?.title]),(0,b.useEffect)(()=>{u&&Pe(e=>{if(!e.has(u))return e;let t=new Set(e);return t.delete(u),t})},[u]),(0,b.useEffect)(()=>{je&&je.sessionId!==u&&Me(null)},[u,je]),(0,b.useEffect)(()=>{let e=Qe.current,t=new Map,n=[];for(let r of c){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==u&&n.push(r),t.set(r.id,a)}Qe.current=t,Pe(e=>{let t=new Set(e),r=!1,i=new Set(c.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of c){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===u||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,u,c]);let _t=(0,b.useMemo)(()=>new Map(C.map(e=>[e.id,e.label])),[C]),vt=(0,b.useMemo)(()=>M4(c),[c]),yt=(0,b.useMemo)(()=>ne?c.find(e=>e.id===ne)??(f?.id===ne?f:null):null,[f,ne,c]);(0,b.useEffect)(()=>{ne&&!yt&&W(null)},[ne,yt]);let bt=(0,b.useMemo)(()=>f?o3({modelLabel:Y4({availableModelsById:_t,model:f.model}),tool:f.tool}):null,[f,_t]),xt=(0,b.useMemo)(()=>f?(f.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?bt??J4(f.tool):s3()})):[],[f,bt]),St=f?.id&&f.agent_status===`running`&&je?.sessionId===f.id?je.turnKey:null,Ct=it===`opencode`&&C.length>0,wt=it===`opencode`&&!Ct&&oe;(0,b.useEffect)(()=>{Fe.current={model:O,variant:A,skills:M,showModelSelector:Ct}},[O,M,A,Ct]);let Tt=(0,b.useMemo)(()=>C.find(e=>e.id===O)??null,[C,O]),Et=g?v:f?.mode??`build`,Dt=g?`New chat`:f?.title??`Chat`,Ot=g?r:f?.tool??r,kt=(0,b.useMemo)(()=>r3(),[]),At=Ct?O||null:f?.model??null,jt=Y4({availableModelsById:_t,model:At}),Mt=(0,b.useMemo)(()=>{let e=f?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=u3({tool:Ot,model:At,availableModels:C,fallbackContextWindow:f?.usage_snapshot_context_window??null});if(t===null)return null;let n=l3({totalTokens:e,contextWindow:t});return n===null?null:`${c3(e)} (${n}%)`},[f?.usage_snapshot_context_window,f?.usage_snapshot_total_tokens,C,At,Ot]),Nt=g?`draft:${e??`none`}:${r}`:f?.id,Pt=(0,b.useCallback)(()=>{Ie.current=!0,_(!0),y(C3({projectId:e,tool:r})),h(null),d(null),p(null),U(null),Me(null)},[e,r]),Ft=(0,b.useCallback)((e,t=null)=>{Ie.current=!1,_(!1),h(null),d(e),p(t)},[]),It=(0,b.useCallback)(async()=>{if(!(!f||!i)){h(f.id);try{await i(f)}catch(e){X.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`)}finally{h(e=>e===f.id?null:e)}}},[f,i]),Lt=!!(f&&f.target_available!==!1&&!g&&!A3({activeProject:t,activeProjectBranchState:n,session:f})),Rt=Lt&&f?`This session targets ${M3(f)}, but the current target is ${N3({activeProject:t,activeProjectBranchState:n})}. Restore the session target to continue.`:null,zt=Lt&&m===null,Bt=(0,b.useCallback)(async r=>{h(r.id);let a=r;if(e)try{let t=await aO(e,r.id);a=t,at(t)}catch(e){X.error(e instanceof Error?e.message:`Unable to load the chat session right now.`),h(e=>e===r.id?null:e);return}if(a.target_available===!1){Ft(a.id,a);return}if(!A3({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){h(e=>e===a.id?null:e);return}}catch(e){X.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`),h(e=>e===a.id?null:e);return}Ft(a.id,a)},[t,n,e,i,Ft,at]),Vt=(0,b.useCallback)(()=>{Ae(e=>e+1)},[]),Ht=(0,b.useCallback)(async t=>{if(g){let n=Fe.current;y(t),S3({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),Vt();return}if(!(!e||!f||f.mode===t||ae)){G(!0);try{let n=await oO(e,f.id,{mode:t});S3({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),p(n),at(n),Vt()}catch(e){X.error(e instanceof Error?e.message:`Unable to update the chat mode right now.`)}finally{G(!1)}}},[e,f,r,Vt,g,ae,at]),Ut=(0,b.useCallback)(async({instruction:t,targetSession:n})=>{if(!e)return null;let r=Fe.current;Xe.current+=1;let i={sessionId:n.id,turnKey:`${n.id}:${Xe.current}`};Me(i);try{let i=await sO(e,n.id,{instruction:t,tool:n.tool,model:r.showModelSelector&&r.model||null,variant:r.showModelSelector&&r.model&&r.variant||null,skills:r.showModelSelector?r.skills:[]});return S3({projectId:e,tool:i.tool,model:i.model,variant:i.variant,mode:i.mode}),Ie.current=!1,p(i),d(i.id),_(!1),at(i),i}catch(e){throw Me(e=>e?.turnKey===i.turnKey?null:e),e}},[e,at]),Wt=(0,b.useCallback)(async()=>{if(!e)return null;let t=Fe.current,n=await iO(e,{mode:Et,tool:r,model:t.showModelSelector&&t.model||null,variant:t.showModelSelector&&t.model&&t.variant||null,skills:t.showModelSelector?t.skills:[]});return Ie.current=!1,_(!1),d(n.id),p(n),n},[e,r,Et]),Gt=(0,b.useCallback)(async t=>{if(!e||V||ee||f?.agent_status===`running`||f?.target_available===!1||zt)return!1;let n=t.trim();if(!n)return!1;H(!0);let r=null,i=f,a=e&&f?f3({projectId:e,tool:f.tool,chatSessionId:f.id}):null;try{let t=f;if(t||(B(!0),r=await Wt(),t=r,a=e&&r?f3({projectId:e,tool:r.tool,chatSessionId:r.id}):null,lt({fromStorageKey:nt,toStorageKey:a})),!t)return!1;ct(a??nt);let i=O3({session:t,instruction:n,createdAt:new Date().toISOString()});p(i),d(i.id),at(i);let o=await Ut({instruction:n,targetSession:t});return ct(o&&e?f3({projectId:e,tool:o.tool,chatSessionId:o.id}):a),!0}catch(e){throw st(a??nt,n),r?(p(r),d(r.id),_(!1),at(r)):i&&(p(i),at(i)),e}finally{B(!1),H(!1)}},[e,f,ct,Wt,nt,ee,V,lt,Ut,st,zt,at]),Kt=(0,b.useCallback)(async e=>{await Gt(e)},[Gt]),qt=!!(e&&(g||f&&f.target_available!==!1&&!zt)),Jt=f?.agent_status===`running`,Yt=f?.agent_status===`stopped`,Xt=Jt&&te===f?.id,Zt=qt&&!Jt&&!V&&!ee,Qt=qt?f?.target_available===!1?f.target_unavailable_reason??`Target unavailable for this chat session.`:zt?Rt??`Restore the session target to continue.`:Jt?`Wait for the current chat turn to finish before sending review comments.`:ee||V?`Wait for the current chat prompt to finish sending before submitting review comments.`:null:`Open or create a chat session to send review comments.`,$t=(0,b.useCallback)(async()=>{if(!(!e||!f||f.agent_status!==`running`||Xt)){U(f.id);try{await cO(e,f.id)}catch(e){U(e=>e===f.id?null:e),X.error(e instanceof Error?e.message:`Unable to interrupt the chat response right now.`)}}},[e,f,Xt]),en=(0,b.useCallback)(async()=>{if(!(!e||!yt||re)){ie(yt.id);try{await lO(e,yt.id),ot(yt.id)}catch(e){X.error(e instanceof Error?e.message:`Unable to delete the chat session right now.`),ie(e=>e===yt.id?null:e)}}},[e,re,ot,yt]),tn=(0,b.useMemo)(()=>(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(d_,{value:Et,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,q.jsx)(a3,{label:`Switch to Plan`,modifierLabel:kt,keys:[H4]})},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,q.jsx)(a3,{label:`Switch to Build`,modifierLabel:kt,keys:[H4]})}],disabled:ae,onChange:e=>{Ht(e)}}),Jt?(0,q.jsxs)(Y,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:Xt,onClick:()=>{$t()},children:[Xt?(0,q.jsx)(C_,{className:`h-4 w-4 animate-spin`}):(0,q.jsx)(E_,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{children:Xt?`Interrupting...`:`Interrupt`})]}):null]}),[kt,Et,$t,Ht,Xt,Jt,ae]),nn=(0,b.useMemo)(()=>Ct?(0,q.jsx)(oV,{model:O,variant:A,skills:M,showModelSelector:!0,showSkillsSelector:!0,availableModels:C,availableSkills:E,selectedModel:Tt,onModelChange:e=>{let t=C.find(t=>t.id===e)??null;k(e),j(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:j,onSkillsChange:N,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:V||ee||f?.agent_status===`running`}):wt?(0,q.jsx)(aV,{dataTestId:`chat-model-selector-skeleton`}):null,[f?.agent_status,C,E,ee,V,Tt,O,M,A,Ct,wt]);(0,b.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,b.useEffect)(()=>{if(a){if(!e||!qt){a(null);return}a({chatSessionId:f?.id??null,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,mode:Et,onModeChange:Ht,isUpdatingMode:ae,promptPlaceholder:Z4(Et),promptComposerControls:tn,promptComposerInlineControls:nn,submitPrompt:Kt})}},[e,f,Zt,Et,Ht,Kt,qt,ae,a,tn,nn,Qt]);let rn=async()=>{if(rt.trim())try{if(!await Gt(rt))return}catch(e){X.error(e instanceof Error?e.message:`Unable to send the chat prompt right now.`)}},an=e=>{e.key!==`Enter`||e.shiftKey||f?.agent_status===`running`||ee||V||(e.preventDefault(),rn())};(0,b.useEffect)(()=>{let t=t=>{if(t3(t)){if(!e||ee||V)return;t.preventDefault(),Pt(),Vt();return}e3(t)&&(!e||!g&&!f||(t.preventDefault(),Ht($4(Et))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,f,Et,Vt,Pt,Ht,ee,g,V]);let on=(0,b.useCallback)(async t=>{if(!(!e||!f)){le(t);try{let n=await fO(e,f.id,t);p(n.chatSession),at(n.chatSession),X.success(`Created ${n.created_tickets.length} ticket${n.created_tickets.length===1?``:`s`} from chat.`)}catch(e){X.error(e instanceof Error?e.message:`Unable to create tickets from the chat proposal right now.`)}finally{le(e=>e===t?null:e)}}},[e,f,at]),sn=(0,b.useCallback)(e=>{if(!Re.current)return;let t=Re.current.getBoundingClientRect().width,n=q4(e,t);Je.current=n,Be.current&&(Be.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),Be.current.setAttribute(`data-desktop-width`,String(n)))},[]),cn=(0,b.useCallback)(()=>{Ue.current?.(),Ue.current=null},[]),ln=(0,b.useCallback)(e=>{let t=Ve.current,n=He.current,r=We.current;if(t!==null){if(Ve.current=null,He.current=null,We.current=!1,we(!1),Ee(!1),cn(),e!==null&&typeof ze.current?.hasPointerCapture==`function`&&ze.current.hasPointerCapture(e)&&typeof ze.current.releasePointerCapture==`function`&&ze.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;Oe(Je.current),Se(!0);return}Oe(Je.current)}},[cn]),un=(0,b.useCallback)((e,t)=>{if(Ve.current!==e)return;let n=t-Ke.current,r=qe.current-n;if(He.current===`collapsed`){if(!We.current&&r<V4)return;We.current||(We.current=!0,Ge.current=!0,Ee(!0),we(!0))}sn(r)},[sn]),dn=(0,b.useCallback)((e,t)=>{if(Ve.current===e){if(t!==null&&(He.current===`inline`||We.current)){let e=t-Ke.current;sn(qe.current-e)}ln(e)}},[ln,sn]),fn=(0,b.useCallback)(e=>{if(!s)return;e.preventDefault(),Ve.current=e.pointerId,He.current=xe?`inline`:`collapsed`,We.current=!1,Ge.current=!1,Ke.current=e.clientX,qe.current=xe?Je.current:0,we(xe),cn(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{un(e.pointerId,e.clientX)},n=e=>{dn(e.pointerId,e.clientX)},r=e=>{dn(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),Ue.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[dn,un,xe,s,cn]),pn=(0,b.useCallback)(e=>{un(e.pointerId,e.clientX)},[un]),mn=(0,b.useCallback)(e=>{dn(e.pointerId,e.clientX)},[dn]),hn=(0,b.useCallback)(e=>{dn(e.pointerId,e.clientX)},[dn]),gn=(0,b.useCallback)(e=>{Ve.current===e.pointerId&&ln(e.pointerId)},[ln]),_n=(0,b.useCallback)(()=>{if(Ge.current){Ge.current=!1;return}Se(!0)},[]),vn=(0,b.useCallback)(()=>{Se(!1)},[]),yn=(0,b.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),_n())},[_n]);(0,b.useEffect)(()=>{s||(Ve.current=null,He.current=null,We.current=!1,Ge.current=!1,we(!1),Ee(!1),cn())},[s,cn]),(0,b.useEffect)(()=>()=>{cn()},[cn]);let bn=!!u,xn=f?.target_available===!1,Sn=xn?f?.target_unavailable_reason??`Target unavailable for this chat session.`:null,Cn=g||!!(f&&f.target_available!==!1&&!zt),wn=!!(t?.memory_enabled&&f&&(ue.length>0||K)),Tn=s&&(g||bn)&&!xn&&!zt,En=Tn&&!xe&&!Te,Dn=Tn&&(xe||Te),On=`${Nt??`none`}:${Tn?`changes-enabled`:`changes-disabled`}:${Dn?`panel-visible`:`panel-hidden`}`,kn=f||g?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(m4,{projectId:e,messages:f?xt:[],internalLog:f?.agent_log??null,pendingAgentTitle:bt,streamingResponse:f?.streaming_response??null,isRunning:f?.agent_status===`running`,isLoading:!g&&R,canShowComposer:Cn,isExternallyResizing:o||Ce,pendingAgentRevealKey:St,pendingAgentRevealDelayMs:K4,composerFocusNonce:ke,header:(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Dt}),(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[g?null:(0,q.jsx)(NM,{tool:f?.tool,className:`text-[11px]`}),jt?(0,q.jsx)(`p`,{children:jt}):null,Yt?(0,q.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:`Interrupted`}):null,Mt?(0,q.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:Mt}):null]})]}),wn?(0,q.jsx)(Y,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>me(!0),children:K?`Loading memory...`:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:`Memory suggestions`}),(0,q.jsx)(g4,{children:ue.length})]})}):null]}),zt&&Rt?(0,q.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`div`,{children:Rt}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{It()},children:`Switch back`}),(0,q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,onClick:Pt,children:`New session`})]})]})}):null,xn&&Sn?(0,q.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:Sn}):null]}),composerControls:tn,composerInlineControls:nn,composerTheme:Et,layoutKey:Nt,scrollLayoutKey:On,followUpPrompt:rt,followUpPlaceholder:Z4(Et),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,q.jsx)(I3,{proposals:e.ticket_proposals,isApplying:ce===e.id,onApply:()=>{on(e.id)}}):null,isSendingFollowUp:V||ee,followUpDisabledReason:xn?Sn??void 0:f?.agent_status===`running`?`Wait for the current chat turn to finish.`:void 0,onFollowUpPromptChange:e=>{st(nt,e)},onFollowUpKeyDown:an,onFollowUpSubmit:()=>{rn()}})}):bn?(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat session...`}):!I||P?(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,q.jsxs)(zv,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,q.jsxs)(Bv,{children:[(0,q.jsx)(Vv,{children:`No session selected`}),(0,q.jsx)(Hv,{children:`Select a chat session to restore its saved target, or start a new session on the current target.`})]}),(0,q.jsx)(Wv,{children:(0,q.jsx)(Y,{type:`button`,onClick:Pt,disabled:!e||ee||V,children:`Start new session`})})]})}),An=Tn?(0,q.jsx)(`div`,{ref:ze,"aria-label":En?`Open diff`:`Resize diff panel`,"aria-orientation":En?void 0:`vertical`,className:J(En?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Ce&&!En&&`bg-background`),"data-testid":En?`collapsed-changes-rail`:void 0,onLostPointerCapture:gn,onPointerCancel:hn,onPointerDown:fn,onPointerMove:pn,onPointerUp:mn,onClick:En?_n:void 0,onKeyDown:En?yn:void 0,role:En?`button`:`separator`,tabIndex:En?0:void 0,children:En?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,q.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,q.jsx)(x_,{className:`h-3 w-3 shrink-0`})}),(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,q.jsx)(x_,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:`Diff`})]})]}):(0,q.jsx)(`div`,{className:J(`h-14 w-1.5 rounded-full transition-colors`,Ce?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,jn=pe&&e&&t?.memory_enabled?(0,q.jsx)(Iv,{onClose:()=>me(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,q.jsxs)(zv,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,q.jsxs)(Bv,{className:`border-b border-border/80 pb-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Vv,{children:`Memory suggestions`}),(0,q.jsx)(Hv,{children:`Review pending suggestions from this chat before saving them into project memory.`})]}),(0,q.jsx)(Uv,{children:t})]}),(0,q.jsx)(Wv,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,q.jsx)(C4,{projectId:e,suggestions:ue,emptyState:`No pending memory suggestions for this chat session.`,onSuggestionsChanged:ht})})]}),closeButtonLabel:`Close memory suggestions`}):null,Mn=yt?(0,q.jsx)(P3,{title:yt.title,isDeleting:re===yt.id,onConfirm:()=>{en()},onCancel:()=>{re!==yt.id&&W(null)}}):null;return(0,q.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,q.jsx)(F3,{activeProject:t,activeSessionId:u,chatModeShortcutModifierLabel:kt,confirmingDeleteSessionId:ne,deletingSessionId:re,finishedBackgroundSessionIds:Ne,isCreatingSession:ee||!e,isDraftOpen:g,isLoadingSessions:P,isOpen:ye,isSendingPrompt:V,sessionGroups:vt,sessions:c,onConfirmDeleteSession:e=>{W(e)},onDraftOpen:Pt,onSessionSelect:e=>{Bt(e)},onToggleOpen:()=>{be(e=>!e)}}),(0,q.jsxs)(`div`,{ref:Re,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,q.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:kn}),Tn?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(u_,{content:`Open diff`,disabled:!En,side:`left`,children:An}),Dn?(0,q.jsx)(p4,{projectId:e,chatSessionId:g?null:u,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,onSubmitReviewPrompt:Kt,state:_e,onStateChange:ve,isResizing:Ce,onClose:vn,desktopWidth:De,panelElementRef:Be}):null]}):null]}),jn,Mn]})},R3=({className:e})=>(0,q.jsx)(uh,{"aria-hidden":`true`,className:e}),z3=({activeProject:e})=>e?(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,q.jsx)(Ab,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),B3=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),V3=()=>({board:B3(),memory:B3(),chat:B3()}),H3=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},U3=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),W3=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,G3=(e,t)=>t?null:W3(e),K3=320,q3=.7,J3=28,Y3=6,X3=(e,t)=>{let n=Math.max(K3,Math.round(t*q3));return Math.max(K3,Math.min(n,Math.round(e)))},Z3=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},Q3=(e,t)=>{if(t.type===`reset`)return V3();if(t.type===`mark-workspace-visible`)return H3(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},$3=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=_2(),r=(0,b.useRef)(new Map);return(0,b.useEffect)(()=>{r.current=new Map},[e]),(0,b.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},e6=({activeProjectId:e,onActivity:t})=>{let[n,r]=(0,b.useState)([]),i=(0,b.useRef)(new Map);return(0,b.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await rO(e,t.signal);if(t.signal.aborted)return;r(n)}catch(e){T(e)}})(),()=>{t.abort()}},[e]),(0,b.useEffect)(()=>{if(!e)return;let t=new AbortController,n=P$(()=>{document.visibilityState===`visible`&&rO(e,t.signal).then(e=>{t.signal.aborted||r(e)}).catch(e=>{T(e)})});return()=>{t.abort(),n()}},[e]),(0,b.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||r(e=>Z3(e,t))},n=t=>{!t||t.project_id!==e||r(e=>e.filter(e=>e.id!==t.id))};return EZ.on(`chat-session:created`,t),EZ.on(`chat-session:updated`,t),EZ.on(`chat-session:deleted`,n),()=>{EZ.off(`chat-session:created`,t),EZ.off(`chat-session:updated`,t),EZ.off(`chat-session:deleted`,n)}},[e]),(0,b.useEffect)(()=>{let r=i.current,a=new Map,o=[],s=!1;for(let e of n){let t=r.get(e.id)??null,n=e.agent_status??null;t===`running`&&n===`done`&&o.push(e),t===`running`&&n===`error`&&(s=!0),a.set(e.id,n)}i.current=a;for(let e of o)e.title&&l2(`Chat response ready`,e.title);o.length>0&&e&&j$(e),t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,n]),null},t6=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:x,onRunStatusChange:S,onWorkspaceActivityChange:C,onWorkspaceActivityEvent:w,refreshKey:T=0})=>{let E=(0,b.useRef)(null),D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(null),A=(0,b.useRef)(!1),j=(0,b.useRef)(!1),M=(0,b.useRef)(0),N=(0,b.useRef)(u),P=(0,b.useRef)(u),F=p===`board`||p===`chat`,I=l!==null,[L,R]=(0,b.useState)(!1),[z,ee]=(0,b.useState)(!1),[B,V]=(0,b.useState)(u),[H,te]=(0,b.useReducer)(Q3,void 0,V3),U=F&&I&&c===`expanded`,ne=F&&I&&c===`inline`,W=F&&I&&c===`hidden`&&!z,re=(ne||z)&&!U,ie=U||re,ae=F&&I&&!U,G=L?B:u,oe=p!==`chat`||!re,se=e=>{let t=O.current,n=k.current,r=A.current;if(t!==null){if(O.current=null,k.current=null,A.current=!1,R(!1),ee(!1),e!==null&&D.current?.hasPointerCapture(e)&&D.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(P.current),v?.();return}y?.(P.current)}},ce=e=>{if(!E.current)return;let t=E.current.getBoundingClientRect().width,n=X3(e,t);P.current=n,V(n)},le=e=>{y&&(W&&d||(e.preventDefault(),O.current=e.pointerId,k.current=W?`collapsed`:`inline`,A.current=!1,j.current=!1,M.current=e.clientX,N.current=W?0:P.current,R(!W),e.currentTarget.setPointerCapture(e.pointerId)))},ue=e=>{if(O.current!==e.pointerId)return;let t=e.clientX-M.current,n=N.current-t;if(k.current===`collapsed`){if(!A.current&&n<Y3)return;A.current||(A.current=!0,j.current=!0,ee(!0),R(!0))}ce(n)},de=e=>{if(O.current===e.pointerId){if(k.current===`inline`||A.current){let t=e.clientX-M.current;ce(N.current-t)}se(e.pointerId)}},K=e=>{O.current===e.pointerId&&se(e.pointerId)},fe=(0,b.useCallback)((e,t)=>{w?.(e,t),te({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[w,p]);(0,b.useEffect)(()=>{te({type:`reset`})},[e]),(0,b.useEffect)(()=>{p!==`memory`&&te({type:`mark-workspace-visible`,workspace:p})},[p]),(0,b.useEffect)(()=>{C?.(H)},[C,H]),(0,b.useEffect)(()=>{L||(P.current=u),!I&&(O.current=null,k.current=null,A.current=!1,j.current=!1,P.current=u)},[I,L,u]);let pe=()=>{if(j.current){j.current=!1;return}d||v?.()};return(0,q.jsx)(g2,{activeProjectId:e,refreshKey:T,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,q.jsxs)(`div`,{ref:E,className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsx)($3,{activeProjectId:e,onActivity:e=>{fe(`board`,e)}}),(0,q.jsx)(e6,{activeProjectId:e,onActivity:e=>{fe(`chat`,e)}}),p===`memory`?(0,q.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,q.jsx)(z3,{activeProject:t})}):(0,q.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,q.jsx)(L3,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:L,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:oe}):(0,q.jsx)(Y2,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:x,onRunStatusChange:S,refreshKey:T})}),[ae?(0,q.jsx)(u_,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!W,side:`left`,children:(0,q.jsx)(`div`,{"aria-label":W?f??`Show preview`:`Resize preview pane`,"aria-orientation":W?void 0:`vertical`,className:W?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${L?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":W?`collapsed-preview-rail`:void 0,onLostPointerCapture:K,onPointerCancel:de,onPointerDown:le,onPointerMove:ue,onPointerUp:de,onClick:W?pe:void 0,onKeyDown:W?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),pe())}:void 0,ref:D,role:W?`button`:`separator`,style:W?{width:`${J3}px`}:void 0,tabIndex:W?d?-1:0:void 0,children:W?(0,q.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,q.jsx)(R3,{className:`h-3 w-3 shrink-0`})}),(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,q.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${L?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,ie?(0,q.jsx)(`div`,{className:U?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:U?void 0:{width:`${G}px`},children:(0,q.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},n6=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,q.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,q.jsx)(kZ,{createSession:()=>kM(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),r6=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,q.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=G3(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,q.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:J(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,q.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,q.jsx)(Q2,{state:a,className:`mt-0`})]})},n)})}),i6=32,a6=5.5,o6=2,s6=24,c6=8,l6=new Map,u6={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},d6=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),f6=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},p6=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=f6(n.getAttribute(`width`)),a=f6(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${i6} ${i6}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${d6(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${i6}"`,`height="${i6}"`,`viewBox="${d6(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},m6=async e=>{if(!e)return null;let t=l6.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return p6(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return p6(atob(e.slice(26)));let t=await fetch(e);return t.ok?p6(await t.text()):null}catch{return null}})();return l6.set(e,n),n},h6=async(e,t)=>{let{fill:n,stroke:r}=u6[e],i=await m6(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${i6}" height="${i6}" viewBox="0 0 ${i6} ${i6}">`,i,`<circle cx="${s6}" cy="${c6}" r="${a6}" fill="${n}" stroke="${r}" stroke-width="${o6}"/>`,`</svg>`].join(``):null},g6=async(e,t)=>{if(!e)return t;let n=await h6(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},_6=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},v6=({defaultHref:e,state:t})=>{let n=_6(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}g6(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},y6=`archon.active-project-id`,b6=`archon.workspace-by-project`,x6=`archon.preview-mode-by-project`,S6=`archon.dismissed-preview-run-context-by-project`,C6=5e3,w6=`archon.preview-pane-width`,T6=`archon.preview-viewport-preset`,E6=`archon.preview-zoom`,D6=480,O6=`responsive`,k6=1,A6={hasMounted:!1,isOpen:!1,isExpanded:!1},j6=`hidden`,M6=(0,b.lazy)(()=>NZ(()=>Promise.resolve().then(()=>V1).then(e=>({default:e.TicketChangesModal})),void 0)),N6=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},P6=e=>{let t=N6(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},F6=e=>{let t=N6(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},I6=e=>{let t=N6(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},L6=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:P6(e.run_setup),runServices:F6(e.run_services),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:I6(e.worktree_sync)}),R6=e=>{let t=e.previewServiceName?.trim()||null,n=e.previewPath?.trim()||``,r=n===``||n===`/`?null:n,i=t||r||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,run_ide:e.runIde||null,preview_service_name:t,preview_path:r,preview_capability_mode:i,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},z6=e=>e?P6(e.run_setup).length>0||F6(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,B6=(e,t,n)=>`${e} ${e===1?t:n}`,V6=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push(B6(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push(B6(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},H6=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push(B6(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push(B6(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push(B6(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},U6=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},W6=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),G6=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),K6=(e,t)=>t?e[t]??A6:A6,q6=(e,t)=>t?e[t]??j6:j6,J6=()=>{let e=window.localStorage.getItem(w6),t=Number(e);return Number.isFinite(t)&&t>=320?t:D6},Y6=()=>{let e=window.localStorage.getItem(T6);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:O6},X6=()=>{let e=Number(window.localStorage.getItem(E6));return Number.isFinite(e)&&e>0?e:k6},Z6=()=>{let e=N6(window.localStorage.getItem(b6));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},Q6=()=>{let e=N6(window.localStorage.getItem(x6));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},$6=()=>{let e=N6(window.localStorage.getItem(S6));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},e8=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,t8=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},n8=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:t8({activeRun:e,project:t})?e:null,r8=`Project root has uncommitted changes. Confirm branch switch to continue.`,i8=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,a8=()=>{let[e,t]=(0,b.useState)(`opencode`),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(()=>window.localStorage.getItem(y6)),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(null),[m,h]=(0,b.useState)({}),[g,_]=(0,b.useState)({}),[v,y]=(0,b.useState)({}),[x,C]=(0,b.useState)(null),[w,E]=(0,b.useState)({}),[D,O]=(0,b.useState)(Q6),[k,j]=(0,b.useState)($6),[M,N]=(0,b.useState)(J6),[P,F]=(0,b.useState)(Y6),[I,L]=(0,b.useState)(X6),[R,z]=(0,b.useState)(null),[ee,B]=(0,b.useState)([]),[V,H]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(``),[G,oe]=(0,b.useState)(``),[se,ce]=(0,b.useState)(!1),[le,ue]=(0,b.useState)(null),[de,K]=(0,b.useState)(null),[fe,pe]=(0,b.useState)({}),[me,he]=(0,b.useState)(Z6),[ge,_e]=(0,b.useState)(()=>V3()),[ve,ye]=(0,b.useState)(()=>B3()),[be,xe]=(0,b.useState)(0),[Se,Ce]=(0,b.useState)(null),[we,Te]=(0,b.useState)(null),[De,Oe]=(0,b.useState)({}),[ke,Ae]=(0,b.useState)({}),[je,Me]=(0,b.useState)({}),[Ne,We]=(0,b.useState)({}),[qe,Je]=(0,b.useState)(!1),[Xe,Ze]=(0,b.useState)(null),Qe=(0,b.useRef)(null),$e=(0,b.useRef)(null),et=(0,b.useRef)(null),tt=i.find(e=>e.id===o)??null,nt=!!tt?.memory_enabled,rt=o?me[o]??`board`:`board`,it=rt===`memory`?nt?`memory`:`board`:rt,at=tt!==null,ot=z6(tt),st=!!tt?.run_ide?.trim(),ct=o!==null&&u===o,lt=o!==null&&(!ot||f===o),ut=o?m[o]??G6(o):null,dt=o?g[o]??null:null,ft=o?!!v[o]:!1,pt=o?De[o]??[]:[],mt=o?!!ke[o]:!1,ht=o?je[o]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},yt=o?!!Ne[o]:!1,bt=o?w[o]??null:null,xt=q6(D,o),St=xt!==`hidden`,Ct=n8({activeRun:c,project:tt,projectId:o}),wt=Ct?.context_key??null,Tt=o?k[o]??null:null,Et=e8(tt),Dt=wt===R,Ot=(0,b.useMemo)(()=>U3(ge),[ge]),kt=(0,b.useMemo)(()=>W3({hasRunning:Ot.hasRunning,hasFinishedUnseen:ve.hasFinishedUnseen,hasErrorUnseen:ve.hasErrorUnseen}),[Ot.hasRunning,ve.hasErrorUnseen,ve.hasFinishedUnseen]);(0,b.useEffect)(()=>{Ce(null),Te(null),$e.current=null},[o]),(0,b.useEffect)(()=>{Te(null)},[it]),(0,b.useEffect)(()=>{St||($e.current=null)},[St]),(0,b.useEffect)(()=>{let e=Se?.target?.kind??null;if(e===`ticket`||e===`bundle`){$e.current=Se;return}(it===`board`||!St)&&($e.current=Se)},[St,Se,it]),(0,b.useEffect)(()=>{_e(V3())},[o]),(0,b.useEffect)(()=>{ye(B3())},[o]);let At=(0,b.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||ye(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,b.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&ye(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,b.useEffect)(()=>(Qe.current===null&&(Qe.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),v6({defaultHref:Qe.current,state:kt}),()=>{v6({defaultHref:Qe.current,state:null})}),[kt]);let jt=(0,b.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await Ge(e,r,{refreshRemote:n});if(r?.aborted)return;h(n=>({...n,[e]:W6(e,t)}))}catch(t){if(T(t))return;if(t instanceof S&&t.status===404){h(t=>({...t,[e]:{...G6(e),status:`unknown`}}));return}h(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),Mt=(0,b.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;y(t=>({...t,[e]:!0}));try{let t=await Ye(e,{refreshRemote:n,signal:r});if(r?.aborted)return;_(n=>({...n,[e]:t}))}catch(t){if(T(t))return;t instanceof S&&t.status===404&&_(t=>({...t,[e]:null}))}finally{r?.aborted||y(t=>({...t,[e]:!1}))}},[]);(0,b.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await _t(e.signal);t(n)}catch(e){T(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,b.useEffect)(()=>{if(!se||i.length>0&&le===null||V)return;let e=new AbortController;return(async()=>{try{B(await gt(`opencode`,e.signal))}catch(e){T(e)||B(e=>e)}finally{e.signal.aborted||H(!0)}})(),()=>{e.abort()}},[V,le,i.length,se]),(0,b.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(y6);return(async()=>{try{let n=await Pe(e.signal);if(e.signal.aborted)return;a(n);let r=n[0]?.id??null;s(n.some(e=>e.id===t)?t:r)}catch(e){T(e)||a([])}finally{e.signal.aborted||ce(!0)}})(),()=>{e.abort()}},[]),(0,b.useEffect)(()=>{if(se){if(o){window.localStorage.setItem(y6,o);return}window.localStorage.removeItem(y6)}},[o,se]),(0,b.useEffect)(()=>{window.localStorage.setItem(b6,JSON.stringify(me))},[me]),(0,b.useEffect)(()=>{window.localStorage.setItem(x6,JSON.stringify(D))},[D]),(0,b.useEffect)(()=>{window.localStorage.setItem(S6,JSON.stringify(k))},[k]),(0,b.useEffect)(()=>{h(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),_(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),y(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,b.useEffect)(()=>{pe(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,b.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Oe(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Ae(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Me(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),We(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,b.useEffect)(()=>{E(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),O(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),j(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,b.useEffect)(()=>{se&&he(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,se]),(0,b.useEffect)(()=>{if(!se||!o||!at)return;let e=!1,t=null,n=null;h(e=>e[o]?e:{...e,[o]:G6(o)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([jt(o,{refreshRemote:r,signal:a.signal}),Mt(o,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=P$(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[o,at,se,jt,Mt]),(0,b.useEffect)(()=>{if(o)return M$(e=>{e===o&&(jt(e),Mt(e))})},[o,jt,Mt]);let Nt=(0,b.useCallback)(async e=>{let t=o;if(!t){l(null),p(null);return}try{let n=await ne(t,e);e?.aborted||(l(n.active_run),p(t))}catch(e){T(e)}},[o]),Pt=(0,b.useCallback)(async e=>{let t=o;if(t)try{let n=await U(t,e);e?.aborted||E(e=>({...e,[t]:n}))}catch(e){T(e)}},[o]);(0,b.useEffect)(()=>{if(!se)return;if(!ot){l(null),p(null);return}if(!ct)return;let e=new AbortController;p(null),Nt(e.signal);let t=window.setInterval(()=>{Nt(e.signal)},C6),n=P$(()=>{document.visibilityState===`visible`&&Nt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[ct,ot,se,Nt]),(0,b.useEffect)(()=>{if(!se||!o||!ct||!Et)return;let e=new AbortController;Pt(e.signal);let t=window.setInterval(()=>{Pt(e.signal)},C6),n=P$(()=>{document.visibilityState===`visible`&&Pt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[o,ct,Et,se,Pt]),(0,b.useEffect)(()=>{window.localStorage.setItem(w6,String(M))},[M]),(0,b.useEffect)(()=>{window.localStorage.setItem(T6,P)},[P]),(0,b.useEffect)(()=>{window.localStorage.setItem(E6,String(I))},[I]),(0,b.useEffect)(()=>{o&&wt&&j(e=>{let t=e[o]??null;return!t||t===wt?e:{...e,[o]:null}})},[o,wt]),(0,b.useEffect)(()=>{!o||!Ct||!e8(tt)||Tt!==Ct.context_key&&O(e=>q6(e,o)===`hidden`?{...e,[o]:`inline`}:e)},[tt,o,Tt,Ct]);let Ft=async e=>{try{t((await vt(e)).tool)}catch{}},It=(0,b.useCallback)(e=>{a(t=>t.map(t=>t.id===e.id?e:t))},[]),Lt=(0,b.useCallback)((e,t)=>{Oe(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Rt=(0,b.useCallback)(async e=>{We(t=>({...t,[e]:!0}));try{let t=await ze(e);Me(n=>({...n,[e]:t}))}catch(e){X.error(e instanceof S?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{We(t=>({...t,[e]:!1}))}},[]),zt=async e=>{try{let t=await Fe(R6(e));return a(e=>[...e,t]),s(t.id),ue(null),null}catch(e){return e instanceof S?e.message:`Unable to create the project right now.`}},Bt=async e=>{if(!tt)return`Select a project before editing settings.`;try{let t=await Ie(tt.id,R6(e));return a(e=>e.map(e=>e.id===t.id?t:e)),xe(e=>e+1),ue(null),null}catch(e){return e instanceof S?e.message:`Unable to update the project right now.`}},Vt=async()=>{if(!tt)return`Select a project before deleting it.`;try{await Le(tt.id);let e=i.filter(e=>e.id!==tt.id);return a(e),s(e[0]?.id??null),ue(null),null}catch(e){return e instanceof S?e.message:`Unable to delete the project right now.`}},Ht=(0,b.useCallback)(e=>{a(t=>t.map(t=>U6(t,e)))},[]),Ut=(0,b.useCallback)((e,t)=>{e&&Oe(n=>({...n,[e]:t}))},[]),Wt=(0,b.useCallback)((e,t)=>{e&&Ae(n=>({...n,[e]:t}))},[]),Gt=async(e,t,n)=>await Ve({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Kt=async()=>(await He()).repo_path,qt=(0,b.useCallback)(async e=>{let t=await Ue({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error}},[]),Jt=(0,b.useCallback)((e,t)=>{O(t=>({...t,[e]:`hidden`})),t&&j(n=>({...n,[e]:t}))},[]),Yt=(0,b.useCallback)(()=>{o&&Jt(o,wt)},[o,Jt,wt]),Xt=(0,b.useCallback)(e=>{o&&(O(e=>({...e,[o]:`hidden`})),e&&l(t=>t?.context_key===e?null:t))},[o]),Zt=(0,b.useCallback)(async()=>{if(!Ct||R===Ct.context_key)return;let{context_key:e}=Ct;z(e);try{Ct.kind===`ticket`?await Ee(Ct.ticket_id,Ct.project_id):l((await re(Ct.project_id)).active_run),Xt(e),await Promise.all([Nt(),Pt()])}catch(e){X.error(e instanceof S?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{z(t=>t===e?null:t)}},[Xt,Ct,Pt,Nt,R]),Qt=(0,b.useCallback)(e=>{!e||!o||Rt(o)},[o,Rt]),$t=(0,b.useCallback)(e=>new Promise(t=>{et.current=t,Ze(e)}),[]),en=(0,b.useCallback)(e=>{let t=et.current;et.current=null,Ze(null),t?.(e)},[]),tn=(0,b.useCallback)(async e=>{if(!tt||!o)throw Error(`Select a project first.`);if(!i8({activeProject:tt,activeProjectBranchState:ut,nextTarget:e})||!c||c.kind!==`project`||c.project_id!==tt.id)return!0;if(!await $t({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=c.context_key,t=await re(tt.id);return Xt(e),l(t.active_run),await Pt(),!0}catch(e){return X.error(e instanceof S?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[tt,ut,o,c,Xt,Pt,$t]),nn=(0,b.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);return await tn({kind:`bundle`,bundleId:e})?(It(await Be(o,{kind:`bundle`,bundle_id:e})),_(e=>({...e,[o]:null})),await Promise.all([jt(o),Mt(o)]),!0):!1},[o,tn,jt,Mt,It]),rn=(0,b.useCallback)(async(e,t={})=>{if(!o)throw Error(`Select a project first.`);if(!await tn({kind:`repo_root`,branch:e}))return!1;let n=n=>Be(o,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof S&&e.status===409&&e.message===r8){if(!await $t({title:`Switch repo root branch?`,description:`${r8}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return It(r),_(e=>({...e,[o]:null})),await Promise.all([jt(o),Mt(o),Rt(o)]),!0},[o,tn,Rt,jt,Mt,It,$t]),an=(0,b.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await nn(e.target_bundle_id):!1:await rn(e.target_branch_snapshot??null,{createBranch:!1}),[nn,rn]),on=(0,b.useCallback)(()=>{Je(!0)},[]),sn=(0,b.useCallback)(()=>{Je(!1)},[]),cn=(0,b.useCallback)(e=>{if(e){nn(e);return}rn(null)},[nn,rn]),ln=(0,b.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);let t=await A(o,{name:e,prepare:!0});return Lt(o,t),xe(e=>e+1),t},[o,Lt]),un=(0,b.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);await te(o,e),Oe(t=>({...t,[o]:(t[o]??[]).filter(t=>t.id!==e)})),xe(e=>e+1)},[o]),dn=(0,b.useCallback)(async()=>{if(!tt)return;let e=tt.active_target_kind??`repo_root`,t=tt.active_target_bundle_id??null,n=c?.kind===`project`&&c.project_id===tt.id&&(c.target_kind??`repo_root`)===e&&((c.target_kind??`repo_root`)!==`bundle`||c.target_bundle_id===t),r=n?c?.context_key??null:null,i=!n&&e8(tt)&&xt===`hidden`;i&&(O(e=>({...e,[tt.id]:`inline`})),j(e=>({...e,[tt.id]:null})));try{let e=n?await re(tt.id):await W(tt.id);n&&Xt(r),l(e.active_run),Pt()}catch(e){i&&O(e=>({...e,[tt.id]:`hidden`})),X.error(e instanceof S?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[xt,tt,c,Xt,Pt]),fn=(0,b.useCallback)(async()=>{if(!(!tt||!st))try{await Re(tt.id)}catch(e){X.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[tt,st]),pn=(0,b.useCallback)(async()=>{if(tt){C(tt.id);try{let e=await Ke(tt.id);_(t=>({...t,[tt.id]:e})),tt.active_target_kind!==`bundle`&&await jt(tt.id),j$(tt.id),X.success(e.behind===0?`Project branch synced.`:`Project branch updated.`,{id:`app-project-pull-success`})}catch(e){X.error(e instanceof S?e.message:`Unable to sync the current branch right now.`,{id:`app-project-pull-error`})}finally{C(e=>e===tt.id?null:e)}}},[tt,jt]),mn=(0,b.useCallback)(()=>{tt&&K({projectId:tt.id,title:tt.name})},[tt]),hn=(0,b.useCallback)(()=>{if(!de)return;let{projectId:e}=de;K(null),jt(e),Mt(e)},[jt,Mt,de]),gn=K6(fe,o),_n=it===`chat`?we:null,vn=$e.current,yn=vn?.target?.kind??null,bn=it===`chat`?yn===`ticket`||yn===`bundle`?{target:vn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,promptMode:vn?.promptMode??null,onPromptModeChange:vn?.onPromptModeChange??null,isUpdatingPromptMode:vn?.isUpdatingPromptMode??!1,promptPlaceholder:vn?.promptPlaceholder??null,promptComposerControls:vn?.promptComposerControls,promptComposerInlineControls:vn?.promptComposerInlineControls,submitPrompt:null}:_n?{target:{kind:`chat_session`,id:_n.chatSessionId??`draft:${o}`},canSelect:_n.canSubmitReviewPrompt,disabledReason:_n.canSubmitReviewPrompt?null:_n.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,promptMode:_n.mode,onPromptModeChange:_n.onModeChange,isUpdatingPromptMode:_n.isUpdatingMode,promptPlaceholder:_n.promptPlaceholder,promptComposerControls:_n.promptComposerControls,promptComposerInlineControls:_n.promptComposerInlineControls,submitPrompt:_n.canSubmitReviewPrompt?_n.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:Se,xn=_n?.canSubmitReviewPrompt??!1,Sn=it===`chat`?_n?_n.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,Cn=(0,b.useCallback)(()=>{o&&pe(e=>{let t=e[o]??A6;return{...e,[o]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[o]),wn=(0,b.useCallback)(e=>{pe(t=>{let n=t[e]??A6;return!n.hasMounted||!n.isOpen?t:{...t,[e]:A6}})},[]),Tn=(0,b.useCallback)(e=>{pe(t=>{let n=t[e]??A6;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),En=(0,b.useCallback)(()=>{o&&pe(e=>{let t=e[o]??A6;return t.isOpen?e:{...e,[o]:{hasMounted:!0,isOpen:!0,isExpanded:t.isExpanded}}})},[o]),Dn=(0,b.useCallback)(()=>{ue(`create`)},[]),On=(0,b.useCallback)(()=>{if(o){if(St){Yt();return}O(e=>({...e,[o]:`inline`})),j(e=>({...e,[o]:null}))}},[o,Yt,St]),kn=(0,b.useCallback)(()=>{o&&O(e=>{let t=q6(e,o);return{...e,[o]:t===`expanded`?`inline`:`expanded`}})},[o]),An=tt?tt.preview_service_name?.trim()?tt.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:bt?.state===`unsupported`?bt.message??`Preview is unavailable for this project.`:St?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,jn=!tt||!tt.preview_service_name?.trim()||tt.preview_capability_mode===`force_disabled`||bt?.state===`unsupported`,Mn=tt&&tt.preview_service_name?.trim()?(0,q.jsx)(nO,{project:tt,mode:xt===`expanded`?`expanded`:`inline`,status:bt,viewportPreset:P,zoom:I,activeRun:Ct,reviewCapability:bn,isStoppingActiveRun:Dt,onHide:Yt,onStopActiveRun:()=>{Zt()},onToggleExpanded:kn,onViewportPresetChange:F,onZoomChange:L}):null;return Q0([{key:`t`,onKeyDown:En}],{isBlocked:Z0}),(0,q.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,q.jsx)(Ov,{}),i.length>0&&(0,q.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,q.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,q.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,q.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,q.jsx)(g_,{activeProjectId:o,projects:i,onEditProject:()=>ue(`edit`),onProjectChange:s})})}),o&&(0,q.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,q.jsx)(r6,{activeWorkspace:it,activityByWorkspace:ge,memoryEnabled:nt,onWorkspaceChange:e=>{o&&(he(t=>({...t,[o]:e})),_e(t=>H3(t,e)))}})}),(0,q.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,q.jsx)(Dv,{activeTool:e,onCreateProject:Dn,onToolChange:Ft})})]})}),se?i.length===0?(0,q.jsx)(p_,{activeTool:e,availableHelperModels:ee,helperModel:ie,helperVariant:G,isHelperModelsLoaded:V,isToolLoaded:n,onCreateProject:Dn,onHelperModelChange:e=>{ae(e),oe(``)},onHelperVariantChange:oe,onToolChange:Ft}):(0,q.jsx)(t6,{activeProjectId:o,activeProject:tt,activeProjectBranchState:ut,activeRun:c,activeTool:e,onRestoreChatSessionTarget:an,onChatReviewCapabilityChange:Te,isPreviewButtonDisabled:jn,onPreviewReviewCapabilityChange:Ce,onPreviewToggle:On,onRunStopped:Xt,onWorkspaceActivityChange:_e,onWorkspaceActivityEvent:At,previewDisplayMode:xt,previewPane:Mn,previewPaneWidth:M,previewButtonTitle:An,visibleWorkspace:it,refreshKey:be,onBoardLoadedProjectIdChange:d,onBundlesChange:Ut,onBundlesLoadingChange:Wt,onPreviewPaneWidthChange:N,onProjectUsageChange:Ht,onRunStatusChange:()=>{Nt(),Pt()}},o??`no-project`):(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,q.jsx)(Tv,{activeProject:tt,activeRun:c,branchState:ut,targetGitStatus:dt,isBoardLoadedForActiveProject:ct,isProjectSyncing:x===o,isProjectIdeAvailable:st,isProjectRunAvailable:ot,isRunStatusLoadedForActiveProject:lt,isTerminalOpen:gn.isOpen,targetBundles:pt,targetBranchSuggestions:ht,isTargetBundleLoading:mt,isTargetSelectorLoading:yt,isTargetGitStatusLoading:ft,onProjectIdeOpen:()=>{fn()},onProjectPull:()=>{pn()},onProjectRunToggle:()=>{dn()},onProjectChangesOpen:mn,onTerminalToggle:Cn,onTargetSelectorOpenChange:Qt,onSelectBundleTarget:nn,onSelectRepoRootTarget:rn,onManageBundles:on}),qe&&tt&&(0,q.jsx)(Xv,{bundles:pt,selectedBundleId:tt.active_target_kind===`bundle`?tt.active_target_bundle_id??null:null,activeTargetBundleId:tt.active_target_kind===`bundle`?tt.active_target_bundle_id??null:null,onSelectBundle:cn,onCreateBundle:ln,onDeleteBundle:un,onClose:sn}),Xe&&(0,q.jsx)(Lv,{title:Xe.title,description:Xe.description,confirmLabel:Xe.confirmLabel,cancelLabel:Xe.cancelLabel,confirmVariant:Xe.confirmVariant,onConfirm:()=>en(!0),onCancel:()=>en(!1)}),i.map(e=>{let t=K6(fe,e.id);return t.hasMounted?(0,q.jsx)(n6,{project:e,isExpanded:t.isExpanded,isVisible:e.id===o&&t.isOpen,onClose:()=>wn(e.id),onToggleExpanded:()=>Tn(e.id)},e.id):null}),le&&(0,q.jsx)(Yb,{mode:le,projectId:le===`edit`&&tt?tt.id:null,availableHelperModels:ee,isLoadingHelperModels:!V,isAutoConfigReady:n,initialValues:le===`edit`&&tt?L6(tt):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:G,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==tt?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:le===`edit`&&tt?tt.repo_path_locked:!1,repoPathLockedMessage:le===`edit`&&tt?V6(tt):null,deleteBlockedMessage:le===`edit`&&tt?H6(tt,i):null,onDelete:le===`edit`?Vt:void 0,onAutoConfig:Gt,onBrowseRepoPath:Kt,onValidateRepoPath:qt,onClose:()=>ue(null),onSubmit:le===`edit`?Bt:zt}),de&&de.projectId===o&&(0,q.jsx)(b.Suspense,{fallback:null,children:(0,q.jsx)(M6,{scope:`project_root`,projectId:de.projectId,title:de.title,onSubmitReviewPrompt:_n?.submitPrompt,canSubmitReviewPrompt:xn,reviewSubmitDisabledReason:Sn??void 0,canAddReviewComments:xn,canModifyChanges:!0,onClose:hn})})]})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,y.createRoot)(document.getElementById(`root`)).render((0,q.jsx)(a8,{}));