@superclawd-ai/pipelines 0.1.3 → 0.1.4

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.
@@ -464,7 +464,7 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
464
464
  `)},n_=function(){var e=parseInt(document.body.getAttribute(tu)||"0",10);return isFinite(e)?e:0},cG=function(){E.useEffect(function(){return document.body.setAttribute(tu,(n_()+1).toString()),function(){var e=n_()-1;e<=0?document.body.removeAttribute(tu):document.body.setAttribute(tu,e.toString())}},[])},dG=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;cG();var s=E.useMemo(function(){return oG(a)},[a]);return E.createElement(lG,{styles:uG(s,!t,a,n?"":"!important")})},$y=!1;if(typeof window<"u")try{var Of=Object.defineProperty({},"passive",{get:function(){return $y=!0,!0}});window.addEventListener("test",Of,Of),window.removeEventListener("test",Of,Of)}catch{$y=!1}var zl=$y?{passive:!1}:!1,pG=function(e){return e.tagName==="TEXTAREA"},EO=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!pG(e)&&n[t]==="visible")},fG=function(e){return EO(e,"overflowY")},mG=function(e){return EO(e,"overflowX")},r_=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=xO(e,r);if(a){var s=vO(e,r),l=s[1],u=s[2];if(l>u)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},hG=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},gG=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},xO=function(e,t){return e==="v"?fG(t):mG(t)},vO=function(e,t){return e==="v"?hG(t):gG(t)},bG=function(e,t){return e==="h"&&t==="rtl"?-1:1},yG=function(e,t,n,r,a){var s=bG(e,window.getComputedStyle(t).direction),l=s*r,u=n.target,d=t.contains(u),p=!1,m=l>0,h=0,y=0;do{if(!u)break;var b=vO(e,u),v=b[0],T=b[1],w=b[2],N=T-w-s*v;(v||N)&&xO(e,u)&&(h+=N,y+=v);var k=u.parentNode;u=k&&k.nodeType===Node.DOCUMENT_FRAGMENT_NODE?k.host:k}while(!d&&u!==document.body||d&&(t.contains(u)||t===u));return(m&&Math.abs(h)<1||!m&&Math.abs(y)<1)&&(p=!0),p},Lf=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},a_=function(e){return[e.deltaX,e.deltaY]},i_=function(e){return e&&"current"in e?e.current:e},EG=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xG=function(e){return`
465
465
  .block-interactivity-`.concat(e,` {pointer-events: none;}
