maestro-agent 0.0.1 → 0.0.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 (111) hide show
  1. package/README.md +316 -2
  2. package/bin/maestro.ts +5 -0
  3. package/dist/maestro +0 -0
  4. package/dist/web/apple-touch-icon.png +0 -0
  5. package/dist/web/assets/Connections-BMA04Ycg.js +11 -0
  6. package/dist/web/assets/GanttView-DXjh0gxg.js +49 -0
  7. package/dist/web/assets/Home-Ct3Ho0Qt.js +1 -0
  8. package/dist/web/assets/HooksCrons--0kyVJcR.js +11 -0
  9. package/dist/web/assets/ProjectDetail-B_IqEpFu.js +1 -0
  10. package/dist/web/assets/Roles-D1tIQzto.js +24 -0
  11. package/dist/web/assets/Settings-yts4LUmH.js +11 -0
  12. package/dist/web/assets/Skills-DbuNLjIV.js +12 -0
  13. package/dist/web/assets/Wizard-vJol8-Y4.js +11 -0
  14. package/dist/web/assets/WorkspaceChat-DrsLs4m2.js +56 -0
  15. package/dist/web/assets/WorkspaceDashboard-B9vgrd2Z.js +6 -0
  16. package/dist/web/assets/WorkspaceNew-DoNGYHCG.js +1 -0
  17. package/dist/web/assets/WorkspaceProjects-DDp3mUse.js +6 -0
  18. package/dist/web/assets/WorkspaceSchedules-BTjmCbYG.js +1 -0
  19. package/dist/web/assets/WorkspaceTasks-mPU-bhKR.js +41 -0
  20. package/dist/web/assets/activity-CIA8bIA4.js +6 -0
  21. package/dist/web/assets/addon-fit-BlxrFPDK.js +1 -0
  22. package/dist/web/assets/arrow-right-S7ID7nDp.js +6 -0
  23. package/dist/web/assets/badge-DDTUzWIi.js +1 -0
  24. package/dist/web/assets/circle-check-B3P1qK0Z.js +6 -0
  25. package/dist/web/assets/clock-f9aYZox0.js +6 -0
  26. package/dist/web/assets/index-BRo4Du_s.js +11 -0
  27. package/dist/web/assets/index-C7kx39S9.js +196 -0
  28. package/dist/web/assets/index-D6LSdZea.css +1 -0
  29. package/dist/web/assets/plus-BHnOxbns.js +6 -0
  30. package/dist/web/assets/refresh-cw-BWX04Hg3.js +6 -0
  31. package/dist/web/assets/save-BLbb_9xz.js +6 -0
  32. package/dist/web/assets/sparkles-CDr6Dw1e.js +6 -0
  33. package/dist/web/assets/trash-2-9-ThEdey.js +6 -0
  34. package/dist/web/assets/useEventStream-DXt2Hmei.js +1 -0
  35. package/dist/web/assets/x-DVdKPXXy.js +6 -0
  36. package/dist/web/assets/xterm-DYP7pi_n.css +32 -0
  37. package/dist/web/assets/xterm-DlVFs1Kw.js +9 -0
  38. package/dist/web/favicon-512.png +0 -0
  39. package/dist/web/favicon.png +0 -0
  40. package/dist/web/index.html +15 -0
  41. package/package.json +49 -6
  42. package/src/api/agents.ts +76 -0
  43. package/src/api/audit.ts +19 -0
  44. package/src/api/autopilot.ts +73 -0
  45. package/src/api/chat.ts +801 -0
  46. package/src/api/chief.ts +84 -0
  47. package/src/api/config.ts +39 -0
  48. package/src/api/gantt.ts +72 -0
  49. package/src/api/hooks.ts +54 -0
  50. package/src/api/inbox.ts +125 -0
  51. package/src/api/lark.ts +32 -0
  52. package/src/api/memory.ts +37 -0
  53. package/src/api/ops.ts +89 -0
  54. package/src/api/projects.ts +105 -0
  55. package/src/api/roles.ts +123 -0
  56. package/src/api/runtimes.ts +62 -0
  57. package/src/api/scheduled-tasks.ts +203 -0
  58. package/src/api/sessions.ts +479 -0
  59. package/src/api/skills.ts +386 -0
  60. package/src/api/tasks.ts +457 -0
  61. package/src/api/telegram.ts +94 -0
  62. package/src/api/templates.ts +36 -0
  63. package/src/api/webhooks.ts +20 -0
  64. package/src/api/workspaces.ts +150 -0
  65. package/src/bridges/lark/index.ts +213 -0
  66. package/src/bridges/telegram/index.ts +273 -0
  67. package/src/bridges/telegram/polling.ts +185 -0
  68. package/src/chat/index.ts +86 -0
  69. package/src/chief/index.ts +461 -0
  70. package/src/core/cli.ts +333 -0
  71. package/src/core/db.ts +53 -0
  72. package/src/core/event-bus.ts +33 -0
  73. package/src/core/index.ts +6 -0
  74. package/src/core/migrations.ts +303 -0
  75. package/src/core/router.ts +69 -0
  76. package/src/core/schema.sql +232 -0
  77. package/src/core/server.ts +308 -0
  78. package/src/core/validate.ts +22 -0
  79. package/src/discovery/index.ts +194 -0
  80. package/src/gateway/adapters/telegram.ts +148 -0
  81. package/src/gateway/index.ts +31 -0
  82. package/src/gateway/manager.ts +176 -0
  83. package/src/gateway/types.ts +77 -0
  84. package/src/inbox/index.ts +500 -0
  85. package/src/ops/artifact-sync.ts +65 -0
  86. package/src/ops/autopilot.ts +338 -0
  87. package/src/ops/gc.ts +252 -0
  88. package/src/ops/index.ts +226 -0
  89. package/src/ops/project-serial.ts +52 -0
  90. package/src/ops/role-dispatch.ts +111 -0
  91. package/src/ops/runtime-scheduler.ts +447 -0
  92. package/src/ops/task-blocking.ts +65 -0
  93. package/src/ops/task-deps.ts +37 -0
  94. package/src/ops/task-workspace.ts +60 -0
  95. package/src/roles/index.ts +258 -0
  96. package/src/roles/prompt-assembler.ts +85 -0
  97. package/src/roles/workspace-role.ts +155 -0
  98. package/src/scheduler/index.ts +461 -0
  99. package/src/session/output-parser.ts +75 -0
  100. package/src/session/realtime-parser.ts +40 -0
  101. package/src/skills/builtin.ts +155 -0
  102. package/src/skills/skill-extractor.ts +452 -0
  103. package/src/skills/skill-md.ts +282 -0
  104. package/src/transport/http-api.ts +75 -0
  105. package/src/transport/index.ts +4 -0
  106. package/src/transport/local-pty.ts +119 -0
  107. package/src/transport/ssh.ts +176 -0
  108. package/src/transport/types.ts +20 -0
  109. package/src/workflows/index.ts +231 -0
  110. package/index.js +0 -1
  111. package/maestro-agent-0.0.1.tgz +0 -0
