@staff0rd/assist 0.1120.0 → 0.1120.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +105 -14
- package/package.json +1 -1
package/dist/built-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1120.
|
|
1
|
+
0.1120.1
|
|
@@ -4002,7 +4002,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4002
4002
|
`)){let n=t[t.length-1];r.startsWith("@@")||n===void 0?t.push(r):t[t.length-1]=`${n}
|
|
4003
4003
|
${r}`}return t}function aOr(e){return iOr(e??"").filter(t=>t.startsWith("@@"))}function mLo(e){return Number(/^@@ -(\d+)/.exec(e)?.[1]??1)}function gLo(e){return/^@@[^@]*@@/.exec(e)?.[0]??e.split(`
|
|
4004
4004
|
`)[0]??""}function sOr(e,t){return e.reduce((r,n)=>r+oOr(n,t),0)}function lOr(e,t,r){let n=aOr(e.patch),o=[],i=[];return n.forEach((a,s)=>{let l=r.get(`${e.path}#${s}`)??[];l.includes(t)?o.push(a):i.push({oldStart:mLo(a),header:gLo(a),slice:l[0]??0})}),o.length===0||i.length===0?e:{...e,patch:o.join(`
|
|
4005
|
-
`),additions:sOr(o,"+"),deletions:sOr(o,"-"),split:{hunks:o.length,of:n.length,elsewhere:i}}}function cOr(e){return e.flatMap(t=>{if(t.kind==="dir")return cOr(t.children);let{kind:r,name:n,...o}=t;return[o]})}function yLo(e){let t=new Map;return e.forEach((r,n)=>{for(let o of r.hunks)t.set(o,[...t.get(o)??[],n+1])}),t}function uOr(e,t,r=new Set,n=new Set){let o=cOr(e.tree).filter(a=>!r.has(a.path)).map(a=>n.has(a.path)?{...a,critical:!0}:a),i=yLo(t);return t.map((a,s)=>{let l=new Set(a.hunks.map(EG));return nOr(o.filter(u=>l.has(u.path)).map(u=>lOr(u,s+1,i)))})}function vLo(e,t){let r=-1,n=0;return t.forEach((o,i)=>{let a=o.hunks.filter(s=>EG(s)===e).length;a>n&&(r=i,n=a)}),r}function dOr(e,t){let r=t.map(()=>[]);for(let n of e)r[vLo(n.path,t)]?.push(n);return r}function fOr(e,t){let r=uOr(e.structure,t,new Set(e.tests.map(i=>i.path)),new Set(e.criticalDiffs.map(i=>i.path))),n=dOr(e.tests,t),o=OEe(t);return t.map((i,a)=>{let s=a+1;return{number:s,slice:i,structure:r[a]??e.structure,tests:n[a]??[],critical:e.criticalDiffs.filter(l=>o.get(l.path)?.some(u=>u.number===s))}})}function pOr(e){if(!e.slices)return;let t=fOr(e,e.slices);return{entries:K8r(e,t),slicing:{count:t.length,noCritical:new Set(t.filter(r=>r.critical.length===0).map(r=>r.number))}}}function hOr(e){if(!(!e.repo||!e.headSha))return`${e.repo}#${e.prNumber}@${e.headSha}`}var Nct="assist:high-level-progress:",bLo=`${Nct}head:`,xLo=720*60*60*1e3,Yoe=e=>`${Nct}${e}`,Oct=e=>`${bLo}${e}`,Mct=e=>sl(e)[0];function SLo(e,t){let r=e?Mct(Yoe(e)):void 0;return e&&wv(Yoe(e)),r??(t?Mct(Oct(t)):void 0)}function mOr(e,t,r){return bx(Nct,xLo),Mct(Yoe(e))??SLo(t,r)}function gOr(e,t,r){Rl(Yoe(e),[r]),t&&Rl(Oct(t),[r])}function yOr(e,t){wv(Yoe(e)),t&&wv(Oct(t))}function vOr(e){let t=e;return typeof t?.id=="string"&&typeof t.title=="string"&&typeof t.reason=="string"&&(t.kind==="deterministic"||t.kind==="manual")&&["pass","fail","manual"].includes(t.status)}function OD(e,t){return Array.isArray(e)?t?e.filter(t):e:[]}var OG={repo:"",prNumber:0,headSha:"",checks:[],structure:{tree:[],added:0,removed:0,modified:0,additions:0,deletions:0},criticalDiffs:[],criticalPaths:[],tests:[],testPaths:[],collapsedPaths:[]};function bOr(e){let t;try{t=JSON.parse(e)}catch{return OG}return typeof t!="object"||t===null?OG:{repo:typeof t.repo=="string"?t.repo:OG.repo,prNumber:typeof t.prNumber=="number"?t.prNumber:OG.prNumber,headSha:typeof t.headSha=="string"?t.headSha:OG.headSha,checks:OD(t.checks,vOr),structure:{...OG.structure,...t.structure},criticalDiffs:OD(t.criticalDiffs),criticalPaths:OD(t.criticalPaths),tests:OD(t.tests),testPaths:OD(t.testPaths),collapsedPaths:OD(t.collapsedPaths),...Array.isArray(t.slices)?{slices:t.slices}:{},...t.manualTesting?{manualTesting:t.manualTesting}:{},...t.saved?{saved:t.saved}:{},...t.draft?{draft:t.draft}:{}}}function xOr(e){let t=(0,n4e.useMemo)(()=>bOr(e.body),[e.body]),r=(0,n4e.useMemo)(()=>pOr(t),[t]),n=hOr(t),o=(0,n4e.useMemo)(()=>mOr(e.requestId,e.supersedes,n)??t.draft??t.saved,[e.requestId,e.supersedes,n,t]);return{payload:t,sliced:r,progress:o,head:n}}var SOr=S(ie(),1);function TOr(e){let[t,r]=(0,SOr.useState)(()=>e?.reviewComments??[]);return{queued:t,onQueue:n=>r(o=>[...o,n]),onRemove:n=>r(o=>o.filter((i,a)=>a!==n))}}var wOr=S(ie(),1);function COr(e,t,r,n){(0,wOr.useEffect)(()=>{gOr(e,t,{items:r,reviewComments:n})},[e,t,r,n])}function _Or(e,t,r){let{payload:n,sliced:o,progress:i,head:a}=xOr(e),s=Y8r(n.checks,i,o?.slicing),l=TOr(i),u=$8r(o?.entries??[]),{comments:d,sentTo:f,clearSent:p}=yEe(t,r),h={...d,onQueue:l.onQueue};COr(e.requestId,a,s.items,l.queued);let m=(0,kOr.useMemo)(()=>V8r(n),[n]);return{payload:n,checklist:s,queue:l,details:U8r(n,h),counts:m,sentTo:f,clearSent:p,sliced:o,nav:u,diffComments:h,head:a}}var Ux=S(R(),1);function EOr({preview:e,session:t,sendInput:r,onDecision:n}){let o=_Or(e,t,r);return(0,Ux.jsxs)(W,{sx:L0,children:[(0,Ux.jsx)(yh,{preview:e,draft:!1}),(0,Ux.jsx)(MG,{items:e.metadata??[]}),(0,Ux.jsx)(Kn,{}),(0,Ux.jsx)(E8r,{payload:o.payload,checklist:o.checklist,details:o.details,counts:o.counts,sliced:o.sliced,nav:o.nav,comments:o.diffComments}),(0,Ux.jsx)(Kn,{}),(0,Ux.jsx)(O8r,{pane:o,onDecision:(i,a)=>{yOr(e.requestId,o.head),n(i,a)}}),(0,Ux.jsx)(_0,{sessionName:o.sentTo,onClose:o.clearSent})]})}var NOr=S(ie(),1);var BD=S(R(),1);function TLo(e){return e.topLeft===null?"Click the top-left box":e.bottomRight===null?"Now click the bottom-right box":"Both anchors picked"}function ROr({selection:e,onConfirm:t,onReject:r}){let n=e.topLeft!==null&&e.bottomRight!==null;return(0,BD.jsxs)(kt,{direction:"row",spacing:1,sx:{p:2,alignItems:"center",justifyContent:"flex-end"},children:[(0,BD.jsx)(Te,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:TLo(e)}),(0,BD.jsx)(it,{color:"error",variant:"outlined",onClick:r,children:"Cancel"}),(0,BD.jsx)(it,{variant:"outlined",onClick:e.reset,children:"Start over"}),(0,BD.jsx)(it,{color:"success",variant:"contained",disabled:!n,onClick:t,children:"Extract boxes"})]})}var wLo={"top-left":Jl.miro.topLeft,"bottom-right":Jl.miro.bottomRight};function POr(e,t){let r=e.right-e.left,n=e.bottom-e.top;return{width:r,height:n,fontSize:Math.max(6,Math.min(n*.3,r/6,28)),radius:Math.min(8,n/4),colour:t?wLo[t]:Jl.miro.box,opacity:t?.75:.35,strokeWidth:Math.max(1,r*.004)}}var Koe=S(R(),1);function AOr({box:e,role:t,onSelect:r}){let n=POr(e,t);return(0,Koe.jsxs)("g",{role:"button",tabIndex:0,"aria-label":t?`${e.text} (${t})`:e.text,onClick:()=>r(e.id),onKeyDown:o=>{o.key==="Enter"&&r(e.id)},style:{cursor:"pointer"},children:[(0,Koe.jsx)("rect",{x:e.left,y:e.top,width:n.width,height:n.height,rx:n.radius,fill:n.colour,fillOpacity:n.opacity,stroke:n.colour,strokeWidth:n.strokeWidth}),(0,Koe.jsx)("text",{x:e.left+n.width/2,y:e.top+n.height/2,textAnchor:"middle",dominantBaseline:"central",fontSize:n.fontSize,fill:Jl.miro.text,children:e.text})]})}function LOr(e){if(e.length===0)return"0 0 100 100";let t=Math.min(...e.map(a=>a.left)),r=Math.min(...e.map(a=>a.top)),n=Math.max(...e.map(a=>a.right))-t,o=Math.max(...e.map(a=>a.bottom))-r,i=Math.max(n*.02,8);return`${t-i} ${r-i} ${n+i*2} ${o+i*2}`}var o4e=S(R(),1);function IOr({boxes:e,selection:t}){return(0,o4e.jsx)(W,{sx:{flex:1,minHeight:0,overflow:"auto",p:2},children:(0,o4e.jsx)("svg",{role:"img","aria-label":"Miro board boxes",viewBox:LOr(e),preserveAspectRatio:"xMidYMid meet",style:{width:"100%",height:"100%"},children:e.map(r=>(0,o4e.jsx)(AOr,{box:r,role:t.roleOf(r.id),onSelect:t.choose},r.id))})})}function CLo(e){return typeof e?.id=="string"&&typeof e.text=="string"&&[e.left,e.top,e.right,e.bottom].every(t=>typeof t=="number"&&Number.isFinite(t))}function DOr(e){try{let t=JSON.parse(e);return Array.isArray(t?.boxes)?t.boxes.filter(CLo):[]}catch{return[]}}var Bct=S(ie(),1);function MOr(){let[e,t]=(0,Bct.useState)(null),[r,n]=(0,Bct.useState)(null);return{topLeft:e,bottomRight:r,choose:s=>{if(e===null||r!==null){t(s),n(null);return}n(s)},reset:()=>{t(null),n(null)},roleOf:s=>s===e?"top-left":s===r?"bottom-right":null}}var kR=S(R(),1);function OOr({preview:e,onDecision:t}){let r=(0,NOr.useMemo)(()=>DOr(e.body),[e.body]),n=MOr();return(0,kR.jsxs)(W,{sx:L0,children:[(0,kR.jsx)(yh,{preview:e,draft:!1}),(0,kR.jsx)(Kn,{}),(0,kR.jsx)(IOr,{boxes:r,selection:n}),(0,kR.jsx)(Kn,{}),(0,kR.jsx)(ROr,{selection:n,onConfirm:()=>{let{topLeft:i,bottomRight:a}=n;i===null||a===null||t("approve",Mc({topLeft:i,bottomRight:a}))},onReject:()=>t("reject",Mc())})]})}var pBr=S(ie(),1);function BOr(e){let t=[];return e.map(r=>(t.length=r+1,t[r]=(t[r]??0)+1,t.map(n=>n??1).join(".")))}function i4e(e){return e*22}function $Or(e){return Math.round(e/22)}var FOr={display:"flex",alignItems:"flex-start",gap:.25,"& .criterion-action":{opacity:0,transition:"opacity 120ms"},"&:hover .criterion-action":{opacity:1},"&:focus-within .criterion-action":{opacity:1},"& .criterion-action:focus-visible":{opacity:1}},zOr={p:.25,mt:"2px",color:"text.disabled",cursor:"grab",touchAction:"none","&:active":{cursor:"grabbing"}},HOr={fontFamily:"fontFamilyMono",fontSize:"0.8rem",color:"text.secondary",minWidth:32,pt:"5px",textAlign:"right",userSelect:"none",whiteSpace:"nowrap"},UOr={flex:1,fontSize:"inherit",lineHeight:1.5,px:.75,py:0,borderRadius:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-focused":{bgcolor:"action.selected"}},$ct={p:.25,mt:"2px"},VOr={position:"absolute",right:8,height:2,borderRadius:1,bgcolor:"primary.main",pointerEvents:"none"};var GOr=S(R(),1),kLo=8;function WOr({drag:e}){return e?(0,GOr.jsx)(W,{sx:VOr,style:{top:e.top-1,left:kLo+i4e(e.depth)}}):null}var qOr=S(R(),1),jOr=ot((0,qOr.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");var Fct=S(R(),1);function YOr({number:e,onGrip:t}){return(0,Fct.jsx)(Kt,{size:"small",className:"criterion-action",sx:zOr,"aria-label":`Reorder criterion ${e}`,onPointerDown:t,children:(0,Fct.jsx)(jOr,{fontSize:"inherit"})})}var fC=S(R(),1);function KOr({number:e,onAdd:t,onDelete:r}){return(0,fC.jsxs)(fC.Fragment,{children:[(0,fC.jsx)(Kt,{size:"small",className:"criterion-action",sx:$ct,"aria-label":`Add criterion after ${e}`,onClick:t,children:(0,fC.jsx)(Np,{fontSize:"inherit"})}),(0,fC.jsx)(Kt,{size:"small",className:"criterion-action",sx:$ct,"aria-label":`Delete criterion ${e}`,onClick:r,children:(0,fC.jsx)(Bo,{fontSize:"inherit"})})]})}var a4e=S(ie(),1);function XOr(e,t){return e==="start"?0:e==="end"?t:Math.min(Math.max(e,0),t)}function ZOr(e){let t=(0,a4e.useRef)(null);return(0,a4e.useEffect)(()=>{let r=t.current;if(!e||!r)return;r.focus();let n=XOr(e.caret,r.value.length);r.setSelectionRange(n,n)},[e]),t}var $D=S(R(),1);function QOr({index:e,number:t,item:r,outline:n,dragging:o,onGrip:i}){let a=ZOr(n.focus?.index===e?n.focus:null),s={marginLeft:i4e(r.depth),opacity:o?.4:1};return(0,$D.jsxs)(W,{sx:FOr,"data-criterion-row":!0,style:s,children:[(0,$D.jsx)(YOr,{number:t,onGrip:i}),(0,$D.jsx)(W,{component:"span",sx:HOr,"aria-hidden":"true",children:`${t}.`}),(0,$D.jsx)(na,{multiline:!0,value:r.text,sx:UOr,inputRef:a,inputProps:{"aria-label":`Criterion ${t}`},onChange:l=>n.onText(e,l.target.value),onKeyDown:l=>n.onKeyDown(e,l)}),(0,$D.jsx)(KOr,{number:t,onAdd:()=>n.onAdd(e),onDelete:()=>n.onDelete(e)})]})}var iBr=S(ie(),1);function JOr(e,t,{key:r,shift:n,alt:o,caret:i,text:a}){return o||n?null:r==="ArrowUp"&&i===0&&t>0?{kind:"focus",index:t-1}:r==="ArrowDown"&&i===a.length&&t<e.length-1?{kind:"focus",index:t+1}:null}function _R(e){if(e.length===0)return[{text:"",depth:0}];let t=-1;return e.map(r=>{let n=Math.min(Math.max(r.depth,0),t+1);return t=n,r.depth===n?r:{...r,depth:n}})}function s4e(e,t,r,n){let o=e[t]?.depth??0,i=e.map((a,s)=>s===t?{...a,text:r}:a);return{items:_R([...i.slice(0,t+1),{text:n,depth:o},...i.slice(t+1)]),index:t+1}}function Vm(e,t){let r=t+1;for(;r<e.length&&e[r].depth>e[t].depth;)r+=1;return r}function l4e(e,t){let r=e[t].depth;for(let n=t-1;n>=0;n-=1){if(e[n].depth<r)return-1;if(e[n].depth===r)return n}return-1}function eBr(e,t){let r=Vm(e,t);return r<e.length&&e[r].depth===e[t].depth?r:-1}function tBr(e,t,r){let n=r<0?l4e(e,t):eBr(e,t);if(n<0)return null;let o=Vm(e,t),i=e.slice(t,o),a=[...e.slice(0,t),...e.slice(o)],s=r<0?n:Vm(e,n)-(o-t);return{items:[...a.slice(0,s),...i,...a.slice(s)],index:s}}function c4e(e,t){let r=Vm(e,t),n=e.map((o,i)=>i>t&&i<r?{...o,depth:o.depth-1}:o).filter((o,i)=>i!==t);return{items:_R(n),index:Math.max(0,t-1)}}function rBr(e,t,r){if(r<0&&e[t].depth===0||r>0&&l4e(e,t)<0)return null;let n=Vm(e,t);return e.map((o,i)=>i>=t&&i<n?{...o,depth:o.depth+r}:o)}function u4e(e,t){return e?{kind:"edit",edit:e,caret:t}:null}function _Lo(e,t,{caret:r,text:n}){let o=n.slice(0,r);return u4e(s4e(e,t,o,n.slice(r)),"start")}function ELo(e,t,{shift:r,caret:n}){let o=rBr(e,t,r?-1:1);return u4e(o?{items:o,index:t}:null,n)}function nBr(e,t,r){let{key:n,shift:o,alt:i,caret:a,text:s}=r;return n==="Enter"&&!o?_Lo(e,t,r):n==="Tab"?ELo(e,t,r):i&&(n==="ArrowUp"||n==="ArrowDown")?u4e(tBr(e,t,n==="ArrowUp"?-1:1),a):n==="Backspace"&&a===0&&s===""?u4e(c4e(e,t),"end"):null}function oBr(e,t,r){return nBr(e,t,r)??JOr(e,t,r)}function aBr(e,t){let[r,n]=(0,iBr.useState)(null),o=(a,s)=>{a&&(t(a.items),n({index:a.index,caret:s}))};return{focus:r,onKeyDown:(a,s)=>{let l=s.currentTarget;(s.key==="Enter"||s.key==="Tab")&&s.preventDefault();let u=oBr(e,a,{key:s.key,shift:s.shiftKey,alt:s.altKey,caret:l.selectionStart??0,text:l.value});u&&(s.preventDefault(),u.kind==="focus"?n({index:u.index,caret:"end"}):o(u.edit,u.caret))},onDrop:a=>o(a,"end"),onText:(a,s)=>t(e.map((l,u)=>u===a?{...l,text:s}:l)),onAdd:a=>o(s4e(e,a,e[a].text,""),"start"),onDelete:a=>o(c4e(e,a),"end")}}var dBr=S(ie(),1);function RLo(e,t,r,n){let o=t.length;for(let a=0;a<e.length;a+=1)if(n<e[a].top+e[a].height/2){o=a;break}let i=Vm(t,r);return o>r&&o<i?r:o}function PLo(e,t,r,n){let o=Vm(e,t),i=r-1,a=i>=t&&i<o?t-1:i,s=a>=0?e[a].depth+1:0;return Math.max(0,Math.min(e[t].depth+$Or(n),s))}function ALo(e,t){if(t<e.length)return e[t].top;let r=e[e.length-1];return r?r.top+r.height:0}function sBr(e,t,r,n,o){let i=RLo(e,t,r,o);return{target:i,depth:PLo(t,r,i,n),top:ALo(e,i)}}function LLo(e){let t=e.getBoundingClientRect().top;return{boxes:Array.from(e.querySelectorAll("[data-criterion-row]")).map(n=>{let o=n.getBoundingClientRect();return{top:o.top-t,height:o.height}}),origin:t}}function lBr(e,t,r,n){return o=>{let{boxes:i,origin:a}=LLo(t);return sBr(i,e,r,o.clientX-n,o.clientY-a)}}function cBr(e,t,r,n,o){let i=new AbortController,a=null,s=d=>{a=r(d),n(a)},l=()=>{i.abort(),a&&o(a)},u={signal:i.signal};return e.setPointerCapture(t),e.addEventListener("pointermove",s,u),e.addEventListener("pointerup",l,u),e.addEventListener("pointercancel",l,u),s}function uBr(e,t,r,n){let o=Vm(e,t),i=n-e[t].depth,a=e.slice(t,o).map(u=>({...u,depth:Math.max(0,u.depth+i)})),s=[...e.slice(0,t),...e.slice(o)],l=r>t?r-a.length:r;return{items:_R([...s.slice(0,l),...a,...s.slice(l)]),index:l}}function fBr(e,t,r){let[n,o]=(0,dBr.useState)(null);return{drag:n,onGrip:a=>s=>{let l=t.current;if(!l||s.pointerType==="mouse"&&s.button!==0)return;s.preventDefault(),cBr(s.currentTarget,s.pointerId,lBr(e,l,a,s.clientX),d=>o({from:a,depth:d.depth,top:d.top}),d=>{o(null),r(uBr(e,a,d.target,d.depth))})(s)}}}var Xoe=S(R(),1),ILo={my:1,px:1,py:.5,border:1,borderColor:"divider",borderRadius:1,position:"relative",userSelect:"text",cursor:"auto"},DLo=[{text:"",depth:0}];function hBr({items:e,onChange:t}){let r=(0,pBr.useRef)(null),n=e.length>0?e:DLo,o=aBr(n,t),{drag:i,onGrip:a}=fBr(n,r,o.onDrop),s=BOr(n.map(l=>l.depth));return(0,Xoe.jsxs)(W,{sx:ILo,ref:r,"data-preview-skip":!0,"aria-label":"Acceptance criteria",children:[n.map((l,u)=>(0,Xoe.jsx)(QOr,{index:u,number:s[u],item:l,outline:o,dragging:i?.from===u,onGrip:a(u)},`criterion-${u}`)),(0,Xoe.jsx)(WOr,{drag:i})]})}var mBr=S(R(),1),gBr=ot((0,mBr.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2zm5-6v2h14V5zm0 14h14v-2H7zm0-6h14v-2H7z"}),"FormatListNumbered");var Zoe=S(R(),1),MLo={insert:"Add acceptance criteria",convert:"Convert to outline"};function yBr({kind:e,onClick:t}){return(0,Zoe.jsx)(W,{sx:{my:1},"data-preview-skip":!0,children:(0,Zoe.jsx)(it,{size:"small",variant:"outlined",startIcon:e==="insert"?(0,Zoe.jsx)(Np,{}):(0,Zoe.jsx)(gBr,{}),onClick:t,children:MLo[e]})})}var Qoe=S(ie(),1);function vBr(e,t,{color:r,pin:n}){let o=LA(e),i=[],a=o.nextNode();for(;a;){let u=a;if(t.intersectsNode(u)){let d=u===t.startContainer?t.startOffset:0,f=u===t.endContainer?t.endOffset:u.length;d<f&&i.push({node:u,start:d,end:f})}a=o.nextNode()}let l=i.map(u=>NLo(u.node,u.start,u.end,r)).at(-1);l&&n&&(l.dataset.pin=n)}function NLo(e,t,r,n){let o=document.createRange();o.setStart(e,t),o.setEnd(e,r);let i=document.createElement("mark");return i.className="pr-comment",i.style.backgroundColor=n,o.surroundContents(i),i}function bBr(e){for(let t of e.querySelectorAll("mark.pr-comment"))if(t.parentNode){for(;t.firstChild;)t.before(t.firstChild);t.remove()}}function xBr(e,t){for(let r of t){let n=YAt(e,r);n&&vBr(e,n,r)}}var Joe=S(R(),1);function SBr({content:e,control:t,trailing:r,ranges:n,contentRef:o}){let i=(0,Qoe.useMemo)(()=>MI(e),[e]),a=(0,Qoe.useMemo)(()=>MI(r??""),[r]);return(0,Qoe.useLayoutEffect)(()=>{let s=o.current;s&&(bBr(s),xBr(s,n))},[i,a,n,o]),(0,Joe.jsxs)(W,{ref:o,children:[(0,Joe.jsx)(LI,{segments:i,skipDiagramText:!0}),t,t?(0,Joe.jsx)(LI,{segments:a,skipDiagramText:!0}):null]})}var FD=e=>e.split(",").map(t=>`&& .markdown ${t.trim()}`).join(", ");function d4e(e){let{color:t,radius:r}=e.tokens;return{px:2.5,py:2,fontSize:14,lineHeight:1.6,[FD("")]:{lineHeight:1.6},[FD("h1, h2, h3, h4, h5, h6")]:{fontSize:15,fontWeight:600,lineHeight:1.4,mt:2,mb:1},[FD("ul, ol")]:{pl:2.5,mb:2},[FD("li")]:{mb:"6px"},[FD("code")]:{fontFamily:e.typography.fontFamilyMono,fontSize:"0.86em",px:"5px",py:0,bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:"4px"},[FD("pre")]:{bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:`${r.sm}px`},[FD("pre code")]:{border:0,px:0,bgcolor:"transparent"}}}var TBr=e=>({flex:1,overflow:"auto",position:"relative",userSelect:"none",cursor:"text",wordBreak:"break-word","& .markdown":{...dme(e),maxWidth:"none"},"& a":{color:"primary.main"},"& mark.pr-comment":{color:"inherit",borderRadius:"2px"},...d4e(e)});var BG=S(R(),1);function wBr({content:e,control:t,trailing:r,ranges:n,wrapperRef:o,contentRef:i,dragRects:a,dragColor:s,onMouseDown:l,footer:u}){return(0,BG.jsxs)(W,{ref:o,onMouseDown:l,sx:TBr,children:[(0,BG.jsx)(SBr,{content:e,control:t,trailing:r,ranges:n,contentRef:i}),u&&(0,BG.jsx)(W,{sx:{userSelect:"text"},children:u}),(0,BG.jsx)(eB,{rects:a,color:s})]})}function CBr(e){let t=new Map,r=[];for(let n of e){if(!n.group){r.push(n);continue}t.set(n.group,[...t.get(n.group)??[],n])}return{groups:[...t],ungrouped:r}}var f4e=S(ie(),1),kBr=S(R(),1);function zct({label:e,value:t,onCommit:r,listId:n}){let[o,i]=(0,f4e.useState)(t);return(0,f4e.useEffect)(()=>i(t),[t]),(0,kBr.jsx)(xn,{size:"small",variant:"standard",fullWidth:!0,label:e,value:o,onChange:s=>i(s.target.value),onBlur:()=>{let s=o.trim();i(t),s!==t&&r(s)},onKeyDown:s=>{s.key==="Enter"&&s.target.blur()},onMouseDown:s=>s.stopPropagation(),slotProps:{htmlInput:{list:n}}})}var eie=S(R(),1),Hct="screenshot-groups";function OLo(e){return(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"")}function _Br({screenshot:e,onUpdate:t}){return(0,eie.jsxs)(kt,{direction:"row",spacing:1,sx:{mt:.5},children:[(0,eie.jsx)(zct,{label:"Caption",value:e.alt,onCommit:r=>t(e.id,{alt:r||OLo(e.path)})}),(0,eie.jsx)(zct,{label:"Group",value:e.group??"",listId:Hct,onCommit:r=>t(e.id,{group:r})})]})}var ER=S(R(),1),EBr={display:"block",maxWidth:"100%",borderRadius:1,border:1,borderColor:"divider"},BLo={position:"absolute",top:4,right:4,bgcolor:"background.paper","&:hover":{bgcolor:"background.paper"}};function RBr({screenshot:e,onRemove:t,onUpdate:r}){let n=e.contentType.startsWith("video/");return(0,ER.jsxs)(W,{sx:{position:"relative"},children:[n?(0,ER.jsx)(W,{component:"video",controls:!0,src:e.url,"aria-label":"screenshot",sx:EBr}):(0,ER.jsx)(W,{component:"img",src:e.url,alt:"screenshot",sx:EBr}),(0,ER.jsx)(Kt,{size:"small","aria-label":"Remove screenshot",sx:BLo,onMouseDown:o=>o.stopPropagation(),onClick:()=>t(e.id),children:(0,ER.jsx)(Bo,{fontSize:"small"})}),(0,ER.jsx)(_Br,{screenshot:e,onUpdate:r})]})}var F0=S(R(),1);function $Lo(){return(0,F0.jsxs)(kt,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[(0,F0.jsx)(oo,{size:16}),(0,F0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Attaching screenshot or video\u2026"})]})}function FLo({error:e}){return(0,F0.jsx)(Te,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:e})}function PBr({uploads:e,empty:t}){return e.length>0?(0,F0.jsx)(F0.Fragment,{children:e.map(r=>r.error?(0,F0.jsx)(FLo,{error:r.error},r.id):(0,F0.jsx)($Lo,{},r.id))}):t?(0,F0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Drop or paste an image or video to attach"}):null}var z0=S(R(),1),zLo={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:1};function ABr({screenshots:e,uploads:t,onRemove:r,onUpdate:n}){let{groups:o,ungrouped:i}=CBr(e),a=s=>(0,z0.jsx)(RBr,{screenshot:s,onRemove:r,onUpdate:n},s.id);return(0,z0.jsxs)(W,{sx:{mt:3},children:[e.length>0&&(0,z0.jsx)(W,{component:"h2",children:"Screenshots"}),(0,z0.jsx)("datalist",{id:Hct,children:o.map(([s])=>(0,z0.jsx)("option",{value:s},s))}),o.map(([s,l])=>(0,z0.jsxs)(W,{sx:{mb:2},children:[(0,z0.jsx)(W,{component:"h3",children:s}),(0,z0.jsx)(W,{sx:zLo,children:l.map(a)})]},s)),(0,z0.jsxs)(kt,{spacing:1,children:[i.map(a),(0,z0.jsx)(PBr,{uploads:t,empty:e.length===0})]})]})}var tie=S(R(),1);function HLo(e){let t=e.criteria;if(!t)return{content:e.body};let r={content:t.before,trailing:t.after};return t.kind==="outline"?{...r,control:(0,tie.jsx)(hBr,{items:t.items,onChange:e.onCriteriaChange})}:{...r,control:(0,tie.jsx)(yBr,{kind:t.kind,onClick:t.kind==="insert"?e.onCriteriaInsert:e.onCriteriaConvert})}}function p4e({pane:e,screenshots:t}){return(0,tie.jsx)(wBr,{...HLo(e),ranges:e.ranges,wrapperRef:e.wrapperRef,contentRef:e.contentRef,dragRects:e.dragRects,dragColor:e.dragColor,onMouseDown:e.onMouseDown,footer:t?(0,tie.jsx)(ABr,{screenshots:e.screenshots,uploads:e.uploads,onRemove:e.removeScreenshot,onUpdate:e.updateScreenshot}):void 0})}var LBr=e=>({display:"grid",gap:1,maxHeight:220,overflow:"auto",px:2,py:1.25,borderTop:1,borderColor:e.tokens.color.lineSoft}),IBr={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"text.secondary"},DBr=e=>({display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:"4px 8px",px:1.25,py:1,borderRadius:`${e.tokens.radius.sm}px`,bgcolor:e.tokens.color.raised,border:1,borderColor:e.tokens.color.lineSoft,fontSize:12.5}),MBr={gridColumn:2,gridRow:1,width:20,height:20,color:"text.disabled","& .MuiSvgIcon-root":{fontSize:14}};var pC=S(R(),1);function NBr({comments:e,colors:t,onRemove:r}){return(0,pC.jsxs)(W,{sx:LBr,children:[(0,pC.jsxs)(Te,{sx:IBr,children:["Comments (",e.length,")"]}),e.map((n,o)=>(0,pC.jsxs)(W,{sx:DBr,children:[(0,pC.jsx)(XO,{text:n.quote,sx:{gridColumn:1,borderLeft:2,pl:1,borderColor:t[o]}}),(0,pC.jsx)(W,{sx:{gridColumn:1,wordBreak:"break-word"},children:n.note}),(0,pC.jsx)(Kt,{"aria-label":"Remove comment",onClick:()=>r(n.id),sx:MBr,children:(0,pC.jsx)(Bo,{})})]},n.id))]})}var BBr=S(R(),1);function OBr(e){return e.comments.length===0?null:(0,BBr.jsx)(NBr,{...e})}var $Br=S(R(),1),h4e=ot((0,$Br.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var WBr=S(ie(),1);var FBr=S(R(),1),zBr=ot((0,FBr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var H0="0.1120.0";var ULo={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function HBr(e){return e?ULo[e]:"success.main"}function UBr(e){return e.split("-")[0].split(".").map(Number)}function VBr(e,t){if(!e||!t||e===t)return;let r=UBr(e),n=UBr(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var m4e=S(ie(),1),Uct=(0,m4e.createContext)(null);function g4e(){return(0,m4e.useContext)(Uct)}var zD=S(R(),1),VLo={height:16,fontSize:10},WLo={opacity:.6,fontSize:"0.85em"};function GLo(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function RR({nodes:e,name:t,showVersion:r=!1}){let n=g4e()??H0,o=e.links.find(a=>a.name===t),i=VBr(o?.peerVersion,n);return(0,zD.jsx)(pr,{title:GLo(e,t),placement:"right",children:(0,zD.jsxs)(W,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,zD.jsx)(zBr,{sx:{fontSize:8,color:HBr(o?.state)}}),t,r&&o?.peerVersion&&(0,zD.jsxs)(W,{component:"span",sx:WLo,children:["v",o.peerVersion]}),i&&(0,zD.jsx)(Hn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:VLo})]})})}var U0=S(R(),1),qLo={textTransform:"none"};function y4e({nodes:e,options:t,target:r,onPick:n}){let[o,i]=(0,WBr.useState)(null);return(0,U0.jsxs)(U0.Fragment,{children:[(0,U0.jsx)(it,{size:"small",color:"inherit",startIcon:(0,U0.jsx)(h4e,{fontSize:"small"}),"aria-label":"Start on node","aria-haspopup":"menu",onClick:a=>i(a.currentTarget),sx:qLo,children:(0,U0.jsx)(RR,{nodes:e,name:r.node})}),(0,U0.jsx)(oa,{anchorEl:o,open:!!o,onClose:()=>i(null),children:t.map(({name:a,cwd:s})=>(0,U0.jsx)(Xr,{disabled:!s,selected:a===r.node,onClick:()=>{n(a),i(null)},children:(0,U0.jsx)(Tf,{primary:(0,U0.jsx)(RR,{nodes:e,name:a}),secondary:s?void 0:"no clone"})},a))})]})}var GBr=S(ie(),1);function jLo(e,t){return e?.toLowerCase()===t.toLowerCase()}function v4e(e,t){let{nodes:r,names:n,visible:o}=Us(),{repos:i,selectedCwd:a,selectedNode:s,cloneOn:l,originOf:u}=An(),[d,f]=(0,GBr.useState)(),p=e&&u(e)?e:a,h=t?i.find(b=>jLo(u(b),t)):p,m=n.map(b=>({name:b,cwd:h?l(h,b):void 0})),g=b=>m.find(x=>x.name===b&&x.cwd),y=g(d)??g(s??r?.local)??m.find(b=>b.cwd),v=o&&y?.cwd?{node:y.name,cwd:y.cwd}:void 0;return{nodes:r,visible:o,options:m,target:v,pick:f}}var PR=S(R(),1);function qBr({canStart:e,startOrigin:t,cwd:r,onApprove:n,onApproveAndStart:o}){let i=xpe(),a=v4e(r,t);return(0,PR.jsxs)(PR.Fragment,{children:[(0,PR.jsx)(it,{color:"primary",variant:e?"tonal":"contained",onClick:n,...e?{}:i,children:"Approve"}),e&&a.nodes&&a.target&&(0,PR.jsx)(y4e,{nodes:a.nodes,options:a.options,target:a.target,onPick:a.pick}),e&&(0,PR.jsx)(it,{color:"primary",variant:"contained",onClick:()=>o(a.target),...i,children:"Approve & start"})]})}var Vct=S(R(),1),YLo={"& .MuiFormControlLabel-label":{fontSize:12}};function rie({label:e,title:t,checked:r,onChange:n}){return(0,Vct.jsx)(Ad,{control:(0,Vct.jsx)(Cp,{size:"small",checked:r,onChange:o=>n(o.target.checked)}),label:e,title:t,sx:YLo})}var HD=S(R(),1);function b4e({chain:e,newPr:t,onChange:r}){return(0,HD.jsxs)(kt,{direction:"row",sx:{mr:"auto"},children:[t&&(0,HD.jsx)(rie,{label:"Draft",title:"Create the PR as a draft rather than ready for review",checked:e.draft,onChange:n=>r({...e,draft:n,autoMerge:n?!1:e.autoMerge})}),(0,HD.jsx)(rie,{label:"Auto-merge (squash)",title:"Squash-merge the PR automatically once its required checks pass",checked:e.autoMerge,onChange:n=>r({...e,autoMerge:n,draft:n?!1:e.draft})}),(0,HD.jsx)(rie,{label:"Review PR",title:"After raising, run a review that posts its findings and then addresses them",checked:e.reviewAfter,onChange:n=>r({...e,reviewAfter:n})}),(0,HD.jsx)(rie,{label:"Post to Slack",title:"Announce the PR in Slack at the tail of the chain",checked:e.announceAfter,onChange:n=>r({...e,announceAfter:n})})]})}var UD=S(R(),1);function jBr({commentCount:e,chain:t,newPr:r,canStart:n,startOrigin:o,onChainChange:i,onApprove:a,cwd:s,onApproveAndStart:l,onReject:u,onRequestChanges:d}){return(0,UD.jsxs)(kt,{direction:"row",spacing:1,sx:{px:2,py:1.5,alignItems:"center",justifyContent:"flex-end"},children:[t&&(0,UD.jsx)(b4e,{chain:t,newPr:r,onChange:i}),(0,UD.jsx)(it,{color:"error",variant:"outlined",onClick:u,children:"Reject"}),e>0&&(0,UD.jsxs)(it,{color:"warning",variant:"tonal",onClick:d,children:["Request changes (",e,")"]}),(0,UD.jsx)(qBr,{canStart:n,startOrigin:o,cwd:s,onApprove:a,onApproveAndStart:l})]})}var KBr=S(R(),1);function YBr({comments:e,cwd:t,onDecision:r,chain:n,newPr:o,canStart:i,startOrigin:a,onChainChange:s}){let l=()=>e.map(u=>({quote:u.quote,note:u.note}));return(0,KBr.jsx)(jBr,{commentCount:e.length,chain:n,newPr:o,canStart:i,startOrigin:a,onChainChange:s,onApprove:()=>r("approve",l()),cwd:t,onApproveAndStart:u=>r("approve",l(),u??!0),onReject:()=>r("reject",[]),onRequestChanges:()=>r("reject",l())})}var hC=S(R(),1);function XBr(e){let{comments:t,commentColors:r,pending:n,cwd:o,unavailable:i,onAdd:a,onQueue:s,onCite:l,onAddRule:u,onRemove:d,onCancel:f,onCollapse:p,editable:h}=e;return(0,hC.jsxs)(hC.Fragment,{children:[(0,hC.jsx)(OBr,{comments:t,colors:r,onRemove:d}),(0,hC.jsx)(Kn,{}),(0,hC.jsx)(YBr,{...e}),(0,hC.jsx)(Ihe,{pending:n,editable:h,cwd:o,unavailable:i,onAdd:a,onQueue:s,onCite:l,onAddRule:u,onCancel:f,onCollapse:p})]})}var nie=S(R(),1),KLo={px:2,pb:2,display:"flex",alignItems:"center",gap:1.5,minWidth:0},XLo={color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function ZBr({url:e}){return(0,nie.jsxs)(W,{sx:KLo,children:[(0,nie.jsx)(it,{variant:"contained",href:e,target:"_blank",rel:"noopener noreferrer",sx:{flexShrink:0},children:"Open design \u2197"}),(0,nie.jsx)(Te,{variant:"body2",sx:XLo,title:e,children:e})]})}var Wct=S(R(),1);function QBr({preview:e}){let t=e.kind==="design"?e.metadata?.[0]?.url:void 0;return t?(0,Wct.jsx)(ZBr,{url:t}):(0,Wct.jsx)(MG,{items:e.metadata??[]})}function JBr({preview:e,pane:t,cwd:r,isPr:n,editable:o,sender:i,onCite:a,onAddRule:s}){return{comments:t.comments,commentColors:t.commentColors,pending:t.pending,cwd:r,unavailable:i.unavailable,onAdd:i.onSend,onQueue:t.onAdd,onCite:a,onAddRule:s,onRemove:t.remove,onCancel:t.onCancel,onCollapse:t.onCollapse,onDecision:t.onDecide,chain:n?t.chain:void 0,editable:o,newPr:n&&e.prNumber===null,canStart:e.kind==="backlog-item"&&e.canStart===!0,startOrigin:e.startOrigin,onChainChange:t.setChain}}function $G(e){let t=e??"pr";return{isPr:t==="pr",screenshots:t==="pr"||t==="github-issue",editable:t==="github-issue-edit",closeOnly:t==="show"}}function e$r(e,t){return e?`${e}:${t??"pr"}`:void 0}function x4e(e,t,r,n){return{...$G(e.kind),requestId:e.requestId,supersedes:e.supersedes,sessionId:t,cwd:r,onDecision:n,screenshotScope:e$r(t,e.kind),seededScreenshots:e.screenshots??[],chainDefaults:{draft:e.draft===!0,reviewAfter:e.reviewAfter??!0},initialBody:e.body}}function t$r(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&af(t,e,Swe({quote:r,note:o})),n()}}function r$r(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&af(t,e,vx(r,Che(o))),n()}}function S4e(e,t,r,n){return{onCite:r$r(e,t,r,n),onAddRule:t$r(e,t,r,n)}}function n$r(e){return{criteria:e.criteria,onCriteriaChange:e.writeCriteria,onCriteriaInsert:e.insertCriteria,onCriteriaConvert:e.convertCriteria}}var f$r=S(ie(),1);var mC=S(ie(),1);var o$r="assist:pr-preview-comments:",Gct=e=>`${o$r}${e}`;function qct(e){return sl(Gct(e))}function oie(e,t){Rl(Gct(e),t)}function T4e(e){wv(Gct(e))}function i$r(){bx(o$r)}function a$r(e){let t=LA(e),r="";for(let n=t.nextNode();n;n=t.nextNode())r+=n.textContent??"";return r}function ZLo(e,t,r){let n=-1;for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+1))(n===-1||Math.abs(o-r)<Math.abs(n-r))&&(n=o);return n}function s$r(e,t){return e.flatMap(r=>{let n=ZLo(t,r.quote,r.start);return n===-1?[]:[{...r,start:n,end:n+r.quote.length}]})}function l$r(e,t,r){let n=qct(e);if(n.length>0||!t||!r)return n;let o=s$r(qct(t),a$r(r));return oie(e,o),T4e(t),o}function c$r(e,t,r){let[n,o]=(0,mC.useState)([]),i=(0,mC.useRef)(0);(0,mC.useEffect)(()=>{i$r(),o(l$r(e,t,r.current).map(l=>({...l,id:i.current++})))},[e,t,r]);let a=(0,mC.useCallback)(l=>{o(u=>{let d=[...u,{...l,id:i.current++}];return oie(e,d),d})},[e]),s=(0,mC.useCallback)(l=>{o(u=>{let d=u.filter(f=>f.id!==l);return oie(e,d),d})},[e]);return{comments:n,add:a,remove:s}}function u$r(e,t){let r=e.map((i,a)=>NV(a).solid),n=NV(e.length).fill,o=e.map((i,a)=>({start:i.start,end:i.end,color:NV(a).fill,pin:String(a+1)}));return t&&o.push({start:t.start,end:t.end,color:n}),{commentColors:r,dragColor:n,ranges:o}}function d$r(e,t,r,n){return{onAdd:o=>{e&&t({quote:e.quote,note:o,start:e.start,end:e.end}),n()},onCollapse:()=>{e&&r(e.quote),n()}}}function p$r(e,t,r){let{wrapperRef:n,contentRef:o,pending:i,dragRects:a,onMouseDown:s,clear:l,select:u}=S5(),{comments:d,add:f,remove:p}=c$r(e,t,o),{commentColors:h,dragColor:m,ranges:g}=(0,f$r.useMemo)(()=>u$r(d,i),[d,i]),{onAdd:y,onCollapse:v}=d$r(i,f,r,l);return{wrapperRef:n,contentRef:o,onMouseDown:s,comments:d,commentColors:h,remove:p,pending:i,ranges:g,dragRects:a,dragColor:m,onAdd:y,onCollapse:v,onCancel:l,onSelect:u}}var C4e=S(ie(),1);var jct="assist:preview-screenshots:",Yct=e=>`${jct}${e}`,w4e=e=>`${jct}seeded:${e}`;function h$r(e){return e?(bx(jct),sl(Yct(e)).filter(t=>typeof t.path=="string")):[]}function VD(e,t){e&&Rl(Yct(e),t.map(({path:r,alt:n,group:o,contentType:i,seeded:a})=>({path:r,alt:n,group:o,contentType:i,seeded:a})))}function m$r(e){e&&(wv(Yct(e)),wv(w4e(e)))}var WD=S(ie(),1);var g$r={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"};function QLo(e){let t=e.split(".").pop()?.toLowerCase();return Object.entries(g$r).find(([,n])=>n===t)?.[0]??"application/octet-stream"}function y$r(e){return e.map(t=>({...t,contentType:QLo(t.path),seeded:!0}))}function v$r(e,t,r){if(!e)return y$r(r);let n=h$r(e);if(sl(w4e(e))[0]===t)return n;let o=[...y$r(r),...n.filter(i=>!i.seeded)];return VD(e,o),Rl(w4e(e),[t]),o}function b$r(e,t){let r=new URLSearchParams({path:e});return t&&r.set("node",t),U2(`/api/pr-preview/image?${r}`)}function x$r(e,t,r){let[n,o]=(0,WD.useState)([]),i=(0,WD.useRef)(0),a=hr(),s=(0,WD.useRef)(r);return s.current=r,(0,WD.useEffect)(()=>{o(v$r(e,t,s.current).map(l=>({...l,url:b$r(l.path,a),id:i.current++})))},[e,t,a]),{screenshots:n,setScreenshots:o,nextId:i}}var S$r=S(ie(),1);function T$r(e,t){return(0,S$r.useCallback)((r,n)=>{t(o=>{let i=o.map(a=>a.id===r?{...a,...n}:a);return VD(e,i),i})},[e,t])}function w$r(e,t,r){let{screenshots:n,setScreenshots:o,nextId:i}=x$r(e,t,r),a=(0,C4e.useCallback)(d=>{o(f=>{let p=[...f,{...d,id:i.current++}];return VD(e,p),p})},[e,o,i]),s=(0,C4e.useCallback)(d=>{o(f=>{let p=f.find(m=>m.id===d);p?.url.startsWith("blob:")&&URL.revokeObjectURL(p.url);let h=f.filter(m=>m.id!==d);return VD(e,h),h})},[e,o]),l=T$r(e,o),u=(0,C4e.useCallback)(()=>m$r(e),[e]);return{screenshots:n,add:a,remove:s,update:l,clearPersisted:u}}var FG=S(ie(),1);async function C$r(e,t,r){let n=new URLSearchParams;t&&n.set("cwd",t),r&&n.set("node",r),e instanceof File&&e.name&&n.set("name",e.name);let o=await er(`/api/pr-preview/upload-image?${n}`,{method:"POST",headers:{"Content-Type":e.type||"application/octet-stream"},body:e,timeoutMs:12e4}),i=await o.json().catch(()=>null);if(!o.ok||!i?.path)throw new Error(i?.error??"Failed to attach file");return{path:i.path,alt:i.alt??"screenshot"}}var R$r=S(ie(),1);function k$r(e){return e.startsWith("image/")||e.startsWith("video/")}function _$r(e){if(!e)return null;for(let t of e.items)if(t.kind==="file"&&k$r(t.type)){let r=t.getAsFile();if(r)return r}return null}function E$r(e){return e?Array.from(e.files).find(t=>k$r(t.type))??null:null}function P$r(e,t){return(0,R$r.useEffect)(()=>{if(!t)return;let o=i=>{let a=_$r(i.clipboardData);a&&(i.preventDefault(),e(a))};return globalThis.addEventListener("paste",o),()=>globalThis.removeEventListener("paste",o)},[e,t]),t?{onDrop:o=>{let i=E$r(o.dataTransfer);i&&(o.preventDefault(),e(i))},onDragOver:o=>{Array.from(o.dataTransfer.items).some(i=>i.kind==="file")&&o.preventDefault()}}:{onDrop:void 0,onDragOver:void 0}}function A$r(e,t,r){let[n,o]=(0,FG.useState)([]),i=(0,FG.useRef)(0),a=hr(),s=(0,FG.useCallback)(async d=>{let f=i.current++;o(p=>[...p.filter(h=>!h.error),{id:f}]);try{let p=await C$r(d,e,a);t({...p,url:URL.createObjectURL(d),contentType:d.type}),o(h=>h.filter(m=>m.id!==f))}catch(p){let h=p instanceof Error?p.message:"Failed to attach file";o(m=>m.map(g=>g.id===f?{id:f,error:h}:g))}},[e,a,t]),{onDrop:l,onDragOver:u}=P$r(s,r);return{uploads:n,onDrop:l,onDragOver:u}}function L$r({cwd:e,screenshots:t,screenshotScope:r,requestId:n,seededScreenshots:o}){let{screenshots:i,add:a,remove:s,update:l,clearPersisted:u}=w$r(t?r:void 0,n,t?o:[]),{uploads:d,onDrop:f,onDragOver:p}=A$r(e,a,t);return{screenshots:i,removeScreenshot:s,updateScreenshot:l,decision:{attachments:()=>i.map(({path:h,alt:m,group:g})=>g?{path:h,alt:m,group:g}:{path:h,alt:m}),clearPersisted:u},uploads:d,onDrop:f,onDragOver:p}}var z$r=S(ie(),1);var I$r="assist:pr-preview-chain:",Kct=e=>`${I$r}${e}`;function D$r(e){if(e)return sl(Kct(e))[0]}function M$r(e,t){e&&Rl(Kct(e),[t])}function N$r(e){e&&wv(Kct(e))}function O$r(){bx(I$r)}function B$r(e,t,r){if(!e)return{reviewAfter:!1,announceAfter:!1,draft:!1,autoMerge:!1};O$r();let n=D$r(t);return{reviewAfter:n?.reviewAfter??r.reviewAfter,announceAfter:n?.announceAfter??!0,draft:n?.draft??r.draft,autoMerge:n?.autoMerge??!1}}function $$r(e,t,r,n,o){return{comments:t,screenshots:n,reviewAfter:e&&r.reviewAfter,announceAfter:e&&r.announceAfter,draft:r.draft,autoMerge:e&&r.autoMerge,...o===void 0?{}:{body:o}}}function F$r(e,t){return!e||t===!1?{}:t===!0?{autostart:!0}:{autostart:!0,startOn:t}}function H$r(e,t,r,n,o,i,a){let[s,l]=(0,z$r.useState)(()=>B$r(n,t,o));return{chain:s,setChain:f=>{l(f),M$r(t,f)},onDecide:(f,p,h=!1)=>{let m=f==="approve";r(f,{...$$r(m,p,s,m?i.attachments():[],a()),...F$r(m,h)}),T4e(e),m&&(N$r(t),i.clearPersisted())}}}var Z$r=S(ie(),1);var JLo=/^ {0,3}#{1,6}[ \t]+acceptance criteria[ \t]*$/i,eIo=/^ {0,3}#{1,6}[ \t]/;function AR(e){let t=e.split(`
|
|
4005
|
+
`),additions:sOr(o,"+"),deletions:sOr(o,"-"),split:{hunks:o.length,of:n.length,elsewhere:i}}}function cOr(e){return e.flatMap(t=>{if(t.kind==="dir")return cOr(t.children);let{kind:r,name:n,...o}=t;return[o]})}function yLo(e){let t=new Map;return e.forEach((r,n)=>{for(let o of r.hunks)t.set(o,[...t.get(o)??[],n+1])}),t}function uOr(e,t,r=new Set,n=new Set){let o=cOr(e.tree).filter(a=>!r.has(a.path)).map(a=>n.has(a.path)?{...a,critical:!0}:a),i=yLo(t);return t.map((a,s)=>{let l=new Set(a.hunks.map(EG));return nOr(o.filter(u=>l.has(u.path)).map(u=>lOr(u,s+1,i)))})}function vLo(e,t){let r=-1,n=0;return t.forEach((o,i)=>{let a=o.hunks.filter(s=>EG(s)===e).length;a>n&&(r=i,n=a)}),r}function dOr(e,t){let r=t.map(()=>[]);for(let n of e)r[vLo(n.path,t)]?.push(n);return r}function fOr(e,t){let r=uOr(e.structure,t,new Set(e.tests.map(i=>i.path)),new Set(e.criticalDiffs.map(i=>i.path))),n=dOr(e.tests,t),o=OEe(t);return t.map((i,a)=>{let s=a+1;return{number:s,slice:i,structure:r[a]??e.structure,tests:n[a]??[],critical:e.criticalDiffs.filter(l=>o.get(l.path)?.some(u=>u.number===s))}})}function pOr(e){if(!e.slices)return;let t=fOr(e,e.slices);return{entries:K8r(e,t),slicing:{count:t.length,noCritical:new Set(t.filter(r=>r.critical.length===0).map(r=>r.number))}}}function hOr(e){if(!(!e.repo||!e.headSha))return`${e.repo}#${e.prNumber}@${e.headSha}`}var Nct="assist:high-level-progress:",bLo=`${Nct}head:`,xLo=720*60*60*1e3,Yoe=e=>`${Nct}${e}`,Oct=e=>`${bLo}${e}`,Mct=e=>sl(e)[0];function SLo(e,t){let r=e?Mct(Yoe(e)):void 0;return e&&wv(Yoe(e)),r??(t?Mct(Oct(t)):void 0)}function mOr(e,t,r){return bx(Nct,xLo),Mct(Yoe(e))??SLo(t,r)}function gOr(e,t,r){Rl(Yoe(e),[r]),t&&Rl(Oct(t),[r])}function yOr(e,t){wv(Yoe(e)),t&&wv(Oct(t))}function vOr(e){let t=e;return typeof t?.id=="string"&&typeof t.title=="string"&&typeof t.reason=="string"&&(t.kind==="deterministic"||t.kind==="manual")&&["pass","fail","manual"].includes(t.status)}function OD(e,t){return Array.isArray(e)?t?e.filter(t):e:[]}var OG={repo:"",prNumber:0,headSha:"",checks:[],structure:{tree:[],added:0,removed:0,modified:0,additions:0,deletions:0},criticalDiffs:[],criticalPaths:[],tests:[],testPaths:[],collapsedPaths:[]};function bOr(e){let t;try{t=JSON.parse(e)}catch{return OG}return typeof t!="object"||t===null?OG:{repo:typeof t.repo=="string"?t.repo:OG.repo,prNumber:typeof t.prNumber=="number"?t.prNumber:OG.prNumber,headSha:typeof t.headSha=="string"?t.headSha:OG.headSha,checks:OD(t.checks,vOr),structure:{...OG.structure,...t.structure},criticalDiffs:OD(t.criticalDiffs),criticalPaths:OD(t.criticalPaths),tests:OD(t.tests),testPaths:OD(t.testPaths),collapsedPaths:OD(t.collapsedPaths),...Array.isArray(t.slices)?{slices:t.slices}:{},...t.manualTesting?{manualTesting:t.manualTesting}:{},...t.saved?{saved:t.saved}:{},...t.draft?{draft:t.draft}:{}}}function xOr(e){let t=(0,n4e.useMemo)(()=>bOr(e.body),[e.body]),r=(0,n4e.useMemo)(()=>pOr(t),[t]),n=hOr(t),o=(0,n4e.useMemo)(()=>mOr(e.requestId,e.supersedes,n)??t.draft??t.saved,[e.requestId,e.supersedes,n,t]);return{payload:t,sliced:r,progress:o,head:n}}var SOr=S(ie(),1);function TOr(e){let[t,r]=(0,SOr.useState)(()=>e?.reviewComments??[]);return{queued:t,onQueue:n=>r(o=>[...o,n]),onRemove:n=>r(o=>o.filter((i,a)=>a!==n))}}var wOr=S(ie(),1);function COr(e,t,r,n){(0,wOr.useEffect)(()=>{gOr(e,t,{items:r,reviewComments:n})},[e,t,r,n])}function _Or(e,t,r){let{payload:n,sliced:o,progress:i,head:a}=xOr(e),s=Y8r(n.checks,i,o?.slicing),l=TOr(i),u=$8r(o?.entries??[]),{comments:d,sentTo:f,clearSent:p}=yEe(t,r),h={...d,onQueue:l.onQueue};COr(e.requestId,a,s.items,l.queued);let m=(0,kOr.useMemo)(()=>V8r(n),[n]);return{payload:n,checklist:s,queue:l,details:U8r(n,h),counts:m,sentTo:f,clearSent:p,sliced:o,nav:u,diffComments:h,head:a}}var Ux=S(R(),1);function EOr({preview:e,session:t,sendInput:r,onDecision:n}){let o=_Or(e,t,r);return(0,Ux.jsxs)(W,{sx:L0,children:[(0,Ux.jsx)(yh,{preview:e,draft:!1}),(0,Ux.jsx)(MG,{items:e.metadata??[]}),(0,Ux.jsx)(Kn,{}),(0,Ux.jsx)(E8r,{payload:o.payload,checklist:o.checklist,details:o.details,counts:o.counts,sliced:o.sliced,nav:o.nav,comments:o.diffComments}),(0,Ux.jsx)(Kn,{}),(0,Ux.jsx)(O8r,{pane:o,onDecision:(i,a)=>{yOr(e.requestId,o.head),n(i,a)}}),(0,Ux.jsx)(_0,{sessionName:o.sentTo,onClose:o.clearSent})]})}var NOr=S(ie(),1);var BD=S(R(),1);function TLo(e){return e.topLeft===null?"Click the top-left box":e.bottomRight===null?"Now click the bottom-right box":"Both anchors picked"}function ROr({selection:e,onConfirm:t,onReject:r}){let n=e.topLeft!==null&&e.bottomRight!==null;return(0,BD.jsxs)(kt,{direction:"row",spacing:1,sx:{p:2,alignItems:"center",justifyContent:"flex-end"},children:[(0,BD.jsx)(Te,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:TLo(e)}),(0,BD.jsx)(it,{color:"error",variant:"outlined",onClick:r,children:"Cancel"}),(0,BD.jsx)(it,{variant:"outlined",onClick:e.reset,children:"Start over"}),(0,BD.jsx)(it,{color:"success",variant:"contained",disabled:!n,onClick:t,children:"Extract boxes"})]})}var wLo={"top-left":Jl.miro.topLeft,"bottom-right":Jl.miro.bottomRight};function POr(e,t){let r=e.right-e.left,n=e.bottom-e.top;return{width:r,height:n,fontSize:Math.max(6,Math.min(n*.3,r/6,28)),radius:Math.min(8,n/4),colour:t?wLo[t]:Jl.miro.box,opacity:t?.75:.35,strokeWidth:Math.max(1,r*.004)}}var Koe=S(R(),1);function AOr({box:e,role:t,onSelect:r}){let n=POr(e,t);return(0,Koe.jsxs)("g",{role:"button",tabIndex:0,"aria-label":t?`${e.text} (${t})`:e.text,onClick:()=>r(e.id),onKeyDown:o=>{o.key==="Enter"&&r(e.id)},style:{cursor:"pointer"},children:[(0,Koe.jsx)("rect",{x:e.left,y:e.top,width:n.width,height:n.height,rx:n.radius,fill:n.colour,fillOpacity:n.opacity,stroke:n.colour,strokeWidth:n.strokeWidth}),(0,Koe.jsx)("text",{x:e.left+n.width/2,y:e.top+n.height/2,textAnchor:"middle",dominantBaseline:"central",fontSize:n.fontSize,fill:Jl.miro.text,children:e.text})]})}function LOr(e){if(e.length===0)return"0 0 100 100";let t=Math.min(...e.map(a=>a.left)),r=Math.min(...e.map(a=>a.top)),n=Math.max(...e.map(a=>a.right))-t,o=Math.max(...e.map(a=>a.bottom))-r,i=Math.max(n*.02,8);return`${t-i} ${r-i} ${n+i*2} ${o+i*2}`}var o4e=S(R(),1);function IOr({boxes:e,selection:t}){return(0,o4e.jsx)(W,{sx:{flex:1,minHeight:0,overflow:"auto",p:2},children:(0,o4e.jsx)("svg",{role:"img","aria-label":"Miro board boxes",viewBox:LOr(e),preserveAspectRatio:"xMidYMid meet",style:{width:"100%",height:"100%"},children:e.map(r=>(0,o4e.jsx)(AOr,{box:r,role:t.roleOf(r.id),onSelect:t.choose},r.id))})})}function CLo(e){return typeof e?.id=="string"&&typeof e.text=="string"&&[e.left,e.top,e.right,e.bottom].every(t=>typeof t=="number"&&Number.isFinite(t))}function DOr(e){try{let t=JSON.parse(e);return Array.isArray(t?.boxes)?t.boxes.filter(CLo):[]}catch{return[]}}var Bct=S(ie(),1);function MOr(){let[e,t]=(0,Bct.useState)(null),[r,n]=(0,Bct.useState)(null);return{topLeft:e,bottomRight:r,choose:s=>{if(e===null||r!==null){t(s),n(null);return}n(s)},reset:()=>{t(null),n(null)},roleOf:s=>s===e?"top-left":s===r?"bottom-right":null}}var kR=S(R(),1);function OOr({preview:e,onDecision:t}){let r=(0,NOr.useMemo)(()=>DOr(e.body),[e.body]),n=MOr();return(0,kR.jsxs)(W,{sx:L0,children:[(0,kR.jsx)(yh,{preview:e,draft:!1}),(0,kR.jsx)(Kn,{}),(0,kR.jsx)(IOr,{boxes:r,selection:n}),(0,kR.jsx)(Kn,{}),(0,kR.jsx)(ROr,{selection:n,onConfirm:()=>{let{topLeft:i,bottomRight:a}=n;i===null||a===null||t("approve",Mc({topLeft:i,bottomRight:a}))},onReject:()=>t("reject",Mc())})]})}var pBr=S(ie(),1);function BOr(e){let t=[];return e.map(r=>(t.length=r+1,t[r]=(t[r]??0)+1,t.map(n=>n??1).join(".")))}function i4e(e){return e*22}function $Or(e){return Math.round(e/22)}var FOr={display:"flex",alignItems:"flex-start",gap:.25,"& .criterion-action":{opacity:0,transition:"opacity 120ms"},"&:hover .criterion-action":{opacity:1},"&:focus-within .criterion-action":{opacity:1},"& .criterion-action:focus-visible":{opacity:1}},zOr={p:.25,mt:"2px",color:"text.disabled",cursor:"grab",touchAction:"none","&:active":{cursor:"grabbing"}},HOr={fontFamily:"fontFamilyMono",fontSize:"0.8rem",color:"text.secondary",minWidth:32,pt:"5px",textAlign:"right",userSelect:"none",whiteSpace:"nowrap"},UOr={flex:1,fontSize:"inherit",lineHeight:1.5,px:.75,py:0,borderRadius:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-focused":{bgcolor:"action.selected"}},$ct={p:.25,mt:"2px"},VOr={position:"absolute",right:8,height:2,borderRadius:1,bgcolor:"primary.main",pointerEvents:"none"};var GOr=S(R(),1),kLo=8;function WOr({drag:e}){return e?(0,GOr.jsx)(W,{sx:VOr,style:{top:e.top-1,left:kLo+i4e(e.depth)}}):null}var qOr=S(R(),1),jOr=ot((0,qOr.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");var Fct=S(R(),1);function YOr({number:e,onGrip:t}){return(0,Fct.jsx)(Kt,{size:"small",className:"criterion-action",sx:zOr,"aria-label":`Reorder criterion ${e}`,onPointerDown:t,children:(0,Fct.jsx)(jOr,{fontSize:"inherit"})})}var fC=S(R(),1);function KOr({number:e,onAdd:t,onDelete:r}){return(0,fC.jsxs)(fC.Fragment,{children:[(0,fC.jsx)(Kt,{size:"small",className:"criterion-action",sx:$ct,"aria-label":`Add criterion after ${e}`,onClick:t,children:(0,fC.jsx)(Np,{fontSize:"inherit"})}),(0,fC.jsx)(Kt,{size:"small",className:"criterion-action",sx:$ct,"aria-label":`Delete criterion ${e}`,onClick:r,children:(0,fC.jsx)(Bo,{fontSize:"inherit"})})]})}var a4e=S(ie(),1);function XOr(e,t){return e==="start"?0:e==="end"?t:Math.min(Math.max(e,0),t)}function ZOr(e){let t=(0,a4e.useRef)(null);return(0,a4e.useEffect)(()=>{let r=t.current;if(!e||!r)return;r.focus();let n=XOr(e.caret,r.value.length);r.setSelectionRange(n,n)},[e]),t}var $D=S(R(),1);function QOr({index:e,number:t,item:r,outline:n,dragging:o,onGrip:i}){let a=ZOr(n.focus?.index===e?n.focus:null),s={marginLeft:i4e(r.depth),opacity:o?.4:1};return(0,$D.jsxs)(W,{sx:FOr,"data-criterion-row":!0,style:s,children:[(0,$D.jsx)(YOr,{number:t,onGrip:i}),(0,$D.jsx)(W,{component:"span",sx:HOr,"aria-hidden":"true",children:`${t}.`}),(0,$D.jsx)(na,{multiline:!0,value:r.text,sx:UOr,inputRef:a,inputProps:{"aria-label":`Criterion ${t}`},onChange:l=>n.onText(e,l.target.value),onKeyDown:l=>n.onKeyDown(e,l)}),(0,$D.jsx)(KOr,{number:t,onAdd:()=>n.onAdd(e),onDelete:()=>n.onDelete(e)})]})}var iBr=S(ie(),1);function JOr(e,t,{key:r,shift:n,alt:o,caret:i,text:a}){return o||n?null:r==="ArrowUp"&&i===0&&t>0?{kind:"focus",index:t-1}:r==="ArrowDown"&&i===a.length&&t<e.length-1?{kind:"focus",index:t+1}:null}function _R(e){if(e.length===0)return[{text:"",depth:0}];let t=-1;return e.map(r=>{let n=Math.min(Math.max(r.depth,0),t+1);return t=n,r.depth===n?r:{...r,depth:n}})}function s4e(e,t,r,n){let o=e[t]?.depth??0,i=e.map((a,s)=>s===t?{...a,text:r}:a);return{items:_R([...i.slice(0,t+1),{text:n,depth:o},...i.slice(t+1)]),index:t+1}}function Vm(e,t){let r=t+1;for(;r<e.length&&e[r].depth>e[t].depth;)r+=1;return r}function l4e(e,t){let r=e[t].depth;for(let n=t-1;n>=0;n-=1){if(e[n].depth<r)return-1;if(e[n].depth===r)return n}return-1}function eBr(e,t){let r=Vm(e,t);return r<e.length&&e[r].depth===e[t].depth?r:-1}function tBr(e,t,r){let n=r<0?l4e(e,t):eBr(e,t);if(n<0)return null;let o=Vm(e,t),i=e.slice(t,o),a=[...e.slice(0,t),...e.slice(o)],s=r<0?n:Vm(e,n)-(o-t);return{items:[...a.slice(0,s),...i,...a.slice(s)],index:s}}function c4e(e,t){let r=Vm(e,t),n=e.map((o,i)=>i>t&&i<r?{...o,depth:o.depth-1}:o).filter((o,i)=>i!==t);return{items:_R(n),index:Math.max(0,t-1)}}function rBr(e,t,r){if(r<0&&e[t].depth===0||r>0&&l4e(e,t)<0)return null;let n=Vm(e,t);return e.map((o,i)=>i>=t&&i<n?{...o,depth:o.depth+r}:o)}function u4e(e,t){return e?{kind:"edit",edit:e,caret:t}:null}function _Lo(e,t,{caret:r,text:n}){let o=n.slice(0,r);return u4e(s4e(e,t,o,n.slice(r)),"start")}function ELo(e,t,{shift:r,caret:n}){let o=rBr(e,t,r?-1:1);return u4e(o?{items:o,index:t}:null,n)}function nBr(e,t,r){let{key:n,shift:o,alt:i,caret:a,text:s}=r;return n==="Enter"&&!o?_Lo(e,t,r):n==="Tab"?ELo(e,t,r):i&&(n==="ArrowUp"||n==="ArrowDown")?u4e(tBr(e,t,n==="ArrowUp"?-1:1),a):n==="Backspace"&&a===0&&s===""?u4e(c4e(e,t),"end"):null}function oBr(e,t,r){return nBr(e,t,r)??JOr(e,t,r)}function aBr(e,t){let[r,n]=(0,iBr.useState)(null),o=(a,s)=>{a&&(t(a.items),n({index:a.index,caret:s}))};return{focus:r,onKeyDown:(a,s)=>{let l=s.currentTarget;(s.key==="Enter"||s.key==="Tab")&&s.preventDefault();let u=oBr(e,a,{key:s.key,shift:s.shiftKey,alt:s.altKey,caret:l.selectionStart??0,text:l.value});u&&(s.preventDefault(),u.kind==="focus"?n({index:u.index,caret:"end"}):o(u.edit,u.caret))},onDrop:a=>o(a,"end"),onText:(a,s)=>t(e.map((l,u)=>u===a?{...l,text:s}:l)),onAdd:a=>o(s4e(e,a,e[a].text,""),"start"),onDelete:a=>o(c4e(e,a),"end")}}var dBr=S(ie(),1);function RLo(e,t,r,n){let o=t.length;for(let a=0;a<e.length;a+=1)if(n<e[a].top+e[a].height/2){o=a;break}let i=Vm(t,r);return o>r&&o<i?r:o}function PLo(e,t,r,n){let o=Vm(e,t),i=r-1,a=i>=t&&i<o?t-1:i,s=a>=0?e[a].depth+1:0;return Math.max(0,Math.min(e[t].depth+$Or(n),s))}function ALo(e,t){if(t<e.length)return e[t].top;let r=e[e.length-1];return r?r.top+r.height:0}function sBr(e,t,r,n,o){let i=RLo(e,t,r,o);return{target:i,depth:PLo(t,r,i,n),top:ALo(e,i)}}function LLo(e){let t=e.getBoundingClientRect().top;return{boxes:Array.from(e.querySelectorAll("[data-criterion-row]")).map(n=>{let o=n.getBoundingClientRect();return{top:o.top-t,height:o.height}}),origin:t}}function lBr(e,t,r,n){return o=>{let{boxes:i,origin:a}=LLo(t);return sBr(i,e,r,o.clientX-n,o.clientY-a)}}function cBr(e,t,r,n,o){let i=new AbortController,a=null,s=d=>{a=r(d),n(a)},l=()=>{i.abort(),a&&o(a)},u={signal:i.signal};return e.setPointerCapture(t),e.addEventListener("pointermove",s,u),e.addEventListener("pointerup",l,u),e.addEventListener("pointercancel",l,u),s}function uBr(e,t,r,n){let o=Vm(e,t),i=n-e[t].depth,a=e.slice(t,o).map(u=>({...u,depth:Math.max(0,u.depth+i)})),s=[...e.slice(0,t),...e.slice(o)],l=r>t?r-a.length:r;return{items:_R([...s.slice(0,l),...a,...s.slice(l)]),index:l}}function fBr(e,t,r){let[n,o]=(0,dBr.useState)(null);return{drag:n,onGrip:a=>s=>{let l=t.current;if(!l||s.pointerType==="mouse"&&s.button!==0)return;s.preventDefault(),cBr(s.currentTarget,s.pointerId,lBr(e,l,a,s.clientX),d=>o({from:a,depth:d.depth,top:d.top}),d=>{o(null),r(uBr(e,a,d.target,d.depth))})(s)}}}var Xoe=S(R(),1),ILo={my:1,px:1,py:.5,border:1,borderColor:"divider",borderRadius:1,position:"relative",userSelect:"text",cursor:"auto"},DLo=[{text:"",depth:0}];function hBr({items:e,onChange:t}){let r=(0,pBr.useRef)(null),n=e.length>0?e:DLo,o=aBr(n,t),{drag:i,onGrip:a}=fBr(n,r,o.onDrop),s=BOr(n.map(l=>l.depth));return(0,Xoe.jsxs)(W,{sx:ILo,ref:r,"data-preview-skip":!0,"aria-label":"Acceptance criteria",children:[n.map((l,u)=>(0,Xoe.jsx)(QOr,{index:u,number:s[u],item:l,outline:o,dragging:i?.from===u,onGrip:a(u)},`criterion-${u}`)),(0,Xoe.jsx)(WOr,{drag:i})]})}var mBr=S(R(),1),gBr=ot((0,mBr.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2zm5-6v2h14V5zm0 14h14v-2H7zm0-6h14v-2H7z"}),"FormatListNumbered");var Zoe=S(R(),1),MLo={insert:"Add acceptance criteria",convert:"Convert to outline"};function yBr({kind:e,onClick:t}){return(0,Zoe.jsx)(W,{sx:{my:1},"data-preview-skip":!0,children:(0,Zoe.jsx)(it,{size:"small",variant:"outlined",startIcon:e==="insert"?(0,Zoe.jsx)(Np,{}):(0,Zoe.jsx)(gBr,{}),onClick:t,children:MLo[e]})})}var Qoe=S(ie(),1);function vBr(e,t,{color:r,pin:n}){let o=LA(e),i=[],a=o.nextNode();for(;a;){let u=a;if(t.intersectsNode(u)){let d=u===t.startContainer?t.startOffset:0,f=u===t.endContainer?t.endOffset:u.length;d<f&&i.push({node:u,start:d,end:f})}a=o.nextNode()}let l=i.map(u=>NLo(u.node,u.start,u.end,r)).at(-1);l&&n&&(l.dataset.pin=n)}function NLo(e,t,r,n){let o=document.createRange();o.setStart(e,t),o.setEnd(e,r);let i=document.createElement("mark");return i.className="pr-comment",i.style.backgroundColor=n,o.surroundContents(i),i}function bBr(e){for(let t of e.querySelectorAll("mark.pr-comment"))if(t.parentNode){for(;t.firstChild;)t.before(t.firstChild);t.remove()}}function xBr(e,t){for(let r of t){let n=YAt(e,r);n&&vBr(e,n,r)}}var Joe=S(R(),1);function SBr({content:e,control:t,trailing:r,ranges:n,contentRef:o}){let i=(0,Qoe.useMemo)(()=>MI(e),[e]),a=(0,Qoe.useMemo)(()=>MI(r??""),[r]);return(0,Qoe.useLayoutEffect)(()=>{let s=o.current;s&&(bBr(s),xBr(s,n))},[i,a,n,o]),(0,Joe.jsxs)(W,{ref:o,children:[(0,Joe.jsx)(LI,{segments:i,skipDiagramText:!0}),t,t?(0,Joe.jsx)(LI,{segments:a,skipDiagramText:!0}):null]})}var FD=e=>e.split(",").map(t=>`&& .markdown ${t.trim()}`).join(", ");function d4e(e){let{color:t,radius:r}=e.tokens;return{px:2.5,py:2,fontSize:14,lineHeight:1.6,[FD("")]:{lineHeight:1.6},[FD("h1, h2, h3, h4, h5, h6")]:{fontSize:15,fontWeight:600,lineHeight:1.4,mt:2,mb:1},[FD("ul, ol")]:{pl:2.5,mb:2},[FD("li")]:{mb:"6px"},[FD("code")]:{fontFamily:e.typography.fontFamilyMono,fontSize:"0.86em",px:"5px",py:0,bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:"4px"},[FD("pre")]:{bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:`${r.sm}px`},[FD("pre code")]:{border:0,px:0,bgcolor:"transparent"}}}var TBr=e=>({flex:1,overflow:"auto",position:"relative",userSelect:"none",cursor:"text",wordBreak:"break-word","& .markdown":{...dme(e),maxWidth:"none"},"& a":{color:"primary.main"},"& mark.pr-comment":{color:"inherit",borderRadius:"2px"},...d4e(e)});var BG=S(R(),1);function wBr({content:e,control:t,trailing:r,ranges:n,wrapperRef:o,contentRef:i,dragRects:a,dragColor:s,onMouseDown:l,footer:u}){return(0,BG.jsxs)(W,{ref:o,onMouseDown:l,sx:TBr,children:[(0,BG.jsx)(SBr,{content:e,control:t,trailing:r,ranges:n,contentRef:i}),u&&(0,BG.jsx)(W,{sx:{userSelect:"text"},children:u}),(0,BG.jsx)(eB,{rects:a,color:s})]})}function CBr(e){let t=new Map,r=[];for(let n of e){if(!n.group){r.push(n);continue}t.set(n.group,[...t.get(n.group)??[],n])}return{groups:[...t],ungrouped:r}}var f4e=S(ie(),1),kBr=S(R(),1);function zct({label:e,value:t,onCommit:r,listId:n}){let[o,i]=(0,f4e.useState)(t);return(0,f4e.useEffect)(()=>i(t),[t]),(0,kBr.jsx)(xn,{size:"small",variant:"standard",fullWidth:!0,label:e,value:o,onChange:s=>i(s.target.value),onBlur:()=>{let s=o.trim();i(t),s!==t&&r(s)},onKeyDown:s=>{s.key==="Enter"&&s.target.blur()},onMouseDown:s=>s.stopPropagation(),slotProps:{htmlInput:{list:n}}})}var eie=S(R(),1),Hct="screenshot-groups";function OLo(e){return(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"")}function _Br({screenshot:e,onUpdate:t}){return(0,eie.jsxs)(kt,{direction:"row",spacing:1,sx:{mt:.5},children:[(0,eie.jsx)(zct,{label:"Caption",value:e.alt,onCommit:r=>t(e.id,{alt:r||OLo(e.path)})}),(0,eie.jsx)(zct,{label:"Group",value:e.group??"",listId:Hct,onCommit:r=>t(e.id,{group:r})})]})}var ER=S(R(),1),EBr={display:"block",maxWidth:"100%",borderRadius:1,border:1,borderColor:"divider"},BLo={position:"absolute",top:4,right:4,bgcolor:"background.paper","&:hover":{bgcolor:"background.paper"}};function RBr({screenshot:e,onRemove:t,onUpdate:r}){let n=e.contentType.startsWith("video/");return(0,ER.jsxs)(W,{sx:{position:"relative"},children:[n?(0,ER.jsx)(W,{component:"video",controls:!0,src:e.url,"aria-label":"screenshot",sx:EBr}):(0,ER.jsx)(W,{component:"img",src:e.url,alt:"screenshot",sx:EBr}),(0,ER.jsx)(Kt,{size:"small","aria-label":"Remove screenshot",sx:BLo,onMouseDown:o=>o.stopPropagation(),onClick:()=>t(e.id),children:(0,ER.jsx)(Bo,{fontSize:"small"})}),(0,ER.jsx)(_Br,{screenshot:e,onUpdate:r})]})}var F0=S(R(),1);function $Lo(){return(0,F0.jsxs)(kt,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[(0,F0.jsx)(oo,{size:16}),(0,F0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Attaching screenshot or video\u2026"})]})}function FLo({error:e}){return(0,F0.jsx)(Te,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:e})}function PBr({uploads:e,empty:t}){return e.length>0?(0,F0.jsx)(F0.Fragment,{children:e.map(r=>r.error?(0,F0.jsx)(FLo,{error:r.error},r.id):(0,F0.jsx)($Lo,{},r.id))}):t?(0,F0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Drop or paste an image or video to attach"}):null}var z0=S(R(),1),zLo={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:1};function ABr({screenshots:e,uploads:t,onRemove:r,onUpdate:n}){let{groups:o,ungrouped:i}=CBr(e),a=s=>(0,z0.jsx)(RBr,{screenshot:s,onRemove:r,onUpdate:n},s.id);return(0,z0.jsxs)(W,{sx:{mt:3},children:[e.length>0&&(0,z0.jsx)(W,{component:"h2",children:"Screenshots"}),(0,z0.jsx)("datalist",{id:Hct,children:o.map(([s])=>(0,z0.jsx)("option",{value:s},s))}),o.map(([s,l])=>(0,z0.jsxs)(W,{sx:{mb:2},children:[(0,z0.jsx)(W,{component:"h3",children:s}),(0,z0.jsx)(W,{sx:zLo,children:l.map(a)})]},s)),(0,z0.jsxs)(kt,{spacing:1,children:[i.map(a),(0,z0.jsx)(PBr,{uploads:t,empty:e.length===0})]})]})}var tie=S(R(),1);function HLo(e){let t=e.criteria;if(!t)return{content:e.body};let r={content:t.before,trailing:t.after};return t.kind==="outline"?{...r,control:(0,tie.jsx)(hBr,{items:t.items,onChange:e.onCriteriaChange})}:{...r,control:(0,tie.jsx)(yBr,{kind:t.kind,onClick:t.kind==="insert"?e.onCriteriaInsert:e.onCriteriaConvert})}}function p4e({pane:e,screenshots:t}){return(0,tie.jsx)(wBr,{...HLo(e),ranges:e.ranges,wrapperRef:e.wrapperRef,contentRef:e.contentRef,dragRects:e.dragRects,dragColor:e.dragColor,onMouseDown:e.onMouseDown,footer:t?(0,tie.jsx)(ABr,{screenshots:e.screenshots,uploads:e.uploads,onRemove:e.removeScreenshot,onUpdate:e.updateScreenshot}):void 0})}var LBr=e=>({display:"grid",gap:1,maxHeight:220,overflow:"auto",px:2,py:1.25,borderTop:1,borderColor:e.tokens.color.lineSoft}),IBr={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"text.secondary"},DBr=e=>({display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:"4px 8px",px:1.25,py:1,borderRadius:`${e.tokens.radius.sm}px`,bgcolor:e.tokens.color.raised,border:1,borderColor:e.tokens.color.lineSoft,fontSize:12.5}),MBr={gridColumn:2,gridRow:1,width:20,height:20,color:"text.disabled","& .MuiSvgIcon-root":{fontSize:14}};var pC=S(R(),1);function NBr({comments:e,colors:t,onRemove:r}){return(0,pC.jsxs)(W,{sx:LBr,children:[(0,pC.jsxs)(Te,{sx:IBr,children:["Comments (",e.length,")"]}),e.map((n,o)=>(0,pC.jsxs)(W,{sx:DBr,children:[(0,pC.jsx)(XO,{text:n.quote,sx:{gridColumn:1,borderLeft:2,pl:1,borderColor:t[o]}}),(0,pC.jsx)(W,{sx:{gridColumn:1,wordBreak:"break-word"},children:n.note}),(0,pC.jsx)(Kt,{"aria-label":"Remove comment",onClick:()=>r(n.id),sx:MBr,children:(0,pC.jsx)(Bo,{})})]},n.id))]})}var BBr=S(R(),1);function OBr(e){return e.comments.length===0?null:(0,BBr.jsx)(NBr,{...e})}var $Br=S(R(),1),h4e=ot((0,$Br.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var WBr=S(ie(),1);var FBr=S(R(),1),zBr=ot((0,FBr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var H0="0.1120.1";var ULo={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function HBr(e){return e?ULo[e]:"success.main"}function UBr(e){return e.split("-")[0].split(".").map(Number)}function VBr(e,t){if(!e||!t||e===t)return;let r=UBr(e),n=UBr(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var m4e=S(ie(),1),Uct=(0,m4e.createContext)(null);function g4e(){return(0,m4e.useContext)(Uct)}var zD=S(R(),1),VLo={height:16,fontSize:10},WLo={opacity:.6,fontSize:"0.85em"};function GLo(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function RR({nodes:e,name:t,showVersion:r=!1}){let n=g4e()??H0,o=e.links.find(a=>a.name===t),i=VBr(o?.peerVersion,n);return(0,zD.jsx)(pr,{title:GLo(e,t),placement:"right",children:(0,zD.jsxs)(W,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,zD.jsx)(zBr,{sx:{fontSize:8,color:HBr(o?.state)}}),t,r&&o?.peerVersion&&(0,zD.jsxs)(W,{component:"span",sx:WLo,children:["v",o.peerVersion]}),i&&(0,zD.jsx)(Hn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:VLo})]})})}var U0=S(R(),1),qLo={textTransform:"none"};function y4e({nodes:e,options:t,target:r,onPick:n}){let[o,i]=(0,WBr.useState)(null);return(0,U0.jsxs)(U0.Fragment,{children:[(0,U0.jsx)(it,{size:"small",color:"inherit",startIcon:(0,U0.jsx)(h4e,{fontSize:"small"}),"aria-label":"Start on node","aria-haspopup":"menu",onClick:a=>i(a.currentTarget),sx:qLo,children:(0,U0.jsx)(RR,{nodes:e,name:r.node})}),(0,U0.jsx)(oa,{anchorEl:o,open:!!o,onClose:()=>i(null),children:t.map(({name:a,cwd:s})=>(0,U0.jsx)(Xr,{disabled:!s,selected:a===r.node,onClick:()=>{n(a),i(null)},children:(0,U0.jsx)(Tf,{primary:(0,U0.jsx)(RR,{nodes:e,name:a}),secondary:s?void 0:"no clone"})},a))})]})}var GBr=S(ie(),1);function jLo(e,t){return e?.toLowerCase()===t.toLowerCase()}function v4e(e,t){let{nodes:r,names:n,visible:o}=Us(),{repos:i,selectedCwd:a,selectedNode:s,cloneOn:l,originOf:u}=An(),[d,f]=(0,GBr.useState)(),p=e&&u(e)?e:a,h=t?i.find(b=>jLo(u(b),t)):p,m=n.map(b=>({name:b,cwd:h?l(h,b):void 0})),g=b=>m.find(x=>x.name===b&&x.cwd),y=g(d)??g(s??r?.local)??m.find(b=>b.cwd),v=o&&y?.cwd?{node:y.name,cwd:y.cwd}:void 0;return{nodes:r,visible:o,options:m,target:v,pick:f}}var PR=S(R(),1);function qBr({canStart:e,startOrigin:t,cwd:r,onApprove:n,onApproveAndStart:o}){let i=xpe(),a=v4e(r,t);return(0,PR.jsxs)(PR.Fragment,{children:[(0,PR.jsx)(it,{color:"primary",variant:e?"tonal":"contained",onClick:n,...e?{}:i,children:"Approve"}),e&&a.nodes&&a.target&&(0,PR.jsx)(y4e,{nodes:a.nodes,options:a.options,target:a.target,onPick:a.pick}),e&&(0,PR.jsx)(it,{color:"primary",variant:"contained",onClick:()=>o(a.target),...i,children:"Approve & start"})]})}var Vct=S(R(),1),YLo={"& .MuiFormControlLabel-label":{fontSize:12}};function rie({label:e,title:t,checked:r,onChange:n}){return(0,Vct.jsx)(Ad,{control:(0,Vct.jsx)(Cp,{size:"small",checked:r,onChange:o=>n(o.target.checked)}),label:e,title:t,sx:YLo})}var HD=S(R(),1);function b4e({chain:e,newPr:t,onChange:r}){return(0,HD.jsxs)(kt,{direction:"row",sx:{mr:"auto"},children:[t&&(0,HD.jsx)(rie,{label:"Draft",title:"Create the PR as a draft rather than ready for review",checked:e.draft,onChange:n=>r({...e,draft:n,autoMerge:n?!1:e.autoMerge})}),(0,HD.jsx)(rie,{label:"Auto-merge (squash)",title:"Squash-merge the PR automatically once its required checks pass",checked:e.autoMerge,onChange:n=>r({...e,autoMerge:n,draft:n?!1:e.draft})}),(0,HD.jsx)(rie,{label:"Review PR",title:"After raising, run a review that posts its findings and then addresses them",checked:e.reviewAfter,onChange:n=>r({...e,reviewAfter:n})}),(0,HD.jsx)(rie,{label:"Post to Slack",title:"Announce the PR in Slack at the tail of the chain",checked:e.announceAfter,onChange:n=>r({...e,announceAfter:n})})]})}var UD=S(R(),1);function jBr({commentCount:e,chain:t,newPr:r,canStart:n,startOrigin:o,onChainChange:i,onApprove:a,cwd:s,onApproveAndStart:l,onReject:u,onRequestChanges:d}){return(0,UD.jsxs)(kt,{direction:"row",spacing:1,sx:{px:2,py:1.5,alignItems:"center",justifyContent:"flex-end"},children:[t&&(0,UD.jsx)(b4e,{chain:t,newPr:r,onChange:i}),(0,UD.jsx)(it,{color:"error",variant:"outlined",onClick:u,children:"Reject"}),e>0&&(0,UD.jsxs)(it,{color:"warning",variant:"tonal",onClick:d,children:["Request changes (",e,")"]}),(0,UD.jsx)(qBr,{canStart:n,startOrigin:o,cwd:s,onApprove:a,onApproveAndStart:l})]})}var KBr=S(R(),1);function YBr({comments:e,cwd:t,onDecision:r,chain:n,newPr:o,canStart:i,startOrigin:a,onChainChange:s}){let l=()=>e.map(u=>({quote:u.quote,note:u.note}));return(0,KBr.jsx)(jBr,{commentCount:e.length,chain:n,newPr:o,canStart:i,startOrigin:a,onChainChange:s,onApprove:()=>r("approve",l()),cwd:t,onApproveAndStart:u=>r("approve",l(),u??!0),onReject:()=>r("reject",[]),onRequestChanges:()=>r("reject",l())})}var hC=S(R(),1);function XBr(e){let{comments:t,commentColors:r,pending:n,cwd:o,unavailable:i,onAdd:a,onQueue:s,onCite:l,onAddRule:u,onRemove:d,onCancel:f,onCollapse:p,editable:h}=e;return(0,hC.jsxs)(hC.Fragment,{children:[(0,hC.jsx)(OBr,{comments:t,colors:r,onRemove:d}),(0,hC.jsx)(Kn,{}),(0,hC.jsx)(YBr,{...e}),(0,hC.jsx)(Ihe,{pending:n,editable:h,cwd:o,unavailable:i,onAdd:a,onQueue:s,onCite:l,onAddRule:u,onCancel:f,onCollapse:p})]})}var nie=S(R(),1),KLo={px:2,pb:2,display:"flex",alignItems:"center",gap:1.5,minWidth:0},XLo={color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function ZBr({url:e}){return(0,nie.jsxs)(W,{sx:KLo,children:[(0,nie.jsx)(it,{variant:"contained",href:e,target:"_blank",rel:"noopener noreferrer",sx:{flexShrink:0},children:"Open design \u2197"}),(0,nie.jsx)(Te,{variant:"body2",sx:XLo,title:e,children:e})]})}var Wct=S(R(),1);function QBr({preview:e}){let t=e.kind==="design"?e.metadata?.[0]?.url:void 0;return t?(0,Wct.jsx)(ZBr,{url:t}):(0,Wct.jsx)(MG,{items:e.metadata??[]})}function JBr({preview:e,pane:t,cwd:r,isPr:n,editable:o,sender:i,onCite:a,onAddRule:s}){return{comments:t.comments,commentColors:t.commentColors,pending:t.pending,cwd:r,unavailable:i.unavailable,onAdd:i.onSend,onQueue:t.onAdd,onCite:a,onAddRule:s,onRemove:t.remove,onCancel:t.onCancel,onCollapse:t.onCollapse,onDecision:t.onDecide,chain:n?t.chain:void 0,editable:o,newPr:n&&e.prNumber===null,canStart:e.kind==="backlog-item"&&e.canStart===!0,startOrigin:e.startOrigin,onChainChange:t.setChain}}function $G(e){let t=e??"pr";return{isPr:t==="pr",screenshots:t==="pr"||t==="github-issue",editable:t==="github-issue-edit",closeOnly:t==="show"}}function e$r(e,t){return e?`${e}:${t??"pr"}`:void 0}function x4e(e,t,r,n){return{...$G(e.kind),requestId:e.requestId,supersedes:e.supersedes,sessionId:t,cwd:r,onDecision:n,screenshotScope:e$r(t,e.kind),seededScreenshots:e.screenshots??[],chainDefaults:{draft:e.draft===!0,reviewAfter:e.reviewAfter??!0},initialBody:e.body}}function t$r(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&af(t,e,Swe({quote:r,note:o})),n()}}function r$r(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&af(t,e,vx(r,Che(o))),n()}}function S4e(e,t,r,n){return{onCite:r$r(e,t,r,n),onAddRule:t$r(e,t,r,n)}}function n$r(e){return{criteria:e.criteria,onCriteriaChange:e.writeCriteria,onCriteriaInsert:e.insertCriteria,onCriteriaConvert:e.convertCriteria}}var f$r=S(ie(),1);var mC=S(ie(),1);var o$r="assist:pr-preview-comments:",Gct=e=>`${o$r}${e}`;function qct(e){return sl(Gct(e))}function oie(e,t){Rl(Gct(e),t)}function T4e(e){wv(Gct(e))}function i$r(){bx(o$r)}function a$r(e){let t=LA(e),r="";for(let n=t.nextNode();n;n=t.nextNode())r+=n.textContent??"";return r}function ZLo(e,t,r){let n=-1;for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+1))(n===-1||Math.abs(o-r)<Math.abs(n-r))&&(n=o);return n}function s$r(e,t){return e.flatMap(r=>{let n=ZLo(t,r.quote,r.start);return n===-1?[]:[{...r,start:n,end:n+r.quote.length}]})}function l$r(e,t,r){let n=qct(e);if(n.length>0||!t||!r)return n;let o=s$r(qct(t),a$r(r));return oie(e,o),T4e(t),o}function c$r(e,t,r){let[n,o]=(0,mC.useState)([]),i=(0,mC.useRef)(0);(0,mC.useEffect)(()=>{i$r(),o(l$r(e,t,r.current).map(l=>({...l,id:i.current++})))},[e,t,r]);let a=(0,mC.useCallback)(l=>{o(u=>{let d=[...u,{...l,id:i.current++}];return oie(e,d),d})},[e]),s=(0,mC.useCallback)(l=>{o(u=>{let d=u.filter(f=>f.id!==l);return oie(e,d),d})},[e]);return{comments:n,add:a,remove:s}}function u$r(e,t){let r=e.map((i,a)=>NV(a).solid),n=NV(e.length).fill,o=e.map((i,a)=>({start:i.start,end:i.end,color:NV(a).fill,pin:String(a+1)}));return t&&o.push({start:t.start,end:t.end,color:n}),{commentColors:r,dragColor:n,ranges:o}}function d$r(e,t,r,n){return{onAdd:o=>{e&&t({quote:e.quote,note:o,start:e.start,end:e.end}),n()},onCollapse:()=>{e&&r(e.quote),n()}}}function p$r(e,t,r){let{wrapperRef:n,contentRef:o,pending:i,dragRects:a,onMouseDown:s,clear:l,select:u}=S5(),{comments:d,add:f,remove:p}=c$r(e,t,o),{commentColors:h,dragColor:m,ranges:g}=(0,f$r.useMemo)(()=>u$r(d,i),[d,i]),{onAdd:y,onCollapse:v}=d$r(i,f,r,l);return{wrapperRef:n,contentRef:o,onMouseDown:s,comments:d,commentColors:h,remove:p,pending:i,ranges:g,dragRects:a,dragColor:m,onAdd:y,onCollapse:v,onCancel:l,onSelect:u}}var C4e=S(ie(),1);var jct="assist:preview-screenshots:",Yct=e=>`${jct}${e}`,w4e=e=>`${jct}seeded:${e}`;function h$r(e){return e?(bx(jct),sl(Yct(e)).filter(t=>typeof t.path=="string")):[]}function VD(e,t){e&&Rl(Yct(e),t.map(({path:r,alt:n,group:o,contentType:i,seeded:a})=>({path:r,alt:n,group:o,contentType:i,seeded:a})))}function m$r(e){e&&(wv(Yct(e)),wv(w4e(e)))}var WD=S(ie(),1);var g$r={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"};function QLo(e){let t=e.split(".").pop()?.toLowerCase();return Object.entries(g$r).find(([,n])=>n===t)?.[0]??"application/octet-stream"}function y$r(e){return e.map(t=>({...t,contentType:QLo(t.path),seeded:!0}))}function v$r(e,t,r){if(!e)return y$r(r);let n=h$r(e);if(sl(w4e(e))[0]===t)return n;let o=[...y$r(r),...n.filter(i=>!i.seeded)];return VD(e,o),Rl(w4e(e),[t]),o}function b$r(e,t){let r=new URLSearchParams({path:e});return t&&r.set("node",t),U2(`/api/pr-preview/image?${r}`)}function x$r(e,t,r){let[n,o]=(0,WD.useState)([]),i=(0,WD.useRef)(0),a=hr(),s=(0,WD.useRef)(r);return s.current=r,(0,WD.useEffect)(()=>{o(v$r(e,t,s.current).map(l=>({...l,url:b$r(l.path,a),id:i.current++})))},[e,t,a]),{screenshots:n,setScreenshots:o,nextId:i}}var S$r=S(ie(),1);function T$r(e,t){return(0,S$r.useCallback)((r,n)=>{t(o=>{let i=o.map(a=>a.id===r?{...a,...n}:a);return VD(e,i),i})},[e,t])}function w$r(e,t,r){let{screenshots:n,setScreenshots:o,nextId:i}=x$r(e,t,r),a=(0,C4e.useCallback)(d=>{o(f=>{let p=[...f,{...d,id:i.current++}];return VD(e,p),p})},[e,o,i]),s=(0,C4e.useCallback)(d=>{o(f=>{let p=f.find(m=>m.id===d);p?.url.startsWith("blob:")&&URL.revokeObjectURL(p.url);let h=f.filter(m=>m.id!==d);return VD(e,h),h})},[e,o]),l=T$r(e,o),u=(0,C4e.useCallback)(()=>m$r(e),[e]);return{screenshots:n,add:a,remove:s,update:l,clearPersisted:u}}var FG=S(ie(),1);async function C$r(e,t,r){let n=new URLSearchParams;t&&n.set("cwd",t),r&&n.set("node",r),e instanceof File&&e.name&&n.set("name",e.name);let o=await er(`/api/pr-preview/upload-image?${n}`,{method:"POST",headers:{"Content-Type":e.type||"application/octet-stream"},body:e,timeoutMs:12e4}),i=await o.json().catch(()=>null);if(!o.ok||!i?.path)throw new Error(i?.error??"Failed to attach file");return{path:i.path,alt:i.alt??"screenshot"}}var R$r=S(ie(),1);function k$r(e){return e.startsWith("image/")||e.startsWith("video/")}function _$r(e){if(!e)return null;for(let t of e.items)if(t.kind==="file"&&k$r(t.type)){let r=t.getAsFile();if(r)return r}return null}function E$r(e){return e?Array.from(e.files).find(t=>k$r(t.type))??null:null}function P$r(e,t){return(0,R$r.useEffect)(()=>{if(!t)return;let o=i=>{let a=_$r(i.clipboardData);a&&(i.preventDefault(),e(a))};return globalThis.addEventListener("paste",o),()=>globalThis.removeEventListener("paste",o)},[e,t]),t?{onDrop:o=>{let i=E$r(o.dataTransfer);i&&(o.preventDefault(),e(i))},onDragOver:o=>{Array.from(o.dataTransfer.items).some(i=>i.kind==="file")&&o.preventDefault()}}:{onDrop:void 0,onDragOver:void 0}}function A$r(e,t,r){let[n,o]=(0,FG.useState)([]),i=(0,FG.useRef)(0),a=hr(),s=(0,FG.useCallback)(async d=>{let f=i.current++;o(p=>[...p.filter(h=>!h.error),{id:f}]);try{let p=await C$r(d,e,a);t({...p,url:URL.createObjectURL(d),contentType:d.type}),o(h=>h.filter(m=>m.id!==f))}catch(p){let h=p instanceof Error?p.message:"Failed to attach file";o(m=>m.map(g=>g.id===f?{id:f,error:h}:g))}},[e,a,t]),{onDrop:l,onDragOver:u}=P$r(s,r);return{uploads:n,onDrop:l,onDragOver:u}}function L$r({cwd:e,screenshots:t,screenshotScope:r,requestId:n,seededScreenshots:o}){let{screenshots:i,add:a,remove:s,update:l,clearPersisted:u}=w$r(t?r:void 0,n,t?o:[]),{uploads:d,onDrop:f,onDragOver:p}=A$r(e,a,t);return{screenshots:i,removeScreenshot:s,updateScreenshot:l,decision:{attachments:()=>i.map(({path:h,alt:m,group:g})=>g?{path:h,alt:m,group:g}:{path:h,alt:m}),clearPersisted:u},uploads:d,onDrop:f,onDragOver:p}}var z$r=S(ie(),1);var I$r="assist:pr-preview-chain:",Kct=e=>`${I$r}${e}`;function D$r(e){if(e)return sl(Kct(e))[0]}function M$r(e,t){e&&Rl(Kct(e),[t])}function N$r(e){e&&wv(Kct(e))}function O$r(){bx(I$r)}function B$r(e,t,r){if(!e)return{reviewAfter:!1,announceAfter:!1,draft:!1,autoMerge:!1};O$r();let n=D$r(t);return{reviewAfter:n?.reviewAfter??r.reviewAfter,announceAfter:n?.announceAfter??!0,draft:n?.draft??r.draft,autoMerge:n?.autoMerge??!1}}function $$r(e,t,r,n,o){return{comments:t,screenshots:n,reviewAfter:e&&r.reviewAfter,announceAfter:e&&r.announceAfter,draft:r.draft,autoMerge:e&&r.autoMerge,...o===void 0?{}:{body:o}}}function F$r(e,t){return!e||t===!1?{}:t===!0?{autostart:!0}:{autostart:!0,startOn:t}}function H$r(e,t,r,n,o,i,a){let[s,l]=(0,z$r.useState)(()=>B$r(n,t,o));return{chain:s,setChain:f=>{l(f),M$r(t,f)},onDecide:(f,p,h=!1)=>{let m=f==="approve";r(f,{...$$r(m,p,s,m?i.attachments():[],a()),...F$r(m,h)}),T4e(e),m&&(N$r(t),i.clearPersisted())}}}var Z$r=S(ie(),1);var JLo=/^ {0,3}#{1,6}[ \t]+acceptance criteria[ \t]*$/i,eIo=/^ {0,3}#{1,6}[ \t]/;function AR(e){let t=e.split(`
|
|
4006
4006
|
`),r=t.findIndex(a=>JLo.test(a));if(r===-1)return null;let n=r+1;for(;n<t.length&&!eIo.test(t[n]);)n+=1;let o=r+1;for(;o<n&&t[o].trim()==="";)o+=1;let i=n;for(;i>o&&t[i-1].trim()==="";)i-=1;return o===n&&(o=r+1,i=r+1),{before:t.slice(0,o),lines:t.slice(o,i),after:t.slice(i)}}function k4e(e){let t=0;for(let r of e)t+=r===" "?4:1;return t}function _4e(e){let t=[];return e.map(r=>{for(;t.length>0&&r<t[t.length-1];)t.pop();return(t.length===0||r>t[t.length-1])&&t.push(r),t.length-1})}var tIo=" ";function rIo({text:e,depth:t}){let r=`${tIo.repeat(t)}1.`;return e===""?r:`${r} ${e}`}function E4e(e,t){let r=AR(e);return r?[...r.before,...t.map(rIo),...r.after].join(`
|
|
4007
4007
|
`):e}var nIo=/^([ \t]*)(?:[-*+]|\d+[.)])(?:[ \t]+(.*))?$/,oIo=/^\[[ xX]\][ \t]*/;function iIo(e){return e.slice(0,e.length-e.trimStart().length)}function U$r(e){let t=AR(e);if(!t)return e;let r=t.lines.filter(o=>o.trim()!=="").map(o=>{let i=nIo.exec(o);return{width:k4e(i?i[1]:iIo(o)),text:(i?i[2]??"":o.trim()).replace(oIo,"")}}),n=_4e(r.map(o=>o.width));return E4e(e,_R(r.map((o,i)=>({text:o.text,depth:n[i]}))))}var V$r=`## Acceptance criteria
|
|
4008
4008
|
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.1120.
|
|
9
|
+
version: "0.1120.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3301,6 +3301,64 @@ async function cleanupFalseResetSegments(db) {
|
|
|
3301
3301
|
});
|
|
3302
3302
|
}
|
|
3303
3303
|
|
|
3304
|
+
// src/shared/db/describeDatabaseUrlSource.ts
|
|
3305
|
+
function hasDatabaseUrl(path120) {
|
|
3306
|
+
const database = loadRawYaml(path120).database;
|
|
3307
|
+
return database?.url !== void 0;
|
|
3308
|
+
}
|
|
3309
|
+
function describeDatabaseUrlSource(cwd = process.cwd(), globalConfigPath = getGlobalConfigPath()) {
|
|
3310
|
+
if (process.env.ASSIST_DATABASE_URL)
|
|
3311
|
+
return "ASSIST_DATABASE_URL (environment variable)";
|
|
3312
|
+
const projectPath = projectConfigPathFrom(cwd);
|
|
3313
|
+
if (hasDatabaseUrl(projectPath))
|
|
3314
|
+
return `database.url in repo (git), ${projectPath}`;
|
|
3315
|
+
if (hasDatabaseUrl(globalConfigPath))
|
|
3316
|
+
return `database.url in user (node), ${globalConfigPath}`;
|
|
3317
|
+
return "database.url";
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
// src/shared/db/DatabaseConnectionError.ts
|
|
3321
|
+
var CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
3322
|
+
"ENOTFOUND",
|
|
3323
|
+
"EAI_AGAIN",
|
|
3324
|
+
"ECONNREFUSED",
|
|
3325
|
+
"ECONNRESET",
|
|
3326
|
+
"ETIMEDOUT",
|
|
3327
|
+
"EHOSTUNREACH",
|
|
3328
|
+
"ENETUNREACH",
|
|
3329
|
+
"28P01",
|
|
3330
|
+
"28000",
|
|
3331
|
+
"3D000"
|
|
3332
|
+
]);
|
|
3333
|
+
function firstCause(error) {
|
|
3334
|
+
if (error instanceof AggregateError) return error.errors[0];
|
|
3335
|
+
return typeof error === "object" && error !== null ? error : void 0;
|
|
3336
|
+
}
|
|
3337
|
+
function connectionFailure(error) {
|
|
3338
|
+
const cause = firstCause(error);
|
|
3339
|
+
const code = error?.code ?? cause?.code ?? void 0;
|
|
3340
|
+
const message4 = String(cause?.message ?? "");
|
|
3341
|
+
if (typeof code === "string" && CONNECTION_ERROR_CODES.has(code))
|
|
3342
|
+
return message4.includes(code) ? message4 : `${message4} (${code})`;
|
|
3343
|
+
if (/connection timeout|timeout expired/i.test(message4)) return message4;
|
|
3344
|
+
return void 0;
|
|
3345
|
+
}
|
|
3346
|
+
var DatabaseConnectionError = class extends Error {
|
|
3347
|
+
constructor(failure2, source) {
|
|
3348
|
+
super(
|
|
3349
|
+
`Could not connect to the assist database: ${failure2}
|
|
3350
|
+
The connection string comes from ${source}.`
|
|
3351
|
+
);
|
|
3352
|
+
this.name = "DatabaseConnectionError";
|
|
3353
|
+
}
|
|
3354
|
+
};
|
|
3355
|
+
function toDatabaseConnectionError(error) {
|
|
3356
|
+
if (error instanceof DatabaseConnectionError) return error;
|
|
3357
|
+
const failure2 = connectionFailure(error);
|
|
3358
|
+
if (!failure2) return error;
|
|
3359
|
+
return new DatabaseConnectionError(failure2, describeDatabaseUrlSource());
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3304
3362
|
// src/shared/db/Db.ts
|
|
3305
3363
|
import {
|
|
3306
3364
|
drizzle as drizzleNodePg
|
|
@@ -3803,7 +3861,11 @@ function createPool() {
|
|
|
3803
3861
|
return pool;
|
|
3804
3862
|
}
|
|
3805
3863
|
async function initDb(pool) {
|
|
3806
|
-
|
|
3864
|
+
try {
|
|
3865
|
+
await assertMigrationsInSync(pgExecutor(pool));
|
|
3866
|
+
} catch (error) {
|
|
3867
|
+
throw toDatabaseConnectionError(error);
|
|
3868
|
+
}
|
|
3807
3869
|
const orm = makeOrmFromPool(pool);
|
|
3808
3870
|
await seedNewsFeeds(orm);
|
|
3809
3871
|
await runUsagePeakCleanup(orm);
|
|
@@ -11061,15 +11123,14 @@ function configHelpForKey(key) {
|
|
|
11061
11123
|
|
|
11062
11124
|
// src/commands/config/isGlobalOnlyConfigKey.ts
|
|
11063
11125
|
var GLOBAL_ONLY_KEYS = ["sync.autoConfirm", "inbox.intervalMinutes"];
|
|
11126
|
+
var GLOBAL_ONLY_ROOTS = ["database"];
|
|
11064
11127
|
function isGlobalOnlyConfigKey(key) {
|
|
11065
|
-
return GLOBAL_ONLY_KEYS.some((k) => key.startsWith(k));
|
|
11128
|
+
return GLOBAL_ONLY_KEYS.some((k) => key.startsWith(k)) || GLOBAL_ONLY_ROOTS.includes(key.split(".")[0]);
|
|
11066
11129
|
}
|
|
11067
11130
|
|
|
11068
11131
|
// src/commands/config/isNodeOnlyConfigKey.ts
|
|
11069
|
-
var DB_EXCLUDED_ROOTS = ["repos", "database"];
|
|
11070
11132
|
function isNodeOnlyConfigKey(key) {
|
|
11071
|
-
|
|
11072
|
-
return isGlobalOnlyConfigKey(key) || DB_EXCLUDED_ROOTS.includes(root2);
|
|
11133
|
+
return isGlobalOnlyConfigKey(key) || key.split(".")[0] === "repos";
|
|
11073
11134
|
}
|
|
11074
11135
|
|
|
11075
11136
|
// src/commands/config/configWritableScopes.ts
|
|
@@ -30435,17 +30496,37 @@ function registerComplexity(program) {
|
|
|
30435
30496
|
// src/commands/configList.ts
|
|
30436
30497
|
import chalk136 from "chalk";
|
|
30437
30498
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
30499
|
+
async function loadListedConfig() {
|
|
30500
|
+
const fileConfig = loadConfig();
|
|
30501
|
+
try {
|
|
30502
|
+
return {
|
|
30503
|
+
config: await withDbBackedConfigValues(fileConfig, dbBackedKeysIn())
|
|
30504
|
+
};
|
|
30505
|
+
} catch (error) {
|
|
30506
|
+
const reported2 = toDatabaseConnectionError(error);
|
|
30507
|
+
if (!(reported2 instanceof DatabaseConnectionError)) throw error;
|
|
30508
|
+
return { config: fileConfig, dbError: reported2.message };
|
|
30509
|
+
}
|
|
30510
|
+
}
|
|
30438
30511
|
async function configList() {
|
|
30439
|
-
const config =
|
|
30440
|
-
await withDbBackedConfigValues(loadConfig(), dbBackedKeysIn()),
|
|
30441
|
-
describeConfigNode(assistConfigSchema)
|
|
30442
|
-
);
|
|
30512
|
+
const { config, dbError } = await loadListedConfig();
|
|
30443
30513
|
console.log(
|
|
30444
30514
|
chalk136.dim(
|
|
30445
30515
|
"# Only the keys that are set; run assist config keys for every key and its default"
|
|
30446
30516
|
)
|
|
30447
30517
|
);
|
|
30448
|
-
|
|
30518
|
+
if (dbError)
|
|
30519
|
+
console.log(
|
|
30520
|
+
chalk136.yellow(
|
|
30521
|
+
`# DB-backed values could not be loaded; showing file-backed config only.
|
|
30522
|
+
# ${dbError.replaceAll("\n", "\n# ")}`
|
|
30523
|
+
)
|
|
30524
|
+
);
|
|
30525
|
+
const masked = maskConfigSecrets(
|
|
30526
|
+
config,
|
|
30527
|
+
describeConfigNode(assistConfigSchema)
|
|
30528
|
+
);
|
|
30529
|
+
console.log(stringifyYaml2(masked, { lineWidth: 0 }).trimEnd());
|
|
30449
30530
|
}
|
|
30450
30531
|
|
|
30451
30532
|
// src/commands/config/configGet.ts
|
|
@@ -30478,6 +30559,8 @@ function printValue(config, key, options2) {
|
|
|
30478
30559
|
console.log(
|
|
30479
30560
|
formatOutput(options2.reveal ? value : maskConfigKeySecrets(key, value))
|
|
30480
30561
|
);
|
|
30562
|
+
if (key === "database" || key.startsWith("database."))
|
|
30563
|
+
console.error(chalk137.dim(`from ${describeDatabaseUrlSource()}`));
|
|
30481
30564
|
}
|
|
30482
30565
|
function formatOutput(value) {
|
|
30483
30566
|
return typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);
|
|
@@ -30812,6 +30895,12 @@ function coerceWithoutSchemaLeaf(raw) {
|
|
|
30812
30895
|
return raw;
|
|
30813
30896
|
}
|
|
30814
30897
|
|
|
30898
|
+
// src/commands/config/defaultsToNode.ts
|
|
30899
|
+
function defaultsToNode(key, options2) {
|
|
30900
|
+
if (options2.node) return true;
|
|
30901
|
+
return isGlobalOnlyConfigKey(key) && options2.repo === void 0 && !options2.user;
|
|
30902
|
+
}
|
|
30903
|
+
|
|
30815
30904
|
// src/commands/config/resolveRepoTarget.ts
|
|
30816
30905
|
function resolveRepoTarget(key, value, repo) {
|
|
30817
30906
|
if (typeof repo === "string") {
|
|
@@ -30882,7 +30971,7 @@ async function configSet(key, value, options2 = {}) {
|
|
|
30882
30971
|
await setFileConfigKey(
|
|
30883
30972
|
{
|
|
30884
30973
|
...resolved,
|
|
30885
|
-
node:
|
|
30974
|
+
node: defaultsToNode(resolved.key, options2),
|
|
30886
30975
|
user: options2.user ?? false
|
|
30887
30976
|
},
|
|
30888
30977
|
coercion.value
|
|
@@ -30951,7 +31040,7 @@ async function configUnset(key, options2 = {}) {
|
|
|
30951
31040
|
key: resolved.key,
|
|
30952
31041
|
useRepo: resolved.useRepo,
|
|
30953
31042
|
repoName: resolved.repoName,
|
|
30954
|
-
node:
|
|
31043
|
+
node: defaultsToNode(resolved.key, options2),
|
|
30955
31044
|
user: options2.user ?? false
|
|
30956
31045
|
});
|
|
30957
31046
|
}
|
|
@@ -31622,6 +31711,8 @@ async function withPool(fn) {
|
|
|
31622
31711
|
const pool = createPool();
|
|
31623
31712
|
try {
|
|
31624
31713
|
await fn(pgExecutor(pool));
|
|
31714
|
+
} catch (error) {
|
|
31715
|
+
throw toDatabaseConnectionError(error);
|
|
31625
31716
|
} finally {
|
|
31626
31717
|
await pool.end();
|
|
31627
31718
|
}
|
|
@@ -63748,7 +63839,7 @@ function createProgram() {
|
|
|
63748
63839
|
// src/reportCliError.ts
|
|
63749
63840
|
import chalk300 from "chalk";
|
|
63750
63841
|
function reportCliError(error) {
|
|
63751
|
-
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError || error instanceof MissingDatabaseUrlError) {
|
|
63842
|
+
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError || error instanceof MissingDatabaseUrlError || error instanceof DatabaseConnectionError) {
|
|
63752
63843
|
console.error(chalk300.red(error.message));
|
|
63753
63844
|
} else {
|
|
63754
63845
|
console.error(error);
|