oh-my-pr 3.2.3 → 4.0.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.
@@ -45,4 +45,4 @@ Error generating stack: `+f.message+`
45
45
  `)},Sh=function(){var t=parseInt(document.body.getAttribute(Dr)||"0",10);return isFinite(t)?t:0},nk=function(){m.useEffect(function(){return document.body.setAttribute(Dr,(Sh()+1).toString()),function(){var t=Sh()-1;t<=0?document.body.removeAttribute(Dr):document.body.setAttribute(Dr,t.toString())}},[])},rk=function(t){var r=t.noRelative,s=t.noImportant,a=t.gapMode,l=a===void 0?"margin":a;nk();var d=m.useMemo(function(){return JC(l)},[l]);return m.createElement(ek,{styles:tk(d,!r,l,s?"":"!important")})},Au=!1;if(typeof window<"u")try{var pi=Object.defineProperty({},"passive",{get:function(){return Au=!0,!0}});window.addEventListener("test",pi,pi),window.removeEventListener("test",pi,pi)}catch{Au=!1}var Or=Au?{passive:!1}:!1,ok=function(t){return t.tagName==="TEXTAREA"},zg=function(t,r){if(!(t instanceof Element))return!1;var s=window.getComputedStyle(t);return s[r]!=="hidden"&&!(s.overflowY===s.overflowX&&!ok(t)&&s[r]==="visible")},sk=function(t){return zg(t,"overflowY")},ik=function(t){return zg(t,"overflowX")},Ch=function(t,r){var s=r.ownerDocument,a=r;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var l=Ug(t,a);if(l){var d=Hg(t,a),p=d[1],h=d[2];if(p>h)return!0}a=a.parentNode}while(a&&a!==s.body);return!1},ak=function(t){var r=t.scrollTop,s=t.scrollHeight,a=t.clientHeight;return[r,s,a]},lk=function(t){var r=t.scrollLeft,s=t.scrollWidth,a=t.clientWidth;return[r,s,a]},Ug=function(t,r){return t==="v"?sk(r):ik(r)},Hg=function(t,r){return t==="v"?ak(r):lk(r)},uk=function(t,r){return t==="h"&&r==="rtl"?-1:1},ck=function(t,r,s,a,l){var d=uk(t,window.getComputedStyle(r).direction),p=d*a,h=s.target,y=r.contains(h),v=!1,g=p>0,w=0,b=0;do{if(!h)break;var E=Hg(t,h),N=E[0],S=E[1],C=E[2],_=S-C-d*N;(N||_)&&Ug(t,h)&&(w+=_,b+=N);var A=h.parentNode;h=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!y&&h!==document.body||y&&(r.contains(h)||r===h));return(g&&Math.abs(w)<1||!g&&Math.abs(b)<1)&&(v=!0),v},hi=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},kh=function(t){return[t.deltaX,t.deltaY]},Eh=function(t){return t&&"current"in t?t.current:t},dk=function(t,r){return t[0]===r[0]&&t[1]===r[1]},fk=function(t){return`
46
46
  .block-interactivity-`.concat(t,` {pointer-events: none;}
