@tickernelz/paperclip-pro-ui 2026.1009.1 → 2026.1009.3

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.
Files changed (58) hide show
  1. package/dist/assets/{AgentAvatar-CowKoklf.js → AgentAvatar-Jt6HpvU2.js} +1 -1
  2. package/dist/assets/{AgentIdentity-B0GifyUo.js → AgentIdentity-2cID8kur.js} +1 -1
  3. package/dist/assets/{Agents.production-FaM4wpTS.js → Agents.production-BDrotnkr.js} +2 -2
  4. package/dist/assets/{CompanyActivity.production-BcH-cmKg.js → CompanyActivity.production-DVFoP5Wf.js} +1 -1
  5. package/dist/assets/{CompanyExport-E9rrQ06I.js → CompanyExport-CbGWtqna.js} +1 -1
  6. package/dist/assets/{CompanySkills.production-CZdyIGAh.js → CompanySkills.production-DTqClYmE.js} +1 -1
  7. package/dist/assets/{Costs.production-DVpc3sPN.js → Costs.production-ClgsqTtT.js} +1 -1
  8. package/dist/assets/{EmptyState-B54qBJdG.js → EmptyState-B1JSbXSE.js} +1 -1
  9. package/dist/assets/MarkdownBody-CvvH69j_.js +16 -0
  10. package/dist/assets/{MarkdownEditor-Dkh_ud4t.js → MarkdownEditor-DCE_KC27.js} +7 -7
  11. package/dist/assets/{OrgChart.production-BVyu-TT-.js → OrgChart.production-D8k1dx4P.js} +1 -1
  12. package/dist/assets/{PageSkeleton-DOrN07nB.js → PageSkeleton-BmmfQJ6g.js} +1 -1
  13. package/dist/assets/{RoutineDetail.production-DfjhhWSv.js → RoutineDetail.production-BLcjq7J0.js} +1 -1
  14. package/dist/assets/{RoutineRunVariablesDialog-wvsgUi5R.js → RoutineRunVariablesDialog-C-j5V71-.js} +1 -1
  15. package/dist/assets/{Routines.production-DdwLEgVn.js → Routines.production-CrrER4oK.js} +1 -1
  16. package/dist/assets/{SidebarContext-e0rNi3On.js → SidebarContext-BguZPmI9.js} +1 -1
  17. package/dist/assets/{StatusIcon-CJevr908.js → StatusIcon-BCy8D6Fj.js} +1 -1
  18. package/dist/assets/{agent-avatar-url-BgtuDQuJ.js → agent-avatar-url-DtOIjE-b.js} +1 -1
  19. package/dist/assets/{agents-BqHpxyXa.js → agents-DA5qW1fs.js} +1 -1
  20. package/dist/assets/{badge-B1opbM2C.js → badge-DEcdN2HY.js} +1 -1
  21. package/dist/assets/{bot-COgMVxie.js → bot-S2JV9WBV.js} +1 -1
  22. package/dist/assets/{boxes-CmvDVxbq.js → boxes-CeCVqNtb.js} +1 -1
  23. package/dist/assets/{button-CiCWqyHT.js → button-yf2m1_gs.js} +1 -1
  24. package/dist/assets/{card-sHXnFZQl.js → card-Cl_LFk7c.js} +1 -1
  25. package/dist/assets/{check-Co2tYHc6.js → check-xeGJ2HPN.js} +1 -1
  26. package/dist/assets/{checkbox-DxzcpGzB.js → checkbox-CIcktoHJ.js} +1 -1
  27. package/dist/assets/{chevron-down-iZ-OPfMP.js → chevron-down-CZ7qFy9y.js} +1 -1
  28. package/dist/assets/{chevron-right-C2GZk5mS.js → chevron-right-D0Hti4WB.js} +1 -1
  29. package/dist/assets/{clipboard-Ch2RFnBG.js → clipboard-NgncerTn.js} +1 -1
  30. package/dist/assets/{company-members-BJTKKG75.js → company-members-CDG03HZV.js} +1 -1
  31. package/dist/assets/{definition-BXj7kCHc.js → definition-D733B7hW.js} +1 -1
  32. package/dist/assets/{dist-CgrzrDl3.js → dist-B6HyW9be.js} +1 -1
  33. package/dist/assets/{dist-CcAKjIy0.js → dist-BAFQ8Oiq.js} +1 -1
  34. package/dist/assets/{environments-CrkAniLn.js → environments-BT_uDOM8.js} +1 -1
  35. package/dist/assets/{external-link-DO6q0R3l.js → external-link-CjUn0PMx.js} +1 -1
  36. package/dist/assets/{file-text-DPKvkhqC.js → file-text-D87G0ZiA.js} +1 -1
  37. package/dist/assets/{health-DJWMhATw.js → health-k3cyi4s3.js} +1 -1
  38. package/dist/assets/{heartbeats-BIzk9_-_.js → heartbeats-DeXOtSp3.js} +1 -1
  39. package/dist/assets/{index-iLdUWxoA.js → index-aJuthquM.js} +153 -153
  40. package/dist/assets/{input-C5_FG4bG.js → input-DnT08BOo.js} +1 -1
  41. package/dist/assets/{label-LNcfjNUd.js → label-DSx2Qxn6.js} +1 -1
  42. package/dist/assets/{loader-circle-ClbceUoH.js → loader-circle-DSiPgghG.js} +1 -1
  43. package/dist/assets/{mention-chips-DaQB1XXn.js → mention-chips-OAQdMAP9.js} +2 -2
  44. package/dist/assets/{octagon-alert-DvPiKDSj.js → octagon-alert-BbqyswZU.js} +1 -1
  45. package/dist/assets/{rotate-ccw-CnVoQJ8c.js → rotate-ccw-Du0rX6yB.js} +1 -1
  46. package/dist/assets/{router-7hDvVKpK.js → router-CoeH24PK.js} +2 -2
  47. package/dist/assets/{save-C8Purtgn.js → save-d5benU21.js} +1 -1
  48. package/dist/assets/{select-B_zFVzlA.js → select-DarpvIBM.js} +1 -1
  49. package/dist/assets/{sheet-Xthrybbp.js → sheet-_VebRl9q.js} +1 -1
  50. package/dist/assets/{skeleton-CYpNbxbP.js → skeleton-BY2fv9gX.js} +1 -1
  51. package/dist/assets/{tabs-DGoH6b9z.js → tabs-BfWJYNcW.js} +1 -1
  52. package/dist/assets/{triangle-alert-gvuERj81.js → triangle-alert-VjOLPhJL.js} +1 -1
  53. package/dist/assets/{use-adapter-capabilities-BwZhnyTf.js → use-adapter-capabilities-CI0JeLXc.js} +1 -1
  54. package/dist/assets/{useHiddenSettings-pmha2KHR.js → useHiddenSettings-BpAre2Wp.js} +1 -1
  55. package/dist/index.html +45 -45
  56. package/dist/sw.js +1 -1
  57. package/package.json +1 -1
  58. package/dist/assets/MarkdownBody-C7RW4IEj.js +0 -16