466
466
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
467
- `)},vG=0,Gl=[];function wG(e){var t=E.useRef([]),n=E.useRef([0,0]),r=E.useRef(),a=E.useState(vG++)[0],s=E.useState(yO)[0],l=E.useRef(e);E.useEffect(function(){l.current=e},[e]),E.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var T=zz([e.lockRef.current],(e.shards||[]).map(i_),!0).filter(Boolean);return T.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),T.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var u=E.useCallback(function(T,w){if("touches"in T&&T.touches.length===2||T.type==="wheel"&&T.ctrlKey)return!l.current.allowPinchZoom;var N=Lf(T),k=n.current,A="deltaX"in T?T.deltaX:k[0]-N[0],_="deltaY"in T?T.deltaY:k[1]-N[1],I,O=T.target,R=Math.abs(A)>Math.abs(_)?"h":"v";if("touches"in T&&R==="h"&&O.type==="range")return!1;var F=window.getSelection(),z=F&&F.anchorNode,M=z?z===O||z.contains(O):!1;if(M)return!1;var Q=r_(R,O);if(!Q)return!0;if(Q?I=R:(I=R==="v"?"h":"v",Q=r_(R,O)),!Q)return!1;if(!r.current&&"changedTouches"in T&&(A||_)&&(r.current=I),!I)return!0;var Y=r.current||I;return yG(Y,w,T,Y==="h"?A:_)},[]),d=E.useCallback(function(T){var w=T;if(!(!Gl.length||Gl[Gl.length-1]!==s)){var N="deltaY"in w?a_(w):Lf(w),k=t.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&EG(I.delta,N)})[0];if(k&&k.should){w.cancelable&&w.preventDefault();return}if(!k){var A=(l.current.shards||[]).map(i_).filter(Boolean).filter(function(I){return I.contains(w.target)}),_=A.length>0?u(w,A[0]):!l.current.noIsolation;_&&w.cancelable&&w.preventDefault()}}},[]),p=E.useCallback(function(T,w,N,k){var A={name:T,delta:w,target:N,should:k,shadowParent:SG(N)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(_){return _!==A})},1)},[]),m=E.useCallback(function(T){n.current=Lf(T),r.current=void 0},[]),h=E.useCallback(function(T){p(T.type,a_(T),T.target,u(T,e.lockRef.current))},[]),y=E.useCallback(function(T){p(T.type,Lf(T),T.target,u(T,e.lockRef.current))},[]);E.useEffect(function(){return Gl.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:y}),document.addEventListener("wheel",d,zl),document.addEventListener("touchmove",d,zl),document.addEventListener("touchstart",m,zl),function(){Gl=Gl.filter(function(T){return T!==s}),document.removeEventListener("wheel",d,zl),document.removeEventListener("touchmove",d,zl),document.removeEventListener("touchstart",m,zl)}},[]);var b=e.removeScrollBar,v=e.inert;return E.createElement(E.Fragment,null,v?E.createElement(s,{styles:xG(a)}):null,b?E.createElement(dG,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function SG(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const TG=Zz(bO,wG);var Sh=E.forwardRef(function(e,t){return E.createElement(wh,ci({},e,{ref:t,sideCar:TG}))});Sh.classNames=wh.classNames;var zy=["Enter"," "],NG=["ArrowDown","PageUp","Home"],wO=["ArrowUp","PageDown","End"],kG=[...NG,...wO],CG={ltr:[...zy,"ArrowRight"],rtl:[...zy,"ArrowLeft"]},AG={ltr:["ArrowLeft"],rtl:["ArrowRight"]},qd="Menu",[yd,_G,RG]=dh(qd),[rl,SO]=ha(qd,[RG,xh,vh]),Th=xh(),TO=vh(),[IG,al]=rl(qd),[DG,Yd]=rl(qd),NO=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:s,modal:l=!0}=e,u=Th(t),[d,p]=E.useState(null),m=E.useRef(!1),h=na(s),y=fh(a);return E.useEffect(()=>{const b=()=>{m.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>m.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),i.jsx(rO,{...u,children:i.jsx(IG,{scope:t,open:n,onOpenChange:h,content:d,onContentChange:p,children:i.jsx(DG,{scope:t,onClose:E.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:y,modal:l,children:r})})})};NO.displayName=qd;var OG="MenuAnchor",gx=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Th(n);return i.jsx(aO,{...a,...r,ref:t})});gx.displayName=OG;var bx="MenuPortal",[LG,kO]=rl(bx,{forceMount:void 0}),CO=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,s=al(bx,t);return i.jsx(LG,{scope:t,forceMount:n,children:i.jsx(Ya,{present:n||s.open,children:i.jsx(zd,{asChild:!0,container:a,children:r})})})};CO.displayName=bx;var Ia="MenuContent",[MG,yx]=rl(Ia),AO=E.forwardRef((e,t)=>{const n=kO(Ia,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,s=al(Ia,e.__scopeMenu),l=Yd(Ia,e.__scopeMenu);return i.jsx(yd.Provider,{scope:e.__scopeMenu,children:i.jsx(Ya,{present:r||s.open,children:i.jsx(yd.Slot,{scope:e.__scopeMenu,children:l.modal?i.jsx(PG,{...a,ref:t}):i.jsx(FG,{...a,ref:t})})})})}),PG=E.forwardRef((e,t)=>{const n=al(Ia,e.__scopeMenu),r=E.useRef(null),a=Ht(t,r);return E.useEffect(()=>{const s=r.current;if(s)return hx(s)},[]),i.jsx(Ex,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:$e(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),FG=E.forwardRef((e,t)=>{const n=al(Ia,e.__scopeMenu);return i.jsx(Ex,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),jG=wu("MenuContent.ScrollLock"),Ex=E.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:s,onCloseAutoFocus:l,disableOutsidePointerEvents:u,onEntryFocus:d,onEscapeKeyDown:p,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:y,onDismiss:b,disableOutsideScroll:v,...T}=e,w=al(Ia,n),N=Yd(Ia,n),k=Th(n),A=TO(n),_=_G(n),[I,O]=E.useState(null),R=E.useRef(null),F=Ht(t,R,w.onContentChange),z=E.useRef(0),M=E.useRef(""),Q=E.useRef(0),Y=E.useRef(null),ae=E.useRef("right"),V=E.useRef(0),G=v?Sh:E.Fragment,te=v?{as:jG,allowPinchZoom:!0}:void 0,ue=H=>{var fe,xe;const D=M.current+H,U=_().filter(ve=>!ve.disabled),Z=document.activeElement,j=(fe=U.find(ve=>ve.ref.current===Z))==null?void 0:fe.textValue,Se=U.map(ve=>ve.textValue),oe=XG(Se,D,j),pe=(xe=U.find(ve=>ve.textValue===oe))==null?void 0:xe.ref.current;(function ve(Ue){M.current=Ue,window.clearTimeout(z.current),Ue!==""&&(z.current=window.setTimeout(()=>ve(""),1e3))})(D),pe&&setTimeout(()=>pe.focus())};E.useEffect(()=>()=>window.clearTimeout(z.current),[]),sx();const q=E.useCallback(H=>{var U,Z;return ae.current===((U=Y.current)==null?void 0:U.side)&&ZG(H,(Z=Y.current)==null?void 0:Z.area)},[]);return i.jsx(MG,{scope:n,searchRef:M,onItemEnter:E.useCallback(H=>{q(H)&&H.preventDefault()},[q]),onItemLeave:E.useCallback(H=>{var D;q(H)||((D=R.current)==null||D.focus(),O(null))},[q]),onTriggerLeave:E.useCallback(H=>{q(H)&&H.preventDefault()},[q]),pointerGraceTimerRef:Q,onPointerGraceIntentChange:E.useCallback(H=>{Y.current=H},[]),children:i.jsx(G,{...te,children:i.jsx(mh,{asChild:!0,trapped:a,onMountAutoFocus:$e(s,H=>{var D;H.preventDefault(),(D=R.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:i.jsx($d,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:p,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:y,onDismiss:b,children:i.jsx(pO,{asChild:!0,...A,dir:N.dir,orientation:"vertical",loop:r,currentTabStopId:I,onCurrentTabStopIdChange:O,onEntryFocus:$e(d,H=>{N.isUsingKeyboardRef.current||H.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(iO,{role:"menu","aria-orientation":"vertical","data-state":GO(w.open),"data-radix-menu-content":"",dir:N.dir,...k,...T,ref:F,style:{outline:"none",...T.style},onKeyDown:$e(T.onKeyDown,H=>{const U=H.target.closest("[data-radix-menu-content]")===H.currentTarget,Z=H.ctrlKey||H.altKey||H.metaKey,j=H.key.length===1;U&&(H.key==="Tab"&&H.preventDefault(),!Z&&j&&ue(H.key));const Se=R.current;if(H.target!==Se||!kG.includes(H.key))return;H.preventDefault();const pe=_().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);wO.includes(H.key)&&pe.reverse(),YG(pe)}),onBlur:$e(e.onBlur,H=>{H.currentTarget.contains(H.target)||(window.clearTimeout(z.current),M.current="")}),onPointerMove:$e(e.onPointerMove,Ed(H=>{const D=H.target,U=V.current!==H.clientX;if(H.currentTarget.contains(D)&&U){const Z=H.clientX>V.current?"right":"left";ae.current=Z,V.current=H.clientX}}))})})})})})})});AO.displayName=Ia;var BG="MenuGroup",xx=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(gt.div,{role:"group",...r,ref:t})});xx.displayName=BG;var UG="MenuLabel",_O=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(gt.div,{...r,ref:t})});_O.displayName=UG;var Am="MenuItem",s_="menu.itemSelect",Nh=E.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,s=E.useRef(null),l=Yd(Am,e.__scopeMenu),u=yx(Am,e.__scopeMenu),d=Ht(t,s),p=E.useRef(!1),m=()=>{const h=s.current;if(!n&&h){const y=new CustomEvent(s_,{bubbles:!0,cancelable:!0});h.addEventListener(s_,b=>r==null?void 0:r(b),{once:!0}),tx(h,y),y.defaultPrevented?p.current=!1:l.onClose()}};return i.jsx(RO,{...a,ref:d,disabled:n,onClick:$e(e.onClick,m),onPointerDown:h=>{var y;(y=e.onPointerDown)==null||y.call(e,h),p.current=!0},onPointerUp:$e(e.onPointerUp,h=>{var y;p.current||(y=h.currentTarget)==null||y.click()}),onKeyDown:$e(e.onKeyDown,h=>{const y=u.searchRef.current!=="";n||y&&h.key===" "||zy.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Nh.displayName=Am;var RO=E.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...s}=e,l=yx(Am,n),u=TO(n),d=E.useRef(null),p=Ht(t,d),[m,h]=E.useState(!1),[y,b]=E.useState("");return E.useEffect(()=>{const v=d.current;v&&b((v.textContent??"").trim())},[s.children]),i.jsx(yd.ItemSlot,{scope:n,disabled:r,textValue:a??y,children:i.jsx(fO,{asChild:!0,...u,focusable:!r,children:i.jsx(gt.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:p,onPointerMove:$e(e.onPointerMove,Ed(v=>{r?l.onItemLeave(v):(l.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$e(e.onPointerLeave,Ed(v=>l.onItemLeave(v))),onFocus:$e(e.onFocus,()=>h(!0)),onBlur:$e(e.onBlur,()=>h(!1))})})})}),HG="MenuCheckboxItem",IO=E.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return i.jsx(PO,{scope:e.__scopeMenu,checked:n,children:i.jsx(Nh,{role:"menuitemcheckbox","aria-checked":_m(n)?"mixed":n,...a,ref:t,"data-state":wx(n),onSelect:$e(a.onSelect,()=>r==null?void 0:r(_m(n)?!0:!n),{checkForDefaultPrevented:!1})})})});IO.displayName=HG;var DO="MenuRadioGroup",[$G,zG]=rl(DO,{value:void 0,onValueChange:()=>{}}),OO=E.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,s=na(r);return i.jsx($G,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(xx,{...a,ref:t})})});OO.displayName=DO;var LO="MenuRadioItem",MO=E.forwardRef((e,t)=>{const{value:n,...r}=e,a=zG(LO,e.__scopeMenu),s=n===a.value;return i.jsx(PO,{scope:e.__scopeMenu,checked:s,children:i.jsx(Nh,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wx(s),onSelect:$e(r.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,n)},{checkForDefaultPrevented:!1})})})});MO.displayName=LO;var vx="MenuItemIndicator",[PO,GG]=rl(vx,{checked:!1}),FO=E.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,s=GG(vx,n);return i.jsx(Ya,{present:r||_m(s.checked)||s.checked===!0,children:i.jsx(gt.span,{...a,ref:t,"data-state":wx(s.checked)})})});FO.displayName=vx;var VG="MenuSeparator",jO=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(gt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});jO.displayName=VG;var WG="MenuArrow",BO=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Th(n);return i.jsx(sO,{...a,...r,ref:t})});BO.displayName=WG;var qG="MenuSub",[_ue,UO]=rl(qG),Wc="MenuSubTrigger",HO=E.forwardRef((e,t)=>{const n=al(Wc,e.__scopeMenu),r=Yd(Wc,e.__scopeMenu),a=UO(Wc,e.__scopeMenu),s=yx(Wc,e.__scopeMenu),l=E.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:d}=s,p={__scopeMenu:e.__scopeMenu},m=E.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return E.useEffect(()=>m,[m]),E.useEffect(()=>{const h=u.current;return()=>{window.clearTimeout(h),d(null)}},[u,d]),i.jsx(gx,{asChild:!0,...p,children:i.jsx(RO,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":GO(n.open),...e,ref:Hd(t,a.onTriggerChange),onClick:h=>{var y;(y=e.onClick)==null||y.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:$e(e.onPointerMove,Ed(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(s.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:$e(e.onPointerLeave,Ed(h=>{var b,v;m();const y=(b=n.content)==null?void 0:b.getBoundingClientRect();if(y){const T=(v=n.content)==null?void 0:v.dataset.side,w=T==="right",N=w?-5:5,k=y[w?"left":"right"],A=y[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+N,y:h.clientY},{x:k,y:y.top},{x:A,y:y.top},{x:A,y:y.bottom},{x:k,y:y.bottom}],side:T}),window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:$e(e.onKeyDown,h=>{var b;const y=s.searchRef.current!=="";e.disabled||y&&h.key===" "||CG[r.dir].includes(h.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),h.preventDefault())})})})});HO.displayName=Wc;var $O="MenuSubContent",zO=E.forwardRef((e,t)=>{const n=kO(Ia,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,s=al(Ia,e.__scopeMenu),l=Yd(Ia,e.__scopeMenu),u=UO($O,e.__scopeMenu),d=E.useRef(null),p=Ht(t,d);return i.jsx(yd.Provider,{scope:e.__scopeMenu,children:i.jsx(Ya,{present:r||s.open,children:i.jsx(yd.Slot,{scope:e.__scopeMenu,children:i.jsx(Ex,{id:u.contentId,"aria-labelledby":u.triggerId,...a,ref:p,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var h;l.isUsingKeyboardRef.current&&((h=d.current)==null||h.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:$e(e.onFocusOutside,m=>{m.target!==u.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:$e(e.onEscapeKeyDown,m=>{l.onClose(),m.preventDefault()}),onKeyDown:$e(e.onKeyDown,m=>{var b;const h=m.currentTarget.contains(m.target),y=AG[l.dir].includes(m.key);h&&y&&(s.onOpenChange(!1),(b=u.trigger)==null||b.focus(),m.preventDefault())})})})})})});zO.displayName=$O;function GO(e){return e?"open":"closed"}function _m(e){return e==="indeterminate"}function wx(e){return _m(e)?"indeterminate":e?"checked":"unchecked"}function YG(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function KG(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function XG(e,t,n){const a=t.length>1&&Array.from(t).every(p=>p===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=KG(e,Math.max(s,0));a.length===1&&(l=l.filter(p=>p!==n));const d=l.find(p=>p.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function QG(e,t){const{x:n,y:r}=e;let a=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const u=t[s],d=t[l],p=u.x,m=u.y,h=d.x,y=d.y;m>r!=y>r&&n<(h-p)*(r-m)/(y-m)+p&&(a=!a)}return a}function ZG(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return QG(n,t)}function Ed(e){return t=>t.pointerType==="mouse"?e(t):void 0}var JG=NO,eV=gx,tV=CO,nV=AO,rV=xx,aV=_O,iV=Nh,sV=IO,oV=OO,lV=MO,uV=FO,cV=jO,dV=BO,pV=HO,fV=zO,kh="DropdownMenu",[mV]=ha(kh,[SO]),zr=SO(),[hV,VO]=mV(kh),WO=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:s,onOpenChange:l,modal:u=!0}=e,d=zr(t),p=E.useRef(null),[m,h]=Qi({prop:a,defaultProp:s??!1,onChange:l,caller:kh});return i.jsx(hV,{scope:t,triggerId:Yi(),triggerRef:p,contentId:Yi(),open:m,onOpenChange:h,onOpenToggle:E.useCallback(()=>h(y=>!y),[h]),modal:u,children:i.jsx(JG,{...d,open:m,onOpenChange:h,dir:r,modal:u,children:n})})};WO.displayName=kh;var qO="DropdownMenuTrigger",YO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,s=VO(qO,n),l=zr(n);return i.jsx(eV,{asChild:!0,...l,children:i.jsx(gt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Hd(t,s.triggerRef),onPointerDown:$e(e.onPointerDown,u=>{!r&&u.button===0&&u.ctrlKey===!1&&(s.onOpenToggle(),s.open||u.preventDefault())}),onKeyDown:$e(e.onKeyDown,u=>{r||(["Enter"," "].includes(u.key)&&s.onOpenToggle(),u.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});YO.displayName=qO;var gV="DropdownMenuPortal",KO=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zr(t);return i.jsx(tV,{...r,...n})};KO.displayName=gV;var XO="DropdownMenuContent",QO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=VO(XO,n),s=zr(n),l=E.useRef(!1);return i.jsx(nV,{id:a.contentId,"aria-labelledby":a.triggerId,...s,...r,ref:t,onCloseAutoFocus:$e(e.onCloseAutoFocus,u=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,u.preventDefault()}),onInteractOutside:$e(e.onInteractOutside,u=>{const d=u.detail.originalEvent,p=d.button===0&&d.ctrlKey===!0,m=d.button===2||p;(!a.modal||m)&&(l.current=!0)}),style:{...e.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)"}})});QO.displayName=XO;var bV="DropdownMenuGroup",yV=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(rV,{...a,...r,ref:t})});yV.displayName=bV;var EV="DropdownMenuLabel",ZO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(aV,{...a,...r,ref:t})});ZO.displayName=EV;var xV="DropdownMenuItem",JO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(iV,{...a,...r,ref:t})});JO.displayName=xV;var vV="DropdownMenuCheckboxItem",eL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(sV,{...a,...r,ref:t})});eL.displayName=vV;var wV="DropdownMenuRadioGroup",SV=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(oV,{...a,...r,ref:t})});SV.displayName=wV;var TV="DropdownMenuRadioItem",tL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(lV,{...a,...r,ref:t})});tL.displayName=TV;var NV="DropdownMenuItemIndicator",nL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(uV,{...a,...r,ref:t})});nL.displayName=NV;var kV="DropdownMenuSeparator",rL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(cV,{...a,...r,ref:t})});rL.displayName=kV;var CV="DropdownMenuArrow",AV=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(dV,{...a,...r,ref:t})});AV.displayName=CV;var _V="DropdownMenuSubTrigger",aL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(pV,{...a,...r,ref:t})});aL.displayName=_V;var RV="DropdownMenuSubContent",iL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(fV,{...a,...r,ref:t,style:{...e.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)"}})});iL.displayName=RV;var IV=WO,DV=YO,OV=KO,sL=QO,oL=ZO,lL=JO,uL=eL,cL=tL,dL=nL,pL=rL,fL=aL,mL=iL;const jn=IV,Bn=DV,LV=E.forwardRef(({className:e,inset:t,children:n,...r},a)=>i.jsxs(fL,{ref:a,className:Ee("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",t&&"pl-8",e),...r,children:[n,i.jsx(nl,{className:"ml-auto"})]}));LV.displayName=fL.displayName;const MV=E.forwardRef(({className:e,...t},n)=>i.jsx(mL,{ref:n,className:Ee("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",e),...t}));MV.displayName=mL.displayName;const In=E.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(OV,{children:i.jsx(sL,{ref:r,sideOffset:t,className:Ee("z-50 min-w-[8rem] overflow-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",e),...n})}));In.displayName=sL.displayName;const ct=E.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(lL,{ref:r,className:Ee("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",t&&"pl-8",e),...n}));ct.displayName=lL.displayName;const PV=E.forwardRef(({className:e,children:t,checked:n,...r},a)=>i.jsxs(uL,{ref:a,className:Ee("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",e),checked:n,...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(dL,{children:i.jsx(Nn,{className:"h-4 w-4"})})}),t]}));PV.displayName=uL.displayName;const FV=E.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(cL,{ref:r,className:Ee("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",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(dL,{children:i.jsx(jB,{className:"h-2 w-2 fill-current"})})}),t]}));FV.displayName=cL.displayName;const Xc=E.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(oL,{ref:r,className:Ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Xc.displayName=oL.displayName;const sr=E.forwardRef(({className:e,...t},n)=>i.jsx(pL,{ref:n,className:Ee("-mx-1 my-1 h-px bg-muted",e),...t}));sr.displayName=pL.displayName;function jV(){const{data:e,isLoading:t}=vI();return!t&&e&&!e.loggedIn?i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"max-w-md space-y-4 rounded-lg border bg-card p-8 text-center",children:[i.jsx(xI,{className:"mx-auto h-8 w-8 text-muted-foreground"}),i.jsx("h1",{className:"text-lg font-semibold",children:"You're not logged into SuperClawd"}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:["Run"," ",i.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5",children:"superclawd login"})," ","in your terminal, then reload."]}),i.jsx(re,{onClick:()=>window.location.reload(),children:"Reload"})]})}):i.jsxs(l9,{children:[i.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground",children:[i.jsx(BV,{}),i.jsx("main",{className:"min-h-0 flex-1 overflow-auto",children:i.jsx(nI,{})})]}),i.jsx(t$,{})]})}function BV(){var r;const{data:e}=rh(),{data:t}=vI(),n=(e??[]).some(a=>a.linkStatus==="unlinked"||a.authStatus!=="connected");return i.jsxs("header",{className:"flex h-16 shrink-0 items-center gap-3 border-b bg-card/60 px-4",children:[i.jsxs("a",{href:"https://superclawd.com",target:"_blank",rel:"noopener noreferrer",title:"superclawd.com",className:"flex shrink-0 items-center gap-2 rounded transition-opacity hover:opacity-80",children:[i.jsx(xI,{className:"h-5 w-5 text-primary"}),i.jsxs("div",{className:"text-sm font-semibold leading-none",children:["SuperClawd"," ",i.jsx("span",{className:"font-normal text-muted-foreground",children:"Pipelines"})]})]}),i.jsx("div",{className:"mx-1 h-6 w-px shrink-0 bg-border"}),i.jsx(UV,{}),i.jsxs("nav",{className:"ml-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[i.jsx(Lc,{to:"/board",match:["/board","/tickets"],icon:i.jsx(mI,{className:"h-4 w-4"}),label:"Boards"}),i.jsx(Lc,{to:"/batches",match:["/batches"],icon:i.jsx(Ks,{className:"h-4 w-4"}),label:"Batches"}),i.jsx(Lc,{to:"/schedules",match:["/schedules"],icon:i.jsx(hd,{className:"h-4 w-4"}),label:"Schedules"}),i.jsx(Lc,{to:"/chat",match:["/chat"],icon:i.jsx(Iy,{className:"h-4 w-4"}),label:"Conversations"}),i.jsx(Lc,{to:"/docs",match:["/docs"],icon:i.jsx(Ry,{className:"h-4 w-4"}),label:"Docs"})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-3.5",children:[((r=t==null?void 0:t.account)==null?void 0:r.email)&&i.jsx("span",{className:"hidden max-w-[180px] truncate text-xs text-muted-foreground xl:inline",children:t.account.email}),i.jsxs(ji,{to:"/settings",title:"Settings",className:({isActive:a})=>Ee("relative flex h-9 w-9 items-center justify-center rounded-md border border-border/60 transition-colors",a?"bg-accent text-foreground":"text-foreground/70 hover:bg-accent/50 hover:text-foreground"),children:[i.jsx(bI,{className:"h-[18px] w-[18px]"}),n&&i.jsx("span",{title:"A connection needs attention",className:"absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-amber-400 ring-2 ring-card"})]})]})]})}function UV(){const{workspaces:e,active:t,setActiveId:n}=eo(),r=zn();return e.length===0?i.jsxs(re,{variant:"ghost",size:"sm",className:"h-9 shrink-0 gap-2 px-2 font-medium text-muted-foreground",onClick:()=>r("/settings/workspaces"),children:[i.jsx(Hr,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:"Connect a workspace"})]}):i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsxs(re,{variant:"ghost",size:"sm",className:"h-9 shrink-0 gap-2 px-2 font-medium",children:[i.jsx("span",{className:"max-w-[120px] truncate sm:max-w-[180px]",children:(t==null?void 0:t.name)??"Workspace"}),i.jsx(dI,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),i.jsxs(In,{align:"start",className:"w-56",children:[e.map(a=>i.jsxs(ct,{onSelect:()=>n(a.id),className:"gap-2",children:[i.jsx(Nn,{className:Ee("h-4 w-4",a.id===(t==null?void 0:t.id)?"opacity-100":"opacity-0")}),i.jsx("span",{className:"flex-1 truncate",children:a.name}),i.jsx("span",{className:Ee("rounded px-1.5 py-0.5 text-[10px] font-medium text-white",a.tier==="paid"?"bg-purple-600":"bg-green-600"),children:a.tier==="paid"?"Paid":"Free"})]},a.id)),i.jsx(sr,{}),i.jsxs(ct,{onSelect:()=>r("/settings/workspaces"),className:"gap-2 text-muted-foreground",children:[i.jsx(bI,{className:"h-4 w-4"}),"Manage workspaces"]})]})]})}function Lc({to:e,match:t,icon:n,label:r}){const{pathname:a}=Ei(),s=t.some(l=>a===l||a.startsWith(`${l}/`));return i.jsxs(Ar,{to:e,title:r,className:Ee("flex shrink-0 items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[n,i.jsx("span",{className:"hidden lg:inline",children:r})]})}function HV(e,t=300){const[n,r]=E.useState(e);return E.useEffect(()=>{const a=setTimeout(()=>r(e),t);return()=>clearTimeout(a)},[e,t]),n}function hL(e){switch(e){case"running":return{label:"Running",className:"border-sky-500/40 bg-sky-500/15 text-sky-300"};case"queued":return{label:"Queued",className:"border-border bg-muted text-muted-foreground"};case"paused":return{label:"Paused",className:"border-amber-500/40 bg-amber-500/15 text-amber-300"};case"done":return{label:"Done",className:"border-green-500/40 bg-green-500/15 text-green-300"};default:return{label:"Idle",className:"border-border bg-muted text-muted-foreground"}}}function xd(e){switch(e){case"linear":return{label:"Linear",className:"bg-indigo-500/15 text-indigo-300 border-indigo-500/30"};case"jira":return{label:"Jira",className:"bg-blue-500/15 text-blue-300 border-blue-500/30"};case"asana":return{label:"Asana",className:"bg-rose-500/15 text-rose-300 border-rose-500/30"};case"clickup":return{label:"ClickUp",className:"bg-violet-500/15 text-violet-300 border-violet-500/30"};case"monday":return{label:"Monday",className:"bg-red-500/15 text-red-300 border-red-500/30"};case"local":return{label:"Local",className:"bg-muted text-muted-foreground border-border"}}}function Sx(e){return e!=="asana"&&e!=="monday"}function $V(e){switch(e){case"linear":case"jira":return{labels:!0,assignee:!0};case"asana":return{labels:!1,assignee:!0};case"clickup":return{labels:!0,assignee:!1};default:return{labels:!1,assignee:!1}}}function zV(e){return e!=="asana"}function gL(e,t,n){return e==="team"?`Team: ${t??"—"}`:e==="agent"?`Agent: ${n??"—"}`:"Anyone"}function Gy(e){if(!e)return"—";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=t-Date.now(),r=n<0,a=Math.round(Math.abs(n)/1e3),s=Math.round(a/60),l=Math.round(s/60),u=Math.round(l/24),d=a<60?`${a}s`:s<60?`${s}m`:l<24?`${l}h`:`${u}d`;return r?`${d} ago`:`in ${d}`}function GV(e){return{linear:"bg-indigo-400",jira:"bg-blue-400",asana:"bg-rose-400",clickup:"bg-violet-400",monday:"bg-red-400",local:"bg-muted-foreground/50"}[e]}function Vy(e){return e==null||e===0?null:["","Urgent","High","Medium","Low"][e]??null}const Qc=[{column:"backlog",label:"Backlog"},{column:"in_progress",label:"In Progress"},{column:"needs_input",label:"Blocked"},{column:"in_review",label:"In Review"},{column:"done",label:"Done"}];function VV(e){const t={backlog:{label:"Backlog",className:"bg-muted text-muted-foreground border-border"},in_progress:{label:"In Progress",className:"bg-blue-500/15 text-blue-300 border-blue-500/40"},needs_input:{label:"Blocked",className:"bg-red-500/15 text-red-300 border-red-500/40"},in_review:{label:"In Review",className:"bg-amber-500/15 text-amber-300 border-amber-500/40"},done:{label:"Done",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/40"}};return t[e]??t.backlog}function bL(e,t){const n={not_started:{label:"Not started",className:"bg-muted text-muted-foreground border-border"},running:{label:"Running",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},paused:{label:"Paused",className:"bg-muted text-muted-foreground border-border"},blocked:{label:"Needs input",className:"bg-amber-500/15 text-amber-300 border-amber-500/30"},stopped:{label:"Stopped",className:"bg-muted text-muted-foreground border-border"}};return e==="stopped"&&t==="completed"?{label:"Completed",className:"bg-sky-500/15 text-sky-300 border-sky-500/30"}:e==="stopped"&&t==="error"?{label:"Failed",className:"bg-red-500/15 text-red-300 border-red-500/30"}:n[e]}const Cn=E.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:Ee("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Cn.displayName="Input";var Ch="Dialog",[yL,EL]=ha(Ch),[WV,Ka]=yL(Ch),xL=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:s,modal:l=!0}=e,u=E.useRef(null),d=E.useRef(null),[p,m]=Qi({prop:r,defaultProp:a??!1,onChange:s,caller:Ch});return i.jsx(WV,{scope:t,triggerRef:u,contentRef:d,contentId:Yi(),titleId:Yi(),descriptionId:Yi(),open:p,onOpenChange:m,onOpenToggle:E.useCallback(()=>m(h=>!h),[m]),modal:l,children:n})};xL.displayName=Ch;var vL="DialogTrigger",wL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(vL,n),s=Ht(t,a.triggerRef);return i.jsx(gt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":kx(a.open),...r,ref:s,onClick:$e(e.onClick,a.onOpenToggle)})});wL.displayName=vL;var Tx="DialogPortal",[qV,SL]=yL(Tx,{forceMount:void 0}),TL=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,s=Ka(Tx,t);return i.jsx(qV,{scope:t,forceMount:n,children:E.Children.map(r,l=>i.jsx(Ya,{present:n||s.open,children:i.jsx(zd,{asChild:!0,container:a,children:l})}))})};TL.displayName=Tx;var Rm="DialogOverlay",NL=E.forwardRef((e,t)=>{const n=SL(Rm,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,s=Ka(Rm,e.__scopeDialog);return s.modal?i.jsx(Ya,{present:r||s.open,children:i.jsx(KV,{...a,ref:t})}):null});NL.displayName=Rm;var YV=wu("DialogOverlay.RemoveScroll"),KV=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(Rm,n);return i.jsx(Sh,{as:YV,allowPinchZoom:!0,shards:[a.contentRef],children:i.jsx(gt.div,{"data-state":kx(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Vo="DialogContent",kL=E.forwardRef((e,t)=>{const n=SL(Vo,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,s=Ka(Vo,e.__scopeDialog);return i.jsx(Ya,{present:r||s.open,children:s.modal?i.jsx(XV,{...a,ref:t}):i.jsx(QV,{...a,ref:t})})});kL.displayName=Vo;var XV=E.forwardRef((e,t)=>{const n=Ka(Vo,e.__scopeDialog),r=E.useRef(null),a=Ht(t,n.contentRef,r);return E.useEffect(()=>{const s=r.current;if(s)return hx(s)},[]),i.jsx(CL,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:$e(e.onCloseAutoFocus,s=>{var l;s.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:$e(e.onPointerDownOutside,s=>{const l=s.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0;(l.button===2||u)&&s.preventDefault()}),onFocusOutside:$e(e.onFocusOutside,s=>s.preventDefault())})}),QV=E.forwardRef((e,t)=>{const n=Ka(Vo,e.__scopeDialog),r=E.useRef(!1),a=E.useRef(!1);return i.jsx(CL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,u;(l=e.onCloseAutoFocus)==null||l.call(e,s),s.defaultPrevented||(r.current||(u=n.triggerRef.current)==null||u.focus(),s.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:s=>{var d,p;(d=e.onInteractOutside)==null||d.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((p=n.triggerRef.current)==null?void 0:p.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})}),CL=E.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:s,...l}=e,u=Ka(Vo,n),d=E.useRef(null),p=Ht(t,d);return sx(),i.jsxs(i.Fragment,{children:[i.jsx(mh,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:s,children:i.jsx($d,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":kx(u.open),...l,ref:p,onDismiss:()=>u.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(JV,{titleId:u.titleId}),i.jsx(tW,{contentRef:d,descriptionId:u.descriptionId})]})]})}),Nx="DialogTitle",AL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(Nx,n);return i.jsx(gt.h2,{id:a.titleId,...r,ref:t})});AL.displayName=Nx;var _L="DialogDescription",RL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(_L,n);return i.jsx(gt.p,{id:a.descriptionId,...r,ref:t})});RL.displayName=_L;var IL="DialogClose",DL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(IL,n);return i.jsx(gt.button,{type:"button",...r,ref:t,onClick:$e(e.onClick,()=>a.onOpenChange(!1))})});DL.displayName=IL;function kx(e){return e?"open":"closed"}var OL="DialogTitleWarning",[ZV,LL]=uH(OL,{contentName:Vo,titleName:Nx,docsSlug:"dialog"}),JV=({titleId:e})=>{const t=LL(OL),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
467
+ `)},vG=0,Gl=[];function wG(e){var t=E.useRef([]),n=E.useRef([0,0]),r=E.useRef(),a=E.useState(vG++)[0],s=E.useState(yO)[0],l=E.useRef(e);E.useEffect(function(){l.current=e},[e]),E.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var T=zz([e.lockRef.current],(e.shards||[]).map(i_),!0).filter(Boolean);return T.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),T.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var u=E.useCallback(function(T,w){if("touches"in T&&T.touches.length===2||T.type==="wheel"&&T.ctrlKey)return!l.current.allowPinchZoom;var N=Lf(T),k=n.current,A="deltaX"in T?T.deltaX:k[0]-N[0],_="deltaY"in T?T.deltaY:k[1]-N[1],I,O=T.target,R=Math.abs(A)>Math.abs(_)?"h":"v";if("touches"in T&&R==="h"&&O.type==="range")return!1;var F=window.getSelection(),z=F&&F.anchorNode,M=z?z===O||z.contains(O):!1;if(M)return!1;var Q=r_(R,O);if(!Q)return!0;if(Q?I=R:(I=R==="v"?"h":"v",Q=r_(R,O)),!Q)return!1;if(!r.current&&"changedTouches"in T&&(A||_)&&(r.current=I),!I)return!0;var Y=r.current||I;return yG(Y,w,T,Y==="h"?A:_)},[]),d=E.useCallback(function(T){var w=T;if(!(!Gl.length||Gl[Gl.length-1]!==s)){var N="deltaY"in w?a_(w):Lf(w),k=t.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&EG(I.delta,N)})[0];if(k&&k.should){w.cancelable&&w.preventDefault();return}if(!k){var A=(l.current.shards||[]).map(i_).filter(Boolean).filter(function(I){return I.contains(w.target)}),_=A.length>0?u(w,A[0]):!l.current.noIsolation;_&&w.cancelable&&w.preventDefault()}}},[]),p=E.useCallback(function(T,w,N,k){var A={name:T,delta:w,target:N,should:k,shadowParent:SG(N)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(_){return _!==A})},1)},[]),m=E.useCallback(function(T){n.current=Lf(T),r.current=void 0},[]),h=E.useCallback(function(T){p(T.type,a_(T),T.target,u(T,e.lockRef.current))},[]),y=E.useCallback(function(T){p(T.type,Lf(T),T.target,u(T,e.lockRef.current))},[]);E.useEffect(function(){return Gl.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:y}),document.addEventListener("wheel",d,zl),document.addEventListener("touchmove",d,zl),document.addEventListener("touchstart",m,zl),function(){Gl=Gl.filter(function(T){return T!==s}),document.removeEventListener("wheel",d,zl),document.removeEventListener("touchmove",d,zl),document.removeEventListener("touchstart",m,zl)}},[]);var b=e.removeScrollBar,v=e.inert;return E.createElement(E.Fragment,null,v?E.createElement(s,{styles:xG(a)}):null,b?E.createElement(dG,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function SG(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const TG=Zz(bO,wG);var Sh=E.forwardRef(function(e,t){return E.createElement(wh,ci({},e,{ref:t,sideCar:TG}))});Sh.classNames=wh.classNames;var zy=["Enter"," "],NG=["ArrowDown","PageUp","Home"],wO=["ArrowUp","PageDown","End"],kG=[...NG,...wO],CG={ltr:[...zy,"ArrowRight"],rtl:[...zy,"ArrowLeft"]},AG={ltr:["ArrowLeft"],rtl:["ArrowRight"]},qd="Menu",[yd,_G,RG]=dh(qd),[rl,SO]=ha(qd,[RG,xh,vh]),Th=xh(),TO=vh(),[IG,al]=rl(qd),[DG,Yd]=rl(qd),NO=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:s,modal:l=!0}=e,u=Th(t),[d,p]=E.useState(null),m=E.useRef(!1),h=na(s),y=fh(a);return E.useEffect(()=>{const b=()=>{m.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>m.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),i.jsx(rO,{...u,children:i.jsx(IG,{scope:t,open:n,onOpenChange:h,content:d,onContentChange:p,children:i.jsx(DG,{scope:t,onClose:E.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:y,modal:l,children:r})})})};NO.displayName=qd;var OG="MenuAnchor",gx=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Th(n);return i.jsx(aO,{...a,...r,ref:t})});gx.displayName=OG;var bx="MenuPortal",[LG,kO]=rl(bx,{forceMount:void 0}),CO=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,s=al(bx,t);return i.jsx(LG,{scope:t,forceMount:n,children:i.jsx(Ya,{present:n||s.open,children:i.jsx(zd,{asChild:!0,container:a,children:r})})})};CO.displayName=bx;var Ia="MenuContent",[MG,yx]=rl(Ia),AO=E.forwardRef((e,t)=>{const n=kO(Ia,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,s=al(Ia,e.__scopeMenu),l=Yd(Ia,e.__scopeMenu);return i.jsx(yd.Provider,{scope:e.__scopeMenu,children:i.jsx(Ya,{present:r||s.open,children:i.jsx(yd.Slot,{scope:e.__scopeMenu,children:l.modal?i.jsx(PG,{...a,ref:t}):i.jsx(FG,{...a,ref:t})})})})}),PG=E.forwardRef((e,t)=>{const n=al(Ia,e.__scopeMenu),r=E.useRef(null),a=Ht(t,r);return E.useEffect(()=>{const s=r.current;if(s)return hx(s)},[]),i.jsx(Ex,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:$e(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),FG=E.forwardRef((e,t)=>{const n=al(Ia,e.__scopeMenu);return i.jsx(Ex,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),jG=wu("MenuContent.ScrollLock"),Ex=E.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:s,onCloseAutoFocus:l,disableOutsidePointerEvents:u,onEntryFocus:d,onEscapeKeyDown:p,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:y,onDismiss:b,disableOutsideScroll:v,...T}=e,w=al(Ia,n),N=Yd(Ia,n),k=Th(n),A=TO(n),_=_G(n),[I,O]=E.useState(null),R=E.useRef(null),F=Ht(t,R,w.onContentChange),z=E.useRef(0),M=E.useRef(""),Q=E.useRef(0),Y=E.useRef(null),ae=E.useRef("right"),V=E.useRef(0),G=v?Sh:E.Fragment,te=v?{as:jG,allowPinchZoom:!0}:void 0,ue=H=>{var fe,xe;const D=M.current+H,U=_().filter(ve=>!ve.disabled),Z=document.activeElement,j=(fe=U.find(ve=>ve.ref.current===Z))==null?void 0:fe.textValue,Se=U.map(ve=>ve.textValue),oe=XG(Se,D,j),pe=(xe=U.find(ve=>ve.textValue===oe))==null?void 0:xe.ref.current;(function ve(Ue){M.current=Ue,window.clearTimeout(z.current),Ue!==""&&(z.current=window.setTimeout(()=>ve(""),1e3))})(D),pe&&setTimeout(()=>pe.focus())};E.useEffect(()=>()=>window.clearTimeout(z.current),[]),sx();const q=E.useCallback(H=>{var U,Z;return ae.current===((U=Y.current)==null?void 0:U.side)&&ZG(H,(Z=Y.current)==null?void 0:Z.area)},[]);return i.jsx(MG,{scope:n,searchRef:M,onItemEnter:E.useCallback(H=>{q(H)&&H.preventDefault()},[q]),onItemLeave:E.useCallback(H=>{var D;q(H)||((D=R.current)==null||D.focus(),O(null))},[q]),onTriggerLeave:E.useCallback(H=>{q(H)&&H.preventDefault()},[q]),pointerGraceTimerRef:Q,onPointerGraceIntentChange:E.useCallback(H=>{Y.current=H},[]),children:i.jsx(G,{...te,children:i.jsx(mh,{asChild:!0,trapped:a,onMountAutoFocus:$e(s,H=>{var D;H.preventDefault(),(D=R.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:i.jsx($d,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:p,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:y,onDismiss:b,children:i.jsx(pO,{asChild:!0,...A,dir:N.dir,orientation:"vertical",loop:r,currentTabStopId:I,onCurrentTabStopIdChange:O,onEntryFocus:$e(d,H=>{N.isUsingKeyboardRef.current||H.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(iO,{role:"menu","aria-orientation":"vertical","data-state":GO(w.open),"data-radix-menu-content":"",dir:N.dir,...k,...T,ref:F,style:{outline:"none",...T.style},onKeyDown:$e(T.onKeyDown,H=>{const U=H.target.closest("[data-radix-menu-content]")===H.currentTarget,Z=H.ctrlKey||H.altKey||H.metaKey,j=H.key.length===1;U&&(H.key==="Tab"&&H.preventDefault(),!Z&&j&&ue(H.key));const Se=R.current;if(H.target!==Se||!kG.includes(H.key))return;H.preventDefault();const pe=_().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);wO.includes(H.key)&&pe.reverse(),YG(pe)}),onBlur:$e(e.onBlur,H=>{H.currentTarget.contains(H.target)||(window.clearTimeout(z.current),M.current="")}),onPointerMove:$e(e.onPointerMove,Ed(H=>{const D=H.target,U=V.current!==H.clientX;if(H.currentTarget.contains(D)&&U){const Z=H.clientX>V.current?"right":"left";ae.current=Z,V.current=H.clientX}}))})})})})})})});AO.displayName=Ia;var BG="MenuGroup",xx=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(gt.div,{role:"group",...r,ref:t})});xx.displayName=BG;var UG="MenuLabel",_O=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(gt.div,{...r,ref:t})});_O.displayName=UG;var Am="MenuItem",s_="menu.itemSelect",Nh=E.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,s=E.useRef(null),l=Yd(Am,e.__scopeMenu),u=yx(Am,e.__scopeMenu),d=Ht(t,s),p=E.useRef(!1),m=()=>{const h=s.current;if(!n&&h){const y=new CustomEvent(s_,{bubbles:!0,cancelable:!0});h.addEventListener(s_,b=>r==null?void 0:r(b),{once:!0}),tx(h,y),y.defaultPrevented?p.current=!1:l.onClose()}};return i.jsx(RO,{...a,ref:d,disabled:n,onClick:$e(e.onClick,m),onPointerDown:h=>{var y;(y=e.onPointerDown)==null||y.call(e,h),p.current=!0},onPointerUp:$e(e.onPointerUp,h=>{var y;p.current||(y=h.currentTarget)==null||y.click()}),onKeyDown:$e(e.onKeyDown,h=>{const y=u.searchRef.current!=="";n||y&&h.key===" "||zy.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Nh.displayName=Am;var RO=E.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...s}=e,l=yx(Am,n),u=TO(n),d=E.useRef(null),p=Ht(t,d),[m,h]=E.useState(!1),[y,b]=E.useState("");return E.useEffect(()=>{const v=d.current;v&&b((v.textContent??"").trim())},[s.children]),i.jsx(yd.ItemSlot,{scope:n,disabled:r,textValue:a??y,children:i.jsx(fO,{asChild:!0,...u,focusable:!r,children:i.jsx(gt.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:p,onPointerMove:$e(e.onPointerMove,Ed(v=>{r?l.onItemLeave(v):(l.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$e(e.onPointerLeave,Ed(v=>l.onItemLeave(v))),onFocus:$e(e.onFocus,()=>h(!0)),onBlur:$e(e.onBlur,()=>h(!1))})})})}),HG="MenuCheckboxItem",IO=E.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return i.jsx(PO,{scope:e.__scopeMenu,checked:n,children:i.jsx(Nh,{role:"menuitemcheckbox","aria-checked":_m(n)?"mixed":n,...a,ref:t,"data-state":wx(n),onSelect:$e(a.onSelect,()=>r==null?void 0:r(_m(n)?!0:!n),{checkForDefaultPrevented:!1})})})});IO.displayName=HG;var DO="MenuRadioGroup",[$G,zG]=rl(DO,{value:void 0,onValueChange:()=>{}}),OO=E.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,s=na(r);return i.jsx($G,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(xx,{...a,ref:t})})});OO.displayName=DO;var LO="MenuRadioItem",MO=E.forwardRef((e,t)=>{const{value:n,...r}=e,a=zG(LO,e.__scopeMenu),s=n===a.value;return i.jsx(PO,{scope:e.__scopeMenu,checked:s,children:i.jsx(Nh,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wx(s),onSelect:$e(r.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,n)},{checkForDefaultPrevented:!1})})})});MO.displayName=LO;var vx="MenuItemIndicator",[PO,GG]=rl(vx,{checked:!1}),FO=E.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,s=GG(vx,n);return i.jsx(Ya,{present:r||_m(s.checked)||s.checked===!0,children:i.jsx(gt.span,{...a,ref:t,"data-state":wx(s.checked)})})});FO.displayName=vx;var VG="MenuSeparator",jO=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(gt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});jO.displayName=VG;var WG="MenuArrow",BO=E.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Th(n);return i.jsx(sO,{...a,...r,ref:t})});BO.displayName=WG;var qG="MenuSub",[Rue,UO]=rl(qG),Wc="MenuSubTrigger",HO=E.forwardRef((e,t)=>{const n=al(Wc,e.__scopeMenu),r=Yd(Wc,e.__scopeMenu),a=UO(Wc,e.__scopeMenu),s=yx(Wc,e.__scopeMenu),l=E.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:d}=s,p={__scopeMenu:e.__scopeMenu},m=E.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return E.useEffect(()=>m,[m]),E.useEffect(()=>{const h=u.current;return()=>{window.clearTimeout(h),d(null)}},[u,d]),i.jsx(gx,{asChild:!0,...p,children:i.jsx(RO,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":GO(n.open),...e,ref:Hd(t,a.onTriggerChange),onClick:h=>{var y;(y=e.onClick)==null||y.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:$e(e.onPointerMove,Ed(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(s.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:$e(e.onPointerLeave,Ed(h=>{var b,v;m();const y=(b=n.content)==null?void 0:b.getBoundingClientRect();if(y){const T=(v=n.content)==null?void 0:v.dataset.side,w=T==="right",N=w?-5:5,k=y[w?"left":"right"],A=y[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+N,y:h.clientY},{x:k,y:y.top},{x:A,y:y.top},{x:A,y:y.bottom},{x:k,y:y.bottom}],side:T}),window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:$e(e.onKeyDown,h=>{var b;const y=s.searchRef.current!=="";e.disabled||y&&h.key===" "||CG[r.dir].includes(h.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),h.preventDefault())})})})});HO.displayName=Wc;var $O="MenuSubContent",zO=E.forwardRef((e,t)=>{const n=kO(Ia,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,s=al(Ia,e.__scopeMenu),l=Yd(Ia,e.__scopeMenu),u=UO($O,e.__scopeMenu),d=E.useRef(null),p=Ht(t,d);return i.jsx(yd.Provider,{scope:e.__scopeMenu,children:i.jsx(Ya,{present:r||s.open,children:i.jsx(yd.Slot,{scope:e.__scopeMenu,children:i.jsx(Ex,{id:u.contentId,"aria-labelledby":u.triggerId,...a,ref:p,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var h;l.isUsingKeyboardRef.current&&((h=d.current)==null||h.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:$e(e.onFocusOutside,m=>{m.target!==u.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:$e(e.onEscapeKeyDown,m=>{l.onClose(),m.preventDefault()}),onKeyDown:$e(e.onKeyDown,m=>{var b;const h=m.currentTarget.contains(m.target),y=AG[l.dir].includes(m.key);h&&y&&(s.onOpenChange(!1),(b=u.trigger)==null||b.focus(),m.preventDefault())})})})})})});zO.displayName=$O;function GO(e){return e?"open":"closed"}function _m(e){return e==="indeterminate"}function wx(e){return _m(e)?"indeterminate":e?"checked":"unchecked"}function YG(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function KG(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function XG(e,t,n){const a=t.length>1&&Array.from(t).every(p=>p===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=KG(e,Math.max(s,0));a.length===1&&(l=l.filter(p=>p!==n));const d=l.find(p=>p.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function QG(e,t){const{x:n,y:r}=e;let a=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const u=t[s],d=t[l],p=u.x,m=u.y,h=d.x,y=d.y;m>r!=y>r&&n<(h-p)*(r-m)/(y-m)+p&&(a=!a)}return a}function ZG(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return QG(n,t)}function Ed(e){return t=>t.pointerType==="mouse"?e(t):void 0}var JG=NO,eV=gx,tV=CO,nV=AO,rV=xx,aV=_O,iV=Nh,sV=IO,oV=OO,lV=MO,uV=FO,cV=jO,dV=BO,pV=HO,fV=zO,kh="DropdownMenu",[mV]=ha(kh,[SO]),zr=SO(),[hV,VO]=mV(kh),WO=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:s,onOpenChange:l,modal:u=!0}=e,d=zr(t),p=E.useRef(null),[m,h]=Qi({prop:a,defaultProp:s??!1,onChange:l,caller:kh});return i.jsx(hV,{scope:t,triggerId:Yi(),triggerRef:p,contentId:Yi(),open:m,onOpenChange:h,onOpenToggle:E.useCallback(()=>h(y=>!y),[h]),modal:u,children:i.jsx(JG,{...d,open:m,onOpenChange:h,dir:r,modal:u,children:n})})};WO.displayName=kh;var qO="DropdownMenuTrigger",YO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,s=VO(qO,n),l=zr(n);return i.jsx(eV,{asChild:!0,...l,children:i.jsx(gt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Hd(t,s.triggerRef),onPointerDown:$e(e.onPointerDown,u=>{!r&&u.button===0&&u.ctrlKey===!1&&(s.onOpenToggle(),s.open||u.preventDefault())}),onKeyDown:$e(e.onKeyDown,u=>{r||(["Enter"," "].includes(u.key)&&s.onOpenToggle(),u.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});YO.displayName=qO;var gV="DropdownMenuPortal",KO=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zr(t);return i.jsx(tV,{...r,...n})};KO.displayName=gV;var XO="DropdownMenuContent",QO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=VO(XO,n),s=zr(n),l=E.useRef(!1);return i.jsx(nV,{id:a.contentId,"aria-labelledby":a.triggerId,...s,...r,ref:t,onCloseAutoFocus:$e(e.onCloseAutoFocus,u=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,u.preventDefault()}),onInteractOutside:$e(e.onInteractOutside,u=>{const d=u.detail.originalEvent,p=d.button===0&&d.ctrlKey===!0,m=d.button===2||p;(!a.modal||m)&&(l.current=!0)}),style:{...e.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)"}})});QO.displayName=XO;var bV="DropdownMenuGroup",yV=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(rV,{...a,...r,ref:t})});yV.displayName=bV;var EV="DropdownMenuLabel",ZO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(aV,{...a,...r,ref:t})});ZO.displayName=EV;var xV="DropdownMenuItem",JO=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(iV,{...a,...r,ref:t})});JO.displayName=xV;var vV="DropdownMenuCheckboxItem",eL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(sV,{...a,...r,ref:t})});eL.displayName=vV;var wV="DropdownMenuRadioGroup",SV=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(oV,{...a,...r,ref:t})});SV.displayName=wV;var TV="DropdownMenuRadioItem",tL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(lV,{...a,...r,ref:t})});tL.displayName=TV;var NV="DropdownMenuItemIndicator",nL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(uV,{...a,...r,ref:t})});nL.displayName=NV;var kV="DropdownMenuSeparator",rL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(cV,{...a,...r,ref:t})});rL.displayName=kV;var CV="DropdownMenuArrow",AV=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(dV,{...a,...r,ref:t})});AV.displayName=CV;var _V="DropdownMenuSubTrigger",aL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(pV,{...a,...r,ref:t})});aL.displayName=_V;var RV="DropdownMenuSubContent",iL=E.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=zr(n);return i.jsx(fV,{...a,...r,ref:t,style:{...e.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)"}})});iL.displayName=RV;var IV=WO,DV=YO,OV=KO,sL=QO,oL=ZO,lL=JO,uL=eL,cL=tL,dL=nL,pL=rL,fL=aL,mL=iL;const jn=IV,Bn=DV,LV=E.forwardRef(({className:e,inset:t,children:n,...r},a)=>i.jsxs(fL,{ref:a,className:Ee("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",t&&"pl-8",e),...r,children:[n,i.jsx(nl,{className:"ml-auto"})]}));LV.displayName=fL.displayName;const MV=E.forwardRef(({className:e,...t},n)=>i.jsx(mL,{ref:n,className:Ee("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",e),...t}));MV.displayName=mL.displayName;const In=E.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(OV,{children:i.jsx(sL,{ref:r,sideOffset:t,className:Ee("z-50 min-w-[8rem] overflow-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",e),...n})}));In.displayName=sL.displayName;const ct=E.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(lL,{ref:r,className:Ee("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",t&&"pl-8",e),...n}));ct.displayName=lL.displayName;const PV=E.forwardRef(({className:e,children:t,checked:n,...r},a)=>i.jsxs(uL,{ref:a,className:Ee("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",e),checked:n,...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(dL,{children:i.jsx(Nn,{className:"h-4 w-4"})})}),t]}));PV.displayName=uL.displayName;const FV=E.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(cL,{ref:r,className:Ee("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",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(dL,{children:i.jsx(jB,{className:"h-2 w-2 fill-current"})})}),t]}));FV.displayName=cL.displayName;const Xc=E.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(oL,{ref:r,className:Ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Xc.displayName=oL.displayName;const sr=E.forwardRef(({className:e,...t},n)=>i.jsx(pL,{ref:n,className:Ee("-mx-1 my-1 h-px bg-muted",e),...t}));sr.displayName=pL.displayName;function jV(){const{data:e,isLoading:t}=vI();return!t&&e&&!e.loggedIn?i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"max-w-md space-y-4 rounded-lg border bg-card p-8 text-center",children:[i.jsx(xI,{className:"mx-auto h-8 w-8 text-muted-foreground"}),i.jsx("h1",{className:"text-lg font-semibold",children:"You're not logged into SuperClawd"}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:["Run"," ",i.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5",children:"superclawd login"})," ","in your terminal, then reload."]}),i.jsx(re,{onClick:()=>window.location.reload(),children:"Reload"})]})}):i.jsxs(l9,{children:[i.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground",children:[i.jsx(BV,{}),i.jsx("main",{className:"min-h-0 flex-1 overflow-auto",children:i.jsx(nI,{})})]}),i.jsx(t$,{})]})}function BV(){var r;const{data:e}=rh(),{data:t}=vI(),n=(e??[]).some(a=>a.linkStatus==="unlinked"||a.authStatus!=="connected");return i.jsxs("header",{className:"flex h-16 shrink-0 items-center gap-3 border-b bg-card/60 px-4",children:[i.jsxs("a",{href:"https://superclawd.com",target:"_blank",rel:"noopener noreferrer",title:"superclawd.com",className:"flex shrink-0 items-center gap-2 rounded transition-opacity hover:opacity-80",children:[i.jsx(xI,{className:"h-5 w-5 text-primary"}),i.jsxs("div",{className:"text-sm font-semibold leading-none",children:["SuperClawd"," ",i.jsx("span",{className:"font-normal text-muted-foreground",children:"Pipelines"})]})]}),i.jsx("div",{className:"mx-1 h-6 w-px shrink-0 bg-border"}),i.jsx(UV,{}),i.jsxs("nav",{className:"ml-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[i.jsx(Lc,{to:"/board",match:["/board","/tickets"],icon:i.jsx(mI,{className:"h-4 w-4"}),label:"Boards"}),i.jsx(Lc,{to:"/batches",match:["/batches"],icon:i.jsx(Ks,{className:"h-4 w-4"}),label:"Batches"}),i.jsx(Lc,{to:"/schedules",match:["/schedules"],icon:i.jsx(hd,{className:"h-4 w-4"}),label:"Schedules"}),i.jsx(Lc,{to:"/chat",match:["/chat"],icon:i.jsx(Iy,{className:"h-4 w-4"}),label:"Conversations"}),i.jsx(Lc,{to:"/docs",match:["/docs"],icon:i.jsx(Ry,{className:"h-4 w-4"}),label:"Docs"})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-3.5",children:[((r=t==null?void 0:t.account)==null?void 0:r.email)&&i.jsx("span",{className:"hidden max-w-[180px] truncate text-xs text-muted-foreground xl:inline",children:t.account.email}),i.jsxs(ji,{to:"/settings",title:"Settings",className:({isActive:a})=>Ee("relative flex h-9 w-9 items-center justify-center rounded-md border border-border/60 transition-colors",a?"bg-accent text-foreground":"text-foreground/70 hover:bg-accent/50 hover:text-foreground"),children:[i.jsx(bI,{className:"h-[18px] w-[18px]"}),n&&i.jsx("span",{title:"A connection needs attention",className:"absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-amber-400 ring-2 ring-card"})]})]})]})}function UV(){const{workspaces:e,active:t,setActiveId:n}=eo(),r=zn();return e.length===0?i.jsxs(re,{variant:"ghost",size:"sm",className:"h-9 shrink-0 gap-2 px-2 font-medium text-muted-foreground",onClick:()=>r("/settings/workspaces"),children:[i.jsx(Hr,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:"Connect a workspace"})]}):i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsxs(re,{variant:"ghost",size:"sm",className:"h-9 shrink-0 gap-2 px-2 font-medium",children:[i.jsx("span",{className:"max-w-[120px] truncate sm:max-w-[180px]",children:(t==null?void 0:t.name)??"Workspace"}),i.jsx(dI,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),i.jsxs(In,{align:"start",className:"w-56",children:[e.map(a=>i.jsxs(ct,{onSelect:()=>n(a.id),className:"gap-2",children:[i.jsx(Nn,{className:Ee("h-4 w-4",a.id===(t==null?void 0:t.id)?"opacity-100":"opacity-0")}),i.jsx("span",{className:"flex-1 truncate",children:a.name}),i.jsx("span",{className:Ee("rounded px-1.5 py-0.5 text-[10px] font-medium text-white",a.tier==="paid"?"bg-purple-600":"bg-green-600"),children:a.tier==="paid"?"Paid":"Free"})]},a.id)),i.jsx(sr,{}),i.jsxs(ct,{onSelect:()=>r("/settings/workspaces"),className:"gap-2 text-muted-foreground",children:[i.jsx(bI,{className:"h-4 w-4"}),"Manage workspaces"]})]})]})}function Lc({to:e,match:t,icon:n,label:r}){const{pathname:a}=Ei(),s=t.some(l=>a===l||a.startsWith(`${l}/`));return i.jsxs(Ar,{to:e,title:r,className:Ee("flex shrink-0 items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors",s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[n,i.jsx("span",{className:"hidden lg:inline",children:r})]})}function HV(e,t=300){const[n,r]=E.useState(e);return E.useEffect(()=>{const a=setTimeout(()=>r(e),t);return()=>clearTimeout(a)},[e,t]),n}function hL(e){switch(e){case"running":return{label:"Running",className:"border-sky-500/40 bg-sky-500/15 text-sky-300"};case"queued":return{label:"Queued",className:"border-border bg-muted text-muted-foreground"};case"paused":return{label:"Paused",className:"border-amber-500/40 bg-amber-500/15 text-amber-300"};case"done":return{label:"Done",className:"border-green-500/40 bg-green-500/15 text-green-300"};default:return{label:"Idle",className:"border-border bg-muted text-muted-foreground"}}}function xd(e){switch(e){case"linear":return{label:"Linear",className:"bg-indigo-500/15 text-indigo-300 border-indigo-500/30"};case"jira":return{label:"Jira",className:"bg-blue-500/15 text-blue-300 border-blue-500/30"};case"asana":return{label:"Asana",className:"bg-rose-500/15 text-rose-300 border-rose-500/30"};case"clickup":return{label:"ClickUp",className:"bg-violet-500/15 text-violet-300 border-violet-500/30"};case"monday":return{label:"Monday",className:"bg-red-500/15 text-red-300 border-red-500/30"};case"local":return{label:"Local",className:"bg-muted text-muted-foreground border-border"}}}function Sx(e){return e!=="asana"&&e!=="monday"}function $V(e){switch(e){case"linear":case"jira":return{labels:!0,assignee:!0};case"asana":return{labels:!1,assignee:!0};case"clickup":return{labels:!0,assignee:!1};default:return{labels:!1,assignee:!1}}}function zV(e){return e!=="asana"}function gL(e,t,n){return e==="team"?`Team: ${t??"—"}`:e==="agent"?`Agent: ${n??"—"}`:"Anyone"}function Gy(e){if(!e)return"—";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=t-Date.now(),r=n<0,a=Math.round(Math.abs(n)/1e3),s=Math.round(a/60),l=Math.round(s/60),u=Math.round(l/24),d=a<60?`${a}s`:s<60?`${s}m`:l<24?`${l}h`:`${u}d`;return r?`${d} ago`:`in ${d}`}function GV(e){return{linear:"bg-indigo-400",jira:"bg-blue-400",asana:"bg-rose-400",clickup:"bg-violet-400",monday:"bg-red-400",local:"bg-muted-foreground/50"}[e]}function Vy(e){return e==null||e===0?null:["","Urgent","High","Medium","Low"][e]??null}const Qc=[{column:"backlog",label:"Backlog"},{column:"in_progress",label:"In Progress"},{column:"needs_input",label:"Blocked"},{column:"in_review",label:"In Review"},{column:"done",label:"Done"}];function VV(e){const t={backlog:{label:"Backlog",className:"bg-muted text-muted-foreground border-border"},in_progress:{label:"In Progress",className:"bg-blue-500/15 text-blue-300 border-blue-500/40"},needs_input:{label:"Blocked",className:"bg-red-500/15 text-red-300 border-red-500/40"},in_review:{label:"In Review",className:"bg-amber-500/15 text-amber-300 border-amber-500/40"},done:{label:"Done",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/40"}};return t[e]??t.backlog}function bL(e,t){const n={not_started:{label:"Not started",className:"bg-muted text-muted-foreground border-border"},running:{label:"Running",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},paused:{label:"Paused",className:"bg-muted text-muted-foreground border-border"},blocked:{label:"Needs input",className:"bg-amber-500/15 text-amber-300 border-amber-500/30"},stopped:{label:"Stopped",className:"bg-muted text-muted-foreground border-border"}};return e==="stopped"&&t==="completed"?{label:"Completed",className:"bg-sky-500/15 text-sky-300 border-sky-500/30"}:e==="stopped"&&t==="error"?{label:"Failed",className:"bg-red-500/15 text-red-300 border-red-500/30"}:n[e]}const Cn=E.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:Ee("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Cn.displayName="Input";var Ch="Dialog",[yL,EL]=ha(Ch),[WV,Ka]=yL(Ch),xL=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:s,modal:l=!0}=e,u=E.useRef(null),d=E.useRef(null),[p,m]=Qi({prop:r,defaultProp:a??!1,onChange:s,caller:Ch});return i.jsx(WV,{scope:t,triggerRef:u,contentRef:d,contentId:Yi(),titleId:Yi(),descriptionId:Yi(),open:p,onOpenChange:m,onOpenToggle:E.useCallback(()=>m(h=>!h),[m]),modal:l,children:n})};xL.displayName=Ch;var vL="DialogTrigger",wL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(vL,n),s=Ht(t,a.triggerRef);return i.jsx(gt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":kx(a.open),...r,ref:s,onClick:$e(e.onClick,a.onOpenToggle)})});wL.displayName=vL;var Tx="DialogPortal",[qV,SL]=yL(Tx,{forceMount:void 0}),TL=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,s=Ka(Tx,t);return i.jsx(qV,{scope:t,forceMount:n,children:E.Children.map(r,l=>i.jsx(Ya,{present:n||s.open,children:i.jsx(zd,{asChild:!0,container:a,children:l})}))})};TL.displayName=Tx;var Rm="DialogOverlay",NL=E.forwardRef((e,t)=>{const n=SL(Rm,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,s=Ka(Rm,e.__scopeDialog);return s.modal?i.jsx(Ya,{present:r||s.open,children:i.jsx(KV,{...a,ref:t})}):null});NL.displayName=Rm;var YV=wu("DialogOverlay.RemoveScroll"),KV=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(Rm,n);return i.jsx(Sh,{as:YV,allowPinchZoom:!0,shards:[a.contentRef],children:i.jsx(gt.div,{"data-state":kx(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Vo="DialogContent",kL=E.forwardRef((e,t)=>{const n=SL(Vo,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,s=Ka(Vo,e.__scopeDialog);return i.jsx(Ya,{present:r||s.open,children:s.modal?i.jsx(XV,{...a,ref:t}):i.jsx(QV,{...a,ref:t})})});kL.displayName=Vo;var XV=E.forwardRef((e,t)=>{const n=Ka(Vo,e.__scopeDialog),r=E.useRef(null),a=Ht(t,n.contentRef,r);return E.useEffect(()=>{const s=r.current;if(s)return hx(s)},[]),i.jsx(CL,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:$e(e.onCloseAutoFocus,s=>{var l;s.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:$e(e.onPointerDownOutside,s=>{const l=s.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0;(l.button===2||u)&&s.preventDefault()}),onFocusOutside:$e(e.onFocusOutside,s=>s.preventDefault())})}),QV=E.forwardRef((e,t)=>{const n=Ka(Vo,e.__scopeDialog),r=E.useRef(!1),a=E.useRef(!1);return i.jsx(CL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,u;(l=e.onCloseAutoFocus)==null||l.call(e,s),s.defaultPrevented||(r.current||(u=n.triggerRef.current)==null||u.focus(),s.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:s=>{var d,p;(d=e.onInteractOutside)==null||d.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((p=n.triggerRef.current)==null?void 0:p.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})}),CL=E.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:s,...l}=e,u=Ka(Vo,n),d=E.useRef(null),p=Ht(t,d);return sx(),i.jsxs(i.Fragment,{children:[i.jsx(mh,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:s,children:i.jsx($d,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":kx(u.open),...l,ref:p,onDismiss:()=>u.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(JV,{titleId:u.titleId}),i.jsx(tW,{contentRef:d,descriptionId:u.descriptionId})]})]})}),Nx="DialogTitle",AL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(Nx,n);return i.jsx(gt.h2,{id:a.titleId,...r,ref:t})});AL.displayName=Nx;var _L="DialogDescription",RL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(_L,n);return i.jsx(gt.p,{id:a.descriptionId,...r,ref:t})});RL.displayName=_L;var IL="DialogClose",DL=E.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ka(IL,n);return i.jsx(gt.button,{type:"button",...r,ref:t,onClick:$e(e.onClick,()=>a.onOpenChange(!1))})});DL.displayName=IL;function kx(e){return e?"open":"closed"}var OL="DialogTitleWarning",[ZV,LL]=uH(OL,{contentName:Vo,titleName:Nx,docsSlug:"dialog"}),JV=({titleId:e})=>{const t=LL(OL),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
468
468
 
469
469
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
470
470
 
@@ -608,7 +608,7 @@ Other commands:
608
608
  | --- | --- |
609
609
  | \`superclawd pipelines status\` | Show whether the daemon is running (pid, port) |
610
610
  | \`superclawd pipelines stop\` | Stop the running daemon |
611
- | \`superclawd pipelines update\` | Update the CLI (stop the daemon first) |
611
+ | \`superclawd pipelines update\` | Update the Pipelines app to the latest published version (stop the daemon first) |
612
612
 
613
613
  Only one instance runs at a time. Running \`start\` again while it's already up just re-opens your browser at the existing URL.
614
614
 
@@ -843,7 +843,78 @@ An opt-in loop that watches a ticket's PR after it reaches **In Review** — aut
843
843
  - **Merged or closed** → disarm.
844
844
  - **Engagement cap** — default 5 agent passes. At the cap with CI still red, it disarms and flags for a human.
845
845
  - It **never moves the card to Done** — that's always your call. While armed, it owns the session, so manual **Respond** is blocked; disarm to chat.
846
- `,eue=`# Schedules
846
+ `,eue=`# Batches
847
+
848
+ A batch is a set of already-assigned tickets you press play on once and let run **unattended** — the overnight button. Pipelines starts each ticket's run for you, and as one finishes it starts whatever that unblocks, walking the set in dependency order until everything lands in **In Review**. If any ticket fails or gets blocked, the whole batch pauses and waits for you.
849
+
850
+ Batches are for "I've triaged and assigned tonight's work — go." Everything a batch runs is worktree-isolated and stops at In Review; nothing is auto-merged or auto-Done.
851
+
852
+ ## Creating a batch
853
+
854
+ On a board, click **Select**, tick the tickets you want to run together, then **Create batch**. Only **assigned** tickets can be batched — a batch reuses each ticket's existing delegate, model, and effort, so there are no extra pickers.
855
+
856
+ If you select a ticket that **depends on** others, Pipelines offers to pull its whole dependency tree into the batch. Take it: a batch needs its blockers as members, or it will stall (see *Dependencies* below).
857
+
858
+ In the create dialog you set:
859
+
860
+ - **When a member finishes** — how the batch advances (below).
861
+ - **Stack dependent work** — whether a dependent ticket's branch/PR builds on its blocker's (below).
862
+ - **Cap total runs** *(optional)* — pause the batch once it's started this many runs, as an overnight cost guard.
863
+
864
+ ## Ordered vs. unordered
865
+
866
+ The order is **derived from the tickets' own dependencies** — you don't arrange it by hand.
867
+
868
+ - If no member depends on another, the batch is **unordered** and members run in parallel (up to your concurrency limit).
869
+ - If some members depend on others, the batch is **ordered** and each dependent waits for its blockers.
870
+
871
+ ## How advancing works
872
+
873
+ Members always run **autonomous** (overnight = nobody's watching), overriding how each ticket was assigned. What counts as a blocker being "done enough" to start the next ticket depends on the batch's advance mode:
874
+
875
+ - **Keep going automatically** *(default)* — a member reaching **In Review** unblocks its dependents. The whole batch runs hands-off.
876
+ - **Wait for me to approve** — dependents only start once their blocker is moved to **Done** (which only you can do), so you approve each stage.
877
+
878
+ ## Dependencies
879
+
880
+ A batch respects the full dependency tree at runtime — a dependent never starts until its blockers are satisfied.
881
+
882
+ One thing to know: a blocker that **isn't a member of the batch** only counts as satisfied when it's manually **Done**. So if you batch a dependent without its blocker, that ticket can't run on its own — Pipelines **pauses the batch** and tells you what it's waiting on rather than quietly skipping it. That's why the create flow offers to pull the whole tree in.
883
+
884
+ ### Stacked work
885
+
886
+ For an ordered batch with **Stack dependent work** on, a dependent ticket's worktree branches off its blocker's branch (not \`main\`) per shared repo — so the second ticket builds on the first's committed code and its PR stacks on the first's PR. If two blockers change the same repo, Pipelines can't pick a single base and asks you to chain them instead.
887
+
888
+ ## One at a time
889
+
890
+ Only **one batch runs at a time**. Press play on another while one is active and it **queues**; it starts automatically when the running batch finishes (or pauses, which frees the slot so an overnight queue keeps draining). A ticket can only be in one active batch at a time.
891
+
892
+ ## When a batch pauses
893
+
894
+ A batch pauses — and stops starting new members, though in-flight runs finish — when:
895
+
896
+ - a member **fails** or **blocks itself** (needs your input),
897
+ - a member is stuck on a dependency the batch can't satisfy, or
898
+ - it hits its run cap.
899
+
900
+ Resolve the cause (answer the block, fix the failure, add the missing blocker) and press **Resume** to pick up where it left off.
901
+
902
+ ## Watching it run
903
+
904
+ Running batches are easy to spot: on the board, a ticket in a running batch **glows blue** — the one actually executing has a light chasing around its border, and the ones queued behind it breathe softly. The **Batches** page lists every batch with its status (Idle / Queued / Running / Paused / Done); open one to see each member's live state and what any waiting ticket is blocked on.
905
+
906
+ ## Controls
907
+
908
+ - **Play** — start (or resume) the batch.
909
+ - **Pause** — stop starting new members; in-flight runs finish.
910
+ - **Stop** — halt the batch and kill its running members; resets it so you can play it again.
911
+
912
+ Deleting a ticket from the board removes it from any batch automatically (and a batch left with no tickets is removed).
913
+
914
+ ## API, MCP & webhooks
915
+
916
+ Batches are fully scriptable — create/start/pause/stop/list/get over the public API (\`/v1/batches\`) and the same via MCP tools — and Pipelines emits \`batch.started\`, \`batch.completed\`, \`batch.paused\`, and \`batch.ticket_blocked\` webhooks. See **API, webhooks & MCP**.
917
+ `,tue=`# Schedules
847
918
 
848
919
  A schedule is a saved prompt that runs automatically on a cadence, under a workspace with an optional team or agent delegate. Use them for recurring, hands-off work: a daily triage sweep, a weekly dependency audit, an hourly health check that files tickets when something looks off.
849
920
 
@@ -879,7 +950,7 @@ If a scheduled run decides a code change is warranted, it's instructed to **crea
879
950
  ## Model & effort
880
951
 
881
952
  Same as board runs: the schedule's own model and effort, else your Settings defaults, else **opus / high**. The values used are stamped onto each firing.
882
- `,tue=`# Connections
953
+ `,nue=`# Connections
883
954
 
884
955
  A **connection** links one project-management tool to one SuperClawd workspace, and surfaces as a **board**. You can connect several tools at once — up to **3 vendor connections per workspace** (the built-in Local board doesn't count).
885
956
 
@@ -936,7 +1007,7 @@ This distinction matters:
936
1007
  Local boards can't be unlinked or disconnected — only renamed.
937
1008
 
938
1009
  > **Heads up:** with no connected workspace, you can't add connections, and existing boards and scheduled runs are paused until you connect one.
939
- `,nue=`# Conversations
1010
+ `,rue=`# Conversations
940
1011
 
941
1012
  A **conversation** is an interactive chat with Claude inside a workspace — not tied to any ticket. It carries the same runtime as a run: your workspace's team, guardrails, and memory injection. Use it for quick questions, exploration, or one-off tasks that don't belong on the board.
942
1013
 
@@ -966,7 +1037,7 @@ All three are editable live.
966
1037
  ## Managing conversations
967
1038
 
968
1039
  The list supports **search** and **pagination**, plus per-conversation **star**, **rename**, **AI summarize**, **regenerate title**, and **delete**. The composer accepts **file attachments** — drag, drop, or paste images and PDFs.
969
- `,rue=`# Settings & data
1040
+ `,aue=`# Settings & data
970
1041
 
971
1042
  Settings lives behind the gear icon. It holds your run defaults, connected tools, and local data controls: **General · Workspaces · Presets · Connections · API · Webhooks**.
972
1043
 
@@ -1015,4 +1086,4 @@ Live sessions, run history, and conversations aren't included in a snapshot —
1015
1086
 
1016
1087
  - **Reset local database** — wipes all tickets, runs, schedules, and tool connections, keeping only your connected workspaces and their Local boards. Can't be undone.
1017
1088
  - **Clear uploaded files** — permanently deletes every file attached in chats and prompts (images, PDFs, etc.). Previews stop loading and the assistant can't re-read them; the tickets and messages themselves stay. The dialog shows the count and total size.
1018
- `,aue="# API, webhooks & MCP\n\nPipelines can talk to the outside world three ways: a **public HTTP API** you call to drive the board, **webhooks** that push events to you, and an **MCP server** that lets Claude Code drive your board from a session. The API and webhooks are off by default and configured in Settings; the MCP server runs with the daemon.\n\n## Public API\n\nA key-authenticated HTTP API for board, ticket, and run actions. It runs on its **own port** (default **63211**), separate from the Pipelines UI, and only starts when you enable it in **Settings → API**.\n\n### Authentication\n\nGenerate a key in the API tab. The key is shown **once** — copy it then; only a SHA-256 hash and the last four characters are stored, so it can't be recovered later. You can refresh (rotate) or revoke it anytime.\n\nSend it as a bearer token:\n\n```bash\ncurl -H \"Authorization: Bearer <your-key>\" \\\n http://localhost:63211/v1/boards\n```\n\nThe API tab shows your exact base URL and a ready-to-copy curl example.\n\n### Endpoints\n\nAll routes live under `/v1`:\n\n| Method | Path | Purpose |\n| --- | --- | --- |\n| `GET` | `/v1/boards` | List boards |\n| `GET` | `/v1/boards/:id/tickets` | List a board's tickets |\n| `POST` | `/v1/boards/:id/tickets` | Create a ticket on a Local board |\n| `GET` | `/v1/tickets/:id` | Get one ticket |\n| `PATCH` | `/v1/tickets/:id` | Update ticket fields |\n| `POST` | `/v1/tickets/:id/move` | Move a ticket between lanes |\n| `POST` | `/v1/tickets/:id/unblock` | Unblock a ticket |\n| `GET` / `POST` | `/v1/tickets/:id/notes` | List / add notes |\n| `PATCH` / `DELETE` | `/v1/notes/:id` | Edit / delete a note |\n| `GET` / `POST` | `/v1/tickets/:id/questions` | List / add open questions |\n| `PATCH` / `DELETE` | `/v1/questions/:id` | Update / delete a question |\n| `GET` | `/v1/tickets/:id/run` | Get a ticket's run state |\n| `POST` | `/v1/tickets/:id/run/:action` | Drive a run (start, pause, resume, stop, …) |\n\n### Interactive reference\n\nThe API self-hosts an OpenAPI 3.1 spec and an interactive reference:\n\n- **`/openapi.json`** — the raw spec.\n- **`/docs`** — a browsable API reference on the public API's port (e.g. `http://localhost:63211/docs`).\n\nThere's also an **API reference** button in the API tab that opens it.\n\n## Webhooks\n\nPush ticket, run, and schedule events to an endpoint you own. Enable webhooks in **Settings → Webhooks** and set a destination URL.\n\n### Signing\n\nEvery request is signed. Pipelines sends an HMAC-SHA256 signature over the raw body in the **`X-SuperClawd-Signature`** header, formatted `sha256=<hex>`, using your **signing secret** (rotatable in the tab). Verify it on your end to confirm the request really came from your Pipelines. Fixed headers on every delivery: `X-SuperClawd-Event` (the event name), a JSON content type, and a Pipelines user agent.\n\n### Custom headers\n\nAdd up to **4** custom headers (e.g. an `Authorization` header for your receiver) — stored encrypted at rest. A blocked-list prevents overriding the reserved headers (like the signature).\n\n### Events\n\nSubscribe to any of:\n\n- **Tickets** — `ticket.moved`, `ticket.blocked`, `ticket.unblocked`, `ticket.updated`\n- **Runs** — `run.started`, `run.paused`, `run.resumed`, `run.completed`, `run.failed`, `run.stopped`\n- **Schedules** — `schedule.run.started`, `schedule.run.completed`, `schedule.run.failed`\n\nDeliveries are fire-and-forget with retries, filtered to your subscribed events. Use **Send test** to fire a sample payload at your endpoint and confirm the wiring.\n\n## MCP\n\nThe MCP server is the agent-native twin of the HTTP API — the same board/ticket/run actions, exposed as tools for **Claude Code** so you can drive Pipelines from a session (*\"what's blocked?\"*, *\"plan ENG-123 and start it\"*, *\"file a ticket for this\"*).\n\n- **Transport** — Streamable HTTP, served by the daemon at **`/mcp`** on the main port, so it's available whenever Pipelines is running.\n- **Zero-config in the CLI** — turn on **Pipelines MCP** in `superclawd config`. When the daemon is running, the CLI auto-injects the server into your session using a machine-local token — nothing to paste. If Pipelines isn't running it shows up as a *failed* MCP server, which is your cue to start it.\n- **Remote / programmatic** — the same endpoint also accepts a public API key as a Bearer token (handy if the daemon is ever exposed beyond localhost).\n\nThe tools cover the ticket lifecycle: `list_boards`, `list_tickets`, `get_ticket`, `create_ticket`, `update_ticket`, `move_ticket`, `set_plan`, `set_conclusion`, notes (add / list / edit / delete), `block_ticket` / `unblock_ticket`, questions (add / list / update / delete), and runs (`start` / `pause` / `resume` / `stop` / status).\n",iue=Object.assign({"../docs/01-getting-started.md":Xle,"../docs/02-how-it-works.md":Qle,"../docs/03-boards-and-tickets.md":Zle,"../docs/04-runs.md":Jle,"../docs/05-schedules.md":eue,"../docs/06-connections.md":tue,"../docs/07-conversations.md":nue,"../docs/08-settings.md":rue,"../docs/09-api-and-webhooks.md":aue}),uy=Object.entries(iue).map(([e,t])=>{var u;const n=(e.split("/").pop()??"").replace(/\.md$/,""),r=/^(\d+)-(.+)$/.exec(n),a=r?Number(r[1]):999,s=r?r[2]:n,l=(((u=/^#\s+(.+)$/m.exec(t))==null?void 0:u[1])??s.replace(/-/g," ")).trim();return{slug:s,title:l,order:a,body:t}}).sort((e,t)=>e.order-t.order);function cR(){const{slug:e}=Ru(),t=uy.find(n=>n.slug===e)??uy[0];return i.jsxs("div",{className:"mx-auto flex max-w-6xl gap-8 p-6",children:[i.jsxs("aside",{className:"w-56 shrink-0",children:[i.jsx("h1",{className:"mb-1 text-2xl font-bold tracking-tight",children:"Docs"}),i.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"How SuperClawd Pipelines works."}),i.jsx("nav",{className:"sticky top-6 space-y-1",children:uy.map(n=>i.jsx(ji,{to:`/docs/${n.slug}`,className:Ee("block rounded-md px-3 py-1.5 text-sm transition-colors",n.slug===(t==null?void 0:t.slug)?"bg-accent font-medium text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:n.title},n.slug))})]}),i.jsx("div",{className:"min-w-0 flex-1",children:t?i.jsx(hl,{className:"max-w-3xl",children:t.body}):i.jsx("p",{className:"text-sm text-muted-foreground",children:"No documentation yet."})})]})}const sue=["minutes","hours","days"];function oue(e){const t=/Every\s+(\d+)\s+(minute|hour|day)s?/i.exec(e);return t?{count:Number(t[1]),unit:`${t[2].toLowerCase()}s`}:{count:1,unit:"hours"}}function wP({schedule:e,onClose:t}){const n=ZE(e.id),{data:r}=WE(e.workspaceId),{data:a}=qE(e.workspaceId),[s,l]=E.useState(e.name),[u,d]=E.useState(e.prompt),p=e.workspaceId,[m,h]=E.useState(e.workingDir??"~"),[y,b]=E.useState(e.model??Vm),[v,T]=E.useState(e.effort??Wm),[w,N]=E.useState(e.assignmentKind),[k,A]=E.useState(e.teamId),[_,I]=E.useState(e.agentId),O=oue(e.cadence),[R,F]=E.useState(O.count),[z,M]=E.useState(O.unit),Q=E.useRef(null),Y=`Every ${R} ${R===1?z.slice(0,-1):z}`,ae=w==="anyone"||w==="team"&&!!k||w==="agent"&&!!_,V=!!s.trim()&&!!u.trim()&&R>=1&&ae;async function G(){V&&(await n.mutateAsync({name:s.trim(),prompt:u.trim(),cadence:Y,workspaceId:p,workingDir:m.trim()||"~",assignmentKind:w,teamId:w==="team"?k:void 0,agentId:w==="agent"?_:void 0,model:y,effort:v}),t())}return i.jsx(Ot,{open:!0,onOpenChange:te=>!te&&t(),children:i.jsxs(At,{className:"sm:max-w-4xl",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Edit schedule"})}),i.jsxs(Mt,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{htmlFor:"ed-name",children:"Name"}),i.jsx(ro,{id:"ed-name",value:s,onChange:te=>l(te.target.value),maxLength:80})]}),i.jsxs("div",{className:"grid grid-cols-[2fr_1fr] gap-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Prompt"}),i.jsx(pp,{value:u,onChange:d,maxLength:2e3,placeholder:"What should run each time?",helpText:"Markdown supported",height:340})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Working directory"}),i.jsx(Dx,{value:m,onChange:h})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Model"}),i.jsx(Zo,{value:y,onChange:b,options:fp})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Effort"}),i.jsx(Zo,{value:v,onChange:T,options:mp})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(wt,{children:"Delegate to"}),i.jsxs(kr,{value:w,onValueChange:te=>{const ue=te;N(ue),(ue==="team"||ue==="agent")&&requestAnimationFrame(()=>{var q;return(q=Q.current)==null?void 0:q.focus()})},children:[i.jsx(dr,{children:i.jsx(Cr,{})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"anyone",children:"Anyone"}),i.jsx(Dt,{value:"team",children:"Team"}),i.jsx(Dt,{value:"agent",children:"Agent"})]})]}),i.jsxs(kr,{value:w==="team"?k:w==="agent"?_:void 0,onValueChange:te=>w==="team"?A(te):I(te),disabled:w==="anyone",children:[i.jsx(dr,{ref:Q,children:i.jsx(Cr,{placeholder:w==="team"?"Select a team":w==="agent"?"Select an agent":"No specific team or agent"})}),i.jsxs(pr,{children:[w==="team"&&(r==null?void 0:r.map(te=>i.jsx(Dt,{value:te.id,children:te.name},te.id))),w==="agent"&&(a==null?void 0:a.map(te=>i.jsx(Dt,{value:te.id,children:te.name},te.id)))]})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Cadence"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx(Cn,{type:"number",min:1,value:R,onChange:te=>F(Math.max(1,Number(te.target.value)||1)),className:"w-16"}),i.jsxs(kr,{value:z,onValueChange:te=>M(te),children:[i.jsx(dr,{className:"flex-1",children:i.jsx(Cr,{})}),i.jsx(pr,{children:sue.map(te=>i.jsx(Dt,{value:te,children:te},te))})]})]})]})]})]})]}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:t,children:"Cancel"}),i.jsxs(re,{disabled:!V||n.isPending,onClick:G,children:[n.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Save"]})]})]})})}const lue=[6,12,24];function uue(){const{data:e,isLoading:t}=X7(),{activeId:n,active:r}=eo(),a=FI(),[s,l]=E.useState(!1),[u,d]=E.useState(null),[p,m]=E.useState(null),[h,y]=sB(),[b,v]=E.useState(""),[T,w]=E.useState("all"),[N,k]=E.useState(1),[A,_]=E.useState(6);E.useEffect(()=>{h.get("new")!==null&&(l(!0),h.delete("new"),y(h,{replace:!0}))},[h,y]),E.useEffect(()=>{k(1)},[b,T,n]);const I=b.trim()!==""||T!=="all",O=(e??[]).filter(Y=>Y.workspaceId===n),R=O.filter(Y=>{if(T==="enabled"&&!Y.enabled||T==="disabled"&&Y.enabled)return!1;const ae=b.trim().toLowerCase();return!(ae&&!`${Y.name} ${Y.prompt}`.toLowerCase().includes(ae))}),F=R.length,z=Math.max(1,Math.ceil(F/A)),M=R.slice((N-1)*A,N*A),Q=F===1?"schedule":"schedules";return i.jsxs("div",{className:"p-6",children:[i.jsxs("header",{className:"mb-5 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Schedules"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Run a prompt on a cadence — headless and fully autonomous."})]}),i.jsxs(re,{onClick:()=>l(!0),children:[i.jsx(Hr,{className:"mr-1 h-4 w-4"})," New schedule"]})]}),i.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/30 px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(Ho,{className:"h-4 w-4"}),i.jsx("span",{children:"Filters"})]}),i.jsx("div",{className:"h-4 w-px bg-border"}),i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Bd,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),i.jsx(Cn,{type:"text",placeholder:"Search schedules...",value:b,onChange:Y=>v(Y.target.value),className:"w-full pl-8"})]}),i.jsxs(kr,{value:T,onValueChange:Y=>w(Y),children:[i.jsx(dr,{className:"w-[140px]",children:i.jsx(Cr,{placeholder:"Status"})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"all",children:"Any Status"}),i.jsx(Dt,{value:"enabled",children:"Enabled"}),i.jsx(Dt,{value:"disabled",children:"Disabled"})]})]})]}),!t&&F>0&&i.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:I?`${F} ${Q} matching filters`:`${F} ${Q}`}),i.jsx("div",{className:"flex flex-col gap-2",children:t?[0,1].map(Y=>i.jsx(Dn,{className:"h-24 w-full"},Y)):O.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(hd,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsxs("p",{className:"text-sm font-medium",children:["No schedules in ",(r==null?void 0:r.name)??"this workspace"," yet"]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Create one to run a prompt on a cadence."})]}):F===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(Ho,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsx("p",{className:"text-sm font-medium",children:"No schedules match your filters"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Try adjusting or clearing the filters above."})]}):M.map(Y=>i.jsx(cue,{schedule:Y,onEdit:()=>m(Y),onDelete:()=>d(Y)},Y.id))}),!t&&F>0&&i.jsx(hp,{className:"mt-4 border-t pt-4",currentPage:N,totalPages:z,onPageChange:k,totalItems:F,itemsPerPage:A,pageSize:A,onPageSizeChange:Y=>{_(Y),k(1)},pageSizeOptions:lue}),s&&i.jsx(pue,{onClose:()=>l(!1)}),p&&i.jsx(wP,{schedule:p,onClose:()=>m(null)}),i.jsx(Ot,{open:!!u,onOpenChange:Y=>!Y&&d(null),children:i.jsxs(At,{className:"sm:max-w-md",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Delete schedule?"})}),i.jsx(Mt,{children:i.jsxs(Vt,{children:["“",u==null?void 0:u.name,"” and its run history will be permanently deleted. This can't be undone."]})}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:()=>d(null),children:"Cancel"}),i.jsxs(re,{variant:"destructive",disabled:a.isPending,onClick:()=>u&&a.mutate(u.id,{onSuccess:()=>d(null)}),children:[a.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Delete"]})]})]})})]})}function cue({schedule:e,onEdit:t,onDelete:n}){const r=zn(),a=ZE(e.id),s=PI(e.id);return i.jsxs("div",{onClick:()=>r(`/schedules/${e.id}`),className:"flex cursor-pointer items-center justify-between gap-3 rounded-lg border bg-card p-4 text-sm shadow-sm transition-colors hover:border-primary/50",children:[i.jsx("div",{className:"mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:i.jsx(hd,{className:"h-5 w-5 text-primary"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:e.name}),!e.enabled&&i.jsx(yi,{variant:"outline",className:"border-border px-1.5 py-0 text-[10px] uppercase text-muted-foreground",children:"Disabled"})]}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(hd,{className:"h-3.5 w-3.5"})," ",e.cadence]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:iN(e.model)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:sN(e.effort)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:gL(e.assignmentKind,e.teamName,e.agentName)})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",onClick:l=>l.stopPropagation(),children:[i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",title:e.starred?"Unstar":"Star",onClick:()=>a.mutate({starred:!e.starred}),children:i.jsx(yI,{className:Ee("h-4 w-4",e.starred?"fill-amber-400 text-amber-400":"text-muted-foreground")})}),i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",children:i.jsx(ma,{className:"h-4 w-4"})})}),i.jsxs(In,{align:"end",className:"w-40",children:[i.jsxs(ct,{onSelect:()=>a.mutate({enabled:!e.enabled}),children:[i.jsx(gI,{className:"mr-2 h-4 w-4"})," ",e.enabled?"Disable":"Enable"]}),i.jsx(sr,{}),i.jsxs(ct,{onSelect:t,children:[i.jsx(_r,{className:"mr-2 h-4 w-4"})," Edit"]}),i.jsxs(ct,{onSelect:()=>s.mutate(),children:[i.jsx(zo,{className:"mr-2 h-4 w-4"})," Run now"]}),i.jsx(sr,{}),i.jsxs(ct,{className:"text-red-400",onSelect:n,children:[i.jsx(Rr,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})]})]})}const due=["minutes","hours","days"];function pue({onClose:e}){var D;const{data:t}=nh(),{data:n}=YE(),{activeId:r}=eo(),{data:a}=WE(r),{data:s}=qE(r),l=Z7(),[u,d]=E.useState(""),[p,m]=E.useState(""),[h,y]=E.useState("anyone"),[b,v]=E.useState(),[T,w]=E.useState(),[N,k]=E.useState(1),[A,_]=E.useState("hours"),[I,O]=E.useState(null),[R,F]=E.useState(null),[z,M]=E.useState(null),Q=E.useRef(null),Y=((D=t==null?void 0:t.find(U=>U.id===r))==null?void 0:D.workingDir)??"~",ae=I??Y,V=R??(n==null?void 0:n.defaultModel)??Vm,G=z??(n==null?void 0:n.defaultEffort)??Wm,te=`Every ${N} ${N===1?A.slice(0,-1):A}`,ue=h==="anyone"||h==="team"&&!!b||h==="agent"&&!!T,q=!!u.trim()&&!!p.trim()&&N>=1&&ue;async function H(){q&&(await l.mutateAsync({name:u.trim(),prompt:p.trim(),workspaceId:r,workingDir:ae,cadence:te,assignmentKind:h,teamId:h==="team"?b:void 0,agentId:h==="agent"?T:void 0,model:V,effort:G}),e())}return i.jsx(Ot,{open:!0,onOpenChange:U=>!U&&e(),children:i.jsxs(At,{className:"sm:max-w-4xl",children:[i.jsxs(_t,{children:[i.jsx(Rt,{children:"New schedule"}),i.jsx(Vt,{children:"Runs headless under the workspace, on the cadence — always autonomous."})]}),i.jsxs(Mt,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{htmlFor:"sc-name",children:"Name"}),i.jsx(ro,{id:"sc-name",autoFocus:!0,value:u,onChange:U=>d(U.target.value),maxLength:80,placeholder:"Triage new bugs"})]}),i.jsxs("div",{className:"grid grid-cols-[2fr_1fr] gap-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Prompt"}),i.jsx(pp,{value:p,onChange:m,maxLength:2e3,placeholder:"What should run each time?",helpText:"Markdown supported",height:340})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Working directory"}),i.jsx(Dx,{value:ae,onChange:O})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Model"}),i.jsx(Zo,{value:V,onChange:F,options:fp})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Effort"}),i.jsx(Zo,{value:G,onChange:M,options:mp})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(wt,{children:"Delegate to"}),i.jsxs(kr,{value:h,onValueChange:U=>{const Z=U;y(Z),(Z==="team"||Z==="agent")&&requestAnimationFrame(()=>{var j;return(j=Q.current)==null?void 0:j.focus()})},children:[i.jsx(dr,{children:i.jsx(Cr,{})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"anyone",children:"Anyone"}),i.jsx(Dt,{value:"team",children:"Team"}),i.jsx(Dt,{value:"agent",children:"Agent"})]})]}),i.jsxs(kr,{value:h==="team"?b:h==="agent"?T:void 0,onValueChange:U=>h==="team"?v(U):w(U),disabled:h==="anyone",children:[i.jsx(dr,{ref:Q,children:i.jsx(Cr,{placeholder:h==="team"?"Select a team":h==="agent"?"Select an agent":"No specific team or agent"})}),i.jsxs(pr,{children:[h==="team"&&(a==null?void 0:a.map(U=>i.jsx(Dt,{value:U.id,children:U.name},U.id))),h==="agent"&&(s==null?void 0:s.map(U=>i.jsx(Dt,{value:U.id,children:U.name},U.id)))]})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Cadence"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx(Cn,{type:"number",min:1,value:N,onChange:U=>k(Math.max(1,Number(U.target.value)||1)),className:"w-16"}),i.jsxs(kr,{value:A,onValueChange:U=>_(U),children:[i.jsx(dr,{className:"flex-1",children:i.jsx(Cr,{})}),i.jsx(pr,{children:due.map(U=>i.jsx(Dt,{value:U,children:U},U))})]})]})]})]})]})]}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:e,children:"Cancel"}),i.jsxs(re,{disabled:!q||l.isPending,onClick:H,children:[l.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Create"]})]})]})})}const fue={running:{label:"Running",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},success:{label:"Success",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},failed:{label:"Failed",className:"bg-red-500/15 text-red-300 border-red-500/30"}};function mue(){var w,N;const{scheduleId:e}=Ru(),t=zn(),{data:n,isLoading:r}=Q7(e),a=PI(e),s=ZE(e),l=FI(),u=MI(e,0,1),[d,p]=E.useState(null),[m,h]=E.useState(!1),[y,b]=E.useState(!1);if(r||!n)return i.jsxs("div",{className:"p-6",children:[i.jsx(Dn,{className:"mb-4 h-6 w-24"}),i.jsx(Dn,{className:"mb-2 h-8 w-1/2"}),i.jsx(Dn,{className:"h-40 w-full"})]});const v=(N=(w=u.data)==null?void 0:w.runs)==null?void 0:N[0],T=d??"results";return i.jsxs("div",{className:"flex h-full flex-col p-6",children:[i.jsxs(Ar,{to:"/schedules",className:"mb-4 inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",children:[i.jsx(Zm,{className:"h-4 w-4"})," Schedules"]}),i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h1",{className:"text-2xl font-bold leading-tight tracking-tight",children:n.name}),!n.enabled&&i.jsx(yi,{variant:"outline",className:"border-border px-1.5 py-0 text-[10px] uppercase text-muted-foreground",children:"Disabled"})]}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(hd,{className:"h-3.5 w-3.5"})," ",n.cadence]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:iN(n.model)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:sN(n.effort)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:gL(n.assignmentKind,n.teamName,n.agentName)}),n.enabled&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsxs("span",{children:["next ",Gy(n.nextRunAt)]})]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsxs(re,{size:"sm",disabled:a.isPending,onClick:()=>a.mutate(),children:[a.isPending?i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"}):i.jsx(zo,{className:"mr-1 h-4 w-4"})," ","Run now"]}),i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",children:i.jsx(ma,{className:"h-4 w-4"})})}),i.jsxs(In,{align:"end",className:"w-40",children:[i.jsxs(ct,{onSelect:()=>s.mutate({enabled:!n.enabled}),children:[i.jsx(gI,{className:"mr-2 h-4 w-4"})," ",n.enabled?"Disable":"Enable"]}),i.jsx(sr,{}),i.jsxs(ct,{onSelect:()=>b(!0),children:[i.jsx(_r,{className:"mr-2 h-4 w-4"})," Edit"]}),i.jsx(sr,{}),i.jsxs(ct,{className:"text-red-400",onSelect:()=>h(!0),children:[i.jsx(Rr,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})]})]}),i.jsxs("div",{className:"mt-5 flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:"mb-3 flex shrink-0 gap-5 border-b",children:[i.jsx("button",{type:"button",onClick:()=>p("prompt"),className:Ca(T==="prompt"),children:"Prompt"}),i.jsx("button",{type:"button",onClick:()=>p("notes"),className:Ca(T==="notes"),children:"Notes"}),i.jsx("button",{type:"button",onClick:()=>p("results"),className:Ca(T==="results"),children:"Run results"}),i.jsx("button",{type:"button",onClick:()=>p("history"),className:Ca(T==="history"),children:"Run history"})]}),T==="notes"?i.jsx(hle,{parent:{kind:"schedule",id:n.id}}):i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[T==="prompt"&&i.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:n.prompt}),T==="results"&&(v?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsxs("span",{children:["Latest run · ",Gy(v.startedAt)]}),i.jsx(hue,{status:v.status}),v.model&&i.jsx(vg,{model:v.model,effort:v.effort})]}),i.jsx(wg,{text:n.prompt}),i.jsx(Sg,{text:v.output,divided:!0})]}):i.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 px-4 py-10 text-center text-sm text-muted-foreground",children:"No runs yet — “Run now” to fire this schedule."})),T==="history"&&i.jsx(gue,{scheduleId:n.id,prompt:n.prompt})]})]}),y&&i.jsx(wP,{schedule:n,onClose:()=>b(!1)}),i.jsx(Ot,{open:m,onOpenChange:h,children:i.jsxs(At,{className:"sm:max-w-md",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Delete schedule?"})}),i.jsx(Mt,{children:i.jsxs(Vt,{children:["“",n.name,"” and its run history will be permanently deleted. This can't be undone."]})}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),i.jsxs(re,{variant:"destructive",disabled:l.isPending,onClick:()=>l.mutate(n.id,{onSuccess:()=>t("/schedules")}),children:[l.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Delete"]})]})]})})]})}function hue({status:e}){const t=fue[e];return i.jsx(yi,{variant:"outline",className:Ee("px-1.5 py-0 text-[10px]",t.className),children:t.label})}function gue({scheduleId:e,prompt:t}){const[n,r]=E.useState(1),[a,s]=E.useState(8),[l,u]=E.useState(null),[d,p]=E.useState(null),{data:m,isFetching:h}=MI(e,(n-1)*a,a),y=m==null?void 0:m.runs,b=(m==null?void 0:m.total)??0;return!h&&b===0?i.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 px-4 py-10 text-center text-sm text-muted-foreground",children:"No runs yet — history appears here after this schedule fires."}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("p",{className:"text-sm text-muted-foreground",children:[b," ",b===1?"run":"runs"]}),i.jsx("div",{className:"flex flex-col gap-2",children:y==null?void 0:y.map(v=>i.jsxs("div",{onClick:()=>u(v),className:"group flex cursor-pointer items-center gap-3 rounded-lg border bg-card/50 p-3 text-sm transition-colors hover:border-primary/50",children:[i.jsx("span",{className:Ee("h-2 w-2 shrink-0 rounded-full",v.status==="success"?"bg-emerald-400":v.status==="failed"?"bg-red-400":"bg-amber-400"),title:v.status}),i.jsx("div",{className:"min-w-0 flex-1",children:i.jsx("span",{className:"text-foreground",children:new Date(v.startedAt).toLocaleString()})}),v.sessionId&&i.jsxs(re,{variant:"ghost",size:"sm",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:T=>{T.stopPropagation(),p(v)},title:"View the session terminal",children:[i.jsx(xu,{className:"mr-1 h-4 w-4"})," Terminal"]}),i.jsx(nl,{className:"h-4 w-4 shrink-0 text-muted-foreground/40 transition-colors group-hover:text-foreground"})]},v.id))}),b>0&&i.jsx(hp,{className:"border-t pt-4",currentPage:n,totalPages:Math.max(1,Math.ceil(b/a)),onPageChange:r,totalItems:b,itemsPerPage:a,pageSize:a,onPageSizeChange:v=>{s(v),r(1)},pageSizeOptions:[8,16,24]}),i.jsx(Ot,{open:!!l,onOpenChange:v=>!v&&u(null),children:i.jsxs(At,{className:"flex max-h-[85vh] flex-col sm:max-w-4xl",children:[i.jsxs(_t,{children:[i.jsx(Rt,{children:"Run detail"}),i.jsxs(Vt,{children:[l?new Date(l.startedAt).toLocaleString():"",(l==null?void 0:l.model)&&i.jsxs(i.Fragment,{children:[" · ",i.jsx(vg,{model:l.model,effort:l.effort})]})]})]}),i.jsx(Mt,{className:"min-h-0 flex-1 space-y-4 overflow-y-auto",children:l&&i.jsxs(i.Fragment,{children:[i.jsx(wg,{text:t}),i.jsx(Sg,{text:l.output,divided:!0})]})}),i.jsxs(Lt,{children:[(l==null?void 0:l.sessionId)&&i.jsxs(re,{variant:"outline",onClick:()=>{p(l),u(null)},children:[i.jsx(xu,{className:"mr-1 h-4 w-4"})," View Terminal"]}),i.jsx(re,{variant:"outline",onClick:()=>u(null),children:"Close"})]})]})}),(d==null?void 0:d.sessionId)&&i.jsx(oN,{sessionId:d.sessionId,running:!1,onClose:()=>p(null)})]})}const bue=[6,12,24];function yue(){const{data:e,isLoading:t}=jI(),{activeId:n,active:r}=eo(),a=t9(),[s,l]=E.useState(null),[u,d]=E.useState(""),[p,m]=E.useState("all"),[h,y]=E.useState(1),[b,v]=E.useState(6);E.useEffect(()=>{y(1)},[u,p,n]);const T=u.trim()!==""||p!=="all",w=(e??[]).filter(O=>O.workspaceId===n),N=w.filter(O=>{if(p!=="all"&&O.status!==p)return!1;const R=u.trim().toLowerCase();return!(R&&!O.name.toLowerCase().includes(R))}),k=N.length,A=Math.max(1,Math.ceil(k/b)),_=N.slice((h-1)*b,h*b),I=k===1?"batch":"batches";return i.jsxs("div",{className:"p-6",children:[i.jsxs("header",{className:"mb-5 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Batches"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Press play on a set of assigned tickets and let them run unattended."})]}),i.jsx(re,{asChild:!0,children:i.jsxs(Ar,{to:"/board",children:[i.jsx(Ks,{className:"mr-1 h-4 w-4"})," New batch"]})})]}),i.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/30 px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(Ho,{className:"h-4 w-4"}),i.jsx("span",{children:"Filters"})]}),i.jsx("div",{className:"h-4 w-px bg-border"}),i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Bd,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),i.jsx(Cn,{type:"text",placeholder:"Search batches...",value:u,onChange:O=>d(O.target.value),className:"w-full pl-8"})]}),i.jsxs(kr,{value:p,onValueChange:O=>m(O),children:[i.jsx(dr,{className:"w-[150px]",children:i.jsx(Cr,{placeholder:"Status"})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"all",children:"Any Status"}),i.jsx(Dt,{value:"running",children:"Running"}),i.jsx(Dt,{value:"queued",children:"Queued"}),i.jsx(Dt,{value:"paused",children:"Paused"}),i.jsx(Dt,{value:"done",children:"Done"}),i.jsx(Dt,{value:"idle",children:"Idle"})]})]})]}),!t&&k>0&&i.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:T?`${k} ${I} matching filters`:`${k} ${I}`}),i.jsx("div",{className:"flex flex-col gap-2",children:t?[0,1].map(O=>i.jsx(Dn,{className:"h-20 w-full"},O)):w.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(Ks,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsxs("p",{className:"text-sm font-medium",children:["No batches in ",(r==null?void 0:r.name)??"this workspace"," yet"]}),i.jsxs("p",{className:"mb-4 max-w-sm text-sm text-muted-foreground",children:["Open a board, hit ",i.jsx("span",{className:"font-medium",children:"Select"}),", tick the assigned tickets you want to run together, then create a batch."]}),i.jsx(re,{asChild:!0,size:"sm",variant:"secondary",children:i.jsx(Ar,{to:"/board",children:"Go to a board"})})]}):k===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(Ho,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsx("p",{className:"text-sm font-medium",children:"No batches match your filters"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Try adjusting or clearing the filters above."})]}):_.map(O=>i.jsx(Eue,{batch:O,onDelete:()=>l(O)},O.id))}),!t&&k>0&&i.jsx(hp,{className:"mt-4 border-t pt-4",currentPage:h,totalPages:A,onPageChange:y,totalItems:k,itemsPerPage:b,pageSize:b,onPageSizeChange:O=>{v(O),y(1)},pageSizeOptions:bue}),i.jsx(Ot,{open:!!s,onOpenChange:O=>!O&&l(null),children:i.jsxs(At,{className:"sm:max-w-md",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Delete batch?"})}),i.jsx(Mt,{children:i.jsxs(Vt,{children:["“",s==null?void 0:s.name,"” will be deleted. The tickets and their runs are untouched — only the batch grouping goes away."]})}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsxs(re,{variant:"destructive",disabled:a.isPending,onClick:()=>s&&a.mutate(s.id,{onSuccess:()=>l(null)}),children:[a.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Delete"]})]})]})})]})}function Eue({batch:e,onDelete:t}){const n=zn(),r=BI(e.id),a=UI(e.id),s=HI(e.id),l=hL(e.status),u=e.ticketIds.length,d=r.isPending||a.isPending||s.isPending;return i.jsxs("div",{onClick:()=>n(`/batches/${e.id}`),className:Ee("flex cursor-pointer items-center justify-between gap-3 rounded-lg border bg-card p-4 text-sm shadow-sm transition-colors hover:border-primary/50",e.status==="running"&&"batch-racing",e.status==="queued"&&"batch-waiting"),children:[i.jsx("div",{className:"mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:i.jsx(Ks,{className:"h-5 w-5 text-primary"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"truncate font-medium",children:e.name}),i.jsx(yi,{variant:"outline",className:Ee("px-1.5 py-0 text-[10px] uppercase",l.className),children:l.label})]}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[i.jsxs("span",{children:[u," ",u===1?"ticket":"tickets"]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:e.mode==="ordered"?"Ordered":"Unordered"}),e.pausedReason&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsx("span",{className:"text-amber-300/90",children:e.pausedReason})]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",onClick:p=>p.stopPropagation(),children:[e.status==="running"?i.jsxs(re,{size:"sm",variant:"secondary",disabled:d,onClick:()=>a.mutate(),children:[i.jsx(xm,{className:"mr-1 h-4 w-4"})," Pause"]}):e.status!=="done"&&i.jsxs(re,{size:"sm",disabled:d||e.status==="queued",onClick:()=>r.mutate(),children:[i.jsx(zo,{className:"mr-1 h-4 w-4"})," ",e.status==="paused"?"Resume":"Play"]}),i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",children:i.jsx(ma,{className:"h-4 w-4"})})}),i.jsxs(In,{align:"end",className:"w-40",children:[(e.status==="running"||e.status==="paused"||e.status==="queued")&&i.jsxs(ct,{onSelect:()=>s.mutate(),children:[i.jsx(GE,{className:"mr-2 h-4 w-4"})," Stop"]}),i.jsx(sr,{}),i.jsxs(ct,{className:"text-red-400",disabled:e.status==="running",onSelect:t,children:[i.jsx(Rr,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})]})]})}function xue(e){switch(e){case"done":return{label:"Done",className:"border-green-500/40 bg-green-500/15 text-green-300",icon:jE};case"running":return{label:"Running",className:"border-sky-500/40 bg-sky-500/15 text-sky-300",icon:Ye};case"blocked":return{label:"Blocked",className:"border-red-500/40 bg-red-500/15 text-red-300",icon:NA};case"failed":return{label:"Failed",className:"border-red-500/40 bg-red-500/15 text-red-300",icon:NA};case"waiting":return{label:"Waiting",className:"border-amber-500/40 bg-amber-500/15 text-amber-300",icon:$o};default:return{label:"Queued",className:"border-border bg-muted text-muted-foreground",icon:LB}}}function vue(){const{batchId:e=""}=Ru(),t=zn(),{data:n,isLoading:r}=J7(e),a=BI(e),s=UI(e),l=HI(e);if(r||!n)return i.jsxs("div",{className:"mx-auto max-w-4xl space-y-4 p-6",children:[i.jsx(Dn,{className:"h-9 w-64"}),i.jsx(Dn,{className:"h-40 w-full"})]});const{batch:u,tickets:d}=n,p=hL(u.status),m=a.isPending||s.isPending||l.isPending,h=d.filter(b=>b.state==="done").length,y=d.length;return i.jsxs("div",{className:"mx-auto max-w-4xl p-6",children:[i.jsxs("button",{onClick:()=>t("/batches"),className:"mb-4 flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(Zm,{className:"h-4 w-4"})," Batches"]}),i.jsxs("header",{className:"mb-5 flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[i.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:i.jsx(Ks,{className:"h-6 w-6 text-primary"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h1",{className:"truncate text-2xl font-bold tracking-tight",children:u.name}),i.jsx(yi,{variant:"outline",className:Ee("px-1.5 py-0 text-[10px] uppercase",p.className),children:p.label})]}),i.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[u.mode==="ordered"?"Ordered":"Unordered"," · ",h,"/",y," done · ",u.workspaceName,u.budgetCap!=null&&` · cap ${u.budgetCap} runs`]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[u.status==="running"?i.jsxs(re,{variant:"secondary",disabled:m,onClick:()=>s.mutate(),children:[i.jsx(xm,{className:"mr-1 h-4 w-4"})," Pause"]}):u.status!=="done"&&i.jsxs(re,{disabled:m||u.status==="queued",onClick:()=>a.mutate(),children:[i.jsx(zo,{className:"mr-1 h-4 w-4"})," ",u.status==="paused"?"Resume":"Play"]}),(u.status==="running"||u.status==="paused"||u.status==="queued")&&i.jsxs(re,{variant:"ghost",disabled:m,onClick:()=>l.mutate(),children:[i.jsx(GE,{className:"mr-1 h-4 w-4"})," Stop"]})]})]}),u.pausedReason&&i.jsxs("div",{className:"mb-4 flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-200",children:[i.jsx(xm,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{children:u.pausedReason})]}),i.jsx("div",{className:"flex flex-col gap-2",children:d.map(b=>i.jsx(wue,{member:b,members:d},b.ticketId))})]})}function wue({member:e,members:t}){const n=zn(),r=xue(e.state),a=r.icon,s=e.unmetDeps.map(l=>{var u;return((u=t.find(d=>d.ticketId===l))==null?void 0:u.externalIdentifier)??l});return i.jsxs("div",{onClick:()=>n(`/tickets/${e.ticketId}`),className:"flex cursor-pointer items-center justify-between gap-3 rounded-lg border bg-card p-3 text-sm shadow-sm transition-colors hover:border-primary/50",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i.jsx("span",{className:Ee("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",r.className),children:i.jsx(a,{className:Ee("h-4 w-4",e.state==="running"&&"animate-spin")})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.externalIdentifier}),i.jsx("span",{className:"truncate font-medium",children:e.title})]}),s.length>0&&i.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs text-amber-300/90",children:[i.jsx($o,{className:"h-3 w-3"})," waiting on ",s.join(", ")]})]})]}),i.jsx(yi,{variant:"outline",className:Ee("shrink-0 px-1.5 py-0 text-[10px] uppercase",r.className),children:r.label})]})}const Sue=eB([{path:"/",element:i.jsx(jV,{}),children:[{index:!0,element:i.jsx(Ay,{to:"/board",replace:!0})},{path:"board",element:i.jsx(Q2,{})},{path:"board/:connectionId",element:i.jsx(Q2,{})},{path:"tickets/:ticketId",element:i.jsx(Nle,{})},{path:"schedules",element:i.jsx(uue,{})},{path:"schedules/:scheduleId",element:i.jsx(mue,{})},{path:"batches",element:i.jsx(yue,{})},{path:"batches/:batchId",element:i.jsx(vue,{})},{path:"chat",element:i.jsx(Vle,{})},{path:"chat/new",element:i.jsx(lR,{})},{path:"chat/:conversationId",element:i.jsx(lR,{})},{path:"docs",element:i.jsx(cR,{})},{path:"docs/:slug",element:i.jsx(cR,{})},{path:"settings",element:i.jsx(Lle,{}),children:[{index:!0,element:i.jsx(Ple,{})},{path:"workspaces",element:i.jsx(Fle,{})},{path:"presets",element:i.jsx(Ble,{})},{path:"connections",element:i.jsx(ele,{})},{path:"api",element:i.jsx(Hle,{})},{path:"webhooks",element:i.jsx(zle,{})}]},{path:"connections",element:i.jsx(Ay,{to:"/settings/connections",replace:!0})}]}]),dR=1024;function Tue(e){const[t,n]=E.useState(()=>typeof window>"u"?!0:window.matchMedia(`(min-width: ${e}px)`).matches);return E.useEffect(()=>{const r=window.matchMedia(`(min-width: ${e}px)`),a=()=>n(r.matches);return a(),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}function Nue({children:e}){return Tue(dR)?i.jsx(i.Fragment,{children:e}):i.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-background p-8 text-center text-foreground",children:[i.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-muted",children:i.jsx(hI,{className:"h-7 w-7 text-muted-foreground"})}),i.jsx("h1",{className:"text-xl font-semibold",children:"Window too small"}),i.jsxs("p",{className:"max-w-sm text-sm text-muted-foreground",children:["SuperClawd Pipelines needs a window at least ",dR,"px wide. Widen or maximize this window to continue."]})]})}const kue=new F5({defaultOptions:{queries:{retry:!1}}});f5.createRoot(document.getElementById("root")).render(i.jsx(pn.StrictMode,{children:i.jsx(j5,{client:kue,children:i.jsx(Nue,{children:i.jsx(fB,{router:Sue})})})}));
1089
+ `,iue="# API, webhooks & MCP\n\nPipelines can talk to the outside world three ways: a **public HTTP API** you call to drive the board, **webhooks** that push events to you, and an **MCP server** that lets Claude Code drive your board from a session. The API and webhooks are off by default and configured in Settings; the MCP server runs with the daemon.\n\n## Public API\n\nA key-authenticated HTTP API for board, ticket, and run actions. It runs on its **own port** (default **63211**), separate from the Pipelines UI, and only starts when you enable it in **Settings → API**.\n\n### Authentication\n\nGenerate a key in the API tab. The key is shown **once** — copy it then; only a SHA-256 hash and the last four characters are stored, so it can't be recovered later. You can refresh (rotate) or revoke it anytime.\n\nSend it as a bearer token:\n\n```bash\ncurl -H \"Authorization: Bearer <your-key>\" \\\n http://localhost:63211/v1/boards\n```\n\nThe API tab shows your exact base URL and a ready-to-copy curl example.\n\n### Endpoints\n\nAll routes live under `/v1`:\n\n| Method | Path | Purpose |\n| --- | --- | --- |\n| `GET` | `/v1/boards` | List boards |\n| `GET` | `/v1/boards/:id/tickets` | List a board's tickets |\n| `POST` | `/v1/boards/:id/tickets` | Create a ticket on a Local board |\n| `GET` | `/v1/tickets/:id` | Get one ticket |\n| `PATCH` | `/v1/tickets/:id` | Update ticket fields |\n| `POST` | `/v1/tickets/:id/move` | Move a ticket between lanes |\n| `POST` | `/v1/tickets/:id/unblock` | Unblock a ticket |\n| `GET` / `POST` | `/v1/tickets/:id/notes` | List / add notes |\n| `PATCH` / `DELETE` | `/v1/notes/:id` | Edit / delete a note |\n| `GET` / `POST` | `/v1/tickets/:id/questions` | List / add open questions |\n| `PATCH` / `DELETE` | `/v1/questions/:id` | Update / delete a question |\n| `GET` | `/v1/tickets/:id/run` | Get a ticket's run state |\n| `POST` | `/v1/tickets/:id/run/:action` | Drive a run (start, pause, resume, stop, …) |\n| `GET` / `POST` | `/v1/batches` | List / create batches |\n| `GET` / `DELETE` | `/v1/batches/:id` | Get a batch (with member state) / delete it |\n| `POST` | `/v1/batches/:id/:action` | Drive a batch (start, pause, stop) |\n\n### Interactive reference\n\nThe API self-hosts an OpenAPI 3.1 spec and an interactive reference:\n\n- **`/openapi.json`** — the raw spec.\n- **`/docs`** — a browsable API reference on the public API's port (e.g. `http://localhost:63211/docs`).\n\nThere's also an **API reference** button in the API tab that opens it.\n\n## Webhooks\n\nPush ticket, run, schedule, and batch events to an endpoint you own. Enable webhooks in **Settings → Webhooks** and set a destination URL.\n\n### Signing\n\nEvery request is signed. Pipelines sends an HMAC-SHA256 signature over the raw body in the **`X-SuperClawd-Signature`** header, formatted `sha256=<hex>`, using your **signing secret** (rotatable in the tab). Verify it on your end to confirm the request really came from your Pipelines. Fixed headers on every delivery: `X-SuperClawd-Event` (the event name), a JSON content type, and a Pipelines user agent.\n\n### Custom headers\n\nAdd up to **4** custom headers (e.g. an `Authorization` header for your receiver) — stored encrypted at rest. A blocked-list prevents overriding the reserved headers (like the signature).\n\n### Events\n\nSubscribe to any of:\n\n- **Tickets** — `ticket.moved`, `ticket.blocked`, `ticket.unblocked`, `ticket.updated`\n- **Runs** — `run.started`, `run.paused`, `run.resumed`, `run.completed`, `run.failed`, `run.stopped`\n- **Schedules** — `schedule.run.started`, `schedule.run.completed`, `schedule.run.failed`\n- **Batches** — `batch.started`, `batch.completed`, `batch.paused`, `batch.ticket_blocked`\n\nDeliveries are fire-and-forget with retries, filtered to your subscribed events. Use **Send test** to fire a sample payload at your endpoint and confirm the wiring.\n\n## MCP\n\nThe MCP server is the agent-native twin of the HTTP API — the same board/ticket/run actions, exposed as tools for **Claude Code** so you can drive Pipelines from a session (*\"what's blocked?\"*, *\"plan ENG-123 and start it\"*, *\"file a ticket for this\"*).\n\n- **Transport** — Streamable HTTP, served by the daemon at **`/mcp`** on the main port, so it's available whenever Pipelines is running.\n- **Zero-config in the CLI** — turn on **Pipelines MCP** in `superclawd config`. When the daemon is running, the CLI auto-injects the server into your session using a machine-local token — nothing to paste. If Pipelines isn't running it shows up as a *failed* MCP server, which is your cue to start it.\n- **Remote / programmatic** — the same endpoint also accepts a public API key as a Bearer token (handy if the daemon is ever exposed beyond localhost).\n\nThe tools cover the ticket lifecycle: `list_boards`, `list_tickets`, `get_ticket`, `create_ticket`, `update_ticket`, `move_ticket`, `set_plan`, `set_conclusion`, notes (add / list / edit / delete), `block_ticket` / `unblock_ticket`, questions (add / list / update / delete), and runs (`start` / `pause` / `resume` / `stop` / status). Batches too: `list_batches`, `get_batch`, `create_batch`, `start_batch`, `pause_batch`, `stop_batch`.\n",sue=Object.assign({"../docs/01-getting-started.md":Xle,"../docs/02-how-it-works.md":Qle,"../docs/03-boards-and-tickets.md":Zle,"../docs/04-runs.md":Jle,"../docs/05-batches.md":eue,"../docs/06-schedules.md":tue,"../docs/07-connections.md":nue,"../docs/08-conversations.md":rue,"../docs/09-settings.md":aue,"../docs/10-api-and-webhooks.md":iue}),uy=Object.entries(sue).map(([e,t])=>{var u;const n=(e.split("/").pop()??"").replace(/\.md$/,""),r=/^(\d+)-(.+)$/.exec(n),a=r?Number(r[1]):999,s=r?r[2]:n,l=(((u=/^#\s+(.+)$/m.exec(t))==null?void 0:u[1])??s.replace(/-/g," ")).trim();return{slug:s,title:l,order:a,body:t}}).sort((e,t)=>e.order-t.order);function cR(){const{slug:e}=Ru(),t=uy.find(n=>n.slug===e)??uy[0];return i.jsxs("div",{className:"mx-auto flex max-w-6xl gap-8 p-6",children:[i.jsxs("aside",{className:"w-56 shrink-0",children:[i.jsx("h1",{className:"mb-1 text-2xl font-bold tracking-tight",children:"Docs"}),i.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"How SuperClawd Pipelines works."}),i.jsx("nav",{className:"sticky top-6 space-y-1",children:uy.map(n=>i.jsx(ji,{to:`/docs/${n.slug}`,className:Ee("block rounded-md px-3 py-1.5 text-sm transition-colors",n.slug===(t==null?void 0:t.slug)?"bg-accent font-medium text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:n.title},n.slug))})]}),i.jsx("div",{className:"min-w-0 flex-1",children:t?i.jsx(hl,{className:"max-w-3xl",children:t.body}):i.jsx("p",{className:"text-sm text-muted-foreground",children:"No documentation yet."})})]})}const oue=["minutes","hours","days"];function lue(e){const t=/Every\s+(\d+)\s+(minute|hour|day)s?/i.exec(e);return t?{count:Number(t[1]),unit:`${t[2].toLowerCase()}s`}:{count:1,unit:"hours"}}function wP({schedule:e,onClose:t}){const n=ZE(e.id),{data:r}=WE(e.workspaceId),{data:a}=qE(e.workspaceId),[s,l]=E.useState(e.name),[u,d]=E.useState(e.prompt),p=e.workspaceId,[m,h]=E.useState(e.workingDir??"~"),[y,b]=E.useState(e.model??Vm),[v,T]=E.useState(e.effort??Wm),[w,N]=E.useState(e.assignmentKind),[k,A]=E.useState(e.teamId),[_,I]=E.useState(e.agentId),O=lue(e.cadence),[R,F]=E.useState(O.count),[z,M]=E.useState(O.unit),Q=E.useRef(null),Y=`Every ${R} ${R===1?z.slice(0,-1):z}`,ae=w==="anyone"||w==="team"&&!!k||w==="agent"&&!!_,V=!!s.trim()&&!!u.trim()&&R>=1&&ae;async function G(){V&&(await n.mutateAsync({name:s.trim(),prompt:u.trim(),cadence:Y,workspaceId:p,workingDir:m.trim()||"~",assignmentKind:w,teamId:w==="team"?k:void 0,agentId:w==="agent"?_:void 0,model:y,effort:v}),t())}return i.jsx(Ot,{open:!0,onOpenChange:te=>!te&&t(),children:i.jsxs(At,{className:"sm:max-w-4xl",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Edit schedule"})}),i.jsxs(Mt,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{htmlFor:"ed-name",children:"Name"}),i.jsx(ro,{id:"ed-name",value:s,onChange:te=>l(te.target.value),maxLength:80})]}),i.jsxs("div",{className:"grid grid-cols-[2fr_1fr] gap-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Prompt"}),i.jsx(pp,{value:u,onChange:d,maxLength:2e3,placeholder:"What should run each time?",helpText:"Markdown supported",height:340})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Working directory"}),i.jsx(Dx,{value:m,onChange:h})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Model"}),i.jsx(Zo,{value:y,onChange:b,options:fp})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Effort"}),i.jsx(Zo,{value:v,onChange:T,options:mp})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(wt,{children:"Delegate to"}),i.jsxs(kr,{value:w,onValueChange:te=>{const ue=te;N(ue),(ue==="team"||ue==="agent")&&requestAnimationFrame(()=>{var q;return(q=Q.current)==null?void 0:q.focus()})},children:[i.jsx(dr,{children:i.jsx(Cr,{})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"anyone",children:"Anyone"}),i.jsx(Dt,{value:"team",children:"Team"}),i.jsx(Dt,{value:"agent",children:"Agent"})]})]}),i.jsxs(kr,{value:w==="team"?k:w==="agent"?_:void 0,onValueChange:te=>w==="team"?A(te):I(te),disabled:w==="anyone",children:[i.jsx(dr,{ref:Q,children:i.jsx(Cr,{placeholder:w==="team"?"Select a team":w==="agent"?"Select an agent":"No specific team or agent"})}),i.jsxs(pr,{children:[w==="team"&&(r==null?void 0:r.map(te=>i.jsx(Dt,{value:te.id,children:te.name},te.id))),w==="agent"&&(a==null?void 0:a.map(te=>i.jsx(Dt,{value:te.id,children:te.name},te.id)))]})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Cadence"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx(Cn,{type:"number",min:1,value:R,onChange:te=>F(Math.max(1,Number(te.target.value)||1)),className:"w-16"}),i.jsxs(kr,{value:z,onValueChange:te=>M(te),children:[i.jsx(dr,{className:"flex-1",children:i.jsx(Cr,{})}),i.jsx(pr,{children:oue.map(te=>i.jsx(Dt,{value:te,children:te},te))})]})]})]})]})]})]}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:t,children:"Cancel"}),i.jsxs(re,{disabled:!V||n.isPending,onClick:G,children:[n.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Save"]})]})]})})}const uue=[6,12,24];function cue(){const{data:e,isLoading:t}=X7(),{activeId:n,active:r}=eo(),a=FI(),[s,l]=E.useState(!1),[u,d]=E.useState(null),[p,m]=E.useState(null),[h,y]=sB(),[b,v]=E.useState(""),[T,w]=E.useState("all"),[N,k]=E.useState(1),[A,_]=E.useState(6);E.useEffect(()=>{h.get("new")!==null&&(l(!0),h.delete("new"),y(h,{replace:!0}))},[h,y]),E.useEffect(()=>{k(1)},[b,T,n]);const I=b.trim()!==""||T!=="all",O=(e??[]).filter(Y=>Y.workspaceId===n),R=O.filter(Y=>{if(T==="enabled"&&!Y.enabled||T==="disabled"&&Y.enabled)return!1;const ae=b.trim().toLowerCase();return!(ae&&!`${Y.name} ${Y.prompt}`.toLowerCase().includes(ae))}),F=R.length,z=Math.max(1,Math.ceil(F/A)),M=R.slice((N-1)*A,N*A),Q=F===1?"schedule":"schedules";return i.jsxs("div",{className:"p-6",children:[i.jsxs("header",{className:"mb-5 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Schedules"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Run a prompt on a cadence — headless and fully autonomous."})]}),i.jsxs(re,{onClick:()=>l(!0),children:[i.jsx(Hr,{className:"mr-1 h-4 w-4"})," New schedule"]})]}),i.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/30 px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(Ho,{className:"h-4 w-4"}),i.jsx("span",{children:"Filters"})]}),i.jsx("div",{className:"h-4 w-px bg-border"}),i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Bd,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),i.jsx(Cn,{type:"text",placeholder:"Search schedules...",value:b,onChange:Y=>v(Y.target.value),className:"w-full pl-8"})]}),i.jsxs(kr,{value:T,onValueChange:Y=>w(Y),children:[i.jsx(dr,{className:"w-[140px]",children:i.jsx(Cr,{placeholder:"Status"})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"all",children:"Any Status"}),i.jsx(Dt,{value:"enabled",children:"Enabled"}),i.jsx(Dt,{value:"disabled",children:"Disabled"})]})]})]}),!t&&F>0&&i.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:I?`${F} ${Q} matching filters`:`${F} ${Q}`}),i.jsx("div",{className:"flex flex-col gap-2",children:t?[0,1].map(Y=>i.jsx(Dn,{className:"h-24 w-full"},Y)):O.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(hd,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsxs("p",{className:"text-sm font-medium",children:["No schedules in ",(r==null?void 0:r.name)??"this workspace"," yet"]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Create one to run a prompt on a cadence."})]}):F===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(Ho,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsx("p",{className:"text-sm font-medium",children:"No schedules match your filters"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Try adjusting or clearing the filters above."})]}):M.map(Y=>i.jsx(due,{schedule:Y,onEdit:()=>m(Y),onDelete:()=>d(Y)},Y.id))}),!t&&F>0&&i.jsx(hp,{className:"mt-4 border-t pt-4",currentPage:N,totalPages:z,onPageChange:k,totalItems:F,itemsPerPage:A,pageSize:A,onPageSizeChange:Y=>{_(Y),k(1)},pageSizeOptions:uue}),s&&i.jsx(fue,{onClose:()=>l(!1)}),p&&i.jsx(wP,{schedule:p,onClose:()=>m(null)}),i.jsx(Ot,{open:!!u,onOpenChange:Y=>!Y&&d(null),children:i.jsxs(At,{className:"sm:max-w-md",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Delete schedule?"})}),i.jsx(Mt,{children:i.jsxs(Vt,{children:["“",u==null?void 0:u.name,"” and its run history will be permanently deleted. This can't be undone."]})}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:()=>d(null),children:"Cancel"}),i.jsxs(re,{variant:"destructive",disabled:a.isPending,onClick:()=>u&&a.mutate(u.id,{onSuccess:()=>d(null)}),children:[a.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Delete"]})]})]})})]})}function due({schedule:e,onEdit:t,onDelete:n}){const r=zn(),a=ZE(e.id),s=PI(e.id);return i.jsxs("div",{onClick:()=>r(`/schedules/${e.id}`),className:"flex cursor-pointer items-center justify-between gap-3 rounded-lg border bg-card p-4 text-sm shadow-sm transition-colors hover:border-primary/50",children:[i.jsx("div",{className:"mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:i.jsx(hd,{className:"h-5 w-5 text-primary"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:e.name}),!e.enabled&&i.jsx(yi,{variant:"outline",className:"border-border px-1.5 py-0 text-[10px] uppercase text-muted-foreground",children:"Disabled"})]}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(hd,{className:"h-3.5 w-3.5"})," ",e.cadence]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:iN(e.model)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:sN(e.effort)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:gL(e.assignmentKind,e.teamName,e.agentName)})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",onClick:l=>l.stopPropagation(),children:[i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",title:e.starred?"Unstar":"Star",onClick:()=>a.mutate({starred:!e.starred}),children:i.jsx(yI,{className:Ee("h-4 w-4",e.starred?"fill-amber-400 text-amber-400":"text-muted-foreground")})}),i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",children:i.jsx(ma,{className:"h-4 w-4"})})}),i.jsxs(In,{align:"end",className:"w-40",children:[i.jsxs(ct,{onSelect:()=>a.mutate({enabled:!e.enabled}),children:[i.jsx(gI,{className:"mr-2 h-4 w-4"})," ",e.enabled?"Disable":"Enable"]}),i.jsx(sr,{}),i.jsxs(ct,{onSelect:t,children:[i.jsx(_r,{className:"mr-2 h-4 w-4"})," Edit"]}),i.jsxs(ct,{onSelect:()=>s.mutate(),children:[i.jsx(zo,{className:"mr-2 h-4 w-4"})," Run now"]}),i.jsx(sr,{}),i.jsxs(ct,{className:"text-red-400",onSelect:n,children:[i.jsx(Rr,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})]})]})}const pue=["minutes","hours","days"];function fue({onClose:e}){var D;const{data:t}=nh(),{data:n}=YE(),{activeId:r}=eo(),{data:a}=WE(r),{data:s}=qE(r),l=Z7(),[u,d]=E.useState(""),[p,m]=E.useState(""),[h,y]=E.useState("anyone"),[b,v]=E.useState(),[T,w]=E.useState(),[N,k]=E.useState(1),[A,_]=E.useState("hours"),[I,O]=E.useState(null),[R,F]=E.useState(null),[z,M]=E.useState(null),Q=E.useRef(null),Y=((D=t==null?void 0:t.find(U=>U.id===r))==null?void 0:D.workingDir)??"~",ae=I??Y,V=R??(n==null?void 0:n.defaultModel)??Vm,G=z??(n==null?void 0:n.defaultEffort)??Wm,te=`Every ${N} ${N===1?A.slice(0,-1):A}`,ue=h==="anyone"||h==="team"&&!!b||h==="agent"&&!!T,q=!!u.trim()&&!!p.trim()&&N>=1&&ue;async function H(){q&&(await l.mutateAsync({name:u.trim(),prompt:p.trim(),workspaceId:r,workingDir:ae,cadence:te,assignmentKind:h,teamId:h==="team"?b:void 0,agentId:h==="agent"?T:void 0,model:V,effort:G}),e())}return i.jsx(Ot,{open:!0,onOpenChange:U=>!U&&e(),children:i.jsxs(At,{className:"sm:max-w-4xl",children:[i.jsxs(_t,{children:[i.jsx(Rt,{children:"New schedule"}),i.jsx(Vt,{children:"Runs headless under the workspace, on the cadence — always autonomous."})]}),i.jsxs(Mt,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{htmlFor:"sc-name",children:"Name"}),i.jsx(ro,{id:"sc-name",autoFocus:!0,value:u,onChange:U=>d(U.target.value),maxLength:80,placeholder:"Triage new bugs"})]}),i.jsxs("div",{className:"grid grid-cols-[2fr_1fr] gap-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Prompt"}),i.jsx(pp,{value:p,onChange:m,maxLength:2e3,placeholder:"What should run each time?",helpText:"Markdown supported",height:340})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Working directory"}),i.jsx(Dx,{value:ae,onChange:O})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Model"}),i.jsx(Zo,{value:V,onChange:F,options:fp})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Effort"}),i.jsx(Zo,{value:G,onChange:M,options:mp})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(wt,{children:"Delegate to"}),i.jsxs(kr,{value:h,onValueChange:U=>{const Z=U;y(Z),(Z==="team"||Z==="agent")&&requestAnimationFrame(()=>{var j;return(j=Q.current)==null?void 0:j.focus()})},children:[i.jsx(dr,{children:i.jsx(Cr,{})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"anyone",children:"Anyone"}),i.jsx(Dt,{value:"team",children:"Team"}),i.jsx(Dt,{value:"agent",children:"Agent"})]})]}),i.jsxs(kr,{value:h==="team"?b:h==="agent"?T:void 0,onValueChange:U=>h==="team"?v(U):w(U),disabled:h==="anyone",children:[i.jsx(dr,{ref:Q,children:i.jsx(Cr,{placeholder:h==="team"?"Select a team":h==="agent"?"Select an agent":"No specific team or agent"})}),i.jsxs(pr,{children:[h==="team"&&(a==null?void 0:a.map(U=>i.jsx(Dt,{value:U.id,children:U.name},U.id))),h==="agent"&&(s==null?void 0:s.map(U=>i.jsx(Dt,{value:U.id,children:U.name},U.id)))]})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(wt,{children:"Cadence"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx(Cn,{type:"number",min:1,value:N,onChange:U=>k(Math.max(1,Number(U.target.value)||1)),className:"w-16"}),i.jsxs(kr,{value:A,onValueChange:U=>_(U),children:[i.jsx(dr,{className:"flex-1",children:i.jsx(Cr,{})}),i.jsx(pr,{children:pue.map(U=>i.jsx(Dt,{value:U,children:U},U))})]})]})]})]})]})]}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:e,children:"Cancel"}),i.jsxs(re,{disabled:!q||l.isPending,onClick:H,children:[l.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Create"]})]})]})})}const mue={running:{label:"Running",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},success:{label:"Success",className:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30"},failed:{label:"Failed",className:"bg-red-500/15 text-red-300 border-red-500/30"}};function hue(){var w,N;const{scheduleId:e}=Ru(),t=zn(),{data:n,isLoading:r}=Q7(e),a=PI(e),s=ZE(e),l=FI(),u=MI(e,0,1),[d,p]=E.useState(null),[m,h]=E.useState(!1),[y,b]=E.useState(!1);if(r||!n)return i.jsxs("div",{className:"p-6",children:[i.jsx(Dn,{className:"mb-4 h-6 w-24"}),i.jsx(Dn,{className:"mb-2 h-8 w-1/2"}),i.jsx(Dn,{className:"h-40 w-full"})]});const v=(N=(w=u.data)==null?void 0:w.runs)==null?void 0:N[0],T=d??"results";return i.jsxs("div",{className:"flex h-full flex-col p-6",children:[i.jsxs(Ar,{to:"/schedules",className:"mb-4 inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",children:[i.jsx(Zm,{className:"h-4 w-4"})," Schedules"]}),i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h1",{className:"text-2xl font-bold leading-tight tracking-tight",children:n.name}),!n.enabled&&i.jsx(yi,{variant:"outline",className:"border-border px-1.5 py-0 text-[10px] uppercase text-muted-foreground",children:"Disabled"})]}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(hd,{className:"h-3.5 w-3.5"})," ",n.cadence]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:iN(n.model)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:sN(n.effort)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:gL(n.assignmentKind,n.teamName,n.agentName)}),n.enabled&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsxs("span",{children:["next ",Gy(n.nextRunAt)]})]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsxs(re,{size:"sm",disabled:a.isPending,onClick:()=>a.mutate(),children:[a.isPending?i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"}):i.jsx(zo,{className:"mr-1 h-4 w-4"})," ","Run now"]}),i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",children:i.jsx(ma,{className:"h-4 w-4"})})}),i.jsxs(In,{align:"end",className:"w-40",children:[i.jsxs(ct,{onSelect:()=>s.mutate({enabled:!n.enabled}),children:[i.jsx(gI,{className:"mr-2 h-4 w-4"})," ",n.enabled?"Disable":"Enable"]}),i.jsx(sr,{}),i.jsxs(ct,{onSelect:()=>b(!0),children:[i.jsx(_r,{className:"mr-2 h-4 w-4"})," Edit"]}),i.jsx(sr,{}),i.jsxs(ct,{className:"text-red-400",onSelect:()=>h(!0),children:[i.jsx(Rr,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})]})]}),i.jsxs("div",{className:"mt-5 flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:"mb-3 flex shrink-0 gap-5 border-b",children:[i.jsx("button",{type:"button",onClick:()=>p("prompt"),className:Ca(T==="prompt"),children:"Prompt"}),i.jsx("button",{type:"button",onClick:()=>p("notes"),className:Ca(T==="notes"),children:"Notes"}),i.jsx("button",{type:"button",onClick:()=>p("results"),className:Ca(T==="results"),children:"Run results"}),i.jsx("button",{type:"button",onClick:()=>p("history"),className:Ca(T==="history"),children:"Run history"})]}),T==="notes"?i.jsx(hle,{parent:{kind:"schedule",id:n.id}}):i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[T==="prompt"&&i.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:n.prompt}),T==="results"&&(v?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsxs("span",{children:["Latest run · ",Gy(v.startedAt)]}),i.jsx(gue,{status:v.status}),v.model&&i.jsx(vg,{model:v.model,effort:v.effort})]}),i.jsx(wg,{text:n.prompt}),i.jsx(Sg,{text:v.output,divided:!0})]}):i.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 px-4 py-10 text-center text-sm text-muted-foreground",children:"No runs yet — “Run now” to fire this schedule."})),T==="history"&&i.jsx(bue,{scheduleId:n.id,prompt:n.prompt})]})]}),y&&i.jsx(wP,{schedule:n,onClose:()=>b(!1)}),i.jsx(Ot,{open:m,onOpenChange:h,children:i.jsxs(At,{className:"sm:max-w-md",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Delete schedule?"})}),i.jsx(Mt,{children:i.jsxs(Vt,{children:["“",n.name,"” and its run history will be permanently deleted. This can't be undone."]})}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),i.jsxs(re,{variant:"destructive",disabled:l.isPending,onClick:()=>l.mutate(n.id,{onSuccess:()=>t("/schedules")}),children:[l.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Delete"]})]})]})})]})}function gue({status:e}){const t=mue[e];return i.jsx(yi,{variant:"outline",className:Ee("px-1.5 py-0 text-[10px]",t.className),children:t.label})}function bue({scheduleId:e,prompt:t}){const[n,r]=E.useState(1),[a,s]=E.useState(8),[l,u]=E.useState(null),[d,p]=E.useState(null),{data:m,isFetching:h}=MI(e,(n-1)*a,a),y=m==null?void 0:m.runs,b=(m==null?void 0:m.total)??0;return!h&&b===0?i.jsx("div",{className:"rounded-lg border border-dashed bg-muted/20 px-4 py-10 text-center text-sm text-muted-foreground",children:"No runs yet — history appears here after this schedule fires."}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("p",{className:"text-sm text-muted-foreground",children:[b," ",b===1?"run":"runs"]}),i.jsx("div",{className:"flex flex-col gap-2",children:y==null?void 0:y.map(v=>i.jsxs("div",{onClick:()=>u(v),className:"group flex cursor-pointer items-center gap-3 rounded-lg border bg-card/50 p-3 text-sm transition-colors hover:border-primary/50",children:[i.jsx("span",{className:Ee("h-2 w-2 shrink-0 rounded-full",v.status==="success"?"bg-emerald-400":v.status==="failed"?"bg-red-400":"bg-amber-400"),title:v.status}),i.jsx("div",{className:"min-w-0 flex-1",children:i.jsx("span",{className:"text-foreground",children:new Date(v.startedAt).toLocaleString()})}),v.sessionId&&i.jsxs(re,{variant:"ghost",size:"sm",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:T=>{T.stopPropagation(),p(v)},title:"View the session terminal",children:[i.jsx(xu,{className:"mr-1 h-4 w-4"})," Terminal"]}),i.jsx(nl,{className:"h-4 w-4 shrink-0 text-muted-foreground/40 transition-colors group-hover:text-foreground"})]},v.id))}),b>0&&i.jsx(hp,{className:"border-t pt-4",currentPage:n,totalPages:Math.max(1,Math.ceil(b/a)),onPageChange:r,totalItems:b,itemsPerPage:a,pageSize:a,onPageSizeChange:v=>{s(v),r(1)},pageSizeOptions:[8,16,24]}),i.jsx(Ot,{open:!!l,onOpenChange:v=>!v&&u(null),children:i.jsxs(At,{className:"flex max-h-[85vh] flex-col sm:max-w-4xl",children:[i.jsxs(_t,{children:[i.jsx(Rt,{children:"Run detail"}),i.jsxs(Vt,{children:[l?new Date(l.startedAt).toLocaleString():"",(l==null?void 0:l.model)&&i.jsxs(i.Fragment,{children:[" · ",i.jsx(vg,{model:l.model,effort:l.effort})]})]})]}),i.jsx(Mt,{className:"min-h-0 flex-1 space-y-4 overflow-y-auto",children:l&&i.jsxs(i.Fragment,{children:[i.jsx(wg,{text:t}),i.jsx(Sg,{text:l.output,divided:!0})]})}),i.jsxs(Lt,{children:[(l==null?void 0:l.sessionId)&&i.jsxs(re,{variant:"outline",onClick:()=>{p(l),u(null)},children:[i.jsx(xu,{className:"mr-1 h-4 w-4"})," View Terminal"]}),i.jsx(re,{variant:"outline",onClick:()=>u(null),children:"Close"})]})]})}),(d==null?void 0:d.sessionId)&&i.jsx(oN,{sessionId:d.sessionId,running:!1,onClose:()=>p(null)})]})}const yue=[6,12,24];function Eue(){const{data:e,isLoading:t}=jI(),{activeId:n,active:r}=eo(),a=t9(),[s,l]=E.useState(null),[u,d]=E.useState(""),[p,m]=E.useState("all"),[h,y]=E.useState(1),[b,v]=E.useState(6);E.useEffect(()=>{y(1)},[u,p,n]);const T=u.trim()!==""||p!=="all",w=(e??[]).filter(O=>O.workspaceId===n),N=w.filter(O=>{if(p!=="all"&&O.status!==p)return!1;const R=u.trim().toLowerCase();return!(R&&!O.name.toLowerCase().includes(R))}),k=N.length,A=Math.max(1,Math.ceil(k/b)),_=N.slice((h-1)*b,h*b),I=k===1?"batch":"batches";return i.jsxs("div",{className:"p-6",children:[i.jsxs("header",{className:"mb-5 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Batches"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Press play on a set of assigned tickets and let them run unattended."})]}),i.jsx(re,{asChild:!0,children:i.jsxs(Ar,{to:"/board",children:[i.jsx(Ks,{className:"mr-1 h-4 w-4"})," New batch"]})})]}),i.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/30 px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(Ho,{className:"h-4 w-4"}),i.jsx("span",{children:"Filters"})]}),i.jsx("div",{className:"h-4 w-px bg-border"}),i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Bd,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),i.jsx(Cn,{type:"text",placeholder:"Search batches...",value:u,onChange:O=>d(O.target.value),className:"w-full pl-8"})]}),i.jsxs(kr,{value:p,onValueChange:O=>m(O),children:[i.jsx(dr,{className:"w-[150px]",children:i.jsx(Cr,{placeholder:"Status"})}),i.jsxs(pr,{children:[i.jsx(Dt,{value:"all",children:"Any Status"}),i.jsx(Dt,{value:"running",children:"Running"}),i.jsx(Dt,{value:"queued",children:"Queued"}),i.jsx(Dt,{value:"paused",children:"Paused"}),i.jsx(Dt,{value:"done",children:"Done"}),i.jsx(Dt,{value:"idle",children:"Idle"})]})]})]}),!t&&k>0&&i.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:T?`${k} ${I} matching filters`:`${k} ${I}`}),i.jsx("div",{className:"flex flex-col gap-2",children:t?[0,1].map(O=>i.jsx(Dn,{className:"h-20 w-full"},O)):w.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(Ks,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsxs("p",{className:"text-sm font-medium",children:["No batches in ",(r==null?void 0:r.name)??"this workspace"," yet"]}),i.jsxs("p",{className:"mb-4 max-w-sm text-sm text-muted-foreground",children:["Open a board, hit ",i.jsx("span",{className:"font-medium",children:"Select"}),", tick the assigned tickets you want to run together, then create a batch."]}),i.jsx(re,{asChild:!0,size:"sm",variant:"secondary",children:i.jsx(Ar,{to:"/board",children:"Go to a board"})})]}):k===0?i.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed bg-card py-16 text-center",children:[i.jsx(Ho,{className:"mb-3 h-8 w-8 text-muted-foreground"}),i.jsx("p",{className:"text-sm font-medium",children:"No batches match your filters"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Try adjusting or clearing the filters above."})]}):_.map(O=>i.jsx(xue,{batch:O,onDelete:()=>l(O)},O.id))}),!t&&k>0&&i.jsx(hp,{className:"mt-4 border-t pt-4",currentPage:h,totalPages:A,onPageChange:y,totalItems:k,itemsPerPage:b,pageSize:b,onPageSizeChange:O=>{v(O),y(1)},pageSizeOptions:yue}),i.jsx(Ot,{open:!!s,onOpenChange:O=>!O&&l(null),children:i.jsxs(At,{className:"sm:max-w-md",children:[i.jsx(_t,{children:i.jsx(Rt,{children:"Delete batch?"})}),i.jsx(Mt,{children:i.jsxs(Vt,{children:["“",s==null?void 0:s.name,"” will be deleted. The tickets and their runs are untouched — only the batch grouping goes away."]})}),i.jsxs(Lt,{children:[i.jsx(re,{variant:"ghost",onClick:()=>l(null),children:"Cancel"}),i.jsxs(re,{variant:"destructive",disabled:a.isPending,onClick:()=>s&&a.mutate(s.id,{onSuccess:()=>l(null)}),children:[a.isPending&&i.jsx(Ye,{className:"mr-1 h-4 w-4 animate-spin"})," ","Delete"]})]})]})})]})}function xue({batch:e,onDelete:t}){const n=zn(),r=BI(e.id),a=UI(e.id),s=HI(e.id),l=hL(e.status),u=e.ticketIds.length,d=r.isPending||a.isPending||s.isPending;return i.jsxs("div",{onClick:()=>n(`/batches/${e.id}`),className:Ee("flex cursor-pointer items-center justify-between gap-3 rounded-lg border bg-card p-4 text-sm shadow-sm transition-colors hover:border-primary/50",e.status==="running"&&"batch-racing",e.status==="queued"&&"batch-waiting"),children:[i.jsx("div",{className:"mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:i.jsx(Ks,{className:"h-5 w-5 text-primary"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"truncate font-medium",children:e.name}),i.jsx(yi,{variant:"outline",className:Ee("px-1.5 py-0 text-[10px] uppercase",l.className),children:l.label})]}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[i.jsxs("span",{children:[u," ",u===1?"ticket":"tickets"]}),i.jsx("span",{children:"·"}),i.jsx("span",{children:e.mode==="ordered"?"Ordered":"Unordered"}),e.pausedReason&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsx("span",{className:"text-amber-300/90",children:e.pausedReason})]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",onClick:p=>p.stopPropagation(),children:[e.status==="running"?i.jsxs(re,{size:"sm",variant:"secondary",disabled:d,onClick:()=>a.mutate(),children:[i.jsx(xm,{className:"mr-1 h-4 w-4"})," Pause"]}):e.status!=="done"&&i.jsxs(re,{size:"sm",disabled:d||e.status==="queued",onClick:()=>r.mutate(),children:[i.jsx(zo,{className:"mr-1 h-4 w-4"})," ",e.status==="paused"?"Resume":"Play"]}),i.jsxs(jn,{children:[i.jsx(Bn,{asChild:!0,children:i.jsx(re,{size:"icon",variant:"ghost",className:"h-8 w-8",children:i.jsx(ma,{className:"h-4 w-4"})})}),i.jsxs(In,{align:"end",className:"w-40",children:[(e.status==="running"||e.status==="paused"||e.status==="queued")&&i.jsxs(ct,{onSelect:()=>s.mutate(),children:[i.jsx(GE,{className:"mr-2 h-4 w-4"})," Stop"]}),i.jsx(sr,{}),i.jsxs(ct,{className:"text-red-400",disabled:e.status==="running",onSelect:t,children:[i.jsx(Rr,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})]})]})}function vue(e){switch(e){case"done":return{label:"Done",className:"border-green-500/40 bg-green-500/15 text-green-300",icon:jE};case"running":return{label:"Running",className:"border-sky-500/40 bg-sky-500/15 text-sky-300",icon:Ye};case"blocked":return{label:"Blocked",className:"border-red-500/40 bg-red-500/15 text-red-300",icon:NA};case"failed":return{label:"Failed",className:"border-red-500/40 bg-red-500/15 text-red-300",icon:NA};case"waiting":return{label:"Waiting",className:"border-amber-500/40 bg-amber-500/15 text-amber-300",icon:$o};default:return{label:"Queued",className:"border-border bg-muted text-muted-foreground",icon:LB}}}function wue(){const{batchId:e=""}=Ru(),t=zn(),{data:n,isLoading:r}=J7(e),a=BI(e),s=UI(e),l=HI(e);if(r||!n)return i.jsxs("div",{className:"mx-auto max-w-4xl space-y-4 p-6",children:[i.jsx(Dn,{className:"h-9 w-64"}),i.jsx(Dn,{className:"h-40 w-full"})]});const{batch:u,tickets:d}=n,p=hL(u.status),m=a.isPending||s.isPending||l.isPending,h=d.filter(b=>b.state==="done").length,y=d.length;return i.jsxs("div",{className:"mx-auto max-w-4xl p-6",children:[i.jsxs("button",{onClick:()=>t("/batches"),className:"mb-4 flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(Zm,{className:"h-4 w-4"})," Batches"]}),i.jsxs("header",{className:"mb-5 flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[i.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:i.jsx(Ks,{className:"h-6 w-6 text-primary"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h1",{className:"truncate text-2xl font-bold tracking-tight",children:u.name}),i.jsx(yi,{variant:"outline",className:Ee("px-1.5 py-0 text-[10px] uppercase",p.className),children:p.label})]}),i.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[u.mode==="ordered"?"Ordered":"Unordered"," · ",h,"/",y," done · ",u.workspaceName,u.budgetCap!=null&&` · cap ${u.budgetCap} runs`]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[u.status==="running"?i.jsxs(re,{variant:"secondary",disabled:m,onClick:()=>s.mutate(),children:[i.jsx(xm,{className:"mr-1 h-4 w-4"})," Pause"]}):u.status!=="done"&&i.jsxs(re,{disabled:m||u.status==="queued",onClick:()=>a.mutate(),children:[i.jsx(zo,{className:"mr-1 h-4 w-4"})," ",u.status==="paused"?"Resume":"Play"]}),(u.status==="running"||u.status==="paused"||u.status==="queued")&&i.jsxs(re,{variant:"ghost",disabled:m,onClick:()=>l.mutate(),children:[i.jsx(GE,{className:"mr-1 h-4 w-4"})," Stop"]})]})]}),u.pausedReason&&i.jsxs("div",{className:"mb-4 flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-200",children:[i.jsx(xm,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{children:u.pausedReason})]}),i.jsx("div",{className:"flex flex-col gap-2",children:d.map(b=>i.jsx(Sue,{member:b,members:d},b.ticketId))})]})}function Sue({member:e,members:t}){const n=zn(),r=vue(e.state),a=r.icon,s=e.unmetDeps.map(l=>{var u;return((u=t.find(d=>d.ticketId===l))==null?void 0:u.externalIdentifier)??l});return i.jsxs("div",{onClick:()=>n(`/tickets/${e.ticketId}`),className:"flex cursor-pointer items-center justify-between gap-3 rounded-lg border bg-card p-3 text-sm shadow-sm transition-colors hover:border-primary/50",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i.jsx("span",{className:Ee("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",r.className),children:i.jsx(a,{className:Ee("h-4 w-4",e.state==="running"&&"animate-spin")})}),i.jsxs("div",{className:"min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.externalIdentifier}),i.jsx("span",{className:"truncate font-medium",children:e.title})]}),s.length>0&&i.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs text-amber-300/90",children:[i.jsx($o,{className:"h-3 w-3"})," waiting on ",s.join(", ")]})]})]}),i.jsx(yi,{variant:"outline",className:Ee("shrink-0 px-1.5 py-0 text-[10px] uppercase",r.className),children:r.label})]})}const Tue=eB([{path:"/",element:i.jsx(jV,{}),children:[{index:!0,element:i.jsx(Ay,{to:"/board",replace:!0})},{path:"board",element:i.jsx(Q2,{})},{path:"board/:connectionId",element:i.jsx(Q2,{})},{path:"tickets/:ticketId",element:i.jsx(Nle,{})},{path:"schedules",element:i.jsx(cue,{})},{path:"schedules/:scheduleId",element:i.jsx(hue,{})},{path:"batches",element:i.jsx(Eue,{})},{path:"batches/:batchId",element:i.jsx(wue,{})},{path:"chat",element:i.jsx(Vle,{})},{path:"chat/new",element:i.jsx(lR,{})},{path:"chat/:conversationId",element:i.jsx(lR,{})},{path:"docs",element:i.jsx(cR,{})},{path:"docs/:slug",element:i.jsx(cR,{})},{path:"settings",element:i.jsx(Lle,{}),children:[{index:!0,element:i.jsx(Ple,{})},{path:"workspaces",element:i.jsx(Fle,{})},{path:"presets",element:i.jsx(Ble,{})},{path:"connections",element:i.jsx(ele,{})},{path:"api",element:i.jsx(Hle,{})},{path:"webhooks",element:i.jsx(zle,{})}]},{path:"connections",element:i.jsx(Ay,{to:"/settings/connections",replace:!0})}]}]),dR=1024;function Nue(e){const[t,n]=E.useState(()=>typeof window>"u"?!0:window.matchMedia(`(min-width: ${e}px)`).matches);return E.useEffect(()=>{const r=window.matchMedia(`(min-width: ${e}px)`),a=()=>n(r.matches);return a(),r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}function kue({children:e}){return Nue(dR)?i.jsx(i.Fragment,{children:e}):i.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-background p-8 text-center text-foreground",children:[i.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-muted",children:i.jsx(hI,{className:"h-7 w-7 text-muted-foreground"})}),i.jsx("h1",{className:"text-xl font-semibold",children:"Window too small"}),i.jsxs("p",{className:"max-w-sm text-sm text-muted-foreground",children:["SuperClawd Pipelines needs a window at least ",dR,"px wide. Widen or maximize this window to continue."]})]})}const Cue=new F5({defaultOptions:{queries:{retry:!1}}});f5.createRoot(document.getElementById("root")).render(i.jsx(pn.StrictMode,{children:i.jsx(j5,{client:Cue,children:i.jsx(kue,{children:i.jsx(fB,{router:Tue})})})}));
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>SuperClawd Pipelines</title>
8
- <script type="module" crossorigin src="/assets/index-td0tE559.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-QRKtRqMB.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BVV6Acjd.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superclawd-ai/pipelines",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "Turn your board into an autonomous pipeline — a local, opt-in SuperClawd extension that runs your own Claude on your tickets and opens PRs for review.",
6
6
  "author": "SuperClawd <support@superclawd.com>",