github-issue-tower-defence-management 2.128.0 → 2.129.0

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.
@@ -10,7 +10,7 @@ Error generating stack: `+e.message+`
10
10
 
11
11
  `),fe=`In Tmux by human`,pe=`Awaiting Workspace`,me=[`In Tmux by human`,`Todo by human`,pe],he=e=>e===`todo-by-human`||e===`todo-by-agent`,ge=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===pe.toLowerCase());if(n===void 0)return null;let r=F(n.color);return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:r.fg,borderColor:r.border,backgroundColor:r.bg},onClick:()=>t(n),children:`ok & Awaiting Workspace`})})},_e={issueOpen:{color:`#3fb950`,paths:[`M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z`,`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z`]},issueClosed:{color:`#a371f7`,paths:[`M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z`,`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z`]},issueClosedNotPlanned:{color:`#848d97`,paths:[`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`]},prOpen:{color:`#3fb950`,paths:[`M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z`]},prMerged:{color:`#a371f7`,paths:[`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`]},prClosed:{color:`#f85149`,paths:[`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z`]},prDraft:{color:`#8b949e`,paths:[`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`]}},ve=({isPr:e,state:t,merged:n,isDraft:r,stateReason:i})=>e?r?`prDraft`:n?`prMerged`:t===`closed`?`prClosed`:`prOpen`:t===`closed`?i===`not_planned`?`issueClosedNotPlanned`:`issueClosed`:`issueOpen`,ye=({size:e=12,...t})=>{let n=ve(t),r=_e[n];return(0,x.jsx)(`svg`,{className:`console-item-icon`,viewBox:`0 0 16 16`,width:e,height:e,fill:r.color,role:`img`,"aria-label":n,children:r.paths.map(e=>(0,x.jsx)(`path`,{d:e},e))})},be=({item:e,isActive:t,now:n,statusOptions:r=[],onSelect:i})=>(0,x.jsx)(`button`,{type:`button`,className:`console-item-row`,"aria-current":t?`true`:void 0,"data-active":t?`true`:void 0,onClick:()=>i(e),children:(0,x.jsxs)(`span`,{className:`console-item-meta`,children:[(0,x.jsxs)(`span`,{className:`console-item-title`,children:[(0,x.jsx)(ye,{isPr:e.isPr,state:`open`,merged:!1,isDraft:!1,stateReason:``}),e.title]}),(0,x.jsxs)(`span`,{className:`console-item-sub`,children:[(0,x.jsxs)(`span`,{className:`console-item-pill`,children:[`#`,e.number]}),e.repo!==``&&(0,x.jsx)(`span`,{className:`console-item-pill`,children:e.repo}),(0,x.jsx)(`span`,{className:`console-item-pill`,children:e.isPr?`PR`:`Issue`}),e.createdAt!==``&&(0,x.jsxs)(`span`,{className:`console-item-opened`,children:[` · opened `,(0,x.jsx)(`span`,{className:`console-item-createdat`,title:A(e.createdAt),children:O(e.createdAt,n)})]}),e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-item-status-badge`,style:I(r.find(t=>t.name===e.status)?.color??null),children:e.status})]}),(e.nextActionDate!==null||e.nextActionHour!==null||e.dependedIssueUrls.length>0)&&(0,x.jsxs)(`span`,{className:`console-item-fields`,children:[e.nextActionDate!==null&&(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Next Action Date`}),e.nextActionDate.slice(0,10)]}),e.nextActionHour!==null&&(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Next Action Hour`}),e.nextActionHour]}),e.dependedIssueUrls.length>0&&(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Depended Issue URL`}),e.dependedIssueUrls.join(`, `)]})]}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-item-status-agent`,children:(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Agent`}),e.agent]})})]})}),xe=({story:e,count:t,colorEnum:n})=>{let r=F(n);return(0,x.jsxs)(`div`,{className:`console-group-header`,children:[(0,x.jsxs)(`span`,{className:`console-storytag`,children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:r.dot}}),e]}),(0,x.jsx)(`span`,{className:`console-group-count`,children:t})]})},Se=({rows:e,storyColors:t,statusOptions:n=[],activeItemId:r,now:i,isLoading:a,error:o,onSelectItem:s,executiveSummaries:c,onOkAndAwaitingWorkspace:l})=>o===null?a?(0,x.jsx)(`p`,{className:`console-list-message`,children:`Loading list...`}):e.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No items`}):(0,x.jsx)(`ul`,{className:`console-list`,children:e.map(e=>{if(e.kind===`group-header`)return(0,x.jsx)(`li`,{className:`console-list-group`,children:(0,x.jsx)(xe,{story:e.story,count:e.count,colorEnum:R(t,e.story)})},`group:${e.story}`);let a=c?.[e.item.projectItemId]??null;return(0,x.jsxs)(`li`,{className:`console-list-row`,children:[(0,x.jsx)(be,{item:e.item,isActive:e.item.itemId===r,now:i,statusOptions:n,onSelect:s}),a!==null&&a!==``&&(0,x.jsx)(`span`,{className:`console-item-executive-summary`,children:a}),l!==void 0&&(0,x.jsx)(ge,{statusOptions:n,onOkAndAwaitingWorkspace:t=>l(e.item,t)})]},e.item.itemId)})}):(0,x.jsxs)(`p`,{role:`alert`,className:`console-list-message console-list-error`,children:[`Failed to load list: `,o]}),Ce=({agentOptions:e,agentCounts:t,selectedAgent:n,onAgentChange:r})=>{let i=e.filter(e=>(t[e.name]??0)>0);return i.length===0?null:(0,x.jsx)(`div`,{className:`console-prs-agent-filter`,children:(0,x.jsxs)(`select`,{value:n??``,onChange:e=>r(e.target.value===``?null:e.target.value),"aria-label":`Filter by agent`,children:[(0,x.jsx)(`option`,{value:``,children:`All agents`}),i.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.name,` (`,t[e.name],`)`]},e.id))]})})},we=e=>({...I(e),fontSize:`12px`,whiteSpace:`nowrap`,flexShrink:0}),Te=({item:e,isActive:t,statusOptions:n,agentOptions:r,onSelect:i})=>{let a=n.find(t=>t.name===e.status),o=r.find(t=>t.name===e.agent);return(0,x.jsxs)(`button`,{type:`button`,className:`console-item-row console-queued-item-row`,"aria-current":t?`true`:void 0,"data-active":t?`true`:void 0,onClick:()=>i(e),children:[(0,x.jsx)(ye,{isPr:e.isPr,state:`open`,merged:!1,isDraft:!1,stateReason:``}),(0,x.jsx)(`span`,{className:`console-queued-item-title`,children:e.title}),(0,x.jsxs)(`span`,{className:`console-queued-item-badges`,children:[e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:we(a?.color??null),children:e.status}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:we(o?.color??null),children:e.agent})]}),(0,x.jsx)(`span`,{className:`console-queued-item-actions`})]})},Ee=({rows:e,storyColors:t,statusOptions:n,agentOptions:r,activeItemId:i,isLoading:a,error:o,onSelectItem:s})=>o===null?a?(0,x.jsx)(`p`,{className:`console-list-message`,children:`Loading list...`}):e.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No items`}):(0,x.jsx)(`ul`,{className:`console-list`,children:e.map(e=>e.kind===`group-header`?(0,x.jsx)(`li`,{className:`console-list-group`,children:(0,x.jsx)(xe,{story:e.story,count:e.count,colorEnum:R(t,e.story)})},`group:${e.story}`):(0,x.jsx)(`li`,{className:`console-list-row`,children:(0,x.jsx)(Te,{item:e.item,isActive:e.item.itemId===i,statusOptions:n,agentOptions:r,onSelect:s})},e.item.itemId))}):(0,x.jsxs)(`p`,{role:`alert`,className:`console-list-message console-list-error`,children:[`Failed to load list: `,o]}),De=Object.keys(P),Oe=({placeholder:e,emptyValueError:t,onSubmit:n,onCancel:r,initialValue:i=``,submitLabel:a=`Create`,selectAllOnFocus:o=!1,multiline:s=!1})=>{let[c,l]=(0,y.useState)(i),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),m=(0,y.useRef)(null),h=(0,y.useRef)(null),g=(0,y.useRef)(o);(0,y.useEffect)(()=>{s?(h.current?.focus(),g.current&&h.current?.select()):(m.current?.focus(),g.current&&m.current?.select())},[s]);let _=async()=>{let e=c.trim();if(e.length===0&&t!==``){p(t);return}d(!0),p(null);try{await n(e)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,x.jsxs)(`form`,{className:`console-inline-input-form`,onSubmit:e=>{e.preventDefault(),_()},children:[s?(0,x.jsx)(`textarea`,{ref:h,className:`console-inline-input-form-textarea`,placeholder:e,value:c,onChange:e=>l(e.target.value),disabled:u,rows:3}):(0,x.jsx)(`input`,{ref:m,type:`text`,className:`console-inline-input-form-input`,placeholder:e,value:c,onChange:e=>l(e.target.value),disabled:u}),(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:u,children:u?`${a.replace(/e$/,``)}ing…`:a}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:r,disabled:u,children:`Cancel`}),f!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:f})]})},ke=({storyName:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Oe,{placeholder:`Issue title`,emptyValueError:`Title is required`,onSubmit:n=>t(e,n),onCancel:n}),Ae=({currentName:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Oe,{placeholder:`Story name`,emptyValueError:`Story name is required`,initialValue:e,submitLabel:`Rename`,selectAllOnFocus:!0,onSubmit:t,onCancel:n}),je=({currentDescription:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Oe,{placeholder:`Story description`,emptyValueError:``,initialValue:e,submitLabel:`Save`,selectAllOnFocus:!0,multiline:!0,onSubmit:t,onCancel:n}),Me=({onSelectColor:e,disabled:t})=>(0,x.jsx)(`div`,{className:`console-story-color-palette`,children:De.map(n=>{let r=P[n];return(0,x.jsx)(`button`,{type:`button`,className:`console-story-color-swatch`,"aria-label":n===`GRAY`?`${n} (disable)`:n,style:{backgroundColor:r.dot},onClick:()=>e(n),disabled:t,children:n===`GRAY`&&(0,x.jsx)(`span`,{className:`console-story-color-swatch-label`,children:`disable`})},n)})}),Ne=({storyName:e,isDeleting:t,deleteError:n,onConfirm:r,onCancel:i})=>(0,x.jsxs)(`div`,{className:`console-story-delete-confirm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Confirm story deletion`,children:[(0,x.jsxs)(`p`,{className:`console-story-delete-confirm-message`,children:[`Delete story option "`,e,`" from the GitHub custom field?`]}),n!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:n}),(0,x.jsxs)(`div`,{className:`console-story-delete-confirm-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>r(!0),disabled:t,children:t?`Deleting…`:`Delete with child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>r(!1),disabled:t,children:t?`Deleting…`:`Keep child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:i,disabled:t,children:`Cancel`})]})]}),Pe=({items:e})=>(0,x.jsx)(`ul`,{className:`console-story-task-list`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`console-story-task-row`,children:[(0,x.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`console-story-task-title`,children:e.title}),(0,x.jsx)(`span`,{className:`console-story-task-status`,children:e.status??`—`}),(0,x.jsx)(`span`,{className:`console-story-task-agent`,children:e.agent??`—`}),(0,x.jsx)(`span`,{className:`console-story-task-depended-urls`,children:e.dependedIssueUrls.length>0?e.dependedIssueUrls.join(`, `):`—`}),(0,x.jsx)(`span`,{className:`console-story-task-next-action-date`,children:e.nextActionDate===null?`—`:e.nextActionDate.slice(0,10)}),(0,x.jsx)(`span`,{className:`console-story-task-next-action-hour`,children:e.nextActionHour===null?`—`:String(e.nextActionHour)})]},e.url))}),Fe=({stories:e,isLoading:t,error:n,showGray:r,onCreateIssue:i,onAddStory:a,onSelectColor:o,onToggleGray:s,onReorderStory:c,onDeleteStory:l,onRenameStory:u,onUpdateDescription:d,optimisticColors:f,colorChangeInFlight:p,colorErrors:m})=>{let[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),[b,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(null),[T,ee]=(0,y.useState)({}),[te,E]=(0,y.useState)(null),[D,ne]=(0,y.useState)({}),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)(null),re=e=>T[e]??{inProgress:!1,error:null},M=async(e,t)=>{ee(t=>({...t,[e]:{inProgress:!0,error:null}}));try{await c(e,t),ee(t=>({...t,[e]:{inProgress:!1,error:null}}))}catch(t){ee(n=>({...n,[e]:{inProgress:!1,error:t instanceof Error?t.message:String(t)}}))}};if(n!==null)return(0,x.jsxs)(`p`,{role:`alert`,className:`console-list-message console-list-error`,children:[`Failed to load stories: `,n]});if(t)return(0,x.jsx)(`p`,{className:`console-list-message`,children:`Loading stories...`});let N=e=>{g(h===e?null:e)},ie=async(e,t)=>{await i(e,t),g(null)},ae=e=>{w(C===e?null:e)},P=(e,t)=>{w(null),o(e,t)},I=e=>{E(e)},L=async(e,t)=>{ne(t=>({...t,[e]:{isDeleting:!0,error:null}}));try{await l(e,t),E(null),ne(t=>({...t,[e]:{isDeleting:!1,error:null}}))}catch(t){ne(n=>({...n,[e]:{isDeleting:!1,error:t instanceof Error?t.message:String(t)}}))}},oe=()=>{E(null),ne({})},R=e=>{k(O===e?null:e)},se=async(e,t)=>{await u(e,t),k(null)},z=e=>{j(A===e?null:e)},ce=async(e,t)=>{await d(e,t),j(null)},le=r?e:e.filter(e=>e.color!==`GRAY`),B=e.some(e=>e.color===`GRAY`);return(0,x.jsxs)(`div`,{className:`console-story-list-container`,children:[le.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No active stories`}):(0,x.jsx)(`ul`,{className:`console-story-list`,children:le.map((e,t)=>{let n=F(f[e.storyOptionId]??e.color),r=h===e.storyOptionId,i=C===e.storyOptionId,a=p===e.storyOptionId,o=m[e.storyOptionId]??null,{inProgress:s,error:c}=re(e.storyOptionId),l=t===0,u=t===le.length-1,d=te===e.storyOptionId,y=D[e.storyOptionId]??{isDeleting:!1,error:null},b=O===e.storyOptionId,S=A===e.storyOptionId,w=_===e.storyOptionId,T=e.description??``;return(0,x.jsxs)(`li`,{className:`console-story-list-row`,children:[(0,x.jsxs)(`div`,{className:`console-story-list-row-main`,children:[e.storyViewUrl?(0,x.jsxs)(`a`,{href:e.storyViewUrl,target:`_blank`,rel:`noopener noreferrer`,className:`console-storytag`,style:{color:n.fg,borderColor:n.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:n.dot}}),e.storyName]}):(0,x.jsxs)(`span`,{className:`console-storytag`,style:{color:n.fg,borderColor:n.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:n.dot}}),e.storyName]}),(0,x.jsx)(`span`,{className:`console-story-count`,children:e.openItemCount}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>N(e.storyOptionId),children:`Add task`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>ae(e.storyOptionId),disabled:a,children:`Change color`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move up`,disabled:l||s,onClick:()=>void M(e.storyOptionId,`up`),children:`↑`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move down`,disabled:u||s,onClick:()=>void M(e.storyOptionId,`down`),children:`↓`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,"aria-label":`Delete story`,onClick:()=>I(e.storyOptionId),children:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Rename story`,onClick:()=>R(e.storyOptionId),children:`Rename`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Edit description`,onClick:()=>z(e.storyOptionId),children:`Edit description`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>v(w?null:e.storyOptionId),children:w?`Hide tasks`:`Show tasks`})]}),T!==``&&(0,x.jsx)(`p`,{className:`console-story-description`,children:T}),w&&(0,x.jsx)(Pe,{items:e.items}),c!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:c}),i&&(0,x.jsx)(Me,{onSelectColor:t=>P(e.storyOptionId,t),disabled:a}),o!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:o}),r&&(0,x.jsx)(ke,{storyName:e.storyName,onSubmit:ie,onCancel:()=>g(null)}),d&&(0,x.jsx)(Ne,{storyName:e.storyName,isDeleting:y.isDeleting,deleteError:y.error,onConfirm:t=>void L(e.storyOptionId,t),onCancel:oe}),b&&(0,x.jsx)(Ae,{currentName:e.storyName,onSubmit:t=>se(e.storyOptionId,t),onCancel:()=>k(null)}),S&&(0,x.jsx)(je,{currentDescription:T,onSubmit:t=>ce(e.storyOptionId,t),onCancel:()=>j(null)})]},e.storyOptionId)})}),B&&(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:s,children:r?`Hide archived`:`Show archived`}),(0,x.jsxs)(`div`,{className:`console-add-story-section`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>S(!b),children:`Add story`}),b&&(0,x.jsx)(Oe,{placeholder:`Story name`,emptyValueError:`Story name is required`,onSubmit:async e=>{await a(e),S(!1)},onCancel:()=>S(!1)})]})]})},Ie=e=>`${e.isPr?`PR`:`Issue`} #${e.itemNumber}`,Le=e=>e===null?`loading…`:e,Re=e=>{let t=[];return t.push(`CI: ${e.isCiStateSuccess?`pass`:`fail`}`),t.push(`Merge: ${e.mergeableStatus.toLowerCase()}`),e.isBranchOutOfDate&&t.push(`branch out of date`),t.join(` · `)},ze=e=>e.fetchError?`${Ie(e)} — failed to load current state`:e.currentTitle===null?`${Ie(e)} — loading current state…`:`${Ie(e)} — ${e.currentTitle} (${Le(e.currentState)})`,Be=({actions:e,isOnline:t,isConfirming:n,onConfirm:r,onDiscard:i})=>e.length===0?null:(0,x.jsxs)(`section`,{className:`console-offline-panel`,"aria-label":`Offline actions queue`,children:[(0,x.jsxs)(`div`,{className:`console-offline-panel-header`,children:[e.length,` action`,e.length===1?``:`s`,` held`,t?` — confirm each before sending`:` — awaiting connectivity`]}),e.map(e=>(0,x.jsxs)(`div`,{className:`console-offline-panel-item console-offline-panel-item-${e.color}`,children:[(0,x.jsx)(`div`,{className:`console-offline-panel-item-message`,children:e.message}),(0,x.jsx)(`div`,{className:`console-offline-panel-item-target`,children:ze(e)}),e.fetchError&&(0,x.jsx)(`div`,{className:`console-offline-panel-item-fetch-error`,children:`Failed to load current state — sending will act on the last known state`}),t&&e.isPr&&e.currentPrStatus!==null&&!e.fetchError&&(0,x.jsx)(`div`,{className:`console-offline-panel-item-pr-status`,children:Re(e.currentPrStatus)}),(0,x.jsxs)(`div`,{className:`console-offline-panel-item-controls`,children:[t&&(0,x.jsx)(`button`,{type:`button`,className:`console-offline-panel-confirm`,disabled:n||e.currentTitle===null&&!e.fetchError,onClick:()=>r(e.id),children:`Send`}),(0,x.jsx)(`button`,{type:`button`,className:`console-offline-panel-discard`,onClick:()=>i(e.id),children:`Discard`})]})]},e.id))]}),Ve=({message:e,color:t,remainingSeconds:n,progress:r,onUndo:i})=>(0,x.jsxs)(`div`,{className:`console-undo-toast console-undo-toast-${t}`,role:`status`,"aria-live":`polite`,children:[(0,x.jsx)(`span`,{className:`console-undo-toast-message`,children:e}),(0,x.jsx)(`button`,{type:`button`,className:`console-undo-toast-undo`,onClick:i,children:`Undo`}),(0,x.jsxs)(`span`,{className:`console-undo-toast-countdown`,"aria-hidden":`true`,children:[n,`s`]}),(0,x.jsx)(`span`,{className:`console-undo-toast-bar`,"aria-hidden":`true`,style:{width:`${Math.max(0,Math.min(100,r*100))}%`}})]}),He=({title:e,message:t,onDismiss:n,onRetry:r})=>(0,x.jsxs)(`div`,{className:`console-undo-toast-error console-error-toast`,role:`alert`,"aria-live":`assertive`,children:[e!==void 0&&(0,x.jsx)(`span`,{className:`console-error-toast-title`,children:e}),(0,x.jsx)(`span`,{className:`console-error-toast-message`,children:t}),(0,x.jsxs)(`div`,{className:`console-error-toast-actions`,children:[r!==void 0&&(0,x.jsx)(`button`,{type:`button`,className:`console-error-toast-retry`,onClick:r,children:`Retry`}),(0,x.jsx)(`button`,{type:`button`,className:`console-error-toast-dismiss`,onClick:n,children:`Dismiss`})]})]}),Ue=(e,t)=>Object.keys(t.items).length===0&&t.failures.length>0?{status:`error`,failures:t.failures}:{status:`on`,snapshot:{capturedAt:t.capturedAt,tabs:e===null?t.tabs:{...e.tabs,...t.tabs},items:e===null?t.items:{...e.items,...t.items},failures:t.failures}},We=`tdpm-airplane-v1`,Ge=`/airplane-snapshot-data`,Ke=`tdpm_airplane_mode_on`,qe=()=>typeof localStorage>`u`?!1:localStorage.getItem(Ke)===`1`,Je=e=>{typeof localStorage>`u`||(e?localStorage.setItem(Ke,`1`):localStorage.removeItem(Ke))},Ye=async e=>{if(typeof caches>`u`)throw Error(`Cache API unavailable`);try{await(await caches.open(We)).put(Ge,new Response(JSON.stringify(e),{headers:{"Content-Type":`application/json`}}))}catch(e){throw e instanceof Error&&e.name===`QuotaExceededError`?Error(`Not enough browser storage to save the offline snapshot. Free up storage and retry.`):e}},Xe=async()=>{if(typeof caches>`u`)return null;let e=await(await caches.open(We)).match(Ge);return e===void 0?null:e.json()},Ze=async()=>{typeof caches>`u`||await caches.delete(We)},Qe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$e=e=>typeof e==`string`?e:``,et=e=>typeof e==`number`?e:0,tt=e=>e===!0,nt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],rt=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,it=e=>Qe(e)?{number:et(e.number),title:$e(e.title),url:$e(e.url),repo:$e(e.repo),nameWithOwner:$e(e.nameWithOwner),projectItemId:$e(e.projectItemId),itemId:$e(e.itemId),isPr:tt(e.isPr),story:$e(e.story),status:typeof e.status==`string`?e.status:null,nextActionDate:typeof e.nextActionDate==`string`?e.nextActionDate:null,nextActionHour:typeof e.nextActionHour==`number`?e.nextActionHour:null,dependedIssueUrls:nt(e.dependedIssueUrls),labels:nt(e.labels),createdAt:$e(e.createdAt),relatedOpenPullRequestUrls:nt(e.relatedOpenPullRequestUrls),agent:typeof e.agent==`string`?e.agent:null}:null,at=e=>{if(!Qe(e))return{items:[],generatedAt:``,statusOptions:[],agentOptions:[],storyOptions:[],storyColors:{},stories:[],defaultNameWithOwner:null,fromCache:!1,storyOrder:[],timerEndsAt:null,timerTotalSeconds:null};let t=Array.isArray(e.items)?e.items.map(it).filter(e=>e!==null):[],n=Array.isArray(e.statusOptions)?e.statusOptions.filter(Qe):[],r=Array.isArray(e.agentOptions)?e.agentOptions.filter(Qe):[],i=Array.isArray(e.storyOptions)?e.storyOptions.filter(Qe):[],a=Array.isArray(e.stories)?e.stories.filter(Qe):[],o=Array.isArray(e.storyOrder)?e.storyOrder.filter(e=>typeof e==`string`):[];return{items:t,generatedAt:typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:n,agentOptions:r,storyOptions:i,storyColors:Qe(e.storyColors)?e.storyColors:{},stories:a,defaultNameWithOwner:typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,fromCache:!1,storyOrder:o,timerEndsAt:null,timerTotalSeconds:null}},ot=e=>Qe(e)?{author:$e(e.author),body:$e(e.body),createdAt:$e(e.createdAt)}:null,st=e=>Qe(e)?{path:$e(e.path),additions:et(e.additions),deletions:et(e.deletions),status:$e(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null}:null,ct=e=>Qe(e)?{sha:$e(e.sha),message:$e(e.message),author:$e(e.author),authoredAt:$e(e.authoredAt)}:null,lt=e=>Qe(e)?{found:tt(e.found),isConflicted:tt(e.isConflicted),mergeableStatus:rt(e.mergeableStatus),isPassedAllCiJob:tt(e.isPassedAllCiJob),isCiStateSuccess:tt(e.isCiStateSuccess),isBranchOutOfDate:tt(e.isBranchOutOfDate),missingRequiredCheckNames:nt(e.missingRequiredCheckNames)}:{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},ut=e=>{if(!Qe(e))return null;let t=Qe(e.summary)?{title:$e(e.summary.title),body:$e(e.summary.body),additions:et(e.summary.additions),deletions:et(e.summary.deletions),changedFiles:et(e.summary.changedFiles)}:null;return{url:$e(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:$e(e.createdAt),isDraft:tt(e.isDraft),isConflicted:tt(e.isConflicted),mergeableStatus:rt(e.mergeableStatus),isPassedAllCiJob:tt(e.isPassedAllCiJob),isCiStateSuccess:tt(e.isCiStateSuccess),isResolvedAllReviewComments:tt(e.isResolvedAllReviewComments),isBranchOutOfDate:tt(e.isBranchOutOfDate),missingRequiredCheckNames:nt(e.missingRequiredCheckNames),summary:t}},dt=e=>{if(!Qe(e))return{body:``,comments:[],state:{state:`open`,merged:!1,isPullRequest:!1,title:``},files:null,commits:null,prStatus:null,relatedPrs:null};let t=Qe(e.state)?e.state:{},n={state:$e(t.state)||`open`,merged:tt(t.merged),isPullRequest:tt(t.isPullRequest),title:$e(t.title)},r=e.files===null?null:Array.isArray(e.files)?e.files.map(st).filter(e=>e!==null):null,i=e.commits===null?null:Array.isArray(e.commits)?e.commits.map(ct).filter(e=>e!==null):null,a=e.prStatus===null?null:lt(e.prStatus),o=e.relatedPrs===null?null:Array.isArray(e.relatedPrs)?e.relatedPrs.map(ut).filter(e=>e!==null):null;return{body:$e(e.body),comments:Array.isArray(e.comments)?e.comments.map(ot).filter(e=>e!==null):[],state:n,files:r,commits:i,prStatus:a,relatedPrs:o}},ft=e=>{if(!Qe(e))return null;let t=typeof e.capturedAt==`string`?e.capturedAt:``,n=nt(e.failures),r={};if(Qe(e.tabs))for(let[t,n]of Object.entries(e.tabs)){if(!Qe(n))continue;let e={};for(let[t,r]of Object.entries(n))e[t]=at(r);r[t]=e}let i={};if(Qe(e.items))for(let[t,n]of Object.entries(e.items))i[t]=dt(n);return{capturedAt:t,tabs:r,items:i,failures:n}},pt=`/api/airplanesync`,mt=e=>{try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)&&`type`in t&&typeof t.type==`string`?t:null}catch{return null}},ht=()=>{let[e,t]=(0,y.useState)(`off`),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),c=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!qe())return;let e=!1;return Xe().then(n=>{e||n===null||(a(n),t(`on`))}).catch(()=>{Je(!1)}),()=>{e=!0}},[]);let l=(0,y.useCallback)(async(e,n)=>{let i=e.getReader(),o=new TextDecoder,c=``;for(;;){let{done:e,value:l}=await i.read();if(e)break;c+=o.decode(l,{stream:!0});let u=c.split(`