@@ -1 +1 @@
1
- var pt=Object.defineProperty;var u=(e,a)=>pt(e,"name",{value:a,configurable:!0});import{i as ot}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as yt,Li as bt,W as vt,Z as K,_ as wt,ni as Q,vr as Ct}from"./agent-avatar-url-BgtuDQuJ.js";import{o as jt,t as V}from"./router-7hDvVKpK.js";import{t as Mt}from"./AgentAvatar-CowKoklf.js";import{t as J}from"./agents-BqHpxyXa.js";import{r as Nt,t as tt}from"./EmptyState-B54qBJdG.js";import{k as kt,t as et}from"./button-CiCWqyHT.js";import{n as Pt,t as Dt}from"./useHiddenSettings-pmha2KHR.js";import{t as Zt}from"./card-sHXnFZQl.js";import{t as _t}from"./PageSkeleton-DOrN07nB.js";import{An as Tt,In as Yt,Zt as Et,_n as Xt,kn as rt,nn as zt}from"./index-iLdUWxoA.js";var o=ot(bt(),1),n=ot(yt(),1),N=200,$=100,X=32,Wt=80,L=60,$t=.2,Lt=2,H=6;function _(e){if(e.reports.length===0)return N;const a=e.reports.reduce((i,f)=>i+_(f),0),d=(e.reports.length-1)*X;return Math.max(N,a+d)}u(_,"subtreeWidth");function at(e,a,d){const i=_(e),f=[];if(e.reports.length>0){const C=e.reports.reduce((k,P)=>k+_(P),0),S=(e.reports.length-1)*X;let j=a+(i-C-S)/2;for(const k of e.reports){const P=_(k);f.push(at(k,j,d+$+Wt)),j+=P+X}}return{id:e.id,name:e.name,role:e.role,status:e.status,x:a+(i-N)/2,y:d,children:f}}u(at,"layoutTree");function St(e){if(e.length===0)return[];e.reduce((f,C)=>f+_(C),0),(e.length-1)*X;let a=L;const d=L,i=[];for(const f of e){const C=_(f);i.push(at(f,a,d)),a+=C+X}return i}u(St,"layoutForest");function At(e){const a=[];function d(i){a.push(i),i.children.forEach(d)}return u(d,"walk"),e.forEach(d),a}u(At,"flattenLayout");function Ht(e){const a=[];function d(i){for(const f of i.children)a.push({parent:i,child:f}),d(f)}return u(d,"walk"),e.forEach(d),a}u(Ht,"collectEdges");function R(e){return Math.min(Math.max(e,$t),Lt)}u(R,"clampZoom");function Rt(e){return{x:e.clientX,y:e.clientY}}u(Rt,"touchPoint");function nt(e,a){const d=e.clientX-a.clientX,i=e.clientY-a.clientY;return Math.hypot(d,i)}u(nt,"touchDistance");function st(e,a,d){const i=d.getBoundingClientRect();return{x:(e.clientX+a.clientX)/2-i.left,y:(e.clientY+a.clientY)/2-i.top}}u(st,"touchCenter");var Ot={running:"var(--hex-22d3ee)",active:"var(--hex-4ade80)",paused:"var(--hex-facc15)",idle:"var(--hex-facc15)",error:"var(--hex-f87171)",terminated:"var(--hex-a3a3a3)"},Bt="var(--hex-a3a3a3)";function oe(){const{selectedCompanyId:e}=vt(),{setBreadcrumbs:a}=Nt(),d=jt(),i=!!zt(),{hidden:f}=Dt(),C=!i&&!f.has("company.import"),S=!f.has("company.export"),{data:j,isLoading:k}=Q({queryKey:K.org(e),queryFn:u(()=>J.org(e),"queryFn"),enabled:!!e}),{data:P}=Q({queryKey:K.agents.list(e),queryFn:u(()=>J.list(e),"queryFn"),enabled:!!e}),ct=(0,o.useMemo)(()=>{const t=new Map;for(const r of P??[])t.set(r.id,r);return t},[P]);(0,o.useEffect)(()=>{a([{label:"Org Chart"}])},[a]);const z=(0,o.useMemo)(()=>St(j??[]),[j]),D=(0,o.useMemo)(()=>At(z),[z]),it=(0,o.useMemo)(()=>Ht(z),[z]),v=(0,o.useMemo)(()=>{if(D.length===0)return{width:800,height:600};let t=0,r=0;for(const s of D)t=Math.max(t,s.x+N),r=Math.max(r,s.y+$);return{width:t+L,height:r+L}},[D]),p=(0,o.useRef)(null),[l,M]=(0,o.useState)({x:0,y:0}),[h,T]=(0,o.useState)(1),[A,O]=(0,o.useState)(!1),Y=(0,o.useRef)({x:0,y:0,panX:0,panY:0}),m=(0,o.useRef)({mode:null,startPoint:{x:0,y:0},startPan:{x:0,y:0},startZoom:1,startDistance:0,startCenter:{x:0,y:0},moved:!1}),W=(0,o.useRef)(!1),Z=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{Z.current!==null&&window.clearTimeout(Z.current)},[]);const B=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(B.current||D.length===0||!p.current)return;B.current=!0;const t=p.current,r=t.clientWidth,s=t.clientHeight,c=(r-40)/v.width,x=(s-40)/v.height,g=Math.min(c,x,1),y=v.width*g,w=v.height*g;T(g),M({x:(r-y)/2,y:(s-w)/2})},[D,v]);const lt=(0,o.useCallback)(t=>{t.button===0&&(t.target.closest("[data-org-card]")||(O(!0),Y.current={x:t.clientX,y:t.clientY,panX:l.x,panY:l.y}))},[l]),ut=(0,o.useCallback)(t=>{if(!A)return;const r=t.clientX-Y.current.x,s=t.clientY-Y.current.y;M({x:Y.current.panX+r,y:Y.current.panY+s})},[A]),I=(0,o.useCallback)(()=>{O(!1)},[]),dt=(0,o.useCallback)(t=>{t.preventDefault();const r=p.current;if(!r)return;const s=r.getBoundingClientRect(),c=t.clientX-s.left,x=t.clientY-s.top,g=t.deltaY<0?1.1:.9,y=R(h*g),w=y/h;M({x:c-w*(c-l.x),y:x-w*(x-l.y)}),T(y)},[h,l]),q=(0,o.useCallback)((t,r)=>{const s=R(t),c=s/h;M({x:r.x-c*(r.x-l.x),y:r.y-c*(r.y-l.y)}),T(s)},[h,l]),ht=(0,o.useCallback)(()=>{if(!p.current)return;const t=p.current.clientWidth,r=p.current.clientHeight,s=(t-40)/v.width,c=(r-40)/v.height,x=Math.min(s,c,1),g=v.width*x,y=v.height*x;T(x),M({x:(t-g)/2,y:(r-y)/2})},[v]),mt=(0,o.useCallback)(t=>{if(t.touches.length>=2&&p.current){const[s,c]=[t.touches[0],t.touches[1]];m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:nt(s,c),startCenter:st(s,c,p.current),moved:!1};return}const r=t.touches[0];r&&(m.current={mode:"pan",startPoint:Rt(r),startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1})},[l,h]),ft=(0,o.useCallback)(t=>{const r=p.current;if(!r||!m.current.mode)return;if(t.touches.length>=2){const[g,y]=[t.touches[0],t.touches[1]],w=nt(g,y),E=st(g,y,r);if(m.current.mode!=="pinch"||m.current.startDistance===0){m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:w,startCenter:E,moved:!1};return}const b=m.current,G=R(b.startZoom*(w/b.startDistance)),U=G/b.startZoom,xt=E.x-b.startCenter.x,gt=E.y-b.startCenter.y;b.moved=b.moved||Math.abs(w-b.startDistance)>H||Math.hypot(xt,gt)>H,T(G),M({x:E.x-U*(b.startCenter.x-b.startPan.x),y:E.y-U*(b.startCenter.y-b.startPan.y)});return}const s=t.touches[0];if(!s||m.current.mode!=="pan")return;const c=s.clientX-m.current.startPoint.x,x=s.clientY-m.current.startPoint.y;m.current.moved=m.current.moved||Math.hypot(c,x)>H,M({x:m.current.startPan.x+c,y:m.current.startPan.y+x})},[l,h]),F=(0,o.useCallback)(()=>{m.current.moved&&(W.current=!0,Z.current!==null&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{W.current=!1,Z.current=null},400)),m.current={mode:null,startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1}},[l,h]);return e?k?(0,n.jsx)(_t,{variant:"org-chart"}):j&&j.length===0?(0,n.jsx)(tt,{icon:rt,message:"No organizational hierarchy defined."}):(0,n.jsxs)("div",{className:"flex h-(--sz-calc-38) min-h-(--sz-420px) flex-col md:h-full md:min-h-0",children:[(0,n.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center justify-start gap-2",children:[C&&(0,n.jsx)(V,{to:"/company/import",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Import company"]})}),S&&(0,n.jsx)(V,{to:"/company/export",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(Yt,{className:"mr-1.5 h-3.5 w-3.5"}),"Export company"]})})]}),(0,n.jsxs)("div",{ref:p,"data-testid":"org-chart-viewport",className:"w-full flex-1 min-h-0 overflow-hidden relative bg-muted/20 border border-border rounded-lg",style:{cursor:A?"grabbing":"grab",touchAction:"none",overscrollBehavior:"contain"},onMouseDown:lt,onMouseMove:ut,onMouseUp:I,onMouseLeave:I,onWheel:dt,onTouchStart:mt,onTouchMove:ft,onTouchEnd:F,onTouchCancel:F,children:[(0,n.jsxs)("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&q(h*1.2,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom in","aria-label":"Zoom in",children:(0,n.jsx)(kt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&q(h*.8,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom out","aria-label":"Zoom out",children:(0,n.jsx)(Pt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-(length:--text-nano) transition-colors hover:bg-accent sm:size-7",onClick:ht,title:"Fit to screen","aria-label":"Fit chart to screen",children:(0,n.jsx)(Tt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]}),(0,n.jsx)("svg",{className:"absolute inset-0 pointer-events-none",style:{width:"100%",height:"100%"},children:(0,n.jsx)("g",{transform:`translate(${l.x}, ${l.y}) scale(${h})`,children:it.map(({parent:t,child:r})=>{const s=t.x+N/2,c=t.y+$,x=r.x+N/2,g=r.y,y=(c+g)/2;return(0,n.jsx)("path",{d:`M ${s} ${c} L ${s} ${y} L ${x} ${y} L ${x} ${g}`,fill:"none",stroke:"var(--border)",strokeWidth:1.5},`${t.id}-${r.id}`)})})}),(0,n.jsx)("div",{"data-testid":"org-chart-card-layer",className:"absolute inset-0",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${h})`,transformOrigin:"0 0"},children:D.map(t=>{const r=ct.get(t.id),s=Ot[t.status]??Bt;return(0,n.jsx)(Zt,{"data-org-card":!0,className:"block absolute py-0 hover:shadow-md hover:border-foreground/20 transition-(--tp-box-shadow-border-color) duration-150 cursor-pointer select-none",style:{left:t.x,top:t.y,width:N,minHeight:$},onClick:u(()=>d(r?wt(r):`/agents/${t.id}`),"onClick"),onClickCapture:u(c=>{W.current&&(W.current=!1,c.preventDefault(),c.stopPropagation())},"onClickCapture"),children:(0,n.jsxs)("div",{className:"flex items-center px-4 py-3 gap-3",children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center",children:(0,n.jsx)(Mt,{agent:r,size:16,className:"h-4.5 w-4.5 text-foreground/70"})}),(0,n.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card",style:{backgroundColor:s}})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight",children:t.name}),(0,n.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground leading-tight mt-0.5",children:r?.title??qt(t.role)}),r&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/60 font-mono leading-tight mt-1",children:Et(r.adapterType)}),r&&r.capabilities&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/80 leading-tight mt-1 line-clamp-2",children:r.capabilities})]})]})},t.id)})})]})]}):(0,n.jsx)(tt,{icon:rt,message:"Select a company to view the org chart."})}u(oe,"OrgChart");var It=Ct;function qt(e){return It[e]??e}u(qt,"roleLabel");export{oe as OrgChart};
1
+ var pt=Object.defineProperty;var u=(e,a)=>pt(e,"name",{value:a,configurable:!0});import{i as ot}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as yt,Li as bt,W as vt,Z as K,_ as wt,ni as Q,vr as Ct}from"./agent-avatar-url-DtOIjE-b.js";import{o as jt,t as V}from"./router-CoeH24PK.js";import{t as Mt}from"./AgentAvatar-Jt6HpvU2.js";import{t as J}from"./agents-DA5qW1fs.js";import{r as Nt,t as tt}from"./EmptyState-B1JSbXSE.js";import{k as kt,t as et}from"./button-yf2m1_gs.js";import{n as Pt,t as Dt}from"./useHiddenSettings-BpAre2Wp.js";import{t as Zt}from"./card-Cl_LFk7c.js";import{t as _t}from"./PageSkeleton-BmmfQJ6g.js";import{An as Tt,In as Yt,Zt as Et,_n as Xt,kn as rt,nn as zt}from"./index-aJuthquM.js";var o=ot(bt(),1),n=ot(yt(),1),N=200,$=100,X=32,Wt=80,L=60,$t=.2,Lt=2,H=6;function _(e){if(e.reports.length===0)return N;const a=e.reports.reduce((i,f)=>i+_(f),0),d=(e.reports.length-1)*X;return Math.max(N,a+d)}u(_,"subtreeWidth");function at(e,a,d){const i=_(e),f=[];if(e.reports.length>0){const C=e.reports.reduce((k,P)=>k+_(P),0),S=(e.reports.length-1)*X;let j=a+(i-C-S)/2;for(const k of e.reports){const P=_(k);f.push(at(k,j,d+$+Wt)),j+=P+X}}return{id:e.id,name:e.name,role:e.role,status:e.status,x:a+(i-N)/2,y:d,children:f}}u(at,"layoutTree");function St(e){if(e.length===0)return[];e.reduce((f,C)=>f+_(C),0),(e.length-1)*X;let a=L;const d=L,i=[];for(const f of e){const C=_(f);i.push(at(f,a,d)),a+=C+X}return i}u(St,"layoutForest");function At(e){const a=[];function d(i){a.push(i),i.children.forEach(d)}return u(d,"walk"),e.forEach(d),a}u(At,"flattenLayout");function Ht(e){const a=[];function d(i){for(const f of i.children)a.push({parent:i,child:f}),d(f)}return u(d,"walk"),e.forEach(d),a}u(Ht,"collectEdges");function R(e){return Math.min(Math.max(e,$t),Lt)}u(R,"clampZoom");function Rt(e){return{x:e.clientX,y:e.clientY}}u(Rt,"touchPoint");function nt(e,a){const d=e.clientX-a.clientX,i=e.clientY-a.clientY;return Math.hypot(d,i)}u(nt,"touchDistance");function st(e,a,d){const i=d.getBoundingClientRect();return{x:(e.clientX+a.clientX)/2-i.left,y:(e.clientY+a.clientY)/2-i.top}}u(st,"touchCenter");var Ot={running:"var(--hex-22d3ee)",active:"var(--hex-4ade80)",paused:"var(--hex-facc15)",idle:"var(--hex-facc15)",error:"var(--hex-f87171)",terminated:"var(--hex-a3a3a3)"},Bt="var(--hex-a3a3a3)";function oe(){const{selectedCompanyId:e}=vt(),{setBreadcrumbs:a}=Nt(),d=jt(),i=!!zt(),{hidden:f}=Dt(),C=!i&&!f.has("company.import"),S=!f.has("company.export"),{data:j,isLoading:k}=Q({queryKey:K.org(e),queryFn:u(()=>J.org(e),"queryFn"),enabled:!!e}),{data:P}=Q({queryKey:K.agents.list(e),queryFn:u(()=>J.list(e),"queryFn"),enabled:!!e}),ct=(0,o.useMemo)(()=>{const t=new Map;for(const r of P??[])t.set(r.id,r);return t},[P]);(0,o.useEffect)(()=>{a([{label:"Org Chart"}])},[a]);const z=(0,o.useMemo)(()=>St(j??[]),[j]),D=(0,o.useMemo)(()=>At(z),[z]),it=(0,o.useMemo)(()=>Ht(z),[z]),v=(0,o.useMemo)(()=>{if(D.length===0)return{width:800,height:600};let t=0,r=0;for(const s of D)t=Math.max(t,s.x+N),r=Math.max(r,s.y+$);return{width:t+L,height:r+L}},[D]),p=(0,o.useRef)(null),[l,M]=(0,o.useState)({x:0,y:0}),[h,T]=(0,o.useState)(1),[A,O]=(0,o.useState)(!1),Y=(0,o.useRef)({x:0,y:0,panX:0,panY:0}),m=(0,o.useRef)({mode:null,startPoint:{x:0,y:0},startPan:{x:0,y:0},startZoom:1,startDistance:0,startCenter:{x:0,y:0},moved:!1}),W=(0,o.useRef)(!1),Z=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{Z.current!==null&&window.clearTimeout(Z.current)},[]);const B=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(B.current||D.length===0||!p.current)return;B.current=!0;const t=p.current,r=t.clientWidth,s=t.clientHeight,c=(r-40)/v.width,x=(s-40)/v.height,g=Math.min(c,x,1),y=v.width*g,w=v.height*g;T(g),M({x:(r-y)/2,y:(s-w)/2})},[D,v]);const lt=(0,o.useCallback)(t=>{t.button===0&&(t.target.closest("[data-org-card]")||(O(!0),Y.current={x:t.clientX,y:t.clientY,panX:l.x,panY:l.y}))},[l]),ut=(0,o.useCallback)(t=>{if(!A)return;const r=t.clientX-Y.current.x,s=t.clientY-Y.current.y;M({x:Y.current.panX+r,y:Y.current.panY+s})},[A]),I=(0,o.useCallback)(()=>{O(!1)},[]),dt=(0,o.useCallback)(t=>{t.preventDefault();const r=p.current;if(!r)return;const s=r.getBoundingClientRect(),c=t.clientX-s.left,x=t.clientY-s.top,g=t.deltaY<0?1.1:.9,y=R(h*g),w=y/h;M({x:c-w*(c-l.x),y:x-w*(x-l.y)}),T(y)},[h,l]),q=(0,o.useCallback)((t,r)=>{const s=R(t),c=s/h;M({x:r.x-c*(r.x-l.x),y:r.y-c*(r.y-l.y)}),T(s)},[h,l]),ht=(0,o.useCallback)(()=>{if(!p.current)return;const t=p.current.clientWidth,r=p.current.clientHeight,s=(t-40)/v.width,c=(r-40)/v.height,x=Math.min(s,c,1),g=v.width*x,y=v.height*x;T(x),M({x:(t-g)/2,y:(r-y)/2})},[v]),mt=(0,o.useCallback)(t=>{if(t.touches.length>=2&&p.current){const[s,c]=[t.touches[0],t.touches[1]];m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:nt(s,c),startCenter:st(s,c,p.current),moved:!1};return}const r=t.touches[0];r&&(m.current={mode:"pan",startPoint:Rt(r),startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1})},[l,h]),ft=(0,o.useCallback)(t=>{const r=p.current;if(!r||!m.current.mode)return;if(t.touches.length>=2){const[g,y]=[t.touches[0],t.touches[1]],w=nt(g,y),E=st(g,y,r);if(m.current.mode!=="pinch"||m.current.startDistance===0){m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:w,startCenter:E,moved:!1};return}const b=m.current,G=R(b.startZoom*(w/b.startDistance)),U=G/b.startZoom,xt=E.x-b.startCenter.x,gt=E.y-b.startCenter.y;b.moved=b.moved||Math.abs(w-b.startDistance)>H||Math.hypot(xt,gt)>H,T(G),M({x:E.x-U*(b.startCenter.x-b.startPan.x),y:E.y-U*(b.startCenter.y-b.startPan.y)});return}const s=t.touches[0];if(!s||m.current.mode!=="pan")return;const c=s.clientX-m.current.startPoint.x,x=s.clientY-m.current.startPoint.y;m.current.moved=m.current.moved||Math.hypot(c,x)>H,M({x:m.current.startPan.x+c,y:m.current.startPan.y+x})},[l,h]),F=(0,o.useCallback)(()=>{m.current.moved&&(W.current=!0,Z.current!==null&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{W.current=!1,Z.current=null},400)),m.current={mode:null,startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1}},[l,h]);return e?k?(0,n.jsx)(_t,{variant:"org-chart"}):j&&j.length===0?(0,n.jsx)(tt,{icon:rt,message:"No organizational hierarchy defined."}):(0,n.jsxs)("div",{className:"flex h-(--sz-calc-38) min-h-(--sz-420px) flex-col md:h-full md:min-h-0",children:[(0,n.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center justify-start gap-2",children:[C&&(0,n.jsx)(V,{to:"/company/import",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Import company"]})}),S&&(0,n.jsx)(V,{to:"/company/export",children:(0,n.jsxs)(et,{variant:"outline",size:"sm",children:[(0,n.jsx)(Yt,{className:"mr-1.5 h-3.5 w-3.5"}),"Export company"]})})]}),(0,n.jsxs)("div",{ref:p,"data-testid":"org-chart-viewport",className:"w-full flex-1 min-h-0 overflow-hidden relative bg-muted/20 border border-border rounded-lg",style:{cursor:A?"grabbing":"grab",touchAction:"none",overscrollBehavior:"contain"},onMouseDown:lt,onMouseMove:ut,onMouseUp:I,onMouseLeave:I,onWheel:dt,onTouchStart:mt,onTouchMove:ft,onTouchEnd:F,onTouchCancel:F,children:[(0,n.jsxs)("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&q(h*1.2,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom in","aria-label":"Zoom in",children:(0,n.jsx)(kt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&q(h*.8,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom out","aria-label":"Zoom out",children:(0,n.jsx)(Pt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-(length:--text-nano) transition-colors hover:bg-accent sm:size-7",onClick:ht,title:"Fit to screen","aria-label":"Fit chart to screen",children:(0,n.jsx)(Tt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]}),(0,n.jsx)("svg",{className:"absolute inset-0 pointer-events-none",style:{width:"100%",height:"100%"},children:(0,n.jsx)("g",{transform:`translate(${l.x}, ${l.y}) scale(${h})`,children:it.map(({parent:t,child:r})=>{const s=t.x+N/2,c=t.y+$,x=r.x+N/2,g=r.y,y=(c+g)/2;return(0,n.jsx)("path",{d:`M ${s} ${c} L ${s} ${y} L ${x} ${y} L ${x} ${g}`,fill:"none",stroke:"var(--border)",strokeWidth:1.5},`${t.id}-${r.id}`)})})}),(0,n.jsx)("div",{"data-testid":"org-chart-card-layer",className:"absolute inset-0",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${h})`,transformOrigin:"0 0"},children:D.map(t=>{const r=ct.get(t.id),s=Ot[t.status]??Bt;return(0,n.jsx)(Zt,{"data-org-card":!0,className:"block absolute py-0 hover:shadow-md hover:border-foreground/20 transition-(--tp-box-shadow-border-color) duration-150 cursor-pointer select-none",style:{left:t.x,top:t.y,width:N,minHeight:$},onClick:u(()=>d(r?wt(r):`/agents/${t.id}`),"onClick"),onClickCapture:u(c=>{W.current&&(W.current=!1,c.preventDefault(),c.stopPropagation())},"onClickCapture"),children:(0,n.jsxs)("div",{className:"flex items-center px-4 py-3 gap-3",children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center",children:(0,n.jsx)(Mt,{agent:r,size:16,className:"h-4.5 w-4.5 text-foreground/70"})}),(0,n.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card",style:{backgroundColor:s}})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight",children:t.name}),(0,n.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground leading-tight mt-0.5",children:r?.title??qt(t.role)}),r&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/60 font-mono leading-tight mt-1",children:Et(r.adapterType)}),r&&r.capabilities&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/80 leading-tight mt-1 line-clamp-2",children:r.capabilities})]})]})},t.id)})})]})]}):(0,n.jsx)(tt,{icon:rt,message:"Select a company to view the org chart."})}u(oe,"OrgChart");var It=Ct;function qt(e){return It[e]??e}u(qt,"roleLabel");export{oe as OrgChart};
@@ -1 +1 @@
1
- var i=Object.defineProperty;var r=(l,c)=>i(l,"name",{value:c,configurable:!0});import{i as d}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as x}from"./agent-avatar-url-BgtuDQuJ.js";import{t as e}from"./skeleton-CYpNbxbP.js";var s=d(x(),1);function t({variant:l="list"}){return l==="dashboard"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(e,{className:"h-32 w-full border border-border"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 xl:grid-cols-4",children:Array.from({length:4}).map((c,a)=>(0,s.jsx)(e,{className:"h-24 w-full"},a))}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:Array.from({length:4}).map((c,a)=>(0,s.jsx)(e,{className:"h-44 w-full"},a))}),(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsx)(e,{className:"h-72 w-full"}),(0,s.jsx)(e,{className:"h-72 w-full"})]})]}):l==="approvals"?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-between",children:(0,s.jsx)(e,{className:"h-9 w-44"})}),(0,s.jsx)("div",{className:"grid gap-3",children:Array.from({length:3}).map((c,a)=>(0,s.jsx)(e,{className:"h-36 w-full"},a))})]}):l==="costs"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:Array.from({length:6}).map((c,a)=>(0,s.jsx)(e,{className:"h-9 w-28"},a))}),(0,s.jsx)(e,{className:"h-40 w-full"}),(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsx)(e,{className:"h-72 w-full"}),(0,s.jsx)(e,{className:"h-72 w-full"})]})]}):l==="inbox"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(e,{className:"h-9 w-56"}),(0,s.jsx)(e,{className:"h-8 w-40"})]}),(0,s.jsx)("div",{className:"space-y-5",children:Array.from({length:3}).map((c,a)=>(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e,{className:"h-4 w-40"}),(0,s.jsx)("div",{className:"space-y-1 border border-border",children:Array.from({length:3}).map((h,m)=>(0,s.jsx)(e,{className:"h-14 w-full rounded-none"},m))})]},a))})]}):l==="org-chart"?(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsx)(e,{className:"h-(--sz-calc-17) w-full rounded-lg border border-border"})}):l==="detail"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(e,{className:"h-3 w-64"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-6 w-6"}),(0,s.jsx)(e,{className:"h-6 w-6"}),(0,s.jsx)(e,{className:"h-7 w-48"})]}),(0,s.jsx)(e,{className:"h-4 w-40"})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(e,{className:"h-10 w-full"}),(0,s.jsx)(e,{className:"h-32 w-full"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-8 w-24"}),(0,s.jsx)(e,{className:"h-8 w-24"}),(0,s.jsx)(e,{className:"h-8 w-24"})]}),(0,s.jsx)(e,{className:"h-24 w-full"}),(0,s.jsx)(e,{className:"h-24 w-full"})]})]}):l==="issues-list"?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(e,{className:"h-9 w-64"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-8 w-16"}),(0,s.jsx)(e,{className:"h-8 w-16"}),(0,s.jsx)(e,{className:"h-8 w-16"}),(0,s.jsx)(e,{className:"h-8 w-24"})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e,{className:"h-4 w-40"}),(0,s.jsx)("div",{className:"space-y-1",children:Array.from({length:8}).map((c,a)=>(0,s.jsx)(e,{className:"h-11 w-full rounded-none"},a))})]})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(e,{className:"h-9 w-44"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-8 w-20"}),(0,s.jsx)(e,{className:"h-8 w-24"})]})]}),(0,s.jsx)("div",{className:"space-y-1",children:Array.from({length:7}).map((c,a)=>(0,s.jsx)(e,{className:"h-11 w-full rounded-none"},a))})]})}r(t,"PageSkeleton");export{t};
1
+ var i=Object.defineProperty;var r=(l,c)=>i(l,"name",{value:c,configurable:!0});import{i as d}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as x}from"./agent-avatar-url-DtOIjE-b.js";import{t as e}from"./skeleton-BY2fv9gX.js";var s=d(x(),1);function t({variant:l="list"}){return l==="dashboard"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(e,{className:"h-32 w-full border border-border"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 xl:grid-cols-4",children:Array.from({length:4}).map((c,a)=>(0,s.jsx)(e,{className:"h-24 w-full"},a))}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:Array.from({length:4}).map((c,a)=>(0,s.jsx)(e,{className:"h-44 w-full"},a))}),(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsx)(e,{className:"h-72 w-full"}),(0,s.jsx)(e,{className:"h-72 w-full"})]})]}):l==="approvals"?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-between",children:(0,s.jsx)(e,{className:"h-9 w-44"})}),(0,s.jsx)("div",{className:"grid gap-3",children:Array.from({length:3}).map((c,a)=>(0,s.jsx)(e,{className:"h-36 w-full"},a))})]}):l==="costs"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:Array.from({length:6}).map((c,a)=>(0,s.jsx)(e,{className:"h-9 w-28"},a))}),(0,s.jsx)(e,{className:"h-40 w-full"}),(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsx)(e,{className:"h-72 w-full"}),(0,s.jsx)(e,{className:"h-72 w-full"})]})]}):l==="inbox"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(e,{className:"h-9 w-56"}),(0,s.jsx)(e,{className:"h-8 w-40"})]}),(0,s.jsx)("div",{className:"space-y-5",children:Array.from({length:3}).map((c,a)=>(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e,{className:"h-4 w-40"}),(0,s.jsx)("div",{className:"space-y-1 border border-border",children:Array.from({length:3}).map((h,m)=>(0,s.jsx)(e,{className:"h-14 w-full rounded-none"},m))})]},a))})]}):l==="org-chart"?(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsx)(e,{className:"h-(--sz-calc-17) w-full rounded-lg border border-border"})}):l==="detail"?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(e,{className:"h-3 w-64"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-6 w-6"}),(0,s.jsx)(e,{className:"h-6 w-6"}),(0,s.jsx)(e,{className:"h-7 w-48"})]}),(0,s.jsx)(e,{className:"h-4 w-40"})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(e,{className:"h-10 w-full"}),(0,s.jsx)(e,{className:"h-32 w-full"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-8 w-24"}),(0,s.jsx)(e,{className:"h-8 w-24"}),(0,s.jsx)(e,{className:"h-8 w-24"})]}),(0,s.jsx)(e,{className:"h-24 w-full"}),(0,s.jsx)(e,{className:"h-24 w-full"})]})]}):l==="issues-list"?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(e,{className:"h-9 w-64"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-8 w-16"}),(0,s.jsx)(e,{className:"h-8 w-16"}),(0,s.jsx)(e,{className:"h-8 w-16"}),(0,s.jsx)(e,{className:"h-8 w-24"})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e,{className:"h-4 w-40"}),(0,s.jsx)("div",{className:"space-y-1",children:Array.from({length:8}).map((c,a)=>(0,s.jsx)(e,{className:"h-11 w-full rounded-none"},a))})]})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(e,{className:"h-9 w-44"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e,{className:"h-8 w-20"}),(0,s.jsx)(e,{className:"h-8 w-24"})]})]}),(0,s.jsx)("div",{className:"space-y-1",children:Array.from({length:7}).map((c,a)=>(0,s.jsx)(e,{className:"h-11 w-full rounded-none"},a))})]})}r(t,"PageSkeleton");export{t};
@@ -1 +1 @@
1
- var ot=Object.defineProperty;var i=(s,a)=>ot(s,"name",{value:a,configurable:!0});import{i as Le}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as ct,Li as lt,Pi as dt,S as ut,Vr as mt,W as pt,Z as p,ni as L,ti as U}from"./agent-avatar-url-BgtuDQuJ.js";import{Ht as ht,Mt as Ee,b as gt,o as xt,r as oe}from"./router-7hDvVKpK.js";import{At as yt,Ct as Oe,Fr as vt,Ft as ft,Mt as bt,Pt as jt,jt as wt,t as Nt}from"./RoutineRunVariablesDialog-wvsgUi5R.js";import{Z as kt}from"./mention-chips-DaQB1XXn.js";import{l as T,t as De}from"./MarkdownEditor-Dkh_ud4t.js";import{v as St}from"./sheet-Xthrybbp.js";import{t as Me}from"./AgentAvatar-CowKoklf.js";import{k as It}from"./checkbox-DxzcpGzB.js";import{c as Ct,t as O,v as At}from"./label-LNcfjNUd.js";import{r as Pt,t as Rt}from"./agents-BqHpxyXa.js";import{g as Tt}from"./StatusIcon-CJevr908.js";import{r as Et,t as te}from"./EmptyState-B54qBJdG.js";import{c as de,i as ue,n as me,s as pe,t as he}from"./select-B_zFVzlA.js";import{r as Ot,t as Dt}from"./save-C8Purtgn.js";import{k as Mt,t as E}from"./button-CiCWqyHT.js";import{n as _t,t as qt}from"./clipboard-Ch2RFnBG.js";import{t as Ft}from"./heartbeats-BIzk9_-_.js";import{t as xe}from"./badge-B1opbM2C.js";import{t as G}from"./input-C5_FG4bG.js";import{i as Kt,o as Lt}from"./company-members-BJTKKG75.js";import{r as Ut,t as Wt}from"./card-sHXnFZQl.js";import{t as $t}from"./PageSkeleton-DOrN07nB.js";import{B as Gt,Bn as ye,Dt as Vt,F as zt,G as _e,Gn as ve,H as Qt,I as Bt,J as Ue,K as We,L as Ht,M as Jt,N as Zt,P as $e,Qt as X,R as Yt,Tn as Xt,U as es,Un as ts,Ut as ss,V as is,W as ns,Wt as as,Y as rs,Yt as os,en as qe,hn as cs,j as ls,mn as ds,q as z,z as us}from"./index-iLdUWxoA.js";var u=Le(lt(),1);function ms(s,a,n){const c={label:a.label.trim()||null};return s.kind==="schedule"&&(c.cronExpression=a.cronExpression.trim(),c.timezone=s.timezone??n),s.kind==="webhook"&&(c.signingMode=a.signingMode,c.replayWindowSec=Number(a.replayWindowSec||"300")),c}i(ms,"buildRoutineTriggerPatch");var e=Le(ct(),1),ps=["app_webhook","bearer","hmac_sha256","github_hmac","none"],hs=new Set(["app_webhook","bearer","github_hmac","fireflies_hmac","none"]);function gs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}i(gs,"getLocalTimezone$1");function xs({trigger:s,onSave:a,onRotate:n,onDelete:c,disabled:r}){const[m,l]=(0,u.useState)({label:s.label??"",cronExpression:s.cronExpression??"",signingMode:s.signingMode??"bearer",replayWindowSec:String(s.replayWindowSec??300)});(0,u.useEffect)(()=>{l({label:s.label??"",cronExpression:s.cronExpression??"",signingMode:s.signingMode??"bearer",replayWindowSec:String(s.replayWindowSec??300)})},[s]);const k=s.kind==="schedule"?ye:s.kind==="webhook"?cs:gt,I=s.kind==="schedule"?Bt(m.cronExpression):null,_=/fail|error/i.test(s.lastResult??""),C=s.lastResult?.startsWith("Created execution issue ")?"Task created":s.lastResult;return(0,e.jsxs)("form",{"aria-label":`Trigger: ${s.label??s.kind}`,className:"space-y-4 rounded-lg border border-border p-4",onSubmit:i(x=>x.preventDefault(),"onSubmit"),children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,e.jsx)(k,{className:"h-3.5 w-3.5 shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:s.label??s.kind})]}),I?(0,e.jsx)("p",{id:`cron-readable-${s.id}`,className:"text-xs text-muted-foreground",children:I}):null]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[s.lastResult?(0,e.jsx)(xe,{variant:_?"destructive":"secondary",children:C}):null,(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:s.kind==="schedule"&&s.nextRunAt?`Next: ${new Date(s.nextRunAt).toLocaleString()}`:s.kind==="webhook"?"Webhook":"API"})]})]}),s.kind==="webhook"&&s.webhookUrl&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{htmlFor:`webhook-url-${s.id}`,className:"text-xs",children:"Webhook URL"}),(0,e.jsx)(G,{id:`webhook-url-${s.id}`,value:s.webhookUrl,readOnly:!0,onFocus:i(x=>x.target.select(),"onFocus")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Send a POST request with Content-Type: application/json. Keep this URL private when signing is disabled."})]}),(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Label"}),(0,e.jsx)(G,{value:m.label,disabled:r,onChange:i(x=>l(S=>({...S,label:x.target.value})),"onChange")})]}),s.kind==="schedule"&&(0,e.jsxs)("div",{className:"space-y-1.5 md:col-span-2",children:[(0,e.jsx)(O,{className:"text-xs",children:"Schedule"}),(0,e.jsx)($e,{value:m.cronExpression,onChange:i(x=>l(S=>({...S,cronExpression:x})),"onChange")})]}),s.kind==="webhook"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Signing mode"}),(0,e.jsxs)(he,{value:m.signingMode,onValueChange:i(x=>l(S=>({...S,signingMode:x})),"onValueChange"),disabled:r,children:[(0,e.jsx)(pe,{children:(0,e.jsx)(de,{})}),(0,e.jsx)(me,{children:ps.map(x=>(0,e.jsx)(ue,{value:x,children:x},x))})]})]}),!hs.has(m.signingMode)&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Replay window (seconds)"}),(0,e.jsx)(G,{value:m.replayWindowSec,disabled:r,onChange:i(x=>l(S=>({...S,replayWindowSec:x.target.value})),"onChange")})]})]})]}),!r&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,e.jsxs)(E,{variant:"ghost",size:"sm",className:"mr-auto text-muted-foreground hover:text-destructive",onClick:i(()=>c(s.id),"onClick"),children:[(0,e.jsx)(It,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.kind==="webhook"&&(0,e.jsxs)(E,{variant:"outline",size:"sm",onClick:i(()=>n(s.id),"onClick"),children:[(0,e.jsx)(St,{className:"mr-1.5 h-3.5 w-3.5"}),"Rotate secret"]}),(0,e.jsxs)(E,{variant:"outline",size:"sm",onClick:i(()=>a(s.id,ms(s,m,gs())),"onClick"),children:[(0,e.jsx)(Dt,{className:"mr-1.5 h-3.5 w-3.5"}),"Save trigger"]})]})]})}i(xs,"RoutineTriggerCard");var ys=[{value:"coalesce_if_active",title:"Coalesce if active",description:"Keep one follow-up run queued while an active run is still working."},{value:"always_enqueue",title:"Always enqueue",description:"Queue every trigger occurrence, even if several runs stack up."},{value:"skip_if_active",title:"Skip if active",description:"Drop overlapping trigger occurrences while the routine is already active."}],vs=[{value:"skip_missed",title:"Skip missed",description:"Ignore schedule windows that were missed while paused."},{value:"enqueue_missed_with_cap",title:"Enqueue missed with cap",description:"Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap."}],fs=[{value:"always",title:"Run on every scheduled tick",description:"Fire on the schedule no matter what — the default behavior."},{value:"require_external_activity",title:"Skip when there's been no activity since the last run",description:"On a scheduled tick, only run if something happened since the last run that finished. Lets a watcher-style routine stay asleep while the system is settled instead of burning tokens."}],bs=[{value:"company",title:"Company-wide",description:"Any activity across the company counts as a reason to run."},{value:"project",title:"This project",description:"Only activity in the routine's project counts as a reason to run."}],js=["schedule","webhook"],ws=["app_webhook","bearer","hmac_sha256","github_hmac","none"],Ns={bearer:"Send Authorization: Bearer <secret> with each request.",hmac_sha256:"Send X-Paperclip-Timestamp and X-Paperclip-Signature: sha256=<hex>, signing timestamp + a dot + the exact JSON body.",github_hmac:"Accept GitHub-style X-Hub-Signature-256 header (HMAC over raw body, no timestamp).",app_webhook:"Accept a bearer token or an HMAC-SHA256 signature over the exact request body in X-Hub-Signature or X-Hub-Signature-256.",fireflies_hmac:"Signed webhook (legacy).",none:"No authentication — the webhook URL itself acts as a shared secret."},ks=new Set(["app_webhook","bearer","github_hmac","fireflies_hmac","none"]);function Ss({defaultDescriptionAnnotationsOpen:s=!1}={}){const{routine:a,editDraft:n,setEditDraft:c,assigneeOptions:r,projectOptions:m,recentAssigneeIds:l,recentProjectIds:k,agentById:I,projectById:_,currentAssignee:C,currentProject:x,mentionOptions:S,assigneeSelectorRef:D,projectSelectorRef:q,descriptionEditorRef:A,routineRuns:g,activity:b,saveRoutine:j,saveConflict:se,isSectionDirty:f,navigateToSection:P}=z(),[w,M]=(0,u.useState)(s),o=a.triggers.length,Q=(0,u.useMemo)(()=>{const d=a.triggers.filter(y=>y.kind==="schedule"&&y.nextRunAt).map(y=>new Date(y.nextRunAt)).sort((y,V)=>y.getTime()-V.getTime())[0];return d?d.toLocaleString():null},[a.triggers]),W=n.env?Object.keys(n.env).length:0,R=(g??[])[0]??null,B=(b??[]).slice(0,5);return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,e.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-muted-foreground sm:min-w-max sm:flex-nowrap",children:[(0,e.jsx)("span",{children:"For"}),(0,e.jsx)(Oe,{ref:D,value:n.assigneeAgentId,options:r,recentOptionIds:l,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:i(d=>c(y=>({...y,assigneeAgentId:d})),"onChange"),onConfirm:i(()=>{n.projectId?A.current?.focus():q.current?.focus()},"onConfirm"),renderTriggerValue:i(d=>d?C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Me,{agent:C,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"truncate",children:d.label})]}):(0,e.jsx)("span",{className:"truncate",children:d.label}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"Responsible"}),"renderTriggerValue"),renderOption:i(d=>{if(!d.id)return(0,e.jsx)("span",{className:"truncate",children:d.label});const y=I.get(d.id);return(0,e.jsxs)(e.Fragment,{children:[y?(0,e.jsx)(Me,{agent:y,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,(0,e.jsx)("span",{className:"truncate",children:d.label})]})},"renderOption")}),(0,e.jsx)("span",{children:"in"}),(0,e.jsx)(Oe,{ref:q,value:n.projectId,options:m,recentOptionIds:k,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:i(d=>c(y=>({...y,projectId:d})),"onChange"),onConfirm:i(()=>A.current?.focus(),"onConfirm"),renderTriggerValue:i(d=>d&&x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:x.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:d.label})]}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"Project"}),"renderTriggerValue"),renderOption:i(d=>{if(!d.id)return(0,e.jsx)("span",{className:"truncate",children:d.label});const y=_.get(d.id);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:y?.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:d.label})]})},"renderOption")})]})}),a.assigneeAgentId?null:(0,e.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-900 dark:text-amber-200",children:"Default agent required. This routine can stay as a draft and still run manually, but automation stays paused until you assign a default agent."}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"flex items-center justify-end",children:a.descriptionDocument?(0,e.jsx)(ss,{issueId:a.id,docKey:"description",target:{kind:"routine",routineId:a.id,documentKey:"description"},panelOpen:w,onToggle:i(()=>M(d=>!d),"onToggle")}):null}),a.descriptionDocument?(0,e.jsx)(as,{issueId:a.id,doc:a.descriptionDocument,target:{kind:"routine",routineId:a.id,documentKey:"description"},bodyMarkdown:n.description,draftDirty:f("overview")||j.isPending,draftConflicted:se,historicalPreview:!1,locationHash:typeof window>"u"?"":window.location.hash,panelOpen:w,onPanelOpenChange:M,children:(0,e.jsx)(De,{ref:A,value:n.description,onChange:i(d=>c(y=>({...y,description:d})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-120px) text-sm leading-7",mentions:S,onSubmit:i(()=>{!j.isPending&&n.title.trim()&&j.mutate()},"onSubmit")})}):(0,e.jsx)(De,{ref:A,value:n.description,onChange:i(d=>c(y=>({...y,description:d})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-120px) text-sm leading-7",mentions:S,onSubmit:i(()=>{!j.isPending&&n.title.trim()&&j.mutate()},"onSubmit")})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(rs,{}),(0,e.jsx)(Ue,{title:n.title,description:n.description,value:n.variables,onChange:i(d=>c(y=>({...y,variables:d})),"onChange")})]}),(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,e.jsx)(ce,{icon:ye,label:"Triggers",value:o===0?"None":`${o} active`,hint:Q?`Next fire ${Q}`:"No schedule",to:i(()=>P("triggers"),"to"),ariaLabel:`${o} triggers. Open triggers.`}),(0,e.jsx)(ce,{icon:_t,label:"Secrets",value:W===0?"None":`${W} bound`,hint:"Manage bound secrets",to:i(()=>P("secrets"),"to"),ariaLabel:`${W} secrets bound. Open secrets.`}),(0,e.jsx)(ce,{icon:At,label:"Last run",value:R?R.status.replaceAll("_"," "):"No runs",hint:R?Ee(R.triggeredAt):"Trigger a run",to:i(()=>P("runs"),"to"),ariaLabel:R?`Last run ${R.status}. Open runs.`:"No runs. Open runs."})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Recent activity"}),B.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No activity yet."}):(0,e.jsxs)("div",{className:"divide-y divide-border/60",children:[B.map(d=>(0,e.jsxs)("div",{className:"flex items-center gap-2 py-1.5 text-xs",children:[(0,e.jsx)(xe,{variant:"outline",className:"shrink-0 font-mono",children:d.action}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:d.details&&Object.keys(d.details).length>0?Object.keys(d.details).slice(0,3).join(" · "):""}),(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground/60",children:Ee(d.createdAt)})]},d.id)),(0,e.jsxs)("button",{type:"button",onClick:i(()=>P("activity"),"onClick"),className:"flex items-center gap-1 pt-2 text-xs text-muted-foreground hover:text-foreground",children:["View all activity ",(0,e.jsx)(ve,{className:"h-3 w-3"})]})]})]})]})}i(Ss,"OverviewSection");function ce({icon:s,label:a,value:n,hint:c,to:r,ariaLabel:m}){return(0,e.jsx)("button",{type:"button",onClick:r,"aria-label":m,className:"text-left",children:(0,e.jsx)(Wt,{className:"gap-2 p-4 transition-colors hover:border-border hover:bg-accent/30",children:(0,e.jsxs)(Ut,{className:"space-y-1 p-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground",children:[(0,e.jsx)(s,{className:"h-3.5 w-3.5"}),a,(0,e.jsx)(ve,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground/60"})]}),(0,e.jsx)("p",{className:"text-lg font-semibold",children:n}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:c})]})})})}i(ce,"SummaryCard");function Is(){const{routine:s,newTrigger:a,setNewTrigger:n,createTrigger:c,updateTrigger:r,deleteTrigger:m,rotateTrigger:l,secretMessage:k,copySecretValue:I,setSecretMessage:_}=z(),[C,x]=(0,u.useState)(!1),[S,D]=(0,u.useState)(!0),q=(0,u.useMemo)(()=>a.kind==="schedule"?zt(a.cronExpression):null,[a.cronExpression,a.kind]),A=c.isPending||(q?!q.valid||!S:!1);return(0,u.useEffect)(()=>{a.kind!=="schedule"&&D(!0)},[a.kind]),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:s.triggers.length===0?"No triggers yet":`${s.triggers.length} trigger${s.triggers.length===1?"":"s"}`}),(0,e.jsx)(E,{size:"sm",variant:C?"secondary":"default",onClick:i(()=>x(g=>!g),"onClick"),"aria-expanded":C,children:C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(kt,{className:"mr-1.5 h-3.5 w-3.5"}),"Cancel"]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Mt,{className:"mr-1.5 h-3.5 w-3.5"}),"New trigger"]})})]}),C?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-border p-4",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Add trigger"}),(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Kind"}),(0,e.jsxs)(he,{value:a.kind,onValueChange:i(g=>n(b=>({...b,kind:g})),"onValueChange"),children:[(0,e.jsx)(pe,{children:(0,e.jsx)(de,{})}),(0,e.jsx)(me,{children:js.map(g=>(0,e.jsx)(ue,{value:g,children:g},g))})]})]}),a.kind==="schedule"&&(0,e.jsxs)("div",{className:"space-y-1.5 md:col-span-2",children:[(0,e.jsx)(O,{className:"text-xs",children:"Schedule"}),(0,e.jsx)($e,{value:a.cronExpression,onChange:i(g=>n(b=>({...b,cronExpression:g})),"onChange"),onValidityChange:D})]}),a.kind==="webhook"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Signing mode"}),(0,e.jsxs)(he,{value:a.signingMode,onValueChange:i(g=>n(b=>({...b,signingMode:g})),"onValueChange"),children:[(0,e.jsx)(pe,{children:(0,e.jsx)(de,{})}),(0,e.jsx)(me,{children:ws.map(g=>(0,e.jsx)(ue,{value:g,children:g},g))})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:Ns[a.signingMode]})]}),!ks.has(a.signingMode)&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Replay window (seconds)"}),(0,e.jsx)(G,{value:a.replayWindowSec,onChange:i(g=>n(b=>({...b,replayWindowSec:g.target.value})),"onChange")})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)(E,{size:"sm",variant:"ghost",onClick:i(()=>x(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(E,{size:"sm",onClick:i(()=>c.mutate(void 0,{onSuccess:i(()=>{n(We()),x(!1)},"onSuccess")}),"onClick"),disabled:A,children:c.isPending?"Adding...":"Add trigger"})]})]}):null,k?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-border bg-muted/20 p-4 text-sm",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium",children:k.title}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Save this now. Paperclip will not show the secret value again."})]}),(0,e.jsx)("div",{className:"space-y-3",children:k.entries.map((g,b)=>(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(G,{"aria-label":"New webhook URL",value:g.webhookUrl,readOnly:!0,className:"flex-1"}),(0,e.jsx)(E,{variant:"outline",size:"sm",onClick:i(()=>I("Webhook URL",g.webhookUrl),"onClick"),children:"URL"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(G,{"aria-label":"New webhook secret",value:g.webhookSecret,readOnly:!0,className:"flex-1"}),(0,e.jsx)(E,{variant:"outline",size:"sm",onClick:i(()=>I("Webhook secret",g.webhookSecret),"onClick"),children:"Secret"})]})]},`${g.webhookUrl}-${b}`))}),(0,e.jsx)(E,{variant:"outline",size:"sm",onClick:i(()=>_(null),"onClick"),children:"Done"})]}):null,s.triggers.length===0?(0,e.jsx)(te,{icon:ye,message:"No triggers yet.",action:"Add a trigger",onAction:i(()=>x(!0),"onAction")}):(0,e.jsx)("div",{className:"space-y-3",children:s.triggers.map(g=>(0,e.jsx)(xs,{trigger:g,onSave:i((b,j)=>r.mutate({id:b,patch:j}),"onSave"),onRotate:i(b=>l.mutate(b),"onRotate"),onDelete:i(b=>m.mutate(b),"onDelete")},g.id))})]})}i(Is,"TriggersSection");function Cs(){const{editDraft:s,setEditDraft:a,navigateToSection:n}=z(),c=s.variables.length>0;return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border bg-muted/20 px-4 py-3 text-xs",children:[(0,e.jsxs)("span",{className:"flex-1 text-muted-foreground",children:["Variables are auto-detected from ",(0,e.jsx)("code",{className:"font-mono",children:"{{placeholders}}"})," in the title & instructions. The variable name is read-only — rename by editing the placeholder."]}),(0,e.jsxs)(E,{variant:"secondary",size:"sm",onClick:i(()=>n("overview"),"onClick"),children:[(0,e.jsx)(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit instructions"]})]}),c?(0,e.jsx)(Ue,{title:s.title,description:s.description,value:s.variables,onChange:i(r=>a(m=>({...m,variables:r})),"onChange")}):(0,e.jsx)(te,{icon:ts,message:"No variables yet. Add a {{placeholder}} in the title or instructions to create one.",action:"Edit instructions",onAction:i(()=>n("overview"),"onAction")})]})}i(Cs,"VariablesSection");function As(){const{editDraft:s,setEditDraft:a,availableSecrets:n,createSecret:c}=z(),r=(0,u.useMemo)(()=>[...n].filter(m=>m.status==="active").sort((m,l)=>{const k=(l.referenceCount??0)-(m.referenceCount??0);return k!==0?k:new Date(l.updatedAt).getTime()-new Date(m.updatedAt).getTime()}).slice(0,8),[n]);return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"rounded-md border border-border bg-muted/20 px-4 py-3 text-xs text-muted-foreground",children:["Routine secrets apply to every task this routine creates. They override matching keys in project and agent env. ",(0,e.jsx)("span",{className:"font-mono",children:"PAPERCLIP_*"})," names are reserved."]}),(0,e.jsx)(os,{value:s.env??{},secrets:n,recentlyUsedSecrets:r,onCreateSecret:i(async(m,l)=>c.mutateAsync({name:m,value:l}),"onCreateSecret"),onChange:i(m=>a(l=>({...l,env:m??null})),"onChange")})]})}i(As,"SecretsSection");function Ps(){const{editDraft:s,setEditDraft:a,routine:n}=z(),c=n.triggers.some(m=>m.kind==="schedule"),r=s.activityGatePolicy==="require_external_activity";return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Concurrency"}),(0,e.jsx)(X,{ariaLabel:"Concurrency policy",value:s.concurrencyPolicy,onValueChange:i(m=>a(l=>({...l,concurrencyPolicy:m})),"onValueChange"),options:ys})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Catch-up"}),(0,e.jsx)(X,{ariaLabel:"Catch-up policy",value:s.catchUpPolicy,onValueChange:i(m=>a(l=>({...l,catchUpPolicy:m})),"onValueChange"),options:vs})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Advanced run policy"}),(0,e.jsx)(X,{ariaLabel:"Advanced run policy",value:s.activityGatePolicy,onValueChange:i(m=>a(l=>({...l,activityGatePolicy:m})),"onValueChange"),options:fs,disabled:!c}),c?r?(0,e.jsxs)("div",{className:"space-y-2 rounded-lg border border-border p-3",children:[(0,e.jsx)(O,{className:"text-xs font-medium",children:"Activity scope"}),(0,e.jsx)(X,{ariaLabel:"Activity gate scope",value:s.activityGateScope,onValueChange:i(m=>a(l=>({...l,activityGateScope:m})),"onValueChange"),options:bs})]}):null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add a schedule trigger to gate runs on activity. Webhook, manual, and API fires always run."})]}),(0,e.jsx)(Ts,{triggers:n.triggers,concurrencyPolicy:s.concurrencyPolicy})]})}i(Ps,"DeliverySection");var Rs={queued:"text-emerald-600 dark:text-emerald-400",coalesced:"text-amber-600 dark:text-amber-400",skipped:"text-muted-foreground"};function Ts({triggers:s,concurrencyPolicy:a}){const n=(0,u.useMemo)(()=>{const c=s.filter(r=>r.kind==="schedule"&&r.enabled&&r.cronExpression).map(r=>({trigger:r,fires:Ht(r.cronExpression,5,{timeZone:r.timezone??"UTC"})})).filter(r=>r.fires.length>0).sort((r,m)=>r.fires[0].getTime()-m.fires[0].getTime())[0];return c?{timeZone:c.trigger.timezone??"UTC",entries:Yt(c.fires,a)}:null},[s,a]);return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Next 5 fires"}),n?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"space-y-1.5 rounded-lg border border-border p-3 font-mono text-xs",children:n.entries.map((c,r)=>(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,e.jsx)("span",{className:"tabular-nums",children:Es(c.at,n.timeZone)}),(0,e.jsx)(ve,{className:"h-3 w-3 shrink-0 text-muted-foreground/50"}),(0,e.jsx)("span",{className:ut("font-medium",Rs[c.disposition]),children:c.label}),c.note?(0,e.jsxs)("span",{className:"truncate text-muted-foreground/60",children:["(",c.note,")"]}):null]},r))}),(0,e.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/60",children:["Preview assumes the previous run is still in flight when the next fires. Times shown in"," ",n.timeZone,"."]})]}):(0,e.jsx)("p",{className:"rounded-lg border border-dashed border-border p-3 text-xs text-muted-foreground",children:"No enabled schedule trigger to preview. Add a schedule in Triggers to see how this policy treats upcoming fires."})]})}i(Ts,"NextFiresPreview");function Es(s,a){try{return new Intl.DateTimeFormat(void 0,{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(s).replace(",","")}catch{return s.toISOString()}}i(Es,"formatFireTime");var ge="paperclip.routineLastSection";function Os(s){return s.filter(a=>!a.archivedAt).map(a=>({id:a.id,label:a.name,searchText:a.description??""}))}i(Os,"buildRoutineProjectOptions");var Ds={overview:"Overview",triggers:"Triggers",variables:"Variables",secrets:"Secrets",delivery:"Delivery",runs:"Runs",activity:"Activity",history:"History"};function ee(s){return s!=null&&es.includes(s)}i(ee,"isRoutineSection");function Ms(s){try{const a=localStorage.getItem(ge);if(!a)return null;const n=JSON.parse(a)[s];return ee(n)?n:null}catch{return null}}i(Ms,"readLastSection");function le(s,a){try{const n=localStorage.getItem(ge),c=n?JSON.parse(n):{};c[s]=a,localStorage.setItem(ge,JSON.stringify(c))}catch{}}i(le,"writeLastSection");var Fe={triggers:"triggers",runs:"runs",activity:"activity",secrets:"secrets",history:"history"};function Ke(s){s&&(s.style.height="auto",s.style.height=`${s.scrollHeight}px`)}i(Ke,"autoResizeTextarea");function _s(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}i(_s,"getLocalTimezone");function qs(s){return{...s,description:s.description.trim()||null,projectId:s.projectId||null,assigneeAgentId:s.assigneeAgentId||null,env:s.env&&Object.keys(s.env).length>0?s.env:null}}i(qs,"buildRoutineMutationPayload");function li(){const{routineId:s,section:a}=ht(),{selectedCompanyId:n}=pt(),{setBreadcrumbs:c}=Et(),r=dt(),m=xt(),{pushToast:l}=ds(),k=(0,u.useRef)(null),I=(0,u.useRef)(null),_=(0,u.useRef)(null),C=(0,u.useRef)(null),x=(0,u.useRef)(null),[S,D]=(0,u.useState)(null),[q,A]=(0,u.useState)(!1),[g,b]=(0,u.useState)(!1),[j,se]=(0,u.useState)(We),[f,P]=(0,u.useState)({title:"",description:"",projectId:"",assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",activityGatePolicy:"always",activityGateScope:"company",variables:[],env:null}),w=ee(a)?a:"overview",M=(0,u.useCallback)((t,h)=>{s&&(le(s,t),m(`/routines/${s}/${t}`,{replace:h?.replace??!0}))},[m,s]),{data:o,isLoading:Q,error:W}=L({queryKey:p.routines.detail(s),queryFn:i(()=>T.get(s),"queryFn"),enabled:!!s}),R=o?.activeIssue?.id,{data:B}=L({queryKey:p.issues.liveRuns(R),queryFn:i(()=>Ft.liveRunsForIssue(R),"queryFn"),enabled:!!R,refetchInterval:3e3}),d=(B??[]).length>0,{data:y}=L({queryKey:p.routines.runs(s),queryFn:i(()=>T.listRuns(s),"queryFn"),enabled:!!s,refetchInterval:d?3e3:!1}),V=(0,u.useMemo)(()=>({triggerIds:o?.triggers.map(t=>t.id)??[],runIds:y?.map(t=>t.id)??[]}),[o?.triggers,y]),{data:Ge}=L({queryKey:[...p.routines.activity(n,s),V.triggerIds.join(","),V.runIds.join(",")],queryFn:i(()=>T.activity(n,s,V),"queryFn"),enabled:!!n&&!!s&&!!o}),{data:F}=L({queryKey:p.agents.list(n),queryFn:i(()=>Rt.list(n),"queryFn"),enabled:!!n}),{data:K}=L({queryKey:p.projects.list(n,{includeArchived:!0}),queryFn:i(()=>Tt.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:fe}=L({queryKey:p.access.companyUserDirectory(n),queryFn:i(()=>Lt.listUserDirectory(n),"queryFn"),enabled:!!n}),{data:Ve=[]}=L({queryKey:n?p.secrets.list(n):["secrets","none"],queryFn:i(()=>qe.list(n),"queryFn"),enabled:!!n}),ze=U({mutationFn:i(t=>{if(!n)throw new Error("Select a company to create secrets");return qe.create(n,t)},"mutationFn"),onSuccess:i(()=>{n&&r.invalidateQueries({queryKey:p.secrets.list(n)})},"onSuccess")}),v=(0,u.useMemo)(()=>o?{title:o.title,description:o.description??"",projectId:o.projectId??"",assigneeAgentId:o.assigneeAgentId??"",priority:o.priority,concurrencyPolicy:o.concurrencyPolicy,catchUpPolicy:o.catchUpPolicy,activityGatePolicy:o.activityGatePolicy,activityGateScope:o.activityGateScope,variables:o.variables,env:o.env??null}:null,[o]),H=(0,u.useMemo)(()=>{if(!v)return[];const t=[];return f.title!==v.title&&t.push({key:"title",label:"the title"}),f.description!==v.description&&t.push({key:"description",label:"the description"}),f.projectId!==v.projectId&&t.push({key:"projectId",label:"the project"}),f.assigneeAgentId!==v.assigneeAgentId&&t.push({key:"assigneeAgentId",label:"the default agent"}),f.priority!==v.priority&&t.push({key:"priority",label:"the priority"}),f.concurrencyPolicy!==v.concurrencyPolicy&&t.push({key:"concurrencyPolicy",label:"the concurrency policy"}),f.catchUpPolicy!==v.catchUpPolicy&&t.push({key:"catchUpPolicy",label:"the catch-up policy"}),f.activityGatePolicy!==v.activityGatePolicy&&t.push({key:"activityGatePolicy",label:"the advanced run policy"}),f.activityGateScope!==v.activityGateScope&&t.push({key:"activityGateScope",label:"the activity gate scope"}),JSON.stringify(f.variables)!==JSON.stringify(v.variables)&&t.push({key:"variables",label:"the variables"}),JSON.stringify(f.env??null)!==JSON.stringify(v.env??null)&&t.push({key:"env",label:"the secrets"}),t},[f,v]),ie=H.length>0,J=(0,u.useCallback)(t=>{const h=_e[t];return h?H.filter(N=>h.includes(N.key)):[]},[H]),ne=(0,u.useCallback)(t=>J(t).length>0,[J]),be=(0,u.useCallback)(t=>{if(!v)return;const h=_e[t];h&&P(N=>{const Re={...N};for(const Te of h)Re[Te]=v[Te];return Re})},[v]);(0,u.useEffect)(()=>{o&&(c([{label:"Routines",href:"/routines"},{label:o.title}]),v&&(k.current!==o.id||!ie)&&(P(v),k.current=o.id))},[o,v,ie,c]),(0,u.useEffect)(()=>{Ke(I.current)},[f.title,o?.id]),(0,u.useEffect)(()=>{s&&ee(a)&&le(s,a)},[s,a]);const Qe=(0,u.useCallback)(async(t,h)=>{try{await qt(h),l({title:`${t} copied`,tone:"success"})}catch(N){l({title:`Failed to copy ${t.toLowerCase()}`,body:N instanceof Error?N.message:"Clipboard access was denied.",tone:"error"})}},[l]),Z=U({mutationFn:i(()=>{const t=qs(f),h=o?.latestRevisionId??null;return T.update(s,{...t,...h?{baseRevisionId:h}:{}})},"mutationFn"),onSuccess:i(async()=>{A(!1),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)}),r.invalidateQueries({queryKey:p.routines.revisions(s)})])},"onSuccess"),onError:i(t=>{if(t instanceof mt&&t.status===409){A(!0),l({title:"Routine changed",body:"Someone else updated this routine. Reload to see the latest revision.",tone:"warn"});return}l({title:"Failed to save routine",body:t instanceof Error?t.message:"Paperclip could not save the routine.",tone:"error"})},"onError")}),Y=U({mutationFn:i(t=>T.run(s,{...t?.variables&&Object.keys(t.variables).length>0?{variables:t.variables}:{},...t?.assigneeAgentId!==void 0?{assigneeAgentId:t.assigneeAgentId}:{},...t?.projectId!==void 0?{projectId:t.projectId}:{},...t?.executionWorkspaceId!==void 0?{executionWorkspaceId:t.executionWorkspaceId}:{},...t?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:t.executionWorkspacePreference}:{},...t?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:t.executionWorkspaceSettings}:{}}),"mutationFn"),onSuccess:i(async()=>{l({title:"Routine run started",tone:"success"}),b(!1),M("runs"),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.runs(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Routine run failed",body:t instanceof Error?t.message:"Paperclip could not start the routine run.",tone:"error"})},"onError")}),je=U({mutationFn:i(t=>T.update(s,{status:t}),"mutationFn"),onSuccess:i(async(t,h)=>{l({title:"Routine saved",body:h==="paused"?"Automation paused.":"Automation enabled.",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to update routine",body:t instanceof Error?t.message:"Paperclip could not update the routine.",tone:"error"})},"onError")}),Be=U({mutationFn:i(async()=>{const t=(o?.triggers??[]).filter(N=>N.kind===j.kind).length,h=t>0?`${j.kind}-${t+1}`:j.kind;return T.createTrigger(s,{kind:j.kind,label:h,...j.kind==="schedule"?{cronExpression:j.cronExpression.trim(),timezone:_s()}:{},...j.kind==="webhook"?{signingMode:j.signingMode,replayWindowSec:Number(j.replayWindowSec||"300")}:{}})},"mutationFn"),onSuccess:i(async t=>{t.secretMaterial?D({title:"Webhook trigger created",entries:[{webhookUrl:t.secretMaterial.webhookUrl,webhookSecret:t.secretMaterial.webhookSecret}]}):l({title:"Trigger added",body:"The routine schedule was saved.",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to add trigger",body:t instanceof Error?t.message:"Paperclip could not create the trigger.",tone:"error"})},"onError")}),He=U({mutationFn:i(({id:t,patch:h})=>T.updateTrigger(t,h),"mutationFn"),onSuccess:i(async()=>{l({title:"Trigger saved",body:"The routine cadence update was saved.",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to update trigger",body:t instanceof Error?t.message:"Paperclip could not update the trigger.",tone:"error"})},"onError")}),Je=U({mutationFn:i(t=>T.deleteTrigger(t),"mutationFn"),onSuccess:i(async()=>{l({title:"Trigger deleted",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to delete trigger",body:t instanceof Error?t.message:"Paperclip could not delete the trigger.",tone:"error"})},"onError")}),Ze=U({mutationFn:i(t=>T.rotateTriggerSecret(t),"mutationFn"),onSuccess:i(async t=>{D({title:"Webhook secret rotated",entries:[{webhookUrl:t.secretMaterial.webhookUrl,webhookSecret:t.secretMaterial.webhookSecret}]}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to rotate webhook secret",body:t instanceof Error?t.message:"Paperclip could not rotate the webhook secret.",tone:"error"})},"onError")}),we=(0,u.useMemo)(()=>new Map((F??[]).map(t=>[t.id,t])),[F]),Ne=(0,u.useMemo)(()=>new Map((K??[]).map(t=>[t.id,t])),[K]),ae=(0,u.useMemo)(()=>bt(),[o?.id]),Ye=(0,u.useMemo)(()=>yt(),[o?.id]),Xe=(0,u.useMemo)(()=>jt((F??[]).filter(t=>t.status!=="terminated"),ae).map(t=>({id:t.id,label:t.name,searchText:`${t.name} ${t.role} ${t.title??""}`})),[F,ae]),et=(0,u.useMemo)(()=>Os(K??[]),[K]),tt=(0,u.useMemo)(()=>Kt({agents:F,projects:(K??[]).filter(t=>!t.archivedAt),members:fe?.users}),[F,fe?.users,K]),st=(0,u.useCallback)(t=>{P(h=>{const N=typeof t=="function"?t(h):t;return N.assigneeAgentId&&N.assigneeAgentId!==h.assigneeAgentId&&ft(N.assigneeAgentId),N.projectId&&N.projectId!==h.projectId&&wt(N.projectId),N})},[]),it=f.assigneeAgentId?we.get(f.assigneeAgentId)??null:null,nt=f.projectId?Ne.get(f.projectId)??null:null,ke=(0,u.useCallback)(()=>{A(!1),v&&P(v),r.invalidateQueries({queryKey:p.routines.detail(s)})},[r,v,s]),at=(0,u.useCallback)(t=>{t.secretMaterials.length>0&&(M("triggers"),D({title:t.secretMaterials.length===1?"Webhook trigger restored":`${t.secretMaterials.length} webhook triggers restored`,entries:t.secretMaterials.map(h=>({webhookUrl:h.webhookUrl,webhookSecret:h.webhookSecret}))}))},[M]),rt=(0,u.useCallback)(t=>{A(!1),r.setQueryData(p.routines.detail(s),h=>h&&{...h,...t.routine,latestRevisionId:t.revision.id,latestRevisionNumber:t.revision.revisionNumber}),P({title:t.routine.title,description:t.routine.description??"",projectId:t.routine.projectId??"",assigneeAgentId:t.routine.assigneeAgentId??"",priority:t.routine.priority,concurrencyPolicy:t.routine.concurrencyPolicy,catchUpPolicy:t.routine.catchUpPolicy,activityGatePolicy:t.routine.activityGatePolicy,activityGateScope:t.routine.activityGateScope,variables:t.routine.variables,env:t.routine.env??null}),k.current=t.routine.id},[r,s]);if(!n)return(0,e.jsx)(te,{icon:vt,message:"Select a company to view routines."});const re=new URLSearchParams(window.location.search).get("tab");if(s&&re&&Fe[re])return(0,e.jsx)(oe,{to:`/routines/${s}/${Fe[re]}`,replace:!0});if(s&&!a){const t=Ms(s)??"overview";return(0,e.jsx)(oe,{to:`/routines/${s}/${t}`,replace:!0})}if(s&&a&&!ee(a))return(0,e.jsx)(oe,{to:`/routines/${s}/overview`,replace:!0});if(Q)return(0,e.jsx)($t,{variant:"issues-list"});if(W||!o||!v)return(0,e.jsx)(te,{icon:Ot,message:W instanceof Error?W.message:"We couldn't load this routine."});const $=o.status==="active",Se=je.isPending||o.status==="archived",Ie=o.status==="archived"?"Archived":o.assigneeAgentId?$?"Active":"Paused":"Draft",Ce=o.status==="archived"?"text-muted-foreground":$?"text-emerald-400":"text-muted-foreground",Ae={routine:o,routineId:s,companyId:o.companyId,editDraft:f,setEditDraft:st,routineDefaults:v,dirtyFields:H,isEditDirty:ie,sectionDirtyFields:J,isSectionDirty:ne,discardSection:be,saveRoutine:Z,saveConflict:q,reloadLatest:ke,automationEnabled:$,automationLabel:Ie,automationLabelClassName:Ce,automationToggleDisabled:Se,onToggleAutomation:i(()=>{if(!$&&!o.assigneeAgentId){l({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}je.mutate($?"paused":"active")},"onToggleAutomation"),onOpenRunDialog:i(()=>b(!0),"onOpenRunDialog"),runRoutinePending:Y.isPending,newTrigger:j,setNewTrigger:se,createTrigger:Be,updateTrigger:He,deleteTrigger:Je,rotateTrigger:Ze,secretMessage:S,setSecretMessage:D,copySecretValue:Qe,availableSecrets:Ve,createSecret:ze,agents:F??[],projects:K??[],agentById:we,projectById:Ne,assigneeOptions:Xe,projectOptions:et,recentAssigneeIds:ae,recentProjectIds:Ye,mentionOptions:tt,currentAssignee:it,currentProject:nt,routineRuns:y,activity:Ge,hasLiveRun:d,activeIssueId:R,titleInputRef:I,descriptionEditorRef:_,assigneeSelectorRef:C,projectSelectorRef:x,onHistoryRestoreSecretMaterials:at,onHistoryRestored:rt,navigateToSection:M},Pe=Qt.includes(w);return(0,e.jsxs)(ns.Provider,{value:Ae,children:[(0,e.jsx)("a",{href:"#routine-section",className:"sr-only focus:not-sr-only focus:absolute focus:left-2 focus:top-2 focus:z-20 focus:rounded focus:bg-background focus:px-3 focus:py-1.5 focus:text-sm",children:"Skip to section"}),(0,e.jsxs)("div",{className:"-m-4 flex h-full min-h-0 flex-col overflow-hidden md:-m-6",children:[(0,e.jsxs)("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-6",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,e.jsx)("textarea",{ref:I,"data-autosize-title":!0,className:"min-w-0 flex-1 resize-none overflow-hidden bg-transparent text-base font-semibold leading-7 outline-none placeholder:text-muted-foreground/50",placeholder:"Routine title",rows:1,value:f.title,onChange:i(t=>{P(h=>({...h,title:t.target.value})),Ke(t.target)},"onChange"),onKeyDown:i(t=>{t.key==="Enter"&&!t.metaKey&&!t.ctrlKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),w==="overview"?_.current?.focus():M("overview"))},"onKeyDown")}),o.managedByPlugin?(0,e.jsxs)(xe,{variant:"outline",className:"hidden shrink-0 gap-1.5 text-xs text-muted-foreground sm:inline-flex",children:[(0,e.jsx)(Pt,{className:"h-3 w-3"}),o.managedByPlugin.pluginDisplayName,(0,e.jsx)("span",{className:"font-mono text-(length:--text-nano)",children:o.managedByPlugin.resourceKey})]}):null]}),(0,e.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:[(0,e.jsx)(Vt,{onClick:i(()=>b(!0),"onClick"),disabled:Y.isPending}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ct,{size:"default",checked:$,onCheckedChange:Ae.onToggleAutomation,disabled:Se,"aria-label":$?"Pause automatic triggers":"Enable automatic triggers"}),(0,e.jsx)("span",{className:`text-sm font-medium ${Ce}`,children:Ie})]})]})]}),(0,e.jsx)(Gt,{activeSection:w,onNavigate:M,isSectionDirty:ne}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,e.jsx)(is,{activeSection:w,hrefFor:i(t=>`/routines/${s}/${t}`,"hrefFor"),isSectionDirty:ne,hasLiveRun:d,onNavigate:i(t=>le(s,t),"onNavigate")}),(0,e.jsx)("main",{id:"routine-section",role:"main",className:"min-h-0 min-w-0 flex-1 overflow-y-auto px-4 pb-6 pt-10 md:px-8",children:(0,e.jsxs)("section",{"aria-labelledby":"routine-section-title",className:Pe?"mx-auto w-full max-w-3xl":"w-full",children:[(0,e.jsx)("h2",{id:"routine-section-title",className:"mb-4 text-lg font-semibold",children:Ds[w]}),w==="overview"&&(0,e.jsx)(Ss,{}),w==="triggers"&&(0,e.jsx)(Is,{}),w==="variables"&&(0,e.jsx)(Cs,{}),w==="secrets"&&(0,e.jsx)(As,{}),w==="delivery"&&(0,e.jsx)(Ps,{}),w==="runs"&&(0,e.jsx)(Zt,{}),w==="activity"&&(0,e.jsx)(ls,{}),w==="history"&&(0,e.jsx)(Jt,{}),Pe?(0,e.jsx)(us,{dirtyFields:J(w),isSaving:Z.isPending,saveConflict:q,onSave:i(()=>{!Z.isPending&&f.title.trim()&&Z.mutate()},"onSave"),onDiscard:i(()=>be(w),"onDiscard"),onReload:ke}):null]})})]})]}),(0,e.jsx)(Nt,{open:g,onOpenChange:b,companyId:o.companyId,routineName:o.title,agents:F??[],projects:K??[],defaultProjectId:o.projectId,defaultAssigneeAgentId:o.assigneeAgentId,variables:o.variables??[],isPending:Y.isPending,onSubmit:i(t=>Y.mutate(t),"onSubmit")})]})}i(li,"RoutineDetail");export{li as RoutineDetail};
1
+ var ot=Object.defineProperty;var i=(s,a)=>ot(s,"name",{value:a,configurable:!0});import{i as Le}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as ct,Li as lt,Pi as dt,S as ut,Vr as mt,W as pt,Z as p,ni as L,ti as U}from"./agent-avatar-url-DtOIjE-b.js";import{Ht as ht,Mt as Ee,b as gt,o as xt,r as oe}from"./router-CoeH24PK.js";import{At as yt,Ct as Oe,Fr as vt,Ft as ft,Mt as bt,Pt as jt,jt as wt,t as Nt}from"./RoutineRunVariablesDialog-C-j5V71-.js";import{Z as kt}from"./mention-chips-OAQdMAP9.js";import{l as T,t as De}from"./MarkdownEditor-DCE_KC27.js";import{v as St}from"./sheet-_VebRl9q.js";import{t as Me}from"./AgentAvatar-Jt6HpvU2.js";import{k as It}from"./checkbox-CIcktoHJ.js";import{c as Ct,t as O,v as At}from"./label-DSx2Qxn6.js";import{r as Pt,t as Rt}from"./agents-DA5qW1fs.js";import{g as Tt}from"./StatusIcon-BCy8D6Fj.js";import{r as Et,t as te}from"./EmptyState-B1JSbXSE.js";import{c as de,i as ue,n as me,s as pe,t as he}from"./select-DarpvIBM.js";import{r as Ot,t as Dt}from"./save-d5benU21.js";import{k as Mt,t as E}from"./button-yf2m1_gs.js";import{n as _t,t as qt}from"./clipboard-NgncerTn.js";import{t as Ft}from"./heartbeats-DeXOtSp3.js";import{t as xe}from"./badge-DEcdN2HY.js";import{t as G}from"./input-DnT08BOo.js";import{i as Kt,o as Lt}from"./company-members-CDG03HZV.js";import{r as Ut,t as Wt}from"./card-Cl_LFk7c.js";import{t as $t}from"./PageSkeleton-BmmfQJ6g.js";import{B as Gt,Bn as ye,Dt as Vt,F as zt,G as _e,Gn as ve,H as Qt,I as Bt,J as Ue,K as We,L as Ht,M as Jt,N as Zt,P as $e,Qt as X,R as Yt,Tn as Xt,U as es,Un as ts,Ut as ss,V as is,W as ns,Wt as as,Y as rs,Yt as os,en as qe,hn as cs,j as ls,mn as ds,q as z,z as us}from"./index-aJuthquM.js";var u=Le(lt(),1);function ms(s,a,n){const c={label:a.label.trim()||null};return s.kind==="schedule"&&(c.cronExpression=a.cronExpression.trim(),c.timezone=s.timezone??n),s.kind==="webhook"&&(c.signingMode=a.signingMode,c.replayWindowSec=Number(a.replayWindowSec||"300")),c}i(ms,"buildRoutineTriggerPatch");var e=Le(ct(),1),ps=["app_webhook","bearer","hmac_sha256","github_hmac","none"],hs=new Set(["app_webhook","bearer","github_hmac","fireflies_hmac","none"]);function gs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}i(gs,"getLocalTimezone$1");function xs({trigger:s,onSave:a,onRotate:n,onDelete:c,disabled:r}){const[m,l]=(0,u.useState)({label:s.label??"",cronExpression:s.cronExpression??"",signingMode:s.signingMode??"bearer",replayWindowSec:String(s.replayWindowSec??300)});(0,u.useEffect)(()=>{l({label:s.label??"",cronExpression:s.cronExpression??"",signingMode:s.signingMode??"bearer",replayWindowSec:String(s.replayWindowSec??300)})},[s]);const k=s.kind==="schedule"?ye:s.kind==="webhook"?cs:gt,I=s.kind==="schedule"?Bt(m.cronExpression):null,_=/fail|error/i.test(s.lastResult??""),C=s.lastResult?.startsWith("Created execution issue ")?"Task created":s.lastResult;return(0,e.jsxs)("form",{"aria-label":`Trigger: ${s.label??s.kind}`,className:"space-y-4 rounded-lg border border-border p-4",onSubmit:i(x=>x.preventDefault(),"onSubmit"),children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,e.jsx)(k,{className:"h-3.5 w-3.5 shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:s.label??s.kind})]}),I?(0,e.jsx)("p",{id:`cron-readable-${s.id}`,className:"text-xs text-muted-foreground",children:I}):null]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[s.lastResult?(0,e.jsx)(xe,{variant:_?"destructive":"secondary",children:C}):null,(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:s.kind==="schedule"&&s.nextRunAt?`Next: ${new Date(s.nextRunAt).toLocaleString()}`:s.kind==="webhook"?"Webhook":"API"})]})]}),s.kind==="webhook"&&s.webhookUrl&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{htmlFor:`webhook-url-${s.id}`,className:"text-xs",children:"Webhook URL"}),(0,e.jsx)(G,{id:`webhook-url-${s.id}`,value:s.webhookUrl,readOnly:!0,onFocus:i(x=>x.target.select(),"onFocus")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Send a POST request with Content-Type: application/json. Keep this URL private when signing is disabled."})]}),(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Label"}),(0,e.jsx)(G,{value:m.label,disabled:r,onChange:i(x=>l(S=>({...S,label:x.target.value})),"onChange")})]}),s.kind==="schedule"&&(0,e.jsxs)("div",{className:"space-y-1.5 md:col-span-2",children:[(0,e.jsx)(O,{className:"text-xs",children:"Schedule"}),(0,e.jsx)($e,{value:m.cronExpression,onChange:i(x=>l(S=>({...S,cronExpression:x})),"onChange")})]}),s.kind==="webhook"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Signing mode"}),(0,e.jsxs)(he,{value:m.signingMode,onValueChange:i(x=>l(S=>({...S,signingMode:x})),"onValueChange"),disabled:r,children:[(0,e.jsx)(pe,{children:(0,e.jsx)(de,{})}),(0,e.jsx)(me,{children:ps.map(x=>(0,e.jsx)(ue,{value:x,children:x},x))})]})]}),!hs.has(m.signingMode)&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Replay window (seconds)"}),(0,e.jsx)(G,{value:m.replayWindowSec,disabled:r,onChange:i(x=>l(S=>({...S,replayWindowSec:x.target.value})),"onChange")})]})]})]}),!r&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,e.jsxs)(E,{variant:"ghost",size:"sm",className:"mr-auto text-muted-foreground hover:text-destructive",onClick:i(()=>c(s.id),"onClick"),children:[(0,e.jsx)(It,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.kind==="webhook"&&(0,e.jsxs)(E,{variant:"outline",size:"sm",onClick:i(()=>n(s.id),"onClick"),children:[(0,e.jsx)(St,{className:"mr-1.5 h-3.5 w-3.5"}),"Rotate secret"]}),(0,e.jsxs)(E,{variant:"outline",size:"sm",onClick:i(()=>a(s.id,ms(s,m,gs())),"onClick"),children:[(0,e.jsx)(Dt,{className:"mr-1.5 h-3.5 w-3.5"}),"Save trigger"]})]})]})}i(xs,"RoutineTriggerCard");var ys=[{value:"coalesce_if_active",title:"Coalesce if active",description:"Keep one follow-up run queued while an active run is still working."},{value:"always_enqueue",title:"Always enqueue",description:"Queue every trigger occurrence, even if several runs stack up."},{value:"skip_if_active",title:"Skip if active",description:"Drop overlapping trigger occurrences while the routine is already active."}],vs=[{value:"skip_missed",title:"Skip missed",description:"Ignore schedule windows that were missed while paused."},{value:"enqueue_missed_with_cap",title:"Enqueue missed with cap",description:"Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap."}],fs=[{value:"always",title:"Run on every scheduled tick",description:"Fire on the schedule no matter what — the default behavior."},{value:"require_external_activity",title:"Skip when there's been no activity since the last run",description:"On a scheduled tick, only run if something happened since the last run that finished. Lets a watcher-style routine stay asleep while the system is settled instead of burning tokens."}],bs=[{value:"company",title:"Company-wide",description:"Any activity across the company counts as a reason to run."},{value:"project",title:"This project",description:"Only activity in the routine's project counts as a reason to run."}],js=["schedule","webhook"],ws=["app_webhook","bearer","hmac_sha256","github_hmac","none"],Ns={bearer:"Send Authorization: Bearer <secret> with each request.",hmac_sha256:"Send X-Paperclip-Timestamp and X-Paperclip-Signature: sha256=<hex>, signing timestamp + a dot + the exact JSON body.",github_hmac:"Accept GitHub-style X-Hub-Signature-256 header (HMAC over raw body, no timestamp).",app_webhook:"Accept a bearer token or an HMAC-SHA256 signature over the exact request body in X-Hub-Signature or X-Hub-Signature-256.",fireflies_hmac:"Signed webhook (legacy).",none:"No authentication — the webhook URL itself acts as a shared secret."},ks=new Set(["app_webhook","bearer","github_hmac","fireflies_hmac","none"]);function Ss({defaultDescriptionAnnotationsOpen:s=!1}={}){const{routine:a,editDraft:n,setEditDraft:c,assigneeOptions:r,projectOptions:m,recentAssigneeIds:l,recentProjectIds:k,agentById:I,projectById:_,currentAssignee:C,currentProject:x,mentionOptions:S,assigneeSelectorRef:D,projectSelectorRef:q,descriptionEditorRef:A,routineRuns:g,activity:b,saveRoutine:j,saveConflict:se,isSectionDirty:f,navigateToSection:P}=z(),[w,M]=(0,u.useState)(s),o=a.triggers.length,Q=(0,u.useMemo)(()=>{const d=a.triggers.filter(y=>y.kind==="schedule"&&y.nextRunAt).map(y=>new Date(y.nextRunAt)).sort((y,V)=>y.getTime()-V.getTime())[0];return d?d.toLocaleString():null},[a.triggers]),W=n.env?Object.keys(n.env).length:0,R=(g??[])[0]??null,B=(b??[]).slice(0,5);return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,e.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-muted-foreground sm:min-w-max sm:flex-nowrap",children:[(0,e.jsx)("span",{children:"For"}),(0,e.jsx)(Oe,{ref:D,value:n.assigneeAgentId,options:r,recentOptionIds:l,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:i(d=>c(y=>({...y,assigneeAgentId:d})),"onChange"),onConfirm:i(()=>{n.projectId?A.current?.focus():q.current?.focus()},"onConfirm"),renderTriggerValue:i(d=>d?C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Me,{agent:C,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"truncate",children:d.label})]}):(0,e.jsx)("span",{className:"truncate",children:d.label}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"Responsible"}),"renderTriggerValue"),renderOption:i(d=>{if(!d.id)return(0,e.jsx)("span",{className:"truncate",children:d.label});const y=I.get(d.id);return(0,e.jsxs)(e.Fragment,{children:[y?(0,e.jsx)(Me,{agent:y,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):null,(0,e.jsx)("span",{className:"truncate",children:d.label})]})},"renderOption")}),(0,e.jsx)("span",{children:"in"}),(0,e.jsx)(Oe,{ref:q,value:n.projectId,options:m,recentOptionIds:k,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:i(d=>c(y=>({...y,projectId:d})),"onChange"),onConfirm:i(()=>A.current?.focus(),"onConfirm"),renderTriggerValue:i(d=>d&&x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:x.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:d.label})]}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"Project"}),"renderTriggerValue"),renderOption:i(d=>{if(!d.id)return(0,e.jsx)("span",{className:"truncate",children:d.label});const y=_.get(d.id);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:y?.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:d.label})]})},"renderOption")})]})}),a.assigneeAgentId?null:(0,e.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-900 dark:text-amber-200",children:"Default agent required. This routine can stay as a draft and still run manually, but automation stays paused until you assign a default agent."}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"flex items-center justify-end",children:a.descriptionDocument?(0,e.jsx)(ss,{issueId:a.id,docKey:"description",target:{kind:"routine",routineId:a.id,documentKey:"description"},panelOpen:w,onToggle:i(()=>M(d=>!d),"onToggle")}):null}),a.descriptionDocument?(0,e.jsx)(as,{issueId:a.id,doc:a.descriptionDocument,target:{kind:"routine",routineId:a.id,documentKey:"description"},bodyMarkdown:n.description,draftDirty:f("overview")||j.isPending,draftConflicted:se,historicalPreview:!1,locationHash:typeof window>"u"?"":window.location.hash,panelOpen:w,onPanelOpenChange:M,children:(0,e.jsx)(De,{ref:A,value:n.description,onChange:i(d=>c(y=>({...y,description:d})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-120px) text-sm leading-7",mentions:S,onSubmit:i(()=>{!j.isPending&&n.title.trim()&&j.mutate()},"onSubmit")})}):(0,e.jsx)(De,{ref:A,value:n.description,onChange:i(d=>c(y=>({...y,description:d})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-120px) text-sm leading-7",mentions:S,onSubmit:i(()=>{!j.isPending&&n.title.trim()&&j.mutate()},"onSubmit")})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(rs,{}),(0,e.jsx)(Ue,{title:n.title,description:n.description,value:n.variables,onChange:i(d=>c(y=>({...y,variables:d})),"onChange")})]}),(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,e.jsx)(ce,{icon:ye,label:"Triggers",value:o===0?"None":`${o} active`,hint:Q?`Next fire ${Q}`:"No schedule",to:i(()=>P("triggers"),"to"),ariaLabel:`${o} triggers. Open triggers.`}),(0,e.jsx)(ce,{icon:_t,label:"Secrets",value:W===0?"None":`${W} bound`,hint:"Manage bound secrets",to:i(()=>P("secrets"),"to"),ariaLabel:`${W} secrets bound. Open secrets.`}),(0,e.jsx)(ce,{icon:At,label:"Last run",value:R?R.status.replaceAll("_"," "):"No runs",hint:R?Ee(R.triggeredAt):"Trigger a run",to:i(()=>P("runs"),"to"),ariaLabel:R?`Last run ${R.status}. Open runs.`:"No runs. Open runs."})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Recent activity"}),B.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No activity yet."}):(0,e.jsxs)("div",{className:"divide-y divide-border/60",children:[B.map(d=>(0,e.jsxs)("div",{className:"flex items-center gap-2 py-1.5 text-xs",children:[(0,e.jsx)(xe,{variant:"outline",className:"shrink-0 font-mono",children:d.action}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:d.details&&Object.keys(d.details).length>0?Object.keys(d.details).slice(0,3).join(" · "):""}),(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground/60",children:Ee(d.createdAt)})]},d.id)),(0,e.jsxs)("button",{type:"button",onClick:i(()=>P("activity"),"onClick"),className:"flex items-center gap-1 pt-2 text-xs text-muted-foreground hover:text-foreground",children:["View all activity ",(0,e.jsx)(ve,{className:"h-3 w-3"})]})]})]})]})}i(Ss,"OverviewSection");function ce({icon:s,label:a,value:n,hint:c,to:r,ariaLabel:m}){return(0,e.jsx)("button",{type:"button",onClick:r,"aria-label":m,className:"text-left",children:(0,e.jsx)(Wt,{className:"gap-2 p-4 transition-colors hover:border-border hover:bg-accent/30",children:(0,e.jsxs)(Ut,{className:"space-y-1 p-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground",children:[(0,e.jsx)(s,{className:"h-3.5 w-3.5"}),a,(0,e.jsx)(ve,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground/60"})]}),(0,e.jsx)("p",{className:"text-lg font-semibold",children:n}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:c})]})})})}i(ce,"SummaryCard");function Is(){const{routine:s,newTrigger:a,setNewTrigger:n,createTrigger:c,updateTrigger:r,deleteTrigger:m,rotateTrigger:l,secretMessage:k,copySecretValue:I,setSecretMessage:_}=z(),[C,x]=(0,u.useState)(!1),[S,D]=(0,u.useState)(!0),q=(0,u.useMemo)(()=>a.kind==="schedule"?zt(a.cronExpression):null,[a.cronExpression,a.kind]),A=c.isPending||(q?!q.valid||!S:!1);return(0,u.useEffect)(()=>{a.kind!=="schedule"&&D(!0)},[a.kind]),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:s.triggers.length===0?"No triggers yet":`${s.triggers.length} trigger${s.triggers.length===1?"":"s"}`}),(0,e.jsx)(E,{size:"sm",variant:C?"secondary":"default",onClick:i(()=>x(g=>!g),"onClick"),"aria-expanded":C,children:C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(kt,{className:"mr-1.5 h-3.5 w-3.5"}),"Cancel"]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Mt,{className:"mr-1.5 h-3.5 w-3.5"}),"New trigger"]})})]}),C?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-border p-4",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Add trigger"}),(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Kind"}),(0,e.jsxs)(he,{value:a.kind,onValueChange:i(g=>n(b=>({...b,kind:g})),"onValueChange"),children:[(0,e.jsx)(pe,{children:(0,e.jsx)(de,{})}),(0,e.jsx)(me,{children:js.map(g=>(0,e.jsx)(ue,{value:g,children:g},g))})]})]}),a.kind==="schedule"&&(0,e.jsxs)("div",{className:"space-y-1.5 md:col-span-2",children:[(0,e.jsx)(O,{className:"text-xs",children:"Schedule"}),(0,e.jsx)($e,{value:a.cronExpression,onChange:i(g=>n(b=>({...b,cronExpression:g})),"onChange"),onValidityChange:D})]}),a.kind==="webhook"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Signing mode"}),(0,e.jsxs)(he,{value:a.signingMode,onValueChange:i(g=>n(b=>({...b,signingMode:g})),"onValueChange"),children:[(0,e.jsx)(pe,{children:(0,e.jsx)(de,{})}),(0,e.jsx)(me,{children:ws.map(g=>(0,e.jsx)(ue,{value:g,children:g},g))})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:Ns[a.signingMode]})]}),!ks.has(a.signingMode)&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(O,{className:"text-xs",children:"Replay window (seconds)"}),(0,e.jsx)(G,{value:a.replayWindowSec,onChange:i(g=>n(b=>({...b,replayWindowSec:g.target.value})),"onChange")})]})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)(E,{size:"sm",variant:"ghost",onClick:i(()=>x(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(E,{size:"sm",onClick:i(()=>c.mutate(void 0,{onSuccess:i(()=>{n(We()),x(!1)},"onSuccess")}),"onClick"),disabled:A,children:c.isPending?"Adding...":"Add trigger"})]})]}):null,k?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-border bg-muted/20 p-4 text-sm",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium",children:k.title}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Save this now. Paperclip will not show the secret value again."})]}),(0,e.jsx)("div",{className:"space-y-3",children:k.entries.map((g,b)=>(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(G,{"aria-label":"New webhook URL",value:g.webhookUrl,readOnly:!0,className:"flex-1"}),(0,e.jsx)(E,{variant:"outline",size:"sm",onClick:i(()=>I("Webhook URL",g.webhookUrl),"onClick"),children:"URL"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(G,{"aria-label":"New webhook secret",value:g.webhookSecret,readOnly:!0,className:"flex-1"}),(0,e.jsx)(E,{variant:"outline",size:"sm",onClick:i(()=>I("Webhook secret",g.webhookSecret),"onClick"),children:"Secret"})]})]},`${g.webhookUrl}-${b}`))}),(0,e.jsx)(E,{variant:"outline",size:"sm",onClick:i(()=>_(null),"onClick"),children:"Done"})]}):null,s.triggers.length===0?(0,e.jsx)(te,{icon:ye,message:"No triggers yet.",action:"Add a trigger",onAction:i(()=>x(!0),"onAction")}):(0,e.jsx)("div",{className:"space-y-3",children:s.triggers.map(g=>(0,e.jsx)(xs,{trigger:g,onSave:i((b,j)=>r.mutate({id:b,patch:j}),"onSave"),onRotate:i(b=>l.mutate(b),"onRotate"),onDelete:i(b=>m.mutate(b),"onDelete")},g.id))})]})}i(Is,"TriggersSection");function Cs(){const{editDraft:s,setEditDraft:a,navigateToSection:n}=z(),c=s.variables.length>0;return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border bg-muted/20 px-4 py-3 text-xs",children:[(0,e.jsxs)("span",{className:"flex-1 text-muted-foreground",children:["Variables are auto-detected from ",(0,e.jsx)("code",{className:"font-mono",children:"{{placeholders}}"})," in the title & instructions. The variable name is read-only — rename by editing the placeholder."]}),(0,e.jsxs)(E,{variant:"secondary",size:"sm",onClick:i(()=>n("overview"),"onClick"),children:[(0,e.jsx)(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit instructions"]})]}),c?(0,e.jsx)(Ue,{title:s.title,description:s.description,value:s.variables,onChange:i(r=>a(m=>({...m,variables:r})),"onChange")}):(0,e.jsx)(te,{icon:ts,message:"No variables yet. Add a {{placeholder}} in the title or instructions to create one.",action:"Edit instructions",onAction:i(()=>n("overview"),"onAction")})]})}i(Cs,"VariablesSection");function As(){const{editDraft:s,setEditDraft:a,availableSecrets:n,createSecret:c}=z(),r=(0,u.useMemo)(()=>[...n].filter(m=>m.status==="active").sort((m,l)=>{const k=(l.referenceCount??0)-(m.referenceCount??0);return k!==0?k:new Date(l.updatedAt).getTime()-new Date(m.updatedAt).getTime()}).slice(0,8),[n]);return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"rounded-md border border-border bg-muted/20 px-4 py-3 text-xs text-muted-foreground",children:["Routine secrets apply to every task this routine creates. They override matching keys in project and agent env. ",(0,e.jsx)("span",{className:"font-mono",children:"PAPERCLIP_*"})," names are reserved."]}),(0,e.jsx)(os,{value:s.env??{},secrets:n,recentlyUsedSecrets:r,onCreateSecret:i(async(m,l)=>c.mutateAsync({name:m,value:l}),"onCreateSecret"),onChange:i(m=>a(l=>({...l,env:m??null})),"onChange")})]})}i(As,"SecretsSection");function Ps(){const{editDraft:s,setEditDraft:a,routine:n}=z(),c=n.triggers.some(m=>m.kind==="schedule"),r=s.activityGatePolicy==="require_external_activity";return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Concurrency"}),(0,e.jsx)(X,{ariaLabel:"Concurrency policy",value:s.concurrencyPolicy,onValueChange:i(m=>a(l=>({...l,concurrencyPolicy:m})),"onValueChange"),options:ys})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Catch-up"}),(0,e.jsx)(X,{ariaLabel:"Catch-up policy",value:s.catchUpPolicy,onValueChange:i(m=>a(l=>({...l,catchUpPolicy:m})),"onValueChange"),options:vs})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Advanced run policy"}),(0,e.jsx)(X,{ariaLabel:"Advanced run policy",value:s.activityGatePolicy,onValueChange:i(m=>a(l=>({...l,activityGatePolicy:m})),"onValueChange"),options:fs,disabled:!c}),c?r?(0,e.jsxs)("div",{className:"space-y-2 rounded-lg border border-border p-3",children:[(0,e.jsx)(O,{className:"text-xs font-medium",children:"Activity scope"}),(0,e.jsx)(X,{ariaLabel:"Activity gate scope",value:s.activityGateScope,onValueChange:i(m=>a(l=>({...l,activityGateScope:m})),"onValueChange"),options:bs})]}):null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add a schedule trigger to gate runs on activity. Webhook, manual, and API fires always run."})]}),(0,e.jsx)(Ts,{triggers:n.triggers,concurrencyPolicy:s.concurrencyPolicy})]})}i(Ps,"DeliverySection");var Rs={queued:"text-emerald-600 dark:text-emerald-400",coalesced:"text-amber-600 dark:text-amber-400",skipped:"text-muted-foreground"};function Ts({triggers:s,concurrencyPolicy:a}){const n=(0,u.useMemo)(()=>{const c=s.filter(r=>r.kind==="schedule"&&r.enabled&&r.cronExpression).map(r=>({trigger:r,fires:Ht(r.cronExpression,5,{timeZone:r.timezone??"UTC"})})).filter(r=>r.fires.length>0).sort((r,m)=>r.fires[0].getTime()-m.fires[0].getTime())[0];return c?{timeZone:c.trigger.timezone??"UTC",entries:Yt(c.fires,a)}:null},[s,a]);return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground",children:"Next 5 fires"}),n?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"space-y-1.5 rounded-lg border border-border p-3 font-mono text-xs",children:n.entries.map((c,r)=>(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,e.jsx)("span",{className:"tabular-nums",children:Es(c.at,n.timeZone)}),(0,e.jsx)(ve,{className:"h-3 w-3 shrink-0 text-muted-foreground/50"}),(0,e.jsx)("span",{className:ut("font-medium",Rs[c.disposition]),children:c.label}),c.note?(0,e.jsxs)("span",{className:"truncate text-muted-foreground/60",children:["(",c.note,")"]}):null]},r))}),(0,e.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/60",children:["Preview assumes the previous run is still in flight when the next fires. Times shown in"," ",n.timeZone,"."]})]}):(0,e.jsx)("p",{className:"rounded-lg border border-dashed border-border p-3 text-xs text-muted-foreground",children:"No enabled schedule trigger to preview. Add a schedule in Triggers to see how this policy treats upcoming fires."})]})}i(Ts,"NextFiresPreview");function Es(s,a){try{return new Intl.DateTimeFormat(void 0,{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(s).replace(",","")}catch{return s.toISOString()}}i(Es,"formatFireTime");var ge="paperclip.routineLastSection";function Os(s){return s.filter(a=>!a.archivedAt).map(a=>({id:a.id,label:a.name,searchText:a.description??""}))}i(Os,"buildRoutineProjectOptions");var Ds={overview:"Overview",triggers:"Triggers",variables:"Variables",secrets:"Secrets",delivery:"Delivery",runs:"Runs",activity:"Activity",history:"History"};function ee(s){return s!=null&&es.includes(s)}i(ee,"isRoutineSection");function Ms(s){try{const a=localStorage.getItem(ge);if(!a)return null;const n=JSON.parse(a)[s];return ee(n)?n:null}catch{return null}}i(Ms,"readLastSection");function le(s,a){try{const n=localStorage.getItem(ge),c=n?JSON.parse(n):{};c[s]=a,localStorage.setItem(ge,JSON.stringify(c))}catch{}}i(le,"writeLastSection");var Fe={triggers:"triggers",runs:"runs",activity:"activity",secrets:"secrets",history:"history"};function Ke(s){s&&(s.style.height="auto",s.style.height=`${s.scrollHeight}px`)}i(Ke,"autoResizeTextarea");function _s(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}i(_s,"getLocalTimezone");function qs(s){return{...s,description:s.description.trim()||null,projectId:s.projectId||null,assigneeAgentId:s.assigneeAgentId||null,env:s.env&&Object.keys(s.env).length>0?s.env:null}}i(qs,"buildRoutineMutationPayload");function li(){const{routineId:s,section:a}=ht(),{selectedCompanyId:n}=pt(),{setBreadcrumbs:c}=Et(),r=dt(),m=xt(),{pushToast:l}=ds(),k=(0,u.useRef)(null),I=(0,u.useRef)(null),_=(0,u.useRef)(null),C=(0,u.useRef)(null),x=(0,u.useRef)(null),[S,D]=(0,u.useState)(null),[q,A]=(0,u.useState)(!1),[g,b]=(0,u.useState)(!1),[j,se]=(0,u.useState)(We),[f,P]=(0,u.useState)({title:"",description:"",projectId:"",assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",activityGatePolicy:"always",activityGateScope:"company",variables:[],env:null}),w=ee(a)?a:"overview",M=(0,u.useCallback)((t,h)=>{s&&(le(s,t),m(`/routines/${s}/${t}`,{replace:h?.replace??!0}))},[m,s]),{data:o,isLoading:Q,error:W}=L({queryKey:p.routines.detail(s),queryFn:i(()=>T.get(s),"queryFn"),enabled:!!s}),R=o?.activeIssue?.id,{data:B}=L({queryKey:p.issues.liveRuns(R),queryFn:i(()=>Ft.liveRunsForIssue(R),"queryFn"),enabled:!!R,refetchInterval:3e3}),d=(B??[]).length>0,{data:y}=L({queryKey:p.routines.runs(s),queryFn:i(()=>T.listRuns(s),"queryFn"),enabled:!!s,refetchInterval:d?3e3:!1}),V=(0,u.useMemo)(()=>({triggerIds:o?.triggers.map(t=>t.id)??[],runIds:y?.map(t=>t.id)??[]}),[o?.triggers,y]),{data:Ge}=L({queryKey:[...p.routines.activity(n,s),V.triggerIds.join(","),V.runIds.join(",")],queryFn:i(()=>T.activity(n,s,V),"queryFn"),enabled:!!n&&!!s&&!!o}),{data:F}=L({queryKey:p.agents.list(n),queryFn:i(()=>Rt.list(n),"queryFn"),enabled:!!n}),{data:K}=L({queryKey:p.projects.list(n,{includeArchived:!0}),queryFn:i(()=>Tt.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:fe}=L({queryKey:p.access.companyUserDirectory(n),queryFn:i(()=>Lt.listUserDirectory(n),"queryFn"),enabled:!!n}),{data:Ve=[]}=L({queryKey:n?p.secrets.list(n):["secrets","none"],queryFn:i(()=>qe.list(n),"queryFn"),enabled:!!n}),ze=U({mutationFn:i(t=>{if(!n)throw new Error("Select a company to create secrets");return qe.create(n,t)},"mutationFn"),onSuccess:i(()=>{n&&r.invalidateQueries({queryKey:p.secrets.list(n)})},"onSuccess")}),v=(0,u.useMemo)(()=>o?{title:o.title,description:o.description??"",projectId:o.projectId??"",assigneeAgentId:o.assigneeAgentId??"",priority:o.priority,concurrencyPolicy:o.concurrencyPolicy,catchUpPolicy:o.catchUpPolicy,activityGatePolicy:o.activityGatePolicy,activityGateScope:o.activityGateScope,variables:o.variables,env:o.env??null}:null,[o]),H=(0,u.useMemo)(()=>{if(!v)return[];const t=[];return f.title!==v.title&&t.push({key:"title",label:"the title"}),f.description!==v.description&&t.push({key:"description",label:"the description"}),f.projectId!==v.projectId&&t.push({key:"projectId",label:"the project"}),f.assigneeAgentId!==v.assigneeAgentId&&t.push({key:"assigneeAgentId",label:"the default agent"}),f.priority!==v.priority&&t.push({key:"priority",label:"the priority"}),f.concurrencyPolicy!==v.concurrencyPolicy&&t.push({key:"concurrencyPolicy",label:"the concurrency policy"}),f.catchUpPolicy!==v.catchUpPolicy&&t.push({key:"catchUpPolicy",label:"the catch-up policy"}),f.activityGatePolicy!==v.activityGatePolicy&&t.push({key:"activityGatePolicy",label:"the advanced run policy"}),f.activityGateScope!==v.activityGateScope&&t.push({key:"activityGateScope",label:"the activity gate scope"}),JSON.stringify(f.variables)!==JSON.stringify(v.variables)&&t.push({key:"variables",label:"the variables"}),JSON.stringify(f.env??null)!==JSON.stringify(v.env??null)&&t.push({key:"env",label:"the secrets"}),t},[f,v]),ie=H.length>0,J=(0,u.useCallback)(t=>{const h=_e[t];return h?H.filter(N=>h.includes(N.key)):[]},[H]),ne=(0,u.useCallback)(t=>J(t).length>0,[J]),be=(0,u.useCallback)(t=>{if(!v)return;const h=_e[t];h&&P(N=>{const Re={...N};for(const Te of h)Re[Te]=v[Te];return Re})},[v]);(0,u.useEffect)(()=>{o&&(c([{label:"Routines",href:"/routines"},{label:o.title}]),v&&(k.current!==o.id||!ie)&&(P(v),k.current=o.id))},[o,v,ie,c]),(0,u.useEffect)(()=>{Ke(I.current)},[f.title,o?.id]),(0,u.useEffect)(()=>{s&&ee(a)&&le(s,a)},[s,a]);const Qe=(0,u.useCallback)(async(t,h)=>{try{await qt(h),l({title:`${t} copied`,tone:"success"})}catch(N){l({title:`Failed to copy ${t.toLowerCase()}`,body:N instanceof Error?N.message:"Clipboard access was denied.",tone:"error"})}},[l]),Z=U({mutationFn:i(()=>{const t=qs(f),h=o?.latestRevisionId??null;return T.update(s,{...t,...h?{baseRevisionId:h}:{}})},"mutationFn"),onSuccess:i(async()=>{A(!1),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)}),r.invalidateQueries({queryKey:p.routines.revisions(s)})])},"onSuccess"),onError:i(t=>{if(t instanceof mt&&t.status===409){A(!0),l({title:"Routine changed",body:"Someone else updated this routine. Reload to see the latest revision.",tone:"warn"});return}l({title:"Failed to save routine",body:t instanceof Error?t.message:"Paperclip could not save the routine.",tone:"error"})},"onError")}),Y=U({mutationFn:i(t=>T.run(s,{...t?.variables&&Object.keys(t.variables).length>0?{variables:t.variables}:{},...t?.assigneeAgentId!==void 0?{assigneeAgentId:t.assigneeAgentId}:{},...t?.projectId!==void 0?{projectId:t.projectId}:{},...t?.executionWorkspaceId!==void 0?{executionWorkspaceId:t.executionWorkspaceId}:{},...t?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:t.executionWorkspacePreference}:{},...t?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:t.executionWorkspaceSettings}:{}}),"mutationFn"),onSuccess:i(async()=>{l({title:"Routine run started",tone:"success"}),b(!1),M("runs"),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.runs(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Routine run failed",body:t instanceof Error?t.message:"Paperclip could not start the routine run.",tone:"error"})},"onError")}),je=U({mutationFn:i(t=>T.update(s,{status:t}),"mutationFn"),onSuccess:i(async(t,h)=>{l({title:"Routine saved",body:h==="paused"?"Automation paused.":"Automation enabled.",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to update routine",body:t instanceof Error?t.message:"Paperclip could not update the routine.",tone:"error"})},"onError")}),Be=U({mutationFn:i(async()=>{const t=(o?.triggers??[]).filter(N=>N.kind===j.kind).length,h=t>0?`${j.kind}-${t+1}`:j.kind;return T.createTrigger(s,{kind:j.kind,label:h,...j.kind==="schedule"?{cronExpression:j.cronExpression.trim(),timezone:_s()}:{},...j.kind==="webhook"?{signingMode:j.signingMode,replayWindowSec:Number(j.replayWindowSec||"300")}:{}})},"mutationFn"),onSuccess:i(async t=>{t.secretMaterial?D({title:"Webhook trigger created",entries:[{webhookUrl:t.secretMaterial.webhookUrl,webhookSecret:t.secretMaterial.webhookSecret}]}):l({title:"Trigger added",body:"The routine schedule was saved.",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to add trigger",body:t instanceof Error?t.message:"Paperclip could not create the trigger.",tone:"error"})},"onError")}),He=U({mutationFn:i(({id:t,patch:h})=>T.updateTrigger(t,h),"mutationFn"),onSuccess:i(async()=>{l({title:"Trigger saved",body:"The routine cadence update was saved.",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to update trigger",body:t instanceof Error?t.message:"Paperclip could not update the trigger.",tone:"error"})},"onError")}),Je=U({mutationFn:i(t=>T.deleteTrigger(t),"mutationFn"),onSuccess:i(async()=>{l({title:"Trigger deleted",tone:"success"}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.list(n)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to delete trigger",body:t instanceof Error?t.message:"Paperclip could not delete the trigger.",tone:"error"})},"onError")}),Ze=U({mutationFn:i(t=>T.rotateTriggerSecret(t),"mutationFn"),onSuccess:i(async t=>{D({title:"Webhook secret rotated",entries:[{webhookUrl:t.secretMaterial.webhookUrl,webhookSecret:t.secretMaterial.webhookSecret}]}),await Promise.all([r.invalidateQueries({queryKey:p.routines.detail(s)}),r.invalidateQueries({queryKey:p.routines.activity(n,s)})])},"onSuccess"),onError:i(t=>{l({title:"Failed to rotate webhook secret",body:t instanceof Error?t.message:"Paperclip could not rotate the webhook secret.",tone:"error"})},"onError")}),we=(0,u.useMemo)(()=>new Map((F??[]).map(t=>[t.id,t])),[F]),Ne=(0,u.useMemo)(()=>new Map((K??[]).map(t=>[t.id,t])),[K]),ae=(0,u.useMemo)(()=>bt(),[o?.id]),Ye=(0,u.useMemo)(()=>yt(),[o?.id]),Xe=(0,u.useMemo)(()=>jt((F??[]).filter(t=>t.status!=="terminated"),ae).map(t=>({id:t.id,label:t.name,searchText:`${t.name} ${t.role} ${t.title??""}`})),[F,ae]),et=(0,u.useMemo)(()=>Os(K??[]),[K]),tt=(0,u.useMemo)(()=>Kt({agents:F,projects:(K??[]).filter(t=>!t.archivedAt),members:fe?.users}),[F,fe?.users,K]),st=(0,u.useCallback)(t=>{P(h=>{const N=typeof t=="function"?t(h):t;return N.assigneeAgentId&&N.assigneeAgentId!==h.assigneeAgentId&&ft(N.assigneeAgentId),N.projectId&&N.projectId!==h.projectId&&wt(N.projectId),N})},[]),it=f.assigneeAgentId?we.get(f.assigneeAgentId)??null:null,nt=f.projectId?Ne.get(f.projectId)??null:null,ke=(0,u.useCallback)(()=>{A(!1),v&&P(v),r.invalidateQueries({queryKey:p.routines.detail(s)})},[r,v,s]),at=(0,u.useCallback)(t=>{t.secretMaterials.length>0&&(M("triggers"),D({title:t.secretMaterials.length===1?"Webhook trigger restored":`${t.secretMaterials.length} webhook triggers restored`,entries:t.secretMaterials.map(h=>({webhookUrl:h.webhookUrl,webhookSecret:h.webhookSecret}))}))},[M]),rt=(0,u.useCallback)(t=>{A(!1),r.setQueryData(p.routines.detail(s),h=>h&&{...h,...t.routine,latestRevisionId:t.revision.id,latestRevisionNumber:t.revision.revisionNumber}),P({title:t.routine.title,description:t.routine.description??"",projectId:t.routine.projectId??"",assigneeAgentId:t.routine.assigneeAgentId??"",priority:t.routine.priority,concurrencyPolicy:t.routine.concurrencyPolicy,catchUpPolicy:t.routine.catchUpPolicy,activityGatePolicy:t.routine.activityGatePolicy,activityGateScope:t.routine.activityGateScope,variables:t.routine.variables,env:t.routine.env??null}),k.current=t.routine.id},[r,s]);if(!n)return(0,e.jsx)(te,{icon:vt,message:"Select a company to view routines."});const re=new URLSearchParams(window.location.search).get("tab");if(s&&re&&Fe[re])return(0,e.jsx)(oe,{to:`/routines/${s}/${Fe[re]}`,replace:!0});if(s&&!a){const t=Ms(s)??"overview";return(0,e.jsx)(oe,{to:`/routines/${s}/${t}`,replace:!0})}if(s&&a&&!ee(a))return(0,e.jsx)(oe,{to:`/routines/${s}/overview`,replace:!0});if(Q)return(0,e.jsx)($t,{variant:"issues-list"});if(W||!o||!v)return(0,e.jsx)(te,{icon:Ot,message:W instanceof Error?W.message:"We couldn't load this routine."});const $=o.status==="active",Se=je.isPending||o.status==="archived",Ie=o.status==="archived"?"Archived":o.assigneeAgentId?$?"Active":"Paused":"Draft",Ce=o.status==="archived"?"text-muted-foreground":$?"text-emerald-400":"text-muted-foreground",Ae={routine:o,routineId:s,companyId:o.companyId,editDraft:f,setEditDraft:st,routineDefaults:v,dirtyFields:H,isEditDirty:ie,sectionDirtyFields:J,isSectionDirty:ne,discardSection:be,saveRoutine:Z,saveConflict:q,reloadLatest:ke,automationEnabled:$,automationLabel:Ie,automationLabelClassName:Ce,automationToggleDisabled:Se,onToggleAutomation:i(()=>{if(!$&&!o.assigneeAgentId){l({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}je.mutate($?"paused":"active")},"onToggleAutomation"),onOpenRunDialog:i(()=>b(!0),"onOpenRunDialog"),runRoutinePending:Y.isPending,newTrigger:j,setNewTrigger:se,createTrigger:Be,updateTrigger:He,deleteTrigger:Je,rotateTrigger:Ze,secretMessage:S,setSecretMessage:D,copySecretValue:Qe,availableSecrets:Ve,createSecret:ze,agents:F??[],projects:K??[],agentById:we,projectById:Ne,assigneeOptions:Xe,projectOptions:et,recentAssigneeIds:ae,recentProjectIds:Ye,mentionOptions:tt,currentAssignee:it,currentProject:nt,routineRuns:y,activity:Ge,hasLiveRun:d,activeIssueId:R,titleInputRef:I,descriptionEditorRef:_,assigneeSelectorRef:C,projectSelectorRef:x,onHistoryRestoreSecretMaterials:at,onHistoryRestored:rt,navigateToSection:M},Pe=Qt.includes(w);return(0,e.jsxs)(ns.Provider,{value:Ae,children:[(0,e.jsx)("a",{href:"#routine-section",className:"sr-only focus:not-sr-only focus:absolute focus:left-2 focus:top-2 focus:z-20 focus:rounded focus:bg-background focus:px-3 focus:py-1.5 focus:text-sm",children:"Skip to section"}),(0,e.jsxs)("div",{className:"-m-4 flex h-full min-h-0 flex-col overflow-hidden md:-m-6",children:[(0,e.jsxs)("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-6",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,e.jsx)("textarea",{ref:I,"data-autosize-title":!0,className:"min-w-0 flex-1 resize-none overflow-hidden bg-transparent text-base font-semibold leading-7 outline-none placeholder:text-muted-foreground/50",placeholder:"Routine title",rows:1,value:f.title,onChange:i(t=>{P(h=>({...h,title:t.target.value})),Ke(t.target)},"onChange"),onKeyDown:i(t=>{t.key==="Enter"&&!t.metaKey&&!t.ctrlKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),w==="overview"?_.current?.focus():M("overview"))},"onKeyDown")}),o.managedByPlugin?(0,e.jsxs)(xe,{variant:"outline",className:"hidden shrink-0 gap-1.5 text-xs text-muted-foreground sm:inline-flex",children:[(0,e.jsx)(Pt,{className:"h-3 w-3"}),o.managedByPlugin.pluginDisplayName,(0,e.jsx)("span",{className:"font-mono text-(length:--text-nano)",children:o.managedByPlugin.resourceKey})]}):null]}),(0,e.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-3",children:[(0,e.jsx)(Vt,{onClick:i(()=>b(!0),"onClick"),disabled:Y.isPending}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ct,{size:"default",checked:$,onCheckedChange:Ae.onToggleAutomation,disabled:Se,"aria-label":$?"Pause automatic triggers":"Enable automatic triggers"}),(0,e.jsx)("span",{className:`text-sm font-medium ${Ce}`,children:Ie})]})]})]}),(0,e.jsx)(Gt,{activeSection:w,onNavigate:M,isSectionDirty:ne}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,e.jsx)(is,{activeSection:w,hrefFor:i(t=>`/routines/${s}/${t}`,"hrefFor"),isSectionDirty:ne,hasLiveRun:d,onNavigate:i(t=>le(s,t),"onNavigate")}),(0,e.jsx)("main",{id:"routine-section",role:"main",className:"min-h-0 min-w-0 flex-1 overflow-y-auto px-4 pb-6 pt-10 md:px-8",children:(0,e.jsxs)("section",{"aria-labelledby":"routine-section-title",className:Pe?"mx-auto w-full max-w-3xl":"w-full",children:[(0,e.jsx)("h2",{id:"routine-section-title",className:"mb-4 text-lg font-semibold",children:Ds[w]}),w==="overview"&&(0,e.jsx)(Ss,{}),w==="triggers"&&(0,e.jsx)(Is,{}),w==="variables"&&(0,e.jsx)(Cs,{}),w==="secrets"&&(0,e.jsx)(As,{}),w==="delivery"&&(0,e.jsx)(Ps,{}),w==="runs"&&(0,e.jsx)(Zt,{}),w==="activity"&&(0,e.jsx)(ls,{}),w==="history"&&(0,e.jsx)(Jt,{}),Pe?(0,e.jsx)(us,{dirtyFields:J(w),isSaving:Z.isPending,saveConflict:q,onSave:i(()=>{!Z.isPending&&f.title.trim()&&Z.mutate()},"onSave"),onDiscard:i(()=>be(w),"onDiscard"),onReload:ke}):null]})})]})]}),(0,e.jsx)(Nt,{open:g,onOpenChange:b,companyId:o.companyId,routineName:o.title,agents:F??[],projects:K??[],defaultProjectId:o.projectId,defaultAssigneeAgentId:o.assigneeAgentId,variables:o.variables??[],isPending:Y.isPending,onSubmit:i(t=>Y.mutate(t),"onSubmit")})]})}i(li,"RoutineDetail");export{li as RoutineDetail};
@@ -1,4 +1,4 @@
1
- var Xc=Object.defineProperty;var a=(e,t)=>Xc(e,"name",{value:t,configurable:!0});import{i as Na}from"./rolldown-runtime-ZpX3ckPj.js";import{$r as Jc,Ai as Zc,An as eu,Ci as ji,Di as oo,Dn as tu,Ei as zt,Er as An,Fi as nu,Hr as et,Ii as ru,L as su,Li as au,Mi as ou,N as Si,Oi as iu,On as Ci,Pi as _a,Q as Ni,S as q,Si as io,Ti as lo,W as Aa,Z as De,_i as co,a as lu,ai as cu,bi as Ea,c as uu,ci as du,di as fu,fi as pu,i as mu,ii as hu,ji as gu,k as _i,ki as Hs,kn as ha,l as Ma,li as xu,m as bu,mi as yu,ni as Pe,o as vu,oi as uo,pi as Ai,r as wu,s as ku,si as Iu,t as mt,ui as ju,vi as st,wi as fo,wr as Ra,xi as Su,yi as Cu}from"./agent-avatar-url-BgtuDQuJ.js";import{Mt as Nu,P as Ei,R as po,St as Mr,X as Mi,ft as cn,gt as Kn,o as Ri,t as un,xt as ds}from"./router-7hDvVKpK.js";import{Z as In,s as mo}from"./mention-chips-DaQB1XXn.js";import{d as jn,p as _u}from"./MarkdownEditor-Dkh_ud4t.js";import{b as Au,v as Eu,y as Mu}from"./sheet-Xthrybbp.js";import{r as fs,t as ho}from"./AgentAvatar-CowKoklf.js";import{A as Ru,C as go,O as Du,_ as xo,a as Ou,b as Tu,c as Pu,f as Vs,g as Lu,h as Gs,n as $u,o as Bu,p as Qs,r as Wu,s as Uu,t as Ft,u as Fu,v as zu,y as Ku}from"./checkbox-DxzcpGzB.js";import{a as qu,n as Hu,o as Vu,r as Gu,t as Ys}from"./label-LNcfjNUd.js";import{d as Dt,g as Ot,i as Rr,p as Tt}from"./agents-BqHpxyXa.js";import{S as Qu,_ as bo,c as Di,h as yo,i as Yu,l as Xu,n as Ju,r as Zu,s as ed,t as _t}from"./StatusIcon-CJevr908.js";import{o as ps,t as Oi}from"./EmptyState-B54qBJdG.js";import{t as vo}from"./bot-COgMVxie.js";import{t as fn}from"./check-Co2tYHc6.js";import{t as Wn}from"./chevron-right-C2GZk5mS.js";import{c as wo,i as pr,n as ko,s as Io,t as jo}from"./select-B_zFVzlA.js";import{C as Ti,b as Hr,d as td,k as br,p as nd,t as Ce}from"./button-CiCWqyHT.js";import{i as rd,r as sd,t as ad}from"./clipboard-Ch2RFnBG.js";import{i as Pi,o as Li}from"./heartbeats-BIzk9_-_.js";import{n as od,t as id}from"./useHiddenSettings-pmha2KHR.js";import{t as ld}from"./octagon-alert-DvPiKDSj.js";import{t as $i}from"./rotate-ccw-CnVoQJ8c.js";import{t as Da}from"./triangle-alert-gvuERj81.js";import{t as Ye}from"./badge-B1opbM2C.js";import{n as Vn,t as cd}from"./environments-CrkAniLn.js";import{t as Un}from"./input-C5_FG4bG.js";import{n as Bi,o as Wi,r as Ui}from"./company-members-BJTKKG75.js";import{t as Sn}from"./AgentIdentity-B0GifyUo.js";import{t as ud}from"./card-sHXnFZQl.js";import{t as Fi}from"./PageSkeleton-DOrN07nB.js";var dd=class extends Ea{static{a(this,"MutationCache")}#e;#t;#r;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}build(e,t,n){const r=new pu({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);const t=Vr(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Vr(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Vr(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(r=>r.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=Vr(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){st.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>fo(t,n))}findAll(e={}){return this.getAll().filter(t=>fo(e,t))}notify(e){st.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return st.batch(()=>Promise.all(e.map(t=>t.continue().catch(zt))))}};function Vr(e){return e.options.scope?.id}a(Vr,"scopeFor");function So(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}a(So,"difference");var fd=class extends Ea{static{a(this,"QueriesObserver")}#e;#t;#r;#a;#n;#s;#o;#i;#l;#c=[];constructor(e,t,n){super(),this.#e=e,this.#a=n,this.#r=[],this.#n=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#n.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#n.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#a=t,st.batch(()=>{const n=this.#n,r=this.#f(this.#r);r.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const o=r.map(f=>f.observer),i=o.map(f=>f.getCurrentResult()),l=n.length!==o.length,c=o.some((f,m)=>f!==n[m]),d=l||c,p=d?!0:i.some((f,m)=>{const y=this.#t[m];return!y||!Zc(f,y)});!d&&!p||(d&&(this.#c=r,this.#n=o),this.#t=i,this.hasListeners()&&(d&&(So(n,o).forEach(f=>{f.destroy()}),So(o,n).forEach(f=>{f.subscribe(m=>{this.#p(f,m)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#n.map(e=>e.getCurrentQuery())}getObservers(){return this.#n}getOptimisticResult(e,t){const n=this.#f(e),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[r,i=>this.#d(i??r,t,o),()=>this.#u(r,n)]}#u(e,t){const n=new Set;return t.map((r,o)=>{const i=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?i:r.observer.trackResult(i,l=>{n.has(l)||(n.add(l),t.forEach(c=>{c.observer.trackProp(l)}))})})}#d(e,t,n){if(t){const r=this.#l,o=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((i,l)=>i!==r[l]));return(this.#t!==this.#i||o||t!==this.#o)&&(this.#o=t,this.#i=this.#t,n!==void 0&&(this.#l=n),this.#s=iu(this.#s,t(e))),this.#s}return e}#h(){return!this.#a?.combine||this.#n.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#f(e){const t=new Map;this.#n.forEach(r=>{const o=r.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(r):t.set(o,[r])});const n=[];return e.forEach(r=>{const o=this.#e.defaultQueryOptions(r),i=t.get(o.queryHash)?.shift()??new Ai(this.#e,o);n.push({defaultedQueryOptions:o,observer:i})}),n}#p(e,t){const n=this.#n.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#m())}#m(){if(this.hasListeners()){const e=this.#h(),t=this.#s,n=e?t:this.#d(this.#u(this.#t,this.#c),this.#a?.combine);(e||t!==n)&&st.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},pd=class extends Ea{static{a(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const r=t.queryKey,o=t.queryHash??ji(r,t);let i=this.get(o);return i||(i=new yu({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){st.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>lo(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>lo(e,n)):t}notify(e){st.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){st.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){st.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},md=class{static{a(this,"QueryClient")}#e;#t;#r;#a;#n;#s;#o;#i;constructor(e={}){this.#e=e.queryCache||new pd,this.#t=e.mutationCache||new dd,this.#r=e.defaultOptions||{},this.#a=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=Cu.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=co.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Hs(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(r.queryHash)?.state.data,i=Su(t,o);if(i!==void 0)return this.#e.build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return st.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;st.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return st.batch(()=>{const r=n.findAll(e),o=new Set(r);return r.forEach(i=>{i.reset()}),this.refetchQueries({type:"active",predicate:a(i=>o.has(i),"predicate")},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=st.batch(()=>this.#e.findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(zt).catch(zt)}invalidateQueries(e,t={}){return st.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=st.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(zt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(zt)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),r=n.isStaleByTime(Hs(t.staleTime,n))?await n.fetch(t):n.state.data,o=t.select;return o?o(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Hs(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(zt).catch(zt)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(zt).catch(zt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return co.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#a.set(io(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#a.values()],n={};return t.forEach(r=>{oo(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#n.set(io(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],n={};return t.forEach(r=>{oo(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ji(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===gu&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},u=Na(au(),1);function zi({queries:e,...t},n){const r=_a(n),o=fu(),i=ju(),l=t.subscribed!==!1,c=u.useMemo(()=>e.map(C=>{const M=r.defaultQueryOptions(C);return M._optimisticResults=o?"isRestoring":l?"optimistic":void 0,M}),[e,r,o,l]);c.forEach(C=>{hu(C);const M=r.getQueryCache().get(C.queryHash);Iu(C,i,M)}),xu(i);const[d]=u.useState(()=>new fd(r,c,t)),[p,f,m]=d.getOptimisticResult(c,t.combine),y=!o&&l;u.useSyncExternalStore(u.useCallback(C=>y?d.subscribe(st.batchCalls(C)):zt,[d,y]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),u.useEffect(()=>{d.setQueries(c,t)},[c,t,d]);const j=p.some((C,M)=>uo(c[M],C))?p.flatMap((C,M)=>{const R=c[M];if(R&&uo(R,C)){const B=new Ai(r,R);return cu(R,B,i)}return[]}):[];if(j.length>0)throw Promise.all(j);const A=p.find((C,M)=>{const R=c[M];return R&&du({result:C,errorResetBoundary:i,throwOnError:R.throwOnError,query:r.getQueryCache().get(R.queryHash),suspense:R.suspense})});if(A)throw A.error;return f(m())}a(zi,"useQueries");function Oa(e){return e.createdByUserId?{kind:"user",id:e.createdByUserId}:e.createdByAgentId?e.responsibleUserId?{kind:"user",id:e.responsibleUserId,viaAgentId:e.createdByAgentId}:{kind:"agent",id:e.createdByAgentId}:e.responsibleUserId?{kind:"user",id:e.responsibleUserId}:null}a(Oa,"deriveOriginatingActor");var hd=["uncertain_provider_action","uncertain_external_action","uncertain_control_plane_action","completed_action_context_missing","continuation_evidence_incomplete","execution_finalization_deadline_exceeded","execution_recovery_budget_exhausted","provider_effect_inventory_unavailable","provider_failure_meaning_unverified","provider_ownership_unverified","native_provider_terminal_failed","native_event_replay_conflict","native_session_cleanup_quarantined","native_session_retry_exhausted","native_restart_recovery_blocked","native_continuation_requires_reconciliation","legacy_execution_requires_reconciliation"];function gd(e){return hd.some(t=>t===e)}a(gd,"requiresExecutionReconciliation");var s=Na(nu(),1),xd=Object.defineProperty,Dr=a((e,t)=>xd(e,"name",{value:t,configurable:!0}),"__name"),Ta="Collapsible",[bd,Y0]=uu(Ta),[yd,Pa]=bd(Ta),vd=u.forwardRef(Dr(a(function(t,n){const{__scopeCollapsible:r,open:o,defaultOpen:i,disabled:l,onOpenChange:c,...d}=t,[p,f]=lu({prop:o,defaultProp:i??!1,onChange:c,caller:Ta});return(0,s.jsx)(yd,{scope:r,disabled:l,contentId:wu(),open:p,onOpenToggle:u.useCallback(()=>f(m=>!m),[f]),children:(0,s.jsx)(Ma.div,{"data-state":Cs(p),"data-disabled":l?"":void 0,...d,ref:n})})},"Collapsible2"),"Collapsible")),wd="CollapsibleTrigger",kd=u.forwardRef(Dr(a(function(t,n){const{__scopeCollapsible:r,...o}=t,i=Pa(wd,r);return(0,s.jsx)(Ma.button,{type:"button","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Cs(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...o,ref:n,onClick:ku(t.onClick,i.onOpenToggle)})},"CollapsibleTrigger2"),"CollapsibleTrigger")),Ki="CollapsibleContent",Id=u.forwardRef(Dr(a(function(t,n){const{forceMount:r,...o}=t,i=Pa(Ki,t.__scopeCollapsible);return(0,s.jsx)(mu,{present:r||i.open,children:a(({present:l})=>(0,s.jsx)(jd,{...o,ref:n,present:l}),"children")})},"CollapsibleContent2"),"CollapsibleContent")),jd=u.forwardRef(Dr(a(function(t,n){const{__scopeCollapsible:r,present:o,children:i,...l}=t,c=Pa(Ki,r),[d,p]=u.useState(o),f=u.useRef(null),m=bu(n,f),y=u.useRef(0),j=y.current,A=u.useRef(0),C=A.current,M=c.open||d,R=u.useRef(M),B=u.useRef(void 0);return u.useEffect(()=>{const W=requestAnimationFrame(()=>R.current=!1);return()=>cancelAnimationFrame(W)},[]),vu(()=>{const W=f.current;if(W){B.current=B.current||{transitionDuration:W.style.transitionDuration,animationName:W.style.animationName},W.style.transitionDuration="0s",W.style.animationName="none";const T=W.getBoundingClientRect();y.current=T.height,A.current=T.width,R.current||(W.style.transitionDuration=B.current.transitionDuration,W.style.animationName=B.current.animationName),p(o)}},[c.open,o]),(0,s.jsx)(Ma.div,{"data-state":Cs(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!M,...l,ref:m,style:{"--radix-collapsible-content-height":j?`${j}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...t.style},children:M&&i})},"CollapsibleContentImpl2"),"CollapsibleContentImpl"));function Cs(e){return e?"open":"closed"}a(Cs,"getState");Dr(Cs,"getState");var Sd=vd,qi={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};qi.node;var Cd=mt(qi),Hi={name:"arrow-up-down",size:24,node:[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]};Hi.node;var Vi=mt(Hi),Gi={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Gi.node;var Nd=mt(Gi),Qi={name:"chevrons-down-up",size:24,node:[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]};Qi.node;var Yi=mt(Qi),Xi={name:"circle-slash-2",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]],aliases:["circle-slashed"]};Xi.node;var Ji=mt(Xi),Zi={name:"columns-3",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],aliases:["panels-left-right"]};Zi.node;var _d=mt(Zi),el={name:"file-search",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]};el.node;var Ad=mt(el),tl={name:"funnel",size:24,node:[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],aliases:["filter"]};tl.node;var Ed=mt(tl),nl={name:"hard-drive",size:24,node:[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]};nl.node;var Md=mt(nl),rl={name:"list-collapse",size:24,node:[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]]};rl.node;var sl=mt(rl),al={name:"list-tree",size:24,node:[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]};al.node;var ol=mt(al),il={name:"panel-top-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]};il.node;var ll=mt(il),cl={name:"repeat",size:24,node:[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]};cl.node;var X0=mt(cl),ul={name:"square-kanban",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]],aliases:["kanban-square"]};ul.node;var dl=mt(ul);function fl({...e}){return(0,s.jsx)(Sd,{"data-slot":"collapsible",...e})}a(fl,"Collapsible");function J0({...e}){return(0,s.jsx)(kd,{"data-slot":"collapsible-trigger",...e})}a(J0,"CollapsibleTrigger");function pl({...e}){return(0,s.jsx)(Id,{"data-slot":"collapsible-content",...e})}a(pl,"CollapsibleContent");var hr=Na(ru());function Rd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,u.useMemo)(()=>r=>{t.forEach(o=>o(r))},t)}a(Rd,"useCombinedRefs");var Ns=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}a(Gn,"isWindow");function La(e){return"nodeType"in e}a(La,"isNode");function ut(e){var t,n;return e?Gn(e)?e:La(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}a(ut,"getWindow");function $a(e){const{Document:t}=ut(e);return e instanceof t}a($a,"isDocument");function Or(e){return Gn(e)?!1:e instanceof ut(e).HTMLElement}a(Or,"isHTMLElement");function ml(e){return e instanceof ut(e).SVGElement}a(ml,"isSVGElement");function Qn(e){return e?Gn(e)?e.document:La(e)?$a(e)?e:Or(e)||ml(e)?e.ownerDocument:document:document:document}a(Qn,"getOwnerDocument");var Pt=Ns?u.useLayoutEffect:u.useEffect;function _s(e){const t=(0,u.useRef)(e);return Pt(()=>{t.current=e}),(0,u.useCallback)(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}a(_s,"useEvent");function Dd(){const e=(0,u.useRef)(null);return[(0,u.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,u.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}a(Dd,"useInterval");function Ir(e,t){t===void 0&&(t=[e]);const n=(0,u.useRef)(e);return Pt(()=>{n.current!==e&&(n.current=e)},t),n}a(Ir,"useLatestValue");function Tr(e,t){const n=(0,u.useRef)();return(0,u.useMemo)(()=>{const r=e(n.current);return n.current=r,r},[...t])}a(Tr,"useLazyMemo");function ms(e){const t=_s(e),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&t?.(r,n.current),n.current=r},[])]}a(ms,"useNodeRef");function hs(e){const t=(0,u.useRef)();return(0,u.useEffect)(()=>{t.current=e},[e]),t.current}a(hs,"usePrevious");var Xs={};function Pr(e,t){return(0,u.useMemo)(()=>{if(t)return t;const n=Xs[e]==null?0:Xs[e]+1;return Xs[e]=n,e+"-"+n},[e,t])}a(Pr,"useUniqueId");function hl(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,l)=>{const c=Object.entries(l);for(const[d,p]of c){const f=i[d];f!=null&&(i[d]=f+e*p)}return i},{...t})}}a(hl,"createAdjustmentFn");var Fn=hl(1),jr=hl(-1);function Od(e){return"clientX"in e&&"clientY"in e}a(Od,"hasViewportRelativeCoordinates");function As(e){if(!e)return!1;const{KeyboardEvent:t}=ut(e.target);return t&&e instanceof t}a(As,"isKeyboardEvent");function Td(e){if(!e)return!1;const{TouchEvent:t}=ut(e.target);return t&&e instanceof t}a(Td,"isTouchEvent");function gs(e){if(Td(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Od(e)?{x:e.clientX,y:e.clientY}:null}a(gs,"getEventCoordinates");var pn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[pn.Translate.toString(e),pn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Co="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Pd(e){return e.matches(Co)?e:e.querySelector(Co)}a(Pd,"findFirstFocusableNode");var Ld={display:"none"};function $d(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:Ld},n)}a($d,"HiddenText");function Bd(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}a(Bd,"LiveRegion");function Wd(){const[e,t]=(0,u.useState)("");return{announce:(0,u.useCallback)(n=>{n!=null&&t(n)},[]),announcement:e}}a(Wd,"useAnnouncement");var gl=(0,u.createContext)(null);function Ud(e){const t=(0,u.useContext)(gl);(0,u.useEffect)(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}a(Ud,"useDndMonitor");function Fd(){const[e]=(0,u.useState)(()=>new Set),t=(0,u.useCallback)(n=>(e.add(n),()=>e.delete(n)),[e]);return[(0,u.useCallback)(n=>{let{type:r,event:o}=n;e.forEach(i=>{var l;return(l=i[r])==null?void 0:l.call(i,o)})},[e]),t]}a(Fd,"useDndMonitorProvider");var zd={draggable:`
1
+ var Xc=Object.defineProperty;var a=(e,t)=>Xc(e,"name",{value:t,configurable:!0});import{i as Na}from"./rolldown-runtime-ZpX3ckPj.js";import{$r as Jc,Ai as Zc,An as eu,Ci as ji,Di as oo,Dn as tu,Ei as zt,Er as An,Fi as nu,Hr as et,Ii as ru,L as su,Li as au,Mi as ou,N as Si,Oi as iu,On as Ci,Pi as _a,Q as Ni,S as q,Si as io,Ti as lo,W as Aa,Z as De,_i as co,a as lu,ai as cu,bi as Ea,c as uu,ci as du,di as fu,fi as pu,i as mu,ii as hu,ji as gu,k as _i,ki as Hs,kn as ha,l as Ma,li as xu,m as bu,mi as yu,ni as Pe,o as vu,oi as uo,pi as Ai,r as wu,s as ku,si as Iu,t as mt,ui as ju,vi as st,wi as fo,wr as Ra,xi as Su,yi as Cu}from"./agent-avatar-url-DtOIjE-b.js";import{Mt as Nu,P as Ei,R as po,St as Mr,X as Mi,ft as cn,gt as Kn,o as Ri,t as un,xt as ds}from"./router-CoeH24PK.js";import{Z as In,s as mo}from"./mention-chips-OAQdMAP9.js";import{d as jn,p as _u}from"./MarkdownEditor-DCE_KC27.js";import{b as Au,v as Eu,y as Mu}from"./sheet-_VebRl9q.js";import{r as fs,t as ho}from"./AgentAvatar-Jt6HpvU2.js";import{A as Ru,C as go,O as Du,_ as xo,a as Ou,b as Tu,c as Pu,f as Vs,g as Lu,h as Gs,n as $u,o as Bu,p as Qs,r as Wu,s as Uu,t as Ft,u as Fu,v as zu,y as Ku}from"./checkbox-CIcktoHJ.js";import{a as qu,n as Hu,o as Vu,r as Gu,t as Ys}from"./label-DSx2Qxn6.js";import{d as Dt,g as Ot,i as Rr,p as Tt}from"./agents-DA5qW1fs.js";import{S as Qu,_ as bo,c as Di,h as yo,i as Yu,l as Xu,n as Ju,r as Zu,s as ed,t as _t}from"./StatusIcon-BCy8D6Fj.js";import{o as ps,t as Oi}from"./EmptyState-B1JSbXSE.js";import{t as vo}from"./bot-S2JV9WBV.js";import{t as fn}from"./check-xeGJ2HPN.js";import{t as Wn}from"./chevron-right-D0Hti4WB.js";import{c as wo,i as pr,n as ko,s as Io,t as jo}from"./select-DarpvIBM.js";import{C as Ti,b as Hr,d as td,k as br,p as nd,t as Ce}from"./button-yf2m1_gs.js";import{i as rd,r as sd,t as ad}from"./clipboard-NgncerTn.js";import{i as Pi,o as Li}from"./heartbeats-DeXOtSp3.js";import{n as od,t as id}from"./useHiddenSettings-BpAre2Wp.js";import{t as ld}from"./octagon-alert-BbqyswZU.js";import{t as $i}from"./rotate-ccw-Du0rX6yB.js";import{t as Da}from"./triangle-alert-VjOLPhJL.js";import{t as Ye}from"./badge-DEcdN2HY.js";import{n as Vn,t as cd}from"./environments-BT_uDOM8.js";import{t as Un}from"./input-DnT08BOo.js";import{n as Bi,o as Wi,r as Ui}from"./company-members-CDG03HZV.js";import{t as Sn}from"./AgentIdentity-2cID8kur.js";import{t as ud}from"./card-Cl_LFk7c.js";import{t as Fi}from"./PageSkeleton-BmmfQJ6g.js";var dd=class extends Ea{static{a(this,"MutationCache")}#e;#t;#r;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}build(e,t,n){const r=new pu({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);const t=Vr(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Vr(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Vr(e);if(typeof t=="string"){const n=this.#t.get(t)?.find(r=>r.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=Vr(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){st.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>fo(t,n))}findAll(e={}){return this.getAll().filter(t=>fo(e,t))}notify(e){st.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return st.batch(()=>Promise.all(e.map(t=>t.continue().catch(zt))))}};function Vr(e){return e.options.scope?.id}a(Vr,"scopeFor");function So(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}a(So,"difference");var fd=class extends Ea{static{a(this,"QueriesObserver")}#e;#t;#r;#a;#n;#s;#o;#i;#l;#c=[];constructor(e,t,n){super(),this.#e=e,this.#a=n,this.#r=[],this.#n=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#n.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#n.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#a=t,st.batch(()=>{const n=this.#n,r=this.#f(this.#r);r.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const o=r.map(f=>f.observer),i=o.map(f=>f.getCurrentResult()),l=n.length!==o.length,c=o.some((f,m)=>f!==n[m]),d=l||c,p=d?!0:i.some((f,m)=>{const y=this.#t[m];return!y||!Zc(f,y)});!d&&!p||(d&&(this.#c=r,this.#n=o),this.#t=i,this.hasListeners()&&(d&&(So(n,o).forEach(f=>{f.destroy()}),So(o,n).forEach(f=>{f.subscribe(m=>{this.#p(f,m)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#n.map(e=>e.getCurrentQuery())}getObservers(){return this.#n}getOptimisticResult(e,t){const n=this.#f(e),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[r,i=>this.#d(i??r,t,o),()=>this.#u(r,n)]}#u(e,t){const n=new Set;return t.map((r,o)=>{const i=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?i:r.observer.trackResult(i,l=>{n.has(l)||(n.add(l),t.forEach(c=>{c.observer.trackProp(l)}))})})}#d(e,t,n){if(t){const r=this.#l,o=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((i,l)=>i!==r[l]));return(this.#t!==this.#i||o||t!==this.#o)&&(this.#o=t,this.#i=this.#t,n!==void 0&&(this.#l=n),this.#s=iu(this.#s,t(e))),this.#s}return e}#h(){return!this.#a?.combine||this.#n.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#f(e){const t=new Map;this.#n.forEach(r=>{const o=r.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(r):t.set(o,[r])});const n=[];return e.forEach(r=>{const o=this.#e.defaultQueryOptions(r),i=t.get(o.queryHash)?.shift()??new Ai(this.#e,o);n.push({defaultedQueryOptions:o,observer:i})}),n}#p(e,t){const n=this.#n.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#m())}#m(){if(this.hasListeners()){const e=this.#h(),t=this.#s,n=e?t:this.#d(this.#u(this.#t,this.#c),this.#a?.combine);(e||t!==n)&&st.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},pd=class extends Ea{static{a(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){const r=t.queryKey,o=t.queryHash??ji(r,t);let i=this.get(o);return i||(i=new yu({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){st.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>lo(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>lo(e,n)):t}notify(e){st.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){st.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){st.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},md=class{static{a(this,"QueryClient")}#e;#t;#r;#a;#n;#s;#o;#i;constructor(e={}){this.#e=e.queryCache||new pd,this.#t=e.mutationCache||new dd,this.#r=e.defaultOptions||{},this.#a=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=Cu.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=co.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Hs(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(r.queryHash)?.state.data,i=Su(t,o);if(i!==void 0)return this.#e.build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return st.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;st.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return st.batch(()=>{const r=n.findAll(e),o=new Set(r);return r.forEach(i=>{i.reset()}),this.refetchQueries({type:"active",predicate:a(i=>o.has(i),"predicate")},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=st.batch(()=>this.#e.findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(zt).catch(zt)}invalidateQueries(e,t={}){return st.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=st.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(zt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(zt)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t),r=n.isStaleByTime(Hs(t.staleTime,n))?await n.fetch(t):n.state.data,o=t.select;return o?o(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(Hs(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(zt).catch(zt)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(zt).catch(zt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return co.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#a.set(io(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#a.values()],n={};return t.forEach(r=>{oo(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#n.set(io(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],n={};return t.forEach(r=>{oo(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ji(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===gu&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},u=Na(au(),1);function zi({queries:e,...t},n){const r=_a(n),o=fu(),i=ju(),l=t.subscribed!==!1,c=u.useMemo(()=>e.map(C=>{const M=r.defaultQueryOptions(C);return M._optimisticResults=o?"isRestoring":l?"optimistic":void 0,M}),[e,r,o,l]);c.forEach(C=>{hu(C);const M=r.getQueryCache().get(C.queryHash);Iu(C,i,M)}),xu(i);const[d]=u.useState(()=>new fd(r,c,t)),[p,f,m]=d.getOptimisticResult(c,t.combine),y=!o&&l;u.useSyncExternalStore(u.useCallback(C=>y?d.subscribe(st.batchCalls(C)):zt,[d,y]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),u.useEffect(()=>{d.setQueries(c,t)},[c,t,d]);const j=p.some((C,M)=>uo(c[M],C))?p.flatMap((C,M)=>{const R=c[M];if(R&&uo(R,C)){const B=new Ai(r,R);return cu(R,B,i)}return[]}):[];if(j.length>0)throw Promise.all(j);const A=p.find((C,M)=>{const R=c[M];return R&&du({result:C,errorResetBoundary:i,throwOnError:R.throwOnError,query:r.getQueryCache().get(R.queryHash),suspense:R.suspense})});if(A)throw A.error;return f(m())}a(zi,"useQueries");function Oa(e){return e.createdByUserId?{kind:"user",id:e.createdByUserId}:e.createdByAgentId?e.responsibleUserId?{kind:"user",id:e.responsibleUserId,viaAgentId:e.createdByAgentId}:{kind:"agent",id:e.createdByAgentId}:e.responsibleUserId?{kind:"user",id:e.responsibleUserId}:null}a(Oa,"deriveOriginatingActor");var hd=["uncertain_provider_action","uncertain_external_action","uncertain_control_plane_action","completed_action_context_missing","continuation_evidence_incomplete","execution_finalization_deadline_exceeded","execution_recovery_budget_exhausted","provider_effect_inventory_unavailable","provider_failure_meaning_unverified","provider_ownership_unverified","native_provider_terminal_failed","native_event_replay_conflict","native_session_cleanup_quarantined","native_session_retry_exhausted","native_restart_recovery_blocked","native_continuation_requires_reconciliation","legacy_execution_requires_reconciliation"];function gd(e){return hd.some(t=>t===e)}a(gd,"requiresExecutionReconciliation");var s=Na(nu(),1),xd=Object.defineProperty,Dr=a((e,t)=>xd(e,"name",{value:t,configurable:!0}),"__name"),Ta="Collapsible",[bd,Y0]=uu(Ta),[yd,Pa]=bd(Ta),vd=u.forwardRef(Dr(a(function(t,n){const{__scopeCollapsible:r,open:o,defaultOpen:i,disabled:l,onOpenChange:c,...d}=t,[p,f]=lu({prop:o,defaultProp:i??!1,onChange:c,caller:Ta});return(0,s.jsx)(yd,{scope:r,disabled:l,contentId:wu(),open:p,onOpenToggle:u.useCallback(()=>f(m=>!m),[f]),children:(0,s.jsx)(Ma.div,{"data-state":Cs(p),"data-disabled":l?"":void 0,...d,ref:n})})},"Collapsible2"),"Collapsible")),wd="CollapsibleTrigger",kd=u.forwardRef(Dr(a(function(t,n){const{__scopeCollapsible:r,...o}=t,i=Pa(wd,r);return(0,s.jsx)(Ma.button,{type:"button","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Cs(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...o,ref:n,onClick:ku(t.onClick,i.onOpenToggle)})},"CollapsibleTrigger2"),"CollapsibleTrigger")),Ki="CollapsibleContent",Id=u.forwardRef(Dr(a(function(t,n){const{forceMount:r,...o}=t,i=Pa(Ki,t.__scopeCollapsible);return(0,s.jsx)(mu,{present:r||i.open,children:a(({present:l})=>(0,s.jsx)(jd,{...o,ref:n,present:l}),"children")})},"CollapsibleContent2"),"CollapsibleContent")),jd=u.forwardRef(Dr(a(function(t,n){const{__scopeCollapsible:r,present:o,children:i,...l}=t,c=Pa(Ki,r),[d,p]=u.useState(o),f=u.useRef(null),m=bu(n,f),y=u.useRef(0),j=y.current,A=u.useRef(0),C=A.current,M=c.open||d,R=u.useRef(M),B=u.useRef(void 0);return u.useEffect(()=>{const W=requestAnimationFrame(()=>R.current=!1);return()=>cancelAnimationFrame(W)},[]),vu(()=>{const W=f.current;if(W){B.current=B.current||{transitionDuration:W.style.transitionDuration,animationName:W.style.animationName},W.style.transitionDuration="0s",W.style.animationName="none";const T=W.getBoundingClientRect();y.current=T.height,A.current=T.width,R.current||(W.style.transitionDuration=B.current.transitionDuration,W.style.animationName=B.current.animationName),p(o)}},[c.open,o]),(0,s.jsx)(Ma.div,{"data-state":Cs(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!M,...l,ref:m,style:{"--radix-collapsible-content-height":j?`${j}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...t.style},children:M&&i})},"CollapsibleContentImpl2"),"CollapsibleContentImpl"));function Cs(e){return e?"open":"closed"}a(Cs,"getState");Dr(Cs,"getState");var Sd=vd,qi={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};qi.node;var Cd=mt(qi),Hi={name:"arrow-up-down",size:24,node:[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]};Hi.node;var Vi=mt(Hi),Gi={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Gi.node;var Nd=mt(Gi),Qi={name:"chevrons-down-up",size:24,node:[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]};Qi.node;var Yi=mt(Qi),Xi={name:"circle-slash-2",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]],aliases:["circle-slashed"]};Xi.node;var Ji=mt(Xi),Zi={name:"columns-3",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],aliases:["panels-left-right"]};Zi.node;var _d=mt(Zi),el={name:"file-search",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]};el.node;var Ad=mt(el),tl={name:"funnel",size:24,node:[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],aliases:["filter"]};tl.node;var Ed=mt(tl),nl={name:"hard-drive",size:24,node:[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]};nl.node;var Md=mt(nl),rl={name:"list-collapse",size:24,node:[["path",{d:"M10 5h11",key:"1hkqpe"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 19h11",key:"14g2nv"}],["path",{d:"m3 10 3-3-3-3",key:"i7pm08"}],["path",{d:"m3 20 3-3-3-3",key:"20gx1n"}]]};rl.node;var sl=mt(rl),al={name:"list-tree",size:24,node:[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]};al.node;var ol=mt(al),il={name:"panel-top-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]};il.node;var ll=mt(il),cl={name:"repeat",size:24,node:[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]};cl.node;var X0=mt(cl),ul={name:"square-kanban",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]],aliases:["kanban-square"]};ul.node;var dl=mt(ul);function fl({...e}){return(0,s.jsx)(Sd,{"data-slot":"collapsible",...e})}a(fl,"Collapsible");function J0({...e}){return(0,s.jsx)(kd,{"data-slot":"collapsible-trigger",...e})}a(J0,"CollapsibleTrigger");function pl({...e}){return(0,s.jsx)(Id,{"data-slot":"collapsible-content",...e})}a(pl,"CollapsibleContent");var hr=Na(ru());function Rd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,u.useMemo)(()=>r=>{t.forEach(o=>o(r))},t)}a(Rd,"useCombinedRefs");var Ns=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}a(Gn,"isWindow");function La(e){return"nodeType"in e}a(La,"isNode");function ut(e){var t,n;return e?Gn(e)?e:La(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}a(ut,"getWindow");function $a(e){const{Document:t}=ut(e);return e instanceof t}a($a,"isDocument");function Or(e){return Gn(e)?!1:e instanceof ut(e).HTMLElement}a(Or,"isHTMLElement");function ml(e){return e instanceof ut(e).SVGElement}a(ml,"isSVGElement");function Qn(e){return e?Gn(e)?e.document:La(e)?$a(e)?e:Or(e)||ml(e)?e.ownerDocument:document:document:document}a(Qn,"getOwnerDocument");var Pt=Ns?u.useLayoutEffect:u.useEffect;function _s(e){const t=(0,u.useRef)(e);return Pt(()=>{t.current=e}),(0,u.useCallback)(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}a(_s,"useEvent");function Dd(){const e=(0,u.useRef)(null);return[(0,u.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,u.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}a(Dd,"useInterval");function Ir(e,t){t===void 0&&(t=[e]);const n=(0,u.useRef)(e);return Pt(()=>{n.current!==e&&(n.current=e)},t),n}a(Ir,"useLatestValue");function Tr(e,t){const n=(0,u.useRef)();return(0,u.useMemo)(()=>{const r=e(n.current);return n.current=r,r},[...t])}a(Tr,"useLazyMemo");function ms(e){const t=_s(e),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&t?.(r,n.current),n.current=r},[])]}a(ms,"useNodeRef");function hs(e){const t=(0,u.useRef)();return(0,u.useEffect)(()=>{t.current=e},[e]),t.current}a(hs,"usePrevious");var Xs={};function Pr(e,t){return(0,u.useMemo)(()=>{if(t)return t;const n=Xs[e]==null?0:Xs[e]+1;return Xs[e]=n,e+"-"+n},[e,t])}a(Pr,"useUniqueId");function hl(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,l)=>{const c=Object.entries(l);for(const[d,p]of c){const f=i[d];f!=null&&(i[d]=f+e*p)}return i},{...t})}}a(hl,"createAdjustmentFn");var Fn=hl(1),jr=hl(-1);function Od(e){return"clientX"in e&&"clientY"in e}a(Od,"hasViewportRelativeCoordinates");function As(e){if(!e)return!1;const{KeyboardEvent:t}=ut(e.target);return t&&e instanceof t}a(As,"isKeyboardEvent");function Td(e){if(!e)return!1;const{TouchEvent:t}=ut(e.target);return t&&e instanceof t}a(Td,"isTouchEvent");function gs(e){if(Td(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Od(e)?{x:e.clientX,y:e.clientY}:null}a(gs,"getEventCoordinates");var pn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[pn.Translate.toString(e),pn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Co="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Pd(e){return e.matches(Co)?e:e.querySelector(Co)}a(Pd,"findFirstFocusableNode");var Ld={display:"none"};function $d(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:Ld},n)}a($d,"HiddenText");function Bd(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}a(Bd,"LiveRegion");function Wd(){const[e,t]=(0,u.useState)("");return{announce:(0,u.useCallback)(n=>{n!=null&&t(n)},[]),announcement:e}}a(Wd,"useAnnouncement");var gl=(0,u.createContext)(null);function Ud(e){const t=(0,u.useContext)(gl);(0,u.useEffect)(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}a(Ud,"useDndMonitor");function Fd(){const[e]=(0,u.useState)(()=>new Set),t=(0,u.useCallback)(n=>(e.add(n),()=>e.delete(n)),[e]);return[(0,u.useCallback)(n=>{let{type:r,event:o}=n;e.forEach(i=>{var l;return(l=i[r])==null?void 0:l.call(i,o)})},[e]),t]}a(Fd,"useDndMonitorProvider");var zd={draggable:`
2
2
  To pick up a draggable item, press the space bar.
3
3
  While dragging, use the arrow keys to move the item.
4
4
  Press space again to drop the item in its new position, or press escape to cancel.