@@ -0,0 +1,41 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xterm-DYP7pi_n.css"])))=>i.map(i=>d[i]);
2
+ import{q as ae,z as a,v as e,k,m as Ws,H as Xe,K as ue,b as ke,P as Hs,c as G,l as L,p as qe,G as De,u as Ys,d as Us,J as Ks,F as Js,D as Xs,o as qs,n as Zs,I as Et,E as Qs,w as He,_ as ze,s as J,N as en,O as tn,S as fe,g as he,h as me,e as xe,f as Y,x as Ve,r as sn}from"./index-C7kx39S9.js";import{e as Ze,S as nn,d as rn,B as It,C as Ye,b as an,c as on,a as At}from"./badge-DDTUzWIi.js";import{X as Qe}from"./x-DVdKPXXy.js";import{S as ln,L as yt,a as de,R as K,T as W,K as _t,G as cn}from"./GanttView-DXjh0gxg.js";import{C as et}from"./clock-f9aYZox0.js";import{u as dn}from"./useEventStream-DXt2Hmei.js";import{P as un}from"./plus-BHnOxbns.js";import{T as fn}from"./trash-2-9-ThEdey.js";/**
3
+ * @license lucide-react v1.16.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const hn=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],mn=ae("chart-column",hn);/**
8
+ * @license lucide-react v1.16.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const xn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],pn=ae("circle-alert",xn);/**
13
+ * @license lucide-react v1.16.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const gn=[["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"}]],vn=ae("columns-3",gn);/**
18
+ * @license lucide-react v1.16.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const bn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],jn=ae("copy",bn);/**
23
+ * @license lucide-react v1.16.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const yn=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],_n=ae("list",yn);/**
28
+ * @license lucide-react v1.16.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const Nn=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],wn=ae("pencil",Nn),Sn=Ze("relative w-full rounded-lg border border-[hsl(var(--border))] p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-[hsl(var(--foreground))]",{variants:{variant:{default:"bg-[hsl(var(--background))] text-[hsl(var(--foreground))]",destructive:"border-[hsl(var(--destructive))]/50 text-[hsl(var(--destructive))] [&>svg]:text-[hsl(var(--destructive))]"}},defaultVariants:{variant:"default"}}),tt=a.forwardRef(({className:t,variant:n,...s},r)=>e.jsx("div",{ref:r,role:"alert",className:k(Sn({variant:n}),t),...s}));tt.displayName="Alert";const Cn=a.forwardRef(({className:t,...n},s)=>e.jsx("h5",{ref:s,className:k("mb-1 font-medium leading-none tracking-tight",t),...n}));Cn.displayName="AlertTitle";const st=a.forwardRef(({className:t,...n},s)=>e.jsx("div",{ref:s,className:k("text-sm [&_p]:leading-relaxed",t),...n}));st.displayName="AlertDescription";const Tn=Ze("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-[hsl(var(--background))] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:bg-[hsl(var(--primary))]/90",destructive:"bg-[hsl(var(--destructive))] text-[hsl(var(--destructive-foreground))] hover:bg-[hsl(var(--destructive))]/90",outline:"border border-[hsl(var(--input))] bg-[hsl(var(--background))] hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))]",secondary:"bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] hover:bg-[hsl(var(--secondary))]/80",ghost:"hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))]",link:"text-[hsl(var(--primary))] underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),H=a.forwardRef(({className:t,variant:n,size:s,asChild:r=!1,...o},i)=>{const l=r?nn:"button";return e.jsx(l,{className:k(Tn({variant:n,size:s,className:t})),ref:i,...o})});H.displayName="Button";function Rn(t){const n=kn(t),s=a.forwardRef((r,o)=>{const{children:i,...l}=r,c=a.Children.toArray(i),f=c.find(En);if(f){const h=f.props.children,m=c.map(v=>v===f?a.Children.count(h)>1?a.Children.only(null):a.isValidElement(h)?h.props.children:null:v);return e.jsx(n,{...l,ref:o,children:a.isValidElement(h)?a.cloneElement(h,void 0,m):null})}return e.jsx(n,{...l,ref:o,children:i})});return s.displayName=`${t}.Slot`,s}function kn(t){const n=a.forwardRef((s,r)=>{const{children:o,...i}=s;if(a.isValidElement(o)){const l=An(o),c=In(i,o.props);return o.type!==a.Fragment&&(c.ref=r?Ws(r,l):l),a.cloneElement(o,c)}return a.Children.count(o)>1?a.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var Dn=Symbol("radix.slottable");function En(t){return a.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Dn}function In(t,n){const s={...n};for(const r in n){const o=t[r],i=n[r];/^on[A-Z]/.test(r)?o&&i?s[r]=(...c)=>{const f=i(...c);return o(...c),f}:o&&(s[r]=o):r==="style"?s[r]={...o,...i}:r==="className"&&(s[r]=[o,i].filter(Boolean).join(" "))}return{...t,...s}}function An(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var Ee="Dialog",[Pt]=qe(Ee),[Pn,z]=Pt(Ee),Ft=t=>{const{__scopeDialog:n,children:s,open:r,defaultOpen:o,onOpenChange:i,modal:l=!0}=t,c=a.useRef(null),f=a.useRef(null),[h,m]=Xe({prop:r,defaultProp:o??!1,onChange:i,caller:Ee});return e.jsx(Pn,{scope:n,triggerRef:c,contentRef:f,contentId:ue(),titleId:ue(),descriptionId:ue(),open:h,onOpenChange:m,onOpenToggle:a.useCallback(()=>m(v=>!v),[m]),modal:l,children:s})};Ft.displayName=Ee;var Mt="DialogTrigger",Fn=a.forwardRef((t,n)=>{const{__scopeDialog:s,...r}=t,o=z(Mt,s),i=De(n,o.triggerRef);return e.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":at(o.open),...r,ref:i,onClick:L(t.onClick,o.onOpenToggle)})});Fn.displayName=Mt;var nt="DialogPortal",[Mn,$t]=Pt(nt,{forceMount:void 0}),Ot=t=>{const{__scopeDialog:n,forceMount:s,children:r,container:o}=t,i=z(nt,n);return e.jsx(Mn,{scope:n,forceMount:s,children:a.Children.map(r,l=>e.jsx(ke,{present:s||i.open,children:e.jsx(Hs,{asChild:!0,container:o,children:l})}))})};Ot.displayName=nt;var Re="DialogOverlay",Lt=a.forwardRef((t,n)=>{const s=$t(Re,t.__scopeDialog),{forceMount:r=s.forceMount,...o}=t,i=z(Re,t.__scopeDialog);return i.modal?e.jsx(ke,{present:r||i.open,children:e.jsx(On,{...o,ref:n})}):null});Lt.displayName=Re;var $n=Rn("DialogOverlay.RemoveScroll"),On=a.forwardRef((t,n)=>{const{__scopeDialog:s,...r}=t,o=z(Re,s);return e.jsx(Us,{as:$n,allowPinchZoom:!0,shards:[o.contentRef],children:e.jsx(G.div,{"data-state":at(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),q="DialogContent",Bt=a.forwardRef((t,n)=>{const s=$t(q,t.__scopeDialog),{forceMount:r=s.forceMount,...o}=t,i=z(q,t.__scopeDialog);return e.jsx(ke,{present:r||i.open,children:i.modal?e.jsx(Ln,{...o,ref:n}):e.jsx(Bn,{...o,ref:n})})});Bt.displayName=q;var Ln=a.forwardRef((t,n)=>{const s=z(q,t.__scopeDialog),r=a.useRef(null),o=De(n,s.contentRef,r);return a.useEffect(()=>{const i=r.current;if(i)return Ys(i)},[]),e.jsx(Gt,{...t,ref:o,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:L(t.onCloseAutoFocus,i=>{var l;i.preventDefault(),(l=s.triggerRef.current)==null||l.focus()}),onPointerDownOutside:L(t.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&i.preventDefault()}),onFocusOutside:L(t.onFocusOutside,i=>i.preventDefault())})}),Bn=a.forwardRef((t,n)=>{const s=z(q,t.__scopeDialog),r=a.useRef(!1),o=a.useRef(!1);return e.jsx(Gt,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var l,c;(l=t.onCloseAutoFocus)==null||l.call(t,i),i.defaultPrevented||(r.current||(c=s.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var f,h;(f=t.onInteractOutside)==null||f.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=i.target;((h=s.triggerRef.current)==null?void 0:h.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Gt=a.forwardRef((t,n)=>{const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...l}=t,c=z(q,s),f=a.useRef(null),h=De(n,f);return Ks(),e.jsxs(e.Fragment,{children:[e.jsx(Js,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:e.jsx(Xs,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":at(c.open),...l,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(Gn,{titleId:c.titleId}),e.jsx(Vn,{contentRef:f,descriptionId:c.descriptionId})]})]})}),rt="DialogTitle",zt=a.forwardRef((t,n)=>{const{__scopeDialog:s,...r}=t,o=z(rt,s);return e.jsx(G.h2,{id:o.titleId,...r,ref:n})});zt.displayName=rt;var Vt="DialogDescription",Wt=a.forwardRef((t,n)=>{const{__scopeDialog:s,...r}=t,o=z(Vt,s);return e.jsx(G.p,{id:o.descriptionId,...r,ref:n})});Wt.displayName=Vt;var Ht="DialogClose",Yt=a.forwardRef((t,n)=>{const{__scopeDialog:s,...r}=t,o=z(Ht,s);return e.jsx(G.button,{type:"button",...r,ref:n,onClick:L(t.onClick,()=>o.onOpenChange(!1))})});Yt.displayName=Ht;function at(t){return t?"open":"closed"}var Ut="DialogTitleWarning",[Xr,Kt]=qs(Ut,{contentName:q,titleName:rt,docsSlug:"dialog"}),Gn=({titleId:t})=>{const n=Kt(Ut),s=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
33
+
34
+ If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
35
+
36
+ For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return a.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},zn="DialogDescriptionWarning",Vn=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Kt(zn).contentName}}.`;return a.useEffect(()=>{var i;const o=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},Wn=Ft,Hn=Ot,Jt=Lt,Xt=Bt,qt=zt,Zt=Wt,Yn=Yt;const Un=Wn,Kn=Hn,Qt=a.forwardRef(({className:t,...n},s)=>e.jsx(Jt,{ref:s,className:k("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...n}));Qt.displayName=Jt.displayName;const es=a.forwardRef(({className:t,children:n,...s},r)=>e.jsxs(Kn,{children:[e.jsx(Qt,{}),e.jsxs(Xt,{ref:r,className:k("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-[hsl(var(--border))] bg-[hsl(var(--background))] p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[n,e.jsxs(Yn,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-[hsl(var(--background))] transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))] focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-[hsl(var(--accent))] data-[state=open]:text-[hsl(var(--muted-foreground))]",children:[e.jsx(Qe,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));es.displayName=Xt.displayName;const ts=({className:t,...n})=>e.jsx("div",{className:k("flex flex-col space-y-1.5 text-center sm:text-left",t),...n});ts.displayName="DialogHeader";const ss=({className:t,...n})=>e.jsx("div",{className:k("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...n});ss.displayName="DialogFooter";const ns=a.forwardRef(({className:t,...n},s)=>e.jsx(qt,{ref:s,className:k("text-lg font-semibold leading-none tracking-tight",t),...n}));ns.displayName=qt.displayName;const rs=a.forwardRef(({className:t,...n},s)=>e.jsx(Zt,{ref:s,className:k("text-sm text-[hsl(var(--muted-foreground))]",t),...n}));rs.displayName=Zt.displayName;const pe=a.forwardRef(({className:t,type:n,...s},r)=>e.jsx("input",{type:n,className:k("flex h-10 w-full rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] px-3 py-2 text-sm ring-offset-[hsl(var(--background))] file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-[hsl(var(--muted-foreground))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));pe.displayName="Input";var Jn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Xn=Jn.reduce((t,n)=>{const s=rn(`Primitive.${n}`),r=a.forwardRef((o,i)=>{const{asChild:l,...c}=o,f=l?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(f,{...c,ref:i})});return r.displayName=`Primitive.${n}`,{...t,[n]:r}},{}),qn="Label",as=a.forwardRef((t,n)=>e.jsx(Xn.label,{...t,ref:n,onMouseDown:s=>{var o;s.target.closest("button, input, select, textarea")||((o=t.onMouseDown)==null||o.call(t,s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));as.displayName=qn;var os=as;const Zn=Ze("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),se=a.forwardRef(({className:t,...n},s)=>e.jsx(os,{ref:s,className:k(Zn(),t),...n}));se.displayName=os.displayName;const ot=a.forwardRef(({className:t,...n},s)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:s,className:k("w-full caption-bottom text-sm",t),...n})}));ot.displayName="Table";const it=a.forwardRef(({className:t,...n},s)=>e.jsx("thead",{ref:s,className:k("[&_tr]:border-b",t),...n}));it.displayName="TableHeader";const lt=a.forwardRef(({className:t,...n},s)=>e.jsx("tbody",{ref:s,className:k("[&_tr:last-child]:border-0",t),...n}));lt.displayName="TableBody";const Qn=a.forwardRef(({className:t,...n},s)=>e.jsx("tfoot",{ref:s,className:k("border-t bg-[hsl(var(--muted))]/50 font-medium [&>tr]:last:border-b-0",t),...n}));Qn.displayName="TableFooter";const re=a.forwardRef(({className:t,...n},s)=>e.jsx("tr",{ref:s,className:k("border-b transition-colors hover:bg-[hsl(var(--muted))]/50 data-[state=selected]:bg-[hsl(var(--muted))]",t),...n}));re.displayName="TableRow";const M=a.forwardRef(({className:t,...n},s)=>e.jsx("th",{ref:s,className:k("h-12 px-4 text-left align-middle font-medium text-[hsl(var(--muted-foreground))] [&:has([role=checkbox])]:pr-0",t),...n}));M.displayName="TableHead";const F=a.forwardRef(({className:t,...n},s)=>e.jsx("td",{ref:s,className:k("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...n}));F.displayName="TableCell";const er=a.forwardRef(({className:t,...n},s)=>e.jsx("caption",{ref:s,className:k("mt-4 text-sm text-[hsl(var(--muted-foreground))]",t),...n}));er.displayName="TableCaption";var We="rovingFocusGroup.onEntryFocus",tr={bubbles:!1,cancelable:!0},ve="RovingFocusGroup",[Ue,is,sr]=Zs(ve),[nr,ls]=qe(ve,[sr]),[rr,ar]=nr(ve),cs=a.forwardRef((t,n)=>e.jsx(Ue.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Ue.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(or,{...t,ref:n})})}));cs.displayName=ve;var or=a.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:r,loop:o=!1,dir:i,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:f,onEntryFocus:h,preventScrollOnEntryFocus:m=!1,...v}=t,S=a.useRef(null),C=De(n,S),T=Et(i),[b,y]=Xe({prop:l,defaultProp:c??null,onChange:f,caller:ve}),[d,x]=a.useState(!1),j=Qs(h),_=is(s),D=a.useRef(!1),[A,I]=a.useState(0);return a.useEffect(()=>{const w=S.current;if(w)return w.addEventListener(We,j),()=>w.removeEventListener(We,j)},[j]),e.jsx(rr,{scope:s,orientation:r,dir:T,loop:o,currentTabStopId:b,onItemFocus:a.useCallback(w=>y(w),[y]),onItemShiftTab:a.useCallback(()=>x(!0),[]),onFocusableItemAdd:a.useCallback(()=>I(w=>w+1),[]),onFocusableItemRemove:a.useCallback(()=>I(w=>w-1),[]),children:e.jsx(G.div,{tabIndex:d||A===0?-1:0,"data-orientation":r,...v,ref:C,style:{outline:"none",...t.style},onMouseDown:L(t.onMouseDown,()=>{D.current=!0}),onFocus:L(t.onFocus,w=>{const p=!D.current;if(w.target===w.currentTarget&&p&&!d){const N=new CustomEvent(We,tr);if(w.currentTarget.dispatchEvent(N),!N.defaultPrevented){const E=_().filter(O=>O.focusable),g=E.find(O=>O.active),be=E.find(O=>O.id===b),oe=[g,be,...E].filter(Boolean).map(O=>O.ref.current);fs(oe,m)}}D.current=!1}),onBlur:L(t.onBlur,()=>x(!1))})})}),ds="RovingFocusGroupItem",us=a.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:r=!0,active:o=!1,tabStopId:i,children:l,...c}=t,f=ue(),h=i||f,m=ar(ds,s),v=m.currentTabStopId===h,S=is(s),{onFocusableItemAdd:C,onFocusableItemRemove:T,currentTabStopId:b}=m;return a.useEffect(()=>{if(r)return C(),()=>T()},[r,C,T]),e.jsx(Ue.ItemSlot,{scope:s,id:h,focusable:r,active:o,children:e.jsx(G.span,{tabIndex:v?0:-1,"data-orientation":m.orientation,...c,ref:n,onMouseDown:L(t.onMouseDown,y=>{r?m.onItemFocus(h):y.preventDefault()}),onFocus:L(t.onFocus,()=>m.onItemFocus(h)),onKeyDown:L(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){m.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const d=cr(y,m.orientation,m.dir);if(d!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let j=S().filter(_=>_.focusable).map(_=>_.ref.current);if(d==="last")j.reverse();else if(d==="prev"||d==="next"){d==="prev"&&j.reverse();const _=j.indexOf(y.currentTarget);j=m.loop?dr(j,_+1):j.slice(_+1)}setTimeout(()=>fs(j))}}),children:typeof l=="function"?l({isCurrentTabStop:v,hasTabStop:b!=null}):l})})});us.displayName=ds;var ir={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lr(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function cr(t,n,s){const r=lr(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ir[r]}function fs(t,n=!1){const s=document.activeElement;for(const r of t)if(r===s||(r.focus({preventScroll:n}),document.activeElement!==s))return}function dr(t,n){return t.map((s,r)=>t[(n+r)%t.length])}var ur=cs,fr=us,Ie="Tabs",[hr]=qe(Ie,[ls]),hs=ls(),[mr,ct]=hr(Ie),ms=a.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,onValueChange:o,defaultValue:i,orientation:l="horizontal",dir:c,activationMode:f="automatic",...h}=t,m=Et(c),[v,S]=Xe({prop:r,onChange:o,defaultProp:i??"",caller:Ie});return e.jsx(mr,{scope:s,baseId:ue(),value:v,onValueChange:S,orientation:l,dir:m,activationMode:f,children:e.jsx(G.div,{dir:m,"data-orientation":l,...h,ref:n})})});ms.displayName=Ie;var xs="TabsList",ps=a.forwardRef((t,n)=>{const{__scopeTabs:s,loop:r=!0,...o}=t,i=ct(xs,s),l=hs(s);return e.jsx(ur,{asChild:!0,...l,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(G.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:n})})});ps.displayName=xs;var gs="TabsTrigger",vs=a.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,disabled:o=!1,...i}=t,l=ct(gs,s),c=hs(s),f=ys(l.baseId,r),h=_s(l.baseId,r),m=r===l.value;return e.jsx(fr,{asChild:!0,...c,focusable:!o,active:m,children:e.jsx(G.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":h,"data-state":m?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:f,...i,ref:n,onMouseDown:L(t.onMouseDown,v=>{!o&&v.button===0&&v.ctrlKey===!1?l.onValueChange(r):v.preventDefault()}),onKeyDown:L(t.onKeyDown,v=>{[" ","Enter"].includes(v.key)&&l.onValueChange(r)}),onFocus:L(t.onFocus,()=>{const v=l.activationMode!=="manual";!m&&!o&&v&&l.onValueChange(r)})})})});vs.displayName=gs;var bs="TabsContent",js=a.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,forceMount:o,children:i,...l}=t,c=ct(bs,s),f=ys(c.baseId,r),h=_s(c.baseId,r),m=r===c.value,v=a.useRef(m);return a.useEffect(()=>{const S=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(S)},[]),e.jsx(ke,{present:o||m,children:({present:S})=>e.jsx(G.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":f,hidden:!S,id:h,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:v.current?"0s":void 0},children:S&&i})})});js.displayName=bs;function ys(t,n){return`${t}-trigger-${n}`}function _s(t,n){return`${t}-content-${n}`}var xr=ms,Ns=ps,ws=vs,Ss=js;const pr=xr,Cs=a.forwardRef(({className:t,...n},s)=>e.jsx(Ns,{ref:s,className:k("inline-flex h-10 items-center justify-center rounded-md bg-[hsl(var(--muted))] p-1 text-[hsl(var(--muted-foreground))]",t),...n}));Cs.displayName=Ns.displayName;const Ke=a.forwardRef(({className:t,...n},s)=>e.jsx(ws,{ref:s,className:k("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-[hsl(var(--background))] transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-[hsl(var(--background))] data-[state=active]:text-[hsl(var(--foreground))] data-[state=active]:shadow-sm",t),...n}));Ke.displayName=ws.displayName;const gr=a.forwardRef(({className:t,...n},s)=>e.jsx(Ss,{ref:s,className:k("mt-2 ring-offset-[hsl(var(--background))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-2",t),...n}));gr.displayName=Ss.displayName;const Ts=a.forwardRef(({className:t,...n},s)=>e.jsx("textarea",{className:k("flex min-h-[80px] w-full rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] px-3 py-2 text-sm ring-offset-[hsl(var(--background))] placeholder:text-[hsl(var(--muted-foreground))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...n}));Ts.displayName="Textarea";const Nt=260,le=12,vr=12,wt=40,St=10,Ct=4,br=10,Tt=8,P=12,jr=8,yr=3,Rt=8,ge=13,ne=11,_r=10,Te=10,R={surface:"#ffffff",fg:"#1a2332",muted:"#6b7a8d",border:"#e2e5ea",fgSoft:"#f3f4f6",accent:"#1a9a5c",danger:"#d63031",dangerSoft:"#fef2f2",warning:"#d4880a",info:"#3b6fd4",purple:"#7c3aed",purpleSoft:"#f3eeff"};function Nr(t){switch(t){case"open":return R.info;case"claimed":case"in_progress":return R.warning;case"review":return R.purple;case"done":return R.accent;case"blocked":return R.danger;case"abandoned":return"#94a3b8";default:return R.muted}}function Se(t,n){return t.length>n?t.slice(0,n-1)+"…":t}function Rs(t,n,s,r){let o=1,i=0;for(const l of t){const c=l.charCodeAt(0)>11904?n:n*.55;if(i+c>s){if(o++,i=c,o>=r)return r}else i+=c}return o}function wr(t){const n=Date.now()-t,s=Math.floor(n/1e3);if(s<60)return`${s}s`;const r=Math.floor(s/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Je(t){return t==="claimed"||t==="in_progress"}function Sr(t){if(t.blocked_reason)return t.blocked_reason;const n=t.blocking_dependencies||[];return n.length===0?"Blocked":`等待: ${n.map(r=>r.title||r.id).join(", ")}`}function kt(t,n){const s=n-P*2-8;let r=P;const o=Rs(t.title,ge,s,2);return r+=o*(ge*1.4)+6,r+=ne+8,t.last_output&&Je(t.status)&&(r+=34),t.status==="blocked"&&(r+=8+ne+4),(t.priority>=5||t.created_by==="scheduled_task"||t.assignee_role_id)&&(r+=8+Te+10),r+=P,Math.max(r,76)}const Cr=25,Tr=24,Rr=a.memo(function({task:n,x:s,y:r,width:o,height:i,index:l,onDragEnd:c,onClick:f}){const h=a.useRef(null),m=a.useRef(!0),v=a.useRef(!1),S=n.status==="blocked";a.useEffect(()=>{const p=h.current;if(p){if(m.current){if(m.current=!1,p.position({x:s,y:r}),l>=Tr){p.opacity(1);return}p.opacity(0);const N=setTimeout(()=>{p.to({opacity:1,duration:.2,easing:_t.Easings.EaseOut})},l*Cr);return()=>clearTimeout(N)}p.isDragging()||p.to({x:s,y:r,duration:.25,easing:_t.Easings.EaseInOut})}},[s,r,n.id,l]);const C=o-P*2-8;let T=P;const b=T,y=Rs(n.title,ge,C,2);T+=y*(ge*1.4)+6;const d=T,x=`${n.project_name||"无项目"} · ${n.assignee_agent_id||"未分配"}`;T+=ne+8;const j=Je(n.status)&&n.session_started_at,_=!S&&Je(n.status)&&n.last_output,D=T+4;_&&(T+=34);const A=T+4;S&&(T+=8+ne+4);const I=n.priority>=5||n.created_by==="scheduled_task"||n.assignee_role_id,w=T+4;return e.jsxs(de,{ref:h,x:s,y:r,draggable:!0,onDragStart:()=>{v.current=!0},onDragEnd:p=>{c(n.id,p.target),setTimeout(()=>{v.current=!1},50)},onClick:()=>{!v.current&&f&&f(n.id)},onTap:()=>{!v.current&&f&&f(n.id)},onMouseEnter:p=>{const N=p.target.getStage();N&&(N.container().style.cursor="grab")},onMouseLeave:p=>{const N=p.target.getStage();N&&(N.container().style.cursor="default")},children:[e.jsx(K,{width:o,height:i,fill:S?R.dangerSoft:R.surface,cornerRadius:jr,stroke:S?`${R.danger}66`:R.border,strokeWidth:1}),e.jsx(K,{x:0,y:Rt,width:yr,height:i-Rt*2,fill:Nr(n.status),cornerRadius:[0,2,2,0]}),e.jsx(W,{x:P+8-4,y:b,width:o-P*2-8,text:Se(n.title,48),fontSize:ge,fontStyle:"500",fontFamily:"-apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif",fill:R.fg,lineHeight:1.4}),e.jsx(W,{x:P+8-4,y:d,width:o-P*2-8-(j?50:0),text:x,fontSize:ne,fontFamily:"-apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif",fill:R.muted}),j&&e.jsx(W,{x:o-P-44,y:d,width:44,text:`⏱ ${wr(n.session_started_at)}`,fontSize:10,fontFamily:"'JetBrains Mono', ui-monospace, monospace",fill:R.warning,align:"right"}),_&&e.jsxs(e.Fragment,{children:[e.jsx(K,{x:P+4,y:D,width:o-P*2-8,height:22,fill:R.fgSoft,cornerRadius:4}),e.jsx(W,{x:P+4+6,y:D+5,width:o-P*2-8-12,text:Se(n.last_output,52),fontSize:_r,fontFamily:"'JetBrains Mono', ui-monospace, monospace",fill:R.muted,wrap:"none",ellipsis:!0})]}),S&&e.jsx(W,{x:P+8-4,y:A,width:o-P*2-8,text:Se(Sr(n),50),fontSize:ne,fontFamily:"-apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif",fill:R.danger}),I&&(()=>{let p=P+4;const N=[];if(n.priority>=5&&(N.push(e.jsxs(de,{x:p,y:w,children:[e.jsx(K,{width:28,height:16,fill:R.dangerSoft,cornerRadius:8}),e.jsx(W,{x:0,y:2,width:28,height:16,text:`P${n.priority}`,fontSize:Te,fontFamily:"'JetBrains Mono', monospace",fontStyle:"500",fill:R.danger,align:"center"})]},"pri")),p+=32),n.created_by==="scheduled_task"&&(N.push(e.jsxs(de,{x:p,y:w,children:[e.jsx(K,{width:28,height:16,fill:R.purpleSoft,cornerRadius:8}),e.jsx(W,{x:0,y:2,width:28,height:16,text:"定时",fontSize:Te,fontFamily:"'JetBrains Mono', monospace",fontStyle:"500",fill:R.purple,align:"center"})]},"sched")),p+=32),n.assignee_role_id){const E=n.assignee_role_id,g=Math.min(E.length*7+12,60);N.push(e.jsxs(de,{x:p,y:w,children:[e.jsx(K,{width:g,height:16,fill:R.fgSoft,cornerRadius:8}),e.jsx(W,{x:0,y:2,width:g,height:16,text:Se(E,8),fontSize:Te,fontFamily:"'JetBrains Mono', monospace",fontStyle:"500",fill:R.muted,align:"center"})]},"role"))}return N})()]})});function kr({tasks:t,statuses:n,onRefresh:s,onTaskClick:r}){const o=a.useRef(null),[i,l]=a.useState({width:800,height:600});a.useEffect(()=>{const d=o.current;if(!d)return;const x=new ResizeObserver(j=>{for(const _ of j)l({width:_.contentRect.width,height:_.contentRect.height})});return x.observe(d),l({width:d.clientWidth,height:d.clientHeight}),()=>x.disconnect()},[]);const c=a.useMemo(()=>n.map(d=>({...d,tasks:t.filter(x=>x.status===d.id)})),[t,n]),f=c.length,h=f>0?Math.max(Nt,(i.width-48-(f-1)*le)/f):Nt,m=h-St*2,v=a.useMemo(()=>c.map(d=>{let x=wt+Ct;return d.tasks.forEach(j=>{x+=kt(j,m)+Tt}),x+=br,x}),[c,m]),S=24+f*h+(f-1)*le+24,C=Math.max(i.width,S),T=Math.max(i.height,...v),b=a.useRef({colWidth:h,colCount:f,columns:c,onRefresh:s});b.current={colWidth:h,colCount:f,columns:c,onRefresh:s};const y=a.useCallback((d,x)=>{var N;const{colWidth:j,colCount:_,columns:D,onRefresh:A}=b.current,I=x.absolutePosition().x;let w=0;for(let E=0;E<_;E++){const g=24+E*(j+le);if(I>=g&&I<g+j){w=E;break}E===_-1&&(w=E)}const p=(N=D[w])==null?void 0:N.id;p&&He(`/tasks/${d}`,{status:p}).then(()=>A())},[]);return f===0?e.jsx("div",{className:"flex items-center justify-center h-64 text-sm",style:{color:"hsl(var(--muted-foreground))"},children:"未配置工作流状态"}):e.jsx("div",{ref:o,className:"w-full h-full min-h-[400px] overflow-auto",children:e.jsxs(ln,{width:C,height:T,style:{display:"block"},children:[e.jsx(yt,{listening:!1,children:c.map((d,x)=>{const j=24+x*(h+le),_=v[x];return e.jsxs(de,{children:[e.jsx(K,{x:j,y:0,width:h,height:_,fill:R.fgSoft,cornerRadius:vr}),e.jsx(W,{x:j+14,y:14,text:(d.label||d.id).toUpperCase(),fontSize:12,fontStyle:"600",fontFamily:"-apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif",fill:R.muted,letterSpacing:.5}),e.jsx(K,{x:j+h-14-24,y:11,width:24,height:18,fill:R.surface,stroke:R.border,strokeWidth:1,cornerRadius:9}),e.jsx(W,{x:j+h-14-24,y:13,width:24,height:18,text:String(d.tasks.length),fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace",fill:R.muted,align:"center",verticalAlign:"middle"})]},"col-bg-"+d.id)})}),e.jsx(yt,{children:c.map((d,x)=>{const j=24+x*(h+le);let _=wt+Ct;return d.tasks.map((D,A)=>{const I=j+St,w=_,p=kt(D,m);return _+=p+Tt,e.jsx(Rr,{task:D,x:I,y:w,width:m,height:p,index:x*10+A,onDragEnd:y,onClick:r},"card-"+D.id)})})})]})})}function Dr({sessionId:t,hubUrl:n,compact:s=!1,onClose:r,className:o=""}){const i=a.useRef(null),l=a.useRef(null),c=a.useRef(null),[f,h]=a.useState("connecting"),[m,v]=a.useState(0);a.useEffect(()=>{if(!i.current||!t)return;let b,y,d=null,x=null;return(async()=>{const{Terminal:_}=await ze(async()=>{const{Terminal:p}=await import("./xterm-DlVFs1Kw.js").then(N=>N.x);return{Terminal:p}},[]),{FitAddon:D}=await ze(async()=>{const{FitAddon:p}=await import("./addon-fit-BlxrFPDK.js").then(N=>N.a);return{FitAddon:p}},[]);try{await ze(()=>Promise.resolve({}),__vite__mapDeps([0]))}catch{}b=new _({cursorBlink:!0,cursorStyle:"bar",fontSize:s?11:12,fontFamily:"'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace",lineHeight:1.4,letterSpacing:0,scrollback:5e3,theme:{background:"#161b22",foreground:"#c9d1d9",cursor:"#58a6ff",cursorAccent:"#161b22",selectionBackground:"#264f78",selectionForeground:"#ffffff",black:"#484f58",red:"#ff7b72",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39c5cf",white:"#b1bac4",brightBlack:"#6e7681",brightRed:"#ffa198",brightGreen:"#56d364",brightYellow:"#e3b341",brightBlue:"#79c0ff",brightMagenta:"#d2a8ff",brightCyan:"#56d4dd",brightWhite:"#f0f6fc"}}),y=new D,b.loadAddon(y),b.open(i.current),requestAnimationFrame(()=>{try{y.fit()}catch{}}),c.current=b;let A=0;b.onLineFeed(()=>{A++,v(A)});const I=window.location.protocol==="https:"?"wss:":"ws:",w=n||`${I}//${window.location.host}`;x=new WebSocket(`${w}/space/sessions/${t}`),l.current=x,x.onopen=()=>{h("connected"),b.writeln(`\x1B[38;5;242m── session ${t} ──\x1B[0m\r
37
+ `)},x.onmessage=p=>{try{const N=JSON.parse(p.data);N.type==="stdout"||N.type==="stderr"?b.write(N.data):N.type==="exit"?(b.writeln(`\r
38
+ \x1B[38;5;242m[exited: ${N.code??"signal"}]\x1B[0m`),h("disconnected")):N.type==="error"&&b.writeln(`\r
39
+ \x1B[31m[${N.error}]\x1B[0m`)}catch{b.write(p.data)}},x.onerror=()=>{h("error"),b.writeln(`\r
40
+ \x1B[31m[connection error]\x1B[0m`)},x.onclose=()=>{f!=="error"&&h("disconnected"),b.writeln(`\r
41
+ \x1B[38;5;242m[disconnected]\x1B[0m`)},b.onData(p=>{x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"stdin",data:p}))}),d=new ResizeObserver(()=>{try{y.fit()}catch{}}),d.observe(i.current)})(),()=>{d==null||d.disconnect(),x==null||x.close(),b==null||b.dispose(),c.current=null,l.current=null}},[t,n]);const S=()=>{var y;const b=(y=c.current)==null?void 0:y.getSelection();b&&navigator.clipboard.writeText(b)},C={connecting:"bg-amber-400 animate-pulse",connected:"bg-emerald-400",disconnected:"bg-zinc-500",error:"bg-red-400"},T={connecting:"连接中",connected:"已连接",disconnected:"已断开",error:"错误"};return s?e.jsx("div",{className:`rounded-lg overflow-hidden border border-[#30363d] ${o}`,children:e.jsx("div",{ref:i,className:"w-full h-full min-h-[120px]",style:{background:"#161b22"}})}):e.jsxs("div",{className:`flex flex-col rounded-xl overflow-hidden border border-[#30363d] bg-[#161b22] ${o}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-[#1c2128] border-b border-[#30363d] shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${C[f]}`}),e.jsx("span",{className:"font-mono text-[11px] text-[#8b949e]",children:T[f]}),e.jsx("span",{className:"text-[#30363d]",children:"·"}),e.jsx("span",{className:"font-mono text-[11px] text-[#8b949e] truncate max-w-[180px]",children:t})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:S,className:"p-1.5 rounded-md text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d] transition-colors",title:"复制选中",children:e.jsx(jn,{className:"w-3.5 h-3.5"})}),r&&e.jsx("button",{onClick:r,className:"p-1.5 rounded-md text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d] transition-colors",title:"关闭",children:e.jsx(Qe,{className:"w-3.5 h-3.5"})})]})]}),e.jsx("div",{ref:i,className:"flex-1 min-h-0",style:{padding:"8px 4px"}}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-1 bg-[#1c2128] border-t border-[#30363d] shrink-0",children:[e.jsx("span",{className:"font-mono text-[10px] text-[#484f58]",children:m>0?`${m} lines`:"ready"}),e.jsx("span",{className:"font-mono text-[10px] text-[#484f58]",children:"UTF-8"})]})]})}function ks(t){switch(t){case"open":return"bg-blue-100 text-blue-700";case"claimed":case"in_progress":return"bg-amber-100 text-amber-700";case"review":return"bg-violet-100 text-violet-700";case"done":return"bg-green-100 text-green-700";case"blocked":return"bg-red-100 text-red-700";case"abandoned":return"bg-slate-200 text-slate-700";case"rejected":return"bg-orange-100 text-orange-700";default:return"bg-gray-100 text-gray-700"}}function Ds(t){switch(t){case"done":return"✓";case"blocked":return"!";case"claimed":case"in_progress":return">";case"review":return"?";case"abandoned":return"×";case"rejected":return"-";default:return"•"}}function Er(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ir(t){const n=Date.now()-t,s=Math.floor(n/1e3);if(s<60)return`${s}s`;const r=Math.floor(s/60);return r<60?`${r}m ${s%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function Ar(t){switch(t){case"agent_output":return"💬";case"artifact":return"📦";case"comment":return"💭";case"review":return"👀";case"spawn_task":return"🔀";case"session_diagnostic":return"⚠️";case"workflow_transition":return"➡️";default:return"•"}}function Pr(t){switch(t){case"agent_output":return"Agent Output";case"artifact":return"Artifact";case"comment":return"Comment";case"review":return"Review";case"spawn_task":return"Spawned Task";case"session_diagnostic":return"Diagnostic";case"workflow_transition":return"Transition";default:return t}}function Fr({taskId:t,onClose:n}){var y;const[s,r]=a.useState(null),[o,i]=a.useState(!1),[l,c]=a.useState(!1),[f,h]=a.useState([]),[m,v]=a.useState(260),S=a.useRef(null),C=a.useRef(null);a.useEffect(()=>{if(!t){r(null),c(!1);return}i(!0),J(`/tasks/${t}`).then(d=>{r(d),c(!!d.session_id&&["claimed","in_progress"].includes(d.status))}).catch(()=>r(null)).finally(()=>i(!1))},[t]),a.useEffect(()=>{if(!t||!s||!["claimed","in_progress"].includes(s.status))return;const d=setInterval(()=>{J(`/tasks/${t}`).then(r).catch(()=>{})},5e3);return()=>clearInterval(d)},[t,s==null?void 0:s.status]),a.useEffect(()=>{if(!(s!=null&&s.session_id)||!["claimed","in_progress"].includes(s.status)){h([]);return}if(s.thread.length>0)return;const d=()=>{J(`/sessions/${s.session_id}/output?lines=10`).then(j=>h(j.lines||[])).catch(()=>{})};d();const x=setInterval(d,3e3);return()=>clearInterval(x)},[s==null?void 0:s.session_id,s==null?void 0:s.status,(y=s==null?void 0:s.thread)==null?void 0:y.length]);const T=d=>{d.preventDefault();const x="touches"in d?d.touches[0].clientY:d.clientY;C.current={startY:x,startH:m};const j=D=>{if(!C.current)return;const A="touches"in D?D.touches[0].clientY:D.clientY,I=C.current.startY-A,w=Math.max(120,Math.min(600,C.current.startH+I));v(w)},_=()=>{C.current=null,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",_)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),document.addEventListener("touchmove",j),document.addEventListener("touchend",_)};if(!t)return null;const b=s&&["claimed","in_progress"].includes(s.status);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:n}),e.jsxs("div",{className:"fixed inset-y-0 right-0 w-[520px] max-w-full z-50 flex flex-col bg-white border-l border-[hsl(var(--border))] shadow-2xl animate-in slide-in-from-right duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[hsl(var(--border))] shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsxs(It,{variant:"outline",className:ks((s==null?void 0:s.status)||"open"),children:[e.jsx("span",{"aria-hidden":"true",children:Ds((s==null?void 0:s.status)||"open")}),(s==null?void 0:s.status)||"open"]}),e.jsx("span",{className:"text-sm font-medium truncate",children:(s==null?void 0:s.title)||"Loading..."})]}),e.jsx(H,{variant:"ghost",size:"sm",onClick:n,className:"shrink-0 h-7 w-7 p-0",children:e.jsx(Qe,{className:"w-4 h-4"})})]}),o&&e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-[hsl(var(--muted-foreground))]",children:"Loading..."}),!o&&s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 py-3 border-b border-[hsl(var(--border))] flex flex-wrap gap-x-4 gap-y-1.5 text-[12px] text-[hsl(var(--muted-foreground))]",children:[s.project_name&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:"Project:"}),s.project_name]}),s.assignee_role_id&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:"Role:"}),s.assignee_role_id]}),s.assignee_agent_id&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:"Agent:"}),e.jsx("code",{className:"font-mono text-[11px]",children:s.assignee_agent_id})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:"Priority:"}),"P",s.priority]}),b&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",children:[e.jsx(et,{className:"w-3 h-3"}),Ir(s.created_at)]}),s.created_by==="scheduled_task"&&e.jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-purple-50 text-purple-600 font-mono text-[10px] font-medium",children:"scheduled"}),s.session_id&&e.jsx("button",{onClick:()=>c(!l),className:"underline hover:text-[hsl(var(--foreground))] cursor-pointer",children:l?"Hide Terminal":"Show Terminal"})]}),s.description&&e.jsx("div",{className:"px-5 py-2.5 border-b border-[hsl(var(--border))] text-[12px] text-[hsl(var(--muted-foreground))] leading-relaxed",children:s.description}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-3",children:[s.thread.length===0?e.jsx("div",{className:"py-4",children:f.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[hsl(var(--muted-foreground))]",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),"Agent is working..."]}),e.jsx("div",{className:"bg-[hsl(var(--sidebar-background))] rounded-lg p-3 text-[10px] font-mono leading-relaxed text-gray-300 max-h-[200px] overflow-y-auto",children:f.map((d,x)=>e.jsx("div",{className:"truncate",children:d||" "},x))}),e.jsx("div",{className:"text-[10px] text-[hsl(var(--muted-foreground))] text-center",children:"Live terminal output · Updates every 3s"})]}):e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))] text-center py-8",children:s.session_id&&b?"Agent is starting...":"No activity yet."})}):s.thread.map(d=>e.jsxs("div",{className:"flex gap-2.5 text-xs",children:[e.jsx("div",{className:"w-[26px] h-[26px] rounded-full bg-[hsl(var(--muted))] flex items-center justify-center shrink-0 text-[12px]",children:Ar(d.kind)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--muted-foreground))]",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:Pr(d.kind)}),e.jsx("span",{children:d.author}),e.jsx("span",{className:"ml-auto font-mono text-[10px]",children:Er(d.created_at)})]}),d.content&&e.jsx("div",{className:"mt-1.5 whitespace-pre-wrap text-[hsl(var(--foreground))] bg-[hsl(var(--muted))] rounded-md px-3 py-2 leading-relaxed text-[12px]",children:d.content})]})]},d.id)),e.jsx("div",{ref:S})]}),l&&s.session_id&&e.jsxs("div",{className:"shrink-0 flex flex-col",style:{height:m},children:[e.jsx("div",{onMouseDown:T,onTouchStart:T,className:"h-2 cursor-ns-resize flex items-center justify-center border-t border-[hsl(var(--border))] bg-[hsl(var(--muted))]/30 hover:bg-[hsl(var(--muted))]/60 transition-colors group",children:e.jsx("div",{className:"w-8 h-[3px] rounded-full bg-[hsl(var(--muted-foreground))]/30 group-hover:bg-[hsl(var(--muted-foreground))]/60 transition-colors"})}),e.jsx("div",{className:"flex-1 min-h-0 p-3",children:e.jsx(Dr,{sessionId:s.session_id,onClose:()=>c(!1),className:"h-full"})})]})]})]})]})}function Mr(t){if(t.blocked_reason)return t.blocked_reason;const n=t.blocking_dependencies||[];return n.length===0?t.status==="blocked"?"Blocked":"-":n.map(s=>`${s.title} (${s.status})`).join(", ")}function Dt(t){return t?new Date(Number(t)).toLocaleString():"-"}function $r(t){const n=new Date(Number(t)),s=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-s).toISOString().slice(0,16)}function Or(t){return t?new Date(t).getTime():null}function qr(){const{id:t}=en(),[n]=tn(),s=n.get("view")||"board",[r,o]=a.useState([]),[i,l]=a.useState([]),[c,f]=a.useState([]),[h,m]=a.useState([]),[v,S]=a.useState(s),[C,T]=a.useState("__all__"),[b,y]=a.useState("__all__"),[d,x]=a.useState(!0),[j,_]=a.useState(!1),[D,A]=a.useState(""),[I,w]=a.useState(""),[p,N]=a.useState(""),[E,g]=a.useState("__none__"),[be,Ae]=a.useState("0"),[oe,O]=a.useState(""),[dt,ut]=a.useState(!1),[Es,Pe]=a.useState(null),[Z,Is]=a.useState([]),[je,ft]=a.useState(null),[ye,Fe]=a.useState(""),[ht,Me]=a.useState(""),[_e,mt]=a.useState(""),[xt,$e]=a.useState(""),[Q,Oe]=a.useState("cron"),[Ne,Le]=a.useState("0 9 * * 1"),[we,Be]=a.useState(""),[pt,gt]=a.useState(!1),[As,ee]=a.useState(""),{lastEvent:vt}=dn("task.*,session.*,scheduled_task.*"),ie=a.useRef(null),te=C==="__all__"?"":C,U=()=>{t&&(x(!0),Promise.all([J(`/tasks?workspace_id=${t}`),J(`/workspaces/${t}/projects`),J(`/workspaces/${t}/roles`),J(`/tasks/workflow/statuses${te?`?project_id=${te}`:""}`),J(`/scheduled-tasks?workspace_id=${t}`)]).then(([u,$,B,X,V])=>{o(u),l($),f(B),m(X),Is(V),x(!1)}).catch(()=>x(!1)))};a.useEffect(()=>{U()},[t,C]),a.useEffect(()=>{if(vt)return ie.current&&clearTimeout(ie.current),ie.current=setTimeout(U,300),()=>{ie.current&&clearTimeout(ie.current)}},[vt,t]);const bt=r.filter(u=>te&&u.project_id!==te?!1:b==="manual"?u.created_by!=="scheduled_task":b==="scheduled"?u.created_by==="scheduled_task":!0),jt=a.useMemo(()=>!ye.trim()||!_e?!1:Q==="cron"?!!Ne.trim():!!we,[ye,_e,Q,Ne,we]),Ps=a.useMemo(()=>{const u=Z.filter(V=>V.enabled).length,$=Z.filter(V=>V.schedule_type==="cron").length,B=Z.filter(V=>V.schedule_type==="once").length,X=Z.filter(V=>{if(!V.last_fired_at)return!1;const zs=new Date(Number(V.last_fired_at)),Vs=new Date;return zs.toDateString()===Vs.toDateString()}).length;return{active:u,cron:$,once:B,today:X}},[Z]);function Ge(){ft(null),Fe(""),Me(""),$e(""),Oe("cron"),Le("0 9 * * 1"),Be(""),ee("")}const Fs=async u=>{if(u.preventDefault(),!t||!jt||pt)return;gt(!0),ee("");const $={workspace_id:t,project_id:_e,title:ye.trim(),description:ht.trim(),priority:0,schedule_type:Q,cron_expr:Q==="cron"?Ne.trim():void 0,run_at:Q==="once"?Or(we):void 0,assignee_role_id:xt||void 0};try{je?await He(`/scheduled-tasks/${je}`,$):await Ve("/scheduled-tasks",$),Ge(),U()}catch(B){ee(B.message)}finally{gt(!1)}},Ms=u=>{ft(u.id),Fe(u.title),Me(u.description||""),mt(u.project_id),$e(u.assignee_role_id||""),Oe(u.schedule_type),Le(u.cron_expr||"0 9 * * 1"),Be(u.run_at?$r(u.run_at):"")},$s=async u=>{try{await He(`/scheduled-tasks/${u.id}`,{...u,enabled:u.enabled?0:1}),U()}catch($){ee($.message)}},Os=async u=>{try{await sn(`/scheduled-tasks/${u.id}`),je===u.id&&Ge(),U()}catch($){ee($.message)}},Ls=async()=>{try{await Ve("/scheduled-tasks/run",{}),U()}catch(u){ee(u.message)}},Bs=()=>{var u;A(""),w(""),N(te||((u=i[0])==null?void 0:u.id)||""),g("__none__"),Ae("0"),O(""),_(!0)},Gs=async u=>{u.preventDefault();const $=D.trim();if(!$){O("Task title is required.");return}if(!p){O("Project is required.");return}const B=c.find(X=>X.id===E);ut(!0),O("");try{await Ve("/tasks",{project_id:p,title:$,description:I.trim(),priority:Number(be),assignee_role_id:B==null?void 0:B.id,assignee_role:B==null?void 0:B.name}),_(!1),C!=="__all__"&&C!==p?T(p):U()}catch(X){O(X.message||"Failed to create task.")}finally{ut(!1)}};return d?e.jsx("div",{className:"p-6 text-[hsl(var(--muted-foreground))] text-sm",children:"Loading..."}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 bg-white/90 backdrop-blur-sm shrink-0 sticky top-0 z-10",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Tasks"}),e.jsxs(H,{onClick:Bs,disabled:i.length===0,size:"sm",children:[e.jsx(un,{className:"h-4 w-4"}),"New Task"]})]}),e.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-[hsl(var(--border))] shrink-0 flex-wrap gap-3",children:[e.jsx("div",{className:"flex items-center bg-[hsl(var(--muted))] rounded-md p-[3px] gap-0.5",children:[{id:"board",label:"Board",icon:vn},{id:"table",label:"List",icon:_n},{id:"gantt",label:"Progress",icon:mn},{id:"schedules",label:"Schedules",icon:et}].map(u=>{const $=u.icon;return e.jsxs("button",{onClick:()=>S(u.id),className:`flex items-center gap-1.5 px-3 py-[5px] rounded text-xs font-medium transition-all cursor-pointer border-none ${v===u.id?"bg-white text-[hsl(var(--foreground))] shadow-sm":"bg-transparent text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))]"}`,children:[e.jsx($,{className:"w-3.5 h-3.5"}),u.label]},u.id)})}),v!=="schedules"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{active:C==="__all__",onClick:()=>T("__all__"),children:"All Projects"}),i.map(u=>e.jsx(ce,{active:C===u.id,onClick:()=>T(u.id),children:u.name},u.id)),e.jsx("span",{className:"w-px h-4 bg-[hsl(var(--border))] mx-1"}),e.jsx(ce,{active:b==="__all__",onClick:()=>y("__all__"),children:"All"}),e.jsx(ce,{active:b==="manual",onClick:()=>y("manual"),children:"Manual"}),e.jsx(ce,{active:b==="scheduled",onClick:()=>y("scheduled"),children:"Scheduled"})]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden",children:[v==="board"&&e.jsx("div",{className:"h-full min-h-[400px]",children:e.jsx(kr,{tasks:bt,statuses:h,onRefresh:U,onTaskClick:Pe})}),v==="table"&&e.jsx(Lr,{tasks:bt,onTaskClick:Pe}),v==="gantt"&&t&&e.jsx("div",{className:"h-full min-h-[400px]",children:e.jsx(cn,{workspaceId:t,projectFilter:te||void 0})}),v==="schedules"&&e.jsx(Br,{schedules:Z,projects:i,roles:c,stats:Ps,editingId:je,title:ye,description:ht,projectId:_e,roleId:xt,schedType:Q,cronExpr:Ne,runAt:we,saving:pt,error:As,canSave:jt,onTitleChange:Fe,onDescriptionChange:Me,onProjectChange:mt,onRoleChange:$e,onTypeChange:Oe,onCronChange:Le,onRunAtChange:Be,onSubmit:Fs,onEdit:Ms,onToggle:$s,onDelete:Os,onRunDue:Ls,onCancel:Ge})]}),e.jsx(Un,{open:j,onOpenChange:_,children:e.jsxs(es,{children:[e.jsxs(ts,{children:[e.jsx(ns,{children:"New Task"}),e.jsx(rs,{children:"Create a task in this workspace."})]}),e.jsxs("form",{onSubmit:Gs,className:"space-y-4",children:[oe&&e.jsx(tt,{variant:"destructive",children:e.jsx(st,{children:oe})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"task-title",children:"Title"}),e.jsx(pe,{id:"task-title",value:D,onChange:u=>{A(u.target.value),oe&&O("")},placeholder:"Implement workspace onboarding",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"task-desc",children:"Description"}),e.jsx(Ts,{id:"task-desc",value:I,onChange:u=>w(u.target.value),placeholder:"Add enough context for the assignee to start.",className:"min-h-24"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Project"}),e.jsxs(fe,{value:p,onValueChange:N,children:[e.jsx(he,{children:e.jsx(me,{placeholder:"Select project"})}),e.jsx(xe,{children:i.map(u=>e.jsx(Y,{value:u.id,children:u.name},u.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Priority"}),e.jsxs(fe,{value:be,onValueChange:Ae,children:[e.jsx(he,{children:e.jsx(me,{})}),e.jsxs(xe,{children:[e.jsx(Y,{value:"0",children:"Normal"}),e.jsx(Y,{value:"5",children:"High"}),e.jsx(Y,{value:"10",children:"Urgent"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Assignee role"}),e.jsxs(fe,{value:E,onValueChange:g,children:[e.jsx(he,{children:e.jsx(me,{placeholder:"Leave unassigned"})}),e.jsxs(xe,{children:[e.jsx(Y,{value:"__none__",children:"Leave unassigned"}),c.map(u=>e.jsx(Y,{value:u.id,children:u.name},u.id))]})]})]}),e.jsxs(ss,{children:[e.jsx(H,{type:"button",variant:"secondary",onClick:()=>_(!1),children:"Cancel"}),e.jsx(H,{type:"submit",disabled:dt,children:dt?"Creating...":"Create Task"})]})]})]})}),e.jsx(Fr,{taskId:Es,onClose:()=>Pe(null)})]})}function ce({active:t,onClick:n,children:s}){return e.jsx("button",{onClick:n,className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-medium border cursor-pointer transition-colors ${t?"border-emerald-500/60 text-emerald-700 bg-emerald-50":"border-[hsl(var(--border))] text-[hsl(var(--muted-foreground))] bg-white hover:border-[hsl(var(--muted-foreground))]"}`,children:s})}function Lr({tasks:t,onTaskClick:n}){return t.length===0?e.jsx("div",{className:"p-8 text-center text-[hsl(var(--muted-foreground))] text-sm",children:"No tasks found"}):e.jsx("div",{className:"overflow-auto h-full",children:e.jsxs(ot,{children:[e.jsx(it,{children:e.jsxs(re,{children:[e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Task"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Project"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Status"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Blocked"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Priority"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Role"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Agent"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Source"})]})}),e.jsx(lt,{children:t.map(s=>e.jsxs(re,{className:"cursor-pointer hover:bg-[hsl(var(--muted))]",onClick:()=>n(s.id),children:[e.jsx(F,{className:"font-medium text-[13px]",children:s.title}),e.jsx(F,{className:"text-[hsl(var(--muted-foreground))] text-[13px]",children:s.project_name||"-"}),e.jsx(F,{children:e.jsxs(It,{variant:"outline",className:ks(s.status),children:[e.jsx("span",{"aria-hidden":"true",children:Ds(s.status)}),s.status]})}),e.jsx(F,{className:"text-[13px]",children:s.status==="blocked"?e.jsxs("span",{className:"inline-flex items-start gap-1 text-[hsl(var(--destructive))]",children:[e.jsx(pn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"line-clamp-1",children:Mr(s)})]}):e.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:"-"})}),e.jsxs(F,{className:"font-mono text-[12px] text-[hsl(var(--muted-foreground))]",children:["P",s.priority]}),e.jsx(F,{className:"text-[13px] text-[hsl(var(--muted-foreground))]",children:s.assignee_role_id||"-"}),e.jsx(F,{className:"text-[13px] text-[hsl(var(--muted-foreground))]",children:s.assignee_agent_id||"-"}),e.jsx(F,{children:s.created_by==="scheduled_task"?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-purple-50 text-purple-600 font-mono text-[10px] font-medium",children:[e.jsx(et,{className:"w-3 h-3"}),"scheduled"]}):e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))] font-mono text-[10px] font-medium",children:"manual"})})]},s.id))})]})})}function Br({schedules:t,projects:n,roles:s,stats:r,editingId:o,title:i,description:l,projectId:c,roleId:f,schedType:h,cronExpr:m,runAt:v,saving:S,error:C,canSave:T,onTitleChange:b,onDescriptionChange:y,onProjectChange:d,onRoleChange:x,onTypeChange:j,onCronChange:_,onRunAtChange:D,onSubmit:A,onEdit:I,onToggle:w,onDelete:p,onRunDue:N,onCancel:E}){return e.jsxs("div",{className:"overflow-auto h-full p-6 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(Ce,{label:"Active Schedules",value:r.active}),e.jsx(Ce,{label:"Cron (Recurring)",value:r.cron}),e.jsx(Ce,{label:"One-time",value:r.once}),e.jsx(Ce,{label:"Fired Today",value:r.today})]}),C&&e.jsx(tt,{variant:"destructive",children:e.jsx(st,{children:C})}),e.jsxs(Ye,{children:[e.jsx(an,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(on,{className:"text-sm font-semibold",children:o?"Edit Schedule":"New Schedule"}),e.jsxs("div",{className:"flex gap-2",children:[o&&e.jsx(H,{variant:"ghost",size:"sm",onClick:E,children:"Cancel"}),e.jsx(H,{variant:"outline",size:"sm",onClick:N,children:"Run Due Now"})]})]})}),e.jsx(At,{children:e.jsxs("form",{onSubmit:A,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3",children:[e.jsx(pe,{value:i,onChange:g=>b(g.target.value),placeholder:"Task title"}),e.jsxs(fe,{value:c,onValueChange:d,children:[e.jsx(he,{children:e.jsx(me,{placeholder:"Project"})}),e.jsx(xe,{children:n.map(g=>e.jsx(Y,{value:g.id,children:g.name},g.id))})]}),e.jsxs(fe,{value:f||"__none__",onValueChange:g=>x(g==="__none__"?"":g),children:[e.jsx(he,{children:e.jsx(me,{placeholder:"Unassigned"})}),e.jsxs(xe,{children:[e.jsx(Y,{value:"__none__",children:"Unassigned"}),s.map(g=>e.jsx(Y,{value:g.id,children:g.name},g.id))]})]}),e.jsx(pr,{value:h,onValueChange:g=>j(g),children:e.jsxs(Cs,{className:"w-full",children:[e.jsx(Ke,{value:"cron",className:"flex-1",children:"Cron"}),e.jsx(Ke,{value:"once",className:"flex-1",children:"One-time"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3 items-end",children:[h==="cron"?e.jsxs("div",{className:"md:col-span-3 space-y-1",children:[e.jsx(pe,{value:m,onChange:g=>_(g.target.value),placeholder:"0 9 * * 1",className:"font-mono"}),e.jsx("p",{className:"text-[11px] text-[hsl(var(--muted-foreground))]",children:"Format: minute hour day month weekday"})]}):e.jsx("div",{className:"md:col-span-3",children:e.jsx(pe,{type:"datetime-local",value:v,onChange:g=>D(g.target.value)})}),e.jsx(H,{disabled:!T||S,type:"submit",className:"w-full",children:S?"Saving...":o?"Save":"Create"})]})]})})]}),e.jsx(Ye,{children:e.jsxs(ot,{children:[e.jsx(it,{children:e.jsxs(re,{children:[e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Task"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Schedule"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Next Fire"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Role"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Last Fired"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider",children:"Status"}),e.jsx(M,{className:"font-mono text-[11px] uppercase tracking-wider text-right",children:"Actions"})]})}),e.jsxs(lt,{children:[t.map(g=>e.jsxs(re,{children:[e.jsxs(F,{children:[e.jsx("div",{className:"font-medium text-[13px]",children:g.title}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--muted-foreground))]",children:g.project_name||g.project_id})]}),e.jsx(F,{children:g.schedule_type==="cron"?e.jsx("code",{className:"font-mono text-[11px] bg-[hsl(var(--muted))] px-1.5 py-0.5 rounded",children:g.cron_expr}):e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full bg-purple-50 text-purple-600 font-mono text-[10px] font-medium",children:"one-time"})}),e.jsx(F,{className:"text-[12px] text-[hsl(var(--muted-foreground))]",children:Dt(g.next_fire_at)}),e.jsx(F,{className:"text-[12px] text-[hsl(var(--muted-foreground))]",children:g.resolved_role_name||g.assignee_role_name||"-"}),e.jsx(F,{className:"text-[12px] text-[hsl(var(--muted-foreground))]",children:Dt(g.last_fired_at)}),e.jsx(F,{children:e.jsx(Gr,{enabled:!!g.enabled,onToggle:()=>w(g)})}),e.jsx(F,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>I(g),className:"h-7 w-7 p-0",children:e.jsx(wn,{className:"w-3.5 h-3.5"})}),e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"h-7 w-7 p-0 text-[hsl(var(--destructive))] hover:text-[hsl(var(--destructive))]",children:e.jsx(fn,{className:"w-3.5 h-3.5"})})]})})]},g.id)),t.length===0&&e.jsx(re,{children:e.jsx(F,{colSpan:7,className:"text-center text-[hsl(var(--muted-foreground))] py-8",children:"No scheduled tasks yet."})})]})]})})]})}function Gr({enabled:t,onToggle:n}){return e.jsx("button",{onClick:n,className:`relative inline-flex h-[18px] w-[34px] items-center rounded-full transition-colors cursor-pointer border-none ${t?"bg-emerald-500":"bg-[hsl(var(--muted))]"}`,children:e.jsx("span",{className:`inline-block h-[14px] w-[14px] rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-[17px]":"translate-x-[2px]"}`})})}function Ce({label:t,value:n}){return e.jsx(Ye,{children:e.jsxs(At,{className:"p-4",children:[e.jsx("div",{className:"font-mono text-[11px] uppercase tracking-wider text-[hsl(var(--muted-foreground))] mb-1",children:t}),e.jsx("div",{className:"font-mono text-2xl font-semibold tabular-nums",children:n})]})})}export{qr as default};
@@ -0,0 +1,6 @@
1
+ import{q as t}from"./index-C7kx39S9.js";/**
2
+ * @license lucide-react v1.16.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const a=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],o=t("activity",a);export{o as A};
@@ -0,0 +1 @@
1
+ function f(n,s){for(var i=0;i<s.length;i++){const t=s[i];if(typeof t!="string"&&!Array.isArray(t)){for(const e in t)if(e!=="default"&&!(e in n)){const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var a={exports:{}},d;function g(){return d||(d=1,(function(n,s){(function(i,t){n.exports=t()})(self,(()=>(()=>{var i={};return(()=>{var t=i;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const r=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,r=e._renderService.dimensions;if(r.css.cell.width===0||r.css.cell.height===0)return;const p=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,l=window.getComputedStyle(this._terminal.element.parentElement),c=parseInt(l.getPropertyValue("height")),h=Math.max(0,parseInt(l.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),u=c-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),m=h-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-p;return{cols:Math.max(2,Math.floor(m/r.css.cell.width)),rows:Math.max(1,Math.floor(u/r.css.cell.height))}}}})(),i})()))})(a)),a.exports}var _=g();const y=f({__proto__:null},[_]);export{y as a};
@@ -0,0 +1,6 @@
1
+ import{q as o}from"./index-C7kx39S9.js";/**
2
+ * @license lucide-react v1.16.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const r=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],a=o("arrow-right",r);export{a as A};
@@ -0,0 +1 @@
1
+ import{z as o,v as d,k as y,R,m as S,j as E}from"./index-C7kx39S9.js";const V=o.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:y("rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] shadow-sm",e),...t}));V.displayName="Card";const _=o.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:y("flex flex-col space-y-1.5 p-6",e),...t}));_.displayName="CardHeader";const w=o.forwardRef(({className:e,...t},r)=>d.jsx("h3",{ref:r,className:y("text-2xl font-semibold leading-none tracking-tight",e),...t}));w.displayName="CardTitle";const O=o.forwardRef(({className:e,...t},r)=>d.jsx("p",{ref:r,className:y("text-sm text-[hsl(var(--muted-foreground))]",e),...t}));O.displayName="CardDescription";const P=o.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:y("p-6 pt-0",e),...t}));P.displayName="CardContent";const A=o.forwardRef(({className:e,...t},r)=>d.jsx("div",{ref:r,className:y("flex items-center p-6 pt-0",e),...t}));A.displayName="CardFooter";var T=Symbol.for("react.lazy"),p=R[" use ".trim().toString()];function $(e){return typeof e=="object"&&e!==null&&"then"in e}function C(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===T&&"_payload"in e&&$(e._payload)}function k(e){const t=W(e),r=o.forwardRef((a,n)=>{let{children:s,...c}=a;C(s)&&typeof p=="function"&&(s=p(s._payload));const i=o.Children.toArray(s),v=i.find(I);if(v){const l=v.props.children,u=i.map(f=>f===v?o.Children.count(l)>1?o.Children.only(null):o.isValidElement(l)?l.props.children:null:f);return d.jsx(t,{...c,ref:n,children:o.isValidElement(l)?o.cloneElement(l,void 0,u):null})}return d.jsx(t,{...c,ref:n,children:s})});return r.displayName=`${e}.Slot`,r}var Y=k("Slot");function W(e){const t=o.forwardRef((r,a)=>{let{children:n,...s}=r;if(C(n)&&typeof p=="function"&&(n=p(n._payload)),o.isValidElement(n)){const c=B(n),i=L(s,n.props);return n.type!==o.Fragment&&(i.ref=a?S(a,c):c),o.cloneElement(n,i)}return o.Children.count(n)>1?o.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var D=Symbol("radix.slottable");function I(e){return o.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===D}function L(e,t){const r={...t};for(const a in t){const n=e[a],s=t[a];/^on[A-Z]/.test(a)?n&&s?r[a]=(...i)=>{const v=s(...i);return n(...i),v}:n&&(r[a]=n):a==="style"?r[a]={...n,...s}:a==="className"&&(r[a]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}function B(e){var a,n;let t=(a=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}const b=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,h=E,F=(e,t)=>r=>{var a;if((t==null?void 0:t.variants)==null)return h(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:n,defaultVariants:s}=t,c=Object.keys(n).map(l=>{const u=r==null?void 0:r[l],f=s==null?void 0:s[l];if(u===null)return null;const m=b(u)||b(f);return n[l][m]}),i=r&&Object.entries(r).reduce((l,u)=>{let[f,m]=u;return m===void 0||(l[f]=m),l},{}),v=t==null||(a=t.compoundVariants)===null||a===void 0?void 0:a.reduce((l,u)=>{let{class:f,className:m,...N}=u;return Object.entries(N).every(j=>{let[g,x]=j;return Array.isArray(x)?x.includes({...s,...i}[g]):{...s,...i}[g]===x})?[...l,f,m]:l},[]);return h(e,c,v,r==null?void 0:r.class,r==null?void 0:r.className)},H=F("inline-flex items-center rounded-full border border-[hsl(var(--border))] px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))] focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:bg-[hsl(var(--primary))]/80",secondary:"border-transparent bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] hover:bg-[hsl(var(--secondary))]/80",destructive:"border-transparent bg-[hsl(var(--destructive))] text-[hsl(var(--destructive-foreground))] hover:bg-[hsl(var(--destructive))]/80",outline:"text-[hsl(var(--foreground))]"}},defaultVariants:{variant:"default"}});function Z({className:e,variant:t,...r}){return d.jsx("div",{className:y(H({variant:t}),e),...r})}export{Z as B,V as C,Y as S,P as a,_ as b,w as c,k as d,F as e};
@@ -0,0 +1,6 @@
1
+ import{q as c}from"./index-C7kx39S9.js";/**
2
+ * @license lucide-react v1.16.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],r=c("circle-check",e);export{r as C};
@@ -0,0 +1,6 @@
1
+ import{q as c}from"./index-C7kx39S9.js";/**
2
+ * @license lucide-react v1.16.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const o=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],r=c("clock",o);export{r as C};
@@ -0,0 +1,11 @@
1
+ import{z as u,W as T}from"./index-C7kx39S9.js";function ie(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function be(e){if(Array.isArray(e))return e}function ye(e,t,r){return(t=Ee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function we(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,s,p=[],g=!0,v=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(g=(n=i.call(r)).done)&&(p.push(n.value),p.length!==t);g=!0);}catch(P){v=!0,o=P}finally{try{if(!g&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(v)throw o}}return p}}function Oe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ue(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ae(Object(r),!0).forEach(function(n){ye(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function je(e,t){if(e==null)return{};var r,n,o=Me(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Me(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Pe(e,t){return be(e)||we(e,t)||Ie(e,t)||Oe()}function Se(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ee(e){var t=Se(e,"string");return typeof t=="symbol"?t:t+""}function Ie(e,t){if(e){if(typeof e=="string")return ie(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ie(e,t):void 0}}function Re(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ce(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function le(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ce(Object(r),!0).forEach(function(n){Re(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ce(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ce(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,i){return i(o)},n)}}function N(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var s=arguments.length,p=new Array(s),g=0;g<s;g++)p[g]=arguments[g];return t.apply(r,[].concat(o,p))}}}function K(e){return{}.toString.call(e).includes("Object")}function Le(e){return!Object.keys(e).length}function U(e){return typeof e=="function"}function Ae(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Te(e,t){return K(t)||E("changeType"),Object.keys(t).some(function(r){return!Ae(e,r)})&&E("changeField"),t}function $e(e){U(e)||E("selectorType")}function De(e){U(e)||K(e)||E("handlerType"),K(e)&&Object.values(e).some(function(t){return!U(t)})&&E("handlersType")}function Ve(e){e||E("initialIsRequired"),K(e)||E("initialType"),Le(e)&&E("initialContent")}function xe(e,t){throw new Error(e[t]||e.default)}var ze={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},E=N(xe)(ze),_={changes:Te,selector:$e,handler:De,initial:Ve};function Ne(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_.initial(e),_.handler(t);var r={current:e},n=N(Fe)(r,t),o=N(Ue)(r),i=N(_.changes)(e),s=N(qe)(r);function p(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(P){return P};return _.selector(v),v(r.current)}function g(v){Ce(n,o,i,s)(v)}return[p,g]}function qe(e,t){return U(t)?t(e.current):t}function Ue(e,t){return e.current=le(le({},e.current),t),t}function Fe(e,t,r){return U(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var We={create:Ne},He={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function _e(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var s=arguments.length,p=new Array(s),g=0;g<s;g++)p[g]=arguments[g];return t.apply(r,[].concat(o,p))}}}function Be(e){return{}.toString.call(e).includes("Object")}function Ke(e){return e||se("configIsRequired"),Be(e)||se("configType"),e.urls?(Ge(),{paths:{vs:e.urls.monacoBase}}):e}function Ge(){console.warn(fe.deprecation)}function Ye(e,t){throw new Error(e[t]||e.default)}var fe={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
3
+ You are using deprecated way of configuration.
4
+
5
+ Instead of using
6
+ monaco.config({ urls: { monacoBase: '...' } })
7
+ use
8
+ monaco.config({ paths: { vs: '...' } })
9
+
10
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
11
+ `},se=_e(Ye)(fe),Je={config:Ke},Qe=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,s){return s(i)},o)}};function de(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],de(e[r],t[r]))}),ue(ue({},e),t)}var Xe={type:"cancelation",msg:"operation is manually canceled"};function te(e){var t=!1,r=new Promise(function(n,o){e.then(function(i){return t?o(Xe):n(i)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var Ze=["monaco"],ke=We.create({config:He,isInitialized:!1,resolve:null,reject:null,monaco:null}),pe=Pe(ke,2),F=pe[0],Y=pe[1];function et(e){var t=Je.config(e),r=t.monaco,n=je(t,Ze);Y(function(o){return{config:de(o.config,n),monaco:r}})}function tt(){var e=F(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(Y({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),te(re);if(window.monaco&&window.monaco.editor)return ge(window.monaco),e.resolve(window.monaco),te(re);Qe(rt,ot)(it)}return te(re)}function rt(e){return document.body.appendChild(e)}function nt(e){var t=document.createElement("script");return e&&(t.src=e),t}function ot(e){var t=F(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=nt("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function it(){var e=F(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var n=r.m||r;ge(n),e.resolve(n)},function(r){e.reject(r)})}function ge(e){F().monaco||Y({monaco:e})}function at(){return F(function(e){var t=e.monaco;return t})}var re=new Promise(function(e,t){return Y({resolve:e,reject:t})}),G={config:et,init:tt,__getMonacoInstance:at},ut={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ne=ut,ct={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},lt=ct;function st({children:e}){return T.createElement("div",{style:lt.container},e)}var ft=st,dt=ft;function pt({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:s}){return T.createElement("section",{style:{...ne.wrapper,width:e,height:t},...s},!r&&T.createElement(dt,null,n),T.createElement("div",{ref:o,style:{...ne.fullWidth,...!r&&ne.hide},className:i}))}var gt=pt,he=u.memo(gt);function ht(e){u.useEffect(e,[])}var oe=ht;function vt(e,t,r=!0){let n=u.useRef(!0);u.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var j=vt;function q(){}function A(e,t,r,n){return mt(e,n)||bt(e,t,r,n)}function mt(e,t){return e.editor.getModel(ve(e,t))}function bt(e,t,r,n){return e.editor.createModel(t,r,n?ve(e,n):void 0)}function ve(e,t){return e.Uri.parse(t)}function yt({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:s,keepCurrentOriginalModel:p=!1,keepCurrentModifiedModel:g=!1,theme:v="light",loading:P="Loading...",options:M={},height:J="100%",width:Q="100%",className:X,wrapperProps:Z={},beforeMount:k=q,onMount:ee=q}){let[w,$]=u.useState(!1),[I,m]=u.useState(!0),b=u.useRef(null),h=u.useRef(null),D=u.useRef(null),y=u.useRef(ee),l=u.useRef(k),R=u.useRef(!1);oe(()=>{let a=G.init();return a.then(f=>(h.current=f)&&m(!1)).catch(f=>(f==null?void 0:f.type)!=="cancelation"&&console.error("Monaco initialization: error:",f)),()=>b.current?V():a.cancel()}),j(()=>{if(b.current&&h.current){let a=b.current.getOriginalEditor(),f=A(h.current,e||"",n||r||"text",i||"");f!==a.getModel()&&a.setModel(f)}},[i],w),j(()=>{if(b.current&&h.current){let a=b.current.getModifiedEditor(),f=A(h.current,t||"",o||r||"text",s||"");f!==a.getModel()&&a.setModel(f)}},[s],w),j(()=>{let a=b.current.getModifiedEditor();a.getOption(h.current.editor.EditorOption.readOnly)?a.setValue(t||""):t!==a.getValue()&&(a.executeEdits("",[{range:a.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),a.pushUndoStop())},[t],w),j(()=>{var a,f;(f=(a=b.current)==null?void 0:a.getModel())==null||f.original.setValue(e||"")},[e],w),j(()=>{let{original:a,modified:f}=b.current.getModel();h.current.editor.setModelLanguage(a,n||r||"text"),h.current.editor.setModelLanguage(f,o||r||"text")},[r,n,o],w),j(()=>{var a;(a=h.current)==null||a.editor.setTheme(v)},[v],w),j(()=>{var a;(a=b.current)==null||a.updateOptions(M)},[M],w);let W=u.useCallback(()=>{var S;if(!h.current)return;l.current(h.current);let a=A(h.current,e||"",n||r||"text",i||""),f=A(h.current,t||"",o||r||"text",s||"");(S=b.current)==null||S.setModel({original:a,modified:f})},[r,t,o,e,n,i,s]),H=u.useCallback(()=>{var a;!R.current&&D.current&&(b.current=h.current.editor.createDiffEditor(D.current,{automaticLayout:!0,...M}),W(),(a=h.current)==null||a.editor.setTheme(v),$(!0),R.current=!0)},[M,v,W]);u.useEffect(()=>{w&&y.current(b.current,h.current)},[w]),u.useEffect(()=>{!I&&!w&&H()},[I,w,H]);function V(){var f,S,C,x;let a=(f=b.current)==null?void 0:f.getModel();p||((S=a==null?void 0:a.original)==null||S.dispose()),g||((C=a==null?void 0:a.modified)==null||C.dispose()),(x=b.current)==null||x.dispose()}return T.createElement(he,{width:Q,height:J,isEditorReady:w,loading:P,_ref:D,className:X,wrapperProps:Z})}var wt=yt,Rt=u.memo(wt);function Ot(){let[e,t]=u.useState(G.__getMonacoInstance());return oe(()=>{let r;return e||(r=G.init(),r.then(n=>{t(n)})),()=>r==null?void 0:r.cancel()}),e}var Ct=Ot;function jt(e){let t=u.useRef();return u.useEffect(()=>{t.current=e},[e]),t.current}var Mt=jt,B=new Map;function Pt({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:i,theme:s="light",line:p,loading:g="Loading...",options:v={},overrideServices:P={},saveViewState:M=!0,keepCurrentModel:J=!1,width:Q="100%",height:X="100%",className:Z,wrapperProps:k={},beforeMount:ee=q,onMount:w=q,onChange:$,onValidate:I=q}){let[m,b]=u.useState(!1),[h,D]=u.useState(!0),y=u.useRef(null),l=u.useRef(null),R=u.useRef(null),W=u.useRef(w),H=u.useRef(ee),V=u.useRef(),a=u.useRef(n),f=Mt(i),S=u.useRef(!1),C=u.useRef(!1);oe(()=>{let c=G.init();return c.then(d=>(y.current=d)&&D(!1)).catch(d=>(d==null?void 0:d.type)!=="cancelation"&&console.error("Monaco initialization: error:",d)),()=>l.current?me():c.cancel()}),j(()=>{var d,O,z,L;let c=A(y.current,e||n||"",t||o||"",i||r||"");c!==((d=l.current)==null?void 0:d.getModel())&&(M&&B.set(f,(O=l.current)==null?void 0:O.saveViewState()),(z=l.current)==null||z.setModel(c),M&&((L=l.current)==null||L.restoreViewState(B.get(i))))},[i],m),j(()=>{var c;(c=l.current)==null||c.updateOptions(v)},[v],m),j(()=>{!l.current||n===void 0||(l.current.getOption(y.current.editor.EditorOption.readOnly)?l.current.setValue(n):n!==l.current.getValue()&&(C.current=!0,l.current.executeEdits("",[{range:l.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),l.current.pushUndoStop(),C.current=!1))},[n],m),j(()=>{var d,O;let c=(d=l.current)==null?void 0:d.getModel();c&&o&&((O=y.current)==null||O.editor.setModelLanguage(c,o))},[o],m),j(()=>{var c;p!==void 0&&((c=l.current)==null||c.revealLine(p))},[p],m),j(()=>{var c;(c=y.current)==null||c.editor.setTheme(s)},[s],m);let x=u.useCallback(()=>{var c;if(!(!R.current||!y.current)&&!S.current){H.current(y.current);let d=i||r,O=A(y.current,n||e||"",t||o||"",d||"");l.current=(c=y.current)==null?void 0:c.editor.create(R.current,{model:O,automaticLayout:!0,...v},P),M&&l.current.restoreViewState(B.get(d)),y.current.editor.setTheme(s),p!==void 0&&l.current.revealLine(p),b(!0),S.current=!0}},[e,t,r,n,o,i,v,P,M,s,p]);u.useEffect(()=>{m&&W.current(l.current,y.current)},[m]),u.useEffect(()=>{!h&&!m&&x()},[h,m,x]),a.current=n,u.useEffect(()=>{var c,d;m&&$&&((c=V.current)==null||c.dispose(),V.current=(d=l.current)==null?void 0:d.onDidChangeModelContent(O=>{C.current||$(l.current.getValue(),O)}))},[m,$]),u.useEffect(()=>{if(m){let c=y.current.editor.onDidChangeMarkers(d=>{var z;let O=(z=l.current.getModel())==null?void 0:z.uri;if(O&&d.find(L=>L.path===O.path)){let L=y.current.editor.getModelMarkers({resource:O});I==null||I(L)}});return()=>{c==null||c.dispose()}}return()=>{}},[m,I]);function me(){var c,d;(c=V.current)==null||c.dispose(),J?M&&B.set(i,l.current.saveViewState()):(d=l.current.getModel())==null||d.dispose(),l.current.dispose()}return T.createElement(he,{width:Q,height:X,isEditorReady:m,loading:g,_ref:R,className:Z,wrapperProps:k})}var St=Pt,Et=u.memo(St),Lt=Et;export{Rt as DiffEditor,Et as Editor,Lt as default,G as loader,Ct as useMonaco};