12
12
 
13
- `);c=u.pop()??``;for(let e of u){if(!e.startsWith(`data: `))continue;let i=mt(e.slice(6));if(i!==null){if(i.type===`progress`)r({fetched:typeof i.fetched==`number`?i.fetched:0,total:typeof i.total==`number`?i.total:0});else if(i.type===`done`){let e=ft(i.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}let r=Ue(n,e);if(r.status===`error`){s(r.failures),t(`error`);return}let o=ft(r.snapshot);if(o===null){t(`error`),s([`Failed to merge snapshot`]);return}await Ye(o),Je(!0),a(o),t(`on`),s(o.failures)}}}}},[]),u=(0,y.useCallback)(()=>{c.current!==null&&c.current.abort();let e=new AbortController;c.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),fetch(pt,{signal:e.signal}).then(async e=>{if(!e.ok||e.body===null){t(`error`),s([`HTTP ${e.status}`]);return}await l(e.body,null)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]),d=(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),Je(!1),Ze().catch(()=>{})},[]),f=(0,y.useCallback)((e,n)=>{if(n.length===0)return;c.current!==null&&c.current.abort();let i=new AbortController;c.current=i,t(`syncing`),r({fetched:0,total:n.length}),s([]),fetch(pt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targetUrls:n}),signal:i.signal}).then(async n=>{if(!n.ok||n.body===null){t(`error`),s([`HTTP ${n.status}`]);return}await l(n.body,e)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]);return{status:e,progress:n,snapshot:i,failures:o,startSync:u,turnOff:d,retryFailed:()=>f(i,o)}},gt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),V=e=>typeof e==`string`?e:``,_t=e=>typeof e==`number`?e:0,vt=e=>e===!0,yt=`console-api-v1`,bt=async(e,t)=>{let n=`${e}?url=${encodeURIComponent(t)}`;try{let e=await fetch(n);if(!e.ok){let t=`HTTP ${e.status}`;try{let n=await e.json();gt(n)&&typeof n.error==`string`&&n.error.length>0&&(t=n.error)}catch(e){console.warn(`Failed to parse error body from non-ok response:`,e)}throw Error(t)}let t=await e.json();try{`caches`in globalThis&&globalThis.caches.open(yt).then(e=>e.put(n,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist API response to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}return t}catch(e){try{if(`caches`in globalThis){let e=await(await globalThis.caches.open(yt)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},xt=e=>!gt(e)||!Array.isArray(e.comments)?[]:e.comments.filter(gt).map(e=>({author:V(e.author),body:V(e.body),createdAt:V(e.createdAt)})),St=e=>!gt(e)||!Array.isArray(e.files)?[]:e.files.filter(gt).map(e=>({path:V(e.path)||V(e.filename),additions:_t(e.additions),deletions:_t(e.deletions),status:V(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Ct=e=>!gt(e)||!Array.isArray(e.commits)?[]:e.commits.filter(gt).map(e=>({sha:V(e.sha),message:V(e.message),author:V(e.author),authoredAt:V(e.authoredAt)})),wt=e=>gt(e)?{title:V(e.title),body:V(e.body),additions:_t(e.additions),deletions:_t(e.deletions),changedFiles:_t(e.changedFiles)}:null,Tt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Et=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,Dt=e=>!gt(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(gt).map(e=>({url:V(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:V(e.createdAt),isDraft:vt(e.isDraft),isConflicted:vt(e.isConflicted),mergeableStatus:Et(e.mergeableStatus),isPassedAllCiJob:vt(e.isPassedAllCiJob),isCiStateSuccess:vt(e.isCiStateSuccess),isResolvedAllReviewComments:vt(e.isResolvedAllReviewComments),isBranchOutOfDate:vt(e.isBranchOutOfDate),missingRequiredCheckNames:Tt(e.missingRequiredCheckNames),summary:wt(e.summary)})),Ot=e=>{if(!gt(e)||!gt(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:vt(t.isConflicted),mergeableStatus:Et(t.mergeableStatus),isPassedAllCiJob:vt(t.isPassedAllCiJob),isCiStateSuccess:vt(t.isCiStateSuccess),isBranchOutOfDate:vt(t.isBranchOutOfDate),missingRequiredCheckNames:Tt(t.missingRequiredCheckNames)}},kt=e=>gt(e)?{state:V(e.state)||`open`,merged:vt(e.merged),isPullRequest:vt(e.isPullRequest),title:V(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},At=()=>({fetchItemBody:async e=>{let t=await bt(`/api/itembody`,e);return gt(t)?V(t.body):``},fetchComments:async e=>xt(await bt(`/api/comments`,e)),fetchPrFiles:async e=>St(await bt(`/api/prfiles`,e)),fetchPrCommits:async e=>Ct(await bt(`/api/prcommits`,e)),fetchRelatedPrs:async e=>Dt(await bt(`/api/relatedprs`,e)),fetchIssueState:async e=>kt(await bt(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Ot(await bt(`/api/pullrequeststatus`,e))}),jt=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(gt(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Mt=async(e,t)=>{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(await jt(n))},Nt=`/api/comment`,Pt=e=>({author:V(e.author),body:V(e.body),createdAt:V(e.createdAt)}),Ft=async e=>{let t=await fetch(Nt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await jt(t),rateLimitResetAt:null};let n=await t.json();return gt(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:gt(n.comment)?{posted:!0,comment:Pt(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},It=`/api/upload`,Lt=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Rt=async e=>{let t=await fetch(It,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t));let n=await t.json();if(!gt(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},zt=`/api/addstory`,Bt=async e=>{let t=await fetch(zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Vt=`/api/reviewcomment`,Ht=async e=>{let t=await fetch(Vt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Ut=`/api/createissue`,Wt=`/api/storycolor`,Gt=async e=>{let t=await fetch(Wt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Kt=async e=>{let t=await fetch(Ut,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t));let n=await t.json();if(!(e=>typeof e==`object`&&!!e&&!Array.isArray(e))(n)||typeof n.issueUrl!=`string`)throw Error(`issueUrl was not returned`);return n.issueUrl},qt=`/api/reorderstory`,Jt=async e=>{let t=await fetch(qt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Yt=`/api/deleteallcomments`,Xt=async e=>{let t=await fetch(Yt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Zt=`/api/deletestory`,Qt=async e=>{let t=await fetch(Zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},$t=`/api/renamestory`,en=async e=>{let t=await fetch($t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},tn=`/api/storydescription`,nn=async e=>{let t=await fetch(tn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},rn=e=>typeof e!=`object`||!e||Array.isArray(e)?null:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`)),an=async()=>{let e=await fetch(`/api/projects`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if(typeof t!=`object`||!t||Array.isArray(t))return{pjcodes:[],projectUrls:null,fleetTaskCreateUrl:null,nameWithOwnerByPjcode:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:rn(n.projectUrls),fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null,nameWithOwnerByPjcode:rn(n.nameWithOwnerByPjcode)}},on=`/api/projectreadmeconfig`,sn=async e=>{let t=`${on}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await jt(n));let r=await n.json();return{maximumPreparingIssuesCount:gt(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},cn=`/api/renameissue`,ln=async e=>{let t=await fetch(cn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},un=`/api/setdependedissueurl`,dn=async e=>{let t=await fetch(un,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},fn=`/api/projectsettings`,pn=async e=>{let t=await fetch(fn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},mn=5e3,hn=e=>`${e.isPr?`PR #`:`#`}${e.number}`,gn=(e,t)=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`Approved & Merged`:e.action===`request_changes`?`Rejected`:e.action===`totally_wrong`?`Marked totally wrong`:`Marked unnecessary`;case`next_action_date`:return e.action===`snooze_1hour`?`Next Action Hour +1 hour`:e.action===`snooze_3hours`?`Next Action Hour +3 hours`:e.action===`snooze_6hours`?`Next Action Hour +6 hours`:e.action===`snooze_1day`?`Next Action Date +1 day`:e.action===`snooze_2days`?`Next Action Date +2 days`:e.action===`snooze_3days`?`Next Action Date +3 days`:e.action===`snooze_5days`?`Next Action Date +5 days`:e.action===`snooze_1month`?`Next Action Date +1 month`:he(t)?`Next Action Date +1 week and skip`:`Next Action Date +1 week`;case`set_story`:return`Story → ${e.optionName}`;case`set_agent`:return`Agent → ${e.optionName}`;case`set_status`:return`Status → ${e.optionName}`;case`set_in_tmux_by_human`:return`Added to In Tmux by human`;case`ok_and_awaiting_workspace`:return`ok → Awaiting Workspace`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},_n=e=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`green`:e.action===`request_changes`?`amber`:e.action===`totally_wrong`?`red`:`gray`;case`next_action_date`:return`amber`;case`set_story`:case`set_agent`:case`set_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},vn=(e,t)=>e.type===`next_action_date`?he(t):e.type!==`delete_all_comments`,yn=(e,t,n)=>`${gn(e,n)} — ${hn(t)}`,bn=`console-comment-expanded:`,xn=e=>{try{let t=localStorage.getItem(bn+e);if(t===null)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch(e){return console.error(`Failed to load comment expanded state from storage:`,e),new Set}},Sn=(e,t)=>{try{localStorage.setItem(bn+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Cn=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(bn)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},wn=`console-offline-action-queue`,Tn=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.message==`string`&&typeof t.color==`string`&&typeof t.enqueuedAt==`number`&&typeof t.itemUrl==`string`&&typeof t.projectItemId==`string`&&typeof t.itemNumber==`number`&&typeof t.repo==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},En=()=>{try{let e=localStorage.getItem(wn);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(Tn):[]}catch{return[]}},Dn=e=>{localStorage.setItem(wn,JSON.stringify(e))},On=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`,kn=e=>e instanceof TypeError,An=e=>e instanceof Error&&e.message.length>0?e.message:String(e),jn=100,Mn=e=>Math.max(0,Math.ceil((mn-e)/1e3)),Nn=e=>Math.max(0,1-e/mn),Pn=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(En),o=(0,y.useRef)(i);o.current=i;let s=(0,y.useRef)(null),c=(0,y.useRef)(0),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useRef)(()=>{}),f=(0,y.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),p=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:On(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return Dn(n),n})},[]),m=(0,y.useCallback)(e=>{e.commit().catch(t=>{kn(t)&&e.offline!==void 0?p(e):r({message:e.message,reason:An(t),retry:()=>d.current(e)})})},[p]);d.current=m;let h=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,Cn(),m(e))},[f,m]),g=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.()},[f]),_=(0,y.useCallback)(()=>{r(null)},[]),v=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),b=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return Dn(n),n})},[]),x=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Mt(t.apiPath,t.requestBody),b(e)}catch(n){kn(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:An(n)}),b(e))}},[b]),S=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;f(),u.current=!0,Cn(),m(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Mn(0),progress:Nn(0)}),e.advance(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){h();return}t({message:e.message,color:e.color,remainingSeconds:Mn(n),progress:Nn(n)})},jn)},[f,h,m]);return(0,y.useEffect)(()=>h,[h]),{pending:e,error:n,offlineActions:i,enqueue:S,showError:v,undo:g,dismissError:_,confirmOfflineAction:x,discardOfflineAction:b}},Fn=class{fetcher;cache=new Map;inFlight=new Map;prefetchInFlight=new Set;constructor(e){this.fetcher=e}peek=e=>this.cache.get(e);has=e=>this.cache.has(e);load=(e,t)=>{let n=this.cache.get(e);if(n!==void 0)return Promise.resolve(n);let r=this.inFlight.get(e);if(r!==void 0)return r;let i=this.fetcher(t).then(t=>(this.cache.set(e,t),t)).finally(()=>{this.inFlight.delete(e)});return this.inFlight.set(e,i),i};prefetch=(e,t)=>{this.cache.has(e)||this.inFlight.has(e)||this.prefetchInFlight.has(e)||(this.prefetchInFlight.add(e),this.fetcher(t).then(t=>{this.cache.set(e,t)}).catch(()=>{}).finally(()=>{this.prefetchInFlight.delete(e)}))};seed(e,t){this.cache.set(e,t)}invalidate=e=>{this.cache.delete(e)}},In=e=>{try{let t=new URL(e).pathname.split(`/`).filter(Boolean);if(t.length>=4)return`${t[0]}/${t[1]}#${t[3]}`}catch{}return e},Ln=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=In(n);e.body.seed(t,r.body),e.comments.seed(t,r.comments),e.state.seed(t,r.state),r.files!==null&&e.files.seed(t,r.files),r.commits!==null&&e.commits.seed(t,r.commits),r.prStatus!==null&&e.prStatus.seed(t,r.prStatus),r.relatedPrs!==null&&e.relatedPrs.seed(t,r.relatedPrs)}},Rn=(e=null)=>(0,y.useMemo)(()=>{let t=At(),n={client:t,body:new Fn(t.fetchItemBody),comments:new Fn(t.fetchComments),files:new Fn(t.fetchPrFiles),commits:new Fn(t.fetchPrCommits),relatedPrs:new Fn(t.fetchRelatedPrs),state:new Fn(t.fetchIssueState),prStatus:new Fn(t.fetchPullRequestStatus)};return e!==null&&Ln(n,e),n},[e]),zn=0,Bn=500,Vn=2e3,Hn=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:Vn});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},Un=(e,t)=>{let n=`${t.repo}#${t.number}`;e.body.prefetch(n,t.url),e.state.prefetch(n,t.url),e.comments.prefetch(n,t.url),t.isPr?(e.files.prefetch(n,t.url),e.commits.prefetch(n,t.url),e.prStatus.prefetch(n,t.url)):e.relatedPrs.prefetch(n,t.url)},Wn=(e,t,n)=>{(0,y.useEffect)(()=>{if(t===null)return;let r=n.findIndex(e=>e.projectItemId===t.projectItemId);if(r===-1)return;let i=n.slice(r+1,r+1+zn);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=Hn(()=>{for(let t of i)Un(e,t)})},Bn);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},Gn=`/api/features`,Kn=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(Gn).then(async e=>{if(!e.ok)return;let n=await e.json();typeof n==`object`&&n&&!Array.isArray(n)&&`airplaneMode`in n&&typeof n.airplaneMode==`boolean`&&t({airplaneMode:n.airplaneMode})}).catch(e=>{console.warn(`Failed to fetch /api/features`,e)})},[]),e},qn=(e,t)=>{let n=j.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<j.length;e+=1){let n=j[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},Jn=e=>{let t=j.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},Yn=new Set(j.map(e=>e.name)),Xn=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return Yn.has(n)?n:null},Zn=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Qn=`#settings`,$n=(e,t)=>{let n=(0,y.useCallback)(()=>{let e=Jn(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:Xn(window.location.pathname)??e,selectedItemKey:Zn(window.location.hash)}},[t]),[r,i]=(0,y.useState)(n),a=(0,y.useRef)(null);a.current=e,(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{i(n())};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[n]),(0,y.useEffect)(()=>{if(typeof window>`u`||Xn(window.location.pathname)!==null)return;let e=Jn(t);Object.values(t).some(e=>e>0)&&a.current!==null&&window.history.replaceState({},``,`/projects/${a.current}/${e}${window.location.search}`),i(t=>t.activeTab===e?t:{...t,activeTab:e})},[t]);let o=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),s=(0,y.useCallback)(e=>{if(typeof window>`u`){i({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,o(e)),i({activeTab:e,selectedItemKey:null})},[o]),c=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),i(t=>({...t,selectedItemKey:e}))},[]),l=(0,y.useCallback)(()=>{if(typeof window<`u`&&window.location.hash!==``){let e=`${window.location.pathname}${window.location.search}`;window.history.pushState({},``,e)}i(e=>({...e,selectedItemKey:null}))},[]);return{activeTab:r.activeTab,selectedItemKey:r.selectedItemKey,tabHref:o,selectTab:s,openItem:c,closeItem:l}},er=e=>`pv_overlay_${e}`,tr=e=>e.projectItemId===``?e.itemId:e.projectItemId,nr=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,rr=(e,t,n)=>e.filter(e=>!nr(t[tr(e)],n)).length,ir=(e,t,n)=>e.filter(e=>!nr(t[tr(e)],n)),ar=(e,t)=>{let n=Date.parse(t);if(Number.isNaN(n))return{};let r={};for(let[t,i]of Object.entries(e))i.ts>=n&&(r[t]=i);return r},or=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[tr(t)];return i===void 0||i.ts<r?null:i.status??null},sr=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},cr=`/api/review`,lr=`/api/triage`,ur=`/api/intmux`,dr=(e,t,n,r,i)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:de(i),...r===void 0?{}:{changedFilePath:r.path,line:r.line,side:r.side}}}return r===`totally_wrong`?{pjcode:e,action:`close`,prUrl:n,issueUrl:t.url,projectItemId:t.projectItemId,commentBody:le}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:B,issueCommentBody:ue(n)}},fr=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),pr=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),mr=()=>Error(`No project specified in the URL path.`),hr=`ok`,gr=(e,t,n,r,i)=>{let{patchOverlay:a}=n,o=(0,y.useCallback)(e=>{if(r===void 0)return;let t=`${e.repo}#${e.number}`;r.body.invalidate(t),r.comments.invalidate(t)},[r]),s=(0,y.useCallback)(e=>{a(tr(e),{done:!0},t)},[a,t]),c=(0,y.useCallback)(async(t,n,r,i=[])=>{if(e===null)throw mr();await Mt(cr,dr(e,t,n,r,i)),s(t),o(t)},[e,s,o]),l=(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Mt(lr,r),o(t)},[e,s,o]),u=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_agent`,issueUrl:n.url,projectItemId:n.projectItemId,agentOptionId:r.id};a(tr(n),{done:!0},t),await Mt(lr,i),o(n)},[e,o,a,t]),d=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_story`,issueUrl:n.url,projectItemId:n.projectItemId,storyOptionId:r.id};a(tr(n),{done:!0,story:{name:r.name,color:r.color}},t),await Mt(lr,i),o(n)},[e,o,a,t]),f=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name};a(tr(n),{done:!0,status:{name:r.name,color:r.color}},t),await Mt(lr,i),o(n)},[e,o,a,t]),p=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_intmux`,issueUrl:n.url,projectItemId:n.projectItemId};a(tr(n),{done:!0,status:{name:r.name,color:r.color}},t),await Mt(ur,i),o(n)},[e,o,a,t]),m=(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Mt(lr,r),o(t)},[e,s,o]),h=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();a(tr(n),{done:!0,status:{name:r.name,color:r.color}},t);let s=await Ft({pjcode:e,url:n.url,body:hr});if(await Mt(lr,{pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name}),o(n),await i?.(),!s.posted){let e=s.rateLimitResetAt===null?``:` Rate limit resets at ${s.rateLimitResetAt}.`;throw Error(`Comment not posted — ${s.error}.${e} Status was changed. Re-post: ${hr}`)}},[e,o,a,t,i]),g=(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();let r=await Ft({pjcode:e,url:t.url,body:n});if(!r.posted){let e=r.rateLimitResetAt===null?``:` Rate limit resets at ${r.rateLimitResetAt}.`;throw Error(`${r.error}.${e}`)}return o(t),r.comment},[e,o]),_=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=Lt(new Uint8Array(await n.arrayBuffer()));return Rt({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),v=(0,y.useCallback)((e,n,r)=>{a(tr(e),{done:n,...r===void 0?{}:{status:r}},t)},[a,t]);return{reviewPullRequest:c,setNextActionDate:l,setStory:d,setAgent:u,setStatus:f,setInTmuxByHuman:p,closeIssue:m,okAndMoveToAwaitingWorkspace:h,addComment:g,uploadAttachment:_,addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw mr();await Ht({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),issueRename:(0,y.useCallback)(async(e,t)=>{await ln({issueUrl:e.url,newTitle:t})},[]),deleteAllComments:(0,y.useCallback)(async e=>{await Xt({issueUrl:e.url}),o(e)},[o]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();await dn({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e]),patchItemOverlay:v}},_r=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,vr=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(er(e));if(t===null)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{};let r={};for(let[e,t]of Object.entries(n))_r(t)&&(r[e]=t);return r},yr=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(er(e),JSON.stringify(t))},br=e=>{let[t,n]=(0,y.useState)(()=>vr(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=sr(n,t,r,i,Date.now());return yr(e,a),a})},[e])}},xr=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<2||t[0]!==`projects`)return null;let n=t[1];return n.length===0?null:n},Sr=()=>{let[e,t]=(0,y.useState)(()=>xr(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(xr(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},Cr=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return l(!0),d(null),an().then(n=>{e||(t(n.pjcodes),r(n.projectUrls),a(n.fleetTaskCreateUrl),s(n.nameWithOwnerByPjcode),l(!1))}).catch(t=>{e||(d(t instanceof Error?t:Error(String(t))),l(!1))}),()=>{e=!0}},[]),{pjcodes:e,projectUrls:n,fleetTaskCreateUrl:i,nameWithOwnerByPjcode:o,isLoading:c,error:u}},wr=e=>(0,y.useCallback)(t=>{Cn(),e(t)},[e]),Tr=()=>typeof window<`u`&&window.location.hash===`#settings`,Er=e=>{let[t,n]=(0,y.useState)(Tr),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)({}),d=(0,y.useRef)(``),f=(0,y.useRef)(e);f.current=e,(0,y.useEffect)(()=>{if(!t)return;let e=!1;return u({}),i(!0),c(null),Promise.all(f.current.map(e=>sn(e).then(t=>({pjcode:e,value:t.maximumPreparingIssuesCount===null?``:String(t.maximumPreparingIssuesCount)})))).then(t=>{if(!e){let e={};for(let{pjcode:n,value:r}of t)e[n]=r;u(e)}}).catch(t=>{e||c(t instanceof Error?t.message:`Failed to load settings`)}).finally(()=>{e||i(!1)}),()=>{e=!0}},[t]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.location.hash===Qn;e||c(null),n(e)};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]);let p=(0,y.useCallback)(()=>{typeof window<`u`&&(d.current=window.location.hash,window.history.pushState({},``,Qn)),n(!0)},[]),m=(0,y.useCallback)(()=>{if(typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1),c(null)},[]),h=(0,y.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),g=(0,y.useCallback)(async()=>{o(!0),c(null);try{if(await Promise.all(Object.entries(l).filter(([,e])=>{let t=parseInt(e,10);return!Number.isNaN(t)&&t>=0}).map(([e,t])=>pn({pjcode:e,maximumPreparingIssuesCount:parseInt(t,10)}))),typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1)}catch(e){c(e instanceof Error?e.message:`Failed to save settings`)}finally{o(!1)}},[l]);return(0,y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&m()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,m]),{isOpen:t,isLoading:r,isSaving:a,error:s,inputValues:l,open:p,close:m,changeInput:h,save:g}},Dr=e=>{let t=(0,y.useRef)(e),n=(0,y.useRef)(Date.now());return t.current!==e&&(t.current=e,n.current=Date.now()),{isTimerExpired:(0,y.useCallback)(e=>e<=0?!1:Date.now()-n.current>=e*60*1e3,[])}},Or=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,kr=/^From:\s+:robot:/m,Ar=/^##\s/m,jr=e=>{let t=Or.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=kr.exec(n),i=Ar.exec(n),a=n.length;r!==null&&(a=Math.min(a,r.index)),i!==null&&(a=Math.min(a,i.index));let o=n.slice(0,a).trim();return o.length>0?o:null},Mr=e=>{if(e.length===0)return null;let t=e[e.length-1],n=jr(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},Nr=e=>`${e.repo}#${e.number}`,Pr=(e,t,n)=>{let[r,i]=(0,y.useState)({});return(0,y.useEffect)(()=>{if(!n)return;let r=!1;for(let n of e){let e=Nr(n),a=t.peek(e);if(a!==void 0){let e=Mr(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e});continue}t.load(e,n.url).then(e=>{if(r)return;let t=Mr(e);i(e=>e[n.projectItemId]===t?e:{...e,[n.projectItemId]:t})}).catch(()=>{r||i(e=>e[n.projectItemId]===null?e:{...e,[n.projectItemId]:null})})}return()=>{r=!0}},[e,t,n]),r},Fr=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},Ir=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},Lr=e=>{let t=e instanceof Element?e:null;for(;t!==null&&t!==document.body;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth&&t.scrollLeft>0)return!0;t=t.parentElement}return!1},Rr=e=>{let t=(0,y.useRef)(e);t.current=e;let n=(0,y.useRef)(null),r=(0,y.useCallback)(e=>{let n=0,r=0,i=!1,a=e=>{if(e.touches.length!==1){i=!1;return}if(Lr(e.target)){i=!1;return}let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},o=e=>{if(!i)return;let t=e.touches[0];Ir(t.clientX-n,t.clientY-r)&&(i=!1)},s=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let a=e.changedTouches[0],o=Fr(a.clientX-n,a.clientY-r);o!==null&&t.current(o)};return e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),()=>{e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s)}},[]),i=(0,y.useCallback)(e=>{n.current!==null&&(n.current(),n.current=null),e!==null&&(n.current=r(e))},[r]);return(0,y.useEffect)(()=>()=>{n.current!==null&&(n.current(),n.current=null)},[]),i},zr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Br=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Vr=e=>Array.isArray(e)?e.filter(zr).map(e=>({...e,relatedOpenPullRequestUrls:Br(e.relatedOpenPullRequestUrls)})):[],Hr=e=>!zr(e)||!Array.isArray(e.items)?[]:Vr(e.items),Ur=e=>Array.isArray(e)?e.filter(zr):[],Wr=e=>Array.isArray(e)?e.filter(zr).map(e=>({...e,items:Vr(e.items)})):[],Gr=e=>({items:Hr(e),generatedAt:zr(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:zr(e)?Ur(e.statusOptions):[],agentOptions:zr(e)?Ur(e.agentOptions):[],storyOptions:zr(e)?Ur(e.storyOptions):[],storyColors:zr(e)&&zr(e.storyColors)?e.storyColors:{},stories:zr(e)?Wr(e.stories):[],defaultNameWithOwner:zr(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:zr(e)?Br(e.storyOrder):[],timerEndsAt:zr(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:zr(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Kr=()=>{let e={};for(let t of j)e[t.name]=null;return e},qr=(e,t)=>`/projects/${e}/${t}/list.json`,Jr=6e4,Yr=`console-list-v1`,Xr=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(Yr).then(n=>n.put(e,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist tab snapshot to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}},Zr=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(Yr)).match(e);return t===void 0?null:{...Gr(await t.json()),fromCache:!0}}catch{return null}},Qr=async e=>{let t=await Promise.all(j.map(async t=>({tabName:t.name,snapshot:await Zr(qr(e,t.name))}))),n=Kr();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},$r=async(e,t)=>{let n=qr(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Xr(n,t),{snapshot:{...Gr(t),fromCache:!1},error:null}}catch(e){let t=await Zr(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},ei=async e=>{let t=await Promise.all(j.map(async t=>{let{snapshot:n,error:r}=await $r(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Kr(),r=null;for(let{tabName:e,snapshot:i,error:a}of t)n[e]=i,a!==null&&r===null&&(r=a);return{snapshots:n,firstError:Object.values(n).every(e=>e===null)?r:null}},ti=(e,t=null)=>{let n=(0,y.useRef)(new Map),[r,i]=(0,y.useState)(Kr),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(e);if(l!==e){u(e);let t=e===null?null:n.current.get(e)??null;i(t??Kr()),t!==null&&o(!1)}return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Kr();for(let t of j){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}i(e),o(!1),c(null);return}}let r=!1,a=!1;if(c(null),e===null)return i(Kr()),o(!1),c(`No project specified in the URL path.`),()=>{r=!0};let s=n.current.has(e);Qr(e).then(t=>{if(r)return;let c=Object.values(t).some(e=>e!==null);c&&!a?(n.current.set(e,t),i(t),o(!1)):!c&&!a&&!s&&(o(!0),i(Kr()))});let l=()=>{ei(e).then(({snapshots:t,firstError:s})=>{r||(a=!0,n.current.set(e,t),i(t),c(s===null?null:s.message),o(!1))}).catch(e=>{r||(a=!0,c(e instanceof Error?e.message:String(e)),o(!1))})};l();let u=setInterval(l,Jr);return()=>{r=!0,clearInterval(u)}},[e,t]),{snapshots:r,isLoading:a,error:s,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:r}=await $r(e,t);r!==null&&i(i=>{let a={...i,[t]:r};return n.current.set(e,a),a})},[e])}},ni=e=>(0,y.useCallback)(t=>{Cn(),e(t)},[e]),ri=(e,t,n,r,i)=>{let a=(0,y.useRef)(void 0),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(!e){a.current=t,o.current=!1;return}a.current!==t&&(a.current=t,o.current=t!==null),!(!o.current||r!==null)&&n.length!==0&&(o.current=!1,i(n[0].projectItemId))},[e,t,n,r,i])},ii=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},ai=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},oi=`tdpm-timer-settings`,si=()=>({timerMode:!1,projectMinutes:{}}),ci=()=>{if(typeof localStorage>`u`)return si();let e=localStorage.getItem(oi);if(e===null)return si();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return si();let n=t,r=typeof n.timerMode==`boolean`&&n.timerMode,i=n.projectMinutes;return{timerMode:r,projectMinutes:typeof i==`object`&&i&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(([,e])=>typeof e==`number`).map(([e,t])=>[e,t])):{}}}catch{return si()}},li=e=>{typeof localStorage<`u`&&localStorage.setItem(oi,JSON.stringify(e))},ui=(e,t,n)=>{if(e.length===0)return null;let r=t===null?-1:e.indexOf(t),i=r===-1?0:(r+1)%e.length,a=r===-1?e.length:e.length-1;for(let t=0;t<a;t++){let r=e[(i+t)%e.length];if((n[r]??0)>0)return r}return null},di=(e,t,n,r,i,a,o,s,c,l)=>{let u=(0,y.useRef)(0),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e||r===null){u.current=0,d.current=null;return}if(!o||!s||c||l||d.current===r)return;if(t>0||n>0){d.current=r,u.current=0;return}if(i.length===0)return;let f=i.filter(e=>(a[e]??0)>0);if(u.current>=f.length-1){d.current=r,u.current=0;return}d.current=r,u.current+=1;let p=ui(i,r,a);p===null?u.current=0:ii(`/projects/${p}`)},[e,t,n,r,i,a,o,s,c,l])},fi=()=>{let[e,t]=(0,y.useState)(ci),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(e),o=(0,y.useCallback)(()=>{t(e=>(a(e),e)),r(!0)},[]),s=(0,y.useCallback)(()=>{r(!1)},[]),c=(0,y.useCallback)(()=>{a(e=>(li(e),t(e),e)),r(!1)},[]),l=(0,y.useCallback)(e=>{a(t=>({...t,timerMode:e}))},[]),u=(0,y.useCallback)((e,t)=>{a(n=>({...n,projectMinutes:{...n.projectMinutes,[e]:t}}))},[]);return{timerMode:e.timerMode,projectMinutes:e.projectMinutes,isOpen:n,draftTimerMode:i.timerMode,draftProjectMinutes:i.projectMinutes,openSettings:o,closeSettings:s,saveSettings:c,toggleDraftTimerMode:l,changeDraftMinutes:u}},pi=(e,t)=>{let n=e.indexOf(t);if(n<0)return e.length>0?e[0]:null;let r=n+1;return r<e.length?e[r]:null},mi=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},hi=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},gi=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
13
+ `);c=u.pop()??``;for(let e of u){if(!e.startsWith(`data: `))continue;let i=mt(e.slice(6));if(i!==null){if(i.type===`progress`)r({fetched:typeof i.fetched==`number`?i.fetched:0,total:typeof i.total==`number`?i.total:0});else if(i.type===`done`){let e=ft(i.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}let r=Ue(n,e);if(r.status===`error`){s(r.failures),t(`error`);return}let o=ft(r.snapshot);if(o===null){t(`error`),s([`Failed to merge snapshot`]);return}await Ye(o),Je(!0),a(o),t(`on`),s(o.failures)}}}}},[]),u=(0,y.useCallback)(()=>{c.current!==null&&c.current.abort();let e=new AbortController;c.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),fetch(pt,{signal:e.signal}).then(async e=>{if(!e.ok||e.body===null){t(`error`),s([`HTTP ${e.status}`]);return}await l(e.body,null)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]),d=(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),Je(!1),Ze().catch(()=>{})},[]),f=(0,y.useCallback)((e,n)=>{if(n.length===0)return;c.current!==null&&c.current.abort();let i=new AbortController;c.current=i,t(`syncing`),r({fetched:0,total:n.length}),s([]),fetch(pt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targetUrls:n}),signal:i.signal}).then(async n=>{if(!n.ok||n.body===null){t(`error`),s([`HTTP ${n.status}`]);return}await l(n.body,e)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]);return{status:e,progress:n,snapshot:i,failures:o,startSync:u,turnOff:d,retryFailed:()=>f(i,o)}},gt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),V=e=>typeof e==`string`?e:``,_t=e=>typeof e==`number`?e:0,vt=e=>e===!0,yt=`console-api-v1`,bt=async(e,t)=>{let n=`${e}?url=${encodeURIComponent(t)}`;try{let e=await fetch(n);if(!e.ok){let t=`HTTP ${e.status}`;try{let n=await e.json();gt(n)&&typeof n.error==`string`&&n.error.length>0&&(t=n.error)}catch(e){console.warn(`Failed to parse error body from non-ok response:`,e)}throw Error(t)}let t=await e.json();try{`caches`in globalThis&&globalThis.caches.open(yt).then(e=>e.put(n,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist API response to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}return t}catch(e){try{if(`caches`in globalThis){let e=await(await globalThis.caches.open(yt)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},xt=e=>!gt(e)||!Array.isArray(e.comments)?[]:e.comments.filter(gt).map(e=>({author:V(e.author),body:V(e.body),createdAt:V(e.createdAt)})),St=e=>!gt(e)||!Array.isArray(e.files)?[]:e.files.filter(gt).map(e=>({path:V(e.path)||V(e.filename),additions:_t(e.additions),deletions:_t(e.deletions),status:V(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Ct=e=>!gt(e)||!Array.isArray(e.commits)?[]:e.commits.filter(gt).map(e=>({sha:V(e.sha),message:V(e.message),author:V(e.author),authoredAt:V(e.authoredAt)})),wt=e=>gt(e)?{title:V(e.title),body:V(e.body),additions:_t(e.additions),deletions:_t(e.deletions),changedFiles:_t(e.changedFiles)}:null,Tt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Et=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,Dt=e=>!gt(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(gt).map(e=>({url:V(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:V(e.createdAt),isDraft:vt(e.isDraft),isConflicted:vt(e.isConflicted),mergeableStatus:Et(e.mergeableStatus),isPassedAllCiJob:vt(e.isPassedAllCiJob),isCiStateSuccess:vt(e.isCiStateSuccess),isResolvedAllReviewComments:vt(e.isResolvedAllReviewComments),isBranchOutOfDate:vt(e.isBranchOutOfDate),missingRequiredCheckNames:Tt(e.missingRequiredCheckNames),summary:wt(e.summary)})),Ot=e=>{if(!gt(e)||!gt(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:vt(t.isConflicted),mergeableStatus:Et(t.mergeableStatus),isPassedAllCiJob:vt(t.isPassedAllCiJob),isCiStateSuccess:vt(t.isCiStateSuccess),isBranchOutOfDate:vt(t.isBranchOutOfDate),missingRequiredCheckNames:Tt(t.missingRequiredCheckNames)}},kt=e=>gt(e)?{state:V(e.state)||`open`,merged:vt(e.merged),isPullRequest:vt(e.isPullRequest),title:V(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},At=()=>({fetchItemBody:async e=>{let t=await bt(`/api/itembody`,e);return gt(t)?V(t.body):``},fetchComments:async e=>xt(await bt(`/api/comments`,e)),fetchPrFiles:async e=>St(await bt(`/api/prfiles`,e)),fetchPrCommits:async e=>Ct(await bt(`/api/prcommits`,e)),fetchRelatedPrs:async e=>Dt(await bt(`/api/relatedprs`,e)),fetchIssueState:async e=>kt(await bt(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Ot(await bt(`/api/pullrequeststatus`,e))}),jt=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(gt(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Mt=async(e,t)=>{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(await jt(n))},Nt=`/api/comment`,Pt=e=>({author:V(e.author),body:V(e.body),createdAt:V(e.createdAt)}),Ft=async e=>{let t=await fetch(Nt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await jt(t),rateLimitResetAt:null};let n=await t.json();return gt(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:gt(n.comment)?{posted:!0,comment:Pt(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},It=`/api/upload`,Lt=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Rt=async e=>{let t=await fetch(It,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t));let n=await t.json();if(!gt(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},zt=`/api/addstory`,Bt=async e=>{let t=await fetch(zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Vt=`/api/reviewcomment`,Ht=async e=>{let t=await fetch(Vt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Ut=`/api/createissue`,Wt=`/api/storycolor`,Gt=async e=>{let t=await fetch(Wt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Kt=async e=>{let t=await fetch(Ut,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t));let n=await t.json();if(!(e=>typeof e==`object`&&!!e&&!Array.isArray(e))(n)||typeof n.issueUrl!=`string`)throw Error(`issueUrl was not returned`);return n.issueUrl},qt=`/api/reorderstory`,Jt=async e=>{let t=await fetch(qt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Yt=`/api/deleteallcomments`,Xt=async e=>{let t=await fetch(Yt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},Zt=`/api/deletestory`,Qt=async e=>{let t=await fetch(Zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},$t=`/api/renamestory`,en=async e=>{let t=await fetch($t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},tn=`/api/storydescription`,nn=async e=>{let t=await fetch(tn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},rn=e=>typeof e!=`object`||!e||Array.isArray(e)?null:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`)),an=async()=>{let e=await fetch(`/api/projects`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if(typeof t!=`object`||!t||Array.isArray(t))return{pjcodes:[],projectUrls:null,fleetTaskCreateUrl:null,nameWithOwnerByPjcode:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:rn(n.projectUrls),fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null,nameWithOwnerByPjcode:rn(n.nameWithOwnerByPjcode)}},on=`/api/projectreadmeconfig`,sn=async e=>{let t=`${on}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await jt(n));let r=await n.json();return{maximumPreparingIssuesCount:gt(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},cn=`/api/renameissue`,ln=async e=>{let t=await fetch(cn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},un=`/api/setdependedissueurl`,dn=async e=>{let t=await fetch(un,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},fn=`/api/projectsettings`,pn=async e=>{let t=await fetch(fn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await jt(t))},mn=5e3,hn=e=>`${e.isPr?`PR #`:`#`}${e.number}`,gn=(e,t)=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`Approved & Merged`:e.action===`request_changes`?`Rejected`:e.action===`totally_wrong`?`Marked totally wrong`:`Marked unnecessary`;case`next_action_date`:return e.action===`snooze_1hour`?`Next Action Hour +1h`:e.action===`snooze_3hours`?`Next Action Hour +3h`:e.action===`snooze_6hours`?`Next Action Hour +6h`:e.action===`snooze_1day`?`Next Action Date +1d`:e.action===`snooze_2days`?`Next Action Date +2d`:e.action===`snooze_3days`?`Next Action Date +3d`:e.action===`snooze_5days`?`Next Action Date +5d`:e.action===`snooze_1month`?`Next Action Date +1mo`:he(t)?`Next Action Date +1w skip`:`Next Action Date +1w`;case`set_story`:return`Story → ${e.optionName}`;case`set_agent`:return`Agent → ${e.optionName}`;case`set_status`:return`Status → ${e.optionName}`;case`set_in_tmux_by_human`:return`Added to In Tmux by human`;case`ok_and_awaiting_workspace`:return`ok → Awaiting Workspace`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},_n=e=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`green`:e.action===`request_changes`?`amber`:e.action===`totally_wrong`?`red`:`gray`;case`next_action_date`:return`amber`;case`set_story`:case`set_agent`:case`set_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},vn=(e,t)=>e.type===`next_action_date`?he(t):e.type!==`delete_all_comments`,yn=(e,t,n)=>`${gn(e,n)} — ${hn(t)}`,bn=`console-comment-expanded:`,xn=e=>{try{let t=localStorage.getItem(bn+e);if(t===null)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch(e){return console.error(`Failed to load comment expanded state from storage:`,e),new Set}},Sn=(e,t)=>{try{localStorage.setItem(bn+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Cn=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(bn)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},wn=`console-offline-action-queue`,Tn=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.message==`string`&&typeof t.color==`string`&&typeof t.enqueuedAt==`number`&&typeof t.itemUrl==`string`&&typeof t.projectItemId==`string`&&typeof t.itemNumber==`number`&&typeof t.repo==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},En=()=>{try{let e=localStorage.getItem(wn);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(Tn):[]}catch{return[]}},Dn=e=>{localStorage.setItem(wn,JSON.stringify(e))},On=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`,kn=e=>e instanceof TypeError,An=e=>e instanceof Error&&e.message.length>0?e.message:String(e),jn=100,Mn=e=>Math.max(0,Math.ceil((mn-e)/1e3)),Nn=e=>Math.max(0,1-e/mn),Pn=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(En),o=(0,y.useRef)(i);o.current=i;let s=(0,y.useRef)(null),c=(0,y.useRef)(0),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useRef)(()=>{}),f=(0,y.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),p=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:On(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return Dn(n),n})},[]),m=(0,y.useCallback)(e=>{e.commit().catch(t=>{kn(t)&&e.offline!==void 0?p(e):r({message:e.message,reason:An(t),retry:()=>d.current(e)})})},[p]);d.current=m;let h=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,Cn(),m(e))},[f,m]),g=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.()},[f]),_=(0,y.useCallback)(()=>{r(null)},[]),v=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),b=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return Dn(n),n})},[]),x=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Mt(t.apiPath,t.requestBody),b(e)}catch(n){kn(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:An(n)}),b(e))}},[b]),S=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;f(),u.current=!0,Cn(),m(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Mn(0),progress:Nn(0)}),e.advance(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){h();return}t({message:e.message,color:e.color,remainingSeconds:Mn(n),progress:Nn(n)})},jn)},[f,h,m]);return(0,y.useEffect)(()=>h,[h]),{pending:e,error:n,offlineActions:i,enqueue:S,showError:v,undo:g,dismissError:_,confirmOfflineAction:x,discardOfflineAction:b}},Fn=class{fetcher;cache=new Map;inFlight=new Map;prefetchInFlight=new Set;constructor(e){this.fetcher=e}peek=e=>this.cache.get(e);has=e=>this.cache.has(e);load=(e,t)=>{let n=this.cache.get(e);if(n!==void 0)return Promise.resolve(n);let r=this.inFlight.get(e);if(r!==void 0)return r;let i=this.fetcher(t).then(t=>(this.cache.set(e,t),t)).finally(()=>{this.inFlight.delete(e)});return this.inFlight.set(e,i),i};prefetch=(e,t)=>{this.cache.has(e)||this.inFlight.has(e)||this.prefetchInFlight.has(e)||(this.prefetchInFlight.add(e),this.fetcher(t).then(t=>{this.cache.set(e,t)}).catch(()=>{}).finally(()=>{this.prefetchInFlight.delete(e)}))};seed(e,t){this.cache.set(e,t)}invalidate=e=>{this.cache.delete(e)}},In=e=>{try{let t=new URL(e).pathname.split(`/`).filter(Boolean);if(t.length>=4)return`${t[0]}/${t[1]}#${t[3]}`}catch{}return e},Ln=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=In(n);e.body.seed(t,r.body),e.comments.seed(t,r.comments),e.state.seed(t,r.state),r.files!==null&&e.files.seed(t,r.files),r.commits!==null&&e.commits.seed(t,r.commits),r.prStatus!==null&&e.prStatus.seed(t,r.prStatus),r.relatedPrs!==null&&e.relatedPrs.seed(t,r.relatedPrs)}},Rn=(e=null)=>(0,y.useMemo)(()=>{let t=At(),n={client:t,body:new Fn(t.fetchItemBody),comments:new Fn(t.fetchComments),files:new Fn(t.fetchPrFiles),commits:new Fn(t.fetchPrCommits),relatedPrs:new Fn(t.fetchRelatedPrs),state:new Fn(t.fetchIssueState),prStatus:new Fn(t.fetchPullRequestStatus)};return e!==null&&Ln(n,e),n},[e]),zn=0,Bn=500,Vn=2e3,Hn=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:Vn});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},Un=(e,t)=>{let n=`${t.repo}#${t.number}`;e.body.prefetch(n,t.url),e.state.prefetch(n,t.url),e.comments.prefetch(n,t.url),t.isPr?(e.files.prefetch(n,t.url),e.commits.prefetch(n,t.url),e.prStatus.prefetch(n,t.url)):e.relatedPrs.prefetch(n,t.url)},Wn=(e,t,n)=>{(0,y.useEffect)(()=>{if(t===null)return;let r=n.findIndex(e=>e.projectItemId===t.projectItemId);if(r===-1)return;let i=n.slice(r+1,r+1+zn);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=Hn(()=>{for(let t of i)Un(e,t)})},Bn);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},Gn=`/api/features`,Kn=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(Gn).then(async e=>{if(!e.ok)return;let n=await e.json();typeof n==`object`&&n&&!Array.isArray(n)&&`airplaneMode`in n&&typeof n.airplaneMode==`boolean`&&t({airplaneMode:n.airplaneMode})}).catch(e=>{console.warn(`Failed to fetch /api/features`,e)})},[]),e},qn=(e,t)=>{let n=j.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<j.length;e+=1){let n=j[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},Jn=e=>{let t=j.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},Yn=new Set(j.map(e=>e.name)),Xn=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return Yn.has(n)?n:null},Zn=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Qn=`#settings`,$n=(e,t)=>{let n=(0,y.useCallback)(()=>{let e=Jn(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:Xn(window.location.pathname)??e,selectedItemKey:Zn(window.location.hash)}},[t]),[r,i]=(0,y.useState)(n),a=(0,y.useRef)(null);a.current=e,(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{i(n())};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[n]),(0,y.useEffect)(()=>{if(typeof window>`u`||Xn(window.location.pathname)!==null)return;let e=Jn(t);Object.values(t).some(e=>e>0)&&a.current!==null&&window.history.replaceState({},``,`/projects/${a.current}/${e}${window.location.search}`),i(t=>t.activeTab===e?t:{...t,activeTab:e})},[t]);let o=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),s=(0,y.useCallback)(e=>{if(typeof window>`u`){i({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,o(e)),i({activeTab:e,selectedItemKey:null})},[o]),c=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),i(t=>({...t,selectedItemKey:e}))},[]),l=(0,y.useCallback)(()=>{if(typeof window<`u`&&window.location.hash!==``){let e=`${window.location.pathname}${window.location.search}`;window.history.pushState({},``,e)}i(e=>({...e,selectedItemKey:null}))},[]);return{activeTab:r.activeTab,selectedItemKey:r.selectedItemKey,tabHref:o,selectTab:s,openItem:c,closeItem:l}},er=e=>`pv_overlay_${e}`,tr=e=>e.projectItemId===``?e.itemId:e.projectItemId,nr=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,rr=(e,t,n)=>e.filter(e=>!nr(t[tr(e)],n)).length,ir=(e,t,n)=>e.filter(e=>!nr(t[tr(e)],n)),ar=(e,t)=>{let n=Date.parse(t);if(Number.isNaN(n))return{};let r={};for(let[t,i]of Object.entries(e))i.ts>=n&&(r[t]=i);return r},or=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[tr(t)];return i===void 0||i.ts<r?null:i.status??null},sr=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},cr=`/api/review`,lr=`/api/triage`,ur=`/api/intmux`,dr=(e,t,n,r,i)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:de(i),...r===void 0?{}:{changedFilePath:r.path,line:r.line,side:r.side}}}return r===`totally_wrong`?{pjcode:e,action:`close`,prUrl:n,issueUrl:t.url,projectItemId:t.projectItemId,commentBody:le}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:B,issueCommentBody:ue(n)}},fr=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),pr=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),mr=()=>Error(`No project specified in the URL path.`),hr=`ok`,gr=(e,t,n,r,i)=>{let{patchOverlay:a}=n,o=(0,y.useCallback)(e=>{if(r===void 0)return;let t=`${e.repo}#${e.number}`;r.body.invalidate(t),r.comments.invalidate(t)},[r]),s=(0,y.useCallback)(e=>{a(tr(e),{done:!0},t)},[a,t]),c=(0,y.useCallback)(async(t,n,r,i=[])=>{if(e===null)throw mr();await Mt(cr,dr(e,t,n,r,i)),s(t),o(t)},[e,s,o]),l=(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Mt(lr,r),o(t)},[e,s,o]),u=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_agent`,issueUrl:n.url,projectItemId:n.projectItemId,agentOptionId:r.id};a(tr(n),{done:!0},t),await Mt(lr,i),o(n)},[e,o,a,t]),d=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_story`,issueUrl:n.url,projectItemId:n.projectItemId,storyOptionId:r.id};a(tr(n),{done:!0,story:{name:r.name,color:r.color}},t),await Mt(lr,i),o(n)},[e,o,a,t]),f=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name};a(tr(n),{done:!0,status:{name:r.name,color:r.color}},t),await Mt(lr,i),o(n)},[e,o,a,t]),p=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();let i={pjcode:e,action:`set_intmux`,issueUrl:n.url,projectItemId:n.projectItemId};a(tr(n),{done:!0,status:{name:r.name,color:r.color}},t),await Mt(ur,i),o(n)},[e,o,a,t]),m=(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Mt(lr,r),o(t)},[e,s,o]),h=(0,y.useCallback)(async(n,r)=>{if(e===null)throw mr();a(tr(n),{done:!0,status:{name:r.name,color:r.color}},t);let s=await Ft({pjcode:e,url:n.url,body:hr});if(await Mt(lr,{pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name}),o(n),await i?.(),!s.posted){let e=s.rateLimitResetAt===null?``:` Rate limit resets at ${s.rateLimitResetAt}.`;throw Error(`Comment not posted — ${s.error}.${e} Status was changed. Re-post: ${hr}`)}},[e,o,a,t,i]),g=(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();let r=await Ft({pjcode:e,url:t.url,body:n});if(!r.posted){let e=r.rateLimitResetAt===null?``:` Rate limit resets at ${r.rateLimitResetAt}.`;throw Error(`${r.error}.${e}`)}return o(t),r.comment},[e,o]),_=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=Lt(new Uint8Array(await n.arrayBuffer()));return Rt({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),v=(0,y.useCallback)((e,n,r)=>{a(tr(e),{done:n,...r===void 0?{}:{status:r}},t)},[a,t]);return{reviewPullRequest:c,setNextActionDate:l,setStory:d,setAgent:u,setStatus:f,setInTmuxByHuman:p,closeIssue:m,okAndMoveToAwaitingWorkspace:h,addComment:g,uploadAttachment:_,addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw mr();await Ht({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),issueRename:(0,y.useCallback)(async(e,t)=>{await ln({issueUrl:e.url,newTitle:t})},[]),deleteAllComments:(0,y.useCallback)(async e=>{await Xt({issueUrl:e.url}),o(e)},[o]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw mr();await dn({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e]),patchItemOverlay:v}},_r=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,vr=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(er(e));if(t===null)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{};let r={};for(let[e,t]of Object.entries(n))_r(t)&&(r[e]=t);return r},yr=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(er(e),JSON.stringify(t))},br=e=>{let[t,n]=(0,y.useState)(()=>vr(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=sr(n,t,r,i,Date.now());return yr(e,a),a})},[e])}},xr=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<2||t[0]!==`projects`)return null;let n=t[1];return n.length===0?null:n},Sr=()=>{let[e,t]=(0,y.useState)(()=>xr(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(xr(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},Cr=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return l(!0),d(null),an().then(n=>{e||(t(n.pjcodes),r(n.projectUrls),a(n.fleetTaskCreateUrl),s(n.nameWithOwnerByPjcode),l(!1))}).catch(t=>{e||(d(t instanceof Error?t:Error(String(t))),l(!1))}),()=>{e=!0}},[]),{pjcodes:e,projectUrls:n,fleetTaskCreateUrl:i,nameWithOwnerByPjcode:o,isLoading:c,error:u}},wr=e=>(0,y.useCallback)(t=>{Cn(),e(t)},[e]),Tr=()=>typeof window<`u`&&window.location.hash===`#settings`,Er=e=>{let[t,n]=(0,y.useState)(Tr),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)({}),d=(0,y.useRef)(``),f=(0,y.useRef)(e);f.current=e,(0,y.useEffect)(()=>{if(!t)return;let e=!1;return u({}),i(!0),c(null),Promise.all(f.current.map(e=>sn(e).then(t=>({pjcode:e,value:t.maximumPreparingIssuesCount===null?``:String(t.maximumPreparingIssuesCount)})))).then(t=>{if(!e){let e={};for(let{pjcode:n,value:r}of t)e[n]=r;u(e)}}).catch(t=>{e||c(t instanceof Error?t.message:`Failed to load settings`)}).finally(()=>{e||i(!1)}),()=>{e=!0}},[t]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.location.hash===Qn;e||c(null),n(e)};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]);let p=(0,y.useCallback)(()=>{typeof window<`u`&&(d.current=window.location.hash,window.history.pushState({},``,Qn)),n(!0)},[]),m=(0,y.useCallback)(()=>{if(typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1),c(null)},[]),h=(0,y.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),g=(0,y.useCallback)(async()=>{o(!0),c(null);try{if(await Promise.all(Object.entries(l).filter(([,e])=>{let t=parseInt(e,10);return!Number.isNaN(t)&&t>=0}).map(([e,t])=>pn({pjcode:e,maximumPreparingIssuesCount:parseInt(t,10)}))),typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1)}catch(e){c(e instanceof Error?e.message:`Failed to save settings`)}finally{o(!1)}},[l]);return(0,y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&m()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,m]),{isOpen:t,isLoading:r,isSaving:a,error:s,inputValues:l,open:p,close:m,changeInput:h,save:g}},Dr=e=>{let t=(0,y.useRef)(e),n=(0,y.useRef)(Date.now());return t.current!==e&&(t.current=e,n.current=Date.now()),{isTimerExpired:(0,y.useCallback)(e=>e<=0?!1:Date.now()-n.current>=e*60*1e3,[])}},Or=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,kr=/^From:\s+:robot:/m,Ar=/^##\s/m,jr=e=>{let t=Or.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=kr.exec(n),i=Ar.exec(n),a=n.length;r!==null&&(a=Math.min(a,r.index)),i!==null&&(a=Math.min(a,i.index));let o=n.slice(0,a).trim();return o.length>0?o:null},Mr=e=>{if(e.length===0)return null;let t=e[e.length-1],n=jr(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},Nr=e=>`${e.repo}#${e.number}`,Pr=(e,t,n)=>{let[r,i]=(0,y.useState)({});return(0,y.useEffect)(()=>{if(!n)return;let r=!1;for(let n of e){let e=Nr(n),a=t.peek(e);if(a!==void 0){let e=Mr(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e});continue}t.load(e,n.url).then(e=>{if(r)return;let t=Mr(e);i(e=>e[n.projectItemId]===t?e:{...e,[n.projectItemId]:t})}).catch(()=>{r||i(e=>e[n.projectItemId]===null?e:{...e,[n.projectItemId]:null})})}return()=>{r=!0}},[e,t,n]),r},Fr=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},Ir=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},Lr=e=>{let t=e instanceof Element?e:null;for(;t!==null&&t!==document.body;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth&&t.scrollLeft>0)return!0;t=t.parentElement}return!1},Rr=e=>{let t=(0,y.useRef)(e);t.current=e;let n=(0,y.useRef)(null),r=(0,y.useCallback)(e=>{let n=0,r=0,i=!1,a=e=>{if(e.touches.length!==1){i=!1;return}if(Lr(e.target)){i=!1;return}let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},o=e=>{if(!i)return;let t=e.touches[0];Ir(t.clientX-n,t.clientY-r)&&(i=!1)},s=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let a=e.changedTouches[0],o=Fr(a.clientX-n,a.clientY-r);o!==null&&t.current(o)};return e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),()=>{e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s)}},[]),i=(0,y.useCallback)(e=>{n.current!==null&&(n.current(),n.current=null),e!==null&&(n.current=r(e))},[r]);return(0,y.useEffect)(()=>()=>{n.current!==null&&(n.current(),n.current=null)},[]),i},zr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Br=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Vr=e=>Array.isArray(e)?e.filter(zr).map(e=>({...e,relatedOpenPullRequestUrls:Br(e.relatedOpenPullRequestUrls)})):[],Hr=e=>!zr(e)||!Array.isArray(e.items)?[]:Vr(e.items),Ur=e=>Array.isArray(e)?e.filter(zr):[],Wr=e=>Array.isArray(e)?e.filter(zr).map(e=>({...e,items:Vr(e.items)})):[],Gr=e=>({items:Hr(e),generatedAt:zr(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:zr(e)?Ur(e.statusOptions):[],agentOptions:zr(e)?Ur(e.agentOptions):[],storyOptions:zr(e)?Ur(e.storyOptions):[],storyColors:zr(e)&&zr(e.storyColors)?e.storyColors:{},stories:zr(e)?Wr(e.stories):[],defaultNameWithOwner:zr(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:zr(e)?Br(e.storyOrder):[],timerEndsAt:zr(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:zr(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Kr=()=>{let e={};for(let t of j)e[t.name]=null;return e},qr=(e,t)=>`/projects/${e}/${t}/list.json`,Jr=6e4,Yr=`console-list-v1`,Xr=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(Yr).then(n=>n.put(e,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist tab snapshot to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}},Zr=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(Yr)).match(e);return t===void 0?null:{...Gr(await t.json()),fromCache:!0}}catch{return null}},Qr=async e=>{let t=await Promise.all(j.map(async t=>({tabName:t.name,snapshot:await Zr(qr(e,t.name))}))),n=Kr();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},$r=async(e,t)=>{let n=qr(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Xr(n,t),{snapshot:{...Gr(t),fromCache:!1},error:null}}catch(e){let t=await Zr(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},ei=async e=>{let t=await Promise.all(j.map(async t=>{let{snapshot:n,error:r}=await $r(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Kr(),r=null;for(let{tabName:e,snapshot:i,error:a}of t)n[e]=i,a!==null&&r===null&&(r=a);return{snapshots:n,firstError:Object.values(n).every(e=>e===null)?r:null}},ti=(e,t=null)=>{let n=(0,y.useRef)(new Map),[r,i]=(0,y.useState)(Kr),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(e);if(l!==e){u(e);let t=e===null?null:n.current.get(e)??null;i(t??Kr()),t!==null&&o(!1)}return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Kr();for(let t of j){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}i(e),o(!1),c(null);return}}let r=!1,a=!1;if(c(null),e===null)return i(Kr()),o(!1),c(`No project specified in the URL path.`),()=>{r=!0};let s=n.current.has(e);Qr(e).then(t=>{if(r)return;let c=Object.values(t).some(e=>e!==null);c&&!a?(n.current.set(e,t),i(t),o(!1)):!c&&!a&&!s&&(o(!0),i(Kr()))});let l=()=>{ei(e).then(({snapshots:t,firstError:s})=>{r||(a=!0,n.current.set(e,t),i(t),c(s===null?null:s.message),o(!1))}).catch(e=>{r||(a=!0,c(e instanceof Error?e.message:String(e)),o(!1))})};l();let u=setInterval(l,Jr);return()=>{r=!0,clearInterval(u)}},[e,t]),{snapshots:r,isLoading:a,error:s,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:r}=await $r(e,t);r!==null&&i(i=>{let a={...i,[t]:r};return n.current.set(e,a),a})},[e])}},ni=e=>(0,y.useCallback)(t=>{Cn(),e(t)},[e]),ri=(e,t,n,r,i)=>{let a=(0,y.useRef)(void 0),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(!e){a.current=t,o.current=!1;return}a.current!==t&&(a.current=t,o.current=t!==null),!(!o.current||r!==null)&&n.length!==0&&(o.current=!1,i(n[0].projectItemId))},[e,t,n,r,i])},ii=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},ai=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},oi=`tdpm-timer-settings`,si=()=>({timerMode:!1,projectMinutes:{}}),ci=()=>{if(typeof localStorage>`u`)return si();let e=localStorage.getItem(oi);if(e===null)return si();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return si();let n=t,r=typeof n.timerMode==`boolean`&&n.timerMode,i=n.projectMinutes;return{timerMode:r,projectMinutes:typeof i==`object`&&i&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(([,e])=>typeof e==`number`).map(([e,t])=>[e,t])):{}}}catch{return si()}},li=e=>{typeof localStorage<`u`&&localStorage.setItem(oi,JSON.stringify(e))},ui=(e,t,n)=>{if(e.length===0)return null;let r=t===null?-1:e.indexOf(t),i=r===-1?0:(r+1)%e.length,a=r===-1?e.length:e.length-1;for(let t=0;t<a;t++){let r=e[(i+t)%e.length];if((n[r]??0)>0)return r}return null},di=(e,t,n,r,i,a,o,s,c,l)=>{let u=(0,y.useRef)(0),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e||r===null){u.current=0,d.current=null;return}if(!o||!s||c||l||d.current===r)return;if(t>0||n>0){d.current=r,u.current=0;return}if(i.length===0)return;let f=i.filter(e=>(a[e]??0)>0);if(u.current>=f.length-1){d.current=r,u.current=0;return}d.current=r,u.current+=1;let p=ui(i,r,a);p===null?u.current=0:ii(`/projects/${p}`)},[e,t,n,r,i,a,o,s,c,l])},fi=()=>{let[e,t]=(0,y.useState)(ci),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(e),o=(0,y.useCallback)(()=>{t(e=>(a(e),e)),r(!0)},[]),s=(0,y.useCallback)(()=>{r(!1)},[]),c=(0,y.useCallback)(()=>{a(e=>(li(e),t(e),e)),r(!1)},[]),l=(0,y.useCallback)(e=>{a(t=>({...t,timerMode:e}))},[]),u=(0,y.useCallback)((e,t)=>{a(n=>({...n,projectMinutes:{...n.projectMinutes,[e]:t}}))},[]);return{timerMode:e.timerMode,projectMinutes:e.projectMinutes,isOpen:n,draftTimerMode:i.timerMode,draftProjectMinutes:i.projectMinutes,openSettings:o,closeSettings:s,saveSettings:c,toggleDraftTimerMode:l,changeDraftMinutes:u}},pi=(e,t)=>{let n=e.indexOf(t);if(n<0)return e.length>0?e[0]:null;let r=n+1;return r<e.length?e[r]:null},mi=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},hi=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},gi=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
14
14
  `)?`${e}${t}\n`:`${e}\n${t}\n`,_i=(e,t)=>{let n=`![uploading ${t}]()`;return`${e.length===0?``:e.replace(/\n*$/,`
15
15
  `)}\n\n\n${n}\n`},vi=(e,t,n)=>{let r=`![uploading ${t}]()`,i=e.indexOf(r);return i===-1?gi(e,n):e.slice(0,i)+n+e.slice(i+r.length)},yi=(e,t)=>{let n=`![uploading ${t}]()`,r=e.indexOf(n);if(r===-1)return e;let i=r,a=0;for(;a<3&&i>0&&e[i-1]===`
16
16
  `;)i--,a++;let o=+(e[r+n.length]===`
@@ -86,6 +86,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
86
86
  `)}),o+=1,i=null;continue}i.push(e);continue}if(Qs(e)){r.push(e),a=!0;continue}r.push(e)}return i!==null&&r.push("```mermaid",...i),s(),n},tc=Object.defineProperty,nc=(e,t)=>tc(e,`name`,{value:t,configurable:!0});function rc(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}nc(rc,`setRef`);function ic(...e){return t=>{let n=!1,r=e.map(e=>{let r=rc(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():rc(e[t],null)}}}}nc(ic,`composeRefs`);function ac(...e){return y.useCallback(ic(...e),e)}nc(ac,`useComposedRefs`);var oc=Object.defineProperty,sc=(e,t)=>oc(e,`name`,{value:t,configurable:!0});function cc(e){let t=y.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];_c(r)&&typeof xc==`function`&&(r=xc(r._payload)),y.Children.forEach(r,e=>{if(hc(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;_c(n)&&typeof xc==`function`&&(n=xc(n._payload)),a=fc(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=y.cloneElement(a,void 0,s):!o&&y.Children.count(r)===1&&y.isValidElement(r)&&(a=r);let c=a?mc(a):void 0,l=ac(n,c);if(!a){if(r||r===0)throw Error(o?bc(e):yc(e));return r}let u=pc(i,a.props??{});return a.type!==y.Fragment&&(u.ref=n?l:c),y.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}sc(cc,`createSlot`);var lc=cc(`Slot`),uc=Symbol.for(`radix.slottable`);function dc(e){let t=sc(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=uc,t}sc(dc,`createSlottable`);var fc=sc((e,t)=>{if(`child`in e.props){let t=e.props.child;return y.isValidElement(t)?y.cloneElement(t,void 0,e.props.children(t.props.children)):null}return y.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function pc(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}sc(pc,`mergeProps`);function mc(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}sc(mc,`getElementRef`);function hc(e){return y.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===uc}sc(hc,`isSlottable`);var gc=Symbol.for(`react.lazy`);function _c(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===gc&&`_payload`in e&&vc(e._payload)}sc(_c,`isLazyComponent`);function vc(e){return typeof e==`object`&&!!e&&`then`in e}sc(vc,`isPromiseLike`);var yc=sc(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),bc=sc(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),xc=y.use;function Sc(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Sc(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Cc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Sc(e))&&(r&&(r+=` `),r+=t);return r}var wc=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Tc=Cc,Ec=(e,t)=>n=>{if(t?.variants==null)return Tc(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=wc(t)||wc(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Tc(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Dc=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Oc=(e,t)=>({classGroupId:e,validator:t}),kc=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ac=`-`,jc=[],Mc=`arbitrary..`,Nc=e=>{let t=Ic(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Fc(e);let n=e.split(Ac);return Pc(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Dc(i,t):t:i||jc}return n[e]||jc}}},Pc=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Pc(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Ac):e.slice(t).join(Ac),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Fc=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Mc+r:void 0})(),Ic=e=>{let{theme:t,classGroups:n}=e;return Lc(n,t)},Lc=(e,t)=>{let n=kc();for(let r in e){let i=e[r];Rc(i,n,r,t)}return n},Rc=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];zc(i,t,n,r)}},zc=(e,t,n,r)=>{if(typeof e==`string`){Bc(e,t,n);return}if(typeof e==`function`){Vc(e,t,n,r);return}Hc(e,t,n,r)},Bc=(e,t,n)=>{let r=e===``?t:Uc(t,e);r.classGroupId=n},Vc=(e,t,n,r)=>{if(Wc(e)){Rc(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Oc(n,e))},Hc=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Rc(o,Uc(t,a),n,r)}},Uc=(e,t)=>{let n=e,r=t.split(Ac),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=kc(),n.nextPart.set(t,i)),n=i}return n},Wc=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Gc=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Kc=`!`,qc=`:`,Jc=[],Yc=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Xc=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===qc){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Kc)?(c=s.slice(0,-1),l=!0):s.startsWith(Kc)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Yc(t,l,c,u)};if(t){let e=t+qc,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Yc(Jc,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Zc=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Qc=e=>({cache:Gc(e.cacheSize),parseClassName:Xc(e),sortModifiers:Zc(e),postfixLookupClassGroupIds:$c(e),...Nc(e)}),$c=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},el=/\s+/,tl=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(el),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Kc:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},nl=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=rl(n))&&(i&&(i+=` `),i+=r);return i},rl=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=rl(e[r]))&&(n&&(n+=` `),n+=t);return n},il=(e,...t)=>{let n,r,i,a,o=o=>(n=Qc(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=tl(e,n);return i(e,a),a};return a=o,(...e)=>a(nl(...e))},al=[],q=e=>{let t=t=>t[e]||al;return t.isThemeGetter=!0,t},ol=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,sl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,cl=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ll=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ul=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fl=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pl=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ml=e=>cl.test(e),J=e=>!!e&&!Number.isNaN(Number(e)),hl=e=>!!e&&Number.isInteger(Number(e)),gl=e=>e.endsWith(`%`)&&J(e.slice(0,-1)),_l=e=>ll.test(e),vl=()=>!0,yl=e=>ul.test(e)&&!dl.test(e),bl=()=>!1,xl=e=>fl.test(e),Sl=e=>pl.test(e),Cl=e=>!Y(e)&&!X(e),wl=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Tl=e=>Rl(e,Hl,bl),Y=e=>ol.test(e),El=e=>Rl(e,Ul,yl),Dl=e=>Rl(e,Wl,J),Ol=e=>Rl(e,Kl,vl),kl=e=>Rl(e,Gl,bl),Al=e=>Rl(e,Bl,bl),jl=e=>Rl(e,Vl,Sl),Ml=e=>Rl(e,ql,xl),X=e=>sl.test(e),Nl=e=>zl(e,Ul),Pl=e=>zl(e,Gl),Fl=e=>zl(e,Bl),Z=e=>zl(e,Hl),Q=e=>zl(e,Vl),Il=e=>zl(e,ql,!0),Ll=e=>zl(e,Kl,!0),Rl=(e,t,n)=>{let r=ol.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},zl=(e,t,n=!1)=>{let r=sl.exec(e);return r?r[1]?t(r[1]):n:!1},Bl=e=>e===`position`||e===`percentage`,Vl=e=>e===`image`||e===`url`,Hl=e=>e===`length`||e===`size`||e===`bg-size`,Ul=e=>e===`length`,Wl=e=>e===`number`,Gl=e=>e===`family-name`,Kl=e=>e===`number`||e===`weight`,ql=e=>e===`shadow`,Jl=il(()=>{let e=q(`color`),t=q(`font`),n=q(`text`),r=q(`font-weight`),i=q(`tracking`),a=q(`leading`),o=q(`breakpoint`),s=q(`container`),c=q(`spacing`),l=q(`radius`),u=q(`shadow`),d=q(`inset-shadow`),f=q(`text-shadow`),p=q(`drop-shadow`),m=q(`blur`),h=q(`perspective`),g=q(`aspect`),_=q(`ease`),v=q(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),X,Y],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[X,Y,c],T=()=>[ml,`full`,`auto`,...w()],ee=()=>[hl,`none`,`subgrid`,X,Y],te=()=>[`auto`,{span:[`full`,hl,X,Y]},hl,X,Y],E=()=>[hl,`auto`,X,Y],D=()=>[`auto`,`min`,`max`,`fr`,X,Y],ne=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],O=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],k=()=>[`auto`,...w()],A=()=>[ml,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],j=()=>[ml,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],re=()=>[ml,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],M=()=>[e,X,Y],N=()=>[...b(),Fl,Al,{position:[X,Y]}],ie=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ae=()=>[`auto`,`cover`,`contain`,Z,Tl,{size:[X,Y]}],P=()=>[gl,Nl,El],F=()=>[``,`none`,`full`,l,X,Y],I=()=>[``,J,Nl,El],L=()=>[`solid`,`dashed`,`dotted`,`double`],oe=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],R=()=>[J,gl,Fl,Al],se=()=>[``,`none`,m,X,Y],z=()=>[`none`,J,X,Y],ce=()=>[`none`,J,X,Y],le=()=>[J,X,Y],B=()=>[ml,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[_l],breakpoint:[_l],color:[vl],container:[_l],"drop-shadow":[_l],ease:[`in`,`out`,`in-out`],font:[Cl],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[_l],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[_l],shadow:[_l],spacing:[`px`,J],text:[_l],"text-shadow":[_l],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,ml,Y,X,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,X,Y]}],"container-named":[wl],columns:[{columns:[J,Y,X,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[hl,`auto`,X,Y]}],basis:[{basis:[ml,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[J,ml,`auto`,`initial`,`none`,Y]}],grow:[{grow:[``,J,X,Y]}],shrink:[{shrink:[``,J,X,Y]}],order:[{order:[hl,`first`,`last`,`none`,X,Y]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ne(),`normal`]}],"justify-items":[{"justify-items":[...O(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...O()]}],"align-content":[{content:[`normal`,...ne()]}],"align-items":[{items:[...O(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...O(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...O(),`baseline`]}],"place-self":[{"place-self":[`auto`,...O()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:A()}],"inline-size":[{inline:[`auto`,...j()]}],"min-inline-size":[{"min-inline":[`auto`,...j()]}],"max-inline-size":[{"max-inline":[`none`,...j()]}],"block-size":[{block:[`auto`,...re()]}],"min-block-size":[{"min-block":[`auto`,...re()]}],"max-block-size":[{"max-block":[`none`,...re()]}],w:[{w:[s,`screen`,...A()]}],"min-w":[{"min-w":[s,`screen`,`none`,...A()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...A()]}],h:[{h:[`screen`,`lh`,...A()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...A()]}],"max-h":[{"max-h":[`screen`,`lh`,...A()]}],"font-size":[{text:[`base`,n,Nl,El]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Ll,Ol]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,gl,Y]}],"font-family":[{font:[Pl,kl,t]}],"font-features":[{"font-features":[Y]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,X,Y]}],"line-clamp":[{"line-clamp":[J,`none`,X,Dl]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,X,Y]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,X,Y]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...L(),`wavy`]}],"text-decoration-thickness":[{decoration:[J,`from-font`,`auto`,X,El]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[J,`auto`,X,Y]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[hl,X,Y]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,X,Y]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,X,Y]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:N()}],"bg-repeat":[{bg:ie()}],"bg-size":[{bg:ae()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},hl,X,Y],radial:[``,X,Y],conic:[hl,X,Y]},Q,jl]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:P()}],"gradient-via-pos":[{via:P()}],"gradient-to-pos":[{to:P()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:I()}],"border-w-x":[{"border-x":I()}],"border-w-y":[{"border-y":I()}],"border-w-s":[{"border-s":I()}],"border-w-e":[{"border-e":I()}],"border-w-bs":[{"border-bs":I()}],"border-w-be":[{"border-be":I()}],"border-w-t":[{"border-t":I()}],"border-w-r":[{"border-r":I()}],"border-w-b":[{"border-b":I()}],"border-w-l":[{"border-l":I()}],"divide-x":[{"divide-x":I()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":I()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...L(),`hidden`,`none`]}],"divide-style":[{divide:[...L(),`hidden`,`none`]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...L(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[J,X,Y]}],"outline-w":[{outline:[``,J,Nl,El]}],"outline-color":[{outline:M()}],shadow:[{shadow:[``,`none`,u,Il,Ml]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":[`none`,d,Il,Ml]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:I()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[J,El]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":I()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":[`none`,f,Il,Ml]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[J,X,Y]}],"mix-blend":[{"mix-blend":[...oe(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[J]}],"mask-image-linear-from-pos":[{"mask-linear-from":R()}],"mask-image-linear-to-pos":[{"mask-linear-to":R()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":R()}],"mask-image-t-to-pos":[{"mask-t-to":R()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":R()}],"mask-image-r-to-pos":[{"mask-r-to":R()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":R()}],"mask-image-b-to-pos":[{"mask-b-to":R()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":R()}],"mask-image-l-to-pos":[{"mask-l-to":R()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":R()}],"mask-image-x-to-pos":[{"mask-x-to":R()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":R()}],"mask-image-y-to-pos":[{"mask-y-to":R()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[X,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":R()}],"mask-image-radial-to-pos":[{"mask-radial-to":R()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[J]}],"mask-image-conic-from-pos":[{"mask-conic-from":R()}],"mask-image-conic-to-pos":[{"mask-conic-to":R()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:N()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:ae()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,X,Y]}],filter:[{filter:[``,`none`,X,Y]}],blur:[{blur:se()}],brightness:[{brightness:[J,X,Y]}],contrast:[{contrast:[J,X,Y]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Il,Ml]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:[``,J,X,Y]}],"hue-rotate":[{"hue-rotate":[J,X,Y]}],invert:[{invert:[``,J,X,Y]}],saturate:[{saturate:[J,X,Y]}],sepia:[{sepia:[``,J,X,Y]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,X,Y]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[J,X,Y]}],"backdrop-contrast":[{"backdrop-contrast":[J,X,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,J,X,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[J,X,Y]}],"backdrop-invert":[{"backdrop-invert":[``,J,X,Y]}],"backdrop-opacity":[{"backdrop-opacity":[J,X,Y]}],"backdrop-saturate":[{"backdrop-saturate":[J,X,Y]}],"backdrop-sepia":[{"backdrop-sepia":[``,J,X,Y]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,X,Y]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[J,`initial`,X,Y]}],ease:[{ease:[`linear`,`initial`,_,X,Y]}],delay:[{delay:[J,X,Y]}],animate:[{animate:[`none`,v,X,Y]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,X,Y]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:z()}],"rotate-x":[{"rotate-x":z()}],"rotate-y":[{"rotate-y":z()}],"rotate-z":[{"rotate-z":z()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":[`scale-3d`],skew:[{skew:le()}],"skew-x":[{"skew-x":le()}],"skew-y":[{"skew-y":le()}],transform:[{transform:[X,Y,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:B()}],"translate-x":[{"translate-x":B()}],"translate-y":[{"translate-y":B()}],"translate-z":[{"translate-z":B()}],"translate-none":[`translate-none`],zoom:[{zoom:[hl,X,Y]}],accent:[{accent:M()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,X,Y]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,X,Y]}],fill:[{fill:[`none`,...M()]}],"stroke-w":[{stroke:[J,Nl,El,Dl]}],stroke:[{stroke:[`none`,...M()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}}),Yl=(...e)=>Jl(Cc(e)),Xl=Ec(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 rounded-md px-3 text-xs`,lg:`h-10 rounded-md px-8`}},defaultVariants:{variant:`default`,size:`default`}}),Zl=y.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>(0,x.jsx)(r?lc:`button`,{className:Yl(Xl({variant:t,size:n,className:e})),ref:a,...i}));Zl.displayName=`Button`;var Ql=`Copying to the clipboard is not available in this browser context.`,$l=e=>{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length);let n=document.execCommand(`copy`);return t.remove(),n},eu=async e=>{let t=navigator.clipboard;if(t!==void 0&&typeof t.writeText==`function`)try{await t.writeText(e);return}catch{if($l(e))return;throw Error(Ql)}if(!$l(e))throw Error(Ql)},tu=1500,nu=`Copy failed`,ru=`Copying to the clipboard failed`,iu=({value:e,idleText:t,idleAriaLabel:n,copiedAriaLabel:r,className:i})=>{let[a,o]=(0,y.useState)(`idle`),s=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),(0,x.jsx)(Zl,{type:`button`,variant:`ghost`,size:`sm`,className:i,"aria-label":a===`copied`?r:a===`failed`?ru:n,onClick:async()=>{try{await eu(e),o(`copied`)}catch(e){console.error(e),o(`failed`)}s.current!==null&&clearTimeout(s.current),s.current=setTimeout(()=>{o(`idle`),s.current=null},tu)},children:a===`copied`?`Copied`:a===`failed`?nu:t})},au=({code:e,label:t=`Copy code`})=>(0,x.jsx)(iu,{value:e,idleText:t,idleAriaLabel:t,copiedAriaLabel:`Code copied to clipboard`,className:`console-copy-code-button`}),ou=`https://cdn.jsdelivr.net/npm/mermaid@10.9.6/dist/mermaid.min.js`,su=null,cu=0,lu=e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#0d1117`,primaryColor:`#161b22`,primaryTextColor:`#e6edf3`,primaryBorderColor:`#30363d`,lineColor:`#8b949e`,fontSize:`14px`}}),e),uu=()=>su===null?window.mermaid===void 0?(su=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=ou,n.async=!0,n.onload=()=>{if(window.mermaid===void 0){t(Error(`mermaid failed to load`));return}e(lu(window.mermaid))},n.onerror=()=>t(Error(`mermaid script failed to load`)),document.head.appendChild(n)}),su):(su=Promise.resolve(lu(window.mermaid)),su):su,du=async e=>{let t=await uu();cu+=1;let n=`console-mermaid-${cu}`,{svg:r}=await t.render(n,e);return $a.sanitize(r,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`foreignObject`]})},fu=.5,pu=e=>Number.isNaN(e)||e<1?1:e>6?6:e,mu=e=>pu(pu(e)+fu),hu=e=>pu(pu(e)-fu),gu=e=>pu(e)<=1,_u=e=>pu(e)>=6,vu=e=>`${Math.round(pu(e)*100)}%`,yu=e=>`${pu(e)*100}%`,bu=({svg:e,onClose:t})=>{let[n,r]=(0,y.useState)(1),i=(0,y.useRef)(null);return(0,y.useEffect)(()=>{let t=i.current;if(t===null)return;t.innerHTML=e;let n=t.querySelector(`svg`);n!==null&&(n.style.removeProperty(`max-width`),n.style.setProperty(`width`,`100%`),n.style.setProperty(`height`,`auto`))},[e]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[t]),(0,x.jsxs)(`div`,{className:`console-mermaid-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Enlarged diagram`,children:[(0,x.jsxs)(`div`,{className:`console-mermaid-modal-bar`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom out`,disabled:gu(n),onClick:()=>r(hu(n)),children:`−`}),(0,x.jsx)(`span`,{className:`console-mermaid-modal-scale`,children:vu(n)}),(0,x.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom in`,disabled:_u(n),onClick:()=>r(mu(n)),children:`+`}),(0,x.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-close`,"aria-label":`Close enlarged diagram`,onClick:t,children:`✕`})]}),(0,x.jsx)(`div`,{className:`console-mermaid-modal-viewport`,children:(0,x.jsx)(`div`,{ref:i,className:`console-mermaid-modal-canvas`,style:{width:yu(n)}})})]})},xu=({code:e})=>{let[t,n]=(0,y.useState)({status:`loading`}),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(null);return(0,y.useEffect)(()=>{let t=!1;return n({status:`loading`}),du(e).then(e=>{t||n({status:`ready`,svg:e})}).catch(e=>{t||n({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e]),(0,y.useEffect)(()=>{let e=a.current;e!==null&&(e.innerHTML=t.status===`ready`?t.svg:``)},[t]),t.status===`loading`?(0,x.jsx)(`div`,{className:`console-mermaid-loading`,children:`Rendering diagram...`}):t.status===`error`?(0,x.jsxs)(`div`,{className:`console-mermaid`,children:[(0,x.jsxs)(`div`,{className:`console-mermaid-error`,children:[`Mermaid render error: `,t.message]}),(0,x.jsx)(`pre`,{className:`console-mermaid-source`,children:(0,x.jsx)(`code`,{children:e})})]}):(0,x.jsxs)(`div`,{className:`console-mermaid`,children:[(0,x.jsx)(`div`,{ref:a,className:`console-mermaid-rendered`}),(0,x.jsx)(`button`,{type:`button`,className:`console-mermaid-enlarge`,onClick:()=>i(!0),children:`Enlarge diagram`}),r&&(0,x.jsx)(bu,{svg:t.svg,onClose:()=>i(!1)})]})},Su=e=>{let t=e.querySelectorAll(`a[href]`),n=[];return t.forEach((e,t)=>{let r=e.getAttribute(`href`)??``;if(Si(r)===null)return;let i=e.textContent??r,a=document.createElement(`span`);a.className=`console-markdown-reference-host`,e.replaceWith(a),n.push({key:`${t}:${r}`,host:a,href:r,fallbackText:i})}),n},Cu=e=>{let t=e.querySelectorAll(`pre > code`),n=[];return t.forEach((e,t)=>{let r=e.parentElement;if(r===null)return;let i=e.textContent??``,a=document.createElement(`div`);a.className=`console-markdown-code-block`;let o=document.createElement(`div`);o.className=`console-markdown-code-copy-host`,r.replaceWith(a),a.append(o,r),n.push({key:`code:${t}`,host:o,code:i})}),n},wu=({source:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,y.useMemo)(()=>{let n=Xs(e,r);return t===void 0?n:Oi(n,t)},[e,t,r]),a=(0,y.useRef)(null),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)([]);return(0,y.useEffect)(()=>{let e=a.current;e!==null&&(e.innerHTML=i,l(Cu(e)),s(n===void 0?[]:Su(e)))},[i,n]),(0,x.jsxs)(`div`,{ref:a,className:`console-markdown`,children:[c.map(e=>(0,ee.createPortal)((0,x.jsx)(au,{code:e.code}),e.host,e.key)),n!==void 0&&o.map(e=>(0,ee.createPortal)(n(e.href,e.fallbackText),e.host,e.key))]})},Tu=({body:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,y.useMemo)(()=>ec(e),[e]);return e.trim()===``?(0,x.jsx)(`p`,{className:`console-markdown-empty`,children:`No description provided.`}):(0,x.jsx)(`div`,{className:`console-markdown-view`,children:i.map(e=>e.kind===`mermaid`?(0,x.jsx)(xu,{code:e.code},e.key):(0,x.jsx)(wu,{source:e.source,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r},e.key))})},Eu=({title:e,count:t=null,defaultCollapsed:n=!1,headerAction:r,children:i})=>{let[a,o]=(0,y.useState)(n),s=t===null?e:`${e} (${t})`;return(0,x.jsxs)(`section`,{className:`console-panel`,children:[(0,x.jsxs)(`header`,{className:`console-panel-header`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`console-panel-toggle`,"aria-expanded":!a,onClick:()=>o(e=>!e),children:[(0,x.jsx)(`span`,{className:`console-panel-caret`,children:a?`▸`:`▾`}),(0,x.jsx)(`span`,{className:`console-panel-title`,children:s})]}),r!==void 0&&(0,x.jsx)(`div`,{className:`console-panel-action`,children:r})]}),!a&&(0,x.jsx)(`div`,{className:`console-panel-body`,children:i})]})},Du=e=>{switch(e){case`added`:return{label:`A`,color:`#3fb950`};case`modified`:return{label:`M`,color:`#d29922`};case`removed`:return{label:`D`,color:`#f85149`};case`renamed`:return{label:`R`,color:`#a371f7`};case`changed`:return{label:`M`,color:`#d29922`};default:return{label:`?`,color:`#8b949e`}}},Ou=()=>({directories:new Map,files:[]}),ku=e=>e.split(`/`).filter(e=>e!==``),Au=(e,t)=>e.name.localeCompare(t.name),ju=(e,t)=>{let n=[];e.directories.forEach((e,r)=>{let i=t===``?r:`${t}/${r}`;n.push({kind:`directory`,name:r,path:i,children:ju(e,i)})}),n.sort(Au);let r=e.files.map(e=>({kind:`file`,name:ku(e.path).at(-1)??e.path,path:e.path,file:e}));return r.sort(Au),[...n,...r]},Mu=e=>{let t=Ou();for(let n of e){let e=ku(n.path);if(e.length===0){t.files.push(n);continue}let r=e.slice(0,-1),i=t;for(let e of r){let t=i.directories.get(e);if(t===void 0){let t=Ou();i.directories.set(e,t),i=t;continue}i=t}i.files.push(n)}return ju(t,``)},Nu=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,Pu=e=>{let t=[],n=0,r=0;for(let i of e.split(`
87
87
  `)){if(i.startsWith(`@@`)){let e=i.match(Nu);e!==null&&(n=Number(e[1]),r=Number(e[2])),t.push({kind:`hunk`,oldLineNumber:null,newLineNumber:null,content:i});continue}if(i.startsWith(`+`)){t.push({kind:`add`,oldLineNumber:null,newLineNumber:r,content:i}),r+=1;continue}if(i.startsWith(`-`)){t.push({kind:`del`,oldLineNumber:n,newLineNumber:null,content:i}),n+=1;continue}t.push({kind:`ctx`,oldLineNumber:n,newLineNumber:r,content:i}),n+=1,r+=1}return t},Fu=[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.avif`,`.bmp`,`.ico`],Iu=e=>{let t=e.toLowerCase();return Fu.some(e=>t.endsWith(e))},Lu=e=>e.kind===`add`||e.kind===`ctx`?e.newLineNumber===null?null:{line:e.newLineNumber,side:`RIGHT`}:e.kind===`del`?e.oldLineNumber===null?null:{line:e.oldLineNumber,side:`LEFT`}:null,Ru=e=>`${e.kind}:${e.oldLineNumber??`x`}:${e.newLineNumber??`x`}:${e.content}`,zu=({target:e,onSubmit:t,onClose:n})=>{let[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)({kind:`idle`}),s=async()=>{let n=r.trim();if(n.length!==0&&a.kind!==`posting`){o({kind:`posting`});try{await t(e.path,e.line,e.side,n),i(``),o({kind:`posted`})}catch(e){o({kind:`error`,message:e instanceof Error?e.message:`failed to post`})}}};return(0,x.jsxs)(`div`,{className:`console-diff-composer`,children:[(0,x.jsxs)(`div`,{className:`console-diff-composer-anchor`,children:[`commenting on line `,e.line,` (`,e.side,`)`]}),a.kind===`posted`?(0,x.jsx)(`p`,{className:`console-diff-composer-posted`,children:`Comment saved.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`textarea`,{className:`console-diff-composer-input`,rows:3,placeholder:`Leave a review comment on this line…`,value:r,onChange:e=>i(e.target.value)}),(0,x.jsxs)(`div`,{className:`console-diff-composer-controls`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-diff-composer-submit`,disabled:a.kind===`posting`,onClick:()=>{s()},children:`Comment`}),(0,x.jsx)(`button`,{type:`button`,className:`console-diff-composer-cancel`,onClick:n,children:`Cancel`}),a.kind===`posting`&&(0,x.jsx)(`span`,{className:`console-diff-composer-status`,children:`Posting…`}),a.kind===`error`&&(0,x.jsxs)(`span`,{role:`alert`,className:`console-diff-composer-status console-diff-composer-error`,children:[`Failed: `,a.message]})]})]})]})},Bu=({patch:e,path:t,rawUrl:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,y.useState)(null);if(e===null||e===``){if(t!==void 0&&n!=null){if(n.startsWith(`data:image/`))return(0,x.jsx)(`div`,{className:`console-file-diff-image`,children:(0,x.jsx)(`img`,{className:`console-file-diff-image-content`,src:n,alt:t})});if(Iu(t)&&r!==void 0)return(0,x.jsx)(`div`,{className:`console-file-diff-image`,children:(0,x.jsx)(`img`,{className:`console-file-diff-image-content`,src:r(n),alt:t})})}return(0,x.jsx)(`p`,{className:`console-file-diff-empty`,children:`(no diff / binary or too large)`})}let s=Pu(e),c=i!==void 0&&t!==void 0&&t.length>0,l=c?4:3;return(0,x.jsx)(`table`,{className:`console-file-diff`,children:(0,x.jsx)(`tbody`,{children:s.map(e=>{let n=Ru(e),r=c?Lu(e):null,s=a!==null&&r!==null&&a.line===r.line&&a.side===r.side;return(0,x.jsxs)(y.Fragment,{children:[(0,x.jsxs)(`tr`,{className:`console-diff-row console-diff-${e.kind}`,children:[c&&(0,x.jsx)(`td`,{className:`console-diff-comment-cell`,children:r!==null&&t!==void 0&&(0,x.jsx)(`button`,{type:`button`,className:`console-diff-comment-button`,"aria-label":`Comment on line ${r.line} (${r.side})`,"aria-expanded":s,onClick:()=>o(s?null:{path:t,line:r.line,side:r.side}),children:`+`})}),(0,x.jsx)(`td`,{className:`console-diff-ln`,children:e.oldLineNumber??``}),(0,x.jsx)(`td`,{className:`console-diff-ln`,children:e.newLineNumber??``}),(0,x.jsx)(`td`,{className:`console-diff-code`,children:e.content})]}),s&&i!==void 0&&a!==null&&(0,x.jsx)(`tr`,{className:`console-diff-composer-row`,children:(0,x.jsx)(`td`,{colSpan:l,children:(0,x.jsx)(zu,{target:a,onSubmit:i,onClose:()=>o(null)})})})]},n)})})})},Vu=e=>({paddingLeft:`${e*16}px`}),Hu=({file:e,depth:t,name:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,y.useState)(!1),s=Du(e.status);return(0,x.jsxs)(`li`,{className:`console-file`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`console-file-row`,style:Vu(t),"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,x.jsx)(`span`,{className:`console-file-caret`,children:a?`▾`:`▸`}),(0,x.jsx)(`span`,{className:`console-file-badge`,style:{color:s.color,borderColor:s.color},children:s.label}),(0,x.jsx)(`span`,{className:`console-file-path`,children:n}),(0,x.jsxs)(`span`,{className:`console-file-stat console-file-add`,children:[`+`,e.additions]}),(0,x.jsxs)(`span`,{className:`console-file-stat console-file-del`,children:[`-`,e.deletions]})]}),a&&(0,x.jsx)(Bu,{patch:e.patch,path:e.path,rawUrl:e.rawUrl,buildImageProxyUrl:r,onAddInlineComment:i})]})},Uu=({node:e,depth:t,buildImageProxyUrl:n,onAddInlineComment:r})=>e.kind===`file`?(0,x.jsx)(Hu,{file:e.file,depth:t,name:e.name,buildImageProxyUrl:n,onAddInlineComment:r}):(0,x.jsxs)(`li`,{className:`console-file-tree-dir`,children:[(0,x.jsxs)(`div`,{className:`console-file-tree-dir-name`,style:Vu(t),children:[(0,x.jsx)(`span`,{className:`console-file-tree-dir-icon`,"aria-hidden":`true`,children:`📁`}),e.name]}),(0,x.jsx)(`ul`,{className:`console-file-tree-children`,children:e.children.map(e=>(0,x.jsx)(Uu,{node:e,depth:t+1,buildImageProxyUrl:n,onAddInlineComment:r},e.path))})]}),Wu=({files:e,isLoading:t,error:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{if(n!==null)return(0,x.jsx)(`p`,{className:`console-files-notloaded`,children:`Not loaded.`});if(t)return(0,x.jsx)(`p`,{className:`console-files-loading`,children:`Loading changed files...`});if(e.length===0)return(0,x.jsx)(`p`,{className:`console-files-empty`,children:`No changed files.`});let a=Mu(e);return(0,x.jsx)(`ul`,{className:`console-files console-file-tree`,children:a.map(e=>(0,x.jsx)(Uu,{node:e,depth:0,buildImageProxyUrl:r,onAddInlineComment:i},e.path))})},Gu=e=>e.split(`
88
88
  `).find(e=>e.trim()!==``)??``,Ku=e=>`${e.author}:${e.createdAt}:${e.body}`,qu=({comment:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,y.useRef)(null);return(0,y.useEffect)(()=>{let e=i.current;if(!e)return;let t=e=>e.stopPropagation();return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[]),(0,x.jsx)(`div`,{ref:i,className:`console-comment-body-expanded`,children:(0,x.jsx)(Tu,{body:e.body,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})})},Ju=({comments:e,isLoading:t,error:n,now:r,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o,persistenceKey:s=null})=>{let[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(()=>s==null?new Set:xn(s)),f=e.length>0?Ku(e[e.length-1]):null;(0,y.useEffect)(()=>{f!==null&&d(e=>new Set([...e,f]))},[f]),(0,y.useEffect)(()=>{s!=null&&Sn(s,u)},[s,u]);let p=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(n!==null)return(0,x.jsx)(`p`,{className:`console-comment-notloaded`,children:`Not loaded.`});if(t)return(0,x.jsx)(`p`,{className:`console-comment-loading`,children:`Loading comments...`});if(e.length===0)return(0,x.jsx)(`p`,{className:`console-comment-empty`,children:`No comments.`});let m=!c&&e.length>1;return(0,x.jsxs)(`div`,{className:`console-comment-list`,children:[m&&(0,x.jsxs)(`button`,{type:`button`,className:`console-comment-show-all`,onClick:()=>{l(!0),d(t=>new Set([...t,...e.map(Ku)]))},children:[`Show all `,e.length]}),e.map(e=>{let t=Ku(e),n=u.has(t);return(0,x.jsxs)(`article`,{className:`console-comment${n?` is-expanded`:m?` console-comment--expandable`:``}`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`console-comment-toggle`,onClick:()=>p(t),"aria-expanded":n,children:[(0,x.jsx)(`span`,{className:`console-comment-author`,children:e.author}),(0,x.jsx)(`span`,{className:`console-comment-time`,children:O(e.createdAt,r)}),!n&&(0,x.jsx)(`span`,{className:`console-comment-body-preview`,children:Gu(e.body)})]}),n&&(0,x.jsx)(qu,{comment:e,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})]},t)})]})},Yu=e=>e.slice(0,7),Xu=e=>e.split(`
89
- `)[0],Zu=({commits:e,isLoading:t,error:n,now:r})=>n===null?t?(0,x.jsx)(`p`,{className:`console-commits-loading`,children:`Loading commits...`}):e.length===0?(0,x.jsx)(`p`,{className:`console-commits-empty`,children:`No commits.`}):(0,x.jsx)(`ul`,{className:`console-commits`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`console-commit`,children:[(0,x.jsx)(`span`,{className:`console-commit-message`,children:Xu(e.message)}),(0,x.jsx)(`span`,{className:`console-commit-sha`,children:Yu(e.sha)}),(0,x.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,x.jsx)(`span`,{className:`console-commit-time`,children:O(e.authoredAt,r)})]},e.sha))}):(0,x.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Qu=({url:e,label:t=`Copy URL`})=>(0,x.jsx)(iu,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),$u=e=>{let t=new Map;for(let n of e){let e=t.get(n.message);if(e===void 0){t.set(n.message,[n.section]);continue}e.push(n.section)}return Array.from(t,([e,t])=>({message:e,sections:t}))},ed=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,td=({failures:e})=>e.length===0?null:(0,x.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:$u(e).map(e=>(0,x.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,ed(e.sections),`:`,` `,e.message]},e.message))}),nd=({title:e,onTitleRename:t})=>{let[n,r]=(0,y.useState)(e),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(e),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(e);(0,y.useEffect)(()=>{let t=e!==f.current;f.current=e,!i&&t&&r(e)},[e,i]);let p=()=>{s(n),d(null),a(!0)},m=()=>{a(!1),d(null)},h=async()=>{let e=o.trim();if(e===``||e===n){a(!1);return}l(!0),d(null);try{await t(e),r(e),a(!1)}catch(e){d(e instanceof Error?e.message:`Failed to rename`)}finally{l(!1)}};return i?(0,x.jsxs)(`span`,{className:`console-detail-title-text console-detail-title-text--editing`,children:[(0,x.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&m()},disabled:c,className:`console-detail-title-input`,"aria-label":`Edit title`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>void h(),disabled:c,className:`console-detail-title-save`,children:`Save`}),(0,x.jsx)(`button`,{type:`button`,onClick:m,disabled:c,className:`console-detail-title-cancel`,children:`Cancel`}),u!==null&&(0,x.jsx)(`span`,{className:`console-detail-title-error`,role:`alert`,children:u})]}):(0,x.jsxs)(`span`,{className:`console-detail-title-text`,children:[n,(0,x.jsx)(`button`,{type:`button`,onClick:p,className:`console-detail-title-edit`,"aria-label":`Edit title`,children:`Edit`})]})},rd={MERGEABLE:{color:`GREEN`,label:`No conflict`,title:`This pull request has no merge conflicts`,modifier:`console-detail-mergeable-chip-ok`},CONFLICTING:{color:`RED`,label:`Conflict`,title:`This pull request has merge conflicts`,modifier:`console-detail-mergeable-chip-conflict`},UNKNOWN:{color:`GRAY`,label:`Checking merge status`,title:`GitHub has not finished computing the merge status yet`,modifier:`console-detail-mergeable-chip-unknown`}},id=({mergeableStatus:e})=>{let t=rd[e],n=F(t.color);return(0,x.jsx)(`span`,{className:`console-detail-status-chip console-detail-mergeable-chip ${t.modifier}`,style:{color:n.fg,borderColor:n.border,backgroundColor:n.bg},title:t.title,children:t.label})},ad=e=>{let t=F(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},od=({isPassedAllCiJob:e,isCiStateSuccess:t,isBranchOutOfDate:n,missingRequiredCheckNames:r})=>{let i=e&&t,a=i?`GREEN`:`RED`,o=i?`CI passing`:`CI failing`,s=!i&&r.length>0?`missing: ${r.join(`, `)}`:null;return(0,x.jsxs)(`span`,{className:`console-detail-pr-status`,children:[(0,x.jsxs)(`span`,{className:`console-detail-status-chip console-detail-ci-chip`,style:ad(a),title:s??o,children:[o,s!==null&&(0,x.jsxs)(`span`,{className:`console-detail-ci-missing`,children:[` `,`(`,s,`)`]})]}),n&&(0,x.jsx)(`span`,{className:`console-detail-status-chip console-detail-outofdate-chip`,style:ad(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},sd=({pullRequest:e,body:t,bodyIsLoading:n,files:r,filesAreLoading:i,filesError:a,commits:o,commitsAreLoading:s,commitsError:c,now:l,buildImageProxyUrl:u,renderReferenceLink:d,onAddInlineComment:f})=>{let p=e.summary,m=Si(e.url),h=m===null?void 0:{owner:m.owner,repo:m.repo},g=i||a!==null?null:r.length,_=s||c!==null?null:o.length;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`console-pr-header`,children:[(0,x.jsx)(`a`,{href:e.url,className:`console-pr-section-title`,target:`_blank`,rel:`noopener noreferrer`,children:p?.title??e.url}),e.isDraft&&(0,x.jsx)(`span`,{className:`console-pr-section-state`,children:`draft`}),(0,x.jsx)(id,{mergeableStatus:e.mergeableStatus}),(0,x.jsx)(od,{isPassedAllCiJob:e.isPassedAllCiJob,isCiStateSuccess:e.isCiStateSuccess,isBranchOutOfDate:e.isBranchOutOfDate,missingRequiredCheckNames:e.missingRequiredCheckNames}),(0,x.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),(0,x.jsx)(Qu,{url:e.url,label:`Copy PR URL`}),(0,x.jsxs)(`div`,{className:`console-pr-statbar`,children:[m!==null&&(0,x.jsxs)(`span`,{className:`console-pr-repo`,children:[m.owner,`/`,m.repo]}),e.branchName!==null&&(0,x.jsx)(`span`,{className:`console-pr-branch`,children:e.branchName}),p!==null&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`span`,{className:`console-pr-add`,children:[`+`,p.additions]}),(0,x.jsxs)(`span`,{className:`console-pr-del`,children:[`-`,p.deletions]}),(0,x.jsxs)(`span`,{className:`console-pr-files-count`,children:[p.changedFiles,` files`]})]})]})]}),(0,x.jsx)(Eu,{title:`Description`,children:n?(0,x.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,x.jsx)(Tu,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,x.jsx)(Eu,{title:`Changed files`,count:g,children:(0,x.jsx)(Wu,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,x.jsx)(Eu,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,x.jsx)(Zu,{commits:o,isLoading:s,error:c,now:l})})]})},cd=({item:e,storyName:t,storyColorEnum:n,overlayStatus:r,statusOptions:i,state:a,body:o,bodyIsLoading:s,bodyError:c,comments:l,commentsAreLoading:u,commentsError:d,files:f,filesAreLoading:p,filesError:m,commits:h,commitsAreLoading:g,commitsError:_,stateError:v,pullRequestStatus:y,pullRequestStatusError:b,relatedPullRequests:S,relatedPullRequestsError:C,now:w,commentComposer:T,operationBar:ee,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:D,onTitleRename:ne})=>{let k=a?.state??`open`,j=a?.merged??!1,re=!e.isPr&&k===`closed`?`Closed`:null,M=Ci(e.nameWithOwner)??void 0,N=F(n),ie=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,ae=ie===null?null:F(ie.color),P=p||m!==null?null:f.length,I=u||d!==null?null:l.length,L=g||_!==null?null:h.length,oe=!u&&d===null&&l.length>0,R=e=>{let t=Si(e);return t===null?e:`PR #${t.number}`},se=[{section:`item state`,message:v},{section:`pull request status`,message:e.isPr?b:null},{section:`description`,message:c},{section:`comments`,message:d},{section:`changed files`,message:e.isPr?m:null},{section:`commits`,message:e.isPr?_:null},{section:`related pull requests`,message:e.isPr?null:C},...S.flatMap(e=>[{section:`changed files of ${R(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${R(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),z=e.isPr&&y?.found?[{url:e.url,mergeableStatus:y.mergeableStatus}]:[];return(0,x.jsxs)(`article`,{className:`console-detail`,children:[(0,x.jsxs)(`div`,{className:`console-detail-header`,children:[(0,x.jsxs)(`h2`,{className:`console-detail-title`,children:[(0,x.jsx)(ye,{isPr:e.isPr,state:k,merged:j,isDraft:!1,stateReason:``}),ne==null?(0,x.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}):(0,x.jsx)(nd,{title:e.title,onTitleRename:ne}),(0,x.jsx)(`span`,{className:`console-detail-number`,children:e.isPr?`PR #${e.number}`:`#${e.number}`})]}),(0,x.jsxs)(`div`,{className:`console-detail-topline`,children:[ie!==null&&ae!==null&&(0,x.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:ae.fg,borderColor:ae.border,backgroundColor:ae.bg},children:ie.name}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-detail-agent-chip`,children:e.agent}),t!==null&&(0,x.jsxs)(`span`,{className:`console-storytag`,children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:N.dot}}),t]}),e.isPr&&y?.found&&(0,x.jsx)(od,{isPassedAllCiJob:y.isPassedAllCiJob,isCiStateSuccess:y.isCiStateSuccess,isBranchOutOfDate:y.isBranchOutOfDate,missingRequiredCheckNames:y.missingRequiredCheckNames}),!e.isPr&&S.map(e=>(0,x.jsxs)(`span`,{className:`console-related-pr-group`,children:[S.length>1&&(0,x.jsx)(`span`,{className:`console-related-pr-label`,children:R(e.pullRequest.url)}),(0,x.jsx)(od,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,x.jsx)(id,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),z.map(e=>(0,x.jsx)(id,{mergeableStatus:e.mergeableStatus},e.url)),re!==null&&(0,x.jsx)(`span`,{className:`console-detail-closed-label`,children:re})]}),(0,x.jsx)(td,{failures:se}),(0,x.jsxs)(`div`,{className:`console-detail-subbar`,children:[(0,x.jsxs)(`a`,{href:e.url,className:`console-detail-link`,target:`_blank`,rel:`noopener noreferrer`,children:[`#`,e.number]}),(0,x.jsx)(`span`,{className:`console-detail-repo`,children:e.repo}),(0,x.jsxs)(`span`,{className:`console-detail-createdat`,title:A(e.createdAt),children:[`opened `,O(e.createdAt,w)]}),(0,x.jsx)(Qu,{url:e.url}),e.labels.map(e=>(0,x.jsx)(`span`,{className:`console-label-chip`,children:e},e))]})]}),(0,x.jsxs)(`div`,{className:`console-detail-body`,children:[(0,x.jsx)(Eu,{title:`Description`,defaultCollapsed:oe,headerAction:(0,x.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),children:c===null?s?(0,x.jsx)(`p`,{className:`console-detail-body-loading`,children:`Loading description...`}):(0,x.jsx)(Tu,{body:o,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:M}):(0,x.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})},oe?`desc-collapsed`:`desc-open`),e.isPr&&(0,x.jsx)(Eu,{title:`Changed files`,count:P,children:(0,x.jsx)(Wu,{files:f,isLoading:p,error:m,onAddInlineComment:D})}),(0,x.jsx)(Eu,{title:`Comments`,count:I,children:(0,x.jsx)(Ju,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:M,persistenceKey:e.url})}),e.isPr&&(0,x.jsx)(Eu,{title:`Commits`,count:L,defaultCollapsed:!0,children:(0,x.jsx)(Zu,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&S.map(e=>(0,x.jsx)(sd,{pullRequest:e.pullRequest,body:e.pullRequest.summary?.body??``,bodyIsLoading:!1,files:e.files,filesAreLoading:e.filesAreLoading,filesError:e.filesError,commits:e.commits,commitsAreLoading:e.commitsAreLoading,commitsError:e.commitsError,now:w,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:D},e.pullRequest.url))]}),(0,x.jsxs)(`div`,{className:`console-detail-dock`,children:[(0,x.jsx)(`div`,{className:`console-detail-dock-composer`,children:T}),(0,x.jsx)(`div`,{className:`console-actionbar`,children:ee})]})]})},ld=({className:e,ariaLabel:t,placeholder:n,currentOption:r,options:i,onSelect:a})=>{let o=(0,y.useRef)({ready:!1,currentOptionId:r?.id??null});return(0,y.useLayoutEffect)(()=>{o.current.ready=!0,o.current.currentOptionId=r?.id??null}),(0,x.jsxs)(`select`,{className:e,defaultValue:r?.id??``,onChange:e=>{if(!o.current.ready||e.target.value===(o.current.currentOptionId??``))return;let t=i.find(t=>t.id===e.target.value);t!==void 0&&a(t)},"aria-label":t,children:[(0,x.jsx)(`option`,{value:``,children:n}),i.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})},ud=({agentOptions:e,currentAgentName:t,onSetAgent:n})=>{if(e.length===0)return null;let r=t===null?null:e.find(e=>e.name===t)??null;return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(ld,{className:`console-agent-select`,ariaLabel:`Set agent`,placeholder:`— agent —`,currentOption:r,options:e,onSelect:n},r?.id??`none`)})},dd=({onClose:e,onCommentAndClose:t})=>{let[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),u=async()=>{let e=i.trim();if(!(!e||o||t===void 0)){s(!0),l(null);try{await t(e),a(``),r(!1)}catch(e){l(e instanceof Error?e.message:`failed to post`)}finally{s(!1)}}};return(0,x.jsxs)(`div`,{className:`console-op-group`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close_not_planned`),children:`Close as not planned`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close`),children:`Close`}),t!==void 0&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>r(e=>!e),children:`Comment & Close`}),n&&(0,x.jsxs)(`div`,{className:`console-op-comment-and-close`,children:[(0,x.jsx)(`textarea`,{className:`console-op-comment-and-close-input`,placeholder:`Leave a comment…`,value:i,onChange:e=>a(e.target.value)}),c!==null&&(0,x.jsx)(`span`,{role:`alert`,className:`console-op-comment-and-close-error`,children:c}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,disabled:o||i.trim().length===0,onClick:()=>{u()},children:`Submit`})]})]})]})},fd=({onDeleteAllComments:e,onDeleteStory:t,storyNameForDeletion:n})=>{let[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=()=>{e(),i(!1)},f=()=>{o(!0),u(null)},p=async e=>{if(t){c(!0),u(null);try{await t(e)}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}}};return(0,x.jsxs)(`div`,{className:`console-op-group`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>i(e=>!e),children:`⚠`}),r&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:d,children:`Delete All Comments`}),t!=null&&(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:f,disabled:a,children:`Delete Story`})]}),a&&(0,x.jsxs)(`div`,{className:`console-story-delete-confirm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Confirm story deletion`,children:[(0,x.jsxs)(`p`,{className:`console-story-delete-confirm-message`,children:[`Delete story option "`,n,`" from the GitHub custom field?`]}),l!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:l}),(0,x.jsxs)(`div`,{className:`console-story-delete-confirm-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>void p(!0),disabled:s,children:s?`Deleting…`:`Delete with child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>void p(!1),disabled:s,children:s?`Deleting…`:`Keep child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{o(!1),u(null)},disabled:s,children:`Cancel`})]})]})]})},pd=({isManualTriage:e,onSetNextActionDate:t})=>(0,x.jsxs)(`div`,{className:`console-op-group`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1hour`),children:`+1 hour`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3hours`),children:`+3 hours`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_6hours`),children:`+6 hours`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1day`),children:`+1 day`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_2days`),children:`+2 days`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3days`),children:`+3 days`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_5days`),children:`+5 days`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1week`),children:e?`+1 week and skip`:`+1 week`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1month`),children:`+1 month`})]}),md=[{action:`unnecessary`,label:`Unnecessary`,variant:`unneeded`},{action:`totally_wrong`,label:`Totally wrong`,variant:`wrong`},{action:`request_changes`,label:`Reject`,variant:`reject`},{action:`approve_and_merge`,label:`Approve & Merge`,variant:`approve`}],hd=`Reject needs an inline comment on the diff.`,gd=({onReview:e,rejectEnabled:t})=>(0,x.jsxs)(`div`,{className:`console-op-group console-op-group-review`,children:[!t&&(0,x.jsx)(`p`,{className:`console-op-requirement`,children:hd}),md.map(n=>{let r=n.action===`request_changes`&&!t;return(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-${n.variant}`,disabled:r,onClick:()=>e(n.action),children:n.label},n.action)})]}),_d=({onSetDependedIssueUrl:e})=>{let[t,n]=(0,y.useState)(!1),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null);return(0,x.jsxs)(`div`,{className:`console-op-group console-op-group-rare-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{n(e=>!e),c(null)},title:`Rare actions`,children:`⋯`}),t&&e!==null&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`input`,{type:`url`,className:`console-settings-modal-input`,placeholder:`Depended issue URL`,value:r,onChange:e=>i(e.target.value),disabled:a}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:async()=>{if(e!==null&&r.trim()!==``){o(!0),c(null);try{await e(r.trim()),i(``),n(!1)}catch(e){c(e instanceof Error?e.message:`Failed to set depended issue URL`)}finally{o(!1)}}},disabled:a||r.trim()===``,children:a?`...`:`Set Depended Issue`})]}),s!==null&&(0,x.jsx)(`p`,{className:`console-settings-modal-error`,children:s})]})},vd=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},$=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=me.map(t=>({name:t,option:vd(e,t)})).filter(e=>e.option!==null);return r.length===0?null:(0,x.jsx)(`div`,{className:`console-op-group`,children:r.map(({name:e,option:r})=>{let i=F(r.color),a=e===fe;return(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:i.fg,borderColor:i.border,backgroundColor:i.bg},onClick:()=>a?n(r):t(r),children:r.name},r.id)})})},yd=({storyOptions:e,currentStoryName:t,onSetStory:n})=>{if(e.length===0)return null;let r=t===null?null:e.find(e=>e.name===t)??null;return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(ld,{className:`console-story-select`,ariaLabel:`Set story`,placeholder:`— story —`,currentOption:r,options:e,onSelect:n},r?.id??`none`)})},bd=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,storyOptions:i,currentStoryName:a,agentOptions:o,currentAgentName:s,handlers:c,storyNameForDeletion:l,onCommentAndClose:u})=>{let[d,f]=(0,y.useState)(!1);return(0,x.jsxs)(`div`,{className:`console-operation-bar`,children:[t&&(0,x.jsx)(gd,{onReview:c.onReview,rejectEnabled:n}),(0,x.jsx)(pd,{isManualTriage:he(e),onSetNextActionDate:c.onSetNextActionDate}),(0,x.jsx)($,{statusOptions:r,onSetStatus:c.onSetStatus,onSetInTmuxByHuman:c.onSetInTmuxByHuman}),d&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(yd,{storyOptions:i,currentStoryName:a,onSetStory:c.onSetStory}),(0,x.jsx)(ud,{agentOptions:o,currentAgentName:s,onSetAgent:c.onSetAgent})]}),(0,x.jsxs)(`div`,{className:`console-op-group-bottom-row`,children:[(0,x.jsxs)(`div`,{className:`console-op-group-left-pair`,children:[(i.length>0||o.length>0)&&(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>f(e=>!e),title:`Change agent or story`,children:`⚙`})}),(0,x.jsx)(_d,{onSetDependedIssueUrl:c.onSetDependedIssueUrl}),(0,x.jsx)(fd,{onDeleteAllComments:c.onDeleteAllComments,onDeleteStory:c.onDeleteStory,storyNameForDeletion:l})]}),(0,x.jsx)(dd,{onClose:c.onClose,onCommentAndClose:u})]})]})},xd=(e,t,n,r)=>{let i=t===null?void 0:e.peek(t),[a,o]=(0,y.useState)(i??r),[s,c]=(0,y.useState)(t!==null&&i===void 0),[l,u]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(t===null||n===null)return;let r=e.peek(t);if(r!==void 0){o(r),c(!1),u(null);return}let i=!1;return c(!0),u(null),e.load(t,n).then(e=>{i||(o(e),c(!1))}).catch(e=>{i||(u(e instanceof Error?e.message:String(e)),c(!1))}),()=>{i=!0}},[e,t,n]),{data:a,isLoading:s,error:l}},Sd=[],Cd=[],wd=[],Td=[],Ed={state:`open`,merged:!1,isPullRequest:!1,title:``},Dd={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},Od=(e,t,n)=>{let r=t===null?null:`${t.repo}#${t.number}`,i=t===null?null:t.url,a=t?.isPr??!1,o=xd(e.body,r,i,``),s=xd(e.state,r,i,Ed),c=xd(e.comments,r,i,Sd),l=xd(e.files,a?r:null,a?i:null,Cd),u=xd(e.commits,a?r:null,a?i:null,wd),d=xd(e.prStatus,a?r:null,a?i:null,Dd),f=!a&&((t?.relatedOpenPullRequestUrls.length??0)>0||n===`prs`),p=xd(e.relatedPrs,f?r:null,f?i:null,Td),[m,h]=(0,y.useState)([]);return(0,y.useEffect)(()=>{if(a||p.data.length===0){h([]);return}let t=!1,n=p.data.map(e=>({pullRequest:e,files:Cd,filesAreLoading:!0,filesError:null,commits:wd,commitsAreLoading:!0,commitsError:null}));h(n);let r=(e,n)=>{t||h(t=>t.map(t=>t.pullRequest.url===e?{...t,...n}:t))};for(let t of p.data){let n=t.url;e.files.load(n,t.url).then(e=>r(t.url,{files:e,filesAreLoading:!1})).catch(e=>r(t.url,{filesAreLoading:!1,filesError:e instanceof Error?e.message:String(e)})),e.commits.load(n,t.url).then(e=>r(t.url,{commits:e,commitsAreLoading:!1})).catch(e=>r(t.url,{commitsAreLoading:!1,commitsError:e instanceof Error?e.message:String(e)}))}return()=>{t=!0}},[e,a,p.data]),{state:s.data,body:o.data,bodyIsLoading:o.isLoading,bodyError:o.error,comments:c.data,commentsAreLoading:c.isLoading,commentsError:c.error,files:l.data,filesAreLoading:l.isLoading,filesError:l.error,commits:u.data,commitsAreLoading:u.isLoading,commitsError:u.error,stateError:s.error,pullRequestStatus:a?d.data:null,pullRequestStatusError:a?d.error:null,relatedPullRequests:m,relatedPullRequestsError:a?null:p.error}},kd=e=>JSON.stringify([e.author,e.createdAt,e.body]),Ad=(e,t)=>{let n=new Set(e.map(kd));return[...e,...t.filter(e=>!n.has(kd(e)))]},jd=({href:e,fallbackText:t,state:n})=>{if(n===null||n.title.trim()===``)return(0,x.jsx)(`a`,{className:`console-markdown-reference console-markdown-reference-plain`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t});let r=Si(e);return(0,x.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,x.jsx)(ye,{...wi(n)}),(0,x.jsx)(`span`,{className:`console-markdown-reference-title`,children:n.title}),r!==null&&(0,x.jsxs)(`span`,{className:`console-markdown-reference-number`,children:[`#`,r.number]})]})},Md=(e,t)=>{let[n,r]=(0,y.useState)(()=>e.peek(t)??null);return(0,y.useEffect)(()=>{let n=e.peek(t);if(n!==void 0){r(n);return}let i=!1;return r(null),e.load(t,t).then(e=>{i||r(e)}).catch(()=>{i||r(null)}),()=>{i=!0}},[e,t]),n},Nd=({cache:e,href:t,fallbackText:n})=>{let r=Md(e,t);return(0,x.jsx)(jd,{href:t,fallbackText:n,state:r})},Pd=e=>({itemUrl:e.url,projectItemId:e.projectItemId,itemNumber:e.number,repo:e.repo,isPr:e.isPr}),Fd=(e,t,n,r,i)=>({...Pd(t),apiPath:cr,requestBody:dr(e,t,n,r,i)}),Id=(e,t,n,r)=>({...Pd(t),apiPath:lr,requestBody:fr(e,t,n,r)}),Ld=(e,t)=>({...Pd(t),apiPath:ur,requestBody:pr(e,t)}),Rd=({tab:e,item:t,caches:n,operations:r,pjcode:i,statusOptions:a,storyOptions:o,agentOptions:s,storyColors:c,storyName:l,overlayStatus:u,now:d,initialCommentDraft:f,onCommentDraftChange:p,onQueueAction:m,onDeleteStory:h,storyNameForDeletion:g})=>{let _=Od(n,t,e),v=(0,y.useCallback)(e=>Di(e,t.url),[t.url]),b=(0,y.useCallback)((e,t)=>(0,x.jsx)(Nd,{cache:n.state,href:e,fallbackText:t}),[n.state]),S=t.isPr||t.relatedOpenPullRequestUrls.length>0||_.relatedPullRequests.length>0,[C,w]=(0,y.useState)([]),T=(0,y.useCallback)(async(e,t,n,r)=>{w(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[ee,te]=(0,y.useState)([]),E=(0,y.useCallback)(async e=>{let n=await r.addComment(t,e);return te(e=>[...e,n]),n},[t,r]),D={onReview:e=>{let n=t.isPr?t.url:_.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,a=e===`request_changes`?C:[];m({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,a),offline:i==null?void 0:Fd(i,t,n,e,a),...e===`approve_and_merge`?{onAdvance:()=>r.patchItemOverlay(t,!0),revertAdvance:()=>r.patchItemOverlay(t,!1)}:{}})},onSetNextActionDate:e=>{m({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e),offline:i==null?void 0:Id(i,t,e)})},onSetStory:e=>{m({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e),offline:i==null?void 0:Id(i,t,`set_story`,{storyOptionId:e.id})})},onSetAgent:e=>{m({kind:{type:`set_agent`,optionName:e.name},item:t,commit:()=>r.setAgent(t,e),offline:i==null?void 0:Id(i,t,`set_agent`,{agentOptionId:e.id})})},onSetStatus:e=>{m({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e),offline:i==null?void 0:Id(i,t,`set_status`,{statusName:e.name})})},onSetInTmuxByHuman:e=>{m({kind:{type:`set_in_tmux_by_human`,optionName:e.name},item:t,commit:()=>r.setInTmuxByHuman(t,e),offline:i==null?void 0:Ld(i,t)})},onClose:e=>{m({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e),offline:i==null?void 0:Id(i,t,e),onAdvance:()=>r.patchItemOverlay(t,!0),revertAdvance:()=>r.patchItemOverlay(t,!1)})},onOkAndAwaitingWorkspace:e=>{m({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e),onAdvance:()=>r.patchItemOverlay(t,!0,{name:e.name,color:e.color}),revertAdvance:()=>r.patchItemOverlay(t,!1)})},onDeleteAllComments:()=>{m({kind:{type:`delete_all_comments`},item:t,commit:()=>r.deleteAllComments(t)})},onDeleteStory:h??null,onSetDependedIssueUrl:i==null?null:async e=>{await r.setDependedIssueUrl(t,e)}},ne=(0,y.useCallback)(async e=>{await r.issueRename(t,e)},[t,r]),O=a.find(e=>e.name===`Awaiting Workspace`)??null,k=O===null?void 0:async e=>(p?.(``),D.onSetStatus(O),E(e)),A=async e=>{await E(e),D.onClose(`close`)},j=l??(t.story.trim()===``?null:t.story),re=j===null?null:R(c,j);return(0,x.jsx)(cd,{item:t,storyName:j,storyColorEnum:re,overlayStatus:u,statusOptions:a,state:_.state,stateError:_.stateError,body:_.body,bodyIsLoading:_.bodyIsLoading,bodyError:_.bodyError,comments:Ad(_.comments,ee),commentsAreLoading:_.commentsAreLoading,commentsError:_.commentsError,files:_.files,filesAreLoading:_.filesAreLoading,filesError:_.filesError,commits:_.commits,commitsAreLoading:_.commitsAreLoading,commitsError:_.commitsError,pullRequestStatus:_.pullRequestStatus,pullRequestStatusError:_.pullRequestStatusError,relatedPullRequests:_.relatedPullRequests,relatedPullRequestsError:_.relatedPullRequestsError,now:d,buildImageProxyUrl:v,renderReferenceLink:b,onAddInlineComment:T,onTitleRename:ne,commentComposer:(0,x.jsx)(bi,{initiallyOpen:!0,initialDraft:f,onSubmit:E,onDraftChange:p,onOkAndAwaitingWorkspace:O===null?void 0:()=>D.onOkAndAwaitingWorkspace(O),onSubmitAndMoveToAwaitingWorkspace:k,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,x.jsx)(bd,{tab:e,item:t,hasPullRequest:S,rejectEnabled:C.length>0,statusOptions:a,storyOptions:o,currentStoryName:j,agentOptions:s,currentAgentName:t.agent,handlers:D,storyNameForDeletion:g,onCommentAndClose:A})})},zd=()=>{let e={};for(let t of j)e[t.name]=0;return e},Bd=`console`,Vd=()=>{let e=Sr(),t=Kn(),n=ht(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o,refreshSingleTab:s}=ti(e,r),{timerMode:c,projectMinutes:l,isOpen:u,draftTimerMode:d,draftProjectMinutes:f,openSettings:p,closeSettings:m,saveSettings:h,toggleDraftTimerMode:g,changeDraftMinutes:_}=fi(),{pjcodes:v,projectUrls:b,fleetTaskCreateUrl:C,nameWithOwnerByPjcode:w,isLoading:ee}=Cr(),{isTimerExpired:te}=Dr(e),E=br(e??Bd),D=Er(v),ne=(0,y.useMemo)(()=>{let e=zd();for(let t of j){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=rr(n.items,ar(E.overlay,n.generatedAt),t.name))}return e},[i,E.overlay]),O=$n(e,ne),{activeTab:k,selectedItemKey:A,openItem:re,closeItem:M}=O,ie=ni(O.selectTab),P=wr((0,y.useCallback)(e=>ii(`/projects/${e}`),[])),F=(0,y.useRef)(new Map),I=(0,y.useCallback)(e=>{A!==null&&(e?F.current.set(A,e):F.current.delete(A))},[A]),oe=Rn(r),R=gr(e,k,E,oe,(0,y.useCallback)(()=>s(`queued`),[s])),z=Pn(),[le,B]=(0,y.useState)(()=>Date.now());(0,y.useEffect)(()=>{let e=setInterval(()=>{B(Date.now())},1e3);return()=>{clearInterval(e)}},[]);let[ue,de]=(0,y.useState)(!1),[fe,pe]=(0,y.useState)({title:``,body:null,storyName:null,agentOptionId:null}),[me,he]=(0,y.useState)(()=>navigator.onLine);(0,y.useEffect)(()=>{let e=()=>he(!0),t=()=>he(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)}},[]);let[ge,_e]=(0,y.useState)(new Map),[ve,ye]=(0,y.useState)(new Map),[be,xe]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{if(!(!me||z.offlineActions.length===0))for(let e of z.offlineActions)ge.has(e.id)||be.has(e.id)||(_e(t=>new Map(t).set(e.id,null)),oe.client.fetchIssueState(e.itemUrl).then(t=>{_e(n=>new Map(n).set(e.id,t)),e.isPr&&(ye(t=>new Map(t).set(e.id,null)),oe.client.fetchPullRequestStatus(e.itemUrl).then(t=>{ye(n=>new Map(n).set(e.id,t))}).catch(e=>{console.warn(`Failed to fetch PR status for offline action:`,e)}))}).catch(t=>{console.warn(`Failed to fetch current state for offline action:`,t),xe(t=>new Set(t).add(e.id))}))},[me,z.offlineActions,oe.client,ge,be]);let[we,Te]=(0,y.useState)(!1),De=(0,y.useCallback)(async e=>{Te(!0);try{await z.confirmOfflineAction(e)}finally{Te(!1)}},[z]),Oe=(0,y.useMemo)(()=>z.offlineActions.map(e=>{let t=ge.get(e.id)??null,n=ve.get(e.id)??null,r=be.has(e.id);return{id:e.id,message:e.message,color:e.color,itemNumber:e.itemNumber,isPr:e.isPr,currentTitle:r?null:t?.title??null,currentState:r||t===null?null:t.merged?`closed`:t.state,currentPrStatus:n,fetchError:r}}),[z.offlineActions,ge,ve,be]),ke=i[k],Ae=(0,y.useMemo)(()=>ke===null?[]:ir(ke.items,ar(E.overlay,ke.generatedAt),k),[ke,E.overlay,k]),[je,Me]=(0,y.useState)(null),Ne=(0,y.useMemo)(()=>{if(k!==`prs`)return{};let e={};for(let t of Ae)t.agent!==null&&t.agent!==``&&(e[t.agent]=(e[t.agent]??0)+1);return e},[Ae,k]);(0,y.useEffect)(()=>{k===`prs`&&je!==null&&(Ne[je]??0)===0&&Me(null)},[Ne,je,k]);let Pe=(0,y.useMemo)(()=>k!==`prs`||je===null?Ae:Ae.filter(e=>e.agent===je),[Ae,k,je]),Ie=(0,y.useMemo)(()=>Pe.map(e=>tr(e)),[Pe]),Le=ke?.storyOrder??[],Re=(0,y.useMemo)(()=>ce(Pe,E.overlay,Le,ke?.generatedAt??null),[Pe,E.overlay,Le,ke]),ze=ke?.storyColors??{},Ue=ke?.statusOptions??[],We=ke?.agentOptions??[],Ge=ke?.storyOptions??[],Ke=ke?.generatedAt??null,qe=ke?.fromCache??!1,[Je,Ye]=(0,y.useState)(null),Xe=(0,y.useMemo)(()=>A===null||ke===null?null:ke.items.find(e=>e.projectItemId===A)??null,[A,ke]);Wn(oe,Xe,Ae),(0,y.useEffect)(()=>{A!==null&&window.scrollTo({top:0})},[A]),(0,y.useEffect)(()=>{if(e===null&&c&&v.length>0){let e=ui(v,null,l);e!==null&&ai(`/projects/${e}`)}},[e,c,v,l]),di(c,ne.prs,ne[`todo-by-human`],e,v,l,i.prs!==null,i[`todo-by-human`]!==null,i.prs?.fromCache??!1,i[`todo-by-human`]?.fromCache??!1),ri(c,e,Pe,A,O.openItem);let Ze=ne[k],Qe=(0,y.useRef)({tab:k,count:Ze});(0,y.useEffect)(()=>{let e=Qe.current;if(Qe.current={tab:k,count:Ze},e.tab===k&&e.count>0&&Ze===0){let e=qn(k,ne);e!==null&&(ie(e),M())}},[k,Ze,ne,ie,M]);let $e=Xe===null?null:or(E.overlay,Xe,i[k]?.generatedAt??null),et=Xe===null?null:se(Xe,E.overlay,i[k]?.generatedAt??null),tt=(0,y.useCallback)(e=>{let t=pi(Ie,e);t===null?M():re(t)},[Ie,re,M]),nt=(0,y.useCallback)(t=>{if(n.status===`on`){z.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=tr(t.item);z.enqueue({message:yn(t.kind,t.item,k),color:_n(t.kind),commit:t.commit,offline:t.offline,revertAdvance:t.revertAdvance,advance:()=>{if(t.onAdvance?.(),!t.skipAdvance&&vn(t.kind,k)){if(c&&te(l[e??``]??0)){let t=ui(v,e,l);t!==null&&ii(`/projects/${t}`)}else tt(r)}}})},[z,k,tt,n.status,c,te,l,e,v]),rt=Rr((0,y.useCallback)(e=>{if(A===null||e===null)return;let t=e===`next`?mi(Ie,A):hi(Ie,A);t!==null&&re(t)},[A,Ie,re])),[it,at]=(0,y.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),ot=(0,y.useCallback)(()=>{at(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),st=i.stories,ct=st?.stories??[],lt=Je!==null&&Je.generatedAt===st?.generatedAt?Je.stories:ct,ut=st?.defaultNameWithOwner??null,dt=ut===null?null:`https://github.com/${ut}/issues/new`,ft=(0,y.useMemo)(()=>Xe===null||!Xe.labels.includes(`story`)?null:lt.find(e=>e.storyName===Xe.story)??null,[Xe,lt]),pt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(ut===null)throw Error(`No repository configured for this project.`);await Kt({pjcode:e,title:n,storyName:t,nameWithOwner:ut})},[e,ut]),mt=(0,y.useCallback)(({storyName:t,agentOptionId:n,title:r,body:i,files:a})=>{if(e===null||ut===null)return Promise.resolve();let o=e,s=ut;return z.enqueue({message:`Task created — "${r}"`,color:`blue`,commit:async()=>{let e=await Kt({pjcode:o,title:r,storyName:t??``,nameWithOwner:s,agentOptionId:n??null,body:i??null});if(a.length>0){let t=await Promise.all(a.map(async t=>{let n=Lt(new Uint8Array(await t.arrayBuffer()));return Rt({pjcode:o,url:e,fileName:t.name,contentBase64:n})})),n=await Ft({pjcode:o,url:e,body:t.join(`
89
+ `)[0],Zu=({commits:e,isLoading:t,error:n,now:r})=>n===null?t?(0,x.jsx)(`p`,{className:`console-commits-loading`,children:`Loading commits...`}):e.length===0?(0,x.jsx)(`p`,{className:`console-commits-empty`,children:`No commits.`}):(0,x.jsx)(`ul`,{className:`console-commits`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`console-commit`,children:[(0,x.jsx)(`span`,{className:`console-commit-message`,children:Xu(e.message)}),(0,x.jsx)(`span`,{className:`console-commit-sha`,children:Yu(e.sha)}),(0,x.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,x.jsx)(`span`,{className:`console-commit-time`,children:O(e.authoredAt,r)})]},e.sha))}):(0,x.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Qu=({url:e,label:t=`Copy URL`})=>(0,x.jsx)(iu,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),$u=e=>{let t=new Map;for(let n of e){let e=t.get(n.message);if(e===void 0){t.set(n.message,[n.section]);continue}e.push(n.section)}return Array.from(t,([e,t])=>({message:e,sections:t}))},ed=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,td=({failures:e})=>e.length===0?null:(0,x.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:$u(e).map(e=>(0,x.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,ed(e.sections),`:`,` `,e.message]},e.message))}),nd=({title:e,onTitleRename:t})=>{let[n,r]=(0,y.useState)(e),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(e),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(e);(0,y.useEffect)(()=>{let t=e!==f.current;f.current=e,!i&&t&&r(e)},[e,i]);let p=()=>{s(n),d(null),a(!0)},m=()=>{a(!1),d(null)},h=async()=>{let e=o.trim();if(e===``||e===n){a(!1);return}l(!0),d(null);try{await t(e),r(e),a(!1)}catch(e){d(e instanceof Error?e.message:`Failed to rename`)}finally{l(!1)}};return i?(0,x.jsxs)(`span`,{className:`console-detail-title-text console-detail-title-text--editing`,children:[(0,x.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&m()},disabled:c,className:`console-detail-title-input`,"aria-label":`Edit title`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>void h(),disabled:c,className:`console-detail-title-save`,children:`Save`}),(0,x.jsx)(`button`,{type:`button`,onClick:m,disabled:c,className:`console-detail-title-cancel`,children:`Cancel`}),u!==null&&(0,x.jsx)(`span`,{className:`console-detail-title-error`,role:`alert`,children:u})]}):(0,x.jsxs)(`span`,{className:`console-detail-title-text`,children:[n,(0,x.jsx)(`button`,{type:`button`,onClick:p,className:`console-detail-title-edit`,"aria-label":`Edit title`,children:`Edit`})]})},rd={MERGEABLE:{color:`GREEN`,label:`No conflict`,title:`This pull request has no merge conflicts`,modifier:`console-detail-mergeable-chip-ok`},CONFLICTING:{color:`RED`,label:`Conflict`,title:`This pull request has merge conflicts`,modifier:`console-detail-mergeable-chip-conflict`},UNKNOWN:{color:`GRAY`,label:`Checking merge status`,title:`GitHub has not finished computing the merge status yet`,modifier:`console-detail-mergeable-chip-unknown`}},id=({mergeableStatus:e})=>{let t=rd[e],n=F(t.color);return(0,x.jsx)(`span`,{className:`console-detail-status-chip console-detail-mergeable-chip ${t.modifier}`,style:{color:n.fg,borderColor:n.border,backgroundColor:n.bg},title:t.title,children:t.label})},ad=e=>{let t=F(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},od=({isPassedAllCiJob:e,isCiStateSuccess:t,isBranchOutOfDate:n,missingRequiredCheckNames:r})=>{let i=e&&t,a=i?`GREEN`:`RED`,o=i?`CI passing`:`CI failing`,s=!i&&r.length>0?`missing: ${r.join(`, `)}`:null;return(0,x.jsxs)(`span`,{className:`console-detail-pr-status`,children:[(0,x.jsxs)(`span`,{className:`console-detail-status-chip console-detail-ci-chip`,style:ad(a),title:s??o,children:[o,s!==null&&(0,x.jsxs)(`span`,{className:`console-detail-ci-missing`,children:[` `,`(`,s,`)`]})]}),n&&(0,x.jsx)(`span`,{className:`console-detail-status-chip console-detail-outofdate-chip`,style:ad(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},sd=({pullRequest:e,body:t,bodyIsLoading:n,files:r,filesAreLoading:i,filesError:a,commits:o,commitsAreLoading:s,commitsError:c,now:l,buildImageProxyUrl:u,renderReferenceLink:d,onAddInlineComment:f})=>{let p=e.summary,m=Si(e.url),h=m===null?void 0:{owner:m.owner,repo:m.repo},g=i||a!==null?null:r.length,_=s||c!==null?null:o.length;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`console-pr-header`,children:[(0,x.jsx)(`a`,{href:e.url,className:`console-pr-section-title`,target:`_blank`,rel:`noopener noreferrer`,children:p?.title??e.url}),e.isDraft&&(0,x.jsx)(`span`,{className:`console-pr-section-state`,children:`draft`}),(0,x.jsx)(id,{mergeableStatus:e.mergeableStatus}),(0,x.jsx)(od,{isPassedAllCiJob:e.isPassedAllCiJob,isCiStateSuccess:e.isCiStateSuccess,isBranchOutOfDate:e.isBranchOutOfDate,missingRequiredCheckNames:e.missingRequiredCheckNames}),(0,x.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),(0,x.jsx)(Qu,{url:e.url,label:`Copy PR URL`}),(0,x.jsxs)(`div`,{className:`console-pr-statbar`,children:[m!==null&&(0,x.jsxs)(`span`,{className:`console-pr-repo`,children:[m.owner,`/`,m.repo]}),e.branchName!==null&&(0,x.jsx)(`span`,{className:`console-pr-branch`,children:e.branchName}),p!==null&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`span`,{className:`console-pr-add`,children:[`+`,p.additions]}),(0,x.jsxs)(`span`,{className:`console-pr-del`,children:[`-`,p.deletions]}),(0,x.jsxs)(`span`,{className:`console-pr-files-count`,children:[p.changedFiles,` files`]})]})]})]}),(0,x.jsx)(Eu,{title:`Description`,children:n?(0,x.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,x.jsx)(Tu,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,x.jsx)(Eu,{title:`Changed files`,count:g,children:(0,x.jsx)(Wu,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,x.jsx)(Eu,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,x.jsx)(Zu,{commits:o,isLoading:s,error:c,now:l})})]})},cd=({item:e,storyName:t,storyColorEnum:n,overlayStatus:r,statusOptions:i,state:a,body:o,bodyIsLoading:s,bodyError:c,comments:l,commentsAreLoading:u,commentsError:d,files:f,filesAreLoading:p,filesError:m,commits:h,commitsAreLoading:g,commitsError:_,stateError:v,pullRequestStatus:y,pullRequestStatusError:b,relatedPullRequests:S,relatedPullRequestsError:C,now:w,commentComposer:T,operationBar:ee,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:D,onTitleRename:ne})=>{let k=a?.state??`open`,j=a?.merged??!1,re=!e.isPr&&k===`closed`?`Closed`:null,M=Ci(e.nameWithOwner)??void 0,N=F(n),ie=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,ae=ie===null?null:F(ie.color),P=p||m!==null?null:f.length,I=u||d!==null?null:l.length,L=g||_!==null?null:h.length,oe=!u&&d===null&&l.length>0,R=e=>{let t=Si(e);return t===null?e:`PR #${t.number}`},se=[{section:`item state`,message:v},{section:`pull request status`,message:e.isPr?b:null},{section:`description`,message:c},{section:`comments`,message:d},{section:`changed files`,message:e.isPr?m:null},{section:`commits`,message:e.isPr?_:null},{section:`related pull requests`,message:e.isPr?null:C},...S.flatMap(e=>[{section:`changed files of ${R(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${R(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),z=e.isPr&&y?.found?[{url:e.url,mergeableStatus:y.mergeableStatus}]:[];return(0,x.jsxs)(`article`,{className:`console-detail`,children:[(0,x.jsxs)(`div`,{className:`console-detail-header`,children:[(0,x.jsxs)(`h2`,{className:`console-detail-title`,children:[(0,x.jsx)(ye,{isPr:e.isPr,state:k,merged:j,isDraft:!1,stateReason:``}),ne==null?(0,x.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}):(0,x.jsx)(nd,{title:e.title,onTitleRename:ne}),(0,x.jsx)(`span`,{className:`console-detail-number`,children:e.isPr?`PR #${e.number}`:`#${e.number}`})]}),(0,x.jsxs)(`div`,{className:`console-detail-topline`,children:[ie!==null&&ae!==null&&(0,x.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:ae.fg,borderColor:ae.border,backgroundColor:ae.bg},children:ie.name}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-detail-agent-chip`,children:e.agent}),t!==null&&(0,x.jsxs)(`span`,{className:`console-storytag`,children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:N.dot}}),t]}),e.isPr&&y?.found&&(0,x.jsx)(od,{isPassedAllCiJob:y.isPassedAllCiJob,isCiStateSuccess:y.isCiStateSuccess,isBranchOutOfDate:y.isBranchOutOfDate,missingRequiredCheckNames:y.missingRequiredCheckNames}),!e.isPr&&S.map(e=>(0,x.jsxs)(`span`,{className:`console-related-pr-group`,children:[S.length>1&&(0,x.jsx)(`span`,{className:`console-related-pr-label`,children:R(e.pullRequest.url)}),(0,x.jsx)(od,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,x.jsx)(id,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),z.map(e=>(0,x.jsx)(id,{mergeableStatus:e.mergeableStatus},e.url)),re!==null&&(0,x.jsx)(`span`,{className:`console-detail-closed-label`,children:re})]}),(0,x.jsx)(td,{failures:se}),(0,x.jsxs)(`div`,{className:`console-detail-subbar`,children:[(0,x.jsxs)(`a`,{href:e.url,className:`console-detail-link`,target:`_blank`,rel:`noopener noreferrer`,children:[`#`,e.number]}),(0,x.jsx)(`span`,{className:`console-detail-repo`,children:e.repo}),(0,x.jsxs)(`span`,{className:`console-detail-createdat`,title:A(e.createdAt),children:[`opened `,O(e.createdAt,w)]}),(0,x.jsx)(Qu,{url:e.url}),e.labels.map(e=>(0,x.jsx)(`span`,{className:`console-label-chip`,children:e},e))]})]}),(0,x.jsxs)(`div`,{className:`console-detail-body`,children:[(0,x.jsx)(Eu,{title:`Description`,defaultCollapsed:oe,headerAction:(0,x.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),children:c===null?s?(0,x.jsx)(`p`,{className:`console-detail-body-loading`,children:`Loading description...`}):(0,x.jsx)(Tu,{body:o,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:M}):(0,x.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})},oe?`desc-collapsed`:`desc-open`),e.isPr&&(0,x.jsx)(Eu,{title:`Changed files`,count:P,children:(0,x.jsx)(Wu,{files:f,isLoading:p,error:m,onAddInlineComment:D})}),(0,x.jsx)(Eu,{title:`Comments`,count:I,children:(0,x.jsx)(Ju,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:M,persistenceKey:e.url})}),e.isPr&&(0,x.jsx)(Eu,{title:`Commits`,count:L,defaultCollapsed:!0,children:(0,x.jsx)(Zu,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&S.map(e=>(0,x.jsx)(sd,{pullRequest:e.pullRequest,body:e.pullRequest.summary?.body??``,bodyIsLoading:!1,files:e.files,filesAreLoading:e.filesAreLoading,filesError:e.filesError,commits:e.commits,commitsAreLoading:e.commitsAreLoading,commitsError:e.commitsError,now:w,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:D},e.pullRequest.url))]}),(0,x.jsxs)(`div`,{className:`console-detail-dock`,children:[(0,x.jsx)(`div`,{className:`console-detail-dock-composer`,children:T}),(0,x.jsx)(`div`,{className:`console-actionbar`,children:ee})]})]})},ld=({className:e,ariaLabel:t,placeholder:n,currentOption:r,options:i,onSelect:a})=>{let o=(0,y.useRef)({ready:!1,currentOptionId:r?.id??null});return(0,y.useLayoutEffect)(()=>{o.current.ready=!0,o.current.currentOptionId=r?.id??null}),(0,x.jsxs)(`select`,{className:e,defaultValue:r?.id??``,onChange:e=>{if(!o.current.ready||e.target.value===(o.current.currentOptionId??``))return;let t=i.find(t=>t.id===e.target.value);t!==void 0&&a(t)},"aria-label":t,children:[(0,x.jsx)(`option`,{value:``,children:n}),i.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})},ud=({agentOptions:e,currentAgentName:t,onSetAgent:n})=>{if(e.length===0)return null;let r=t===null?null:e.find(e=>e.name===t)??null;return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(ld,{className:`console-agent-select`,ariaLabel:`Set agent`,placeholder:`— agent —`,currentOption:r,options:e,onSelect:n},r?.id??`none`)})},dd=({onClose:e,onCommentAndClose:t})=>{let[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),u=async()=>{let e=i.trim();if(!(!e||o||t===void 0)){s(!0),l(null);try{await t(e),a(``),r(!1)}catch(e){l(e instanceof Error?e.message:`failed to post`)}finally{s(!1)}}};return(0,x.jsxs)(`div`,{className:`console-op-group`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close_not_planned`),children:`Close as not planned`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close`),children:`Close`}),t!==void 0&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>r(e=>!e),children:`Comment & Close`}),n&&(0,x.jsxs)(`div`,{className:`console-op-comment-and-close`,children:[(0,x.jsx)(`textarea`,{className:`console-op-comment-and-close-input`,placeholder:`Leave a comment…`,value:i,onChange:e=>a(e.target.value)}),c!==null&&(0,x.jsx)(`span`,{role:`alert`,className:`console-op-comment-and-close-error`,children:c}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,disabled:o||i.trim().length===0,onClick:()=>{u()},children:`Submit`})]})]})]})},fd=({onDeleteAllComments:e,onDeleteStory:t,storyNameForDeletion:n})=>{let[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=()=>{e(),i(!1)},f=()=>{o(!0),u(null)},p=async e=>{if(t){c(!0),u(null);try{await t(e)}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}}};return(0,x.jsxs)(`div`,{className:`console-op-group`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>i(e=>!e),children:`⚠`}),r&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:d,children:`Delete All Comments`}),t!=null&&(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:f,disabled:a,children:`Delete Story`})]}),a&&(0,x.jsxs)(`div`,{className:`console-story-delete-confirm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Confirm story deletion`,children:[(0,x.jsxs)(`p`,{className:`console-story-delete-confirm-message`,children:[`Delete story option "`,n,`" from the GitHub custom field?`]}),l!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:l}),(0,x.jsxs)(`div`,{className:`console-story-delete-confirm-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>void p(!0),disabled:s,children:s?`Deleting…`:`Delete with child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>void p(!1),disabled:s,children:s?`Deleting…`:`Keep child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{o(!1),u(null)},disabled:s,children:`Cancel`})]})]})]})},pd=({isManualTriage:e,onSetNextActionDate:t})=>(0,x.jsxs)(`div`,{className:`console-op-group`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1hour`),children:`+1h`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3hours`),children:`+3h`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_6hours`),children:`+6h`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1day`),children:`+1d`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_2days`),children:`+2d`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3days`),children:`+3d`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_5days`),children:`+5d`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1week`),children:e?`+1w skip`:`+1w`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1month`),children:`+1mo`})]}),md=[{action:`unnecessary`,label:`Unnecessary`,variant:`unneeded`},{action:`totally_wrong`,label:`Totally wrong`,variant:`wrong`},{action:`request_changes`,label:`Reject`,variant:`reject`},{action:`approve_and_merge`,label:`Approve & Merge`,variant:`approve`}],hd=`Reject needs an inline comment on the diff.`,gd=({onReview:e,rejectEnabled:t})=>(0,x.jsxs)(`div`,{className:`console-op-group console-op-group-review`,children:[!t&&(0,x.jsx)(`p`,{className:`console-op-requirement`,children:hd}),md.map(n=>{let r=n.action===`request_changes`&&!t;return(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-${n.variant}`,disabled:r,onClick:()=>e(n.action),children:n.label},n.action)})]}),_d=({onSetDependedIssueUrl:e})=>{let[t,n]=(0,y.useState)(!1),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null);return(0,x.jsxs)(`div`,{className:`console-op-group console-op-group-rare-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{n(e=>!e),c(null)},title:`Rare actions`,children:`⋯`}),t&&e!==null&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`input`,{type:`url`,className:`console-settings-modal-input`,placeholder:`Depended issue URL`,value:r,onChange:e=>i(e.target.value),disabled:a}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:async()=>{if(e!==null&&r.trim()!==``){o(!0),c(null);try{await e(r.trim()),i(``),n(!1)}catch(e){c(e instanceof Error?e.message:`Failed to set depended issue URL`)}finally{o(!1)}}},disabled:a||r.trim()===``,children:a?`...`:`Set Depended Issue`})]}),s!==null&&(0,x.jsx)(`p`,{className:`console-settings-modal-error`,children:s})]})},vd=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},$=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=me.map(t=>({name:t,option:vd(e,t)})).filter(e=>e.option!==null);return r.length===0?null:(0,x.jsx)(`div`,{className:`console-op-group`,children:r.map(({name:e,option:r})=>{let i=F(r.color),a=e===fe;return(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:i.fg,borderColor:i.border,backgroundColor:i.bg},onClick:()=>a?n(r):t(r),children:r.name},r.id)})})},yd=({storyOptions:e,currentStoryName:t,onSetStory:n})=>{if(e.length===0)return null;let r=t===null?null:e.find(e=>e.name===t)??null;return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(ld,{className:`console-story-select`,ariaLabel:`Set story`,placeholder:`— story —`,currentOption:r,options:e,onSelect:n},r?.id??`none`)})},bd=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,storyOptions:i,currentStoryName:a,agentOptions:o,currentAgentName:s,handlers:c,storyNameForDeletion:l,onCommentAndClose:u})=>{let[d,f]=(0,y.useState)(!1);return(0,x.jsxs)(`div`,{className:`console-operation-bar`,children:[t&&(0,x.jsx)(gd,{onReview:c.onReview,rejectEnabled:n}),(0,x.jsx)(pd,{isManualTriage:he(e),onSetNextActionDate:c.onSetNextActionDate}),(0,x.jsx)($,{statusOptions:r,onSetStatus:c.onSetStatus,onSetInTmuxByHuman:c.onSetInTmuxByHuman}),d&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(yd,{storyOptions:i,currentStoryName:a,onSetStory:c.onSetStory}),(0,x.jsx)(ud,{agentOptions:o,currentAgentName:s,onSetAgent:c.onSetAgent})]}),(0,x.jsxs)(`div`,{className:`console-op-group-bottom-row`,children:[(0,x.jsxs)(`div`,{className:`console-op-group-left-pair`,children:[(i.length>0||o.length>0)&&(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>f(e=>!e),title:`Change agent or story`,children:`⚙`})}),(0,x.jsx)(_d,{onSetDependedIssueUrl:c.onSetDependedIssueUrl}),(0,x.jsx)(fd,{onDeleteAllComments:c.onDeleteAllComments,onDeleteStory:c.onDeleteStory,storyNameForDeletion:l})]}),(0,x.jsx)(dd,{onClose:c.onClose,onCommentAndClose:u})]})]})},xd=(e,t,n,r)=>{let i=t===null?void 0:e.peek(t),[a,o]=(0,y.useState)(i??r),[s,c]=(0,y.useState)(t!==null&&i===void 0),[l,u]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(t===null||n===null)return;let r=e.peek(t);if(r!==void 0){o(r),c(!1),u(null);return}let i=!1;return c(!0),u(null),e.load(t,n).then(e=>{i||(o(e),c(!1))}).catch(e=>{i||(u(e instanceof Error?e.message:String(e)),c(!1))}),()=>{i=!0}},[e,t,n]),{data:a,isLoading:s,error:l}},Sd=[],Cd=[],wd=[],Td=[],Ed={state:`open`,merged:!1,isPullRequest:!1,title:``},Dd={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},Od=(e,t,n)=>{let r=t===null?null:`${t.repo}#${t.number}`,i=t===null?null:t.url,a=t?.isPr??!1,o=xd(e.body,r,i,``),s=xd(e.state,r,i,Ed),c=xd(e.comments,r,i,Sd),l=xd(e.files,a?r:null,a?i:null,Cd),u=xd(e.commits,a?r:null,a?i:null,wd),d=xd(e.prStatus,a?r:null,a?i:null,Dd),f=!a&&((t?.relatedOpenPullRequestUrls.length??0)>0||n===`prs`),p=xd(e.relatedPrs,f?r:null,f?i:null,Td),[m,h]=(0,y.useState)([]);return(0,y.useEffect)(()=>{if(a||p.data.length===0){h([]);return}let t=!1,n=p.data.map(e=>({pullRequest:e,files:Cd,filesAreLoading:!0,filesError:null,commits:wd,commitsAreLoading:!0,commitsError:null}));h(n);let r=(e,n)=>{t||h(t=>t.map(t=>t.pullRequest.url===e?{...t,...n}:t))};for(let t of p.data){let n=t.url;e.files.load(n,t.url).then(e=>r(t.url,{files:e,filesAreLoading:!1})).catch(e=>r(t.url,{filesAreLoading:!1,filesError:e instanceof Error?e.message:String(e)})),e.commits.load(n,t.url).then(e=>r(t.url,{commits:e,commitsAreLoading:!1})).catch(e=>r(t.url,{commitsAreLoading:!1,commitsError:e instanceof Error?e.message:String(e)}))}return()=>{t=!0}},[e,a,p.data]),{state:s.data,body:o.data,bodyIsLoading:o.isLoading,bodyError:o.error,comments:c.data,commentsAreLoading:c.isLoading,commentsError:c.error,files:l.data,filesAreLoading:l.isLoading,filesError:l.error,commits:u.data,commitsAreLoading:u.isLoading,commitsError:u.error,stateError:s.error,pullRequestStatus:a?d.data:null,pullRequestStatusError:a?d.error:null,relatedPullRequests:m,relatedPullRequestsError:a?null:p.error}},kd=e=>JSON.stringify([e.author,e.createdAt,e.body]),Ad=(e,t)=>{let n=new Set(e.map(kd));return[...e,...t.filter(e=>!n.has(kd(e)))]},jd=({href:e,fallbackText:t,state:n})=>{if(n===null||n.title.trim()===``)return(0,x.jsx)(`a`,{className:`console-markdown-reference console-markdown-reference-plain`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t});let r=Si(e);return(0,x.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,x.jsx)(ye,{...wi(n)}),(0,x.jsx)(`span`,{className:`console-markdown-reference-title`,children:n.title}),r!==null&&(0,x.jsxs)(`span`,{className:`console-markdown-reference-number`,children:[`#`,r.number]})]})},Md=(e,t)=>{let[n,r]=(0,y.useState)(()=>e.peek(t)??null);return(0,y.useEffect)(()=>{let n=e.peek(t);if(n!==void 0){r(n);return}let i=!1;return r(null),e.load(t,t).then(e=>{i||r(e)}).catch(()=>{i||r(null)}),()=>{i=!0}},[e,t]),n},Nd=({cache:e,href:t,fallbackText:n})=>{let r=Md(e,t);return(0,x.jsx)(jd,{href:t,fallbackText:n,state:r})},Pd=e=>({itemUrl:e.url,projectItemId:e.projectItemId,itemNumber:e.number,repo:e.repo,isPr:e.isPr}),Fd=(e,t,n,r,i)=>({...Pd(t),apiPath:cr,requestBody:dr(e,t,n,r,i)}),Id=(e,t,n,r)=>({...Pd(t),apiPath:lr,requestBody:fr(e,t,n,r)}),Ld=(e,t)=>({...Pd(t),apiPath:ur,requestBody:pr(e,t)}),Rd=({tab:e,item:t,caches:n,operations:r,pjcode:i,statusOptions:a,storyOptions:o,agentOptions:s,storyColors:c,storyName:l,overlayStatus:u,now:d,initialCommentDraft:f,onCommentDraftChange:p,onQueueAction:m,onDeleteStory:h,storyNameForDeletion:g})=>{let _=Od(n,t,e),v=(0,y.useCallback)(e=>Di(e,t.url),[t.url]),b=(0,y.useCallback)((e,t)=>(0,x.jsx)(Nd,{cache:n.state,href:e,fallbackText:t}),[n.state]),S=t.isPr||t.relatedOpenPullRequestUrls.length>0||_.relatedPullRequests.length>0,[C,w]=(0,y.useState)([]),T=(0,y.useCallback)(async(e,t,n,r)=>{w(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[ee,te]=(0,y.useState)([]),E=(0,y.useCallback)(async e=>{let n=await r.addComment(t,e);return te(e=>[...e,n]),n},[t,r]),D={onReview:e=>{let n=t.isPr?t.url:_.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,a=e===`request_changes`?C:[];m({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,a),offline:i==null?void 0:Fd(i,t,n,e,a),...e===`approve_and_merge`?{onAdvance:()=>r.patchItemOverlay(t,!0),revertAdvance:()=>r.patchItemOverlay(t,!1)}:{}})},onSetNextActionDate:e=>{m({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e),offline:i==null?void 0:Id(i,t,e)})},onSetStory:e=>{m({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e),offline:i==null?void 0:Id(i,t,`set_story`,{storyOptionId:e.id})})},onSetAgent:e=>{m({kind:{type:`set_agent`,optionName:e.name},item:t,commit:()=>r.setAgent(t,e),offline:i==null?void 0:Id(i,t,`set_agent`,{agentOptionId:e.id})})},onSetStatus:e=>{m({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e),offline:i==null?void 0:Id(i,t,`set_status`,{statusName:e.name})})},onSetInTmuxByHuman:e=>{m({kind:{type:`set_in_tmux_by_human`,optionName:e.name},item:t,commit:()=>r.setInTmuxByHuman(t,e),offline:i==null?void 0:Ld(i,t)})},onClose:e=>{m({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e),offline:i==null?void 0:Id(i,t,e),onAdvance:()=>r.patchItemOverlay(t,!0),revertAdvance:()=>r.patchItemOverlay(t,!1)})},onOkAndAwaitingWorkspace:e=>{m({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e),onAdvance:()=>r.patchItemOverlay(t,!0,{name:e.name,color:e.color}),revertAdvance:()=>r.patchItemOverlay(t,!1)})},onDeleteAllComments:()=>{m({kind:{type:`delete_all_comments`},item:t,commit:()=>r.deleteAllComments(t)})},onDeleteStory:h??null,onSetDependedIssueUrl:i==null?null:async e=>{await r.setDependedIssueUrl(t,e)}},ne=(0,y.useCallback)(async e=>{await r.issueRename(t,e)},[t,r]),O=a.find(e=>e.name===`Awaiting Workspace`)??null,k=O===null?void 0:async e=>(p?.(``),D.onSetStatus(O),E(e)),A=async e=>{await E(e),D.onClose(`close`)},j=l??(t.story.trim()===``?null:t.story),re=j===null?null:R(c,j);return(0,x.jsx)(cd,{item:t,storyName:j,storyColorEnum:re,overlayStatus:u,statusOptions:a,state:_.state,stateError:_.stateError,body:_.body,bodyIsLoading:_.bodyIsLoading,bodyError:_.bodyError,comments:Ad(_.comments,ee),commentsAreLoading:_.commentsAreLoading,commentsError:_.commentsError,files:_.files,filesAreLoading:_.filesAreLoading,filesError:_.filesError,commits:_.commits,commitsAreLoading:_.commitsAreLoading,commitsError:_.commitsError,pullRequestStatus:_.pullRequestStatus,pullRequestStatusError:_.pullRequestStatusError,relatedPullRequests:_.relatedPullRequests,relatedPullRequestsError:_.relatedPullRequestsError,now:d,buildImageProxyUrl:v,renderReferenceLink:b,onAddInlineComment:T,onTitleRename:ne,commentComposer:(0,x.jsx)(bi,{initiallyOpen:!0,initialDraft:f,onSubmit:E,onDraftChange:p,onOkAndAwaitingWorkspace:O===null?void 0:()=>D.onOkAndAwaitingWorkspace(O),onSubmitAndMoveToAwaitingWorkspace:k,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,x.jsx)(bd,{tab:e,item:t,hasPullRequest:S,rejectEnabled:C.length>0,statusOptions:a,storyOptions:o,currentStoryName:j,agentOptions:s,currentAgentName:t.agent,handlers:D,storyNameForDeletion:g,onCommentAndClose:A})})},zd=()=>{let e={};for(let t of j)e[t.name]=0;return e},Bd=`console`,Vd=()=>{let e=Sr(),t=Kn(),n=ht(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o,refreshSingleTab:s}=ti(e,r),{timerMode:c,projectMinutes:l,isOpen:u,draftTimerMode:d,draftProjectMinutes:f,openSettings:p,closeSettings:m,saveSettings:h,toggleDraftTimerMode:g,changeDraftMinutes:_}=fi(),{pjcodes:v,projectUrls:b,fleetTaskCreateUrl:C,nameWithOwnerByPjcode:w,isLoading:ee}=Cr(),{isTimerExpired:te}=Dr(e),E=br(e??Bd),D=Er(v),ne=(0,y.useMemo)(()=>{let e=zd();for(let t of j){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=rr(n.items,ar(E.overlay,n.generatedAt),t.name))}return e},[i,E.overlay]),O=$n(e,ne),{activeTab:k,selectedItemKey:A,openItem:re,closeItem:M}=O,ie=ni(O.selectTab),P=wr((0,y.useCallback)(e=>ii(`/projects/${e}`),[])),F=(0,y.useRef)(new Map),I=(0,y.useCallback)(e=>{A!==null&&(e?F.current.set(A,e):F.current.delete(A))},[A]),oe=Rn(r),R=gr(e,k,E,oe,(0,y.useCallback)(()=>s(`queued`),[s])),z=Pn(),[le,B]=(0,y.useState)(()=>Date.now());(0,y.useEffect)(()=>{let e=setInterval(()=>{B(Date.now())},1e3);return()=>{clearInterval(e)}},[]);let[ue,de]=(0,y.useState)(!1),[fe,pe]=(0,y.useState)({title:``,body:null,storyName:null,agentOptionId:null}),[me,he]=(0,y.useState)(()=>navigator.onLine);(0,y.useEffect)(()=>{let e=()=>he(!0),t=()=>he(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)}},[]);let[ge,_e]=(0,y.useState)(new Map),[ve,ye]=(0,y.useState)(new Map),[be,xe]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{if(!(!me||z.offlineActions.length===0))for(let e of z.offlineActions)ge.has(e.id)||be.has(e.id)||(_e(t=>new Map(t).set(e.id,null)),oe.client.fetchIssueState(e.itemUrl).then(t=>{_e(n=>new Map(n).set(e.id,t)),e.isPr&&(ye(t=>new Map(t).set(e.id,null)),oe.client.fetchPullRequestStatus(e.itemUrl).then(t=>{ye(n=>new Map(n).set(e.id,t))}).catch(e=>{console.warn(`Failed to fetch PR status for offline action:`,e)}))}).catch(t=>{console.warn(`Failed to fetch current state for offline action:`,t),xe(t=>new Set(t).add(e.id))}))},[me,z.offlineActions,oe.client,ge,be]);let[we,Te]=(0,y.useState)(!1),De=(0,y.useCallback)(async e=>{Te(!0);try{await z.confirmOfflineAction(e)}finally{Te(!1)}},[z]),Oe=(0,y.useMemo)(()=>z.offlineActions.map(e=>{let t=ge.get(e.id)??null,n=ve.get(e.id)??null,r=be.has(e.id);return{id:e.id,message:e.message,color:e.color,itemNumber:e.itemNumber,isPr:e.isPr,currentTitle:r?null:t?.title??null,currentState:r||t===null?null:t.merged?`closed`:t.state,currentPrStatus:n,fetchError:r}}),[z.offlineActions,ge,ve,be]),ke=i[k],Ae=(0,y.useMemo)(()=>ke===null?[]:ir(ke.items,ar(E.overlay,ke.generatedAt),k),[ke,E.overlay,k]),[je,Me]=(0,y.useState)(null),Ne=(0,y.useMemo)(()=>{if(k!==`prs`)return{};let e={};for(let t of Ae)t.agent!==null&&t.agent!==``&&(e[t.agent]=(e[t.agent]??0)+1);return e},[Ae,k]);(0,y.useEffect)(()=>{k===`prs`&&je!==null&&(Ne[je]??0)===0&&Me(null)},[Ne,je,k]);let Pe=(0,y.useMemo)(()=>k!==`prs`||je===null?Ae:Ae.filter(e=>e.agent===je),[Ae,k,je]),Ie=(0,y.useMemo)(()=>Pe.map(e=>tr(e)),[Pe]),Le=ke?.storyOrder??[],Re=(0,y.useMemo)(()=>ce(Pe,E.overlay,Le,ke?.generatedAt??null),[Pe,E.overlay,Le,ke]),ze=ke?.storyColors??{},Ue=ke?.statusOptions??[],We=ke?.agentOptions??[],Ge=ke?.storyOptions??[],Ke=ke?.generatedAt??null,qe=ke?.fromCache??!1,[Je,Ye]=(0,y.useState)(null),Xe=(0,y.useMemo)(()=>A===null||ke===null?null:ke.items.find(e=>e.projectItemId===A)??null,[A,ke]);Wn(oe,Xe,Ae),(0,y.useEffect)(()=>{A!==null&&window.scrollTo({top:0})},[A]),(0,y.useEffect)(()=>{if(e===null&&c&&v.length>0){let e=ui(v,null,l);e!==null&&ai(`/projects/${e}`)}},[e,c,v,l]),di(c,ne.prs,ne[`todo-by-human`],e,v,l,i.prs!==null,i[`todo-by-human`]!==null,i.prs?.fromCache??!1,i[`todo-by-human`]?.fromCache??!1),ri(c,e,Pe,A,O.openItem);let Ze=ne[k],Qe=(0,y.useRef)({tab:k,count:Ze});(0,y.useEffect)(()=>{let e=Qe.current;if(Qe.current={tab:k,count:Ze},e.tab===k&&e.count>0&&Ze===0){let e=qn(k,ne);e!==null&&(ie(e),M())}},[k,Ze,ne,ie,M]);let $e=Xe===null?null:or(E.overlay,Xe,i[k]?.generatedAt??null),et=Xe===null?null:se(Xe,E.overlay,i[k]?.generatedAt??null),tt=(0,y.useCallback)(e=>{let t=pi(Ie,e);t===null?M():re(t)},[Ie,re,M]),nt=(0,y.useCallback)(t=>{if(n.status===`on`){z.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=tr(t.item);z.enqueue({message:yn(t.kind,t.item,k),color:_n(t.kind),commit:t.commit,offline:t.offline,revertAdvance:t.revertAdvance,advance:()=>{if(t.onAdvance?.(),!t.skipAdvance&&vn(t.kind,k)){if(c&&te(l[e??``]??0)){let t=ui(v,e,l);t!==null&&ii(`/projects/${t}`)}else tt(r)}}})},[z,k,tt,n.status,c,te,l,e,v]),rt=Rr((0,y.useCallback)(e=>{if(A===null||e===null)return;let t=e===`next`?mi(Ie,A):hi(Ie,A);t!==null&&re(t)},[A,Ie,re])),[it,at]=(0,y.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),ot=(0,y.useCallback)(()=>{at(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),st=i.stories,ct=st?.stories??[],lt=Je!==null&&Je.generatedAt===st?.generatedAt?Je.stories:ct,ut=st?.defaultNameWithOwner??null,dt=ut===null?null:`https://github.com/${ut}/issues/new`,ft=(0,y.useMemo)(()=>Xe===null||!Xe.labels.includes(`story`)?null:lt.find(e=>e.storyName===Xe.story)??null,[Xe,lt]),pt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(ut===null)throw Error(`No repository configured for this project.`);await Kt({pjcode:e,title:n,storyName:t,nameWithOwner:ut})},[e,ut]),mt=(0,y.useCallback)(({storyName:t,agentOptionId:n,title:r,body:i,files:a})=>{if(e===null||ut===null)return Promise.resolve();let o=e,s=ut;return z.enqueue({message:`Task created — "${r}"`,color:`blue`,commit:async()=>{let e=await Kt({pjcode:o,title:r,storyName:t??``,nameWithOwner:s,agentOptionId:n??null,body:i??null});if(a.length>0){let t=await Promise.all(a.map(async t=>{let n=Lt(new Uint8Array(await t.arrayBuffer()));return Rt({pjcode:o,url:e,fileName:t.name,contentBase64:n})})),n=await Ft({pjcode:o,url:e,body:t.join(`
90
90
 
91
91
  `)});if(!n.posted)throw Error(n.error)}},advance:()=>{}}),pe({title:``,body:null,storyName:null,agentOptionId:null}),Promise.resolve()},[e,ut,z]),gt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Jt({pjcode:e,storyOptionId:t,direction:n});let r=lt.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<lt.length){let t=[...lt],n=t[r];t[r]=t[e],t[e]=n,Ye({generatedAt:st?.generatedAt,stories:t})}}},[e,lt,st?.generatedAt]),V=(0,y.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Bt({pjcode:e,storyName:t})},[e]),[_t,vt]=(0,y.useState)({}),[yt,bt]=(0,y.useState)(null),[xt,St]=(0,y.useState)({}),Ct=(0,y.useCallback)((t,n)=>{let r=lt.find(e=>e.storyOptionId===t)?.color;if(bt(t),vt(e=>({...e,[t]:n})),St(e=>{let n={...e};return delete n[t],n}),e===null||ut===null){vt(e=>r===void 0?e:{...e,[t]:r}),St(e=>({...e,[t]:`No project or repository configured.`})),bt(e=>e===t?null:e);return}Gt({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:ut}).catch(e=>{vt(e=>r===void 0?e:{...e,[t]:r}),St(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{bt(e=>e===t?null:e)})},[e,ut,lt]),wt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Qt({pjcode:e,storyOptionId:t,deleteChildTasks:n}),Ye({generatedAt:st?.generatedAt,stories:lt.filter(e=>e.storyOptionId!==t)})},[e,lt,st?.generatedAt]),Tt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await en({pjcode:e,storyOptionId:t,newName:n});let r=lt.map(e=>e.storyOptionId===t?{...e,storyName:n}:e);Ye({generatedAt:st?.generatedAt,stories:r})},[e,lt,st?.generatedAt]),Et=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await nn({pjcode:e,storyOptionId:t,description:n});let r=lt.map(e=>e.storyOptionId===t?{...e,description:n}:e);Ye({generatedAt:st?.generatedAt,stories:r})},[e,lt,st?.generatedAt]),Dt=Pr(Ae,oe.comments,k===`prs`),Ot=(0,y.useCallback)((e,t)=>{nt({kind:{type:`ok_and_awaiting_workspace`},item:e,commit:()=>R.okAndMoveToAwaitingWorkspace(e,t),skipAdvance:!0,onAdvance:()=>{E.patchOverlay(tr(e),{done:!0,status:{name:t.name,color:t.color}},k)},revertAdvance:()=>{E.patchOverlay(tr(e),{done:!1},k)}})},[nt,R,E,k]);return(0,x.jsxs)(`main`,{className:`console-app`,children:[z.pending!==null&&(0,x.jsx)(Ve,{message:z.pending.message,color:z.pending.color,remainingSeconds:z.pending.remainingSeconds,progress:z.pending.progress,onUndo:z.undo}),z.error!==null&&(0,x.jsx)(He,{title:z.error.message,message:`Operation failed: ${z.error.reason}`,onDismiss:z.dismissError,onRetry:z.error.retry===void 0?void 0:()=>{z.dismissError(),z.error?.retry?.()}}),(0,x.jsx)(Be,{actions:Oe,isOnline:me,isConfirming:we,onConfirm:De,onDiscard:z.discardOfflineAction}),D.isOpen&&(0,x.jsx)(S,{pjcodes:v,inputValues:D.inputValues,onChangeInput:D.changeInput,isLoading:D.isLoading,isSaving:D.isSaving,error:D.error,nameWithOwnerByPjcode:w,onSave:D.save,onClose:D.close}),(0,x.jsx)(N,{activeTab:k,counts:ne,pjcode:e,pjcodes:v,generatedAt:Ke,fromCache:qe,tabHref:O.tabHref,onSelectTab:ie,onSelectProject:P,settingsButton:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(ae,{isOpen:u,isTimerActive:c,timerMode:d,projectMinutes:f,pjcodes:v,isLoadingPjcodes:ee,onOpen:p,onToggleTimerMode:g,onChangeMinutes:_,onSave:h,onClose:m}),(0,x.jsx)(`button`,{type:`button`,className:`console-tab-settings-button`,"aria-label":`Open max settings`,onClick:D.open,children:`⚙`}),e!==null&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,className:`console-task-create-button`,disabled:ut===null||lt.length===0,onClick:()=>de(!0),"aria-label":`Create new task`,title:`Create new task`,children:(0,x.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,x.jsx)(`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}),(0,x.jsx)(`path`,{d:`M18.375 2.625a2.121 2.121 0 0 1 3 3L7 18l-4 1 1-4Z`})]})}),ue&&(0,x.jsx)(L,{storyEntries:lt,agentOptions:We,onSubmit:mt,onClose:()=>de(!1),initialDraft:fe,onDraftChange:pe,fleetTaskCreateUrl:C,newIssueUrl:dt})]})]}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff,onAirplaneModeRetryFailed:n.retryFailed,projectUrl:e===null?null:b?.[e]??null,fleetTaskCreateUrl:C,now:le}),(0,x.jsx)(T,{timerEndsAt:ke?.timerEndsAt??null,timerTotalSeconds:ke?.timerTotalSeconds??null,now:le}),k===`stories`?(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(Fe,{stories:lt,isLoading:a,error:o,showGray:it,onCreateIssue:pt,onAddStory:V,onSelectColor:Ct,onToggleGray:ot,onReorderStory:gt,onDeleteStory:wt,onRenameStory:Tt,onUpdateDescription:Et,optimisticColors:_t,colorChangeInFlight:yt,colorErrors:xt})}):Xe===null?k===`queued`?(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(Ee,{rows:Re,storyColors:ze,statusOptions:Ue,agentOptions:We,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>O.openItem(e.projectItemId)})}):k===`prs`?(0,x.jsxs)(`div`,{className:`console-list-screen`,children:[(0,x.jsx)(Ce,{agentOptions:We,agentCounts:Ne,selectedAgent:je,onAgentChange:Me}),(0,x.jsx)(Se,{rows:Re,storyColors:ze,statusOptions:Ue,activeItemId:null,now:le,isLoading:a,error:o,onSelectItem:e=>O.openItem(e.projectItemId),executiveSummaries:Dt,onOkAndAwaitingWorkspace:Ot})]}):(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(Se,{rows:Re,storyColors:ze,statusOptions:Ue,activeItemId:null,now:le,isLoading:a,error:o,onSelectItem:e=>O.openItem(e.projectItemId)})}):(0,x.jsx)(`div`,{className:`console-detail-screen`,ref:rt,children:(0,x.jsx)(Rd,{tab:k,item:Xe,caches:oe,operations:R,pjcode:e,statusOptions:Ue,storyOptions:Ge,agentOptions:We,storyColors:ze,storyName:et,overlayStatus:$e,now:le,initialCommentDraft:F.current.get(Xe.projectItemId)??``,onCommentDraftChange:I,onQueueAction:nt,onDeleteStory:ft===null?null:async e=>{await wt(ft.storyOptionId,e),M()},storyNameForDeletion:ft?.storyName??null},Xe.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var Hd=document.getElementById(`root`);if(Hd===null)throw Error(`Root container #root not found`);(0,b.createRoot)(Hd).render((0,x.jsx)(y.StrictMode,{children:(0,x.jsx)(Vd,{})}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>TDPM Console</title>
8
- <script type="module" crossorigin src="/assets/index-DNbXF7Un.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CqOLKxom.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-MOWwYLb7.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-issue-tower-defence-management",
3
- "version": "2.128.0",
3
+ "version": "2.129.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {