github-issue-tower-defence-management 2.49.1 → 2.51.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.
- package/README.md +1 -1
- package/bin/adapter/entry-points/console/consoleCloseEventStore.js +85 -0
- package/bin/adapter/entry-points/console/consoleCloseEventStore.js.map +1 -0
- package/bin/adapter/entry-points/console/consoleOperationApi.js +49 -6
- package/bin/adapter/entry-points/console/consoleOperationApi.js.map +1 -1
- package/bin/adapter/entry-points/console/dashboardComposeService.js +10 -0
- package/bin/adapter/entry-points/console/dashboardComposeService.js.map +1 -1
- package/bin/adapter/entry-points/console/ui-dist/assets/{index-Bw5W8a4g.js → index-CSabdYt0.js} +2 -2
- package/bin/adapter/entry-points/console/ui-dist/index.html +1 -1
- package/bin/adapter/entry-points/console/webServer.js +9 -1
- package/bin/adapter/entry-points/console/webServer.js.map +1 -1
- package/bin/adapter/entry-points/handlers/FileSystemConsoleTabsRepository.js +43 -0
- package/bin/adapter/entry-points/handlers/FileSystemConsoleTabsRepository.js.map +1 -1
- package/bin/domain/usecases/dashboard/ComposeDashboardUseCase.js +17 -2
- package/bin/domain/usecases/dashboard/ComposeDashboardUseCase.js.map +1 -1
- package/package.json +1 -1
- package/types/adapter/entry-points/console/consoleCloseEventStore.d.ts +5 -0
- package/types/adapter/entry-points/console/consoleCloseEventStore.d.ts.map +1 -0
- package/types/adapter/entry-points/console/consoleOperationApi.d.ts +2 -0
- package/types/adapter/entry-points/console/consoleOperationApi.d.ts.map +1 -1
- package/types/adapter/entry-points/console/dashboardComposeService.d.ts +2 -0
- package/types/adapter/entry-points/console/dashboardComposeService.d.ts.map +1 -1
- package/types/adapter/entry-points/console/webServer.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/FileSystemConsoleTabsRepository.d.ts +1 -0
- package/types/adapter/entry-points/handlers/FileSystemConsoleTabsRepository.d.ts.map +1 -1
- package/types/domain/usecases/dashboard/ComposeDashboardUseCase.d.ts +6 -0
- package/types/domain/usecases/dashboard/ComposeDashboardUseCase.d.ts.map +1 -1
package/bin/adapter/entry-points/console/ui-dist/assets/{index-Bw5W8a4g.js → index-CSabdYt0.js}
RENAMED
|
@@ -10,7 +10,7 @@ Error generating stack: `+e.message+`
|
|
|
10
10
|
|
|
11
11
|
`),L=`In Tmux by human`,se=`Awaiting Workspace`,ce=[`In Tmux by human`,`Todo by human`,se],le=e=>e===`todo-by-human`||e===`todo-by-agent`,ue=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===se.toLowerCase());if(n===void 0)return null;let r=ae(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`})})},R=1e3,de=60*R,z=60*de,fe=24*z,pe=(e,t)=>{let n=Date.parse(e);if(Number.isNaN(n))return``;let r=t-n;if(r<45*R)return`just now`;if(r<z){let e=Math.round(r/de);return`${e} minute${e===1?``:`s`} ago`}if(r<fe){let e=Math.round(r/z);return`${e} hour${e===1?``:`s`} ago`}let i=Math.round(r/fe);if(i===1)return`yesterday`;if(i<30)return`${i} days ago`;let a=new Date(n),o=a.getUTCFullYear()===new Date(t).getUTCFullYear();return a.toLocaleDateString(`en-US`,{timeZone:`UTC`,year:o?void 0:`numeric`,month:`short`,day:`numeric`})},me=e=>{let t=Date.parse(e);return Number.isNaN(t)?``:new Date(t).toLocaleString(`ja-JP`,{timeZone:`UTC`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})},he={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`]}},ge=({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`,_e=({size:e=12,...t})=>{let n=ge(t),r=he[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))})},ve=({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)(_e,{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:me(e.createdAt),children:pe(e.createdAt,n)})]}),e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-item-status-badge`,style:N(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]})})]})}),ye=({story:e,count:t,colorEnum:n})=>{let r=ae(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})]})},be=({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)(ye,{story:e.story,count:e.count,colorEnum:k(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)(ve,{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)(ue,{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]}),xe=({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))]})})},Se=e=>({...N(e),fontSize:`12px`,whiteSpace:`nowrap`,flexShrink:0}),Ce=({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)(_e,{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:Se(a?.color??null),children:e.status}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:Se(o?.color??null),children:e.agent})]}),(0,x.jsx)(`span`,{className:`console-queued-item-actions`})]})},we=({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)(ye,{story:e.story,count:e.count,colorEnum:k(t,e.story)})},`group:${e.story}`):(0,x.jsx)(`li`,{className:`console-list-row`,children:(0,x.jsx)(Ce,{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]}),Te=Object.defineProperty,Ee=(e,t)=>Te(e,`name`,{value:t,configurable:!0});function De(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Ee(De,`setRef`);function Oe(...e){return t=>{let n=!1,r=e.map(e=>{let r=De(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():De(e[t],null)}}}}Ee(Oe,`composeRefs`);function ke(...e){return y.useCallback(Oe(...e),e)}Ee(ke,`useComposedRefs`);var Ae=Object.defineProperty,je=(e,t)=>Ae(e,`name`,{value:t,configurable:!0});function Me(e){let t=y.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];Ve(r)&&typeof Ge==`function`&&(r=Ge(r._payload)),y.Children.forEach(r,e=>{if(ze(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Ve(n)&&typeof Ge==`function`&&(n=Ge(n._payload)),a=Ie(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?Re(a):void 0,l=ke(n,c);if(!a){if(r||r===0)throw Error(o?We(e):Ue(e));return r}let u=Le(i,a.props??{});return a.type!==y.Fragment&&(u.ref=n?l:c),y.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}je(Me,`createSlot`);var Ne=Me(`Slot`),Pe=Symbol.for(`radix.slottable`);function Fe(e){let t=je(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=Pe,t}je(Fe,`createSlottable`);var Ie=je((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 Le(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}}je(Le,`mergeProps`);function Re(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)}je(Re,`getElementRef`);function ze(e){return y.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Pe}je(ze,`isSlottable`);var Be=Symbol.for(`react.lazy`);function Ve(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Be&&`_payload`in e&&He(e._payload)}je(Ve,`isLazyComponent`);function He(e){return typeof e==`object`&&!!e&&`then`in e}je(He,`isPromiseLike`);var Ue=je(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),We=je(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Ge=y.use;function Ke(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=Ke(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function qe(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ke(e))&&(r&&(r+=` `),r+=t);return r}var Je=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Ye=qe,Xe=(e,t)=>n=>{if(t?.variants==null)return Ye(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=Je(t)||Je(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 Ye(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)},Ze=(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},Qe=(e,t)=>({classGroupId:e,validator:t}),$e=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),et=`-`,tt=[],nt=`arbitrary..`,rt=e=>{let t=ot(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return at(e);let n=e.split(et);return it(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Ze(i,t):t:i||tt}return n[e]||tt}}},it=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=it(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(et):e.slice(t).join(et),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},at=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?nt+r:void 0})(),ot=e=>{let{theme:t,classGroups:n}=e;return st(n,t)},st=(e,t)=>{let n=$e();for(let r in e){let i=e[r];ct(i,n,r,t)}return n},ct=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];lt(i,t,n,r)}},lt=(e,t,n,r)=>{if(typeof e==`string`){ut(e,t,n);return}if(typeof e==`function`){dt(e,t,n,r);return}ft(e,t,n,r)},ut=(e,t,n)=>{let r=e===``?t:pt(t,e);r.classGroupId=n},dt=(e,t,n,r)=>{if(mt(e)){ct(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Qe(n,e))},ft=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];ct(o,pt(t,a),n,r)}},pt=(e,t)=>{let n=e,r=t.split(et),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=$e(),n.nextPart.set(t,i)),n=i}return n},mt=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,ht=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)}}},gt=`!`,_t=`:`,vt=[],yt=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),bt=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===_t){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(gt)?(c=s.slice(0,-1),l=!0):s.startsWith(gt)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return yt(t,l,c,u)};if(t){let e=t+_t,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):yt(vt,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},xt=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}},St=e=>({cache:ht(e.cacheSize),parseClassName:bt(e),sortModifiers:xt(e),postfixLookupClassGroupIds:Ct(e),...rt(e)}),Ct=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},wt=/\s+/,Tt=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(wt),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?_+gt:_,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},Et=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Dt(n))&&(i&&(i+=` `),i+=r);return i},Dt=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Dt(e[r]))&&(n&&(n+=` `),n+=t);return n},Ot=(e,...t)=>{let n,r,i,a,o=o=>(n=St(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=Tt(e,n);return i(e,a),a};return a=o,(...e)=>a(Et(...e))},kt=[],B=e=>{let t=t=>t[e]||kt;return t.isThemeGetter=!0,t},At=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jt=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Mt=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Nt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Pt=/\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$/,Ft=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,It=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Lt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rt=e=>Mt.test(e),V=e=>!!e&&!Number.isNaN(Number(e)),zt=e=>!!e&&Number.isInteger(Number(e)),Bt=e=>e.endsWith(`%`)&&V(e.slice(0,-1)),Vt=e=>Nt.test(e),Ht=()=>!0,Ut=e=>Pt.test(e)&&!Ft.test(e),Wt=()=>!1,Gt=e=>It.test(e),Kt=e=>Lt.test(e),qt=e=>!H(e)&&!U(e),Jt=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)),Yt=e=>dn(e,hn,Wt),H=e=>At.test(e),Xt=e=>dn(e,gn,Ut),Zt=e=>dn(e,_n,V),Qt=e=>dn(e,yn,Ht),$t=e=>dn(e,vn,Wt),en=e=>dn(e,pn,Wt),tn=e=>dn(e,mn,Kt),nn=e=>dn(e,bn,Gt),U=e=>jt.test(e),rn=e=>fn(e,gn),an=e=>fn(e,vn),on=e=>fn(e,pn),sn=e=>fn(e,hn),cn=e=>fn(e,mn),ln=e=>fn(e,bn,!0),un=e=>fn(e,yn,!0),dn=(e,t,n)=>{let r=At.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},fn=(e,t,n=!1)=>{let r=jt.exec(e);return r?r[1]?t(r[1]):n:!1},pn=e=>e===`position`||e===`percentage`,mn=e=>e===`image`||e===`url`,hn=e=>e===`length`||e===`size`||e===`bg-size`,gn=e=>e===`length`,_n=e=>e===`number`,vn=e=>e===`family-name`,yn=e=>e===`number`||e===`weight`,bn=e=>e===`shadow`,xn=Ot(()=>{let e=B(`color`),t=B(`font`),n=B(`text`),r=B(`font-weight`),i=B(`tracking`),a=B(`leading`),o=B(`breakpoint`),s=B(`container`),c=B(`spacing`),l=B(`radius`),u=B(`shadow`),d=B(`inset-shadow`),f=B(`text-shadow`),p=B(`drop-shadow`),m=B(`blur`),h=B(`perspective`),g=B(`aspect`),_=B(`ease`),v=B(`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(),U,H],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[U,H,c],T=()=>[Rt,`full`,`auto`,...w()],E=()=>[zt,`none`,`subgrid`,U,H],D=()=>[`auto`,{span:[`full`,zt,U,H]},zt,U,H],O=()=>[zt,`auto`,U,H],ee=()=>[`auto`,`min`,`max`,`fr`,U,H],te=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ne=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],re=()=>[`auto`,...w()],k=()=>[Rt,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ie=()=>[Rt,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],A=()=>[Rt,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],j=()=>[e,U,H],M=()=>[...b(),on,en,{position:[U,H]}],ae=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],N=()=>[`auto`,`cover`,`contain`,sn,Yt,{size:[U,H]}],oe=()=>[Bt,rn,Xt],P=()=>[``,`none`,`full`,l,U,H],F=()=>[``,V,rn,Xt],I=()=>[`solid`,`dashed`,`dotted`,`double`],L=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],se=()=>[V,Bt,on,en],ce=()=>[``,`none`,m,U,H],le=()=>[`none`,V,U,H],ue=()=>[`none`,V,U,H],R=()=>[V,U,H],de=()=>[Rt,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Vt],breakpoint:[Vt],color:[Ht],container:[Vt],"drop-shadow":[Vt],ease:[`in`,`out`,`in-out`],font:[qt],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Vt],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Vt],shadow:[Vt],spacing:[`px`,V],text:[Vt],"text-shadow":[Vt],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,Rt,H,U,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,U,H]}],"container-named":[Jt],columns:[{columns:[V,H,U,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:[zt,`auto`,U,H]}],basis:[{basis:[Rt,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[V,Rt,`auto`,`initial`,`none`,H]}],grow:[{grow:[``,V,U,H]}],shrink:[{shrink:[``,V,U,H]}],order:[{order:[zt,`first`,`last`,`none`,U,H]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ee()}],"auto-rows":[{"auto-rows":ee()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...te(),`normal`]}],"justify-items":[{"justify-items":[...ne(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ne()]}],"align-content":[{content:[`normal`,...te()]}],"align-items":[{items:[...ne(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ne(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":te()}],"place-items":[{"place-items":[...ne(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ne()]}],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:re()}],mx:[{mx:re()}],my:[{my:re()}],ms:[{ms:re()}],me:[{me:re()}],mbs:[{mbs:re()}],mbe:[{mbe:re()}],mt:[{mt:re()}],mr:[{mr:re()}],mb:[{mb:re()}],ml:[{ml:re()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:k()}],"inline-size":[{inline:[`auto`,...ie()]}],"min-inline-size":[{"min-inline":[`auto`,...ie()]}],"max-inline-size":[{"max-inline":[`none`,...ie()]}],"block-size":[{block:[`auto`,...A()]}],"min-block-size":[{"min-block":[`auto`,...A()]}],"max-block-size":[{"max-block":[`none`,...A()]}],w:[{w:[s,`screen`,...k()]}],"min-w":[{"min-w":[s,`screen`,`none`,...k()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...k()]}],h:[{h:[`screen`,`lh`,...k()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...k()]}],"max-h":[{"max-h":[`screen`,`lh`,...k()]}],"font-size":[{text:[`base`,n,rn,Xt]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,un,Qt]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,Bt,H]}],"font-family":[{font:[an,$t,t]}],"font-features":[{"font-features":[H]}],"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,U,H]}],"line-clamp":[{"line-clamp":[V,`none`,U,Zt]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,U,H]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,U,H]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...I(),`wavy`]}],"text-decoration-thickness":[{decoration:[V,`from-font`,`auto`,U,Xt]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[V,`auto`,U,H]}],"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:[zt,U,H]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,U,H]}],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`,U,H]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:N()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},zt,U,H],radial:[``,U,H],conic:[zt,U,H]},cn,tn]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:oe()}],"gradient-via-pos":[{via:oe()}],"gradient-to-pos":[{to:oe()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":F()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...I(),`hidden`,`none`]}],"divide-style":[{divide:[...I(),`hidden`,`none`]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...I(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[V,U,H]}],"outline-w":[{outline:[``,V,rn,Xt]}],"outline-color":[{outline:j()}],shadow:[{shadow:[``,`none`,u,ln,nn]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":[`none`,d,ln,nn]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:F()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[V,Xt]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":[`none`,f,ln,nn]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[V,U,H]}],"mix-blend":[{"mix-blend":[...L(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":L()}],"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":[V]}],"mask-image-linear-from-pos":[{"mask-linear-from":se()}],"mask-image-linear-to-pos":[{"mask-linear-to":se()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":se()}],"mask-image-t-to-pos":[{"mask-t-to":se()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":se()}],"mask-image-r-to-pos":[{"mask-r-to":se()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":se()}],"mask-image-b-to-pos":[{"mask-b-to":se()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":se()}],"mask-image-l-to-pos":[{"mask-l-to":se()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":se()}],"mask-image-x-to-pos":[{"mask-x-to":se()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":se()}],"mask-image-y-to-pos":[{"mask-y-to":se()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[U,H]}],"mask-image-radial-from-pos":[{"mask-radial-from":se()}],"mask-image-radial-to-pos":[{"mask-radial-to":se()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"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":[V]}],"mask-image-conic-from-pos":[{"mask-conic-from":se()}],"mask-image-conic-to-pos":[{"mask-conic-to":se()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,U,H]}],filter:[{filter:[``,`none`,U,H]}],blur:[{blur:ce()}],brightness:[{brightness:[V,U,H]}],contrast:[{contrast:[V,U,H]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,ln,nn]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:[``,V,U,H]}],"hue-rotate":[{"hue-rotate":[V,U,H]}],invert:[{invert:[``,V,U,H]}],saturate:[{saturate:[V,U,H]}],sepia:[{sepia:[``,V,U,H]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,U,H]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[V,U,H]}],"backdrop-contrast":[{"backdrop-contrast":[V,U,H]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,V,U,H]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[V,U,H]}],"backdrop-invert":[{"backdrop-invert":[``,V,U,H]}],"backdrop-opacity":[{"backdrop-opacity":[V,U,H]}],"backdrop-saturate":[{"backdrop-saturate":[V,U,H]}],"backdrop-sepia":[{"backdrop-sepia":[``,V,U,H]}],"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`,U,H]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[V,`initial`,U,H]}],ease:[{ease:[`linear`,`initial`,_,U,H]}],delay:[{delay:[V,U,H]}],animate:[{animate:[`none`,v,U,H]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,U,H]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:ue()}],"scale-x":[{"scale-x":ue()}],"scale-y":[{"scale-y":ue()}],"scale-z":[{"scale-z":ue()}],"scale-3d":[`scale-3d`],skew:[{skew:R()}],"skew-x":[{"skew-x":R()}],"skew-y":[{"skew-y":R()}],transform:[{transform:[U,H,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:de()}],"translate-x":[{"translate-x":de()}],"translate-y":[{"translate-y":de()}],"translate-z":[{"translate-z":de()}],"translate-none":[`translate-none`],zoom:[{zoom:[zt,U,H]}],accent:[{accent:j()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:j()}],"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`,U,H]}],"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":j()}],"scrollbar-track-color":[{"scrollbar-track":j()}],"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`,U,H]}],fill:[{fill:[`none`,...j()]}],"stroke-w":[{stroke:[V,rn,Xt,Zt]}],stroke:[{stroke:[`none`,...j()]}],"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`]}}),Sn=(...e)=>xn(qe(e)),Cn=Xe(`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`}}),wn=y.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>(0,x.jsx)(r?Ne:`button`,{className:Sn(Cn({variant:t,size:n,className:e})),ref:a,...i}));wn.displayName=`Button`;var Tn=`Copying to the clipboard is not available in this browser context.`,En=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},Dn=async e=>{let t=navigator.clipboard;if(t!==void 0&&typeof t.writeText==`function`)try{await t.writeText(e);return}catch{if(En(e))return;throw Error(Tn)}if(!En(e))throw Error(Tn)},On=1500,kn=`Copy failed`,An=`Copying to the clipboard failed`,jn=({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)(wn,{type:`button`,variant:`ghost`,size:`sm`,className:i,"aria-label":a===`copied`?r:a===`failed`?An:n,onClick:async()=>{try{await Dn(e),o(`copied`)}catch(e){console.error(e),o(`failed`)}s.current!==null&&clearTimeout(s.current),s.current=setTimeout(()=>{o(`idle`),s.current=null},On)},children:a===`copied`?`Copied`:a===`failed`?kn:t})},Mn=({storyName:e})=>(0,x.jsx)(jn,{value:e,idleText:`Copy name`,idleAriaLabel:`Copy story name`,copiedAriaLabel:`Story name copied to clipboard`,className:`console-copy-story-name-button`}),Nn=Object.keys(M),Pn=({placeholder:e,emptyValueError:t,onSubmit:n,onCancel:r,initialValue:i=``,submitLabel:a=`Create`,selectAllOnFocus:o=!1})=>{let[s,c]=(0,y.useState)(i),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),p=(0,y.useRef)(null),m=(0,y.useRef)(o);(0,y.useEffect)(()=>{p.current?.focus(),m.current&&p.current?.select()},[]);let h=async()=>{let e=s.trim();if(e.length===0){f(t);return}u(!0),f(null);try{await n(e)}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,x.jsxs)(`form`,{className:`console-inline-input-form`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,x.jsx)(`input`,{ref:p,type:`text`,className:`console-inline-input-form-input`,placeholder:e,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:l,children:l?`${a.replace(/e$/,``)}ing…`:a}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:r,disabled:l,children:`Cancel`}),d!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:d})]})},Fn=({storyOptionId:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Pn,{placeholder:`Issue title`,emptyValueError:`Title is required`,onSubmit:n=>t(e,n),onCancel:n}),In=({currentName:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Pn,{placeholder:`Story name`,emptyValueError:`Story name is required`,initialValue:e,submitLabel:`Rename`,selectAllOnFocus:!0,onSubmit:t,onCancel:n}),Ln=({onSelectColor:e,disabled:t})=>(0,x.jsx)(`div`,{className:`console-story-color-palette`,children:Nn.map(n=>{let r=M[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)})}),Rn=({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? Tasks assigned to this story will not be deleted.`]}),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,disabled:t,children:t?`Deleting…`:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:i,disabled:t,children:`Cancel`})]})]}),zn=({stories:e,isLoading:t,error:n,showGray:r,onCreateIssue:i,onAddStory:a,onSelectColor:o,onToggleGray:s,onReorderStory:c,onDeleteStory:l,onRenameStory:u,optimisticColors:d,colorChangeInFlight:f,colorErrors:p})=>{let[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(null),[S,C]=(0,y.useState)({}),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)({}),[O,ee]=(0,y.useState)(null),te=e=>S[e]??{inProgress:!1,error:null},ne=async(e,t)=>{C(t=>({...t,[e]:{inProgress:!0,error:null}}));try{await c(e,t),C(t=>({...t,[e]:{inProgress:!1,error:null}}))}catch(t){C(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 re=e=>{h(m===e?null:e)},k=async(e,t)=>{await i(e,t),h(null)},ie=e=>{b(v===e?null:e)},A=(e,t)=>{b(null),o(e,t)},j=e=>{T(e)},M=async e=>{D(t=>({...t,[e]:{isDeleting:!0,error:null}}));try{await l(e),T(null),D(t=>({...t,[e]:{isDeleting:!1,error:null}}))}catch(t){D(n=>({...n,[e]:{isDeleting:!1,error:t instanceof Error?t.message:String(t)}}))}},N=()=>{T(null),D({})},oe=e=>{ee(O===e?null:e)},P=async(e,t)=>{await u(e,t),ee(null)},F=r?e:e.filter(e=>e.color!==`GRAY`),I=e.some(e=>e.color===`GRAY`);return(0,x.jsxs)(`div`,{className:`console-story-list-container`,children:[F.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No active stories`}):(0,x.jsx)(`ul`,{className:`console-story-list`,children:F.map((e,t)=>{let n=ae(d[e.storyOptionId]??e.color),r=m===e.storyOptionId,i=v===e.storyOptionId,a=f===e.storyOptionId,o=p[e.storyOptionId]??null,{inProgress:s,error:c}=te(e.storyOptionId),l=t===0,u=t===F.length-1,g=w===e.storyOptionId,_=E[e.storyOptionId]??{isDeleting:!1,error:null},y=O===e.storyOptionId;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)(Mn,{storyName:e.storyName}),(0,x.jsx)(`span`,{className:`console-story-count`,children:e.openItemCount}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>re(e.storyOptionId),children:`Add task`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>ie(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 ne(e.storyOptionId,`up`),children:`↑`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move down`,disabled:u||s,onClick:()=>void ne(e.storyOptionId,`down`),children:`↓`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,"aria-label":`Delete story`,onClick:()=>j(e.storyOptionId),children:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Rename story`,onClick:()=>oe(e.storyOptionId),children:`Rename`})]}),c!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:c}),i&&(0,x.jsx)(Ln,{onSelectColor:t=>A(e.storyOptionId,t),disabled:a}),o!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:o}),r&&(0,x.jsx)(Fn,{storyOptionId:e.storyOptionId,onSubmit:k,onCancel:()=>h(null)}),g&&(0,x.jsx)(Rn,{storyName:e.storyName,isDeleting:_.isDeleting,deleteError:_.error,onConfirm:()=>void M(e.storyOptionId),onCancel:N}),y&&(0,x.jsx)(In,{currentName:e.storyName,onSubmit:t=>P(e.storyOptionId,t),onCancel:()=>ee(null)})]},e.storyOptionId)})}),I&&(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:()=>_(!g),children:`Add story`}),g&&(0,x.jsx)(Pn,{placeholder:`Story name`,emptyValueError:`Story name is required`,onSubmit:async e=>{await a(e),_(!1)},onCancel:()=>_(!1)})]})]})},Bn=e=>`${e.isPr?`PR`:`Issue`} #${e.itemNumber}`,Vn=e=>e===null?`loading…`:e,Hn=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(` · `)},Un=e=>e.fetchError?`${Bn(e)} — failed to load current state`:e.currentTitle===null?`${Bn(e)} — loading current state…`:`${Bn(e)} — ${e.currentTitle} (${Vn(e.currentState)})`,Wn=({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:Un(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:Hn(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))]}),Gn=({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))}%`}})]}),Kn=({title:e,message:t,onDismiss:n})=>(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.jsx)(`button`,{type:`button`,className:`console-error-toast-dismiss`,onClick:n,children:`Dismiss`})]}),qn=`tdpm-airplane-v1`,Jn=`/airplane-snapshot-data`,Yn=`tdpm_airplane_mode_on`,Xn=()=>typeof localStorage>`u`?!1:localStorage.getItem(Yn)===`1`,Zn=e=>{typeof localStorage>`u`||(e?localStorage.setItem(Yn,`1`):localStorage.removeItem(Yn))},Qn=async e=>{if(typeof caches>`u`)throw Error(`Cache API unavailable`);try{await(await caches.open(qn)).put(Jn,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}},$n=async()=>{if(typeof caches>`u`)return null;let e=await(await caches.open(qn)).match(Jn);return e===void 0?null:e.json()},er=async()=>{typeof caches>`u`||await caches.delete(qn)},tr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),nr=e=>typeof e==`string`?e:``,rr=e=>typeof e==`number`?e:0,ir=e=>e===!0,ar=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],or=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,sr=e=>tr(e)?{number:rr(e.number),title:nr(e.title),url:nr(e.url),repo:nr(e.repo),nameWithOwner:nr(e.nameWithOwner),projectItemId:nr(e.projectItemId),itemId:nr(e.itemId),isPr:ir(e.isPr),story:nr(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:ar(e.dependedIssueUrls),labels:ar(e.labels),createdAt:nr(e.createdAt),relatedOpenPullRequestUrls:ar(e.relatedOpenPullRequestUrls),agent:typeof e.agent==`string`?e.agent:null}:null,cr=e=>{if(!tr(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(sr).filter(e=>e!==null):[],n=Array.isArray(e.statusOptions)?e.statusOptions.filter(tr):[],r=Array.isArray(e.agentOptions)?e.agentOptions.filter(tr):[],i=Array.isArray(e.storyOptions)?e.storyOptions.filter(tr):[],a=Array.isArray(e.stories)?e.stories.filter(tr):[],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:tr(e.storyColors)?e.storyColors:{},stories:a,defaultNameWithOwner:typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,fromCache:!1,storyOrder:o,timerEndsAt:null,timerTotalSeconds:null}},lr=e=>tr(e)?{author:nr(e.author),body:nr(e.body),createdAt:nr(e.createdAt)}:null,ur=e=>tr(e)?{path:nr(e.path),additions:rr(e.additions),deletions:rr(e.deletions),status:nr(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null}:null,dr=e=>tr(e)?{sha:nr(e.sha),message:nr(e.message),author:nr(e.author),authoredAt:nr(e.authoredAt)}:null,fr=e=>tr(e)?{found:ir(e.found),isConflicted:ir(e.isConflicted),mergeableStatus:or(e.mergeableStatus),isPassedAllCiJob:ir(e.isPassedAllCiJob),isCiStateSuccess:ir(e.isCiStateSuccess),isBranchOutOfDate:ir(e.isBranchOutOfDate),missingRequiredCheckNames:ar(e.missingRequiredCheckNames)}:{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},pr=e=>{if(!tr(e))return null;let t=tr(e.summary)?{title:nr(e.summary.title),body:nr(e.summary.body),additions:rr(e.summary.additions),deletions:rr(e.summary.deletions),changedFiles:rr(e.summary.changedFiles)}:null;return{url:nr(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:nr(e.createdAt),isDraft:ir(e.isDraft),isConflicted:ir(e.isConflicted),mergeableStatus:or(e.mergeableStatus),isPassedAllCiJob:ir(e.isPassedAllCiJob),isCiStateSuccess:ir(e.isCiStateSuccess),isResolvedAllReviewComments:ir(e.isResolvedAllReviewComments),isBranchOutOfDate:ir(e.isBranchOutOfDate),missingRequiredCheckNames:ar(e.missingRequiredCheckNames),summary:t}},mr=e=>{if(!tr(e))return{body:``,comments:[],state:{state:`open`,merged:!1,isPullRequest:!1,title:``},files:null,commits:null,prStatus:null,relatedPrs:null};let t=tr(e.state)?e.state:{},n={state:nr(t.state)||`open`,merged:ir(t.merged),isPullRequest:ir(t.isPullRequest),title:nr(t.title)},r=e.files===null?null:Array.isArray(e.files)?e.files.map(ur).filter(e=>e!==null):null,i=e.commits===null?null:Array.isArray(e.commits)?e.commits.map(dr).filter(e=>e!==null):null,a=e.prStatus===null?null:fr(e.prStatus),o=e.relatedPrs===null?null:Array.isArray(e.relatedPrs)?e.relatedPrs.map(pr).filter(e=>e!==null):null;return{body:nr(e.body),comments:Array.isArray(e.comments)?e.comments.map(lr).filter(e=>e!==null):[],state:n,files:r,commits:i,prStatus:a,relatedPrs:o}},hr=e=>{if(!tr(e))return null;let t=typeof e.capturedAt==`string`?e.capturedAt:``,n=ar(e.failures),r={};if(tr(e.tabs))for(let[t,n]of Object.entries(e.tabs)){if(!tr(n))continue;let e={};for(let[t,r]of Object.entries(n))e[t]=cr(r);r[t]=e}let i={};if(tr(e.items))for(let[t,n]of Object.entries(e.items))i[t]=mr(n);return{capturedAt:t,tabs:r,items:i,failures:n}},gr=`/api/airplanesync`,_r=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}},vr=()=>{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);return(0,y.useEffect)(()=>{if(!Xn())return;let e=!1;return $n().then(n=>{e||n===null||(a(n),t(`on`))}).catch(()=>{Zn(!1)}),()=>{e=!0}},[]),{status:e,progress:n,snapshot:i,failures:o,startSync:(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(gr,{signal:e.signal}).then(async e=>{if(!e.ok||e.body===null){t(`error`),s([`HTTP ${e.status}`]);return}let n=e.body.pipeThrough(new TextDecoderStream).getReader(),i=``;for(;;){let{done:e,value:o}=await n.read();if(e)break;i+=o;let c=i.split(`
|
|
12
12
|
|
|
13
|
-
`);i=c.pop()??``;for(let e of c){if(!e.startsWith(`data: `))continue;let n=_r(e.slice(6));if(n!==null){if(n.type===`progress`)r({fetched:typeof n.fetched==`number`?n.fetched:0,total:typeof n.total==`number`?n.total:0});else if(n.type===`done`){let e=hr(n.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}if(e.failures.length>0){s(e.failures),t(`error`);return}await Qn(e),Zn(!0),a(e),t(`on`),s([])}}}}}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[]),turnOff:(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),Zn(!1),er().catch(()=>{})},[])}},yr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),br=e=>typeof e==`string`?e:``,xr=e=>typeof e==`number`?e:0,Sr=e=>e===!0,Cr=`console-api-v1`,wr=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();yr(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(Cr).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(Cr)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},Tr=e=>!yr(e)||!Array.isArray(e.comments)?[]:e.comments.filter(yr).map(e=>({author:br(e.author),body:br(e.body),createdAt:br(e.createdAt)})),Er=e=>!yr(e)||!Array.isArray(e.files)?[]:e.files.filter(yr).map(e=>({path:br(e.path)||br(e.filename),additions:xr(e.additions),deletions:xr(e.deletions),status:br(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Dr=e=>!yr(e)||!Array.isArray(e.commits)?[]:e.commits.filter(yr).map(e=>({sha:br(e.sha),message:br(e.message),author:br(e.author),authoredAt:br(e.authoredAt)})),Or=e=>yr(e)?{title:br(e.title),body:br(e.body),additions:xr(e.additions),deletions:xr(e.deletions),changedFiles:xr(e.changedFiles)}:null,kr=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ar=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,jr=e=>!yr(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(yr).map(e=>({url:br(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:br(e.createdAt),isDraft:Sr(e.isDraft),isConflicted:Sr(e.isConflicted),mergeableStatus:Ar(e.mergeableStatus),isPassedAllCiJob:Sr(e.isPassedAllCiJob),isCiStateSuccess:Sr(e.isCiStateSuccess),isResolvedAllReviewComments:Sr(e.isResolvedAllReviewComments),isBranchOutOfDate:Sr(e.isBranchOutOfDate),missingRequiredCheckNames:kr(e.missingRequiredCheckNames),summary:Or(e.summary)})),Mr=e=>{if(!yr(e)||!yr(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:Sr(t.isConflicted),mergeableStatus:Ar(t.mergeableStatus),isPassedAllCiJob:Sr(t.isPassedAllCiJob),isCiStateSuccess:Sr(t.isCiStateSuccess),isBranchOutOfDate:Sr(t.isBranchOutOfDate),missingRequiredCheckNames:kr(t.missingRequiredCheckNames)}},Nr=e=>yr(e)?{state:br(e.state)||`open`,merged:Sr(e.merged),isPullRequest:Sr(e.isPullRequest),title:br(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},Pr=()=>({fetchItemBody:async e=>{let t=await wr(`/api/itembody`,e);return yr(t)?br(t.body):``},fetchComments:async e=>Tr(await wr(`/api/comments`,e)),fetchPrFiles:async e=>Er(await wr(`/api/prfiles`,e)),fetchPrCommits:async e=>Dr(await wr(`/api/prcommits`,e)),fetchRelatedPrs:async e=>jr(await wr(`/api/relatedprs`,e)),fetchIssueState:async e=>Nr(await wr(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Mr(await wr(`/api/pullrequeststatus`,e))}),Fr=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(yr(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Ir=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 Fr(n))},Lr=`/api/comment`,Rr=e=>{if(!yr(e)||!yr(e.comment))throw Error(`comment was not returned`);return{author:br(e.comment.author),body:br(e.comment.body),createdAt:br(e.comment.createdAt)}},zr=async e=>{let t=await fetch(Lr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`);return Rr(await t.json())},Br=`/api/upload`,Vr=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Hr=async e=>{let t=await fetch(Br,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t));let n=await t.json();if(!yr(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},Ur=`/api/addstory`,Wr=async e=>{let t=await fetch(Ur,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},Gr=`/api/reviewcomment`,Kr=async e=>{let t=await fetch(Gr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},qr=`/api/createissue`,Jr=`/api/storycolor`,Yr=async e=>{let t=await fetch(Jr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},Xr=async e=>{let t=await fetch(qr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(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},Zr=`/api/reorderstory`,Qr=async e=>{let t=await fetch(Zr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},$r=`/api/deleteallcomments`,ei=async e=>{let t=await fetch($r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ti=`/api/deletestory`,ni=async e=>{let t=await fetch(ti,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ri=`/api/renamestory`,ii=async e=>{let t=await fetch(ri,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ai=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:[],workflowImprovementIssueUrl:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],workflowImprovementIssueUrl:typeof n.workflowImprovementIssueUrl==`string`?n.workflowImprovementIssueUrl:null}},oi=`/api/projectreadmeconfig`,si=async e=>{let t=`${oi}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await Fr(n));let r=await n.json();return{maximumPreparingIssuesCount:yr(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},ci=`/api/setdependedissueurl`,li=async e=>{let t=await fetch(ci,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ui=`/api/projectsettings`,di=async e=>{let t=await fetch(ui,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},fi=5e3,pi=e=>`${e.isPr?`PR #`:`#`}${e.number}`,mi=(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_1day`?`Next Action Date +1 day`:le(t)?`Next Action Date +1 week and skip`:`Next Action Date +1 week`;case`set_story`:return`Story → ${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`}},hi=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_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},gi=(e,t)=>e.type===`next_action_date`?le(t):e.type!==`delete_all_comments`,_i=(e,t,n)=>`${mi(e,n)} — ${pi(t)}`,vi=`console-offline-action-queue`,yi=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},bi=()=>{try{let e=localStorage.getItem(vi);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(yi):[]}catch{return[]}},xi=e=>{localStorage.setItem(vi,JSON.stringify(e))},Si=()=>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)}`,Ci=e=>e instanceof TypeError,wi=e=>e instanceof Error&&e.message.length>0?e.message:String(e),Ti=100,Ei=e=>Math.max(0,Math.ceil((fi-e)/1e3)),Di=e=>Math.max(0,1-e/fi),Oi=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(bi),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.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),f=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:Si(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return xi(n),n})},[]),p=(0,y.useCallback)(e=>{e.commit().catch(t=>{Ci(t)&&e.offline!==void 0?f(e):r({message:e.message,reason:wi(t)})})},[f]),m=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,p(e))},[d,p]),h=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.()},[d]),g=(0,y.useCallback)(()=>{r(null)},[]),_=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),v=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return xi(n),n})},[]),b=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Ir(t.apiPath,t.requestBody),v(e)}catch(n){Ci(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:wi(n)}),v(e))}},[v]),x=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;d(),u.current=!0,p(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Ei(0),progress:Di(0)}),e.advance(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){m();return}t({message:e.message,color:e.color,remainingSeconds:Ei(n),progress:Di(n)})},Ti)},[d,m,p]);return(0,y.useEffect)(()=>d,[d]),{pending:e,error:n,offlineActions:i,enqueue:x,showError:_,undo:h,dismissError:g,confirmOfflineAction:b,discardOfflineAction:v}},W=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)}},G=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},ki=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=G(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)}},Ai=(e=null)=>(0,y.useMemo)(()=>{let t=Pr(),n={client:t,body:new W(t.fetchItemBody),comments:new W(t.fetchComments),files:new W(t.fetchPrFiles),commits:new W(t.fetchPrCommits),relatedPrs:new W(t.fetchRelatedPrs),state:new W(t.fetchIssueState),prStatus:new W(t.fetchPullRequestStatus)};return e!==null&&ki(n,e),n},[e]),ji=0,Mi=500,Ni=2e3,Pi=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:Ni});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},Fi=(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)},Ii=(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+ji);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=Pi(()=>{for(let t of i)Fi(e,t)})},Mi);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},Li=`/api/features`,Ri=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(Li).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},zi=(e,t)=>{let n=D.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<D.length;e+=1){let n=D[e].name;if((t[n]??0)>0)return n}return null},Bi=e=>{for(let t of D)if((e[t.name]??0)>0)return t.name;return D[0].name},Vi=new Set(D.map(e=>e.name)),Hi=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return Vi.has(n)?n:null},Ui=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Wi=`#settings`,Gi=(e,t)=>{let n=(0,y.useCallback)(()=>{let e=Bi(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:Hi(window.location.pathname)??e,selectedItemKey:Ui(window.location.hash)}},[t]),[r,i]=(0,y.useState)(n);(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`||Hi(window.location.pathname)!==null)return;let e=Bi(t);i(t=>t.activeTab===e?t:{...t,activeTab:e})},[t]);let a=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),o=(0,y.useCallback)(e=>{if(typeof window>`u`){i({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,a(e)),i({activeTab:e,selectedItemKey:null})},[a]),s=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),i(t=>({...t,selectedItemKey:e}))},[]),c=(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:a,selectTab:o,openItem:s,closeItem:c}},Ki=e=>`pv_overlay_${e}`,qi=e=>e.projectItemId===``?e.itemId:e.projectItemId,Ji=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,Yi=(e,t,n)=>e.filter(e=>!Ji(t[qi(e)],n)).length,Xi=(e,t,n)=>e.filter(e=>!Ji(t[qi(e)],n)),Zi=(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},Qi=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[qi(t)];return i===void 0||i.ts<r?null:i.status??null},$i=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},ea=`/api/review`,ta=`/api/triage`,na=`/api/intmux`,ra=(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:I(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:oe}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:P,issueCommentBody:F(n)}},ia=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),aa=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),oa=()=>Error(`No project specified in the URL path.`),sa=(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(qi(e),{done:!0},t)},[a,t]);return{reviewPullRequest:(0,y.useCallback)(async(t,n,r,i=[])=>{if(e===null)throw oa();await Ir(ea,ra(e,t,n,r,i)),s(t),o(t)},[e,s,o]),setNextActionDate:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Ir(ta,r),o(t)},[e,s,o]),setStory:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();let i={pjcode:e,action:`set_story`,issueUrl:n.url,projectItemId:n.projectItemId,storyOptionId:r.id};a(qi(n),{done:!0,story:{name:r.name,color:r.color}},t),await Ir(ta,i),o(n)},[e,o,a,t]),setStatus:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();let i={pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name};a(qi(n),{done:!0,status:{name:r.name,color:r.color}},t),await Ir(ta,i),o(n)},[e,o,a,t]),setInTmuxByHuman:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();let i={pjcode:e,action:`set_intmux`,issueUrl:n.url,projectItemId:n.projectItemId};a(qi(n),{done:!0,status:{name:r.name,color:r.color}},t),await Ir(na,i),o(n)},[e,o,a,t]),closeIssue:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Ir(ta,r),o(t)},[e,s,o]),okAndMoveToAwaitingWorkspace:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();a(qi(n),{done:!0,status:{name:r.name,color:r.color}},t),await zr({pjcode:e,url:n.url,body:`ok`}),await Ir(ta,{pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name}),o(n),await i?.()},[e,o,a,t,i]),addComment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();let r=await zr({pjcode:e,url:t.url,body:n});return o(t),r},[e,o]),uploadAttachment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=Vr(new Uint8Array(await n.arrayBuffer()));return Hr({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw oa();await Kr({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),deleteAllComments:(0,y.useCallback)(async e=>{await ei({issueUrl:e.url}),o(e)},[o]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();await li({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e])}},ca=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,la=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(Ki(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))ca(t)&&(r[e]=t);return r},ua=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(Ki(e),JSON.stringify(t))},da=e=>{let[t,n]=(0,y.useState)(()=>la(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=$i(n,t,r,i,Date.now());return ua(e,a),a})},[e])}},fa=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},pa=()=>fa(typeof window>`u`?``:window.location.pathname),ma=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return a(!0),s(null),ai().then(n=>{e||(t(n.pjcodes),r(n.workflowImprovementIssueUrl),a(!1))}).catch(t=>{e||(s(t instanceof Error?t:Error(String(t))),a(!1))}),()=>{e=!0}},[]),{pjcodes:e,workflowImprovementIssueUrl:n,isLoading:i,error:o}},ha=()=>typeof window<`u`&&window.location.hash===`#settings`,ga=e=>{let[t,n]=(0,y.useState)(ha),[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)(``);(0,y.useEffect)(()=>{if(!t||e===null)return;let n=!1;return u(``),i(!0),c(null),si(e).then(e=>{n||u(e.maximumPreparingIssuesCount===null?``:String(e.maximumPreparingIssuesCount))}).catch(e=>{n||c(e instanceof Error?e.message:`Failed to load settings`)}).finally(()=>{n||i(!1)}),()=>{n=!0}},[t,e]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.location.hash===Wi;e||c(null),n(e)};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]);let f=(0,y.useCallback)(()=>{e!==null&&(typeof window<`u`&&(d.current=window.location.hash,window.history.pushState({},``,Wi)),n(!0))},[e]),p=(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)},[]),m=(0,y.useCallback)(e=>{u(e)},[]),h=(0,y.useCallback)(async t=>{if(e!==null){o(!0),c(null);try{if(await di({pjcode:e,maximumPreparingIssuesCount:t}),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)}}},[e]);return(0,y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&p()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,p]),{isOpen:t,isLoading:r,isSaving:a,error:s,inputValue:l,open:f,close:p,changeInput:m,save:h}},_a=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,[])}},va=/##\s+エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?\s*\n/i,ya=/^From:\s+:robot:/m,ba=e=>{let t=va.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=ya.exec(n),i=(r===null?n:n.slice(0,r.index)).trim();return i.length>0?i:null},xa=e=>{for(let t=e.length-1;t>=0;t--){let n=ba(e[t].body);if(n!==null)return n}return null},Sa=e=>`${e.repo}#${e.number}`,Ca=(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=Sa(n),a=t.peek(e);if(a!==void 0){let e=xa(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=xa(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},wa=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},Ta=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},Ea=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)return!0;t=t.parentElement}return!1},Da=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(Ea(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];Ta(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=wa(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},Oa=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ka=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Aa=e=>!Oa(e)||!Array.isArray(e.items)?[]:e.items.filter(Oa).map(e=>({...e,relatedOpenPullRequestUrls:ka(e.relatedOpenPullRequestUrls)})),ja=e=>Array.isArray(e)?e.filter(Oa):[],Ma=e=>Array.isArray(e)?e.filter(Oa):[],Na=e=>({items:Aa(e),generatedAt:Oa(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Oa(e)?ja(e.statusOptions):[],agentOptions:Oa(e)?ja(e.agentOptions):[],storyOptions:Oa(e)?ja(e.storyOptions):[],storyColors:Oa(e)&&Oa(e.storyColors)?e.storyColors:{},stories:Oa(e)?Ma(e.stories):[],defaultNameWithOwner:Oa(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Oa(e)?ka(e.storyOrder):[],timerEndsAt:Oa(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Oa(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Pa=()=>{let e={};for(let t of D)e[t.name]=null;return e},Fa=(e,t)=>`/projects/${e}/${t}/list.json`,Ia=6e4,La=`console-list-v1`,Ra=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(La).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)}},za=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(La)).match(e);return t===void 0?null:{...Na(await t.json()),fromCache:!0}}catch{return null}},Ba=async(e,t)=>{let n=Fa(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Ra(n,t),{snapshot:{...Na(t),fromCache:!1},error:null}}catch(e){let t=await za(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},Va=async e=>{let t=await Promise.all(D.map(async t=>{let{snapshot:n,error:r}=await Ba(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Pa(),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}},Ha=(e,t=null)=>{let[n,r]=(0,y.useState)(Pa),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Pa();for(let t of D){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}r(e),a(!1),s(null);return}}let n=!1;if(a(!0),s(null),e===null)return r(Pa()),a(!1),s(`No project specified in the URL path.`),()=>{n=!0};let i=()=>{Va(e).then(({snapshots:e,firstError:t})=>{n||(r(e),s(t===null?null:t.message),a(!1))}).catch(e=>{n||(s(e instanceof Error?e.message:String(e)),a(!1))})};i();let o=setInterval(i,Ia);return()=>{n=!0,clearInterval(o)}},[e,t]),{snapshots:n,isLoading:i,error:o,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:n}=await Ba(e,t);n!==null&&r(e=>({...e,[t]:n}))},[e])}},Ua=`tdpm-timer-settings`,Wa=()=>({timerMode:!1,projectMinutes:{}}),Ga=()=>{if(typeof localStorage>`u`)return Wa();let e=localStorage.getItem(Ua);if(e===null)return Wa();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return Wa();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 Wa()}},Ka=e=>{typeof localStorage<`u`&&localStorage.setItem(Ua,JSON.stringify(e))},qa=(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},Ja=()=>{let[e,t]=(0,y.useState)(Ga),[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=>(Ka(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}},Ya=e=>{window.location.replace(e)},Xa=e=>{window.location.assign(e)},Za=(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},Qa=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},$a=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},eo=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
|
|
13
|
+
`);i=c.pop()??``;for(let e of c){if(!e.startsWith(`data: `))continue;let n=_r(e.slice(6));if(n!==null){if(n.type===`progress`)r({fetched:typeof n.fetched==`number`?n.fetched:0,total:typeof n.total==`number`?n.total:0});else if(n.type===`done`){let e=hr(n.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}if(e.failures.length>0){s(e.failures),t(`error`);return}await Qn(e),Zn(!0),a(e),t(`on`),s([])}}}}}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[]),turnOff:(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),Zn(!1),er().catch(()=>{})},[])}},yr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),br=e=>typeof e==`string`?e:``,xr=e=>typeof e==`number`?e:0,Sr=e=>e===!0,Cr=`console-api-v1`,wr=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();yr(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(Cr).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(Cr)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},Tr=e=>!yr(e)||!Array.isArray(e.comments)?[]:e.comments.filter(yr).map(e=>({author:br(e.author),body:br(e.body),createdAt:br(e.createdAt)})),Er=e=>!yr(e)||!Array.isArray(e.files)?[]:e.files.filter(yr).map(e=>({path:br(e.path)||br(e.filename),additions:xr(e.additions),deletions:xr(e.deletions),status:br(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Dr=e=>!yr(e)||!Array.isArray(e.commits)?[]:e.commits.filter(yr).map(e=>({sha:br(e.sha),message:br(e.message),author:br(e.author),authoredAt:br(e.authoredAt)})),Or=e=>yr(e)?{title:br(e.title),body:br(e.body),additions:xr(e.additions),deletions:xr(e.deletions),changedFiles:xr(e.changedFiles)}:null,kr=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ar=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,jr=e=>!yr(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(yr).map(e=>({url:br(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:br(e.createdAt),isDraft:Sr(e.isDraft),isConflicted:Sr(e.isConflicted),mergeableStatus:Ar(e.mergeableStatus),isPassedAllCiJob:Sr(e.isPassedAllCiJob),isCiStateSuccess:Sr(e.isCiStateSuccess),isResolvedAllReviewComments:Sr(e.isResolvedAllReviewComments),isBranchOutOfDate:Sr(e.isBranchOutOfDate),missingRequiredCheckNames:kr(e.missingRequiredCheckNames),summary:Or(e.summary)})),Mr=e=>{if(!yr(e)||!yr(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:Sr(t.isConflicted),mergeableStatus:Ar(t.mergeableStatus),isPassedAllCiJob:Sr(t.isPassedAllCiJob),isCiStateSuccess:Sr(t.isCiStateSuccess),isBranchOutOfDate:Sr(t.isBranchOutOfDate),missingRequiredCheckNames:kr(t.missingRequiredCheckNames)}},Nr=e=>yr(e)?{state:br(e.state)||`open`,merged:Sr(e.merged),isPullRequest:Sr(e.isPullRequest),title:br(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},Pr=()=>({fetchItemBody:async e=>{let t=await wr(`/api/itembody`,e);return yr(t)?br(t.body):``},fetchComments:async e=>Tr(await wr(`/api/comments`,e)),fetchPrFiles:async e=>Er(await wr(`/api/prfiles`,e)),fetchPrCommits:async e=>Dr(await wr(`/api/prcommits`,e)),fetchRelatedPrs:async e=>jr(await wr(`/api/relatedprs`,e)),fetchIssueState:async e=>Nr(await wr(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Mr(await wr(`/api/pullrequeststatus`,e))}),Fr=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(yr(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Ir=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 Fr(n))},Lr=`/api/comment`,Rr=e=>{if(!yr(e)||!yr(e.comment))throw Error(`comment was not returned`);return{author:br(e.comment.author),body:br(e.comment.body),createdAt:br(e.comment.createdAt)}},zr=async e=>{let t=await fetch(Lr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(`HTTP ${t.status}`);return Rr(await t.json())},Br=`/api/upload`,Vr=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Hr=async e=>{let t=await fetch(Br,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t));let n=await t.json();if(!yr(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},Ur=`/api/addstory`,Wr=async e=>{let t=await fetch(Ur,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},Gr=`/api/reviewcomment`,Kr=async e=>{let t=await fetch(Gr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},qr=`/api/createissue`,Jr=`/api/storycolor`,Yr=async e=>{let t=await fetch(Jr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},Xr=async e=>{let t=await fetch(qr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(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},Zr=`/api/reorderstory`,Qr=async e=>{let t=await fetch(Zr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},$r=`/api/deleteallcomments`,ei=async e=>{let t=await fetch($r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ti=`/api/deletestory`,ni=async e=>{let t=await fetch(ti,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ri=`/api/renamestory`,ii=async e=>{let t=await fetch(ri,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ai=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:[],workflowImprovementIssueUrl:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],workflowImprovementIssueUrl:typeof n.workflowImprovementIssueUrl==`string`?n.workflowImprovementIssueUrl:null}},oi=`/api/projectreadmeconfig`,si=async e=>{let t=`${oi}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await Fr(n));let r=await n.json();return{maximumPreparingIssuesCount:yr(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},ci=`/api/setdependedissueurl`,li=async e=>{let t=await fetch(ci,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},ui=`/api/projectsettings`,di=async e=>{let t=await fetch(ui,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Fr(t))},fi=5e3,pi=e=>`${e.isPr?`PR #`:`#`}${e.number}`,mi=(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`:le(t)?`Next Action Date +1 week and skip`:`Next Action Date +1 week`;case`set_story`:return`Story → ${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`}},hi=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_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},gi=(e,t)=>e.type===`next_action_date`?le(t):e.type!==`delete_all_comments`,_i=(e,t,n)=>`${mi(e,n)} — ${pi(t)}`,vi=`console-offline-action-queue`,yi=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},bi=()=>{try{let e=localStorage.getItem(vi);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(yi):[]}catch{return[]}},xi=e=>{localStorage.setItem(vi,JSON.stringify(e))},Si=()=>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)}`,Ci=e=>e instanceof TypeError,wi=e=>e instanceof Error&&e.message.length>0?e.message:String(e),Ti=100,Ei=e=>Math.max(0,Math.ceil((fi-e)/1e3)),Di=e=>Math.max(0,1-e/fi),Oi=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(bi),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.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),f=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:Si(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return xi(n),n})},[]),p=(0,y.useCallback)(e=>{e.commit().catch(t=>{Ci(t)&&e.offline!==void 0?f(e):r({message:e.message,reason:wi(t)})})},[f]),m=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,p(e))},[d,p]),h=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.()},[d]),g=(0,y.useCallback)(()=>{r(null)},[]),_=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),v=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return xi(n),n})},[]),b=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Ir(t.apiPath,t.requestBody),v(e)}catch(n){Ci(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:wi(n)}),v(e))}},[v]),x=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;d(),u.current=!0,p(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Ei(0),progress:Di(0)}),e.advance(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){m();return}t({message:e.message,color:e.color,remainingSeconds:Ei(n),progress:Di(n)})},Ti)},[d,m,p]);return(0,y.useEffect)(()=>d,[d]),{pending:e,error:n,offlineActions:i,enqueue:x,showError:_,undo:h,dismissError:g,confirmOfflineAction:b,discardOfflineAction:v}},W=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)}},G=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},ki=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=G(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)}},Ai=(e=null)=>(0,y.useMemo)(()=>{let t=Pr(),n={client:t,body:new W(t.fetchItemBody),comments:new W(t.fetchComments),files:new W(t.fetchPrFiles),commits:new W(t.fetchPrCommits),relatedPrs:new W(t.fetchRelatedPrs),state:new W(t.fetchIssueState),prStatus:new W(t.fetchPullRequestStatus)};return e!==null&&ki(n,e),n},[e]),ji=0,Mi=500,Ni=2e3,Pi=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:Ni});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},Fi=(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)},Ii=(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+ji);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=Pi(()=>{for(let t of i)Fi(e,t)})},Mi);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},Li=`/api/features`,Ri=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(Li).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},zi=(e,t)=>{let n=D.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<D.length;e+=1){let n=D[e].name;if((t[n]??0)>0)return n}return null},Bi=e=>{for(let t of D)if((e[t.name]??0)>0)return t.name;return D[0].name},Vi=new Set(D.map(e=>e.name)),Hi=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return Vi.has(n)?n:null},Ui=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Wi=`#settings`,Gi=(e,t)=>{let n=(0,y.useCallback)(()=>{let e=Bi(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:Hi(window.location.pathname)??e,selectedItemKey:Ui(window.location.hash)}},[t]),[r,i]=(0,y.useState)(n);(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`||Hi(window.location.pathname)!==null)return;let e=Bi(t);i(t=>t.activeTab===e?t:{...t,activeTab:e})},[t]);let a=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),o=(0,y.useCallback)(e=>{if(typeof window>`u`){i({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,a(e)),i({activeTab:e,selectedItemKey:null})},[a]),s=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),i(t=>({...t,selectedItemKey:e}))},[]),c=(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:a,selectTab:o,openItem:s,closeItem:c}},Ki=e=>`pv_overlay_${e}`,qi=e=>e.projectItemId===``?e.itemId:e.projectItemId,Ji=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,Yi=(e,t,n)=>e.filter(e=>!Ji(t[qi(e)],n)).length,Xi=(e,t,n)=>e.filter(e=>!Ji(t[qi(e)],n)),Zi=(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},Qi=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[qi(t)];return i===void 0||i.ts<r?null:i.status??null},$i=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},ea=`/api/review`,ta=`/api/triage`,na=`/api/intmux`,ra=(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:I(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:oe}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:P,issueCommentBody:F(n)}},ia=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),aa=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),oa=()=>Error(`No project specified in the URL path.`),sa=(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(qi(e),{done:!0},t)},[a,t]);return{reviewPullRequest:(0,y.useCallback)(async(t,n,r,i=[])=>{if(e===null)throw oa();await Ir(ea,ra(e,t,n,r,i)),s(t),o(t)},[e,s,o]),setNextActionDate:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Ir(ta,r),o(t)},[e,s,o]),setStory:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();let i={pjcode:e,action:`set_story`,issueUrl:n.url,projectItemId:n.projectItemId,storyOptionId:r.id};a(qi(n),{done:!0,story:{name:r.name,color:r.color}},t),await Ir(ta,i),o(n)},[e,o,a,t]),setStatus:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();let i={pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name};a(qi(n),{done:!0,status:{name:r.name,color:r.color}},t),await Ir(ta,i),o(n)},[e,o,a,t]),setInTmuxByHuman:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();let i={pjcode:e,action:`set_intmux`,issueUrl:n.url,projectItemId:n.projectItemId};a(qi(n),{done:!0,status:{name:r.name,color:r.color}},t),await Ir(na,i),o(n)},[e,o,a,t]),closeIssue:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Ir(ta,r),o(t)},[e,s,o]),okAndMoveToAwaitingWorkspace:(0,y.useCallback)(async(n,r)=>{if(e===null)throw oa();a(qi(n),{done:!0,status:{name:r.name,color:r.color}},t),await zr({pjcode:e,url:n.url,body:`ok`}),await Ir(ta,{pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name}),o(n),await i?.()},[e,o,a,t,i]),addComment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();let r=await zr({pjcode:e,url:t.url,body:n});return o(t),r},[e,o]),uploadAttachment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=Vr(new Uint8Array(await n.arrayBuffer()));return Hr({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw oa();await Kr({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),deleteAllComments:(0,y.useCallback)(async e=>{await ei({issueUrl:e.url}),o(e)},[o]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw oa();await li({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e])}},ca=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,la=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(Ki(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))ca(t)&&(r[e]=t);return r},ua=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(Ki(e),JSON.stringify(t))},da=e=>{let[t,n]=(0,y.useState)(()=>la(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=$i(n,t,r,i,Date.now());return ua(e,a),a})},[e])}},fa=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},pa=()=>fa(typeof window>`u`?``:window.location.pathname),ma=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return a(!0),s(null),ai().then(n=>{e||(t(n.pjcodes),r(n.workflowImprovementIssueUrl),a(!1))}).catch(t=>{e||(s(t instanceof Error?t:Error(String(t))),a(!1))}),()=>{e=!0}},[]),{pjcodes:e,workflowImprovementIssueUrl:n,isLoading:i,error:o}},ha=()=>typeof window<`u`&&window.location.hash===`#settings`,ga=e=>{let[t,n]=(0,y.useState)(ha),[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)(``);(0,y.useEffect)(()=>{if(!t||e===null)return;let n=!1;return u(``),i(!0),c(null),si(e).then(e=>{n||u(e.maximumPreparingIssuesCount===null?``:String(e.maximumPreparingIssuesCount))}).catch(e=>{n||c(e instanceof Error?e.message:`Failed to load settings`)}).finally(()=>{n||i(!1)}),()=>{n=!0}},[t,e]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.location.hash===Wi;e||c(null),n(e)};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]);let f=(0,y.useCallback)(()=>{e!==null&&(typeof window<`u`&&(d.current=window.location.hash,window.history.pushState({},``,Wi)),n(!0))},[e]),p=(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)},[]),m=(0,y.useCallback)(e=>{u(e)},[]),h=(0,y.useCallback)(async t=>{if(e!==null){o(!0),c(null);try{if(await di({pjcode:e,maximumPreparingIssuesCount:t}),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)}}},[e]);return(0,y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&p()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,p]),{isOpen:t,isLoading:r,isSaving:a,error:s,inputValue:l,open:f,close:p,changeInput:m,save:h}},_a=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,[])}},va=/##\s+エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?\s*\n/i,ya=/^From:\s+:robot:/m,ba=e=>{let t=va.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=ya.exec(n),i=(r===null?n:n.slice(0,r.index)).trim();return i.length>0?i:null},xa=e=>{for(let t=e.length-1;t>=0;t--){let n=ba(e[t].body);if(n!==null)return n}return null},Sa=e=>`${e.repo}#${e.number}`,Ca=(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=Sa(n),a=t.peek(e);if(a!==void 0){let e=xa(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=xa(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},wa=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},Ta=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},Ea=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)return!0;t=t.parentElement}return!1},Da=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(Ea(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];Ta(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=wa(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},Oa=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ka=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Aa=e=>!Oa(e)||!Array.isArray(e.items)?[]:e.items.filter(Oa).map(e=>({...e,relatedOpenPullRequestUrls:ka(e.relatedOpenPullRequestUrls)})),ja=e=>Array.isArray(e)?e.filter(Oa):[],Ma=e=>Array.isArray(e)?e.filter(Oa):[],Na=e=>({items:Aa(e),generatedAt:Oa(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Oa(e)?ja(e.statusOptions):[],agentOptions:Oa(e)?ja(e.agentOptions):[],storyOptions:Oa(e)?ja(e.storyOptions):[],storyColors:Oa(e)&&Oa(e.storyColors)?e.storyColors:{},stories:Oa(e)?Ma(e.stories):[],defaultNameWithOwner:Oa(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Oa(e)?ka(e.storyOrder):[],timerEndsAt:Oa(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Oa(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Pa=()=>{let e={};for(let t of D)e[t.name]=null;return e},Fa=(e,t)=>`/projects/${e}/${t}/list.json`,Ia=6e4,La=`console-list-v1`,Ra=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(La).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)}},za=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(La)).match(e);return t===void 0?null:{...Na(await t.json()),fromCache:!0}}catch{return null}},Ba=async(e,t)=>{let n=Fa(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Ra(n,t),{snapshot:{...Na(t),fromCache:!1},error:null}}catch(e){let t=await za(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},Va=async e=>{let t=await Promise.all(D.map(async t=>{let{snapshot:n,error:r}=await Ba(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Pa(),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}},Ha=(e,t=null)=>{let[n,r]=(0,y.useState)(Pa),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Pa();for(let t of D){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}r(e),a(!1),s(null);return}}let n=!1;if(a(!0),s(null),e===null)return r(Pa()),a(!1),s(`No project specified in the URL path.`),()=>{n=!0};let i=()=>{Va(e).then(({snapshots:e,firstError:t})=>{n||(r(e),s(t===null?null:t.message),a(!1))}).catch(e=>{n||(s(e instanceof Error?e.message:String(e)),a(!1))})};i();let o=setInterval(i,Ia);return()=>{n=!0,clearInterval(o)}},[e,t]),{snapshots:n,isLoading:i,error:o,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:n}=await Ba(e,t);n!==null&&r(e=>({...e,[t]:n}))},[e])}},Ua=`tdpm-timer-settings`,Wa=()=>({timerMode:!1,projectMinutes:{}}),Ga=()=>{if(typeof localStorage>`u`)return Wa();let e=localStorage.getItem(Ua);if(e===null)return Wa();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return Wa();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 Wa()}},Ka=e=>{typeof localStorage<`u`&&localStorage.setItem(Ua,JSON.stringify(e))},qa=(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},Ja=()=>{let[e,t]=(0,y.useState)(Ga),[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=>(Ka(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}},Ya=e=>{window.location.replace(e)},Xa=e=>{window.location.assign(e)},Za=(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},Qa=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},$a=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},eo=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
|
|
14
14
|
`)?`${e}${t}\n`:`${e}\n${t}\n`,to=(e,t)=>{let n=`![uploading ${t}]()`;return`${e.length===0?``:e.replace(/\n*$/,`
|
|
15
15
|
`)}\n\n\n${n}\n`},no=(e,t,n)=>{let r=`![uploading ${t}]()`,i=e.indexOf(r);return i===-1?eo(e,n):e.slice(0,i)+n+e.slice(i+r.length)},ro=(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]===`
|
|
@@ -85,4 +85,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
85
85
|
`)}),o+=1,r=[])};for(let e of t){if(a){r.push(e),Q(e)&&(a=!1);continue}if(i===null&&Fl(e)){s(),i=[];continue}if(i!==null){if(Q(e)){n.push({kind:`mermaid`,key:`mermaid:${o}`,code:i.join(`
|
|
86
86
|
`)}),o+=1,i=null;continue}i.push(e);continue}if(Z(e)){r.push(e),a=!0;continue}r.push(e)}return i!==null&&r.push("```mermaid",...i),s(),n},Ll=({code:e,label:t=`Copy code`})=>(0,x.jsx)(jn,{value:e,idleText:t,idleAriaLabel:t,copiedAriaLabel:`Code copied to clipboard`,className:`console-copy-code-button`}),Rl=`https://cdn.jsdelivr.net/npm/mermaid@10.9.6/dist/mermaid.min.js`,zl=null,Bl=0,Vl=e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#0d1117`,primaryColor:`#161b22`,primaryTextColor:`#e6edf3`,primaryBorderColor:`#30363d`,lineColor:`#8b949e`,fontSize:`14px`}}),e),Hl=()=>zl===null?window.mermaid===void 0?(zl=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=Rl,n.async=!0,n.onload=()=>{if(window.mermaid===void 0){t(Error(`mermaid failed to load`));return}e(Vl(window.mermaid))},n.onerror=()=>t(Error(`mermaid script failed to load`)),document.head.appendChild(n)}),zl):(zl=Promise.resolve(Vl(window.mermaid)),zl):zl,Ul=async e=>{let t=await Hl();Bl+=1;let n=`console-mermaid-${Bl}`,{svg:r}=await t.render(n,e);return Rs.sanitize(r,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`foreignObject`]})},Wl=.5,Gl=e=>Number.isNaN(e)||e<1?1:e>6?6:e,Kl=e=>Gl(Gl(e)+Wl),ql=e=>Gl(Gl(e)-Wl),Jl=e=>Gl(e)<=1,Yl=e=>Gl(e)>=6,Xl=e=>`${Math.round(Gl(e)*100)}%`,Zl=e=>`${Gl(e)*100}%`,Ql=({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:Jl(n),onClick:()=>r(ql(n)),children:`−`}),(0,x.jsx)(`span`,{className:`console-mermaid-modal-scale`,children:Xl(n)}),(0,x.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom in`,disabled:Yl(n),onClick:()=>r(Kl(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:Zl(n)}})})]})},$l=({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`}),Ul(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)(Ql,{svg:t.svg,onClose:()=>i(!1)})]})},eu=e=>{let t=e.querySelectorAll(`a[href]`),n=[];return t.forEach((e,t)=>{let r=e.getAttribute(`href`)??``;if(oo(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},tu=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},nu=({source:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,y.useMemo)(()=>{let n=X(e,r);return t===void 0?n:fo(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(tu(e)),s(n===void 0?[]:eu(e)))},[i,n]),(0,x.jsxs)(`div`,{ref:a,className:`console-markdown`,children:[c.map(e=>(0,E.createPortal)((0,x.jsx)(Ll,{code:e.code}),e.host,e.key)),n!==void 0&&o.map(e=>(0,E.createPortal)(n(e.href,e.fallbackText),e.host,e.key))]})},ru=({body:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,y.useMemo)(()=>Il(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)($l,{code:e.code},e.key):(0,x.jsx)(nu,{source:e.source,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r},e.key))})},iu=({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})]})},au=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:[]}),su=e=>e.split(`/`).filter(e=>e!==``),cu=(e,t)=>e.name.localeCompare(t.name),lu=(e,t)=>{let n=[];e.directories.forEach((e,r)=>{let i=t===``?r:`${t}/${r}`;n.push({kind:`directory`,name:r,path:i,children:lu(e,i)})}),n.sort(cu);let r=e.files.map(e=>({kind:`file`,name:su(e.path).at(-1)??e.path,path:e.path,file:e}));return r.sort(cu),[...n,...r]},uu=e=>{let t=ou();for(let n of e){let e=su(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 lu(t,``)},du=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,fu=e=>{let t=[],n=0,r=0;for(let i of e.split(`
|
|
87
87
|
`)){if(i.startsWith(`@@`)){let e=i.match(du);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},pu=[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.avif`,`.bmp`,`.ico`],mu=e=>{let t=e.toLowerCase();return pu.some(e=>t.endsWith(e))},hu=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,gu=e=>`${e.kind}:${e.oldLineNumber??`x`}:${e.newLineNumber??`x`}:${e.content}`,_u=({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]})]})]})]})},vu=({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(mu(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=fu(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=gu(e),r=c?hu(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)(_u,{target:a,onSubmit:i,onClose:()=>o(null)})})})]},n)})})})},yu=e=>({paddingLeft:`${e*16}px`}),bu=({file:e,depth:t,name:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,y.useState)(!1),s=au(e.status);return(0,x.jsxs)(`li`,{className:`console-file`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`console-file-row`,style:yu(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)(vu,{patch:e.patch,path:e.path,rawUrl:e.rawUrl,buildImageProxyUrl:r,onAddInlineComment:i})]})},xu=({node:e,depth:t,buildImageProxyUrl:n,onAddInlineComment:r})=>e.kind===`file`?(0,x.jsx)(bu,{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:yu(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)(xu,{node:e,depth:t+1,buildImageProxyUrl:n,onAddInlineComment:r},e.path))})]}),Su=({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=uu(e);return(0,x.jsx)(`ul`,{className:`console-files console-file-tree`,children:a.map(e=>(0,x.jsx)(xu,{node:e,depth:0,buildImageProxyUrl:r,onAddInlineComment:i},e.path))})},Cu=({comments:e,isLoading:t,error:n,now:r,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})=>{let[s,c]=(0,y.useState)(!1);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 l=s?e:e.slice(-1);return(0,x.jsxs)(`div`,{className:`console-comment-list`,children:[!s&&e.length>1&&(0,x.jsxs)(`button`,{type:`button`,className:`console-comment-show-all`,onClick:()=>c(!0),children:[`Show all `,e.length]}),l.map(e=>(0,x.jsxs)(`article`,{className:`console-comment`,children:[(0,x.jsxs)(`header`,{className:`console-comment-header`,children:[(0,x.jsx)(`span`,{className:`console-comment-author`,children:e.author}),(0,x.jsx)(`span`,{className:`console-comment-time`,children:pe(e.createdAt,r)})]}),(0,x.jsx)(ru,{body:e.body,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})]},`${e.author}:${e.createdAt}:${e.body}`))]})},wu=e=>e.slice(0,7),Tu=e=>e.split(`
|
|
88
|
-
`)[0],Eu=({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:Tu(e.message)}),(0,x.jsx)(`span`,{className:`console-commit-sha`,children:wu(e.sha)}),(0,x.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,x.jsx)(`span`,{className:`console-commit-time`,children:pe(e.authoredAt,r)})]},e.sha))}):(0,x.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Du=({url:e,label:t=`Copy URL`})=>(0,x.jsx)(jn,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),Ou=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}))},ku=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,Au=({failures:e})=>e.length===0?null:(0,x.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:Ou(e).map(e=>(0,x.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,ku(e.sections),`:`,` `,e.message]},e.message))}),ju={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`}},Mu=({mergeableStatus:e})=>{let t=ju[e],n=ae(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})},Nu=e=>{let t=ae(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},Pu=({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:Nu(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:Nu(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},Fu=({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=oo(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)(Mu,{mergeableStatus:e.mergeableStatus}),(0,x.jsx)(Pu,{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)(Du,{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)(iu,{title:`Description`,children:n?(0,x.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,x.jsx)(ru,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,x.jsx)(iu,{title:`Changed files`,count:g,children:(0,x.jsx)(Su,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,x.jsx)(iu,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,x.jsx)(Eu,{commits:o,isLoading:s,error:c,now:l})})]})},Iu=({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:E,buildImageProxyUrl:D,renderReferenceLink:O,onAddInlineComment:ee})=>{let te=a?.state??`open`,ne=a?.merged??!1,re=!e.isPr&&te===`closed`?`Closed`:null,k=K(e.nameWithOwner)??void 0,ie=ae(n),A=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,j=A===null?null:ae(A.color),M=p||m!==null?null:f.length,N=u||d!==null?null:l.length,oe=g||_!==null?null:h.length,P=!u&&d===null&&l.length>0,F=e=>{let t=oo(e);return t===null?e:`PR #${t.number}`},I=[{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 ${F(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${F(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),L=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)(_e,{isPr:e.isPr,state:te,merged:ne,isDraft:!1,stateReason:``}),(0,x.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}),(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:[A!==null&&j!==null&&(0,x.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:j.fg,borderColor:j.border,backgroundColor:j.bg},children:A.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:ie.dot}}),t]}),e.isPr&&y?.found&&(0,x.jsx)(Pu,{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:F(e.pullRequest.url)}),(0,x.jsx)(Pu,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,x.jsx)(Mu,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),L.map(e=>(0,x.jsx)(Mu,{mergeableStatus:e.mergeableStatus},e.url)),re!==null&&(0,x.jsx)(`span`,{className:`console-detail-closed-label`,children:re})]}),(0,x.jsx)(Au,{failures:I}),(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:me(e.createdAt),children:[`opened `,pe(e.createdAt,w)]}),(0,x.jsx)(Du,{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)(iu,{title:`Description`,defaultCollapsed:P,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)(ru,{body:o,buildImageProxyUrl:D,renderReferenceLink:O,repoContext:k}):(0,x.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})},P?`desc-collapsed`:`desc-open`),e.isPr&&(0,x.jsx)(iu,{title:`Changed files`,count:M,children:(0,x.jsx)(Su,{files:f,isLoading:p,error:m,onAddInlineComment:ee})}),(0,x.jsx)(iu,{title:`Comments`,count:N,defaultCollapsed:e.isPr,children:(0,x.jsx)(Cu,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:D,renderReferenceLink:O,repoContext:k})}),e.isPr&&(0,x.jsx)(iu,{title:`Commits`,count:oe,defaultCollapsed:!0,children:(0,x.jsx)(Eu,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&S.map(e=>(0,x.jsx)(Fu,{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:D,renderReferenceLink:O,onAddInlineComment:ee},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:E})]})]})},Lu=({onClose:e})=>(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`})]}),Ru=({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()=>{if(t){c(!0),u(null);try{await t()}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? Open tasks assigned to this story will be closed.`]}),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(),disabled:s,children:s?`Deleting…`:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{o(!1),u(null)},disabled:s,children:`Cancel`})]})]})]})},zu=({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_1day`),children:`+1 day`}),(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`})]}),Bu=[{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`}],Vu=`Reject needs an inline comment on the diff.`,Hu=({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:Vu}),Bu.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)})]}),Uu=({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})]})},Wu=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},Gu=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=ce.map(t=>({name:t,option:Wu(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=ae(r.color),a=e===L;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)})})},Ku=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,handlers:i,storyNameForDeletion:a})=>(0,x.jsxs)(`div`,{className:`console-operation-bar`,children:[t&&(0,x.jsx)(Hu,{onReview:i.onReview,rejectEnabled:n}),(0,x.jsx)(zu,{isManualTriage:le(e),onSetNextActionDate:i.onSetNextActionDate}),(0,x.jsx)(Gu,{statusOptions:r,onSetStatus:i.onSetStatus,onSetInTmuxByHuman:i.onSetInTmuxByHuman}),(0,x.jsxs)(`div`,{className:`console-op-group-bottom-row`,children:[(0,x.jsxs)(`div`,{className:`console-op-group-left-pair`,children:[(0,x.jsx)(Uu,{onSetDependedIssueUrl:i.onSetDependedIssueUrl}),(0,x.jsx)(Ru,{onDeleteAllComments:i.onDeleteAllComments,onDeleteStory:i.onDeleteStory,storyNameForDeletion:a})]}),(0,x.jsx)(Lu,{onClose:i.onClose})]})]}),qu=(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}},Ju=[],Yu=[],Xu=[],Zu=[],Qu={state:`open`,merged:!1,isPullRequest:!1,title:``},$u={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},ed=(e,t,n)=>{let r=t===null?null:`${t.repo}#${t.number}`,i=t===null?null:t.url,a=t?.isPr??!1,o=qu(e.body,r,i,``),s=qu(e.state,r,i,Qu),c=qu(e.comments,r,i,Ju),l=qu(e.files,a?r:null,a?i:null,Yu),u=qu(e.commits,a?r:null,a?i:null,Xu),d=qu(e.prStatus,a?r:null,a?i:null,$u),f=!a&&((t?.relatedOpenPullRequestUrls.length??0)>0||n===`prs`),p=qu(e.relatedPrs,f?r:null,f?i:null,Zu),[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:Yu,filesAreLoading:!0,filesError:null,commits:Xu,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}},td=e=>JSON.stringify([e.author,e.createdAt,e.body]),nd=(e,t)=>{let n=new Set(e.map(td));return[...e,...t.filter(e=>!n.has(td(e)))]},rd=({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=oo(e);return(0,x.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,x.jsx)(_e,{...so(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]})]})},id=(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},ad=({cache:e,href:t,fallbackText:n})=>{let r=id(e,t);return(0,x.jsx)(rd,{href:t,fallbackText:n,state:r})},od=e=>({itemUrl:e.url,projectItemId:e.projectItemId,itemNumber:e.number,repo:e.repo,isPr:e.isPr}),sd=(e,t,n,r,i)=>({...od(t),apiPath:ea,requestBody:ra(e,t,n,r,i)}),cd=(e,t,n,r)=>({...od(t),apiPath:ta,requestBody:ia(e,t,n,r)}),ld=(e,t)=>({...od(t),apiPath:na,requestBody:aa(e,t)}),ud=({tab:e,item:t,caches:n,operations:r,pjcode:i,statusOptions:a,storyColors:o,storyName:s,overlayStatus:c,now:l,initialCommentDraft:u,onCommentDraftChange:d,onQueueAction:f,onDeleteStory:p,storyNameForDeletion:m})=>{let h=ed(n,t,e),g=(0,y.useCallback)(e=>uo(e,t.url),[t.url]),_=(0,y.useCallback)((e,t)=>(0,x.jsx)(ad,{cache:n.state,href:e,fallbackText:t}),[n.state]),v=t.isPr||t.relatedOpenPullRequestUrls.length>0||h.relatedPullRequests.length>0,[b,S]=(0,y.useState)([]),C=(0,y.useCallback)(async(e,t,n,r)=>{S(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[w,T]=(0,y.useState)([]),E=(0,y.useCallback)(async e=>{let n=await r.addComment(t,e);return T(e=>[...e,n]),n},[t,r]),D={onReview:e=>{let n=t.isPr?t.url:h.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,a=e===`request_changes`?b:[];f({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,a),offline:i==null?void 0:sd(i,t,n,e,a)})},onSetNextActionDate:e=>{f({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e),offline:i==null?void 0:cd(i,t,e)})},onSetStory:e=>{f({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e),offline:i==null?void 0:cd(i,t,`set_story`,{storyOptionId:e.id})})},onSetStatus:e=>{f({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e),offline:i==null?void 0:cd(i,t,`set_status`,{statusName:e.name})})},onSetInTmuxByHuman:e=>{f({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=>{f({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e),offline:i==null?void 0:cd(i,t,e)})},onOkAndAwaitingWorkspace:e=>{f({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e)})},onDeleteAllComments:()=>{f({kind:{type:`delete_all_comments`},item:t,commit:()=>r.deleteAllComments(t)})},onDeleteStory:p??null,onSetDependedIssueUrl:i==null?null:async e=>{await r.setDependedIssueUrl(t,e)}},O=a.find(e=>e.name===`Awaiting Workspace`)??null,ee=O===null?void 0:async e=>(d?.(``),D.onSetStatus(O),E(e)),te=s??(t.story.trim()===``?null:t.story),ne=te===null?null:k(o,te);return(0,x.jsx)(Iu,{item:t,storyName:te,storyColorEnum:ne,overlayStatus:c,statusOptions:a,state:h.state,stateError:h.stateError,body:h.body,bodyIsLoading:h.bodyIsLoading,bodyError:h.bodyError,comments:nd(h.comments,w),commentsAreLoading:h.commentsAreLoading,commentsError:h.commentsError,files:h.files,filesAreLoading:h.filesAreLoading,filesError:h.filesError,commits:h.commits,commitsAreLoading:h.commitsAreLoading,commitsError:h.commitsError,pullRequestStatus:h.pullRequestStatus,pullRequestStatusError:h.pullRequestStatusError,relatedPullRequests:h.relatedPullRequests,relatedPullRequestsError:h.relatedPullRequestsError,now:l,buildImageProxyUrl:g,renderReferenceLink:_,onAddInlineComment:C,commentComposer:(0,x.jsx)(io,{initiallyOpen:!0,initialDraft:u,onSubmit:E,onDraftChange:d,onOkAndAwaitingWorkspace:O===null?void 0:()=>D.onOkAndAwaitingWorkspace(O),onSubmitAndMoveToAwaitingWorkspace:ee,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,x.jsx)(Ku,{tab:e,item:t,hasPullRequest:v,rejectEnabled:b.length>0,statusOptions:a,handlers:D,storyNameForDeletion:m})})},dd=()=>{let e={};for(let t of D)e[t.name]=0;return e},fd=`console`,pd=()=>{let e=pa(),t=Ri(),n=vr(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o,refreshSingleTab:s}=Ha(e,r),{timerMode:c,projectMinutes:l,isOpen:u,draftTimerMode:d,draftProjectMinutes:f,openSettings:p,closeSettings:m,saveSettings:h,toggleDraftTimerMode:g,changeDraftMinutes:_}=Ja(),{pjcodes:v,workflowImprovementIssueUrl:b,isLoading:C}=ma(),{isTimerExpired:w}=_a(e),E=da(e??fd),O=ga(e),ee=(0,y.useMemo)(()=>{let e=dd();for(let t of D){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=Yi(n.items,Zi(E.overlay,n.generatedAt),t.name))}return e},[i,E.overlay]),re=Gi(e,ee),{activeTab:k,selectedItemKey:A,openItem:M,closeItem:ae,selectTab:N}=re,oe=(0,y.useRef)(new Map),P=(0,y.useCallback)(e=>{A!==null&&(e?oe.current.set(A,e):oe.current.delete(A))},[A]),F=Ai(r),I=sa(e,k,E,F,(0,y.useCallback)(()=>s(`queued`),[s])),L=Oi(),[se,ce]=(0,y.useState)(()=>Date.now());(0,y.useEffect)(()=>{let e=setInterval(()=>{ce(Date.now())},1e3);return()=>{clearInterval(e)}},[]);let[le,ue]=(0,y.useState)(()=>navigator.onLine);(0,y.useEffect)(()=>{let e=()=>ue(!0),t=()=>ue(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)}},[]);let[R,de]=(0,y.useState)(new Map),[z,fe]=(0,y.useState)(new Map),[pe,me]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{if(!(!le||L.offlineActions.length===0))for(let e of L.offlineActions)R.has(e.id)||pe.has(e.id)||(de(t=>new Map(t).set(e.id,null)),F.client.fetchIssueState(e.itemUrl).then(t=>{de(n=>new Map(n).set(e.id,t)),e.isPr&&(fe(t=>new Map(t).set(e.id,null)),F.client.fetchPullRequestStatus(e.itemUrl).then(t=>{fe(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),me(t=>new Set(t).add(e.id))}))},[le,L.offlineActions,F.client,R,pe]);let[he,ge]=(0,y.useState)(!1),_e=(0,y.useCallback)(async e=>{ge(!0);try{await L.confirmOfflineAction(e)}finally{ge(!1)}},[L]),ve=(0,y.useMemo)(()=>L.offlineActions.map(e=>{let t=R.get(e.id)??null,n=z.get(e.id)??null,r=pe.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}}),[L.offlineActions,R,z,pe]),ye=i[k],Se=(0,y.useMemo)(()=>ye===null?[]:Xi(ye.items,Zi(E.overlay,ye.generatedAt),k),[ye,E.overlay,k]),[Ce,Te]=(0,y.useState)(null),Ee=(0,y.useMemo)(()=>{if(k!==`prs`)return{};let e={};for(let t of Se)t.agent!==null&&t.agent!==``&&(e[t.agent]=(e[t.agent]??0)+1);return e},[Se,k]);(0,y.useEffect)(()=>{k===`prs`&&Ce!==null&&(Ee[Ce]??0)===0&&Te(null)},[Ee,Ce,k]);let De=(0,y.useMemo)(()=>k!==`prs`||Ce===null?Se:Se.filter(e=>e.agent===Ce),[Se,k,Ce]),Oe=(0,y.useMemo)(()=>De.map(e=>qi(e)),[De]),ke=ye?.storyOrder??[],Ae=(0,y.useMemo)(()=>j(De,E.overlay,ke,ye?.generatedAt??null),[De,E.overlay,ke,ye]),je=ye?.storyColors??{},Me=ye?.statusOptions??[],Ne=ye?.agentOptions??[],Pe=ye?.generatedAt??null,Fe=ye?.fromCache??!1,[Ie,Le]=(0,y.useState)(null),Re=(0,y.useMemo)(()=>A===null||ye===null?null:ye.items.find(e=>e.projectItemId===A)??null,[A,ye]);Ii(F,Re,Se),(0,y.useEffect)(()=>{A!==null&&window.scrollTo({top:0})},[A]),(0,y.useEffect)(()=>{if(e===null&&c&&v.length>0){let e=qa(v,null,l);e!==null&&Ya(`/projects/${e}`)}},[e,c,v,l]);let ze=ee[k],Be=(0,y.useRef)({tab:k,count:ze});(0,y.useEffect)(()=>{let e=Be.current;if(Be.current={tab:k,count:ze},e.tab===k&&e.count>0&&ze===0){let e=zi(k,ee);e!==null&&(N(e),ae())}},[k,ze,ee,N,ae]);let Ve=Re===null?null:Qi(E.overlay,Re,i[k]?.generatedAt??null),He=Re===null?null:ie(Re,E.overlay,i[k]?.generatedAt??null),Ue=(0,y.useCallback)(e=>{let t=Za(Oe,e);t===null?ae():M(t)},[Oe,M,ae]),We=(0,y.useCallback)(t=>{if(n.status===`on`){L.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=qi(t.item);L.enqueue({message:_i(t.kind,t.item,k),color:hi(t.kind),commit:t.commit,offline:t.offline,revertAdvance:t.revertAdvance,advance:()=>{if(t.onAdvance?.(),!t.skipAdvance&&gi(t.kind,k)){if(c&&w(l[e??``]??0)){let t=qa(v,e,l);t!==null&&Xa(`/projects/${t}`)}else Ue(r)}}})},[L,k,Ue,n.status,c,w,l,e,v]),Ge=Da((0,y.useCallback)(e=>{if(A===null||e===null)return;let t=e===`next`?Qa(Oe,A):$a(Oe,A);t!==null&&M(t)},[A,Oe,M])),[Ke,qe]=(0,y.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),Je=(0,y.useCallback)(()=>{qe(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),Ye=i.stories,Xe=Ye?.stories??[],Ze=Ie!==null&&Ie.generatedAt===Ye?.generatedAt?Ie.stories:Xe,Qe=Ye?.defaultNameWithOwner??null,$e=(0,y.useMemo)(()=>Re===null||!Re.labels.includes(`story`)?null:Ze.find(e=>e.storyName===Re.story)??null,[Re,Ze]),et=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(Qe===null)throw Error(`No repository configured for this project.`);await Xr({pjcode:e,title:n,storyOptionId:t,nameWithOwner:Qe})},[e,Qe]),tt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Qr({pjcode:e,storyOptionId:t,direction:n});let r=Ze.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<Ze.length){let t=[...Ze],n=t[r];t[r]=t[e],t[e]=n,Le({generatedAt:Ye?.generatedAt,stories:t})}}},[e,Ze,Ye?.generatedAt]),nt=(0,y.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Wr({pjcode:e,storyName:t})},[e]),[rt,it]=(0,y.useState)({}),[at,ot]=(0,y.useState)(null),[st,ct]=(0,y.useState)({}),lt=(0,y.useCallback)((t,n)=>{let r=Ze.find(e=>e.storyOptionId===t)?.color;if(ot(t),it(e=>({...e,[t]:n})),ct(e=>{let n={...e};return delete n[t],n}),e===null||Qe===null){it(e=>r===void 0?e:{...e,[t]:r}),ct(e=>({...e,[t]:`No project or repository configured.`})),ot(e=>e===t?null:e);return}Yr({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:Qe}).catch(e=>{it(e=>r===void 0?e:{...e,[t]:r}),ct(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{ot(e=>e===t?null:e)})},[e,Qe,Ze]),ut=(0,y.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await ni({pjcode:e,storyOptionId:t}),Le({generatedAt:Ye?.generatedAt,stories:Ze.filter(e=>e.storyOptionId!==t)})},[e,Ze,Ye?.generatedAt]),dt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await ii({pjcode:e,storyOptionId:t,newName:n});let r=Ze.map(e=>e.storyOptionId===t?{...e,storyName:n}:e);Le({generatedAt:Ye?.generatedAt,stories:r})},[e,Ze,Ye?.generatedAt]),ft=Ca(Se,F.comments,k===`prs`),pt=(0,y.useCallback)((e,t)=>{We({kind:{type:`ok_and_awaiting_workspace`},item:e,commit:()=>I.okAndMoveToAwaitingWorkspace(e,t),skipAdvance:!0,onAdvance:()=>{E.patchOverlay(qi(e),{done:!0,status:{name:t.name,color:t.color}},k)},revertAdvance:()=>{E.patchOverlay(qi(e),{done:!1},k)}})},[We,I,E,k]);return(0,x.jsxs)(`main`,{className:`console-app`,children:[L.pending!==null&&(0,x.jsx)(Gn,{message:L.pending.message,color:L.pending.color,remainingSeconds:L.pending.remainingSeconds,progress:L.pending.progress,onUndo:L.undo}),L.error!==null&&(0,x.jsx)(Kn,{title:L.error.message,message:`Operation failed: ${L.error.reason}`,onDismiss:L.dismissError}),(0,x.jsx)(Wn,{actions:ve,isOnline:le,isConfirming:he,onConfirm:_e,onDiscard:L.discardOfflineAction}),O.isOpen&&(0,x.jsx)(S,{value:O.inputValue,onChange:O.changeInput,isLoading:O.isLoading,isSaving:O.isSaving,error:O.error,onSave:O.save,onClose:O.close}),(0,x.jsx)(te,{activeTab:k,counts:ee,pjcode:e,pjcodes:v,generatedAt:Pe,fromCache:Fe,tabHref:re.tabHref,onSelectTab:re.selectTab,onSelectProject:e=>Xa(`/projects/${e}`),settingsButton:(0,x.jsxs)(x.Fragment,{children:[e!==null&&(0,x.jsx)(`button`,{type:`button`,className:`console-tab-settings-button`,"aria-label":`Open project settings`,onClick:O.open,children:`⚙`}),(0,x.jsx)(ne,{isOpen:u,timerMode:d,projectMinutes:f,pjcodes:v,isLoadingPjcodes:C,onOpen:p,onToggleTimerMode:g,onChangeMinutes:_,onSave:h,onClose:m})]}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff,workflowImprovementIssueUrl:b}),(0,x.jsx)(T,{timerEndsAt:ye?.timerEndsAt??null,timerTotalSeconds:ye?.timerTotalSeconds??null,now:se}),k===`stories`?(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(zn,{stories:Ze,isLoading:a,error:o,showGray:Ke,onCreateIssue:et,onAddStory:nt,onSelectColor:lt,onToggleGray:Je,onReorderStory:tt,onDeleteStory:ut,onRenameStory:dt,optimisticColors:rt,colorChangeInFlight:at,colorErrors:st})}):Re===null?k===`queued`?(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(we,{rows:Ae,storyColors:je,statusOptions:Me,agentOptions:Ne,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>re.openItem(e.projectItemId)})}):k===`prs`?(0,x.jsxs)(`div`,{className:`console-list-screen`,children:[(0,x.jsx)(xe,{agentOptions:Ne,agentCounts:Ee,selectedAgent:Ce,onAgentChange:Te}),(0,x.jsx)(be,{rows:Ae,storyColors:je,statusOptions:Me,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>re.openItem(e.projectItemId),executiveSummaries:ft,onOkAndAwaitingWorkspace:pt})]}):(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(be,{rows:Ae,storyColors:je,statusOptions:Me,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>re.openItem(e.projectItemId)})}):(0,x.jsx)(`div`,{className:`console-detail-screen`,ref:Ge,children:(0,x.jsx)(ud,{tab:k,item:Re,caches:F,operations:I,pjcode:e,statusOptions:Me,storyColors:je,storyName:He,overlayStatus:Ve,now:se,initialCommentDraft:oe.current.get(Re.projectItemId)??``,onCommentDraftChange:P,onQueueAction:We,onDeleteStory:$e===null?null:async()=>{await ut($e.storyOptionId),ae()},storyNameForDeletion:$e?.storyName??null},Re.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var md=document.getElementById(`root`);if(md===null)throw Error(`Root container #root not found`);(0,b.createRoot)(md).render((0,x.jsx)(y.StrictMode,{children:(0,x.jsx)(pd,{})}));
|
|
88
|
+
`)[0],Eu=({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:Tu(e.message)}),(0,x.jsx)(`span`,{className:`console-commit-sha`,children:wu(e.sha)}),(0,x.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,x.jsx)(`span`,{className:`console-commit-time`,children:pe(e.authoredAt,r)})]},e.sha))}):(0,x.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Du=({url:e,label:t=`Copy URL`})=>(0,x.jsx)(jn,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),Ou=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}))},ku=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,Au=({failures:e})=>e.length===0?null:(0,x.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:Ou(e).map(e=>(0,x.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,ku(e.sections),`:`,` `,e.message]},e.message))}),ju={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`}},Mu=({mergeableStatus:e})=>{let t=ju[e],n=ae(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})},Nu=e=>{let t=ae(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},Pu=({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:Nu(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:Nu(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},Fu=({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=oo(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)(Mu,{mergeableStatus:e.mergeableStatus}),(0,x.jsx)(Pu,{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)(Du,{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)(iu,{title:`Description`,children:n?(0,x.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,x.jsx)(ru,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,x.jsx)(iu,{title:`Changed files`,count:g,children:(0,x.jsx)(Su,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,x.jsx)(iu,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,x.jsx)(Eu,{commits:o,isLoading:s,error:c,now:l})})]})},Iu=({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:E,buildImageProxyUrl:D,renderReferenceLink:O,onAddInlineComment:ee})=>{let te=a?.state??`open`,ne=a?.merged??!1,re=!e.isPr&&te===`closed`?`Closed`:null,k=K(e.nameWithOwner)??void 0,ie=ae(n),A=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,j=A===null?null:ae(A.color),M=p||m!==null?null:f.length,N=u||d!==null?null:l.length,oe=g||_!==null?null:h.length,P=!u&&d===null&&l.length>0,F=e=>{let t=oo(e);return t===null?e:`PR #${t.number}`},I=[{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 ${F(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${F(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),L=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)(_e,{isPr:e.isPr,state:te,merged:ne,isDraft:!1,stateReason:``}),(0,x.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}),(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:[A!==null&&j!==null&&(0,x.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:j.fg,borderColor:j.border,backgroundColor:j.bg},children:A.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:ie.dot}}),t]}),e.isPr&&y?.found&&(0,x.jsx)(Pu,{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:F(e.pullRequest.url)}),(0,x.jsx)(Pu,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,x.jsx)(Mu,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),L.map(e=>(0,x.jsx)(Mu,{mergeableStatus:e.mergeableStatus},e.url)),re!==null&&(0,x.jsx)(`span`,{className:`console-detail-closed-label`,children:re})]}),(0,x.jsx)(Au,{failures:I}),(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:me(e.createdAt),children:[`opened `,pe(e.createdAt,w)]}),(0,x.jsx)(Du,{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)(iu,{title:`Description`,defaultCollapsed:P,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)(ru,{body:o,buildImageProxyUrl:D,renderReferenceLink:O,repoContext:k}):(0,x.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})},P?`desc-collapsed`:`desc-open`),e.isPr&&(0,x.jsx)(iu,{title:`Changed files`,count:M,children:(0,x.jsx)(Su,{files:f,isLoading:p,error:m,onAddInlineComment:ee})}),(0,x.jsx)(iu,{title:`Comments`,count:N,defaultCollapsed:e.isPr,children:(0,x.jsx)(Cu,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:D,renderReferenceLink:O,repoContext:k})}),e.isPr&&(0,x.jsx)(iu,{title:`Commits`,count:oe,defaultCollapsed:!0,children:(0,x.jsx)(Eu,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&S.map(e=>(0,x.jsx)(Fu,{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:D,renderReferenceLink:O,onAddInlineComment:ee},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:E})]})]})},Lu=({onClose:e})=>(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`})]}),Ru=({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()=>{if(t){c(!0),u(null);try{await t()}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? Open tasks assigned to this story will be closed.`]}),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(),disabled:s,children:s?`Deleting…`:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{o(!1),u(null)},disabled:s,children:`Cancel`})]})]})]})},zu=({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`})]}),Bu=[{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`}],Vu=`Reject needs an inline comment on the diff.`,Hu=({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:Vu}),Bu.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)})]}),Uu=({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})]})},Wu=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},Gu=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=ce.map(t=>({name:t,option:Wu(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=ae(r.color),a=e===L;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)})})},Ku=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,handlers:i,storyNameForDeletion:a})=>(0,x.jsxs)(`div`,{className:`console-operation-bar`,children:[t&&(0,x.jsx)(Hu,{onReview:i.onReview,rejectEnabled:n}),(0,x.jsx)(zu,{isManualTriage:le(e),onSetNextActionDate:i.onSetNextActionDate}),(0,x.jsx)(Gu,{statusOptions:r,onSetStatus:i.onSetStatus,onSetInTmuxByHuman:i.onSetInTmuxByHuman}),(0,x.jsxs)(`div`,{className:`console-op-group-bottom-row`,children:[(0,x.jsxs)(`div`,{className:`console-op-group-left-pair`,children:[(0,x.jsx)(Uu,{onSetDependedIssueUrl:i.onSetDependedIssueUrl}),(0,x.jsx)(Ru,{onDeleteAllComments:i.onDeleteAllComments,onDeleteStory:i.onDeleteStory,storyNameForDeletion:a})]}),(0,x.jsx)(Lu,{onClose:i.onClose})]})]}),qu=(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}},Ju=[],Yu=[],Xu=[],Zu=[],Qu={state:`open`,merged:!1,isPullRequest:!1,title:``},$u={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},ed=(e,t,n)=>{let r=t===null?null:`${t.repo}#${t.number}`,i=t===null?null:t.url,a=t?.isPr??!1,o=qu(e.body,r,i,``),s=qu(e.state,r,i,Qu),c=qu(e.comments,r,i,Ju),l=qu(e.files,a?r:null,a?i:null,Yu),u=qu(e.commits,a?r:null,a?i:null,Xu),d=qu(e.prStatus,a?r:null,a?i:null,$u),f=!a&&((t?.relatedOpenPullRequestUrls.length??0)>0||n===`prs`),p=qu(e.relatedPrs,f?r:null,f?i:null,Zu),[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:Yu,filesAreLoading:!0,filesError:null,commits:Xu,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}},td=e=>JSON.stringify([e.author,e.createdAt,e.body]),nd=(e,t)=>{let n=new Set(e.map(td));return[...e,...t.filter(e=>!n.has(td(e)))]},rd=({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=oo(e);return(0,x.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,x.jsx)(_e,{...so(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]})]})},id=(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},ad=({cache:e,href:t,fallbackText:n})=>{let r=id(e,t);return(0,x.jsx)(rd,{href:t,fallbackText:n,state:r})},od=e=>({itemUrl:e.url,projectItemId:e.projectItemId,itemNumber:e.number,repo:e.repo,isPr:e.isPr}),sd=(e,t,n,r,i)=>({...od(t),apiPath:ea,requestBody:ra(e,t,n,r,i)}),cd=(e,t,n,r)=>({...od(t),apiPath:ta,requestBody:ia(e,t,n,r)}),ld=(e,t)=>({...od(t),apiPath:na,requestBody:aa(e,t)}),ud=({tab:e,item:t,caches:n,operations:r,pjcode:i,statusOptions:a,storyColors:o,storyName:s,overlayStatus:c,now:l,initialCommentDraft:u,onCommentDraftChange:d,onQueueAction:f,onDeleteStory:p,storyNameForDeletion:m})=>{let h=ed(n,t,e),g=(0,y.useCallback)(e=>uo(e,t.url),[t.url]),_=(0,y.useCallback)((e,t)=>(0,x.jsx)(ad,{cache:n.state,href:e,fallbackText:t}),[n.state]),v=t.isPr||t.relatedOpenPullRequestUrls.length>0||h.relatedPullRequests.length>0,[b,S]=(0,y.useState)([]),C=(0,y.useCallback)(async(e,t,n,r)=>{S(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[w,T]=(0,y.useState)([]),E=(0,y.useCallback)(async e=>{let n=await r.addComment(t,e);return T(e=>[...e,n]),n},[t,r]),D={onReview:e=>{let n=t.isPr?t.url:h.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,a=e===`request_changes`?b:[];f({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,a),offline:i==null?void 0:sd(i,t,n,e,a)})},onSetNextActionDate:e=>{f({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e),offline:i==null?void 0:cd(i,t,e)})},onSetStory:e=>{f({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e),offline:i==null?void 0:cd(i,t,`set_story`,{storyOptionId:e.id})})},onSetStatus:e=>{f({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e),offline:i==null?void 0:cd(i,t,`set_status`,{statusName:e.name})})},onSetInTmuxByHuman:e=>{f({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=>{f({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e),offline:i==null?void 0:cd(i,t,e)})},onOkAndAwaitingWorkspace:e=>{f({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e)})},onDeleteAllComments:()=>{f({kind:{type:`delete_all_comments`},item:t,commit:()=>r.deleteAllComments(t)})},onDeleteStory:p??null,onSetDependedIssueUrl:i==null?null:async e=>{await r.setDependedIssueUrl(t,e)}},O=a.find(e=>e.name===`Awaiting Workspace`)??null,ee=O===null?void 0:async e=>(d?.(``),D.onSetStatus(O),E(e)),te=s??(t.story.trim()===``?null:t.story),ne=te===null?null:k(o,te);return(0,x.jsx)(Iu,{item:t,storyName:te,storyColorEnum:ne,overlayStatus:c,statusOptions:a,state:h.state,stateError:h.stateError,body:h.body,bodyIsLoading:h.bodyIsLoading,bodyError:h.bodyError,comments:nd(h.comments,w),commentsAreLoading:h.commentsAreLoading,commentsError:h.commentsError,files:h.files,filesAreLoading:h.filesAreLoading,filesError:h.filesError,commits:h.commits,commitsAreLoading:h.commitsAreLoading,commitsError:h.commitsError,pullRequestStatus:h.pullRequestStatus,pullRequestStatusError:h.pullRequestStatusError,relatedPullRequests:h.relatedPullRequests,relatedPullRequestsError:h.relatedPullRequestsError,now:l,buildImageProxyUrl:g,renderReferenceLink:_,onAddInlineComment:C,commentComposer:(0,x.jsx)(io,{initiallyOpen:!0,initialDraft:u,onSubmit:E,onDraftChange:d,onOkAndAwaitingWorkspace:O===null?void 0:()=>D.onOkAndAwaitingWorkspace(O),onSubmitAndMoveToAwaitingWorkspace:ee,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,x.jsx)(Ku,{tab:e,item:t,hasPullRequest:v,rejectEnabled:b.length>0,statusOptions:a,handlers:D,storyNameForDeletion:m})})},dd=()=>{let e={};for(let t of D)e[t.name]=0;return e},fd=`console`,pd=()=>{let e=pa(),t=Ri(),n=vr(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o,refreshSingleTab:s}=Ha(e,r),{timerMode:c,projectMinutes:l,isOpen:u,draftTimerMode:d,draftProjectMinutes:f,openSettings:p,closeSettings:m,saveSettings:h,toggleDraftTimerMode:g,changeDraftMinutes:_}=Ja(),{pjcodes:v,workflowImprovementIssueUrl:b,isLoading:C}=ma(),{isTimerExpired:w}=_a(e),E=da(e??fd),O=ga(e),ee=(0,y.useMemo)(()=>{let e=dd();for(let t of D){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=Yi(n.items,Zi(E.overlay,n.generatedAt),t.name))}return e},[i,E.overlay]),re=Gi(e,ee),{activeTab:k,selectedItemKey:A,openItem:M,closeItem:ae,selectTab:N}=re,oe=(0,y.useRef)(new Map),P=(0,y.useCallback)(e=>{A!==null&&(e?oe.current.set(A,e):oe.current.delete(A))},[A]),F=Ai(r),I=sa(e,k,E,F,(0,y.useCallback)(()=>s(`queued`),[s])),L=Oi(),[se,ce]=(0,y.useState)(()=>Date.now());(0,y.useEffect)(()=>{let e=setInterval(()=>{ce(Date.now())},1e3);return()=>{clearInterval(e)}},[]);let[le,ue]=(0,y.useState)(()=>navigator.onLine);(0,y.useEffect)(()=>{let e=()=>ue(!0),t=()=>ue(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)}},[]);let[R,de]=(0,y.useState)(new Map),[z,fe]=(0,y.useState)(new Map),[pe,me]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{if(!(!le||L.offlineActions.length===0))for(let e of L.offlineActions)R.has(e.id)||pe.has(e.id)||(de(t=>new Map(t).set(e.id,null)),F.client.fetchIssueState(e.itemUrl).then(t=>{de(n=>new Map(n).set(e.id,t)),e.isPr&&(fe(t=>new Map(t).set(e.id,null)),F.client.fetchPullRequestStatus(e.itemUrl).then(t=>{fe(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),me(t=>new Set(t).add(e.id))}))},[le,L.offlineActions,F.client,R,pe]);let[he,ge]=(0,y.useState)(!1),_e=(0,y.useCallback)(async e=>{ge(!0);try{await L.confirmOfflineAction(e)}finally{ge(!1)}},[L]),ve=(0,y.useMemo)(()=>L.offlineActions.map(e=>{let t=R.get(e.id)??null,n=z.get(e.id)??null,r=pe.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}}),[L.offlineActions,R,z,pe]),ye=i[k],Se=(0,y.useMemo)(()=>ye===null?[]:Xi(ye.items,Zi(E.overlay,ye.generatedAt),k),[ye,E.overlay,k]),[Ce,Te]=(0,y.useState)(null),Ee=(0,y.useMemo)(()=>{if(k!==`prs`)return{};let e={};for(let t of Se)t.agent!==null&&t.agent!==``&&(e[t.agent]=(e[t.agent]??0)+1);return e},[Se,k]);(0,y.useEffect)(()=>{k===`prs`&&Ce!==null&&(Ee[Ce]??0)===0&&Te(null)},[Ee,Ce,k]);let De=(0,y.useMemo)(()=>k!==`prs`||Ce===null?Se:Se.filter(e=>e.agent===Ce),[Se,k,Ce]),Oe=(0,y.useMemo)(()=>De.map(e=>qi(e)),[De]),ke=ye?.storyOrder??[],Ae=(0,y.useMemo)(()=>j(De,E.overlay,ke,ye?.generatedAt??null),[De,E.overlay,ke,ye]),je=ye?.storyColors??{},Me=ye?.statusOptions??[],Ne=ye?.agentOptions??[],Pe=ye?.generatedAt??null,Fe=ye?.fromCache??!1,[Ie,Le]=(0,y.useState)(null),Re=(0,y.useMemo)(()=>A===null||ye===null?null:ye.items.find(e=>e.projectItemId===A)??null,[A,ye]);Ii(F,Re,Se),(0,y.useEffect)(()=>{A!==null&&window.scrollTo({top:0})},[A]),(0,y.useEffect)(()=>{if(e===null&&c&&v.length>0){let e=qa(v,null,l);e!==null&&Ya(`/projects/${e}`)}},[e,c,v,l]);let ze=ee[k],Be=(0,y.useRef)({tab:k,count:ze});(0,y.useEffect)(()=>{let e=Be.current;if(Be.current={tab:k,count:ze},e.tab===k&&e.count>0&&ze===0){let e=zi(k,ee);e!==null&&(N(e),ae())}},[k,ze,ee,N,ae]);let Ve=Re===null?null:Qi(E.overlay,Re,i[k]?.generatedAt??null),He=Re===null?null:ie(Re,E.overlay,i[k]?.generatedAt??null),Ue=(0,y.useCallback)(e=>{let t=Za(Oe,e);t===null?ae():M(t)},[Oe,M,ae]),We=(0,y.useCallback)(t=>{if(n.status===`on`){L.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=qi(t.item);L.enqueue({message:_i(t.kind,t.item,k),color:hi(t.kind),commit:t.commit,offline:t.offline,revertAdvance:t.revertAdvance,advance:()=>{if(t.onAdvance?.(),!t.skipAdvance&&gi(t.kind,k)){if(c&&w(l[e??``]??0)){let t=qa(v,e,l);t!==null&&Xa(`/projects/${t}`)}else Ue(r)}}})},[L,k,Ue,n.status,c,w,l,e,v]),Ge=Da((0,y.useCallback)(e=>{if(A===null||e===null)return;let t=e===`next`?Qa(Oe,A):$a(Oe,A);t!==null&&M(t)},[A,Oe,M])),[Ke,qe]=(0,y.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),Je=(0,y.useCallback)(()=>{qe(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),Ye=i.stories,Xe=Ye?.stories??[],Ze=Ie!==null&&Ie.generatedAt===Ye?.generatedAt?Ie.stories:Xe,Qe=Ye?.defaultNameWithOwner??null,$e=(0,y.useMemo)(()=>Re===null||!Re.labels.includes(`story`)?null:Ze.find(e=>e.storyName===Re.story)??null,[Re,Ze]),et=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(Qe===null)throw Error(`No repository configured for this project.`);await Xr({pjcode:e,title:n,storyOptionId:t,nameWithOwner:Qe})},[e,Qe]),tt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Qr({pjcode:e,storyOptionId:t,direction:n});let r=Ze.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<Ze.length){let t=[...Ze],n=t[r];t[r]=t[e],t[e]=n,Le({generatedAt:Ye?.generatedAt,stories:t})}}},[e,Ze,Ye?.generatedAt]),nt=(0,y.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Wr({pjcode:e,storyName:t})},[e]),[rt,it]=(0,y.useState)({}),[at,ot]=(0,y.useState)(null),[st,ct]=(0,y.useState)({}),lt=(0,y.useCallback)((t,n)=>{let r=Ze.find(e=>e.storyOptionId===t)?.color;if(ot(t),it(e=>({...e,[t]:n})),ct(e=>{let n={...e};return delete n[t],n}),e===null||Qe===null){it(e=>r===void 0?e:{...e,[t]:r}),ct(e=>({...e,[t]:`No project or repository configured.`})),ot(e=>e===t?null:e);return}Yr({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:Qe}).catch(e=>{it(e=>r===void 0?e:{...e,[t]:r}),ct(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{ot(e=>e===t?null:e)})},[e,Qe,Ze]),ut=(0,y.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await ni({pjcode:e,storyOptionId:t}),Le({generatedAt:Ye?.generatedAt,stories:Ze.filter(e=>e.storyOptionId!==t)})},[e,Ze,Ye?.generatedAt]),dt=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await ii({pjcode:e,storyOptionId:t,newName:n});let r=Ze.map(e=>e.storyOptionId===t?{...e,storyName:n}:e);Le({generatedAt:Ye?.generatedAt,stories:r})},[e,Ze,Ye?.generatedAt]),ft=Ca(Se,F.comments,k===`prs`),pt=(0,y.useCallback)((e,t)=>{We({kind:{type:`ok_and_awaiting_workspace`},item:e,commit:()=>I.okAndMoveToAwaitingWorkspace(e,t),skipAdvance:!0,onAdvance:()=>{E.patchOverlay(qi(e),{done:!0,status:{name:t.name,color:t.color}},k)},revertAdvance:()=>{E.patchOverlay(qi(e),{done:!1},k)}})},[We,I,E,k]);return(0,x.jsxs)(`main`,{className:`console-app`,children:[L.pending!==null&&(0,x.jsx)(Gn,{message:L.pending.message,color:L.pending.color,remainingSeconds:L.pending.remainingSeconds,progress:L.pending.progress,onUndo:L.undo}),L.error!==null&&(0,x.jsx)(Kn,{title:L.error.message,message:`Operation failed: ${L.error.reason}`,onDismiss:L.dismissError}),(0,x.jsx)(Wn,{actions:ve,isOnline:le,isConfirming:he,onConfirm:_e,onDiscard:L.discardOfflineAction}),O.isOpen&&(0,x.jsx)(S,{value:O.inputValue,onChange:O.changeInput,isLoading:O.isLoading,isSaving:O.isSaving,error:O.error,onSave:O.save,onClose:O.close}),(0,x.jsx)(te,{activeTab:k,counts:ee,pjcode:e,pjcodes:v,generatedAt:Pe,fromCache:Fe,tabHref:re.tabHref,onSelectTab:re.selectTab,onSelectProject:e=>Xa(`/projects/${e}`),settingsButton:(0,x.jsxs)(x.Fragment,{children:[e!==null&&(0,x.jsx)(`button`,{type:`button`,className:`console-tab-settings-button`,"aria-label":`Open project settings`,onClick:O.open,children:`⚙`}),(0,x.jsx)(ne,{isOpen:u,timerMode:d,projectMinutes:f,pjcodes:v,isLoadingPjcodes:C,onOpen:p,onToggleTimerMode:g,onChangeMinutes:_,onSave:h,onClose:m})]}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff,workflowImprovementIssueUrl:b}),(0,x.jsx)(T,{timerEndsAt:ye?.timerEndsAt??null,timerTotalSeconds:ye?.timerTotalSeconds??null,now:se}),k===`stories`?(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(zn,{stories:Ze,isLoading:a,error:o,showGray:Ke,onCreateIssue:et,onAddStory:nt,onSelectColor:lt,onToggleGray:Je,onReorderStory:tt,onDeleteStory:ut,onRenameStory:dt,optimisticColors:rt,colorChangeInFlight:at,colorErrors:st})}):Re===null?k===`queued`?(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(we,{rows:Ae,storyColors:je,statusOptions:Me,agentOptions:Ne,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>re.openItem(e.projectItemId)})}):k===`prs`?(0,x.jsxs)(`div`,{className:`console-list-screen`,children:[(0,x.jsx)(xe,{agentOptions:Ne,agentCounts:Ee,selectedAgent:Ce,onAgentChange:Te}),(0,x.jsx)(be,{rows:Ae,storyColors:je,statusOptions:Me,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>re.openItem(e.projectItemId),executiveSummaries:ft,onOkAndAwaitingWorkspace:pt})]}):(0,x.jsx)(`div`,{className:`console-list-screen`,children:(0,x.jsx)(be,{rows:Ae,storyColors:je,statusOptions:Me,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>re.openItem(e.projectItemId)})}):(0,x.jsx)(`div`,{className:`console-detail-screen`,ref:Ge,children:(0,x.jsx)(ud,{tab:k,item:Re,caches:F,operations:I,pjcode:e,statusOptions:Me,storyColors:je,storyName:He,overlayStatus:Ve,now:se,initialCommentDraft:oe.current.get(Re.projectItemId)??``,onCommentDraftChange:P,onQueueAction:We,onDeleteStory:$e===null?null:async()=>{await ut($e.storyOptionId),ae()},storyNameForDeletion:$e?.storyName??null},Re.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var md=document.getElementById(`root`);if(md===null)throw Error(`Root container #root not found`);(0,b.createRoot)(md).render((0,x.jsx)(y.StrictMode,{children:(0,x.jsx)(pd,{})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>TDPM Console</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-CSabdYt0.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-xecnDL1W.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -45,6 +45,7 @@ const consoleImageProxy_1 = require("./consoleImageProxy");
|
|
|
45
45
|
const consoleGithubTokenResolver_1 = require("./consoleGithubTokenResolver");
|
|
46
46
|
const dashboardComposeService_1 = require("./dashboardComposeService");
|
|
47
47
|
const OwnerCallFile_1 = require("../../../domain/usecases/intmux/OwnerCallFile");
|
|
48
|
+
const FileSystemConsoleTabsRepository_1 = require("../handlers/FileSystemConsoleTabsRepository");
|
|
48
49
|
exports.DEFAULT_WEB_PORT = 9980;
|
|
49
50
|
exports.CONSOLE_TOKEN_HEADER = 'x-pv-token';
|
|
50
51
|
exports.CONSOLE_TOKEN_COOKIE = 'pv_token';
|
|
@@ -447,15 +448,21 @@ const handleOperationApi = async (options, requestPath, body) => {
|
|
|
447
448
|
return null;
|
|
448
449
|
}
|
|
449
450
|
const resolveIssueRepository = options.resolveIssueRepository ?? (() => issueRepository);
|
|
451
|
+
const consoleDataOutputDir = options.consoleDataOutputDir;
|
|
450
452
|
const context = {
|
|
451
453
|
resolveIssueRepository,
|
|
452
454
|
resolveProject,
|
|
453
455
|
isPjcodeConfigured,
|
|
454
|
-
consoleDataOutputDir
|
|
456
|
+
consoleDataOutputDir,
|
|
455
457
|
issueAttachmentRepository: options.issueAttachmentRepository ?? null,
|
|
456
458
|
resolveProjectRepository: options.resolveProjectRepository ?? null,
|
|
457
459
|
invalidateProject: options.invalidateProject ?? null,
|
|
458
460
|
updateProjectCacheEntry: options.updateProjectCacheEntry ?? null,
|
|
461
|
+
patchItemIntoQueuedTab: consoleDataOutputDir !== null
|
|
462
|
+
? (pjcode, projectItemId, canonicalStatusName) => {
|
|
463
|
+
new FileSystemConsoleTabsRepository_1.FileSystemConsoleTabsRepository(consoleDataOutputDir, pjcode).moveItemToQueuedTab(projectItemId, canonicalStatusName);
|
|
464
|
+
}
|
|
465
|
+
: null,
|
|
459
466
|
};
|
|
460
467
|
const githubToken = options.resolveGithubToken != null ? options.resolveGithubToken('') : null;
|
|
461
468
|
const dispatched = dispatchOperation(context, githubToken, requestPath, body);
|
|
@@ -620,6 +627,7 @@ const resolveDashboardContent = (options, requestPath) => {
|
|
|
620
627
|
const dashboardText = (0, dashboardComposeService_1.composeDashboardText)({
|
|
621
628
|
dashboardDataDir: options.dashboardDataDir,
|
|
622
629
|
projectNames: options.dashboardProjectNames,
|
|
630
|
+
consoleDataOutputDir: options.consoleDataOutputDir,
|
|
623
631
|
});
|
|
624
632
|
return Buffer.from(dashboardText, 'utf-8');
|
|
625
633
|
}
|