47
47
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
48
- `)},pk=0,Ar=[];function hk(t){var r=m.useRef([]),s=m.useRef([0,0]),a=m.useRef(),l=m.useState(pk++)[0],d=m.useState($g)[0],p=m.useRef(t);m.useEffect(function(){p.current=t},[t]),m.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(l));var S=IC([t.lockRef.current],(t.shards||[]).map(Eh),!0).filter(Boolean);return S.forEach(function(C){return C.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),S.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(l))})}}},[t.inert,t.lockRef.current,t.shards]);var h=m.useCallback(function(S,C){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!p.current.allowPinchZoom;var _=hi(S),A=s.current,O="deltaX"in S?S.deltaX:A[0]-_[0],I="deltaY"in S?S.deltaY:A[1]-_[1],F,L=S.target,U=Math.abs(O)>Math.abs(I)?"h":"v";if("touches"in S&&U==="h"&&L.type==="range")return!1;var q=window.getSelection(),te=q&&q.anchorNode,ne=te?te===L||te.contains(L):!1;if(ne)return!1;var se=Ch(U,L);if(!se)return!0;if(se?F=U:(F=U==="v"?"h":"v",se=Ch(U,L)),!se)return!1;if(!a.current&&"changedTouches"in S&&(O||I)&&(a.current=F),!F)return!0;var Y=a.current||F;return ck(Y,C,S,Y==="h"?O:I)},[]),y=m.useCallback(function(S){var C=S;if(!(!Ar.length||Ar[Ar.length-1]!==d)){var _="deltaY"in C?kh(C):hi(C),A=r.current.filter(function(F){return F.name===C.type&&(F.target===C.target||C.target===F.shadowParent)&&dk(F.delta,_)})[0];if(A&&A.should){C.cancelable&&C.preventDefault();return}if(!A){var O=(p.current.shards||[]).map(Eh).filter(Boolean).filter(function(F){return F.contains(C.target)}),I=O.length>0?h(C,O[0]):!p.current.noIsolation;I&&C.cancelable&&C.preventDefault()}}},[]),v=m.useCallback(function(S,C,_,A){var O={name:S,delta:C,target:_,should:A,shadowParent:mk(_)};r.current.push(O),setTimeout(function(){r.current=r.current.filter(function(I){return I!==O})},1)},[]),g=m.useCallback(function(S){s.current=hi(S),a.current=void 0},[]),w=m.useCallback(function(S){v(S.type,kh(S),S.target,h(S,t.lockRef.current))},[]),b=m.useCallback(function(S){v(S.type,hi(S),S.target,h(S,t.lockRef.current))},[]);m.useEffect(function(){return Ar.push(d),t.setCallbacks({onScrollCapture:w,onWheelCapture:w,onTouchMoveCapture:b}),document.addEventListener("wheel",y,Or),document.addEventListener("touchmove",y,Or),document.addEventListener("touchstart",g,Or),function(){Ar=Ar.filter(function(S){return S!==d}),document.removeEventListener("wheel",y,Or),document.removeEventListener("touchmove",y,Or),document.removeEventListener("touchstart",g,Or)}},[]);var E=t.removeScrollBar,N=t.inert;return m.createElement(m.Fragment,null,N?m.createElement(d,{styles:fk(l)}):null,E?m.createElement(rk,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function mk(t){for(var r=null;t!==null;)t instanceof ShadowRoot&&(r=t.host,t=t.host),t=t.parentNode;return r}const gk=WC(Fg,hk);var Bg=m.forwardRef(function(t,r){return m.createElement(Wi,Bt({},t,{ref:r,sideCar:gk}))});Bg.classNames=Wi.classNames;var Mu=["Enter"," "],vk=["ArrowDown","PageUp","Home"],Wg=["ArrowUp","PageDown","End"],yk=[...vk,...Wg],xk={ltr:[...Mu,"ArrowRight"],rtl:[...Mu,"ArrowLeft"]},wk={ltr:["ArrowLeft"],rtl:["ArrowRight"]},qo="Menu",[Ho,bk,Sk]=Qu(qo),[rr,Kg]=Ln(qo,[Sk,Fi,Tg]),Ki=Fi(),Vg=Tg(),[Ck,or]=rr(qo),[kk,Yo]=rr(qo),Qg=t=>{const{__scopeMenu:r,open:s=!1,children:a,dir:l,onOpenChange:d,modal:p=!0}=t,h=Ki(r),[y,v]=m.useState(null),g=m.useRef(!1),w=yt(d),b=Ng(l);return m.useEffect(()=>{const E=()=>{g.current=!0,document.addEventListener("pointerdown",N,{capture:!0,once:!0}),document.addEventListener("pointermove",N,{capture:!0,once:!0})},N=()=>g.current=!1;return document.addEventListener("keydown",E,{capture:!0}),()=>{document.removeEventListener("keydown",E,{capture:!0}),document.removeEventListener("pointerdown",N,{capture:!0}),document.removeEventListener("pointermove",N,{capture:!0})}},[]),u.jsx(sg,{...h,children:u.jsx(Ck,{scope:r,open:s,onOpenChange:w,content:y,onContentChange:v,children:u.jsx(kk,{scope:r,onClose:m.useCallback(()=>w(!1),[w]),isUsingKeyboardRef:g,dir:b,modal:p,children:a})})})};Qg.displayName=qo;var Ek="MenuAnchor",fc=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t,l=Ki(s);return u.jsx(ig,{...l,...a,ref:r})});fc.displayName=Ek;var pc="MenuPortal",[Nk,Gg]=rr(pc,{forceMount:void 0}),qg=t=>{const{__scopeMenu:r,forceMount:s,children:a,container:l}=t,d=or(pc,r);return u.jsx(Nk,{scope:r,forceMount:s,children:u.jsx(Fn,{present:s||d.open,children:u.jsx(qu,{asChild:!0,container:l,children:a})})})};qg.displayName=pc;var Nt="MenuContent",[Rk,hc]=rr(Nt),Yg=m.forwardRef((t,r)=>{const s=Gg(Nt,t.__scopeMenu),{forceMount:a=s.forceMount,...l}=t,d=or(Nt,t.__scopeMenu),p=Yo(Nt,t.__scopeMenu);return u.jsx(Ho.Provider,{scope:t.__scopeMenu,children:u.jsx(Fn,{present:a||d.open,children:u.jsx(Ho.Slot,{scope:t.__scopeMenu,children:p.modal?u.jsx(Pk,{...l,ref:r}):u.jsx(jk,{...l,ref:r})})})})}),Pk=m.forwardRef((t,r)=>{const s=or(Nt,t.__scopeMenu),a=m.useRef(null),l=He(r,a);return m.useEffect(()=>{const d=a.current;if(d)return MC(d)},[]),u.jsx(mc,{...t,ref:l,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:ce(t.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),jk=m.forwardRef((t,r)=>{const s=or(Nt,t.__scopeMenu);return u.jsx(mc,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),Tk=EC("MenuContent.ScrollLock"),mc=m.forwardRef((t,r)=>{const{__scopeMenu:s,loop:a=!1,trapFocus:l,onOpenAutoFocus:d,onCloseAutoFocus:p,disableOutsidePointerEvents:h,onEntryFocus:y,onEscapeKeyDown:v,onPointerDownOutside:g,onFocusOutside:w,onInteractOutside:b,onDismiss:E,disableOutsideScroll:N,...S}=t,C=or(Nt,s),_=Yo(Nt,s),A=Ki(s),O=Vg(s),I=bk(s),[F,L]=m.useState(null),U=m.useRef(null),q=He(r,U,C.onContentChange),te=m.useRef(0),ne=m.useRef(""),se=m.useRef(0),Y=m.useRef(null),ae=m.useRef("right"),G=m.useRef(0),me=N?Bg:m.Fragment,ee=N?{as:Tk,allowPinchZoom:!0}:void 0,ie=z=>{const V=ne.current+z,T=I().filter(he=>!he.disabled),H=document.activeElement,de=T.find(he=>he.ref.current===H)?.textValue,pe=T.map(he=>he.textValue),xe=Hk(pe,V,de),ve=T.find(he=>he.textValue===xe)?.ref.current;(function he(be){ne.current=be,window.clearTimeout(te.current),be!==""&&(te.current=window.setTimeout(()=>he(""),1e3))})(V),ve&&setTimeout(()=>ve.focus())};m.useEffect(()=>()=>window.clearTimeout(te.current),[]),sC();const P=m.useCallback(z=>ae.current===Y.current?.side&&Wk(z,Y.current?.area),[]);return u.jsx(Rk,{scope:s,searchRef:ne,onItemEnter:m.useCallback(z=>{P(z)&&z.preventDefault()},[P]),onItemLeave:m.useCallback(z=>{P(z)||(U.current?.focus(),L(null))},[P]),onTriggerLeave:m.useCallback(z=>{P(z)&&z.preventDefault()},[P]),pointerGraceTimerRef:se,onPointerGraceIntentChange:m.useCallback(z=>{Y.current=z},[]),children:u.jsx(me,{...ee,children:u.jsx(Rg,{asChild:!0,trapped:l,onMountAutoFocus:ce(d,z=>{z.preventDefault(),U.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:p,children:u.jsx(_i,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:v,onPointerDownOutside:g,onFocusOutside:w,onInteractOutside:b,onDismiss:E,children:u.jsx(CC,{asChild:!0,...O,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:F,onCurrentTabStopIdChange:L,onEntryFocus:ce(y,z=>{_.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ag,{role:"menu","aria-orientation":"vertical","data-state":fv(C.open),"data-radix-menu-content":"",dir:_.dir,...A,...S,ref:q,style:{outline:"none",...S.style},onKeyDown:ce(S.onKeyDown,z=>{const T=z.target.closest("[data-radix-menu-content]")===z.currentTarget,H=z.ctrlKey||z.altKey||z.metaKey,de=z.key.length===1;T&&(z.key==="Tab"&&z.preventDefault(),!H&&de&&ie(z.key));const pe=U.current;if(z.target!==pe||!yk.includes(z.key))return;z.preventDefault();const ve=I().filter(he=>!he.disabled).map(he=>he.ref.current);Wg.includes(z.key)&&ve.reverse(),zk(ve)}),onBlur:ce(t.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(te.current),ne.current="")}),onPointerMove:ce(t.onPointerMove,Bo(z=>{const V=z.target,T=G.current!==z.clientX;if(z.currentTarget.contains(V)&&T){const H=z.clientX>G.current?"right":"left";ae.current=H,G.current=z.clientX}}))})})})})})})});Yg.displayName=Nt;var _k="MenuGroup",gc=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t;return u.jsx(Re.div,{role:"group",...a,ref:r})});gc.displayName=_k;var Ok="MenuLabel",Xg=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t;return u.jsx(Re.div,{...a,ref:r})});Xg.displayName=Ok;var Ni="MenuItem",Nh="menu.itemSelect",Vi=m.forwardRef((t,r)=>{const{disabled:s=!1,onSelect:a,...l}=t,d=m.useRef(null),p=Yo(Ni,t.__scopeMenu),h=hc(Ni,t.__scopeMenu),y=He(r,d),v=m.useRef(!1),g=()=>{const w=d.current;if(!s&&w){const b=new CustomEvent(Nh,{bubbles:!0,cancelable:!0});w.addEventListener(Nh,E=>a?.(E),{once:!0}),Gu(w,b),b.defaultPrevented?v.current=!1:p.onClose()}};return u.jsx(Zg,{...l,ref:y,disabled:s,onClick:ce(t.onClick,g),onPointerDown:w=>{t.onPointerDown?.(w),v.current=!0},onPointerUp:ce(t.onPointerUp,w=>{v.current||w.currentTarget?.click()}),onKeyDown:ce(t.onKeyDown,w=>{const b=h.searchRef.current!=="";s||b&&w.key===" "||Mu.includes(w.key)&&(w.currentTarget.click(),w.preventDefault())})})});Vi.displayName=Ni;var Zg=m.forwardRef((t,r)=>{const{__scopeMenu:s,disabled:a=!1,textValue:l,...d}=t,p=hc(Ni,s),h=Vg(s),y=m.useRef(null),v=He(r,y),[g,w]=m.useState(!1),[b,E]=m.useState("");return m.useEffect(()=>{const N=y.current;N&&E((N.textContent??"").trim())},[d.children]),u.jsx(Ho.ItemSlot,{scope:s,disabled:a,textValue:l??b,children:u.jsx(kC,{asChild:!0,...h,focusable:!a,children:u.jsx(Re.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...d,ref:v,onPointerMove:ce(t.onPointerMove,Bo(N=>{a?p.onItemLeave(N):(p.onItemEnter(N),N.defaultPrevented||N.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(t.onPointerLeave,Bo(N=>p.onItemLeave(N))),onFocus:ce(t.onFocus,()=>w(!0)),onBlur:ce(t.onBlur,()=>w(!1))})})})}),Ak="MenuCheckboxItem",Jg=m.forwardRef((t,r)=>{const{checked:s=!1,onCheckedChange:a,...l}=t;return u.jsx(ov,{scope:t.__scopeMenu,checked:s,children:u.jsx(Vi,{role:"menuitemcheckbox","aria-checked":Ri(s)?"mixed":s,...l,ref:r,"data-state":yc(s),onSelect:ce(l.onSelect,()=>a?.(Ri(s)?!0:!s),{checkForDefaultPrevented:!1})})})});Jg.displayName=Ak;var ev="MenuRadioGroup",[Mk,Ik]=rr(ev,{value:void 0,onValueChange:()=>{}}),tv=m.forwardRef((t,r)=>{const{value:s,onValueChange:a,...l}=t,d=yt(a);return u.jsx(Mk,{scope:t.__scopeMenu,value:s,onValueChange:d,children:u.jsx(gc,{...l,ref:r})})});tv.displayName=ev;var nv="MenuRadioItem",rv=m.forwardRef((t,r)=>{const{value:s,...a}=t,l=Ik(nv,t.__scopeMenu),d=s===l.value;return u.jsx(ov,{scope:t.__scopeMenu,checked:d,children:u.jsx(Vi,{role:"menuitemradio","aria-checked":d,...a,ref:r,"data-state":yc(d),onSelect:ce(a.onSelect,()=>l.onValueChange?.(s),{checkForDefaultPrevented:!1})})})});rv.displayName=nv;var vc="MenuItemIndicator",[ov,Dk]=rr(vc,{checked:!1}),sv=m.forwardRef((t,r)=>{const{__scopeMenu:s,forceMount:a,...l}=t,d=Dk(vc,s);return u.jsx(Fn,{present:a||Ri(d.checked)||d.checked===!0,children:u.jsx(Re.span,{...l,ref:r,"data-state":yc(d.checked)})})});sv.displayName=vc;var Lk="MenuSeparator",iv=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t;return u.jsx(Re.div,{role:"separator","aria-orientation":"horizontal",...a,ref:r})});iv.displayName=Lk;var Fk="MenuArrow",av=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t,l=Ki(s);return u.jsx(lg,{...l,...a,ref:r})});av.displayName=Fk;var $k="MenuSub",[DN,lv]=rr($k),Do="MenuSubTrigger",uv=m.forwardRef((t,r)=>{const s=or(Do,t.__scopeMenu),a=Yo(Do,t.__scopeMenu),l=lv(Do,t.__scopeMenu),d=hc(Do,t.__scopeMenu),p=m.useRef(null),{pointerGraceTimerRef:h,onPointerGraceIntentChange:y}=d,v={__scopeMenu:t.__scopeMenu},g=m.useCallback(()=>{p.current&&window.clearTimeout(p.current),p.current=null},[]);return m.useEffect(()=>g,[g]),m.useEffect(()=>{const w=h.current;return()=>{window.clearTimeout(w),y(null)}},[h,y]),u.jsx(fc,{asChild:!0,...v,children:u.jsx(Zg,{id:l.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":l.contentId,"data-state":fv(s.open),...t,ref:zr(r,l.onTriggerChange),onClick:w=>{t.onClick?.(w),!(t.disabled||w.defaultPrevented)&&(w.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:ce(t.onPointerMove,Bo(w=>{d.onItemEnter(w),!w.defaultPrevented&&!t.disabled&&!s.open&&!p.current&&(d.onPointerGraceIntentChange(null),p.current=window.setTimeout(()=>{s.onOpenChange(!0),g()},100))})),onPointerLeave:ce(t.onPointerLeave,Bo(w=>{g();const b=s.content?.getBoundingClientRect();if(b){const E=s.content?.dataset.side,N=E==="right",S=N?-5:5,C=b[N?"left":"right"],_=b[N?"right":"left"];d.onPointerGraceIntentChange({area:[{x:w.clientX+S,y:w.clientY},{x:C,y:b.top},{x:_,y:b.top},{x:_,y:b.bottom},{x:C,y:b.bottom}],side:E}),window.clearTimeout(h.current),h.current=window.setTimeout(()=>d.onPointerGraceIntentChange(null),300)}else{if(d.onTriggerLeave(w),w.defaultPrevented)return;d.onPointerGraceIntentChange(null)}})),onKeyDown:ce(t.onKeyDown,w=>{const b=d.searchRef.current!=="";t.disabled||b&&w.key===" "||xk[a.dir].includes(w.key)&&(s.onOpenChange(!0),s.content?.focus(),w.preventDefault())})})})});uv.displayName=Do;var cv="MenuSubContent",dv=m.forwardRef((t,r)=>{const s=Gg(Nt,t.__scopeMenu),{forceMount:a=s.forceMount,...l}=t,d=or(Nt,t.__scopeMenu),p=Yo(Nt,t.__scopeMenu),h=lv(cv,t.__scopeMenu),y=m.useRef(null),v=He(r,y);return u.jsx(Ho.Provider,{scope:t.__scopeMenu,children:u.jsx(Fn,{present:a||d.open,children:u.jsx(Ho.Slot,{scope:t.__scopeMenu,children:u.jsx(mc,{id:h.contentId,"aria-labelledby":h.triggerId,...l,ref:v,align:"start",side:p.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:g=>{p.isUsingKeyboardRef.current&&y.current?.focus(),g.preventDefault()},onCloseAutoFocus:g=>g.preventDefault(),onFocusOutside:ce(t.onFocusOutside,g=>{g.target!==h.trigger&&d.onOpenChange(!1)}),onEscapeKeyDown:ce(t.onEscapeKeyDown,g=>{p.onClose(),g.preventDefault()}),onKeyDown:ce(t.onKeyDown,g=>{const w=g.currentTarget.contains(g.target),b=wk[p.dir].includes(g.key);w&&b&&(d.onOpenChange(!1),h.trigger?.focus(),g.preventDefault())})})})})})});dv.displayName=cv;function fv(t){return t?"open":"closed"}function Ri(t){return t==="indeterminate"}function yc(t){return Ri(t)?"indeterminate":t?"checked":"unchecked"}function zk(t){const r=document.activeElement;for(const s of t)if(s===r||(s.focus(),document.activeElement!==r))return}function Uk(t,r){return t.map((s,a)=>t[(r+a)%t.length])}function Hk(t,r,s){const l=r.length>1&&Array.from(r).every(v=>v===r[0])?r[0]:r,d=s?t.indexOf(s):-1;let p=Uk(t,Math.max(d,0));l.length===1&&(p=p.filter(v=>v!==s));const y=p.find(v=>v.toLowerCase().startsWith(l.toLowerCase()));return y!==s?y:void 0}function Bk(t,r){const{x:s,y:a}=t;let l=!1;for(let d=0,p=r.length-1;d<r.length;p=d++){const h=r[d],y=r[p],v=h.x,g=h.y,w=y.x,b=y.y;g>a!=b>a&&s<(w-v)*(a-g)/(b-g)+v&&(l=!l)}return l}function Wk(t,r){if(!r)return!1;const s={x:t.clientX,y:t.clientY};return Bk(s,r)}function Bo(t){return r=>r.pointerType==="mouse"?t(r):void 0}var Kk=Qg,Vk=fc,Qk=qg,Gk=Yg,qk=gc,Yk=Xg,Xk=Vi,Zk=Jg,Jk=tv,eE=rv,tE=sv,nE=iv,rE=av,oE=uv,sE=dv,Qi="DropdownMenu",[iE]=Ln(Qi,[Kg]),rt=Kg(),[aE,pv]=iE(Qi),hv=t=>{const{__scopeDropdownMenu:r,children:s,dir:a,open:l,defaultOpen:d,onOpenChange:p,modal:h=!0}=t,y=rt(r),v=m.useRef(null),[g,w]=Ko({prop:l,defaultProp:d??!1,onChange:p,caller:Qi});return u.jsx(aE,{scope:r,triggerId:$o(),triggerRef:v,contentId:$o(),open:g,onOpenChange:w,onOpenToggle:m.useCallback(()=>w(b=>!b),[w]),modal:h,children:u.jsx(Kk,{...y,open:g,onOpenChange:w,dir:a,modal:h,children:s})})};hv.displayName=Qi;var mv="DropdownMenuTrigger",gv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,disabled:a=!1,...l}=t,d=pv(mv,s),p=rt(s);return u.jsx(Vk,{asChild:!0,...p,children:u.jsx(Re.button,{type:"button",id:d.triggerId,"aria-haspopup":"menu","aria-expanded":d.open,"aria-controls":d.open?d.contentId:void 0,"data-state":d.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...l,ref:zr(r,d.triggerRef),onPointerDown:ce(t.onPointerDown,h=>{!a&&h.button===0&&h.ctrlKey===!1&&(d.onOpenToggle(),d.open||h.preventDefault())}),onKeyDown:ce(t.onKeyDown,h=>{a||(["Enter"," "].includes(h.key)&&d.onOpenToggle(),h.key==="ArrowDown"&&d.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(h.key)&&h.preventDefault())})})})});gv.displayName=mv;var lE="DropdownMenuPortal",vv=t=>{const{__scopeDropdownMenu:r,...s}=t,a=rt(r);return u.jsx(Qk,{...a,...s})};vv.displayName=lE;var yv="DropdownMenuContent",xv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=pv(yv,s),d=rt(s),p=m.useRef(!1);return u.jsx(Gk,{id:l.contentId,"aria-labelledby":l.triggerId,...d,...a,ref:r,onCloseAutoFocus:ce(t.onCloseAutoFocus,h=>{p.current||l.triggerRef.current?.focus(),p.current=!1,h.preventDefault()}),onInteractOutside:ce(t.onInteractOutside,h=>{const y=h.detail.originalEvent,v=y.button===0&&y.ctrlKey===!0,g=y.button===2||v;(!l.modal||g)&&(p.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xv.displayName=yv;var uE="DropdownMenuGroup",cE=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(qk,{...l,...a,ref:r})});cE.displayName=uE;var dE="DropdownMenuLabel",wv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Yk,{...l,...a,ref:r})});wv.displayName=dE;var fE="DropdownMenuItem",bv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Xk,{...l,...a,ref:r})});bv.displayName=fE;var pE="DropdownMenuCheckboxItem",Sv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Zk,{...l,...a,ref:r})});Sv.displayName=pE;var hE="DropdownMenuRadioGroup",mE=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Jk,{...l,...a,ref:r})});mE.displayName=hE;var gE="DropdownMenuRadioItem",Cv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(eE,{...l,...a,ref:r})});Cv.displayName=gE;var vE="DropdownMenuItemIndicator",kv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(tE,{...l,...a,ref:r})});kv.displayName=vE;var yE="DropdownMenuSeparator",Ev=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(nE,{...l,...a,ref:r})});Ev.displayName=yE;var xE="DropdownMenuArrow",wE=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(rE,{...l,...a,ref:r})});wE.displayName=xE;var bE="DropdownMenuSubTrigger",Nv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(oE,{...l,...a,ref:r})});Nv.displayName=bE;var SE="DropdownMenuSubContent",Rv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(sE,{...l,...a,ref:r,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Rv.displayName=SE;var CE=hv,kE=gv,EE=vv,Pv=xv,jv=wv,Tv=bv,_v=Sv,Ov=Cv,Av=kv,Mv=Ev,Iv=Nv,Dv=Rv;const NE=CE,RE=kE,PE=m.forwardRef(({className:t,inset:r,children:s,...a},l)=>u.jsxs(Iv,{ref:l,className:Le("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",t),...a,children:[s,u.jsx(C0,{className:"ml-auto"})]}));PE.displayName=Iv.displayName;const jE=m.forwardRef(({className:t,...r},s)=>u.jsx(Dv,{ref:s,className:Le("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...r}));jE.displayName=Dv.displayName;const Lv=m.forwardRef(({className:t,sideOffset:r=4,...s},a)=>u.jsx(EE,{children:u.jsx(Pv,{ref:a,sideOffset:r,className:Le("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s})}));Lv.displayName=Pv.displayName;const TE=m.forwardRef(({className:t,inset:r,...s},a)=>u.jsx(Tv,{ref:a,className:Le("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",t),...s}));TE.displayName=Tv.displayName;const _E=m.forwardRef(({className:t,children:r,checked:s,...a},l)=>u.jsxs(_v,{ref:l,className:Le("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...a,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Av,{children:u.jsx(S0,{className:"h-4 w-4"})})}),r]}));_E.displayName=_v.displayName;const OE=m.forwardRef(({className:t,children:r,...s},a)=>u.jsxs(Ov,{ref:a,className:Le("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Av,{children:u.jsx(E0,{className:"h-2 w-2 fill-current"})})}),r]}));OE.displayName=Ov.displayName;const AE=m.forwardRef(({className:t,inset:r,...s},a)=>u.jsx(jv,{ref:a,className:Le("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",t),...s}));AE.displayName=jv.displayName;const ME=m.forwardRef(({className:t,...r},s)=>u.jsx(Mv,{ref:s,className:Le("-mx-1 my-1 h-px bg-muted",t),...r}));ME.displayName=Mv.displayName;function IE(t){return t.replace("_"," ").toUpperCase()}function DE(t){return t==="in_progress"?"border-foreground text-foreground animate-pulse":t==="failed"?"border-destructive text-destructive":t==="warning"?"border-warning-border bg-warning-muted text-warning-foreground":t==="resolved"?"border-foreground/20 text-muted-foreground":t==="rejected"?"border-foreground/20 text-muted-foreground line-through":t==="flagged"?"border-foreground/40 text-foreground/60":t==="queued"?"border-foreground text-foreground":"border-foreground/30 text-foreground/60"}function Fv(t){return t==="resolved"||t==="rejected"}function LE(t){return Fv(t)||t==="warning"}function $v(t){return t.length===0?!1:t.every(r=>Fv(r.status))}function Wo(t){return t.reduce((r,s)=>(s.status==="queued"?r.queued+=1:s.status==="in_progress"?r.inProgress+=1:s.status==="failed"?r.failed+=1:s.status==="warning"&&(r.warning+=1),r),{queued:0,inProgress:0,failed:0,warning:0})}const FE={idle:"IDLE",triaging:"TRIAGING",awaiting_repair_slot:"REPAIR QUEUED",repairing:"REPAIRING",awaiting_ci:"WAITING FOR CI",verifying:"VERIFYING",healed:"HEALED",cooldown:"COOLDOWN",blocked:"BLOCKED",escalated:"ESCALATED",superseded:"SUPERSEDED"},$E={idle:[],triaging:["cancel"],awaiting_repair_slot:["pause","cancel"],repairing:["pause","cancel"],awaiting_ci:["pause","cancel"],verifying:["cancel"],healed:[],cooldown:["resume","cancel"],blocked:["retry"],escalated:["retry"],superseded:[]},zE={idle:"neutral",triaging:"info",awaiting_repair_slot:"warning",repairing:"info",awaiting_ci:"info",verifying:"info",healed:"success",cooldown:"warning",blocked:"danger",escalated:"danger",superseded:"neutral"},UE={idle:"Waiting for a new failing check on the current PR head.",triaging:"Classifying the current failure set before deciding whether it is safe to repair.",awaiting_repair_slot:"Ready for the next bounded repair attempt as soon as a slot is free.",repairing:"A repair agent is actively working in an isolated worktree.",awaiting_ci:"A repair was pushed and the new head SHA is waiting for CI to settle.",verifying:"Comparing the latest check results against the previous failure fingerprint.",healed:"The latest repair cycle converged to green and the session is complete.",cooldown:"Cooling down before another retry is allowed.",blocked:"Stopped because the failure looks external or unsafe to repair in-branch.",escalated:"Stopped because retries were exhausted or the failure did not improve.",superseded:"Replaced after the PR head moved to a newer commit."};function HE(t){return FE[t]}function BE(t){return $E[t]}function Rh(t){return t==="pause"?"Pause":t==="resume"?"Resume":t==="retry"?"Retry":"Cancel"}function WE(t){return zE[t]}function KE(t){return UE[t]}function VE(t){const r=t.attemptCount,s=r===1?"":"s";return r===0?t.state==="triaging"?"Preparing attempt 1":t.state==="awaiting_repair_slot"?"Queued for attempt 1":t.state==="healed"?"Healed without a repair attempt":"No repair attempts yet":t.state==="repairing"?`Attempt ${r} running`:t.state==="awaiting_ci"?`Attempt ${r} pushed, waiting on CI`:t.state==="verifying"?`Attempt ${r} verifying`:t.state==="healed"?`Healed after ${r} attempt${s}`:t.state==="blocked"?`${r} attempt${s} before blocking`:t.state==="escalated"?`${r} attempt${s} before escalation`:t.state==="cooldown"?`${r} attempt${s}, cooling down`:t.state==="superseded"?`${r} attempt${s}, superseded`:`${r} attempt${s} recorded`}function QE(t){return t?t.blockedReason??t.escalationReason??t.latestFingerprint??null:null}function GE(t,r){const s=t.filter(a=>a.prId===r);return s.length===0?null:s.reduce((a,l)=>l.updatedAt>a.updatedAt?l:a)}function qE(t,r){return GE(t,r)}function YE(t,r){return{stateLabel:HE(t.state),tone:WE(t.state),attemptSummary:VE(t),reasonSummary:QE(t),statusHint:KE(t.state),actions:BE(t.state).map(s=>({label:Rh(s),available:!0,hint:`${Rh(s)} controls are planned but not wired to the backend yet.`}))}}function Mt(t){return t?new Date(t).toLocaleTimeString("en-US",{hour12:!1}):null}function zv(t){return t.watchEnabled}function Uv(t){return t==="processing"?"autonomous run active":t==="done"?"completed":t==="error"?"attention needed":t==="archived"?"archived":"watching"}function XE(t){return`${Math.max(1,Math.round((t??12e4)/1e3))}s`}const ZE=[{value:"mine",label:"My PRs only"},{value:"team",label:"My PRs + teammates"}],JE={failed:[],inProgress:[],queued:[],warnings:[],generatedAt:""},fu=200;function eN(t){return t===!1?"team":"mine"}const Ph={neutral:"border-border text-muted-foreground",info:"border-foreground text-foreground",warning:"border-warning-border bg-warning-muted text-warning-foreground",success:"border-success-border bg-success-muted text-success-foreground",danger:"border-destructive text-destructive"};function Hv({status:t}){const r=t==="watching"?"bg-foreground/30":t==="processing"?"bg-foreground animate-pulse":t==="done"?"bg-foreground":t==="archived"?"bg-foreground/15":"bg-destructive";return u.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 ${r}`})}function tN({status:t}){const r=DE(t);return u.jsx("span",{className:`inline-block border px-1.5 py-0 text-[11px] uppercase tracking-wide ${r}`,children:IE(t)})}function Iu(){return u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"watch paused"})}function jh({value:t,onChange:r,disabled:s,name:a,testIdPrefix:l,compact:d=!1}){return u.jsx("div",{role:"radiogroup","aria-label":"Automatic PR tracking scope",className:`flex flex-wrap gap-1 ${d?"":"mt-1"}`,children:ZE.map(p=>{const h=t===p.value;return u.jsxs("label",{"data-testid":`${l}-${p.value}`,className:`cursor-pointer border px-2 text-[10px] transition-colors focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-1 focus-within:ring-offset-background ${d?"py-0.5":"py-1"} ${h?"border-foreground bg-muted text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${s?"cursor-not-allowed opacity-50":""} whitespace-nowrap`,children:[u.jsx("input",{type:"radio",name:a,value:p.value,checked:h,onChange:()=>r(p.value),disabled:s,className:"sr-only"}),p.label]},p.value)})})}function nN({activity:t}){const r=t.status==="failed"?Mt(t.updatedAt):t.status==="in_progress"?Mt(t.startedAt)??Mt(t.updatedAt):Mt(t.availableAt)??Mt(t.queuedAt),s=u.jsxs("div",{className:"flex min-w-0 items-start gap-2 px-2 py-1.5 text-left",children:[u.jsx("span",{className:`mt-1.5 h-1.5 w-1.5 shrink-0 ${t.status==="failed"?"bg-destructive":t.status==="in_progress"?"animate-pulse bg-foreground":"bg-muted-foreground"}`}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate text-[12px] leading-4 text-foreground",children:t.label}),t.detail&&u.jsx("span",{className:"block truncate text-[11px] leading-4 text-muted-foreground",children:t.detail}),t.status==="failed"&&t.lastError&&u.jsx("span",{className:"block truncate text-[11px] leading-4 text-destructive",children:t.lastError})]}),r&&u.jsx("span",{className:"shrink-0 text-[10px] leading-4 text-muted-foreground",children:r})]});return t.targetUrl?u.jsx("a",{href:t.targetUrl,target:"_blank",rel:"noopener noreferrer",className:"block outline-none hover:bg-muted focus:bg-muted focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:s}):u.jsx("div",{children:s})}function pu({title:t,items:r,emptyLabel:s}){return u.jsxs("div",{className:"py-1",children:[u.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:t}),r.length>0?u.jsx("div",{className:"max-h-52 overflow-y-auto",children:r.map(a=>u.jsx(nN,{activity:a},a.id))}):u.jsx("div",{className:"px-2 pb-2 text-[11px] text-muted-foreground",children:s})]})}function rN({activities:t}){const r=t.failed.length,s=t.inProgress.length,a=t.queued.length,l=r+s+a;return u.jsxs(NE,{children:[u.jsxs(RE,{className:"inline-flex items-center gap-1 border border-border px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","aria-label":"Open activity menu","data-testid":"activity-menu-trigger",children:[u.jsx(b0,{className:"h-3 w-3","aria-hidden":"true"}),u.jsx("span",{children:"activity"}),u.jsx("span",{className:"text-foreground",children:l})]}),u.jsxs(Lv,{align:"end",className:"w-80 p-0",children:[u.jsxs("div",{className:"border-b border-border px-2 py-2",children:[u.jsx("div",{className:"text-[12px] font-medium",children:"Activities"}),u.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[r," failed / ",s," in progress / ",a," queued"]})]}),u.jsx(pu,{title:"Failed",items:t.failed,emptyLabel:"No failed activities."}),u.jsx("div",{className:"border-t border-border"}),u.jsx(pu,{title:"In progress",items:t.inProgress,emptyLabel:"No activities running right now."}),u.jsx("div",{className:"border-t border-border"}),u.jsx(pu,{title:"Queued",items:t.queued,emptyLabel:"Queue is empty."})]})]})}function oN({warnings:t}){return t.length===0?null:u.jsx("div",{className:"shrink-0 border-b border-yellow-600/50 bg-yellow-500/10 px-4 py-3","data-testid":"operator-warnings-banner",children:u.jsx("div",{className:"space-y-3",children:t.map(r=>u.jsxs("div",{"data-testid":`operator-warning-${r.id}`,children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[u.jsx("div",{className:"text-[12px] font-medium uppercase tracking-wider text-yellow-600",children:r.title}),r.targetUrl&&u.jsx("a",{href:r.targetUrl,target:"_blank",rel:"noopener noreferrer",className:"border border-yellow-600/60 px-2 py-0.5 text-[10px] uppercase tracking-wider text-yellow-600 transition-colors hover:bg-yellow-600 hover:text-background",children:"Open PR"})]}),u.jsx("div",{className:"mt-1 text-[12px] text-foreground/80",children:r.message}),u.jsx("ol",{className:"mt-2 list-decimal space-y-1 pl-4 text-[11px] text-muted-foreground",children:r.fixSteps.map(s=>u.jsx("li",{children:s},s))})]},r.id))})})}function Bv({href:t,testId:r,label:s,hint:a,className:l,dotClassName:d,hintClassName:p,onClick:h}){return u.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:h,"data-testid":r,className:`inline-flex items-center border border-success-border bg-success-muted font-medium uppercase text-success-foreground transition-colors hover:bg-success-muted/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background ${l}`,children:[u.jsx("span",{className:`inline-block rounded-full bg-success ${d}`}),s,a&&u.jsx("span",{className:p,children:a})]})}function Wv({pr:t}){const r=Wo(t.feedbackItems).inProgress;if(!(t.status==="processing")&&r===0)return null;const a=r>0?`${r} agent${r!==1?"s":""} running on this PR`:"Agent run active on this PR";return u.jsxs(VS,{children:[u.jsx(QS,{asChild:!0,children:u.jsxs("span",{className:"inline-flex shrink-0 cursor-default items-center gap-0.5 text-[12px]","data-testid":`agent-indicator-${t.id}`,children:[u.jsx("span",{className:"animate-pulse",children:"🤖"}),r>0&&u.jsx("span",{className:"text-[10px] text-muted-foreground",children:r})]})}),u.jsx(vg,{side:"top",children:u.jsx("p",{className:"text-xs",children:a})})]})}const sN=m.memo(function({pr:r,isSelected:s,onSelect:a}){const l=Mt(r.lastChecked),d=zv(r),h=!(r.status==="processing"||Wo(r.feedbackItems).inProgress>0)&&$v(r.feedbackItems);return u.jsx("div",{onClick:()=>a(r.id),onKeyDown:y=>{y.target===y.currentTarget&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),a(r.id))},role:"button",tabIndex:0,"data-testid":`pr-row-${r.id}`,className:`w-full border-b border-border px-4 py-3 text-left transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${s?"bg-muted":""}`,children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx(Hv,{status:r.status}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"w-12 shrink-0 text-muted-foreground",children:["#",r.number]}),u.jsx("span",{className:"truncate",children:r.title}),u.jsx(Wv,{pr:r})]}),h&&u.jsx(Bv,{href:r.url,testId:`ready-to-merge-${r.id}`,label:"Ready to merge",hint:"— click to open PR",onClick:y=>y.stopPropagation(),className:"mt-1.5 ml-[3.75rem] gap-1.5 px-2 py-0.5 text-[11px] tracking-wider",dotClassName:"h-1.5 w-1.5",hintClassName:"text-[10px] normal-case tracking-normal text-success-foreground/75"}),u.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 pl-[3.75rem] text-[11px] text-muted-foreground",children:[u.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",onClick:y=>y.stopPropagation(),className:"underline decoration-border underline-offset-2 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:r.repo}),u.jsx("span",{children:Uv(r.status)}),!d&&u.jsx(Iu,{}),r.feedbackItems.length>0&&(()=>{const y=Wo(r.feedbackItems),v=[];return y.queued>0&&v.push(`${y.queued}q`),y.inProgress>0&&v.push(`${y.inProgress} active`),y.failed>0&&v.push(`${y.failed} failed`),y.warning>0&&v.push(`${y.warning} warn`),v.length===0?u.jsxs("span",{children:[r.feedbackItems.length," items"]}):u.jsx("span",{children:v.join(" · ")})})(),l&&u.jsxs("span",{children:["checked ",l]})]})]})]})})});function iN({item:t,prId:r,readOnly:s}){const a=ct({mutationFn:async h=>(await nt("PATCH",`/api/prs/${r}/feedback/${t.id}`,{decision:h})).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/prs",r]})}}),l=ct({mutationFn:async()=>(await nt("POST",`/api/prs/${r}/feedback/${t.id}/retry`)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/prs",r]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/logs"]})},onError:h=>{Ht("Could not retry feedback item",h)}}),d=Mt(t.createdAt),p=LE(t.status);return u.jsxs(Sg,{defaultOpen:!p,className:"border-b border-border",children:[u.jsx("div",{className:"px-4 py-3",children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"shrink-0 pt-0.5",children:u.jsx(tN,{status:t.status})}),u.jsx("div",{className:"min-w-0 flex-1",children:u.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[u.jsx("span",{className:"font-medium",children:t.author}),t.file&&u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[t.file,t.line?`:${t.line}`:""]}),u.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.type.replace("_"," ")}),d&&u.jsx("span",{className:"text-[11px] text-muted-foreground",children:d})]})}),u.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!s&&(t.status==="failed"||t.status==="warning")&&u.jsx("button",{type:"button",onClick:()=>l.mutate(),disabled:l.isPending,"data-testid":`retry-${t.id}`,"aria-label":`Retry feedback from ${t.author}`,title:"Retry feedback item",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:"Retry"}),u.jsx(Cg,{asChild:!0,children:u.jsx("button",{type:"button","data-testid":`toggle-${t.id}`,"aria-label":`${p?"Show":"Hide"} feedback details from ${t.author}`,title:"Toggle feedback details",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"Details"})}),!s&&["accept","reject","flag"].map(h=>u.jsx("button",{type:"button",onClick:()=>a.mutate(h),"data-testid":`override-${h}-${t.id}`,"aria-label":`${h} feedback from ${t.author}`,className:`px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background ${t.decision===h?"bg-foreground text-background":"border border-border text-muted-foreground"}`,children:h},h))]})]})}),u.jsx(kg,{children:u.jsxs("div",{className:"px-4 pb-3",children:[t.bodyHtml?u.jsx("div",{className:"feedback-markdown text-[12px] leading-relaxed",dangerouslySetInnerHTML:{__html:t.bodyHtml}}):u.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-relaxed text-foreground/80",children:t.body}),(t.statusReason||t.decisionReason)&&u.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:t.statusReason||t.decisionReason})]})})]})}function aN({prId:t}){const r=m.useRef(null),{data:s=[]}=dt({queryKey:["/api/logs",t??"all"],queryFn:async()=>{const d=t?`/api/logs?prId=${encodeURIComponent(t)}`:"/api/logs";return(await nt("GET",d)).json()},refetchInterval:1500}),a=m.useMemo(()=>s.length>fu?s.slice(-fu):s,[s]),l=s.length-a.length;return m.useEffect(()=>{const d=r.current;d&&(d.scrollTop=d.scrollHeight)},[s.length,t]),u.jsx("div",{className:"flex h-full flex-col",children:u.jsx("div",{ref:r,className:"flex-1 overflow-y-auto p-4 font-mono text-[11px] leading-relaxed",children:s.length===0?u.jsx("span",{className:"text-muted-foreground",children:"No log entries."}):u.jsxs(u.Fragment,{children:[l>0&&u.jsxs("div",{className:"border-b border-border/60 pb-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:["Showing latest ",fu," of ",s.length," entries."]}),a.map(d=>{const p=d.metadata&&Object.keys(d.metadata).length>0?JSON.stringify(d.metadata,null,2):null;return u.jsxs("div",{className:"border-b border-border/60 py-2 last:border-b-0","data-testid":`log-${d.id}`,children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[u.jsx("span",{children:Mt(d.timestamp)}),u.jsx("span",{className:d.level==="error"?"text-destructive":d.level==="warn"?"text-foreground/80":"text-foreground/55",children:d.level}),d.phase&&u.jsx("span",{className:"border border-border px-1 py-0",children:d.phase}),d.runId&&u.jsxs("span",{className:"normal-case text-foreground/45",children:["run ",d.runId.slice(0,8)]})]}),u.jsx("div",{className:"mt-1 break-words text-foreground/75",children:d.message}),p&&u.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all text-[10px] text-muted-foreground",children:p})]},d.id)})]})})})}function lN({pr:t,config:r,healingSessions:s}){const a=qE(s,t.id),l=a?YE(a):null,d=l?Ph[l.tone]:Ph.neutral;return u.jsxs("div",{className:"shrink-0 border-b border-border px-4 py-3","data-testid":"panel-ci-healing",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"CI healing"}),u.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:l?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:`inline-flex border px-1.5 py-0.5 text-[11px] uppercase tracking-wider ${d}`,children:l.stateLabel}),u.jsx("span",{className:"text-[11px] text-muted-foreground",children:l.attemptSummary})]}):u.jsx("span",{className:"text-[11px] text-muted-foreground",children:r?.autoHealCI===!1?"Automatic CI healing is disabled in settings.":"No healing session yet for this PR."})})]}),a&&u.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["head ",a.currentHeadSha.slice(0,7)]})]}),l?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mt-2 grid gap-1 text-[11px] text-muted-foreground",children:[l.reasonSummary&&u.jsxs("div",{children:["Reason: ",l.reasonSummary]}),u.jsx("div",{children:l.statusHint}),u.jsxs("div",{children:["Attempts: ",l.attemptSummary,a?.latestFingerprint?` · fingerprint ${a.latestFingerprint}`:""]})]}),l.actions.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:l.actions.map(p=>u.jsx("button",{type:"button",disabled:!0,title:p.hint,className:`border px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors ${p.available?"border-border text-foreground/70 hover:bg-muted":"border-border text-muted-foreground/60"} disabled:opacity-100`,children:p.label},p.label))}),u.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground",children:"Operator controls are read-only until healing action endpoints are added."})]})]}):r?.autoHealCI!==!1&&u.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:"The watcher will create a healing session when a failing check is classified as healable."})]})}function uN({prId:t}){const[r,s]=m.useState("ask");return u.jsxs("div",{className:"flex min-h-[24rem] w-full shrink-0 flex-col border-t border-border lg:min-h-0 lg:w-80 lg:border-l lg:border-t-0",children:[u.jsxs("div",{className:"flex border-b border-border",children:[u.jsx("button",{type:"button",onClick:()=>s("ask"),"data-testid":"tab-ask",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${r==="ask"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Ask Agent"}),u.jsx("button",{type:"button",onClick:()=>s("activity"),"data-testid":"tab-activity",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${r==="activity"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Activity"})]}),u.jsx("div",{className:"flex-1 overflow-hidden",children:r==="activity"?u.jsx(aN,{prId:t}):t?u.jsx(cN,{prId:t}):u.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Select a PR to ask questions."})})]})}function cN({prId:t}){const[r,s]=m.useState(""),a=m.useRef(null),{data:l=[]}=dt({queryKey:["/api/prs",t,"questions"],refetchInterval:2e3}),d=ct({mutationFn:p=>nt("POST",`/api/prs/${t}/questions`,{question:p}).then(h=>h.json()),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs",t,"questions"]}),we.invalidateQueries({queryKey:["/api/activities"]}),s("")}});return m.useEffect(()=>{const p=a.current;p&&(p.scrollTop=p.scrollHeight)},[l.length,l[l.length-1]?.status]),u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsx("div",{className:"border-b border-border px-4 py-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:"Ask Agent"}),u.jsx("div",{ref:a,className:"flex-1 overflow-y-auto p-4 space-y-3",children:l.length===0?u.jsx("span",{className:"text-[12px] text-muted-foreground",children:"Ask questions about this PR — the agent will read activity logs, feedback, and status to answer."}):l.map(p=>u.jsxs("div",{className:"space-y-1.5","data-testid":`question-${p.id}`,children:[u.jsxs("div",{className:"text-[12px]",children:[u.jsx("span",{className:"font-medium text-foreground/90",children:"Q: "}),u.jsx("span",{className:"text-foreground/80",children:p.question})]}),p.status==="pending"||p.status==="answering"?u.jsx("div",{className:"text-[11px] text-muted-foreground animate-pulse",children:"Agent is thinking..."}):p.status==="error"?u.jsxs("div",{className:"text-[11px] text-destructive",children:["Error: ",p.error||"Unknown error"]}):u.jsx("div",{className:"text-[12px] leading-relaxed text-foreground/75 whitespace-pre-wrap border-l-2 border-border pl-3",children:p.answer}),u.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Mt(p.createdAt),p.answeredAt&&` — answered ${Mt(p.answeredAt)}`]})]},p.id))}),u.jsxs("form",{onSubmit:p=>{p.preventDefault(),r.trim()&&!d.isPending&&d.mutate(r.trim())},className:"border-t border-border p-3",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:r,onChange:p=>s(p.target.value),placeholder:"Was the review done? Why did this fail?","aria-label":"Question for selected pull request","data-testid":"input-question",className:"flex-1 border border-border bg-transparent px-2 py-1 text-[12px] placeholder:text-muted-foreground/50 focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"submit",disabled:d.isPending||!r.trim(),"data-testid":"button-ask",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:d.isPending?"...":"Ask"})]}),d.isError&&u.jsx("div",{className:"mt-1 text-[11px] text-destructive",children:Kv(d.error)})]})]})}function Kv(t){if(!(t instanceof Error))return String(t);const r=t.message.replace(/^\d+:\s*/,"").trim();if(!r)return"Request failed";try{const s=JSON.parse(r);if(typeof s.error=="string")return s.error;if(typeof s.message=="string")return s.message}catch{}return r}function Ht(t,r){Vt({variant:"destructive",title:t,description:Kv(r)})}function dN(){const[t,r]=m.useState(null),[s,a]=m.useState(""),[l,d]=m.useState(""),[p,h]=m.useState(null),[y,v]=m.useState("mine"),[g,w]=m.useState("active"),{data:b=[],isLoading:E}=dt({queryKey:["/api/prs"],refetchInterval:3e3}),{data:N=[],isLoading:S}=dt({queryKey:["/api/prs/archived"],refetchInterval:1e4}),{data:C}=dt({queryKey:["/api/config"],refetchInterval:5e3}),{data:_=[]}=dt({queryKey:["/api/healing-sessions"],queryFn:async()=>sb("/api/healing-sessions"),refetchInterval:5e3}),{data:A=JE}=dt({queryKey:["/api/activities"],refetchInterval:3e3}),{data:O=[]}=dt({queryKey:["/api/repos/settings"],refetchInterval:5e3}),I=g==="active"?b:N,F=g==="archived";m.useEffect(()=>{if(I.length===0){t!==null&&r(null);return}(!t||!I.some(P=>P.id===t))&&r(I[0].id)},[I,t]);const L=I.find(P=>P.id===t)??null,U=L?zv(L):!0,q=ZS(p,O.length),te=ct({mutationFn:async P=>(await nt("POST","/api/prs",{url:P})).json(),onSuccess:P=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]}),a(""),r(P.id)},onError:P=>{Ht("Could not add PR",P)}}),ne=ct({mutationFn:async P=>(await nt("POST",`/api/prs/${P}/apply`)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/logs"]})},onError:P=>{Ht("Could not run babysitter",P)}}),se=ct({mutationFn:async({id:P,enabled:z})=>(await nt("PATCH",`/api/prs/${P}/watch`,{enabled:z})).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/prs/archived"]}),we.invalidateQueries({queryKey:["/api/logs"]})},onError:P=>{Ht("Could not update PR watch state",P)}}),Y=ct({mutationFn:async P=>(await nt("PATCH","/api/config",P)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/config"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]})},onError:P=>{Ht("Could not update settings",P)}}),ae=ct({mutationFn:async()=>(await nt("POST","/api/repos/sync")).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]})},onError:P=>{Ht("Could not sync repositories",P)}}),G=ct({mutationFn:async P=>(await nt("POST","/api/repos/release",{repo:P})).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/releases"]}),we.invalidateQueries({queryKey:["/api/activities"]}),Vt({description:"Release queued."})},onError:P=>{Ht("Could not create release",P)}}),me=async P=>(await nt("PATCH","/api/repos/settings",P)).json(),ee=ct({mutationFn:me,onSuccess:()=>{we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]})},onError:P=>{Ht("Could not update repository settings",P)}}),ie=ct({mutationFn:async({repo:P})=>(await nt("POST","/api/repos",{repo:P})).json(),onSuccess:async(P,z)=>{if(we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]}),d(""),v("mine"),z.watchScope==="team")try{await me({repo:P.repo,ownPrsOnly:!1}),we.invalidateQueries({queryKey:["/api/repos/settings"]})}catch(V){Ht("Repository added, but could not update tracking scope",V)}},onError:P=>{Ht("Could not watch repository",P)}});return u.jsxs("div",{className:"flex min-h-screen flex-col lg:h-screen lg:overflow-hidden",children:[u.jsx(Bi,{}),u.jsxs("header",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-2.5 lg:flex-row lg:items-center lg:justify-between",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-label":"oh-my-pr",children:[u.jsx("rect",{x:"1",y:"1",width:"14",height:"14",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M4 5h8M4 8h5M4 11h6",stroke:"currentColor",strokeWidth:"1"})]}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"oh-my-pr"}),u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"autonomous"}),u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["poll ",XE(C?.pollIntervalMs)]}),u.jsx(An,{href:"/changelogs",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"changelogs"}),u.jsx(An,{href:"/releases",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"releases"})]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[b.length," PR",b.length!==1?"s":""," in ",O.length," repo",O.length!==1?"s":""]}),u.jsx("label",{htmlFor:"dashboard-coding-agent",className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Agent"}),u.jsxs("select",{id:"dashboard-coding-agent",value:C?.codingAgent??"codex",onChange:P=>{const z=P.target.value;Y.mutate({codingAgent:z})},disabled:Y.isPending,"data-testid":"select-coding-agent",className:"border border-border bg-transparent px-2 py-0.5 text-[11px] focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:[u.jsx("option",{value:"codex",children:"codex"}),u.jsx("option",{value:"claude",children:"claude"})]}),u.jsx(An,{href:"/settings",className:"border border-border px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"settings"}),u.jsx(rN,{activities:A})]})]}),u.jsx(nC,{}),u.jsx(oN,{warnings:A.warnings}),u.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden",children:[u.jsxs("div",{className:"flex max-h-[42vh] w-full shrink-0 flex-col overflow-y-auto border-b border-border lg:max-h-none lg:min-h-0 lg:w-80 lg:border-b-0 lg:border-r",children:[u.jsxs("div",{className:"sticky top-0 z-10 flex shrink-0 border-b border-border bg-background",children:[u.jsxs("button",{type:"button",onClick:()=>w("active"),"data-testid":"tab-active",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${g==="active"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:["Active (",b.length,")"]}),u.jsxs("button",{type:"button",onClick:()=>w("archived"),"data-testid":"tab-archived",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${g==="archived"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:["Archived (",N.length,")"]})]}),!F&&u.jsxs(u.Fragment,{children:[u.jsxs(Sg,{open:q,onOpenChange:h,className:"border-b border-border",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 text-[11px] text-muted-foreground",children:[u.jsx("span",{children:O.length>0?"Add a PR or watch another repo.":"Add a PR or watch a repo. Sync and babysit start automatically."}),u.jsx(Cg,{asChild:!0,children:u.jsx("button",{type:"button","data-testid":"button-toggle-add-controls",className:"shrink-0 border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:q?"Hide":"Add"})})]}),u.jsxs(kg,{children:[u.jsx("form",{onSubmit:P=>{P.preventDefault(),s.trim()&&te.mutate(s.trim())},className:"border-t border-border p-3",children:u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:s,onChange:P=>a(P.target.value),placeholder:"github.com/owner/repo/pull/123","aria-label":"GitHub pull request URL","data-testid":"input-add-pr",className:"flex-1 border border-border bg-transparent px-2 py-1 text-[12px] placeholder:text-muted-foreground/50 focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"submit",disabled:te.isPending||!s.trim(),"data-testid":"button-add-pr",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:"Add"})]})}),u.jsxs("form",{onSubmit:P=>{P.preventDefault();const z=l.trim();z&&ie.mutate({repo:z,watchScope:y})},className:"border-t border-border p-3",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:l,onChange:P=>d(P.target.value),placeholder:"owner/repo","aria-label":"Repository owner and name","data-testid":"input-add-repo",className:"flex-1 border border-border bg-transparent px-2 py-1 text-[12px] placeholder:text-muted-foreground/50 focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"submit",disabled:ie.isPending||!l.trim(),"data-testid":"button-add-repo",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:"Watch"})]}),u.jsxs("div",{className:"mt-3",children:[u.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Track automatically"}),u.jsx(jh,{value:y,onChange:v,disabled:ie.isPending,name:"watch-scope",testIdPrefix:"watch-scope"})]})]})]})]}),u.jsxs("div",{className:"border-b border-border p-3",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Tracked repositories"}),u.jsx("button",{type:"button",onClick:()=>ae.mutate(),disabled:ae.isPending,"data-testid":"button-sync-repos",className:"border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:ae.isPending?"Fetching...":"Fetch"})]}),O.length===0?u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"No repositories being watched yet."}):u.jsx("div",{className:"space-y-1 text-[12px]",children:O.map(P=>{const z=G.isPending&&G.variables===P.repo;return u.jsxs("div",{className:"space-y-2 border border-border/60 px-2 py-2",children:[u.jsx("a",{href:XS(P.repo),target:"_blank",rel:"noopener noreferrer","data-testid":`tracked-repo-${P.repo.replace("/","-")}`,className:"min-w-0 break-all text-foreground/75 underline decoration-border underline-offset-2 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:P.repo}),u.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Track automatically"}),u.jsx(jh,{value:eN(P.ownPrsOnly),onChange:V=>ee.mutate({repo:P.repo,ownPrsOnly:V==="mine"}),disabled:ee.isPending,name:`tracked-repo-scope-${P.repo}`,testIdPrefix:`tracked-repo-scope-${P.repo.replace("/","-")}`,compact:!0})]}),u.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2 self-end",children:[u.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:[u.jsx("input",{type:"checkbox",checked:P.autoCreateReleases,onChange:V=>ee.mutate({repo:P.repo,autoCreateReleases:V.target.checked}),disabled:ee.isPending,"data-testid":`tracked-repo-auto-release-${P.repo.replace("/","-")}`,className:"accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),"Auto-release"]}),u.jsx("button",{type:"button",onClick:()=>G.mutate(P.repo),disabled:G.isPending,"data-testid":`tracked-repo-manual-release-${P.repo.replace("/","-")}`,className:"border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:z?"Releasing...":"Release"})]})]})]},P.repo)})})]})]}),u.jsx("div",{className:"flex-1",children:(F?S:E)?u.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:"Loading..."}):I.length===0?u.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:F?"No archived PRs. Closed PRs are archived automatically.":"No PRs tracked yet. Add a repository to watch or add a PR URL."}):I.map(P=>u.jsx(sN,{pr:P,isSelected:P.id===t,onSelect:r},P.id))})]}),u.jsx("div",{className:"flex min-h-[32rem] flex-1 flex-col overflow-hidden lg:min-h-0",children:L?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"shrink-0 border-b border-border px-4 py-3",children:[u.jsxs("div",{className:"mb-1 flex items-start justify-between gap-4",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(Hv,{status:L.status}),u.jsx("span",{className:"truncate font-medium",children:L.title}),u.jsx(Wv,{pr:L}),!U&&u.jsx(Iu,{}),u.jsxs("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-[11px] text-muted-foreground underline decoration-border underline-offset-2 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:[L.repo,"#",L.number]})]}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[u.jsxs("span",{children:["status: ",Uv(L.status)]}),!U&&u.jsx(Iu,{}),u.jsxs("span",{children:[L.feedbackItems.length," items"]}),L.feedbackItems.length>0&&(()=>{const P=Wo(L.feedbackItems);return u.jsxs(u.Fragment,{children:[P.queued>0&&u.jsxs("span",{children:[P.queued," queued"]}),P.inProgress>0&&u.jsxs("span",{children:[P.inProgress," in progress"]}),P.failed>0&&u.jsxs("span",{children:[P.failed," failed"]}),P.warning>0&&u.jsxs("span",{children:[P.warning," warnings"]})]})})(),L.testsPassed!==null&&u.jsxs("span",{children:["tests: ",L.testsPassed?"pass":"fail"]}),L.lintPassed!==null&&u.jsxs("span",{children:["lint: ",L.lintPassed?"pass":"fail"]}),L.lastChecked&&u.jsxs("span",{children:["checked ",Mt(L.lastChecked)]})]})]}),!F&&u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:()=>ne.mutate(L.id),disabled:ne.isPending||L.status==="processing","data-testid":"button-apply",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:L.status==="processing"?"Running":"Run now"}),u.jsx("button",{type:"button",onClick:()=>se.mutate({id:L.id,enabled:!U}),disabled:se.isPending,"data-testid":"button-toggle-watch",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:U?"Pause watch":"Resume watch"})]})]}),$v(L.feedbackItems)&&L.status!=="processing"&&Wo(L.feedbackItems).inProgress===0&&u.jsx(Bv,{href:L.url,testId:"detail-ready-to-merge",label:"All comments resolved — ready to merge",hint:"Open PR on GitHub →",className:"mt-2 gap-2 px-3 py-1.5 text-[12px] tracking-wider",dotClassName:"h-2 w-2",hintClassName:"text-[11px] normal-case tracking-normal text-success-foreground/75"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:U?"Background watcher syncs GitHub feedback and pushes approved fixes automatically.":"Background watch is paused for this PR; manual runs still work."})]}),u.jsx(lN,{pr:L,config:C,healingSessions:_}),u.jsx("div",{className:"flex-1 overflow-y-auto",children:L.feedbackItems.length===0?u.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:U?"No feedback yet. The watcher will sync GitHub comments automatically.":"No feedback yet. Background watch is paused for this PR."}):L.feedbackItems.map(P=>u.jsx(iN,{item:P,prId:L.id,readOnly:F},P.id))})]}):u.jsx("div",{className:"flex flex-1 items-center justify-center text-[12px] text-muted-foreground",children:"Select a PR from the left panel."})}),u.jsx(uN,{prId:t})]})]})}function fN(){const{data:t}=dt({queryKey:["/api/config"]}),[r,s]=m.useState(""),[a,l]=m.useState(!1),d=t?.githubTokens??(t?.githubToken?[t.githubToken]:[]),p=g=>{v.mutate({githubTokens:g})},h=(g,w)=>{const b=[...d],[E]=b.splice(g,1);E&&(b.splice(w,0,E),p(b))},y=g=>{p(d.filter((w,b)=>b!==g))},v=ct({mutationFn:async g=>(await nt("PATCH","/api/config",g)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/config"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]}),Vt({description:"Settings saved."})},onError:g=>{Vt({variant:"destructive",description:`Failed to save: ${g.message}`})}});return u.jsxs("div",{className:"flex min-h-screen flex-col",children:[u.jsx(Bi,{}),u.jsx("header",{className:"flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(An,{href:"/",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"← back"}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"settings"})]})}),u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsxs("div",{className:"mx-auto flex max-w-2xl flex-col gap-8",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Agent"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{htmlFor:"settings-coding-agent",className:"text-sm",children:"Coding Agent"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"CLI agent used to apply fixes"})]}),u.jsxs("select",{id:"settings-coding-agent",value:t?.codingAgent??"codex",onChange:g=>{const w=g.target.value;v.mutate({codingAgent:w})},disabled:v.isPending,className:"border border-border bg-transparent px-2 py-1 text-sm focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:[u.jsx("option",{value:"codex",children:"codex"}),u.jsx("option",{value:"claude",children:"claude"})]})]}),u.jsxs("label",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Fallback to next coding agent"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"If the configured agent cannot start or authenticate, retry the babysitter run with the other local agent."})]}),u.jsx("input",{type:"checkbox",checked:t?.fallbackToNextCodingAgent??!1,onChange:g=>v.mutate({fallbackToNextCodingAgent:g.target.checked}),disabled:v.isPending,className:"mt-1 h-4 w-4 accent-foreground","data-testid":"checkbox-fallback-to-next-coding-agent"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Automation"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Auto-resolve conflicts"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ask the agent to resolve merge conflicts when tracked PRs are not mergeable."})]}),u.jsx("input",{type:"checkbox",checked:t?.autoResolveMergeConflicts??!0,onChange:g=>v.mutate({autoResolveMergeConflicts:g.target.checked}),disabled:v.isPending,"data-testid":"checkbox-auto-resolve-conflicts",className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]}),u.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Auto-update docs"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Automatically assess whether tracked PRs need documentation updates."})]}),u.jsx("input",{type:"checkbox",checked:t?.autoUpdateDocs??!0,onChange:g=>v.mutate({autoUpdateDocs:g.target.checked}),disabled:v.isPending,"data-testid":"checkbox-auto-update-docs",className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Tuning"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsx(Tn,{label:"Max turns",description:"Maximum agent turns per feedback item",value:t?.maxTurns??15,onChange:g=>v.mutate({maxTurns:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Poll interval (ms)",description:"How often to check for new feedback",value:t?.pollIntervalMs??12e4,onChange:g=>v.mutate({pollIntervalMs:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Batch window (ms)",description:"Time to batch feedback before processing",value:t?.batchWindowMs??3e5,onChange:g=>v.mutate({batchWindowMs:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Max changes per run",description:"Limit on concurrent changes",value:t?.maxChangesPerRun??20,onChange:g=>v.mutate({maxChangesPerRun:g}),disabled:v.isPending})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"CI Healing"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Automatic CI healing"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Classify healable CI failures and run bounded repair attempts in isolated worktrees."})]}),u.jsx("input",{type:"checkbox","aria-label":"Automatic CI healing",checked:t?.autoHealCI??!1,onChange:g=>v.mutate({autoHealCI:g.target.checked}),disabled:v.isPending,className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]}),u.jsx(Tn,{label:"Max healing attempts per session",description:"Upper bound on repair attempts for a single healing session",value:t?.maxHealingAttemptsPerSession??3,onChange:g=>v.mutate({maxHealingAttemptsPerSession:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Max healing attempts per fingerprint",description:"Cap retries for the same failure fingerprint",value:t?.maxHealingAttemptsPerFingerprint??2,onChange:g=>v.mutate({maxHealingAttemptsPerFingerprint:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Max concurrent healing runs",description:"How many healing runs can execute at once",value:t?.maxConcurrentHealingRuns??1,onChange:g=>v.mutate({maxConcurrentHealingRuns:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Healing cooldown (ms)",description:"Backoff before a cooldowned session can retry",value:t?.healingCooldownMs??3e5,onChange:g=>v.mutate({healingCooldownMs:g}),disabled:v.isPending})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Releases"}),u.jsx("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:u.jsxs("label",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Automatic release creation"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Evaluate merged PRs and publish GitHub releases automatically when the agent decides they are release-worthy."})]}),u.jsx("input",{type:"checkbox",checked:t?.autoCreateReleases??!0,onChange:g=>v.mutate({autoCreateReleases:g.target.checked}),disabled:v.isPending,className:"mt-1 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","data-testid":"checkbox-auto-create-releases"})]})})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"GitHub"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Tokens"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Tried in order before GITHUB_TOKEN and gh auth."})]}),!a&&u.jsx("button",{type:"button",onClick:()=>l(!0),className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"add"})]}),d.length?u.jsx("div",{className:"flex flex-col gap-2",children:d.map((g,w)=>u.jsxs("div",{className:"flex items-center justify-between gap-3 border border-border px-2 py-1.5",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"truncate font-mono text-xs",children:g}),u.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["priority ",w+1]})]}),u.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[u.jsx("button",{type:"button",onClick:()=>h(w,w-1),disabled:w===0||v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"up"}),u.jsx("button",{type:"button",onClick:()=>h(w,w+1),disabled:w===d.length-1||v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"down"}),u.jsx("button",{type:"button",onClick:()=>y(w),disabled:v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"remove"})]})]},w))}):u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"none configured"}),a?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"password",value:r,onChange:g=>s(g.target.value),placeholder:"ghp_...","aria-label":"GitHub token",className:"min-w-0 flex-1 border border-border bg-transparent px-2 py-1 text-sm focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"button",onClick:()=>{const g=r.trim();g&&(p([...d,g]),s(""),l(!1))},disabled:!r.trim()||v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"add"}),u.jsx("button",{type:"button",onClick:()=>{l(!1),s("")},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"cancel"})]}):null]}),u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Repository links in PR comments"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Link oh-my-pr back to its repository in agent-authored GitHub PR comments and footers."})]}),u.jsx("input",{type:"checkbox","aria-label":"Repository links in PR comments",checked:t?.includeRepositoryLinksInGitHubComments??!0,onChange:g=>v.mutate({includeRepositoryLinksInGitHubComments:g.target.checked}),disabled:v.isPending,className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Trusted reviewers"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:t?.trustedReviewers?.length?t.trustedReviewers.join(", "):"none configured"})]}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Ignored bots"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:t?.ignoredBots?.length?t.ignoredBots.join(", "):"none configured"})]})]})]})]})})]})}function Tn({label:t,description:r,value:s,onChange:a,disabled:l}){const d=`setting-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`,p=`${d}-description`;return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{htmlFor:d,className:"text-sm",children:t}),u.jsx("div",{id:p,className:"text-[11px] text-muted-foreground",children:r})]}),u.jsx("input",{id:d,type:"number",value:s,onChange:h=>{const y=parseInt(h.target.value,10);isNaN(y)||a(y)},disabled:l,"aria-describedby":p,className:"w-28 border border-border bg-transparent px-2 py-1 text-right text-sm focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50"})]})}function pN(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function hN(t){const r=t.match(/##\s*Twitter\/X\s*(?:Thread)?\n([\s\S]*?)(?=\n##\s|\s*$)/i),s=t.match(/##\s*LinkedIn\s*(?:\/\s*General)?\n([\s\S]*?)(?=\n##\s|\s*$)/i);return{twitter:r?r[1].trim():null,linkedin:s?s[1].trim():null}}function mN({text:t}){const[r,s]=m.useState(!1),a=async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)}catch{}};return u.jsx("button",{type:"button",onClick:a,className:"border border-border px-2 py-0.5 text-[11px] uppercase tracking-wider text-muted-foreground hover:border-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:r?"copied":"copy"})}function hu({title:t,content:r}){return u.jsxs("div",{className:"mt-4",children:[u.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[u.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:t}),u.jsx(mN,{text:r})]}),u.jsx("pre",{className:"whitespace-pre-wrap border border-border bg-background p-3 text-[12px] leading-relaxed font-mono",children:r})]})}function gN({status:t}){const r=t==="done"?"border-foreground/40 text-foreground":t==="generating"?"border-border text-muted-foreground animate-pulse":"border-destructive/40 text-destructive";return u.jsx("span",{className:`border px-1.5 py-0 text-[10px] uppercase tracking-wider ${r}`,children:t})}function vN({changelog:t}){const[r,s]=m.useState(!1),a=t.content?hN(t.content):null,l=`changelog-${t.id}-content`;return u.jsxs("div",{className:"border border-border",children:[u.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-4 py-3 text-left hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default disabled:hover:bg-transparent",onClick:()=>t.status==="done"&&s(d=>!d),disabled:t.status!=="done","aria-expanded":t.status==="done"?r:void 0,"aria-controls":t.status==="done"?l:void 0,children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(gN,{status:t.status}),u.jsx("span",{className:"text-sm font-medium",children:pN(t.createdAt)}),u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[t.triggerCount," PR",t.triggerCount!==1?"s":""," merged"]}),u.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.prSummaries.map(d=>`#${d.number}`).join(" · ")})]}),t.status==="done"&&u.jsx("span",{className:"text-[11px] text-muted-foreground",children:r?"Hide":"Show"})]}),r&&t.status==="done"&&u.jsxs("div",{id:l,className:"border-t border-border px-4 pb-4 pt-3",children:[t.error&&u.jsx("p",{className:"mb-3 text-[12px] text-destructive",children:t.error}),a?.twitter&&u.jsx(hu,{title:"Twitter / X Thread",content:a.twitter}),a?.linkedin&&u.jsx(hu,{title:"LinkedIn / General",content:a.linkedin}),!a?.twitter&&!a?.linkedin&&t.content&&u.jsx(hu,{title:"Full output",content:t.content})]}),t.status==="error"&&t.error&&u.jsx("div",{className:"border-t border-border px-4 py-3",children:u.jsx("p",{className:"text-[12px] text-destructive",children:t.error})}),t.status==="generating"&&u.jsx("div",{className:"border-t border-border px-4 py-2.5",children:u.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Generating social media post with AI agent…"})})]})}function yN(){const{data:t=[],isLoading:r}=dt({queryKey:["/api/changelogs"],refetchInterval:s=>s.state.data?.some(l=>l.status==="generating")?5e3:!1});return u.jsxs("div",{className:"flex min-h-screen flex-col",children:[u.jsx(Bi,{}),u.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-label":"oh-my-pr",children:[u.jsx("rect",{x:"1",y:"1",width:"14",height:"14",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M4 5h8M4 8h5M4 11h6",stroke:"currentColor",strokeWidth:"1"})]}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"oh-my-pr"}),u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"changelogs"})]}),u.jsx(An,{href:"/",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"← back to dashboard"})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsxs("div",{className:"mx-auto max-w-3xl",children:[u.jsxs("div",{className:"mb-5",children:[u.jsx("h1",{className:"text-base font-medium",children:"Social Media Changelogs"}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Generated automatically every 5 PRs merged to main. Copy and paste into Twitter/X or LinkedIn."})]}),!r&&t.length===0&&u.jsxs("div",{className:"border border-border px-4 py-8 text-center",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"No changelogs yet."}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"A post will be generated automatically after every 5 PRs are merged to main."})]}),r&&u.jsx("div",{className:"border border-border px-4 py-6 text-center",children:u.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading…"})}),u.jsx("div",{className:"flex flex-col gap-2",children:t.map(s=>u.jsx(vN,{changelog:s},s.id))})]})})]})}const xN=new Set(["detected","evaluating","proposed","publishing"]);function Vv(t){return xN.has(t)}function wN(t){return t==="published"||t==="skipped"||t==="error"}function bN(t){return typeof t=="object"&&t!==null&&"status"in t&&typeof t.status=="string"}function mu(t){if(!t)return"n/a";const r=new Date(t);return Number.isNaN(r.getTime())?"n/a":r.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function SN(t){return t?t.slice(0,7):"n/a"}function CN({status:t}){const r=t==="published"?"border-foreground/40 text-foreground":t==="skipped"?"border-border text-muted-foreground":t==="error"?"border-destructive/40 text-destructive":Vv(t)?"border-border text-muted-foreground animate-pulse":"border-border text-muted-foreground";return u.jsx("span",{className:`border px-1.5 py-0 text-[10px] uppercase tracking-wider ${r}`,children:t})}function kN({text:t}){const[r,s]=m.useState(!1),a=async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch(l){const d=l instanceof Error?l.message:"Clipboard write failed";Vt({variant:"destructive",description:`Failed to copy: ${d}`})}};return u.jsx("button",{type:"button",onClick:a,className:"border border-border px-2 py-0.5 text-[11px] uppercase tracking-wider text-muted-foreground hover:border-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:r?"copied":"copy"})}function EN({run:t,onRetry:r,retryPending:s}){const[a,l]=m.useState(!1),p=!(!!t.decisionReason||!!t.releaseTitle||!!t.releaseNotes||!!t.error||!!t.githubReleaseUrl||t.includedPrs.length>0)&&wN(t.status),h=`release-run-${t.id}-details`;return u.jsxs("div",{className:"border border-border",children:[u.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-4 py-3 text-left hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>l(y=>!y),"aria-expanded":a,"aria-controls":h,children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[u.jsx(CN,{status:t.status}),u.jsx("span",{className:"truncate text-sm font-medium",children:t.repo}),u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",t.triggerPrNumber]}),t.proposedVersion&&u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.proposedVersion}),!t.proposedVersion&&t.recommendedBump&&u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["bump ",t.recommendedBump]})]}),u.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground",children:[u.jsx("span",{children:mu(t.createdAt)}),u.jsx("span",{children:a?"Hide":"Show"})]})]}),a&&u.jsxs("div",{id:h,className:"border-t border-border px-4 pb-4 pt-3",children:[u.jsxs("div",{className:"mb-3 text-[12px] text-muted-foreground",children:["Trigger PR:"," ",u.jsxs("a",{href:t.triggerPrUrl,target:"_blank",rel:"noreferrer noopener",className:"underline underline-offset-2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:["#",t.triggerPrNumber," ",t.triggerPrTitle]})]}),t.decisionReason&&u.jsx("p",{className:"mb-3 text-[12px] leading-relaxed",children:t.decisionReason}),t.releaseTitle&&u.jsxs("p",{className:"mb-3 text-[12px]",children:[u.jsx("span",{className:"text-muted-foreground",children:"Release title:"})," ",u.jsx("span",{children:t.releaseTitle})]}),u.jsxs("div",{className:"mb-3 grid grid-cols-1 gap-2 text-[12px] text-muted-foreground md:grid-cols-2",children:[u.jsxs("div",{children:["Base branch: ",t.baseBranch||"n/a"]}),u.jsxs("div",{children:["Trigger SHA: ",SN(t.triggerMergeSha)]}),u.jsxs("div",{children:["Merged at: ",mu(t.triggerMergedAt)]}),u.jsxs("div",{children:["Updated: ",mu(t.updatedAt)]})]}),t.includedPrs.length>0&&u.jsxs("div",{className:"mb-3",children:[u.jsxs("div",{className:"mb-1.5 text-[11px] uppercase tracking-wider text-muted-foreground",children:["Included PRs (",t.includedPrs.length,")"]}),u.jsx("div",{className:"space-y-1 border border-border p-3 text-[12px]",children:t.includedPrs.map(y=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"truncate",children:["#",y.number," ",y.title]}),u.jsx("a",{href:y.url,target:"_blank",rel:"noreferrer noopener",className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"open"})]},`${y.mergeSha}-${y.number}`))})]}),t.releaseNotes&&u.jsxs("div",{className:"mb-3",children:[u.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[u.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Release Notes"}),u.jsx(kN,{text:t.releaseNotes})]}),u.jsx("pre",{className:"whitespace-pre-wrap border border-border bg-background p-3 text-[12px] leading-relaxed font-mono",children:t.releaseNotes})]}),t.error&&u.jsx("div",{className:"mb-3 border border-destructive/40 bg-destructive/5 p-3 text-[12px] text-destructive",children:t.error}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.githubReleaseUrl&&u.jsx("a",{href:t.githubReleaseUrl,target:"_blank",rel:"noreferrer noopener",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"open release"}),t.status==="error"&&u.jsx("button",{type:"button",onClick:()=>r(t.id),disabled:s,className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"retry"})]}),p&&u.jsx("p",{className:"mt-2 text-[12px] text-muted-foreground",children:"No details available yet."})]})]})}function NN(){const{data:t=[],isLoading:r}=dt({queryKey:["/api/releases"],refetchInterval:a=>{const l=a.state.data;return Array.isArray(l)&&l.some(d=>bN(d)&&Vv(d.status))?5e3:!1}}),s=ct({mutationFn:async a=>(await nt("POST",`/api/releases/${a}/retry`)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/releases"]}),Vt({description:"Retry queued."})},onError:a=>{Vt({variant:"destructive",description:`Retry failed: ${a.message}`})}});return u.jsxs("div",{className:"flex min-h-screen flex-col",children:[u.jsx(Bi,{}),u.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-label":"Release Management",children:[u.jsx("rect",{x:"1",y:"1",width:"14",height:"14",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M4 6h8M4 9h8M4 12h5",stroke:"currentColor",strokeWidth:"1"})]}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"oh-my-pr"}),u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"releases"})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(An,{href:"/settings",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"settings"}),u.jsx(An,{href:"/",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"← back to dashboard"})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsxs("div",{className:"mx-auto max-w-4xl",children:[u.jsxs("div",{className:"mb-5",children:[u.jsx("h1",{className:"text-base font-medium",children:"Release Management"}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Every merged PR can trigger agent evaluation. This page shows release decisions, version bumps, notes, and publishing outcomes."})]}),r&&u.jsx("div",{className:"border border-border px-4 py-6 text-center",children:u.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading…"})}),!r&&t.length===0&&u.jsxs("div",{className:"border border-border px-4 py-8 text-center",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"No release runs yet."}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Runs appear after merged PRs are evaluated for release-worthiness."})]}),u.jsx("div",{className:"flex flex-col gap-2",children:t.map(a=>u.jsx(EN,{run:a,onRetry:l=>s.mutate(l),retryPending:s.isPending},a.id))})]})})]})}const Qv=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",t),...r}));Qv.displayName="Card";const RN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("flex flex-col space-y-1.5 p-6",t),...r}));RN.displayName="CardHeader";const PN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("text-2xl font-semibold leading-none tracking-tight",t),...r}));PN.displayName="CardTitle";const jN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("text-sm text-muted-foreground",t),...r}));jN.displayName="CardDescription";const Gv=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("p-6 pt-0",t),...r}));Gv.displayName="CardContent";const TN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("flex items-center p-6 pt-0",t),...r}));TN.displayName="CardFooter";function _N(){return u.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-gray-50",children:u.jsx(Qv,{className:"w-full max-w-md mx-4",children:u.jsxs(Gv,{className:"pt-6",children:[u.jsxs("div",{className:"flex mb-4 gap-2",children:[u.jsx(k0,{className:"h-8 w-8 text-red-500"}),u.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"404 Page Not Found"})]}),u.jsx("p",{className:"mt-4 text-sm text-gray-600",children:"Did you forget to add the page to the router?"})]})})})}function ON(){return u.jsxs(xw,{children:[u.jsx(Oo,{path:"/",component:dN}),u.jsx(Oo,{path:"/settings",component:fN}),u.jsx(Oo,{path:"/changelogs",component:yN}),u.jsx(Oo,{path:"/releases",component:NN}),u.jsx(Oo,{component:_N})]})}function AN(){return u.jsx(ub,{attribute:"class",defaultTheme:"system",enableSystem:!0,children:u.jsx(Qw,{client:we,children:u.jsxs(KS,{children:[u.jsx(l1,{}),u.jsx(Uh,{hook:Bh,children:u.jsx(ON,{})})]})})})}window.location.hash||(window.location.hash="#/");Jx.createRoot(document.getElementById("root")).render(u.jsx(AN,{}));
48
+ `)},pk=0,Ar=[];function hk(t){var r=m.useRef([]),s=m.useRef([0,0]),a=m.useRef(),l=m.useState(pk++)[0],d=m.useState($g)[0],p=m.useRef(t);m.useEffect(function(){p.current=t},[t]),m.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(l));var S=IC([t.lockRef.current],(t.shards||[]).map(Eh),!0).filter(Boolean);return S.forEach(function(C){return C.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),S.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(l))})}}},[t.inert,t.lockRef.current,t.shards]);var h=m.useCallback(function(S,C){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!p.current.allowPinchZoom;var _=hi(S),A=s.current,O="deltaX"in S?S.deltaX:A[0]-_[0],I="deltaY"in S?S.deltaY:A[1]-_[1],F,L=S.target,U=Math.abs(O)>Math.abs(I)?"h":"v";if("touches"in S&&U==="h"&&L.type==="range")return!1;var q=window.getSelection(),te=q&&q.anchorNode,ne=te?te===L||te.contains(L):!1;if(ne)return!1;var se=Ch(U,L);if(!se)return!0;if(se?F=U:(F=U==="v"?"h":"v",se=Ch(U,L)),!se)return!1;if(!a.current&&"changedTouches"in S&&(O||I)&&(a.current=F),!F)return!0;var Y=a.current||F;return ck(Y,C,S,Y==="h"?O:I)},[]),y=m.useCallback(function(S){var C=S;if(!(!Ar.length||Ar[Ar.length-1]!==d)){var _="deltaY"in C?kh(C):hi(C),A=r.current.filter(function(F){return F.name===C.type&&(F.target===C.target||C.target===F.shadowParent)&&dk(F.delta,_)})[0];if(A&&A.should){C.cancelable&&C.preventDefault();return}if(!A){var O=(p.current.shards||[]).map(Eh).filter(Boolean).filter(function(F){return F.contains(C.target)}),I=O.length>0?h(C,O[0]):!p.current.noIsolation;I&&C.cancelable&&C.preventDefault()}}},[]),v=m.useCallback(function(S,C,_,A){var O={name:S,delta:C,target:_,should:A,shadowParent:mk(_)};r.current.push(O),setTimeout(function(){r.current=r.current.filter(function(I){return I!==O})},1)},[]),g=m.useCallback(function(S){s.current=hi(S),a.current=void 0},[]),w=m.useCallback(function(S){v(S.type,kh(S),S.target,h(S,t.lockRef.current))},[]),b=m.useCallback(function(S){v(S.type,hi(S),S.target,h(S,t.lockRef.current))},[]);m.useEffect(function(){return Ar.push(d),t.setCallbacks({onScrollCapture:w,onWheelCapture:w,onTouchMoveCapture:b}),document.addEventListener("wheel",y,Or),document.addEventListener("touchmove",y,Or),document.addEventListener("touchstart",g,Or),function(){Ar=Ar.filter(function(S){return S!==d}),document.removeEventListener("wheel",y,Or),document.removeEventListener("touchmove",y,Or),document.removeEventListener("touchstart",g,Or)}},[]);var E=t.removeScrollBar,N=t.inert;return m.createElement(m.Fragment,null,N?m.createElement(d,{styles:fk(l)}):null,E?m.createElement(rk,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function mk(t){for(var r=null;t!==null;)t instanceof ShadowRoot&&(r=t.host,t=t.host),t=t.parentNode;return r}const gk=WC(Fg,hk);var Bg=m.forwardRef(function(t,r){return m.createElement(Wi,Bt({},t,{ref:r,sideCar:gk}))});Bg.classNames=Wi.classNames;var Mu=["Enter"," "],vk=["ArrowDown","PageUp","Home"],Wg=["ArrowUp","PageDown","End"],yk=[...vk,...Wg],xk={ltr:[...Mu,"ArrowRight"],rtl:[...Mu,"ArrowLeft"]},wk={ltr:["ArrowLeft"],rtl:["ArrowRight"]},qo="Menu",[Ho,bk,Sk]=Qu(qo),[rr,Kg]=Ln(qo,[Sk,Fi,Tg]),Ki=Fi(),Vg=Tg(),[Ck,or]=rr(qo),[kk,Yo]=rr(qo),Qg=t=>{const{__scopeMenu:r,open:s=!1,children:a,dir:l,onOpenChange:d,modal:p=!0}=t,h=Ki(r),[y,v]=m.useState(null),g=m.useRef(!1),w=yt(d),b=Ng(l);return m.useEffect(()=>{const E=()=>{g.current=!0,document.addEventListener("pointerdown",N,{capture:!0,once:!0}),document.addEventListener("pointermove",N,{capture:!0,once:!0})},N=()=>g.current=!1;return document.addEventListener("keydown",E,{capture:!0}),()=>{document.removeEventListener("keydown",E,{capture:!0}),document.removeEventListener("pointerdown",N,{capture:!0}),document.removeEventListener("pointermove",N,{capture:!0})}},[]),u.jsx(sg,{...h,children:u.jsx(Ck,{scope:r,open:s,onOpenChange:w,content:y,onContentChange:v,children:u.jsx(kk,{scope:r,onClose:m.useCallback(()=>w(!1),[w]),isUsingKeyboardRef:g,dir:b,modal:p,children:a})})})};Qg.displayName=qo;var Ek="MenuAnchor",fc=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t,l=Ki(s);return u.jsx(ig,{...l,...a,ref:r})});fc.displayName=Ek;var pc="MenuPortal",[Nk,Gg]=rr(pc,{forceMount:void 0}),qg=t=>{const{__scopeMenu:r,forceMount:s,children:a,container:l}=t,d=or(pc,r);return u.jsx(Nk,{scope:r,forceMount:s,children:u.jsx(Fn,{present:s||d.open,children:u.jsx(qu,{asChild:!0,container:l,children:a})})})};qg.displayName=pc;var Nt="MenuContent",[Rk,hc]=rr(Nt),Yg=m.forwardRef((t,r)=>{const s=Gg(Nt,t.__scopeMenu),{forceMount:a=s.forceMount,...l}=t,d=or(Nt,t.__scopeMenu),p=Yo(Nt,t.__scopeMenu);return u.jsx(Ho.Provider,{scope:t.__scopeMenu,children:u.jsx(Fn,{present:a||d.open,children:u.jsx(Ho.Slot,{scope:t.__scopeMenu,children:p.modal?u.jsx(Pk,{...l,ref:r}):u.jsx(jk,{...l,ref:r})})})})}),Pk=m.forwardRef((t,r)=>{const s=or(Nt,t.__scopeMenu),a=m.useRef(null),l=He(r,a);return m.useEffect(()=>{const d=a.current;if(d)return MC(d)},[]),u.jsx(mc,{...t,ref:l,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:ce(t.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),jk=m.forwardRef((t,r)=>{const s=or(Nt,t.__scopeMenu);return u.jsx(mc,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),Tk=EC("MenuContent.ScrollLock"),mc=m.forwardRef((t,r)=>{const{__scopeMenu:s,loop:a=!1,trapFocus:l,onOpenAutoFocus:d,onCloseAutoFocus:p,disableOutsidePointerEvents:h,onEntryFocus:y,onEscapeKeyDown:v,onPointerDownOutside:g,onFocusOutside:w,onInteractOutside:b,onDismiss:E,disableOutsideScroll:N,...S}=t,C=or(Nt,s),_=Yo(Nt,s),A=Ki(s),O=Vg(s),I=bk(s),[F,L]=m.useState(null),U=m.useRef(null),q=He(r,U,C.onContentChange),te=m.useRef(0),ne=m.useRef(""),se=m.useRef(0),Y=m.useRef(null),ae=m.useRef("right"),G=m.useRef(0),me=N?Bg:m.Fragment,ee=N?{as:Tk,allowPinchZoom:!0}:void 0,ie=z=>{const V=ne.current+z,T=I().filter(he=>!he.disabled),H=document.activeElement,de=T.find(he=>he.ref.current===H)?.textValue,pe=T.map(he=>he.textValue),xe=Hk(pe,V,de),ve=T.find(he=>he.textValue===xe)?.ref.current;(function he(be){ne.current=be,window.clearTimeout(te.current),be!==""&&(te.current=window.setTimeout(()=>he(""),1e3))})(V),ve&&setTimeout(()=>ve.focus())};m.useEffect(()=>()=>window.clearTimeout(te.current),[]),sC();const P=m.useCallback(z=>ae.current===Y.current?.side&&Wk(z,Y.current?.area),[]);return u.jsx(Rk,{scope:s,searchRef:ne,onItemEnter:m.useCallback(z=>{P(z)&&z.preventDefault()},[P]),onItemLeave:m.useCallback(z=>{P(z)||(U.current?.focus(),L(null))},[P]),onTriggerLeave:m.useCallback(z=>{P(z)&&z.preventDefault()},[P]),pointerGraceTimerRef:se,onPointerGraceIntentChange:m.useCallback(z=>{Y.current=z},[]),children:u.jsx(me,{...ee,children:u.jsx(Rg,{asChild:!0,trapped:l,onMountAutoFocus:ce(d,z=>{z.preventDefault(),U.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:p,children:u.jsx(_i,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:v,onPointerDownOutside:g,onFocusOutside:w,onInteractOutside:b,onDismiss:E,children:u.jsx(CC,{asChild:!0,...O,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:F,onCurrentTabStopIdChange:L,onEntryFocus:ce(y,z=>{_.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ag,{role:"menu","aria-orientation":"vertical","data-state":fv(C.open),"data-radix-menu-content":"",dir:_.dir,...A,...S,ref:q,style:{outline:"none",...S.style},onKeyDown:ce(S.onKeyDown,z=>{const T=z.target.closest("[data-radix-menu-content]")===z.currentTarget,H=z.ctrlKey||z.altKey||z.metaKey,de=z.key.length===1;T&&(z.key==="Tab"&&z.preventDefault(),!H&&de&&ie(z.key));const pe=U.current;if(z.target!==pe||!yk.includes(z.key))return;z.preventDefault();const ve=I().filter(he=>!he.disabled).map(he=>he.ref.current);Wg.includes(z.key)&&ve.reverse(),zk(ve)}),onBlur:ce(t.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(te.current),ne.current="")}),onPointerMove:ce(t.onPointerMove,Bo(z=>{const V=z.target,T=G.current!==z.clientX;if(z.currentTarget.contains(V)&&T){const H=z.clientX>G.current?"right":"left";ae.current=H,G.current=z.clientX}}))})})})})})})});Yg.displayName=Nt;var _k="MenuGroup",gc=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t;return u.jsx(Re.div,{role:"group",...a,ref:r})});gc.displayName=_k;var Ok="MenuLabel",Xg=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t;return u.jsx(Re.div,{...a,ref:r})});Xg.displayName=Ok;var Ni="MenuItem",Nh="menu.itemSelect",Vi=m.forwardRef((t,r)=>{const{disabled:s=!1,onSelect:a,...l}=t,d=m.useRef(null),p=Yo(Ni,t.__scopeMenu),h=hc(Ni,t.__scopeMenu),y=He(r,d),v=m.useRef(!1),g=()=>{const w=d.current;if(!s&&w){const b=new CustomEvent(Nh,{bubbles:!0,cancelable:!0});w.addEventListener(Nh,E=>a?.(E),{once:!0}),Gu(w,b),b.defaultPrevented?v.current=!1:p.onClose()}};return u.jsx(Zg,{...l,ref:y,disabled:s,onClick:ce(t.onClick,g),onPointerDown:w=>{t.onPointerDown?.(w),v.current=!0},onPointerUp:ce(t.onPointerUp,w=>{v.current||w.currentTarget?.click()}),onKeyDown:ce(t.onKeyDown,w=>{const b=h.searchRef.current!=="";s||b&&w.key===" "||Mu.includes(w.key)&&(w.currentTarget.click(),w.preventDefault())})})});Vi.displayName=Ni;var Zg=m.forwardRef((t,r)=>{const{__scopeMenu:s,disabled:a=!1,textValue:l,...d}=t,p=hc(Ni,s),h=Vg(s),y=m.useRef(null),v=He(r,y),[g,w]=m.useState(!1),[b,E]=m.useState("");return m.useEffect(()=>{const N=y.current;N&&E((N.textContent??"").trim())},[d.children]),u.jsx(Ho.ItemSlot,{scope:s,disabled:a,textValue:l??b,children:u.jsx(kC,{asChild:!0,...h,focusable:!a,children:u.jsx(Re.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...d,ref:v,onPointerMove:ce(t.onPointerMove,Bo(N=>{a?p.onItemLeave(N):(p.onItemEnter(N),N.defaultPrevented||N.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(t.onPointerLeave,Bo(N=>p.onItemLeave(N))),onFocus:ce(t.onFocus,()=>w(!0)),onBlur:ce(t.onBlur,()=>w(!1))})})})}),Ak="MenuCheckboxItem",Jg=m.forwardRef((t,r)=>{const{checked:s=!1,onCheckedChange:a,...l}=t;return u.jsx(ov,{scope:t.__scopeMenu,checked:s,children:u.jsx(Vi,{role:"menuitemcheckbox","aria-checked":Ri(s)?"mixed":s,...l,ref:r,"data-state":yc(s),onSelect:ce(l.onSelect,()=>a?.(Ri(s)?!0:!s),{checkForDefaultPrevented:!1})})})});Jg.displayName=Ak;var ev="MenuRadioGroup",[Mk,Ik]=rr(ev,{value:void 0,onValueChange:()=>{}}),tv=m.forwardRef((t,r)=>{const{value:s,onValueChange:a,...l}=t,d=yt(a);return u.jsx(Mk,{scope:t.__scopeMenu,value:s,onValueChange:d,children:u.jsx(gc,{...l,ref:r})})});tv.displayName=ev;var nv="MenuRadioItem",rv=m.forwardRef((t,r)=>{const{value:s,...a}=t,l=Ik(nv,t.__scopeMenu),d=s===l.value;return u.jsx(ov,{scope:t.__scopeMenu,checked:d,children:u.jsx(Vi,{role:"menuitemradio","aria-checked":d,...a,ref:r,"data-state":yc(d),onSelect:ce(a.onSelect,()=>l.onValueChange?.(s),{checkForDefaultPrevented:!1})})})});rv.displayName=nv;var vc="MenuItemIndicator",[ov,Dk]=rr(vc,{checked:!1}),sv=m.forwardRef((t,r)=>{const{__scopeMenu:s,forceMount:a,...l}=t,d=Dk(vc,s);return u.jsx(Fn,{present:a||Ri(d.checked)||d.checked===!0,children:u.jsx(Re.span,{...l,ref:r,"data-state":yc(d.checked)})})});sv.displayName=vc;var Lk="MenuSeparator",iv=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t;return u.jsx(Re.div,{role:"separator","aria-orientation":"horizontal",...a,ref:r})});iv.displayName=Lk;var Fk="MenuArrow",av=m.forwardRef((t,r)=>{const{__scopeMenu:s,...a}=t,l=Ki(s);return u.jsx(lg,{...l,...a,ref:r})});av.displayName=Fk;var $k="MenuSub",[DN,lv]=rr($k),Do="MenuSubTrigger",uv=m.forwardRef((t,r)=>{const s=or(Do,t.__scopeMenu),a=Yo(Do,t.__scopeMenu),l=lv(Do,t.__scopeMenu),d=hc(Do,t.__scopeMenu),p=m.useRef(null),{pointerGraceTimerRef:h,onPointerGraceIntentChange:y}=d,v={__scopeMenu:t.__scopeMenu},g=m.useCallback(()=>{p.current&&window.clearTimeout(p.current),p.current=null},[]);return m.useEffect(()=>g,[g]),m.useEffect(()=>{const w=h.current;return()=>{window.clearTimeout(w),y(null)}},[h,y]),u.jsx(fc,{asChild:!0,...v,children:u.jsx(Zg,{id:l.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":l.contentId,"data-state":fv(s.open),...t,ref:zr(r,l.onTriggerChange),onClick:w=>{t.onClick?.(w),!(t.disabled||w.defaultPrevented)&&(w.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:ce(t.onPointerMove,Bo(w=>{d.onItemEnter(w),!w.defaultPrevented&&!t.disabled&&!s.open&&!p.current&&(d.onPointerGraceIntentChange(null),p.current=window.setTimeout(()=>{s.onOpenChange(!0),g()},100))})),onPointerLeave:ce(t.onPointerLeave,Bo(w=>{g();const b=s.content?.getBoundingClientRect();if(b){const E=s.content?.dataset.side,N=E==="right",S=N?-5:5,C=b[N?"left":"right"],_=b[N?"right":"left"];d.onPointerGraceIntentChange({area:[{x:w.clientX+S,y:w.clientY},{x:C,y:b.top},{x:_,y:b.top},{x:_,y:b.bottom},{x:C,y:b.bottom}],side:E}),window.clearTimeout(h.current),h.current=window.setTimeout(()=>d.onPointerGraceIntentChange(null),300)}else{if(d.onTriggerLeave(w),w.defaultPrevented)return;d.onPointerGraceIntentChange(null)}})),onKeyDown:ce(t.onKeyDown,w=>{const b=d.searchRef.current!=="";t.disabled||b&&w.key===" "||xk[a.dir].includes(w.key)&&(s.onOpenChange(!0),s.content?.focus(),w.preventDefault())})})})});uv.displayName=Do;var cv="MenuSubContent",dv=m.forwardRef((t,r)=>{const s=Gg(Nt,t.__scopeMenu),{forceMount:a=s.forceMount,...l}=t,d=or(Nt,t.__scopeMenu),p=Yo(Nt,t.__scopeMenu),h=lv(cv,t.__scopeMenu),y=m.useRef(null),v=He(r,y);return u.jsx(Ho.Provider,{scope:t.__scopeMenu,children:u.jsx(Fn,{present:a||d.open,children:u.jsx(Ho.Slot,{scope:t.__scopeMenu,children:u.jsx(mc,{id:h.contentId,"aria-labelledby":h.triggerId,...l,ref:v,align:"start",side:p.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:g=>{p.isUsingKeyboardRef.current&&y.current?.focus(),g.preventDefault()},onCloseAutoFocus:g=>g.preventDefault(),onFocusOutside:ce(t.onFocusOutside,g=>{g.target!==h.trigger&&d.onOpenChange(!1)}),onEscapeKeyDown:ce(t.onEscapeKeyDown,g=>{p.onClose(),g.preventDefault()}),onKeyDown:ce(t.onKeyDown,g=>{const w=g.currentTarget.contains(g.target),b=wk[p.dir].includes(g.key);w&&b&&(d.onOpenChange(!1),h.trigger?.focus(),g.preventDefault())})})})})})});dv.displayName=cv;function fv(t){return t?"open":"closed"}function Ri(t){return t==="indeterminate"}function yc(t){return Ri(t)?"indeterminate":t?"checked":"unchecked"}function zk(t){const r=document.activeElement;for(const s of t)if(s===r||(s.focus(),document.activeElement!==r))return}function Uk(t,r){return t.map((s,a)=>t[(r+a)%t.length])}function Hk(t,r,s){const l=r.length>1&&Array.from(r).every(v=>v===r[0])?r[0]:r,d=s?t.indexOf(s):-1;let p=Uk(t,Math.max(d,0));l.length===1&&(p=p.filter(v=>v!==s));const y=p.find(v=>v.toLowerCase().startsWith(l.toLowerCase()));return y!==s?y:void 0}function Bk(t,r){const{x:s,y:a}=t;let l=!1;for(let d=0,p=r.length-1;d<r.length;p=d++){const h=r[d],y=r[p],v=h.x,g=h.y,w=y.x,b=y.y;g>a!=b>a&&s<(w-v)*(a-g)/(b-g)+v&&(l=!l)}return l}function Wk(t,r){if(!r)return!1;const s={x:t.clientX,y:t.clientY};return Bk(s,r)}function Bo(t){return r=>r.pointerType==="mouse"?t(r):void 0}var Kk=Qg,Vk=fc,Qk=qg,Gk=Yg,qk=gc,Yk=Xg,Xk=Vi,Zk=Jg,Jk=tv,eE=rv,tE=sv,nE=iv,rE=av,oE=uv,sE=dv,Qi="DropdownMenu",[iE]=Ln(Qi,[Kg]),rt=Kg(),[aE,pv]=iE(Qi),hv=t=>{const{__scopeDropdownMenu:r,children:s,dir:a,open:l,defaultOpen:d,onOpenChange:p,modal:h=!0}=t,y=rt(r),v=m.useRef(null),[g,w]=Ko({prop:l,defaultProp:d??!1,onChange:p,caller:Qi});return u.jsx(aE,{scope:r,triggerId:$o(),triggerRef:v,contentId:$o(),open:g,onOpenChange:w,onOpenToggle:m.useCallback(()=>w(b=>!b),[w]),modal:h,children:u.jsx(Kk,{...y,open:g,onOpenChange:w,dir:a,modal:h,children:s})})};hv.displayName=Qi;var mv="DropdownMenuTrigger",gv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,disabled:a=!1,...l}=t,d=pv(mv,s),p=rt(s);return u.jsx(Vk,{asChild:!0,...p,children:u.jsx(Re.button,{type:"button",id:d.triggerId,"aria-haspopup":"menu","aria-expanded":d.open,"aria-controls":d.open?d.contentId:void 0,"data-state":d.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...l,ref:zr(r,d.triggerRef),onPointerDown:ce(t.onPointerDown,h=>{!a&&h.button===0&&h.ctrlKey===!1&&(d.onOpenToggle(),d.open||h.preventDefault())}),onKeyDown:ce(t.onKeyDown,h=>{a||(["Enter"," "].includes(h.key)&&d.onOpenToggle(),h.key==="ArrowDown"&&d.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(h.key)&&h.preventDefault())})})})});gv.displayName=mv;var lE="DropdownMenuPortal",vv=t=>{const{__scopeDropdownMenu:r,...s}=t,a=rt(r);return u.jsx(Qk,{...a,...s})};vv.displayName=lE;var yv="DropdownMenuContent",xv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=pv(yv,s),d=rt(s),p=m.useRef(!1);return u.jsx(Gk,{id:l.contentId,"aria-labelledby":l.triggerId,...d,...a,ref:r,onCloseAutoFocus:ce(t.onCloseAutoFocus,h=>{p.current||l.triggerRef.current?.focus(),p.current=!1,h.preventDefault()}),onInteractOutside:ce(t.onInteractOutside,h=>{const y=h.detail.originalEvent,v=y.button===0&&y.ctrlKey===!0,g=y.button===2||v;(!l.modal||g)&&(p.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xv.displayName=yv;var uE="DropdownMenuGroup",cE=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(qk,{...l,...a,ref:r})});cE.displayName=uE;var dE="DropdownMenuLabel",wv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Yk,{...l,...a,ref:r})});wv.displayName=dE;var fE="DropdownMenuItem",bv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Xk,{...l,...a,ref:r})});bv.displayName=fE;var pE="DropdownMenuCheckboxItem",Sv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Zk,{...l,...a,ref:r})});Sv.displayName=pE;var hE="DropdownMenuRadioGroup",mE=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(Jk,{...l,...a,ref:r})});mE.displayName=hE;var gE="DropdownMenuRadioItem",Cv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(eE,{...l,...a,ref:r})});Cv.displayName=gE;var vE="DropdownMenuItemIndicator",kv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(tE,{...l,...a,ref:r})});kv.displayName=vE;var yE="DropdownMenuSeparator",Ev=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(nE,{...l,...a,ref:r})});Ev.displayName=yE;var xE="DropdownMenuArrow",wE=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(rE,{...l,...a,ref:r})});wE.displayName=xE;var bE="DropdownMenuSubTrigger",Nv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(oE,{...l,...a,ref:r})});Nv.displayName=bE;var SE="DropdownMenuSubContent",Rv=m.forwardRef((t,r)=>{const{__scopeDropdownMenu:s,...a}=t,l=rt(s);return u.jsx(sE,{...l,...a,ref:r,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Rv.displayName=SE;var CE=hv,kE=gv,EE=vv,Pv=xv,jv=wv,Tv=bv,_v=Sv,Ov=Cv,Av=kv,Mv=Ev,Iv=Nv,Dv=Rv;const NE=CE,RE=kE,PE=m.forwardRef(({className:t,inset:r,children:s,...a},l)=>u.jsxs(Iv,{ref:l,className:Le("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",t),...a,children:[s,u.jsx(C0,{className:"ml-auto"})]}));PE.displayName=Iv.displayName;const jE=m.forwardRef(({className:t,...r},s)=>u.jsx(Dv,{ref:s,className:Le("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...r}));jE.displayName=Dv.displayName;const Lv=m.forwardRef(({className:t,sideOffset:r=4,...s},a)=>u.jsx(EE,{children:u.jsx(Pv,{ref:a,sideOffset:r,className:Le("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s})}));Lv.displayName=Pv.displayName;const TE=m.forwardRef(({className:t,inset:r,...s},a)=>u.jsx(Tv,{ref:a,className:Le("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",t),...s}));TE.displayName=Tv.displayName;const _E=m.forwardRef(({className:t,children:r,checked:s,...a},l)=>u.jsxs(_v,{ref:l,className:Le("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...a,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Av,{children:u.jsx(S0,{className:"h-4 w-4"})})}),r]}));_E.displayName=_v.displayName;const OE=m.forwardRef(({className:t,children:r,...s},a)=>u.jsxs(Ov,{ref:a,className:Le("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Av,{children:u.jsx(E0,{className:"h-2 w-2 fill-current"})})}),r]}));OE.displayName=Ov.displayName;const AE=m.forwardRef(({className:t,inset:r,...s},a)=>u.jsx(jv,{ref:a,className:Le("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",t),...s}));AE.displayName=jv.displayName;const ME=m.forwardRef(({className:t,...r},s)=>u.jsx(Mv,{ref:s,className:Le("-mx-1 my-1 h-px bg-muted",t),...r}));ME.displayName=Mv.displayName;function IE(t){return t.replace("_"," ").toUpperCase()}function DE(t){return t==="in_progress"?"border-foreground text-foreground animate-pulse":t==="failed"?"border-destructive text-destructive":t==="warning"?"border-warning-border bg-warning-muted text-warning-foreground":t==="resolved"?"border-foreground/20 text-muted-foreground":t==="rejected"?"border-foreground/20 text-muted-foreground line-through":t==="flagged"?"border-foreground/40 text-foreground/60":t==="queued"?"border-foreground text-foreground":"border-foreground/30 text-foreground/60"}function Fv(t){return t==="resolved"||t==="rejected"}function LE(t){return Fv(t)||t==="warning"}function $v(t){return t.length===0?!1:t.every(r=>Fv(r.status))}function Wo(t){return t.reduce((r,s)=>(s.status==="queued"?r.queued+=1:s.status==="in_progress"?r.inProgress+=1:s.status==="failed"?r.failed+=1:s.status==="warning"&&(r.warning+=1),r),{queued:0,inProgress:0,failed:0,warning:0})}const FE={idle:"IDLE",triaging:"TRIAGING",awaiting_repair_slot:"REPAIR QUEUED",repairing:"REPAIRING",awaiting_ci:"WAITING FOR CI",verifying:"VERIFYING",healed:"HEALED",cooldown:"COOLDOWN",blocked:"BLOCKED",escalated:"ESCALATED",superseded:"SUPERSEDED"},$E={idle:[],triaging:["cancel"],awaiting_repair_slot:["pause","cancel"],repairing:["pause","cancel"],awaiting_ci:["pause","cancel"],verifying:["cancel"],healed:[],cooldown:["resume","cancel"],blocked:["retry"],escalated:["retry"],superseded:[]},zE={idle:"neutral",triaging:"info",awaiting_repair_slot:"warning",repairing:"info",awaiting_ci:"info",verifying:"info",healed:"success",cooldown:"warning",blocked:"danger",escalated:"danger",superseded:"neutral"},UE={idle:"Waiting for a new failing check on the current PR head.",triaging:"Classifying the current failure set before deciding whether it is safe to repair.",awaiting_repair_slot:"Ready for the next bounded repair attempt as soon as a slot is free.",repairing:"A repair agent is actively working in an isolated worktree.",awaiting_ci:"A repair was pushed and the new head SHA is waiting for CI to settle.",verifying:"Comparing the latest check results against the previous failure fingerprint.",healed:"The latest repair cycle converged to green and the session is complete.",cooldown:"Cooling down before another retry is allowed.",blocked:"Stopped because the failure looks external or unsafe to repair in-branch.",escalated:"Stopped because retries were exhausted or the failure did not improve.",superseded:"Replaced after the PR head moved to a newer commit."};function HE(t){return FE[t]}function BE(t){return $E[t]}function Rh(t){return t==="pause"?"Pause":t==="resume"?"Resume":t==="retry"?"Retry":"Cancel"}function WE(t){return zE[t]}function KE(t){return UE[t]}function VE(t){const r=t.attemptCount,s=r===1?"":"s";return r===0?t.state==="triaging"?"Preparing attempt 1":t.state==="awaiting_repair_slot"?"Queued for attempt 1":t.state==="healed"?"Healed without a repair attempt":"No repair attempts yet":t.state==="repairing"?`Attempt ${r} running`:t.state==="awaiting_ci"?`Attempt ${r} pushed, waiting on CI`:t.state==="verifying"?`Attempt ${r} verifying`:t.state==="healed"?`Healed after ${r} attempt${s}`:t.state==="blocked"?`${r} attempt${s} before blocking`:t.state==="escalated"?`${r} attempt${s} before escalation`:t.state==="cooldown"?`${r} attempt${s}, cooling down`:t.state==="superseded"?`${r} attempt${s}, superseded`:`${r} attempt${s} recorded`}function QE(t){return t?t.blockedReason??t.escalationReason??t.latestFingerprint??null:null}function GE(t,r){const s=t.filter(a=>a.prId===r);return s.length===0?null:s.reduce((a,l)=>l.updatedAt>a.updatedAt?l:a)}function qE(t,r){return GE(t,r)}function YE(t,r){return{stateLabel:HE(t.state),tone:WE(t.state),attemptSummary:VE(t),reasonSummary:QE(t),statusHint:KE(t.state),actions:BE(t.state).map(s=>({label:Rh(s),available:!0,hint:`${Rh(s)} controls are planned but not wired to the backend yet.`}))}}function Mt(t){return t?new Date(t).toLocaleTimeString("en-US",{hour12:!1}):null}function zv(t){return t.watchEnabled}function Uv(t){return t==="processing"?"autonomous run active":t==="done"?"completed":t==="error"?"attention needed":t==="archived"?"archived":"watching"}function XE(t){return`${Math.max(1,Math.round((t??12e4)/1e3))}s`}const ZE=[{value:"mine",label:"My PRs only"},{value:"team",label:"My PRs + teammates"}],JE={failed:[],inProgress:[],queued:[],warnings:[],generatedAt:""},fu=200;function eN(t){return t===!1?"team":"mine"}const Ph={neutral:"border-border text-muted-foreground",info:"border-foreground text-foreground",warning:"border-warning-border bg-warning-muted text-warning-foreground",success:"border-success-border bg-success-muted text-success-foreground",danger:"border-destructive text-destructive"};function Hv({status:t}){const r=t==="watching"?"bg-foreground/30":t==="processing"?"bg-foreground animate-pulse":t==="done"?"bg-foreground":t==="archived"?"bg-foreground/15":"bg-destructive";return u.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 ${r}`})}function tN({status:t}){const r=DE(t);return u.jsx("span",{className:`inline-block border px-1.5 py-0 text-[11px] uppercase tracking-wide ${r}`,children:IE(t)})}function Iu(){return u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"watch paused"})}function jh({value:t,onChange:r,disabled:s,name:a,testIdPrefix:l,compact:d=!1}){return u.jsx("div",{role:"radiogroup","aria-label":"Automatic PR tracking scope",className:`flex flex-wrap gap-1 ${d?"":"mt-1"}`,children:ZE.map(p=>{const h=t===p.value;return u.jsxs("label",{"data-testid":`${l}-${p.value}`,className:`cursor-pointer border px-2 text-[10px] transition-colors focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-1 focus-within:ring-offset-background ${d?"py-0.5":"py-1"} ${h?"border-foreground bg-muted text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${s?"cursor-not-allowed opacity-50":""} whitespace-nowrap`,children:[u.jsx("input",{type:"radio",name:a,value:p.value,checked:h,onChange:()=>r(p.value),disabled:s,className:"sr-only"}),p.label]},p.value)})})}function nN({activity:t}){const r=t.status==="failed"?Mt(t.updatedAt):t.status==="in_progress"?Mt(t.startedAt)??Mt(t.updatedAt):Mt(t.availableAt)??Mt(t.queuedAt),s=u.jsxs("div",{className:"flex min-w-0 items-start gap-2 px-2 py-1.5 text-left",children:[u.jsx("span",{className:`mt-1.5 h-1.5 w-1.5 shrink-0 ${t.status==="failed"?"bg-destructive":t.status==="in_progress"?"animate-pulse bg-foreground":"bg-muted-foreground"}`}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate text-[12px] leading-4 text-foreground",children:t.label}),t.detail&&u.jsx("span",{className:"block truncate text-[11px] leading-4 text-muted-foreground",children:t.detail}),t.status==="failed"&&t.lastError&&u.jsx("span",{className:"block truncate text-[11px] leading-4 text-destructive",children:t.lastError})]}),r&&u.jsx("span",{className:"shrink-0 text-[10px] leading-4 text-muted-foreground",children:r})]});return t.targetUrl?u.jsx("a",{href:t.targetUrl,target:"_blank",rel:"noopener noreferrer",className:"block outline-none hover:bg-muted focus:bg-muted focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:s}):u.jsx("div",{children:s})}function pu({title:t,items:r,emptyLabel:s}){return u.jsxs("div",{className:"py-1",children:[u.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:t}),r.length>0?u.jsx("div",{className:"max-h-52 overflow-y-auto",children:r.map(a=>u.jsx(nN,{activity:a},a.id))}):u.jsx("div",{className:"px-2 pb-2 text-[11px] text-muted-foreground",children:s})]})}function rN({activities:t}){const r=t.failed.length,s=t.inProgress.length,a=t.queued.length,l=r+s+a;return u.jsxs(NE,{children:[u.jsxs(RE,{className:"inline-flex items-center gap-1 border border-border px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","aria-label":"Open activity menu","data-testid":"activity-menu-trigger",children:[u.jsx(b0,{className:"h-3 w-3","aria-hidden":"true"}),u.jsx("span",{children:"activity"}),u.jsx("span",{className:"text-foreground",children:l})]}),u.jsxs(Lv,{align:"end",className:"w-80 p-0",children:[u.jsxs("div",{className:"border-b border-border px-2 py-2",children:[u.jsx("div",{className:"text-[12px] font-medium",children:"Activities"}),u.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[r," failed / ",s," in progress / ",a," queued"]})]}),u.jsx(pu,{title:"Failed",items:t.failed,emptyLabel:"No failed activities."}),u.jsx("div",{className:"border-t border-border"}),u.jsx(pu,{title:"In progress",items:t.inProgress,emptyLabel:"No activities running right now."}),u.jsx("div",{className:"border-t border-border"}),u.jsx(pu,{title:"Queued",items:t.queued,emptyLabel:"Queue is empty."})]})]})}function oN({warnings:t}){return t.length===0?null:u.jsx("div",{className:"shrink-0 border-b border-yellow-600/50 bg-yellow-500/10 px-4 py-3","data-testid":"operator-warnings-banner",children:u.jsx("div",{className:"space-y-3",children:t.map(r=>u.jsxs("div",{"data-testid":`operator-warning-${r.id}`,children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[u.jsx("div",{className:"text-[12px] font-medium uppercase tracking-wider text-yellow-600",children:r.title}),r.targetUrl&&u.jsx("a",{href:r.targetUrl,target:"_blank",rel:"noopener noreferrer",className:"border border-yellow-600/60 px-2 py-0.5 text-[10px] uppercase tracking-wider text-yellow-600 transition-colors hover:bg-yellow-600 hover:text-background",children:"Open PR"})]}),u.jsx("div",{className:"mt-1 text-[12px] text-foreground/80",children:r.message}),u.jsx("ol",{className:"mt-2 list-decimal space-y-1 pl-4 text-[11px] text-muted-foreground",children:r.fixSteps.map(s=>u.jsx("li",{children:s},s))})]},r.id))})})}function Bv({href:t,testId:r,label:s,hint:a,className:l,dotClassName:d,hintClassName:p,onClick:h}){return u.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:h,"data-testid":r,className:`inline-flex items-center border border-success-border bg-success-muted font-medium uppercase text-success-foreground transition-colors hover:bg-success-muted/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background ${l}`,children:[u.jsx("span",{className:`inline-block rounded-full bg-success ${d}`}),s,a&&u.jsx("span",{className:p,children:a})]})}function Wv({pr:t}){const r=Wo(t.feedbackItems).inProgress;if(!(t.status==="processing")&&r===0)return null;const a=r>0?`${r} agent${r!==1?"s":""} running on this PR`:"Agent run active on this PR";return u.jsxs(VS,{children:[u.jsx(QS,{asChild:!0,children:u.jsxs("span",{className:"inline-flex shrink-0 cursor-default items-center gap-0.5 text-[12px]","data-testid":`agent-indicator-${t.id}`,children:[u.jsx("span",{className:"animate-pulse",children:"🤖"}),r>0&&u.jsx("span",{className:"text-[10px] text-muted-foreground",children:r})]})}),u.jsx(vg,{side:"top",children:u.jsx("p",{className:"text-xs",children:a})})]})}const sN=m.memo(function({pr:r,isSelected:s,onSelect:a}){const l=Mt(r.lastChecked),d=zv(r),h=!(r.status==="processing"||Wo(r.feedbackItems).inProgress>0)&&$v(r.feedbackItems);return u.jsx("div",{onClick:()=>a(r.id),onKeyDown:y=>{y.target===y.currentTarget&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),a(r.id))},role:"button",tabIndex:0,"data-testid":`pr-row-${r.id}`,className:`w-full border-b border-border px-4 py-3 text-left transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${s?"bg-muted":""}`,children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx(Hv,{status:r.status}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"w-12 shrink-0 text-muted-foreground",children:["#",r.number]}),u.jsx("span",{className:"truncate",children:r.title}),u.jsx(Wv,{pr:r})]}),h&&u.jsx(Bv,{href:r.url,testId:`ready-to-merge-${r.id}`,label:"Ready to merge",hint:"— click to open PR",onClick:y=>y.stopPropagation(),className:"mt-1.5 ml-[3.75rem] gap-1.5 px-2 py-0.5 text-[11px] tracking-wider",dotClassName:"h-1.5 w-1.5",hintClassName:"text-[10px] normal-case tracking-normal text-success-foreground/75"}),u.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 pl-[3.75rem] text-[11px] text-muted-foreground",children:[u.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",onClick:y=>y.stopPropagation(),className:"underline decoration-border underline-offset-2 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:r.repo}),u.jsx("span",{children:Uv(r.status)}),!d&&u.jsx(Iu,{}),r.feedbackItems.length>0&&(()=>{const y=Wo(r.feedbackItems),v=[];return y.queued>0&&v.push(`${y.queued}q`),y.inProgress>0&&v.push(`${y.inProgress} active`),y.failed>0&&v.push(`${y.failed} failed`),y.warning>0&&v.push(`${y.warning} warn`),v.length===0?u.jsxs("span",{children:[r.feedbackItems.length," items"]}):u.jsx("span",{children:v.join(" · ")})})(),l&&u.jsxs("span",{children:["checked ",l]})]})]})]})})});function iN({item:t,prId:r,readOnly:s}){const a=ct({mutationFn:async h=>(await nt("PATCH",`/api/prs/${r}/feedback/${t.id}`,{decision:h})).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/prs",r]})}}),l=ct({mutationFn:async()=>(await nt("POST",`/api/prs/${r}/feedback/${t.id}/retry`)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/prs",r]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/logs"]})},onError:h=>{Ht("Could not retry feedback item",h)}}),d=Mt(t.createdAt),p=LE(t.status);return u.jsxs(Sg,{defaultOpen:!p,className:"border-b border-border",children:[u.jsx("div",{className:"px-4 py-3",children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"shrink-0 pt-0.5",children:u.jsx(tN,{status:t.status})}),u.jsx("div",{className:"min-w-0 flex-1",children:u.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[u.jsx("span",{className:"font-medium",children:t.author}),t.file&&u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[t.file,t.line?`:${t.line}`:""]}),u.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.type.replace("_"," ")}),d&&u.jsx("span",{className:"text-[11px] text-muted-foreground",children:d})]})}),u.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!s&&(t.status==="failed"||t.status==="warning")&&u.jsx("button",{type:"button",onClick:()=>l.mutate(),disabled:l.isPending,"data-testid":`retry-${t.id}`,"aria-label":`Retry feedback from ${t.author}`,title:"Retry feedback item",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:"Retry"}),u.jsx(Cg,{asChild:!0,children:u.jsx("button",{type:"button","data-testid":`toggle-${t.id}`,"aria-label":`${p?"Show":"Hide"} feedback details from ${t.author}`,title:"Toggle feedback details",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"Details"})}),!s&&["accept","reject","flag"].map(h=>u.jsx("button",{type:"button",onClick:()=>a.mutate(h),"data-testid":`override-${h}-${t.id}`,"aria-label":`${h} feedback from ${t.author}`,className:`px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background ${t.decision===h?"bg-foreground text-background":"border border-border text-muted-foreground"}`,children:h},h))]})]})}),u.jsx(kg,{children:u.jsxs("div",{className:"px-4 pb-3",children:[t.bodyHtml?u.jsx("div",{className:"feedback-markdown text-[12px] leading-relaxed",dangerouslySetInnerHTML:{__html:t.bodyHtml}}):u.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-relaxed text-foreground/80",children:t.body}),(t.statusReason||t.decisionReason)&&u.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:t.statusReason||t.decisionReason})]})})]})}function aN({prId:t}){const r=m.useRef(null),{data:s=[]}=dt({queryKey:["/api/logs",t??"all"],queryFn:async()=>{const d=t?`/api/logs?prId=${encodeURIComponent(t)}`:"/api/logs";return(await nt("GET",d)).json()},refetchInterval:1500}),a=m.useMemo(()=>s.length>fu?s.slice(-fu):s,[s]),l=s.length-a.length;return m.useEffect(()=>{const d=r.current;d&&(d.scrollTop=d.scrollHeight)},[s.length,t]),u.jsx("div",{className:"flex h-full flex-col",children:u.jsx("div",{ref:r,className:"flex-1 overflow-y-auto p-4 font-mono text-[11px] leading-relaxed",children:s.length===0?u.jsx("span",{className:"text-muted-foreground",children:"No log entries."}):u.jsxs(u.Fragment,{children:[l>0&&u.jsxs("div",{className:"border-b border-border/60 pb-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:["Showing latest ",fu," of ",s.length," entries."]}),a.map(d=>{const p=d.metadata&&Object.keys(d.metadata).length>0?JSON.stringify(d.metadata,null,2):null;return u.jsxs("div",{className:"border-b border-border/60 py-2 last:border-b-0","data-testid":`log-${d.id}`,children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[u.jsx("span",{children:Mt(d.timestamp)}),u.jsx("span",{className:d.level==="error"?"text-destructive":d.level==="warn"?"text-foreground/80":"text-foreground/55",children:d.level}),d.phase&&u.jsx("span",{className:"border border-border px-1 py-0",children:d.phase}),d.runId&&u.jsxs("span",{className:"normal-case text-foreground/45",children:["run ",d.runId.slice(0,8)]})]}),u.jsx("div",{className:"mt-1 break-words text-foreground/75",children:d.message}),p&&u.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all text-[10px] text-muted-foreground",children:p})]},d.id)})]})})})}function lN({pr:t,config:r,healingSessions:s}){const a=qE(s,t.id),l=a?YE(a):null,d=l?Ph[l.tone]:Ph.neutral;return u.jsxs("div",{className:"shrink-0 border-b border-border px-4 py-3","data-testid":"panel-ci-healing",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"CI healing"}),u.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:l?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:`inline-flex border px-1.5 py-0.5 text-[11px] uppercase tracking-wider ${d}`,children:l.stateLabel}),u.jsx("span",{className:"text-[11px] text-muted-foreground",children:l.attemptSummary})]}):u.jsx("span",{className:"text-[11px] text-muted-foreground",children:r?.autoHealCI===!1?"Automatic CI healing is disabled in settings.":"No healing session yet for this PR."})})]}),a&&u.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["head ",a.currentHeadSha.slice(0,7)]})]}),l?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mt-2 grid gap-1 text-[11px] text-muted-foreground",children:[l.reasonSummary&&u.jsxs("div",{children:["Reason: ",l.reasonSummary]}),u.jsx("div",{children:l.statusHint}),u.jsxs("div",{children:["Attempts: ",l.attemptSummary,a?.latestFingerprint?` · fingerprint ${a.latestFingerprint}`:""]})]}),l.actions.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:l.actions.map(p=>u.jsx("button",{type:"button",disabled:!0,title:p.hint,className:`border px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors ${p.available?"border-border text-foreground/70 hover:bg-muted":"border-border text-muted-foreground/60"} disabled:opacity-100`,children:p.label},p.label))}),u.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground",children:"Operator controls are read-only until healing action endpoints are added."})]})]}):r?.autoHealCI!==!1&&u.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:"The watcher will create a healing session when a failing check is classified as healable."})]})}function uN({prId:t}){const[r,s]=m.useState("ask");return u.jsxs("div",{className:"flex min-h-[24rem] w-full shrink-0 flex-col border-t border-border lg:min-h-0 lg:w-80 lg:border-l lg:border-t-0",children:[u.jsxs("div",{className:"flex border-b border-border",children:[u.jsx("button",{type:"button",onClick:()=>s("ask"),"data-testid":"tab-ask",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${r==="ask"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Ask Agent"}),u.jsx("button",{type:"button",onClick:()=>s("activity"),"data-testid":"tab-activity",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${r==="activity"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Activity"})]}),u.jsx("div",{className:"flex-1 overflow-hidden",children:r==="activity"?u.jsx(aN,{prId:t}):t?u.jsx(cN,{prId:t}):u.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Select a PR to ask questions."})})]})}function cN({prId:t}){const[r,s]=m.useState(""),a=m.useRef(null),{data:l=[]}=dt({queryKey:["/api/prs",t,"questions"],refetchInterval:2e3}),d=ct({mutationFn:p=>nt("POST",`/api/prs/${t}/questions`,{question:p}).then(h=>h.json()),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs",t,"questions"]}),we.invalidateQueries({queryKey:["/api/activities"]}),s("")}});return m.useEffect(()=>{const p=a.current;p&&(p.scrollTop=p.scrollHeight)},[l.length,l[l.length-1]?.status]),u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsx("div",{className:"border-b border-border px-4 py-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:"Ask Agent"}),u.jsx("div",{ref:a,className:"flex-1 overflow-y-auto p-4 space-y-3",children:l.length===0?u.jsx("span",{className:"text-[12px] text-muted-foreground",children:"Ask questions about this PR — the agent will read activity logs, feedback, and status to answer."}):l.map(p=>u.jsxs("div",{className:"space-y-1.5","data-testid":`question-${p.id}`,children:[u.jsxs("div",{className:"text-[12px]",children:[u.jsx("span",{className:"font-medium text-foreground/90",children:"Q: "}),u.jsx("span",{className:"text-foreground/80",children:p.question})]}),p.status==="pending"||p.status==="answering"?u.jsx("div",{className:"text-[11px] text-muted-foreground animate-pulse",children:"Agent is thinking..."}):p.status==="error"?u.jsxs("div",{className:"text-[11px] text-destructive",children:["Error: ",p.error||"Unknown error"]}):u.jsx("div",{className:"text-[12px] leading-relaxed text-foreground/75 whitespace-pre-wrap border-l-2 border-border pl-3",children:p.answer}),u.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Mt(p.createdAt),p.answeredAt&&` — answered ${Mt(p.answeredAt)}`]})]},p.id))}),u.jsxs("form",{onSubmit:p=>{p.preventDefault(),r.trim()&&!d.isPending&&d.mutate(r.trim())},className:"border-t border-border p-3",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:r,onChange:p=>s(p.target.value),placeholder:"Was the review done? Why did this fail?","aria-label":"Question for selected pull request","data-testid":"input-question",className:"flex-1 border border-border bg-transparent px-2 py-1 text-[12px] placeholder:text-muted-foreground/50 focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"submit",disabled:d.isPending||!r.trim(),"data-testid":"button-ask",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:d.isPending?"...":"Ask"})]}),d.isError&&u.jsx("div",{className:"mt-1 text-[11px] text-destructive",children:Kv(d.error)})]})]})}function Kv(t){if(!(t instanceof Error))return String(t);const r=t.message.replace(/^\d+:\s*/,"").trim();if(!r)return"Request failed";try{const s=JSON.parse(r);if(typeof s.error=="string")return s.error;if(typeof s.message=="string")return s.message}catch{}return r}function Ht(t,r){Vt({variant:"destructive",title:t,description:Kv(r)})}function dN(){const[t,r]=m.useState(null),[s,a]=m.useState(""),[l,d]=m.useState(""),[p,h]=m.useState(null),[y,v]=m.useState("mine"),[g,w]=m.useState("active"),{data:b=[],isLoading:E}=dt({queryKey:["/api/prs"],refetchInterval:3e3}),{data:N=[],isLoading:S}=dt({queryKey:["/api/prs/archived"],refetchInterval:1e4}),{data:C}=dt({queryKey:["/api/config"],refetchInterval:5e3}),{data:_=[]}=dt({queryKey:["/api/healing-sessions"],queryFn:async()=>sb("/api/healing-sessions"),refetchInterval:5e3}),{data:A=JE}=dt({queryKey:["/api/activities"],refetchInterval:3e3}),{data:O=[]}=dt({queryKey:["/api/repos/settings"],refetchInterval:5e3}),I=g==="active"?b:N,F=g==="archived";m.useEffect(()=>{if(I.length===0){t!==null&&r(null);return}(!t||!I.some(P=>P.id===t))&&r(I[0].id)},[I,t]);const L=I.find(P=>P.id===t)??null,U=L?zv(L):!0,q=ZS(p,O.length),te=ct({mutationFn:async P=>(await nt("POST","/api/prs",{url:P})).json(),onSuccess:P=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]}),a(""),r(P.id)},onError:P=>{Ht("Could not add PR",P)}}),ne=ct({mutationFn:async P=>(await nt("POST",`/api/prs/${P}/apply`)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/logs"]})},onError:P=>{Ht("Could not run babysitter",P)}}),se=ct({mutationFn:async({id:P,enabled:z})=>(await nt("PATCH",`/api/prs/${P}/watch`,{enabled:z})).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/prs/archived"]}),we.invalidateQueries({queryKey:["/api/logs"]})},onError:P=>{Ht("Could not update PR watch state",P)}}),Y=ct({mutationFn:async P=>(await nt("PATCH","/api/config",P)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/config"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]})},onError:P=>{Ht("Could not update settings",P)}}),ae=ct({mutationFn:async()=>(await nt("POST","/api/repos/sync")).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/activities"]}),we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]})},onError:P=>{Ht("Could not sync repositories",P)}}),G=ct({mutationFn:async P=>(await nt("POST","/api/repos/release",{repo:P})).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/releases"]}),we.invalidateQueries({queryKey:["/api/activities"]}),Vt({description:"Release queued."})},onError:P=>{Ht("Could not create release",P)}}),me=async P=>(await nt("PATCH","/api/repos/settings",P)).json(),ee=ct({mutationFn:me,onSuccess:()=>{we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]})},onError:P=>{Ht("Could not update repository settings",P)}}),ie=ct({mutationFn:async({repo:P})=>(await nt("POST","/api/repos",{repo:P})).json(),onSuccess:async(P,z)=>{if(we.invalidateQueries({queryKey:["/api/repos/settings"]}),we.invalidateQueries({queryKey:["/api/prs"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]}),d(""),v("mine"),z.watchScope==="team")try{await me({repo:P.repo,ownPrsOnly:!1}),we.invalidateQueries({queryKey:["/api/repos/settings"]})}catch(V){Ht("Repository added, but could not update tracking scope",V)}},onError:P=>{Ht("Could not watch repository",P)}});return u.jsxs("div",{className:"flex min-h-screen flex-col lg:h-screen lg:overflow-hidden",children:[u.jsx(Bi,{}),u.jsxs("header",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-2.5 lg:flex-row lg:items-center lg:justify-between",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-label":"oh-my-pr",children:[u.jsx("rect",{x:"1",y:"1",width:"14",height:"14",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M4 5h8M4 8h5M4 11h6",stroke:"currentColor",strokeWidth:"1"})]}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"oh-my-pr"}),u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"autonomous"}),u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["poll ",XE(C?.pollIntervalMs)]}),u.jsx(An,{href:"/changelogs",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"changelogs"}),u.jsx(An,{href:"/releases",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"releases"})]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[b.length," PR",b.length!==1?"s":""," in ",O.length," repo",O.length!==1?"s":""]}),u.jsx("label",{htmlFor:"dashboard-coding-agent",className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Agent"}),u.jsxs("select",{id:"dashboard-coding-agent",value:C?.codingAgent??"codex",onChange:P=>{const z=P.target.value;Y.mutate({codingAgent:z})},disabled:Y.isPending,"data-testid":"select-coding-agent",className:"border border-border bg-transparent px-2 py-0.5 text-[11px] focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:[u.jsx("option",{value:"codex",children:"codex"}),u.jsx("option",{value:"claude",children:"claude"})]}),u.jsx(An,{href:"/settings",className:"border border-border px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"settings"}),u.jsx(rN,{activities:A})]})]}),u.jsx(nC,{}),u.jsx(oN,{warnings:A.warnings}),u.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden",children:[u.jsxs("div",{className:"flex max-h-[42vh] w-full shrink-0 flex-col overflow-y-auto border-b border-border lg:max-h-none lg:min-h-0 lg:w-80 lg:border-b-0 lg:border-r",children:[u.jsxs("div",{className:"sticky top-0 z-10 flex shrink-0 border-b border-border bg-background",children:[u.jsxs("button",{type:"button",onClick:()=>w("active"),"data-testid":"tab-active",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${g==="active"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:["Active (",b.length,")"]}),u.jsxs("button",{type:"button",onClick:()=>w("archived"),"data-testid":"tab-archived",className:`flex-1 px-3 py-2 text-[11px] uppercase tracking-wider transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset ${g==="archived"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,children:["Archived (",N.length,")"]})]}),!F&&u.jsxs(u.Fragment,{children:[u.jsxs(Sg,{open:q,onOpenChange:h,className:"border-b border-border",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 text-[11px] text-muted-foreground",children:[u.jsx("span",{children:O.length>0?"Add a PR or watch another repo.":"Add a PR or watch a repo. Sync and babysit start automatically."}),u.jsx(Cg,{asChild:!0,children:u.jsx("button",{type:"button","data-testid":"button-toggle-add-controls",className:"shrink-0 border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:q?"Hide":"Add"})})]}),u.jsxs(kg,{children:[u.jsx("form",{onSubmit:P=>{P.preventDefault(),s.trim()&&te.mutate(s.trim())},className:"border-t border-border p-3",children:u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:s,onChange:P=>a(P.target.value),placeholder:"github.com/owner/repo/pull/123","aria-label":"GitHub pull request URL","data-testid":"input-add-pr",className:"flex-1 border border-border bg-transparent px-2 py-1 text-[12px] placeholder:text-muted-foreground/50 focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"submit",disabled:te.isPending||!s.trim(),"data-testid":"button-add-pr",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:"Add"})]})}),u.jsxs("form",{onSubmit:P=>{P.preventDefault();const z=l.trim();z&&ie.mutate({repo:z,watchScope:y})},className:"border-t border-border p-3",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:l,onChange:P=>d(P.target.value),placeholder:"owner/repo","aria-label":"Repository owner and name","data-testid":"input-add-repo",className:"flex-1 border border-border bg-transparent px-2 py-1 text-[12px] placeholder:text-muted-foreground/50 focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"submit",disabled:ie.isPending||!l.trim(),"data-testid":"button-add-repo",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:"Watch"})]}),u.jsxs("div",{className:"mt-3",children:[u.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Track automatically"}),u.jsx(jh,{value:y,onChange:v,disabled:ie.isPending,name:"watch-scope",testIdPrefix:"watch-scope"})]})]})]})]}),u.jsxs("div",{className:"border-b border-border p-3",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Tracked repositories"}),u.jsx("button",{type:"button",onClick:()=>ae.mutate(),disabled:ae.isPending,"data-testid":"button-sync-repos",className:"border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:ae.isPending?"Fetching...":"Fetch"})]}),O.length===0?u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"No repositories being watched yet."}):u.jsx("div",{className:"space-y-1 text-[12px]",children:O.map(P=>{const z=G.isPending&&G.variables===P.repo;return u.jsxs("div",{className:"space-y-2 border border-border/60 px-2 py-2",children:[u.jsx("a",{href:XS(P.repo),target:"_blank",rel:"noopener noreferrer","data-testid":`tracked-repo-${P.repo.replace("/","-")}`,className:"min-w-0 break-all text-foreground/75 underline decoration-border underline-offset-2 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:P.repo}),u.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Track automatically"}),u.jsx(jh,{value:eN(P.ownPrsOnly),onChange:V=>ee.mutate({repo:P.repo,ownPrsOnly:V==="mine"}),disabled:ee.isPending,name:`tracked-repo-scope-${P.repo}`,testIdPrefix:`tracked-repo-scope-${P.repo.replace("/","-")}`,compact:!0})]}),u.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2 self-end",children:[u.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:[u.jsx("input",{type:"checkbox",checked:P.autoCreateReleases,onChange:V=>ee.mutate({repo:P.repo,autoCreateReleases:V.target.checked}),disabled:ee.isPending,"data-testid":`tracked-repo-auto-release-${P.repo.replace("/","-")}`,className:"accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),"Auto-release"]}),u.jsx("button",{type:"button",onClick:()=>G.mutate(P.repo),disabled:G.isPending,"data-testid":`tracked-repo-manual-release-${P.repo.replace("/","-")}`,className:"border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:z?"Releasing...":"Release"})]})]})]},P.repo)})})]})]}),u.jsx("div",{className:"flex-1",children:(F?S:E)?u.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:"Loading..."}):I.length===0?u.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:F?"No archived PRs. Closed PRs are archived automatically.":"No PRs tracked yet. Add a repository to watch or add a PR URL."}):I.map(P=>u.jsx(sN,{pr:P,isSelected:P.id===t,onSelect:r},P.id))})]}),u.jsx("div",{className:"flex min-h-[32rem] flex-1 flex-col overflow-hidden lg:min-h-0",children:L?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"shrink-0 border-b border-border px-4 py-3",children:[u.jsxs("div",{className:"mb-1 flex items-start justify-between gap-4",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(Hv,{status:L.status}),u.jsx("span",{className:"truncate font-medium",children:L.title}),u.jsx(Wv,{pr:L}),!U&&u.jsx(Iu,{}),u.jsxs("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-[11px] text-muted-foreground underline decoration-border underline-offset-2 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:[L.repo,"#",L.number]})]}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[u.jsxs("span",{children:["status: ",Uv(L.status)]}),!U&&u.jsx(Iu,{}),u.jsxs("span",{children:[L.feedbackItems.length," items"]}),L.feedbackItems.length>0&&(()=>{const P=Wo(L.feedbackItems);return u.jsxs(u.Fragment,{children:[P.queued>0&&u.jsxs("span",{children:[P.queued," queued"]}),P.inProgress>0&&u.jsxs("span",{children:[P.inProgress," in progress"]}),P.failed>0&&u.jsxs("span",{children:[P.failed," failed"]}),P.warning>0&&u.jsxs("span",{children:[P.warning," warnings"]})]})})(),L.testsPassed!==null&&u.jsxs("span",{children:["tests: ",L.testsPassed?"pass":"fail"]}),L.lintPassed!==null&&u.jsxs("span",{children:["lint: ",L.lintPassed?"pass":"fail"]}),L.lastChecked&&u.jsxs("span",{children:["checked ",Mt(L.lastChecked)]})]})]}),!F&&u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:()=>ne.mutate(L.id),disabled:ne.isPending||L.status==="processing","data-testid":"button-apply",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:L.status==="processing"?"Running":"Run now"}),u.jsx("button",{type:"button",onClick:()=>se.mutate({id:L.id,enabled:!U}),disabled:se.isPending,"data-testid":"button-toggle-watch",className:"border border-border px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-30",children:U?"Pause watch":"Resume watch"})]})]}),$v(L.feedbackItems)&&L.status!=="processing"&&Wo(L.feedbackItems).inProgress===0&&u.jsx(Bv,{href:L.url,testId:"detail-ready-to-merge",label:"All comments resolved — ready to merge",hint:"Open PR on GitHub →",className:"mt-2 gap-2 px-3 py-1.5 text-[12px] tracking-wider",dotClassName:"h-2 w-2",hintClassName:"text-[11px] normal-case tracking-normal text-success-foreground/75"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:U?"Background watcher syncs GitHub feedback and pushes approved fixes automatically.":"Background watch is paused for this PR; manual runs still work."})]}),u.jsx(lN,{pr:L,config:C,healingSessions:_}),u.jsx("div",{className:"flex-1 overflow-y-auto",children:L.feedbackItems.length===0?u.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:U?"No feedback yet. The watcher will sync GitHub comments automatically.":"No feedback yet. Background watch is paused for this PR."}):L.feedbackItems.map(P=>u.jsx(iN,{item:P,prId:L.id,readOnly:F},P.id))})]}):u.jsx("div",{className:"flex flex-1 items-center justify-center text-[12px] text-muted-foreground",children:"Select a PR from the left panel."})}),u.jsx(uN,{prId:t})]})]})}function fN(){const{data:t}=dt({queryKey:["/api/config"]}),[r,s]=m.useState(""),[a,l]=m.useState(!1),d=t?.githubTokens??(t?.githubToken?[t.githubToken]:[]),p=g=>{v.mutate({githubTokens:g})},h=(g,w)=>{const b=[...d],[E]=b.splice(g,1);E&&(b.splice(w,0,E),p(b))},y=g=>{p(d.filter((w,b)=>b!==g))},v=ct({mutationFn:async g=>(await nt("PATCH","/api/config",g)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/config"]}),we.invalidateQueries({queryKey:["/api/onboarding/status"]}),Vt({description:"Settings saved."})},onError:g=>{Vt({variant:"destructive",description:`Failed to save: ${g.message}`})}});return u.jsxs("div",{className:"flex min-h-screen flex-col",children:[u.jsx(Bi,{}),u.jsx("header",{className:"flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(An,{href:"/",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"← back"}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"settings"})]})}),u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsxs("div",{className:"mx-auto flex max-w-2xl flex-col gap-8",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Agent"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{htmlFor:"settings-coding-agent",className:"text-sm",children:"Coding Agent"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"CLI agent used to apply fixes"})]}),u.jsxs("select",{id:"settings-coding-agent",value:t?.codingAgent??"codex",onChange:g=>{const w=g.target.value;v.mutate({codingAgent:w})},disabled:v.isPending,className:"border border-border bg-transparent px-2 py-1 text-sm focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:[u.jsx("option",{value:"codex",children:"codex"}),u.jsx("option",{value:"claude",children:"claude"})]})]}),u.jsxs("label",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Fallback to next coding agent"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"If the configured agent cannot start or authenticate, retry the babysitter run with the other local agent."})]}),u.jsx("input",{type:"checkbox",checked:t?.fallbackToNextCodingAgent??!1,onChange:g=>v.mutate({fallbackToNextCodingAgent:g.target.checked}),disabled:v.isPending,className:"mt-1 h-4 w-4 accent-foreground","data-testid":"checkbox-fallback-to-next-coding-agent"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Automation"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Auto-resolve conflicts"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ask the agent to resolve merge conflicts when tracked PRs are not mergeable."})]}),u.jsx("input",{type:"checkbox",checked:t?.autoResolveMergeConflicts??!0,onChange:g=>v.mutate({autoResolveMergeConflicts:g.target.checked}),disabled:v.isPending,"data-testid":"checkbox-auto-resolve-conflicts",className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]}),u.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Auto-update docs"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Automatically assess whether tracked PRs need documentation updates."})]}),u.jsx("input",{type:"checkbox",checked:t?.autoUpdateDocs??!0,onChange:g=>v.mutate({autoUpdateDocs:g.target.checked}),disabled:v.isPending,"data-testid":"checkbox-auto-update-docs",className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Tuning"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsx(Tn,{label:"Max turns",description:"Maximum agent turns per feedback item",value:t?.maxTurns??15,onChange:g=>v.mutate({maxTurns:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Poll interval (ms)",description:"How often to check for new feedback",value:t?.pollIntervalMs??12e4,onChange:g=>v.mutate({pollIntervalMs:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Batch window (ms)",description:"Time to batch feedback before processing",value:t?.batchWindowMs??3e5,onChange:g=>v.mutate({batchWindowMs:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Max changes per run",description:"Limit on concurrent changes",value:t?.maxChangesPerRun??20,onChange:g=>v.mutate({maxChangesPerRun:g}),disabled:v.isPending})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"CI Healing"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Automatic CI healing"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Classify healable CI failures and run bounded repair attempts in isolated worktrees."})]}),u.jsx("input",{type:"checkbox","aria-label":"Automatic CI healing",checked:t?.autoHealCI??!1,onChange:g=>v.mutate({autoHealCI:g.target.checked}),disabled:v.isPending,className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]}),u.jsx(Tn,{label:"Max healing attempts per session",description:"Upper bound on repair attempts for a single healing session",value:t?.maxHealingAttemptsPerSession??3,onChange:g=>v.mutate({maxHealingAttemptsPerSession:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Max healing attempts per fingerprint",description:"Cap retries for the same failure fingerprint",value:t?.maxHealingAttemptsPerFingerprint??2,onChange:g=>v.mutate({maxHealingAttemptsPerFingerprint:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Max concurrent healing runs",description:"How many healing runs can execute at once",value:t?.maxConcurrentHealingRuns??1,onChange:g=>v.mutate({maxConcurrentHealingRuns:g}),disabled:v.isPending}),u.jsx(Tn,{label:"Healing cooldown (ms)",description:"Backoff before a cooldowned session can retry",value:t?.healingCooldownMs??3e5,onChange:g=>v.mutate({healingCooldownMs:g}),disabled:v.isPending})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Releases"}),u.jsx("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:u.jsxs("label",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Automatic release creation"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Evaluate merged PRs and publish GitHub releases automatically when the agent decides they are release-worthy."})]}),u.jsx("input",{type:"checkbox",checked:t?.autoCreateReleases??!0,onChange:g=>v.mutate({autoCreateReleases:g.target.checked}),disabled:v.isPending,className:"mt-1 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background","data-testid":"checkbox-auto-create-releases"})]})})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-4 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"GitHub"}),u.jsxs("div",{className:"flex flex-col gap-4 rounded border border-border p-4",children:[u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Tokens"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Tried in order before GITHUB_TOKEN and gh auth."})]}),!a&&u.jsx("button",{type:"button",onClick:()=>l(!0),className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"add"})]}),d.length?u.jsx("div",{className:"flex flex-col gap-2",children:d.map((g,w)=>u.jsxs("div",{className:"flex items-center justify-between gap-3 border border-border px-2 py-1.5",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"truncate font-mono text-xs",children:g}),u.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["priority ",w+1]})]}),u.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[u.jsx("button",{type:"button",onClick:()=>h(w,w-1),disabled:w===0||v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"up"}),u.jsx("button",{type:"button",onClick:()=>h(w,w+1),disabled:w===d.length-1||v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"down"}),u.jsx("button",{type:"button",onClick:()=>y(w),disabled:v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"remove"})]})]},w))}):u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"none configured"}),a?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"password",value:r,onChange:g=>s(g.target.value),placeholder:"ghp_...","aria-label":"GitHub token",className:"min-w-0 flex-1 border border-border bg-transparent px-2 py-1 text-sm focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"}),u.jsx("button",{type:"button",onClick:()=>{const g=r.trim();g&&(p([...d,g]),s(""),l(!1))},disabled:!r.trim()||v.isPending,className:"border border-border px-2 py-1 text-xs hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"add"}),u.jsx("button",{type:"button",onClick:()=>{l(!1),s("")},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"cancel"})]}):null]}),u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Repository links in PR comments"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Link oh-my-pr back to its repository in agent-authored GitHub PR comments and footers."})]}),u.jsx("input",{type:"checkbox","aria-label":"Repository links in PR comments",checked:t?.includeRepositoryLinksInGitHubComments??!0,onChange:g=>v.mutate({includeRepositoryLinksInGitHubComments:g.target.checked}),disabled:v.isPending,className:"h-4 w-4 accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"})]}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Trusted reviewers"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:t?.trustedReviewers?.length?t.trustedReviewers.join(", "):"none configured"})]}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm",children:"Ignored bots"}),u.jsx("div",{className:"text-[11px] text-muted-foreground",children:t?.ignoredBots?.length?t.ignoredBots.join(", "):"none configured"})]})]})]})]})})]})}function Tn({label:t,description:r,value:s,onChange:a,disabled:l}){const d=`setting-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`,p=`${d}-description`;return u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{htmlFor:d,className:"text-sm",children:t}),u.jsx("div",{id:p,className:"text-[11px] text-muted-foreground",children:r})]}),u.jsx("input",{id:d,type:"number",value:s,onChange:h=>{const y=parseInt(h.target.value,10);isNaN(y)||a(y)},disabled:l,"aria-describedby":p,className:"w-28 border border-border bg-transparent px-2 py-1 text-right text-sm focus:border-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50"})]})}function pN(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function hN(t){const r=t.match(/##\s*Twitter\/X\s*(?:Thread)?\n([\s\S]*?)(?=\n##\s|\s*$)/i),s=t.match(/##\s*LinkedIn\s*(?:\/\s*General)?\n([\s\S]*?)(?=\n##\s|\s*$)/i);return{twitter:r?r[1].trim():null,linkedin:s?s[1].trim():null}}function mN({text:t}){const[r,s]=m.useState(!1),a=async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)}catch{}};return u.jsx("button",{type:"button",onClick:a,className:"border border-border px-2 py-0.5 text-[11px] uppercase tracking-wider text-muted-foreground hover:border-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:r?"copied":"copy"})}function hu({title:t,content:r}){return u.jsxs("div",{className:"mt-4",children:[u.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[u.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:t}),u.jsx(mN,{text:r})]}),u.jsx("pre",{className:"whitespace-pre-wrap border border-border bg-background p-3 text-[12px] leading-relaxed font-mono",children:r})]})}function gN({status:t}){const r=t==="done"?"border-foreground/40 text-foreground":t==="generating"?"border-border text-muted-foreground animate-pulse":"border-destructive/40 text-destructive";return u.jsx("span",{className:`border px-1.5 py-0 text-[10px] uppercase tracking-wider ${r}`,children:t})}function vN({changelog:t}){const[r,s]=m.useState(!1),a=t.content?hN(t.content):null,l=`changelog-${t.id}-content`;return u.jsxs("div",{className:"border border-border",children:[u.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-4 py-3 text-left hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default disabled:hover:bg-transparent",onClick:()=>t.status==="done"&&s(d=>!d),disabled:t.status!=="done","aria-expanded":t.status==="done"?r:void 0,"aria-controls":t.status==="done"?l:void 0,children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(gN,{status:t.status}),u.jsx("span",{className:"text-sm font-medium",children:pN(t.createdAt)}),u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[t.triggerCount," PR",t.triggerCount!==1?"s":""," merged"]}),u.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.prSummaries.map(d=>`#${d.number}`).join(" · ")})]}),t.status==="done"&&u.jsx("span",{className:"text-[11px] text-muted-foreground",children:r?"Hide":"Show"})]}),r&&t.status==="done"&&u.jsxs("div",{id:l,className:"border-t border-border px-4 pb-4 pt-3",children:[t.error&&u.jsx("p",{className:"mb-3 text-[12px] text-destructive",children:t.error}),a?.twitter&&u.jsx(hu,{title:"Twitter / X Thread",content:a.twitter}),a?.linkedin&&u.jsx(hu,{title:"LinkedIn / General",content:a.linkedin}),!a?.twitter&&!a?.linkedin&&t.content&&u.jsx(hu,{title:"Full output",content:t.content})]}),t.status==="error"&&t.error&&u.jsx("div",{className:"border-t border-border px-4 py-3",children:u.jsx("p",{className:"text-[12px] text-destructive",children:t.error})}),t.status==="generating"&&u.jsx("div",{className:"border-t border-border px-4 py-2.5",children:u.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Generation was removed before this row completed."})})]})}function yN(){const{data:t=[],isLoading:r}=dt({queryKey:["/api/changelogs"],refetchInterval:s=>s.state.data?.some(l=>l.status==="generating")?5e3:!1});return u.jsxs("div",{className:"flex min-h-screen flex-col",children:[u.jsx(Bi,{}),u.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-label":"oh-my-pr",children:[u.jsx("rect",{x:"1",y:"1",width:"14",height:"14",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M4 5h8M4 8h5M4 11h6",stroke:"currentColor",strokeWidth:"1"})]}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"oh-my-pr"}),u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"changelogs"})]}),u.jsx(An,{href:"/",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"← back to dashboard"})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsxs("div",{className:"mx-auto max-w-3xl",children:[u.jsxs("div",{className:"mb-5",children:[u.jsx("h1",{className:"text-base font-medium",children:"Social Media Changelogs"}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Historical generated posts from earlier versions."})]}),!r&&t.length===0&&u.jsxs("div",{className:"border border-border px-4 py-8 text-center",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"No changelogs yet."}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Social media changelog generation has been removed."})]}),r&&u.jsx("div",{className:"border border-border px-4 py-6 text-center",children:u.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading…"})}),u.jsx("div",{className:"flex flex-col gap-2",children:t.map(s=>u.jsx(vN,{changelog:s},s.id))})]})})]})}const xN=new Set(["detected","evaluating","proposed","publishing"]);function Vv(t){return xN.has(t)}function wN(t){return t==="published"||t==="skipped"||t==="error"}function bN(t){return typeof t=="object"&&t!==null&&"status"in t&&typeof t.status=="string"}function mu(t){if(!t)return"n/a";const r=new Date(t);return Number.isNaN(r.getTime())?"n/a":r.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function SN(t){return t?t.slice(0,7):"n/a"}function CN({status:t}){const r=t==="published"?"border-foreground/40 text-foreground":t==="skipped"?"border-border text-muted-foreground":t==="error"?"border-destructive/40 text-destructive":Vv(t)?"border-border text-muted-foreground animate-pulse":"border-border text-muted-foreground";return u.jsx("span",{className:`border px-1.5 py-0 text-[10px] uppercase tracking-wider ${r}`,children:t})}function kN({text:t}){const[r,s]=m.useState(!1),a=async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch(l){const d=l instanceof Error?l.message:"Clipboard write failed";Vt({variant:"destructive",description:`Failed to copy: ${d}`})}};return u.jsx("button",{type:"button",onClick:a,className:"border border-border px-2 py-0.5 text-[11px] uppercase tracking-wider text-muted-foreground hover:border-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:r?"copied":"copy"})}function EN({run:t,onRetry:r,retryPending:s}){const[a,l]=m.useState(!1),p=!(!!t.decisionReason||!!t.releaseTitle||!!t.releaseNotes||!!t.error||!!t.githubReleaseUrl||t.includedPrs.length>0)&&wN(t.status),h=`release-run-${t.id}-details`;return u.jsxs("div",{className:"border border-border",children:[u.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-4 py-3 text-left hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>l(y=>!y),"aria-expanded":a,"aria-controls":h,children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[u.jsx(CN,{status:t.status}),u.jsx("span",{className:"truncate text-sm font-medium",children:t.repo}),u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",t.triggerPrNumber]}),t.proposedVersion&&u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.proposedVersion}),!t.proposedVersion&&t.recommendedBump&&u.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["bump ",t.recommendedBump]})]}),u.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground",children:[u.jsx("span",{children:mu(t.createdAt)}),u.jsx("span",{children:a?"Hide":"Show"})]})]}),a&&u.jsxs("div",{id:h,className:"border-t border-border px-4 pb-4 pt-3",children:[u.jsxs("div",{className:"mb-3 text-[12px] text-muted-foreground",children:["Trigger PR:"," ",u.jsxs("a",{href:t.triggerPrUrl,target:"_blank",rel:"noreferrer noopener",className:"underline underline-offset-2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:["#",t.triggerPrNumber," ",t.triggerPrTitle]})]}),t.decisionReason&&u.jsx("p",{className:"mb-3 text-[12px] leading-relaxed",children:t.decisionReason}),t.releaseTitle&&u.jsxs("p",{className:"mb-3 text-[12px]",children:[u.jsx("span",{className:"text-muted-foreground",children:"Release title:"})," ",u.jsx("span",{children:t.releaseTitle})]}),u.jsxs("div",{className:"mb-3 grid grid-cols-1 gap-2 text-[12px] text-muted-foreground md:grid-cols-2",children:[u.jsxs("div",{children:["Base branch: ",t.baseBranch||"n/a"]}),u.jsxs("div",{children:["Trigger SHA: ",SN(t.triggerMergeSha)]}),u.jsxs("div",{children:["Merged at: ",mu(t.triggerMergedAt)]}),u.jsxs("div",{children:["Updated: ",mu(t.updatedAt)]})]}),t.includedPrs.length>0&&u.jsxs("div",{className:"mb-3",children:[u.jsxs("div",{className:"mb-1.5 text-[11px] uppercase tracking-wider text-muted-foreground",children:["Included PRs (",t.includedPrs.length,")"]}),u.jsx("div",{className:"space-y-1 border border-border p-3 text-[12px]",children:t.includedPrs.map(y=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"truncate",children:["#",y.number," ",y.title]}),u.jsx("a",{href:y.url,target:"_blank",rel:"noreferrer noopener",className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"open"})]},`${y.mergeSha}-${y.number}`))})]}),t.releaseNotes&&u.jsxs("div",{className:"mb-3",children:[u.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[u.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Release Notes"}),u.jsx(kN,{text:t.releaseNotes})]}),u.jsx("pre",{className:"whitespace-pre-wrap border border-border bg-background p-3 text-[12px] leading-relaxed font-mono",children:t.releaseNotes})]}),t.error&&u.jsx("div",{className:"mb-3 border border-destructive/40 bg-destructive/5 p-3 text-[12px] text-destructive",children:t.error}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.githubReleaseUrl&&u.jsx("a",{href:t.githubReleaseUrl,target:"_blank",rel:"noreferrer noopener",className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"open release"}),t.status==="error"&&u.jsx("button",{type:"button",onClick:()=>r(t.id),disabled:s,className:"border border-border px-2 py-1 text-[11px] uppercase tracking-wider text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:opacity-50",children:"retry"})]}),p&&u.jsx("p",{className:"mt-2 text-[12px] text-muted-foreground",children:"No details available yet."})]})]})}function NN(){const{data:t=[],isLoading:r}=dt({queryKey:["/api/releases"],refetchInterval:a=>{const l=a.state.data;return Array.isArray(l)&&l.some(d=>bN(d)&&Vv(d.status))?5e3:!1}}),s=ct({mutationFn:async a=>(await nt("POST",`/api/releases/${a}/retry`)).json(),onSuccess:()=>{we.invalidateQueries({queryKey:["/api/releases"]}),Vt({description:"Retry queued."})},onError:a=>{Vt({variant:"destructive",description:`Retry failed: ${a.message}`})}});return u.jsxs("div",{className:"flex min-h-screen flex-col",children:[u.jsx(Bi,{}),u.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-label":"Release Management",children:[u.jsx("rect",{x:"1",y:"1",width:"14",height:"14",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M4 6h8M4 9h8M4 12h5",stroke:"currentColor",strokeWidth:"1"})]}),u.jsx("span",{className:"text-sm font-medium tracking-tight",children:"oh-my-pr"}),u.jsx("span",{className:"border border-border px-1.5 py-0 text-[10px] uppercase tracking-wider text-muted-foreground",children:"releases"})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(An,{href:"/settings",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"settings"}),u.jsx(An,{href:"/",className:"text-[11px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",children:"← back to dashboard"})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsxs("div",{className:"mx-auto max-w-4xl",children:[u.jsxs("div",{className:"mb-5",children:[u.jsx("h1",{className:"text-base font-medium",children:"Release Management"}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Every merged PR can trigger agent evaluation. This page shows release decisions, version bumps, notes, and publishing outcomes."})]}),r&&u.jsx("div",{className:"border border-border px-4 py-6 text-center",children:u.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading…"})}),!r&&t.length===0&&u.jsxs("div",{className:"border border-border px-4 py-8 text-center",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"No release runs yet."}),u.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Runs appear after merged PRs are evaluated for release-worthiness."})]}),u.jsx("div",{className:"flex flex-col gap-2",children:t.map(a=>u.jsx(EN,{run:a,onRetry:l=>s.mutate(l),retryPending:s.isPending},a.id))})]})})]})}const Qv=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",t),...r}));Qv.displayName="Card";const RN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("flex flex-col space-y-1.5 p-6",t),...r}));RN.displayName="CardHeader";const PN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("text-2xl font-semibold leading-none tracking-tight",t),...r}));PN.displayName="CardTitle";const jN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("text-sm text-muted-foreground",t),...r}));jN.displayName="CardDescription";const Gv=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("p-6 pt-0",t),...r}));Gv.displayName="CardContent";const TN=m.forwardRef(({className:t,...r},s)=>u.jsx("div",{ref:s,className:Le("flex items-center p-6 pt-0",t),...r}));TN.displayName="CardFooter";function _N(){return u.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-gray-50",children:u.jsx(Qv,{className:"w-full max-w-md mx-4",children:u.jsxs(Gv,{className:"pt-6",children:[u.jsxs("div",{className:"flex mb-4 gap-2",children:[u.jsx(k0,{className:"h-8 w-8 text-red-500"}),u.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"404 Page Not Found"})]}),u.jsx("p",{className:"mt-4 text-sm text-gray-600",children:"Did you forget to add the page to the router?"})]})})})}function ON(){return u.jsxs(xw,{children:[u.jsx(Oo,{path:"/",component:dN}),u.jsx(Oo,{path:"/settings",component:fN}),u.jsx(Oo,{path:"/changelogs",component:yN}),u.jsx(Oo,{path:"/releases",component:NN}),u.jsx(Oo,{component:_N})]})}function AN(){return u.jsx(ub,{attribute:"class",defaultTheme:"system",enableSystem:!0,children:u.jsx(Qw,{client:we,children:u.jsxs(KS,{children:[u.jsx(l1,{}),u.jsx(Uh,{hook:Bh,children:u.jsx(ON,{})})]})})})}window.location.hash||(window.location.hash="#/");Jx.createRoot(document.getElementById("root")).render(u.jsx(AN,{}));
@@ -29,7 +29,7 @@
29
29
  <link rel="preconnect" href="https://fonts.googleapis.com">
30
30
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
31
31
  <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap" rel="stylesheet">
32
- <script type="module" crossorigin src="./assets/index-CTng6NQK.js"></script>
32
+ <script type="module" crossorigin src="./assets/index-CC3msXls.js"></script>
33
33
  <link rel="stylesheet" crossorigin href="./assets/index-BIO7suRv.css">
34
34
  </head>
35
35
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-pr",
3
- "version": "3.2.3",
3
+ "version": "4.0.0",
4
4
  "description": "Autonomous GitHub PR babysitter that watches repos, triages review feedback, and dispatches AI agents to fix code locally",
5
5
  "keywords": [
6
6
  "github",