@alook/app 0.0.133 → 0.0.135

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 (97) hide show
  1. package/bundled/email-worker/index.js +17 -9
  2. package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
  3. package/bundled/web/.open-next/assets/BUILD_ID +1 -1
  4. package/bundled/web/.open-next/assets/_next/static/chunks/0vq-9me5zdpwe.js +1 -0
  5. package/bundled/web/.open-next/assets/_next/static/chunks/{3issuq6aouf1q.js → 1soxnit9hjz-0.js} +1 -1
  6. package/bundled/web/.open-next/assets/_next/static/chunks/{1iux65sajp19w.js → 25mf0rxvnm36s.js} +1 -1
  7. package/bundled/web/.open-next/assets/_next/static/chunks/{1z4a4-hyguhc1.js → 29vahszwp_yzk.js} +3 -3
  8. package/bundled/web/.open-next/assets/_next/static/chunks/2nzhi1-lt9r-h.js +1 -0
  9. package/bundled/web/.open-next/assets/_next/static/chunks/2owkk0a9xurql.js +1 -0
  10. package/bundled/web/.open-next/assets/_next/static/chunks/{27vz1_55bn5h_.js → 2vvce1uli_yf3.js} +1 -1
  11. package/bundled/web/.open-next/assets/_next/static/chunks/3ad50t_oqhpk_.js +1 -0
  12. package/bundled/web/.open-next/assets/_next/static/chunks/{2yh4j7b0i4eye.js → 3g9-r7m865tot.js} +2 -2
  13. package/bundled/web/.open-next/cache/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/_global-error.cache +1 -1
  14. package/bundled/web/.open-next/cache/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/_not-found.cache +1 -1
  15. package/bundled/web/.open-next/cache/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/device.cache +1 -1
  16. package/bundled/web/.open-next/cache/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/privacy.cache +1 -1
  17. package/bundled/web/.open-next/cache/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/sitemap.xml.cache +1 -1
  18. package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
  19. package/bundled/web/.open-next/cloudflare/init.js +1 -1
  20. package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
  21. package/bundled/web/.open-next/middleware/handler.mjs +6 -6
  22. package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
  23. package/bundled/web/.open-next/server-functions/default/src/web/.next/app-path-routes-manifest.json +1 -0
  24. package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
  25. package/bundled/web/.open-next/server-functions/default/src/web/.next/prerender-manifest.json +3 -3
  26. package/bundled/web/.open-next/server-functions/default/src/web/.next/required-server-files.json +3 -1
  27. package/bundled/web/.open-next/server-functions/default/src/web/.next/routes-manifest.json +8 -0
  28. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
  29. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/page_client-reference-manifest.js +1 -1
  30. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/activity/page_client-reference-manifest.js +1 -1
  31. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page_client-reference-manifest.js +1 -1
  32. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/page_client-reference-manifest.js +1 -1
  33. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/email/page_client-reference-manifest.js +1 -1
  34. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/files/page_client-reference-manifest.js +1 -1
  35. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/meetings/page_client-reference-manifest.js +1 -1
  36. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/page_client-reference-manifest.js +1 -1
  37. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/new/page_client-reference-manifest.js +1 -1
  38. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
  39. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
  40. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/flags/page_client-reference-manifest.js +1 -1
  41. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/help/email-setup/page_client-reference-manifest.js +1 -1
  42. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
  43. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
  44. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/page_client-reference-manifest.js +1 -1
  45. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
  46. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/page_client-reference-manifest.js +1 -1
  47. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/traces/[traceId]/page_client-reference-manifest.js +1 -1
  48. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/traces/page_client-reference-manifest.js +1 -1
  49. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
  50. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/agents/recruit/route.js +1 -1
  51. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/email/[id]/trust/route.js +15 -0
  52. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/email/[id]/trust/route_client-reference-manifest.js +3 -0
  53. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/email/notify/route.js +2 -2
  54. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/email/send/route.js +1 -1
  55. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page/react-loadable-manifest.json +1 -1
  56. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page_client-reference-manifest.js +1 -1
  57. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app-paths-manifest.json +1 -0
  58. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__12fz1lr._.js +1 -1
  59. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[turbopack]_runtime.js +7 -5
  60. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/{_1pt-oj4._.js → _0eu_mts._.js} +2 -2
  61. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/{_0c6q0et._.js → _0kca2k0._.js} +2 -2
  62. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0r2vuif._.js +3 -0
  63. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0v95a0y._.js +14 -14
  64. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_139j3zh._.js +14 -14
  65. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_1nfaney._.js +14 -14
  66. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_1p90k-4._.js +3 -0
  67. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/src_web__next-internal_server_app_api_email_[id]_trust_route_actions_0rx9apz.js +3 -0
  68. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/1b4r_lucide-react_dist_esm_icons_0ci7b7p._.js +3 -0
  69. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[turbopack]_runtime.js +7 -5
  70. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0p54okk._.js +13 -13
  71. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0qgcnj5._.js +1 -1
  72. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0t5ob43._.js +3 -0
  73. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_agents_[id]_email_page_tsx_0gv3qni._.js +1 -1
  74. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_lib_api_ts_1ffelwp._.js +1 -1
  75. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
  76. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +5 -5
  77. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.js +1 -1
  78. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.json +1 -1
  79. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +99 -97
  80. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +181 -113
  81. package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +6 -6
  82. package/bundled/web/wrangler.toml +1 -1
  83. package/bundled/ws-do/index.js +17 -9
  84. package/dist/cli/index.js +1 -1
  85. package/dist/cli/session-runner.js +1 -1
  86. package/package.json +1 -1
  87. package/bundled/web/.open-next/assets/_next/static/chunks/0pd5shecdv7w3.js +0 -1
  88. package/bundled/web/.open-next/assets/_next/static/chunks/1ox78wqeeqant.js +0 -1
  89. package/bundled/web/.open-next/assets/_next/static/chunks/38j_4uwfj09mb.js +0 -1
  90. package/bundled/web/.open-next/assets/_next/static/chunks/3bfk44a51kg4q.js +0 -1
  91. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0qy7lt2._.js +0 -3
  92. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/1b4r_lucide-react_dist_esm_icons_0u7bkx8._.js +0 -3
  93. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_agents_[id]_meetings_page_tsx_0ciapb3._.js +0 -3
  94. /package/bundled/web/.open-next/assets/_next/static/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/_buildManifest.js +0 -0
  95. /package/bundled/web/.open-next/assets/_next/static/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/_clientMiddlewareManifest.js +0 -0
  96. /package/bundled/web/.open-next/assets/_next/static/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/_ssgManifest.js +0 -0
  97. /package/bundled/web/.open-next/cache/{UUtXyb9u1pubazU2jTktS → sGrtuJLQm2artu6oSgWPT}/robots.txt.cache +0 -0
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,129396,e=>{"use strict";var t=e.i(653772),s=e.i(511043),n=e.i(126942),i=e.i(500324),a=e.i(355578),l=e.i(222862);e.i(954194);var r=e.i(439769),o=e.i(186339),d=e.i(393153),c=e.i(720115),u=e.i(941693),m=e.i(37476),x=e.i(16770),h=e.i(928059),p=e.i(729432),f=p.Extension.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>!!this.options.alignments.includes(e)&&this.options.types.map(s=>t.updateAttributes(s,{textAlign:e})).some(e=>e),unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(e=>e),toggleTextAlign:e=>({editor:t,commands:s})=>!!this.options.alignments.includes(e)&&(t.isActive({textAlign:e})?s.unsetTextAlign():s.setTextAlign(e))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),g=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,j=p.Node.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",(0,p.mergeAttributes)(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode("image",{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{var t,s,n,i,a,l;let r=null!=(s=null==(t=e.attrs)?void 0:t.src)?s:"",o=null!=(i=null==(n=e.attrs)?void 0:n.alt)?i:"",d=null!=(l=null==(a=e.attrs)?void 0:a.title)?l:"";return d?`![${o}](${r} "${d}")`:`![${o}](${r})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:e,minWidth:t,minHeight:s,alwaysPreserveAspectRatio:n}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:l,editor:r})=>{let o=document.createElement("img");o.draggable=!1;let d=(0,p.mergeAttributes)(this.options.HTMLAttributes,l);Object.entries(d).forEach(([e,t])=>{if(null!=t)switch(e){case"width":case"height":break;default:o.setAttribute(e,t)}}),null!==d.src&&(o.src=d.src);let c=new p.ResizableNodeView({element:o,editor:r,node:i,getPos:a,onResize:(e,t)=>{o.style.width=`${e}px`,o.style.height=`${t}px`},onCommit:(e,t)=>{let s=a();void 0!==s&&this.editor.chain().setNodeSelection(s).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,s)=>e.type===i.type,options:{directions:e,min:{width:t,height:s},preserveAspectRatio:!0===n}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[(0,p.nodeInputRule)({find:g,type:this.type,getAttributes:e=>{let[,,t,s,n]=e;return{src:s,alt:t,title:n}}})]}}),b=e.i(613349),y=e.i(329686),v=e.i(779646),N=e.i(903477),k=e.i(419412);let w=(0,k.default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]),z=(0,k.default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]),A=(0,k.default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]),T=(0,k.default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]),C=(0,k.default)("list",[["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"}]]),M=(0,k.default)("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]),S=(0,k.default)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]),H=(0,k.default)("text-align-center",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]]),B=(0,k.default)("text-align-end",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]]),R=(0,k.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),E=(0,k.default)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),L=(0,k.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),_=(0,k.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]),$=(0,k.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);var D=e.i(573404),D=D;function I({active:e,disabled:s,onAction:n,title:i,children:a}){return(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon-sm",disabled:s,onMouseDown:e=>e.preventDefault(),onClick:n,className:(0,b.cn)("text-muted-foreground/70",e&&"bg-accent text-foreground")}),children:a}),(0,t.jsx)(y.TooltipContent,{children:i})]})}function F(){return(0,t.jsx)("div",{className:"w-px h-4 bg-border/60 mx-0.5 shrink-0"})}function P({editor:e}){let[,n]=(0,s.useReducer)(e=>e+1,0),[i,a]=(0,s.useState)(!1),[l,r]=(0,s.useState)("link"),[d,c]=(0,s.useState)(""),[u,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(""),[p,f]=(0,s.useState)(!1),g=(0,s.useRef)(null),j=(0,s.useRef)(!1);if((0,s.useEffect)(()=>{if(!e)return;let t=()=>n();return e.on("transaction",t),()=>{e.off("transaction",t)}},[e]),(0,s.useEffect)(()=>{i&&setTimeout(()=>g.current?.focus(),0)},[i]),!e)return null;let k="size-3.5",O=()=>{let t=d.trim();if(t){try{new URL(t)}catch{m("Please enter a valid URL");return}if(m(""),"link"===l)if(p){let s=x.trim()||t;e.chain().focus().insertContent({type:"text",text:s,marks:[{type:"link",attrs:{href:t}}]}).run()}else e.chain().focus().extendMarkRange("link").setLink({href:t}).run();else e.chain().focus().setImage({src:t}).run();a(!1)}};return(0,t.jsxs)("div",{className:"flex items-center gap-0.5 px-3 py-1 overflow-x-auto",children:[(0,t.jsx)(I,{title:"Bold",active:e.isActive("bold"),onAction:()=>e.chain().focus().toggleBold().run(),children:(0,t.jsx)(w,{className:k})}),(0,t.jsx)(I,{title:"Italic",active:e.isActive("italic"),onAction:()=>e.chain().focus().toggleItalic().run(),children:(0,t.jsx)(z,{className:k})}),(0,t.jsx)(I,{title:"Underline",active:e.isActive("underline"),onAction:()=>e.chain().focus().toggleUnderline().run(),children:(0,t.jsx)(A,{className:k})}),(0,t.jsx)(I,{title:"Strikethrough",active:e.isActive("strike"),onAction:()=>e.chain().focus().toggleStrike().run(),children:(0,t.jsx)(T,{className:k})}),(0,t.jsx)(F,{}),(0,t.jsx)(I,{title:"Heading 1",active:e.isActive("heading",{level:1}),onAction:()=>e.chain().focus().toggleHeading({level:1}).run(),children:(0,t.jsx)(_,{className:k})}),(0,t.jsx)(I,{title:"Heading 2",active:e.isActive("heading",{level:2}),onAction:()=>e.chain().focus().toggleHeading({level:2}).run(),children:(0,t.jsx)($,{className:k})}),(0,t.jsx)(F,{}),(0,t.jsx)(I,{title:"Bullet List",active:e.isActive("bulletList"),onAction:()=>e.chain().focus().toggleBulletList().run(),children:(0,t.jsx)(C,{className:k})}),(0,t.jsx)(I,{title:"Ordered List",active:e.isActive("orderedList"),onAction:()=>e.chain().focus().toggleOrderedList().run(),children:(0,t.jsx)(M,{className:k})}),(0,t.jsx)(F,{}),(0,t.jsx)(I,{title:"Align Left",active:e.isActive({textAlign:"left"}),onAction:()=>e.chain().focus().setTextAlign("left").run(),children:(0,t.jsx)(S,{className:k})}),(0,t.jsx)(I,{title:"Align Center",active:e.isActive({textAlign:"center"}),onAction:()=>e.chain().focus().setTextAlign("center").run(),children:(0,t.jsx)(H,{className:k})}),(0,t.jsx)(I,{title:"Align Right",active:e.isActive({textAlign:"right"}),onAction:()=>e.chain().focus().setTextAlign("right").run(),children:(0,t.jsx)(B,{className:k})}),(0,t.jsx)(F,{}),(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon-sm",onMouseDown:t=>{t.preventDefault(),j.current=e.isActive("link")},onClick:()=>{j.current?e.chain().focus().unsetLink().run():(r("link"),c(""),m(""),h(""),f(e.state.selection.empty),a(!0))},className:(0,b.cn)("text-muted-foreground/70",e.isActive("link")&&"bg-accent text-foreground")}),children:e.isActive("link")?(0,t.jsx)(E,{className:k}):(0,t.jsx)(R,{className:k})}),(0,t.jsx)(y.TooltipContent,{children:e.isActive("link")?"Remove Link":"Insert Link"})]}),(0,t.jsx)(I,{title:"Insert Image",onAction:()=>{r("image"),c(""),m(""),a(!0)},children:(0,t.jsx)(L,{className:k})}),(0,t.jsx)(F,{}),(0,t.jsx)(I,{title:"Horizontal Rule",onAction:()=>e.chain().focus().setHorizontalRule().run(),children:(0,t.jsx)(D.default,{className:k})}),(0,t.jsx)(v.Dialog,{open:i,onOpenChange:a,children:(0,t.jsxs)(v.DialogContent,{children:[(0,t.jsx)(v.DialogHeader,{children:(0,t.jsx)(v.DialogTitle,{children:"link"===l?"Insert Link":"Insert Image"})}),"link"===l&&p&&(0,t.jsx)(N.Input,{ref:g,value:x,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&O()},placeholder:"Display text"}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(N.Input,{ref:"image"!==l&&p?void 0:g,value:d,onChange:e=>{c(e.target.value),m("")},onKeyDown:e=>{"Enter"===e.key&&O()},placeholder:"link"===l?"https://example.com":"https://example.com/image.png",type:"url","aria-invalid":!!u}),u&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:u})]}),(0,t.jsx)(v.DialogFooter,{children:(0,t.jsx)(o.Button,{onClick:O,disabled:!d.trim(),children:"Insert"})})]})})]})}var O=e.i(516266),U=e.i(392277),q=e.i(692670),V=e.i(945074),K=e.i(966662),W=e.i(492451);function G({fromAddress:n,onSend:i,onDiscard:a,initialTo:l="",initialSubject:r="",initialBody:d="",initialAttachments:p=[],inReplyTo:g,references:b}){let[v,k]=(0,s.useState)(l),[w,z]=(0,s.useState)(r),[A,T]=(0,s.useState)(!1),[C,M]=(0,s.useState)(p),[S,H]=(0,s.useState)(!1),B=(0,s.useRef)(null),R=(0,c.useEditor)({immediatelyRender:!1,content:d||void 0,extensions:[u.default.configure({link:!1,underline:!1}),m.default.configure({placeholder:"Write your email..."}),x.default,h.default.configure({autolink:!0,openOnClick:!1,linkOnPaste:!0}),f.configure({types:["heading","paragraph"]}),j.configure({inline:!0,allowBase64:!0})],editorProps:{attributes:{class:"text-sm max-w-none focus:outline-none min-h-50 px-4 py-3"}}}),E=async()=>{if(v.trim()&&w.trim()&&R){T(!0);try{let e=R.getHTML();await i(v.trim(),w.trim(),e,C,g||b?{inReplyTo:g,references:b}:void 0)&&(k(""),z(""),M([]),R.commands.clearContent())}finally{T(!1)}}},L=async t=>{let s=t.target.files;if(s&&0!==s.length){H(!0);try{let{uploadEmailAttachment:t}=await e.A(302482);for(let e of Array.from(s)){if(e.size>0xa00000){O.toast.error(`${e.name} exceeds 10 MB limit`);continue}let s=new URLSearchParams(window.location.search).get("workspace_id")??"",n=await t(e,s);M(e=>[...e,n])}}catch{O.toast.error("Failed to upload attachment")}finally{H(!1),B.current&&(B.current.value="")}}};return(0,t.jsxs)("div",{className:"flex flex-col h-full w-full min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2",children:[(0,t.jsx)("h3",{className:"text-sm font-heading font-medium tracking-tight",children:"New Email"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)(o.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground h-7 px-2",onClick:a,disabled:A,children:[(0,t.jsx)(q.X,{className:"size-3 mr-1"}),"Discard"]}),(0,t.jsxs)(o.Button,{size:"sm",className:"text-xs h-7 px-3",onClick:E,disabled:A||!v.trim()||!w.trim(),children:[A?(0,t.jsx)(V.Loader2,{className:"size-3 mr-1 animate-spin"}):(0,t.jsx)(U.Send,{className:"size-3 mr-1"}),"Send"]})]})]}),(0,t.jsxs)("div",{className:"border-b border-border/30 px-4 py-2.5 space-y-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"From"}),(0,t.jsx)("span",{className:"text-muted-foreground truncate min-w-0",children:n})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"To"}),(0,t.jsx)("div",{className:"flex-1 min-w-0 -ml-1.5 rounded-md bg-muted/40",children:(0,t.jsx)(N.Input,{type:"email",value:v,onChange:e=>k(e.target.value),placeholder:"recipient@example.com",className:"h-7 text-sm border-0 bg-transparent px-1.5 shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50",disabled:A})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm min-w-0",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"Subject"}),(0,t.jsx)("div",{className:"flex-1 min-w-0 -ml-1.5 rounded-md bg-muted/40",children:(0,t.jsx)(N.Input,{value:w,onChange:e=>z(e.target.value),placeholder:"Email subject",className:"h-7 text-sm border-0 bg-transparent px-1.5 shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50",disabled:A})})]})]}),(0,t.jsxs)("div",{className:"flex items-center border-b border-border/30",children:[(0,t.jsx)(P,{editor:R}),(0,t.jsxs)("div",{className:"flex items-center gap-1 px-2 border-l border-border/30",children:[(0,t.jsx)("input",{ref:B,type:"file",multiple:!0,className:"hidden",onChange:L}),(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon-sm",disabled:S,onMouseDown:e=>e.preventDefault(),onClick:()=>B.current?.click(),className:"text-muted-foreground/70"}),children:S?(0,t.jsx)(V.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(K.Paperclip,{className:"size-3.5"})}),(0,t.jsx)(y.TooltipContent,{children:"Attach file"})]})]})]}),C.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 px-4 py-2 border-b border-border/30",children:C.map(e=>{var s;return(0,t.jsxs)("div",{className:"flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs",children:[(0,t.jsx)(W.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.filename}),(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:(s=e.size)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(1)} MB`}),(0,t.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.key,void M(e=>e.filter(e=>e.key!==t))},className:"text-muted-foreground hover:text-foreground ml-0.5 cursor-pointer",children:(0,t.jsx)(q.X,{className:"size-3"})})]},e.key)})}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto thin-scrollbar",children:(0,t.jsx)(c.EditorContent,{editor:R})})]})}var X=e.i(728886),J=e.i(967723),Q=e.i(896210),Y=e.i(46464),Z=e.i(947308),ee=e.i(813141);let et=(0,k.default)("forward",[["path",{d:"m15 17 5-5-5-5",key:"nf172w"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]),es=(0,k.default)("reply",[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]);var en=e.i(330746),ei=e.i(353155);let ea=(0,k.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var el=e.i(584761),er=e.i(205189),eo=e.i(996718),ed=e.i(888917),ec=e.i(940931);function eu(e){let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;let n=Math.floor(s/60);if(n<24)return`${n}h ago`;let i=Math.floor(n/24);return i<7?`${i}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}e.s(["default",0,function(){let e=(0,n.useParams)().id,{workspaceId:c}=(0,i.useWorkspace)(),{agents:u,subscribeWs:m}=(0,a.useAgentContext)(),x=u.find(t=>t.id===e),h=(0,eo.useIsMobile)(),[p,f]=(0,s.useState)("inbox"),[g,j]=(0,s.useState)([]),v=(0,s.useMemo)(()=>g.filter(e=>"unread"===e.status).length,[g]),[N,k]=(0,s.useState)(!0),[w,z]=(0,s.useState)(null),[A,T]=(0,s.useState)(null),[C,M]=(0,s.useState)(!1),[S,H]=(0,s.useState)(!1),[B,R]=(0,s.useState)({}),[E,L]=(0,s.useState)([]),[_,$]=(0,s.useState)(null),[D,I]=(0,s.useState)({}),[F,P]=(0,s.useState)(!1),[q,em]=(0,s.useState)(null),[ex,eh]=(0,s.useState)(!1),[ep,ef]=(0,s.useState)([]),[eg,ej]=(0,s.useState)(!1),eb=(0,s.useCallback)(e=>{f(e),j([]),z(null),T(null),H(!1)},[]),ey=x?.email_handle?(0,r.toAlookAddress)(x.email_handle):"",ev=[...ey?[{type:"alook",address:ey}]:[],...ep.map(e=>({type:"custom",address:e.email_address,accountId:e.id}))],[eN,ek]=(0,s.useState)(0),ew=ev[eN]??ev[0]??null,ez=ew?.address??"",eA=ew?.type==="custom"?ew.accountId:void 0,eT=g.find(e=>e.id===w)??null,eC=(0,s.useCallback)(async(t,s)=>{k(!0);try{let n=await (0,l.listEmails)(e,c,t,s);j(n)}catch{O.toast.error("Failed to load emails")}finally{k(!1)}},[e,c]);(0,s.useEffect)(()=>{(0,l.listEmailAccounts)(e,c).then(ef).catch(()=>{})},[e,c]),(0,s.useEffect)(()=>{eC(p,ez)},[p,ez,eC]),(0,s.useEffect)(()=>m(t=>{"email.received"===t.type&&t.agentId===e?((0,er.trackEmailReceived)({agent_id:e,mailbox_type:ew?.type==="custom"?"imap":"alook"}),eC(p,ez)):"email.sent"===t.type&&t.agentId===e&&eC(p,ez)}),[m,e,p,ez,eC,ew?.type]);let eM=async e=>{H(!1),z(e),T(null),M(!0),L([]),$(null),I({});try{let[t,s]=await Promise.all([(0,l.getEmailBody)(e,c),(0,l.getEmailThread)(e,c).catch(()=>[])]);T(t),L(s);let n=g.find(t=>t.id===e);n&&"unread"===n.status&&(0,l.updateEmailStatus)(e,c,"read").then(()=>{j(t=>t.map(t=>t.id===e?{...t,status:"read"}:t))}).catch(()=>{j(t=>t.map(t=>t.id===e?{...t,status:"unread"}:t))})}catch{T({content:"(body not available)",isHtml:!1})}finally{M(!1)}},eS=async e=>{if(_===e)return void $(null);if($(e),!D[e])try{let t=await (0,l.getEmailBody)(e,c);I(s=>({...s,[e]:t}))}catch{I(t=>({...t,[e]:{content:"(body not available)",isHtml:!1}}))}},eH=async()=>{if(q){eh(!0);try{await (0,l.deleteEmail)(q,c),j(e=>e.filter(e=>e.id!==q)),w===q&&(z(null),T(null)),O.toast.success("Email deleted")}catch{O.toast.error("Failed to delete email")}finally{eh(!1),P(!1),em(null)}}},eB=async(t,s,n,i,a)=>{try{return await (0,l.sendEmail)(e,t,s,n,c,i.length>0?i:void 0,a,eA),(0,er.trackEmailComposed)({agent_id:e,has_attachments:i.length>0}),O.toast.success("Email sent"),H(!1),eb("sent"),!0}catch{return O.toast.error("Failed to send email"),!1}},eR=e=>`<br/><br/><div style="border-left: 2px solid #ccc; padding-left: 12px; margin-left: 0; color: #666;"><p><strong>From:</strong> ${e.from_email}<br/><strong>To:</strong> ${e.to_email}<br/><strong>Date:</strong> ${new Date(e.created_at).toLocaleString()}<br/><strong>Subject:</strong> ${e.subject}</p>`+(e.html_body?e.html_body:A?.isHtml?A.content:`<pre>${A?.content??""}</pre>`)+"</div>",eE=e=>({inReplyTo:e.message_id||void 0,references:[e.references,e.message_id].filter(Boolean).join(" ").trim()||void 0}),[eL,e_]=(0,s.useState)(!1),e$=async()=>{if(ez)try{await navigator.clipboard.writeText(ez),e_(!0),setTimeout(()=>e_(!1),1500)}catch{O.toast.error("Failed to copy")}},eD=(0,t.jsxs)("div",{className:"flex h-full flex-col",children:[ev.length>0?(0,t.jsx)("div",{className:"px-3 pt-3 pb-1 relative",children:1===ev.length?(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsxs)(y.TooltipTrigger,{render:(0,t.jsx)("button",{type:"button",onClick:e$,className:"group flex items-center gap-1.5 text-left cursor-pointer w-full"}),children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ez}),eL?(0,t.jsx)(ei.Check,{className:"size-2.5 text-green-500 shrink-0"}):(0,t.jsx)(en.Copy,{className:"size-2.5 text-muted-foreground/0 group-hover:text-muted-foreground/60 shrink-0 transition-colors"})]}),(0,t.jsx)(y.TooltipContent,{children:"Click to copy"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 w-full",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>ej(!eg),className:"flex items-center gap-1 text-left cursor-pointer min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ez}),(0,t.jsx)(el.ChevronDown,{className:"size-2.5 text-muted-foreground shrink-0"})]}),(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)("button",{type:"button",onClick:e$,className:"shrink-0 p-0.5"}),children:eL?(0,t.jsx)(ei.Check,{className:"size-2.5 text-green-500"}):(0,t.jsx)(en.Copy,{className:"size-2.5 text-muted-foreground/40 hover:text-muted-foreground/80 transition-colors"})}),(0,t.jsx)(y.TooltipContent,{children:"Copy address"})]})]}),eg&&(0,t.jsx)("div",{className:"absolute left-2 right-2 top-full mt-0.5 z-10 rounded-lg border border-border bg-popover shadow-md py-1",children:ev.map((e,s)=>(0,t.jsxs)("button",{type:"button",onClick:()=>{ek(s),ej(!1)},className:(0,b.cn)("flex items-center gap-2 w-full px-2.5 py-1.5 text-left text-xs transition-colors",s===eN?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),children:[(0,t.jsx)(Q.Mail,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.address}),"custom"===e.type&&(0,t.jsx)("span",{className:"text-[9px] text-muted-foreground/60 shrink-0",children:"IMAP"})]},e.address))})]})}):(0,t.jsx)("div",{className:"px-3 pt-3 pb-1",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground/60",children:"No email configured"})}),(0,t.jsx)("div",{className:"p-2",children:(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsxs)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{size:"sm",className:"w-full justify-start text-xs h-8 gap-1.5",onClick:()=>{R({}),H(!0),z(null)},disabled:0===ev.length}),children:[(0,t.jsx)(Z.Plus,{className:"size-3.5"}),"New Email"]}),(0,t.jsx)(y.TooltipContent,{children:0===ev.length?"Configure an email in agent settings to send emails":"Compose new email"})]})}),(0,t.jsxs)("nav",{className:"flex flex-col gap-0.5 px-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>eb("inbox"),className:(0,b.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","inbox"===p?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(Y.Inbox,{className:"size-4 shrink-0"}),"Inbox","inbox"===p&&v>0&&(0,t.jsx)("span",{className:"ml-auto text-xs bg-blue-500 text-white rounded-full px-1.5 py-0.5 leading-none min-w-5 text-center",children:v})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>eb("sent"),className:(0,b.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","sent"===p?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(U.Send,{className:"size-4 shrink-0"}),"Sent"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>eb("untrust"),className:(0,b.cn)("flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm transition-colors cursor-pointer","untrust"===p?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(ea,{className:"size-4 shrink-0"}),"Untrust"]})]})]}),eI=(0,t.jsx)("div",{className:(0,b.cn)("h-full thin-scrollbar",g.length>0&&!N?"overflow-y-auto":"overflow-hidden"),children:N?(0,t.jsx)(t.Fragment,{children:Array.from({length:3}).map((e,s)=>(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-border/30",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[(0,t.jsx)(X.Skeleton,{className:"h-3.5 w-32"}),(0,t.jsx)(X.Skeleton,{className:"h-2.5 w-10"})]}),(0,t.jsx)(X.Skeleton,{className:"h-3.5 w-48 mb-1.5"}),(0,t.jsx)(X.Skeleton,{className:"h-4 w-16 rounded-full"})]},s))}):0===g.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full animate-[fade-up_400ms_ease-out_both]",children:[(0,t.jsx)(Q.Mail,{className:"size-8 text-muted-foreground mb-3"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"inbox"===p?"No emails from trusted senders":"sent"===p?"No emails sent yet":"No untrusted emails"})]}):g.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>eM(e.id),className:(0,b.cn)("w-full text-left px-4 py-3 border-b border-border/30 transition-colors duration-150 cursor-pointer",w===e.id?"bg-accent/60":"hover:bg-accent/30"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[(0,t.jsx)("p",{className:(0,b.cn)("text-sm truncate","unread"===e.status?"font-semibold":"font-medium text-muted-foreground"),children:"sent"===p?e.to_email:e.from_email}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:["sent"!==p&&(0,t.jsx)("span",{className:(0,b.cn)("text-[10px] rounded-full px-1.5 py-0.5 leading-none font-medium","unread"===e.status?"bg-blue-500/15 text-blue-600 dark:text-blue-400":"bg-muted text-muted-foreground"),children:"unread"===e.status?"unread":"read"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:eu(e.created_at)})]})]}),(0,t.jsx)("p",{className:(0,b.cn)("text-[13px] truncate","unread"===e.status?"text-foreground":"text-muted-foreground"),children:e.subject||"(no subject)"})]},e.id))}),eF=(0,t.jsx)("div",{className:"h-full overflow-auto flex flex-col min-w-0 thin-scrollbar",children:S?(0,t.jsx)(G,{fromAddress:ez,onSend:eB,onDiscard:()=>{H(!1),R({})},initialTo:B.to,initialSubject:B.subject,initialBody:B.body,initialAttachments:B.attachments,inReplyTo:B.inReplyTo,references:B.references},JSON.stringify(B)):eT?(0,t.jsxs)("div",{className:"flex flex-col h-full md:min-w-100 max-w-3xl mx-auto w-full",children:[(0,t.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-border/40 px-4 py-1.5",children:["sent"!==p&&(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-foreground",onClick:()=>{let e;return e=eT.subject.startsWith("Re:")?eT.subject:`Re: ${eT.subject}`,void(z(null),R({to:eT.from_email,subject:e,body:eR(eT),...eE(eT)}),H(!0))}}),children:(0,t.jsx)(es,{className:"size-3.5"})}),(0,t.jsx)(y.TooltipContent,{children:"Reply"})]}),(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-foreground",onClick:()=>{let e;return e=eT.subject.startsWith("Fwd:")?eT.subject:`Fwd: ${eT.subject}`,void(z(null),R({subject:e,body:eR(eT),attachments:eT.attachments??[],...eE(eT)}),H(!0))}}),children:(0,t.jsx)(et,{className:"size-3.5"})}),(0,t.jsx)(y.TooltipContent,{children:"Forward"})]}),(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/60 hover:text-destructive",onClick:()=>{em(eT.id),P(!0)}}),children:(0,t.jsx)(ee.Trash2,{className:"size-3.5"})}),(0,t.jsx)(y.TooltipContent,{children:"Delete"})]})]}),E.length>0&&(0,t.jsx)("div",{className:"border-b border-border/30",children:E.map(e=>(0,t.jsxs)("div",{className:"border-b border-border/20 last:border-b-0",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>eS(e.id),className:"w-full flex items-center gap-2 px-5 py-2.5 text-left hover:bg-accent/30 transition-colors cursor-pointer",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:_===e.id?"▾":"▸"}),(0,t.jsx)("span",{className:"text-sm font-medium truncate flex-1",children:e.from_email}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:eu(e.created_at)})]}),_===e.id&&(0,t.jsxs)("div",{className:"px-5 pb-3",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:e.subject}),D[e.id]?D[e.id].isHtml?(0,t.jsx)(ec.EmailBodyFrame,{html:D[e.id].content,className:"max-w-full text-sm"}):(0,t.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-[1.65] text-foreground",children:D[e.id].content}):(0,t.jsx)(V.Loader2,{className:"size-3 animate-spin text-muted-foreground"})]})]},e.id))}),(0,t.jsxs)("div",{className:"p-5",children:[(0,t.jsx)("h2",{className:"text-lg font-heading font-semibold tracking-tight mb-1",children:eT.subject||"(no subject)"}),(0,t.jsxs)("div",{className:"text-sm space-y-1 mb-5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"From"}),(0,t.jsx)("span",{children:eT.from_email})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"To"}),(0,t.jsx)("span",{children:eT.to_email})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16 shrink-0",children:"sent"===p?"Sent":"Received"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:new Date(eT.created_at).toLocaleString()})]})]}),C?(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(V.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}):eT.html_body?(0,t.jsx)(ec.EmailBodyFrame,{html:eT.html_body,className:"max-w-full"}):A?.isHtml?(0,t.jsx)(ec.EmailBodyFrame,{html:A.content,className:"max-w-full"}):(0,t.jsx)("div",{className:"text-sm whitespace-pre-wrap leading-[1.65] text-foreground",children:A?.content}),eT.attachments&&eT.attachments.length>0&&(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 text-xs text-muted-foreground",children:[(0,t.jsx)(K.Paperclip,{className:"size-3"}),eT.attachments.length," attachment",eT.attachments.length>1?"s":""]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:eT.attachments.map((e,s)=>(0,t.jsxs)("a",{href:`/api/email/${eT.id}/attachment/${s}?workspace_id=${c}`,target:"_blank",rel:"noopener noreferrer",download:e.filename,className:"flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/50 px-2.5 py-1.5 text-xs hover:bg-muted transition-colors cursor-pointer",children:[(0,t.jsx)(W.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-45",children:e.filename}),(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:e.size<1024?`${e.size} B`:e.size<1048576?`${(e.size/1024).toFixed(1)} KB`:`${(e.size/1048576).toFixed(1)} MB`})]},e.key))})]})]})]}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select an email to view"})}),eP=S?(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/50 px-3 py-2",children:[(0,t.jsx)(o.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{H(!1),R({})},children:(0,t.jsx)(J.ArrowLeft,{className:"size-4"})}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"New Email"})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:eF})]}):w&&eT?(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b border-border/50 px-3 py-2",children:[(0,t.jsx)(o.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{z(null),T(null)},children:(0,t.jsx)(J.ArrowLeft,{className:"size-4"})}),(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:eT.subject||"(no subject)"})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:eF})]}):(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[ev.length>1&&(0,t.jsxs)("div",{className:"relative px-3 pt-2 pb-1 border-b border-border/30",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>ej(!eg),className:"flex items-center gap-1 text-left cursor-pointer min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ez}),(0,t.jsx)(el.ChevronDown,{className:"size-2.5 text-muted-foreground shrink-0"})]}),(0,t.jsxs)(y.Tooltip,{children:[(0,t.jsx)(y.TooltipTrigger,{render:(0,t.jsx)("button",{type:"button",onClick:e$,className:"shrink-0 p-0.5"}),children:eL?(0,t.jsx)(ei.Check,{className:"size-2.5 text-green-500"}):(0,t.jsx)(en.Copy,{className:"size-2.5 text-muted-foreground/40 hover:text-muted-foreground/80 transition-colors"})}),(0,t.jsx)(y.TooltipContent,{children:"Copy address"})]})]}),eg&&(0,t.jsx)("div",{className:"absolute left-2 right-2 top-full mt-0.5 z-10 rounded-lg border border-border bg-popover shadow-md py-1",children:ev.map((e,s)=>(0,t.jsxs)("button",{type:"button",onClick:()=>{ek(s),ej(!1)},className:(0,b.cn)("flex items-center gap-2 w-full px-2.5 py-1.5 text-left text-xs transition-colors",s===eN?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),children:[(0,t.jsx)(Q.Mail,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.address}),"custom"===e.type&&(0,t.jsx)("span",{className:"text-[9px] text-muted-foreground/60 shrink-0",children:"IMAP"})]},e.address))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 border-b border-border/50 px-3 py-2",children:[(0,t.jsx)("div",{className:"flex items-center gap-0.5 flex-1 min-w-0",children:[{id:"inbox",label:"Inbox"},{id:"sent",label:"Sent"},{id:"untrust",label:"Untrust"}].map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>eb(e.id),className:(0,b.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors",p===e.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.label,"inbox"===e.id&&"inbox"===p&&v>0&&(0,t.jsx)("span",{className:"ml-0.5 text-[10px] bg-blue-500 text-white rounded-full px-1 leading-none min-w-4 text-center",children:v})]},e.id))}),(0,t.jsx)(o.Button,{size:"icon-sm",variant:"ghost",onClick:()=>{R({}),H(!0),z(null)},disabled:0===ev.length,children:(0,t.jsx)(Z.Plus,{className:"size-4"})})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:eI})]});return(0,t.jsxs)(t.Fragment,{children:[h?eP:(0,t.jsxs)(ed.ResizablePanelGroup,{orientation:"horizontal",children:[(0,t.jsx)(ed.ResizablePanel,{defaultSize:"15%",minSize:"10%",maxSize:"20%",children:eD}),(0,t.jsx)(ed.ResizableHandle,{withHandle:!0}),(0,t.jsx)(ed.ResizablePanel,{defaultSize:"30%",minSize:"15%",maxSize:"40%",children:eI}),(0,t.jsx)(ed.ResizableHandle,{withHandle:!0}),(0,t.jsx)(ed.ResizablePanel,{defaultSize:"55%",minSize:"25%",children:eF})]}),(0,t.jsx)(d.ConfirmDialog,{open:F,onOpenChange:P,title:"Delete email",description:"This will permanently delete this email.",loading:ex,onConfirm:eH})]})}],129396)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,716032,e=>{"use strict";var s=e.i(653772),t=e.i(511043),a=e.i(255334),r=e.i(613349),i=e.i(516266),n=e.i(126942),l=e.i(500324),c=e.i(23055),d=e.i(222862),o=e.i(186339),m=e.i(903477),u=e.i(473131),x=e.i(728886),h=e.i(553617),p=e.i(205189);function f(){let{workspaceId:e,slug:a}=(0,l.useWorkspace)(),r=(0,c.useSession)(),f=(0,n.useRouter)(),[g,j]=(0,t.useState)(""),[v,N]=(0,t.useState)(!0),[b,y]=(0,t.useState)(""),[k,w]=(0,t.useState)(""),[C,T]=(0,t.useState)(""),[S,E]=(0,t.useState)(""),[_,M]=(0,t.useState)(!1),[P,z]=(0,t.useState)({}),[I,O]=(0,t.useState)(""),[R,$]=(0,t.useState)(!1),F=(0,t.useCallback)(async()=>{N(!0);try{let s=r.data?.user?.id,[t,a]=await Promise.all([(0,d.listMembers)(e),(0,d.listWorkspaces)()]),i=t.find(e=>e.user_id===s);j(i?.role??"");let n=a.find(s=>s.id===e);n&&(y(n.name),w(n.slug),T(n.name),E(n.slug))}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load workspace info")}finally{N(!1)}},[e,r.data?.user?.id]);(0,t.useEffect)(()=>{r.data&&F()},[F,r.data]);let A=b!==C||k!==S,D=async()=>{let s=(0,h.validateWorkspaceForm)({name:b,slug:k});if(z(s),!(0,h.hasWorkspaceFormErrors)(s)){M(!0);try{let s=await (0,d.updateWorkspace)(e,{name:b.trim(),slug:k.trim()});(0,p.trackSettingsUpdated)({setting_tab:"general"}),T(s.name),E(s.slug),i.toast.success("Workspace updated"),s.slug!==a&&f.replace(`/w/${s.slug}/settings`)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to update workspace")}finally{M(!1)}}},L=async()=>{if(I===C){$(!0);try{await (0,d.deleteWorkspace)(e,C),i.toast.success("Workspace deleted"),f.replace("/workspaces")}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to delete workspace")}finally{$(!1)}}};return v?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(x.Skeleton,{className:"h-4 w-32"}),(0,s.jsx)(x.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(x.Skeleton,{className:"h-10 w-full"})]}):"owner"!==g?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Only workspace owners can edit workspace settings."}):(0,s.jsxs)("div",{className:"space-y-10",children:[(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)("h2",{className:"text-sm font-medium",children:"Workspace"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(u.Label,{htmlFor:"workspace-name",children:"Name"}),(0,s.jsx)(m.Input,{id:"workspace-name",value:b,onChange:e=>{let s=e.target.value;y(s),P.name&&s.trim()&&z(e=>({...e,name:void 0}))},placeholder:"Workspace name","aria-invalid":!!P.name,"aria-describedby":P.name?"workspace-name-error":void 0}),P.name&&(0,s.jsx)("p",{id:"workspace-name-error",className:"text-xs text-destructive",children:P.name})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(u.Label,{htmlFor:"workspace-slug",children:"Slug"}),(0,s.jsx)(m.Input,{id:"workspace-slug",value:k,onChange:e=>{let s=e.target.value;w(s),P.slug&&s.trim()&&z(e=>({...e,slug:void 0}))},placeholder:"workspace-slug","aria-invalid":!!P.slug,"aria-describedby":P.slug?"workspace-slug-error":void 0}),P.slug&&(0,s.jsx)("p",{id:"workspace-slug-error",className:"text-xs text-destructive",children:P.slug}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/70",children:["Used in URLs: /w/",k,"/"]})]})]}),(0,s.jsx)(o.Button,{size:"sm",onClick:D,disabled:!A||_,children:_?"Saving…":"Save"})]}),(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)("h2",{className:"text-sm font-medium text-destructive",children:"Danger Zone"}),(0,s.jsxs)("div",{className:"rounded-md border border-destructive/30 p-4 space-y-3",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Deleting this workspace is permanent and cannot be undone. All agents, conversations, and data will be lost."}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)(u.Label,{htmlFor:"delete-confirm",className:"text-xs",children:["Type ",(0,s.jsx)("span",{className:"font-medium text-foreground",children:C})," to confirm"]}),(0,s.jsx)(m.Input,{id:"delete-confirm",value:I,onChange:e=>O(e.target.value),placeholder:C})]}),(0,s.jsx)(o.Button,{size:"sm",variant:"destructive",onClick:L,disabled:I!==C||R,children:R?"Deleting…":"Delete Workspace"})]})]})]})}var g=e.i(740513);function j({ratio:e,size:t=16,stroke:a=1.5}){let i=(t-a)/2,n=2*Math.PI*i,l=(e<=0?0:e>=1?1:Math.log1p(99*e)/Math.log(100))*n;return(0,s.jsxs)("svg",{width:t,height:t,className:"shrink-0 -rotate-90","aria-hidden":!0,children:[(0,s.jsx)("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",strokeWidth:a,className:"text-border"}),(0,s.jsx)("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",strokeWidth:a,strokeDasharray:`${l} ${n-l}`,strokeLinecap:"round",className:(0,r.cn)("transition-all duration-300",e>.9?"text-destructive/70":e>.7?"text-yellow-500/50":"text-muted-foreground/30")})]})}function v(){let{workspaceId:e}=(0,l.useWorkspace)(),[a,r]=(0,t.useState)(""),[n,c]=(0,t.useState)(""),[o,m]=(0,t.useState)(!0),u=(0,t.useRef)(a);(0,t.useEffect)(()=>{u.current=a},[a]);let h=(0,t.useRef)(n);(0,t.useEffect)(()=>{h.current=n},[n]);let p=(0,t.useRef)(null),f=(0,t.useRef)(!1),v=(0,t.useCallback)(async()=>{m(!0);try{let s=await (0,d.getMemberMe)(e);r(s.global_instruction),c(s.global_instruction)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load settings")}finally{m(!1)}},[e]);(0,t.useEffect)(()=>{v()},[v]);let N=(0,t.useRef)(()=>{}),b=(0,t.useCallback)(async()=>{if(f.current)return;let s=u.current;if(s!==h.current){f.current=!0;try{let t=await (0,d.updateMemberMe)(e,s);c(t.global_instruction)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to save")}finally{f.current=!1,u.current!==h.current&&N.current()}}},[e]),y=(0,t.useCallback)(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(b,500)},[b]);(0,t.useEffect)(()=>{N.current=y},[y]);let k=(0,t.useCallback)(e=>{r(e),y()},[y]);(0,t.useEffect)(()=>{let s=()=>{if(p.current&&clearTimeout(p.current),u.current!==h.current){let s=new URLSearchParams({workspace_id:e});fetch(`/api/members/me?${s}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({global_instruction:u.current}),keepalive:!0})}};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[e]),(0,t.useEffect)(()=>()=>{if(p.current&&clearTimeout(p.current),u.current!==h.current){let s=new URLSearchParams({workspace_id:e});fetch(`/api/members/me?${s}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({global_instruction:u.current}),keepalive:!0})}},[e]);let w=a.length/5e4;return o?(0,s.jsxs)("div",{className:"px-6 py-6 space-y-4",children:[(0,s.jsx)(x.Skeleton,{className:"h-4 w-48"}),(0,s.jsx)(x.Skeleton,{className:"h-40 w-full"})]}):(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsx)("div",{className:"flex-1 px-6 pt-4 pb-4",children:(0,s.jsx)(g.MarkdownEditor,{value:a,onChange:k,placeholder:"Write instructions that every agent you own will follow...",minHeight:"calc(100vh - 240px)",contentType:"markdown",variant:"seamless"})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 px-6 py-3",children:[(0,s.jsx)(j,{ratio:w}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"This instruction is prepended to every agent's individual instruction."})]})]})}var N=e.i(330746),b=e.i(813141),y=e.i(947308),k=e.i(419412);let w=(0,k.default)("user-minus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);var C=e.i(329686);function T(e){return`${window.location.origin}/invite/${e}`}function S(){let{workspaceId:e}=(0,l.useWorkspace)(),a=(0,c.useSession)(),n=a.data?.user?.id,[m,u]=(0,t.useState)([]),[h,f]=(0,t.useState)([]),[g,j]=(0,t.useState)(!0),[v,k]=(0,t.useState)(!1),S=m.find(e=>e.user_id===n)?.role==="owner",E=(0,t.useCallback)(async()=>{j(!0);try{let[s,t]=await Promise.all([(0,d.listMembers)(e),(0,d.listInvites)(e).catch(()=>[])]);u(s),f(t)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load members")}finally{j(!1)}},[e]);(0,t.useEffect)(()=>{E()},[E]);let _=async()=>{k(!0);try{let s=await (0,d.createInvite)(e);(0,p.trackTeamMemberInvited)({workspace_id:e}),f(e=>[...e,s]);let t=T(s.token);await navigator.clipboard.writeText(t),i.toast.success("Invite link copied to clipboard")}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to generate invite")}finally{k(!1)}},M=async e=>{let s=T(e);try{await navigator.clipboard.writeText(s),i.toast.success("Invite link copied")}catch{i.toast.error("Failed to copy link")}},P=async s=>{try{await (0,d.revokeInvite)(e,s),f(e=>e.filter(e=>e.id!==s)),i.toast.success("Invite revoked")}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to revoke invite")}},z=async s=>{try{await (0,d.removeMember)(e,s),u(e=>e.filter(e=>e.id!==s)),i.toast.success("Member removed")}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to remove member")}};return g?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(x.Skeleton,{className:"h-4 w-24"}),(0,s.jsx)(x.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(x.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(x.Skeleton,{className:"h-4 w-24 mt-6"}),(0,s.jsx)(x.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(x.Skeleton,{className:"h-10 w-full"})]}):(0,s.jsxs)("div",{className:"space-y-8",children:[S&&(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-sm font-medium",children:"Pending Invites"}),(0,s.jsxs)(o.Button,{size:"sm",variant:"outline",onClick:_,disabled:v,children:[(0,s.jsx)(y.Plus,{className:"size-3.5 mr-1"}),v?"Generating…":"Generate invite link"]})]}),0===h.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground py-2",children:"No active invite links. Generate one to invite someone to this workspace."}):(0,s.jsx)("div",{className:"space-y-1.5",children:h.map(e=>{let t=new Date(e.expires_at),a=t<new Date;return(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2 text-xs",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:(0,r.cn)("font-mono truncate",a&&"text-muted-foreground line-through"),children:["/invite/",e.token.slice(0,12),"…"]}),(0,s.jsx)("p",{className:(0,r.cn)("text-muted-foreground/70 mt-0.5",a&&"text-destructive/70"),children:a?"Expired":`Expires ${t.toLocaleDateString()}`})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 ml-2 shrink-0",children:[!a&&(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)(o.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>M(e.token)}),children:(0,s.jsx)(N.Copy,{className:"size-3.5"})}),(0,s.jsx)(C.TooltipContent,{children:"Copy invite link"})]}),(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)(o.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>P(e.id)}),children:(0,s.jsx)(b.Trash2,{className:"size-3.5"})}),(0,s.jsx)(C.TooltipContent,{children:"Revoke invite"})]})]})]},e.id)})})]}),(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)("h2",{className:"text-sm font-medium",children:"Members"}),(0,s.jsx)("div",{className:"space-y-1.5",children:m.map(e=>{let t=e.user_id===n,a=e.name?e.name.split(" ").map(e=>e[0]).join("").slice(0,2).toUpperCase():e.email.slice(0,2).toUpperCase();return(0,s.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-border/50 px-3 py-2",children:[(0,s.jsx)("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground shrink-0 overflow-hidden",children:e.image?(0,s.jsx)("img",{src:e.image,alt:e.name,className:"size-full object-cover"}):a}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"text-sm font-medium truncate leading-tight",children:[e.name||e.email,t&&(0,s.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground font-normal",children:"(you)"})]}),e.name&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.email})]}),(0,s.jsx)("span",{className:(0,r.cn)("text-xs px-1.5 py-0.5 rounded shrink-0","owner"===e.role?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:e.role}),S&&!t&&(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)(o.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive shrink-0",onClick:()=>z(e.id)}),children:(0,s.jsx)(w,{className:"size-3.5"})}),(0,s.jsx)(C.TooltipContent,{children:"Remove member"})]})]},e.id)})})]})]})}var E=e.i(885515),_=e.i(254618),M=e.i(899746);function P(){let[e,a]=(0,t.useState)(!1),[r,n]=(0,t.useState)([...M.NOTIFICATION_EVENTS]),[l,c]=(0,t.useState)(!0),[d,o]=(0,t.useState)(!1);(0,t.useEffect)(()=>{c((0,M.isNotificationSupported)()),a((0,M.getNotificationEnabled)()),n((0,M.getNotificationEvents)()),(0,M.isNotificationSupported)()&&o("denied"===Notification.permission)},[]);let m=async e=>{if(!e){a(!1),(0,M.setNotificationEnabled)(!1);return}await (0,M.requestNotificationPermission)()?(a(!0),(0,M.setNotificationEnabled)(!0)):(o(!0),i.toast.error("Notification permission denied. Please enable it in browser settings."))};return l?(0,s.jsx)("div",{className:"space-y-6",children:(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)("h2",{className:"text-sm font-medium",children:"Browser Notifications"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)("p",{className:"text-sm",children:"Enable notifications"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Get notified when tasks finish while the tab is in the background"})]}),(0,s.jsx)(_.Switch,{checked:e,onCheckedChange:m,disabled:d&&!e})]}),d&&!e&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:"Notification permission was denied. Please allow it in your browser settings."}),e&&(0,s.jsxs)("div",{className:"space-y-2 pl-0.5",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Notify me when:"}),M.NOTIFICATION_EVENTS.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[(0,s.jsx)(E.Checkbox,{checked:r.includes(e),onCheckedChange:()=>{n(s=>{let t=s.includes(e)?s.filter(s=>s!==e):[...s,e];return(0,M.setNotificationEvents)(t),t})}}),M.NOTIFICATION_EVENT_LABELS[e]]},e))]})]})]})}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Your browser does not support notifications."})}let z=(0,k.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);var I=e.i(399561),O=e.i(460520),R=e.i(961909),$=e.i(790961);function F(){let[e,a]=(0,t.useState)(!1),[i,n]=(0,t.useState)(I.CLOUD_CODE_MONSTER_PET_PRESETS[0].id),l=(0,I.getCloudCodeMonsterPreset)(i);return(0,t.useEffect)(()=>{a((0,$.readHomePetSettings)().enabled),n((0,I.readCloudCodeMonsterPetPresetId)());let e=e=>{let s=e.detail?.presetId;n(s?(0,I.getCloudCodeMonsterPreset)(s).id:(0,I.readCloudCodeMonsterPetPresetId)())};return window.addEventListener(O.CLOUD_CODE_MONSTER_PRESET_CHANGED_EVENT,e),()=>{window.removeEventListener(O.CLOUD_CODE_MONSTER_PRESET_CHANGED_EVENT,e)}},[]),(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)("h2",{className:"text-sm font-medium",children:"Pet"}),(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(u.Label,{htmlFor:"pet-enabled",className:"text-sm",children:"Enable pet"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Off by default. Turn it on when you want the workspace companion."})]}),(0,s.jsx)(_.Switch,{id:"pet-enabled",checked:e,onCheckedChange:e=>{a(e),(0,$.writeHomePetSettings)({enabled:e})}})]})})]}),e?(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-sm font-medium",children:"Preset"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:l.name})]}),(0,s.jsx)("div",{className:"grid size-14 place-items-center rounded-md bg-card ring-1 ring-border/60",children:(0,s.jsx)(R.CloudCodeMonsterPresetPreview,{preset:l,className:"size-11"})})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:I.CLOUD_CODE_MONSTER_PET_PRESETS.map(e=>{let t=e.id===l.id;return(0,s.jsxs)("button",{type:"button","aria-pressed":t,onClick:()=>{n((0,I.writeCloudCodeMonsterPetPresetId)(e.id))},className:(0,r.cn)("group grid h-28 min-w-0 grid-rows-[1fr_auto] rounded-md border bg-card/60 p-2 text-left transition-all hover:border-foreground/20 hover:bg-accent/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",t?"border-primary/50 bg-accent text-foreground":"border-border/50 text-muted-foreground"),children:[(0,s.jsx)("div",{className:"grid place-items-center rounded bg-background/70 ring-1 ring-border/35",children:(0,s.jsx)(R.CloudCodeMonsterPresetPreview,{preset:e,className:"size-14 transition-transform duration-200 group-hover:scale-105"})}),(0,s.jsxs)("div",{className:"mt-1.5 flex min-w-0 items-center justify-between gap-1 text-[10px] leading-none",children:[(0,s.jsx)("span",{className:"truncate font-medium text-foreground",children:e.name}),t?(0,s.jsx)(z,{className:"size-3 shrink-0 text-primary"}):(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.id.replace("pet-","#")})]})]},e.id)})})]}):null]})}var A=e.i(355578),D=e.i(934351),L=e.i(875061);let W=(0,k.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var U=e.i(896210),B=e.i(392277);let H=(0,k.default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);var q=e.i(646769);let G=(0,k.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function V({icon:e,label:t,value:a,sub:r}){return(0,s.jsx)(D.Card,{size:"sm",children:(0,s.jsxs)(D.CardContent,{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:(0,s.jsx)(e,{className:"size-4"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-1",children:[(0,s.jsx)("p",{className:"text-2xl font-semibold leading-none tracking-tight",children:a}),r&&(0,s.jsx)(L.Badge,{variant:"secondary",className:"text-[10px] px-1.5 h-4 font-normal",children:r})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground truncate",children:t})]})]})})}function J({agents:e,runtimes:t,activeTaskCounts:a,overview:r}){let i=new Map;for(let e of t){let s=e.daemon_id??e.id;i.set(s,i.get(s)||"online"===e.status)}let n=i.size,l=[...i.values()].filter(Boolean).length,c=Object.values(a).reduce((e,s)=>e+s,0),d=e.filter(e=>{let s=t.find(s=>s.id===e.runtime_id);return s?.status==="online"}).length;return(0,s.jsxs)("div",{className:"grid gap-3 grid-cols-2 sm:grid-cols-3 lg:grid-cols-6",children:[(0,s.jsx)(V,{icon:q.Monitor,label:"Machines",value:`${l}/${n}`,sub:"online"}),(0,s.jsx)(V,{icon:W,label:"Agents",value:e.length,sub:`${d} online`}),(0,s.jsx)(V,{icon:H,label:"Members",value:r.members.length,sub:r.pending_invites>0?`${r.pending_invites} pending`:void 0}),(0,s.jsx)(V,{icon:G,label:"Active Tasks",value:c,sub:r.task_stats.queued>0?`${r.task_stats.queued} queued`:void 0}),(0,s.jsx)(V,{icon:B.Send,label:"Emails Sent",value:r.email_stats.outbound,sub:`${r.email_stats.unread} unread`}),(0,s.jsx)(V,{icon:U.Mail,label:"Custom Emails",value:r.email_accounts.length})]})}function K({overview:e}){let{completed:t,failed:a,cancelled:r,queued:i,stale:n}=e.task_stats,l=t+a,c=l>0?(a/l*100).toFixed(1):"0";return(0,s.jsxs)(D.Card,{children:[(0,s.jsx)(D.CardHeader,{children:(0,s.jsx)(D.CardTitle,{children:"Task Health (Today)"})}),(0,s.jsx)(D.CardContent,{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(Q,{label:"Completed",value:t}),(0,s.jsx)(Q,{label:"Failed",value:a,className:a>0?"text-destructive":void 0}),(0,s.jsx)(Q,{label:"Cancelled",value:r}),(0,s.jsx)(Q,{label:"Failure Rate",value:`${c}%`,className:Number(c)>10?"text-destructive":void 0}),(0,s.jsx)(Q,{label:"Queue Backlog",value:i,className:i>10?"text-amber-500":void 0}),(0,s.jsx)(Q,{label:"Stale Tasks",value:n,className:n>0?"text-destructive":void 0})]})})]})}function Q({label:e,value:t,className:a}){return(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:`text-xl font-semibold ${a??""}`,children:t}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e})]})}function Y({overview:e,agents:t}){let{inbound:a,outbound:r,unread:i,rejected:n}=e.email_stats,l=new Map(t.map(e=>[e.id,e.name]));return(0,s.jsxs)(D.Card,{children:[(0,s.jsx)(D.CardHeader,{children:(0,s.jsx)(D.CardTitle,{children:"Email Summary"})}),(0,s.jsxs)(D.CardContent,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xl font-semibold",children:a}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Received"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xl font-semibold",children:r}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Sent"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:`text-xl font-semibold ${i>0?"text-primary":""}`,children:i}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Unread"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:`text-xl font-semibold ${n>0?"text-amber-500":""}`,children:n}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Untrust"})]})]}),e.email_accounts.length>0&&(0,s.jsxs)("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Custom Mailboxes"}),e.email_accounts.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)("span",{className:`size-1.5 shrink-0 rounded-full ${"active"===e.status?"bg-emerald-500":"bg-destructive"}`})}),(0,s.jsx)(C.TooltipContent,{side:"top",children:"active"===e.status?"Active":`Error: ${e.error_message||"inactive"}`})]}),(0,s.jsx)("span",{className:"truncate",children:e.email_address})]}),(0,s.jsx)("span",{className:"text-muted-foreground shrink-0",children:l.get(e.agent_id)??"—"})]},e.id))]})]})]})}var Z=e.i(345262);function X({runtimes:e,agents:t}){let a=(0,n.useRouter)(),{slug:r}=(0,l.useWorkspace)(),i=new Map;for(let s of e){let e=s.daemon_id??s.id;i.has(e)||i.set(e,{runtimes:[],deviceInfo:s.device_info??""}),i.get(e).runtimes.push(s)}let c=[...i.entries()];return 0===c.length?(0,s.jsxs)(D.Card,{children:[(0,s.jsxs)(D.CardHeader,{children:[(0,s.jsx)(D.CardTitle,{children:"Machines"}),(0,s.jsx)(D.CardAction,{children:(0,s.jsx)("button",{type:"button",onClick:()=>a.push(`/w/${r}/runtimes`),className:"text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:(0,s.jsx)(Z.ArrowUpRight,{className:"size-4"})})})]}),(0,s.jsx)(D.CardContent,{children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No machines connected."})})]}):(0,s.jsxs)(D.Card,{children:[(0,s.jsx)(D.CardHeader,{children:(0,s.jsx)(D.CardTitle,{children:"Machines"})}),(0,s.jsx)(D.CardContent,{className:"space-y-3",children:c.map(([e,a])=>{let r=a.runtimes.some(e=>"online"===e.status),i=a.runtimes.map(e=>e.last_seen_at).filter(Boolean).sort().reverse()[0],n=t.filter(e=>a.runtimes.some(s=>s.id===e.runtime_id)),l=a.runtimes.some(e=>e.pending_update_version),c=a.runtimes.find(e=>e.pending_update_version)?.pending_update_version;return(0,s.jsxs)("div",{className:"flex items-start gap-3 text-xs",children:[(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)("span",{className:`mt-1 size-2 shrink-0 rounded-full ${r?"bg-emerald-500":"bg-muted-foreground/30"}`})}),(0,s.jsx)(C.TooltipContent,{side:"top",children:r?"Online":"Offline"})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium truncate",children:a.deviceInfo||e.slice(0,12)}),l&&(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)("span",{children:(0,s.jsx)(L.Badge,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-amber-500 border-amber-500/30",children:"update"})})}),(0,s.jsxs)(C.TooltipContent,{side:"top",children:["Pending update to v",c]})]})]}),(0,s.jsxs)("div",{className:"text-muted-foreground mt-0.5",children:[n.length>0?n.map(e=>e.name).join(", "):"No agents"," · ",function(e){if(!e)return"never";let s=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(s<60)return`${s}s ago`;let t=Math.floor(s/60);if(t<60)return`${t}m ago`;let a=Math.floor(t/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}(i??null)]})]})]},e)})})]})}function ee({overview:e}){let t=(0,n.useRouter)(),{slug:a}=(0,l.useWorkspace)(),{members:r,pending_invites:i}=e;return(0,s.jsxs)(D.Card,{children:[(0,s.jsxs)(D.CardHeader,{children:[(0,s.jsx)(D.CardAction,{children:(0,s.jsx)("button",{type:"button",onClick:()=>t.push(`/w/${a}/settings`),className:"text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:(0,s.jsx)(Z.ArrowUpRight,{className:"size-4"})})}),(0,s.jsxs)(D.CardTitle,{children:["Team",i>0&&(0,s.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground font-normal",children:["(",i," pending invite",i>1?"s":"",")"]})]})]}),(0,s.jsx)(D.CardContent,{className:"p-0",children:(0,s.jsx)("div",{className:"divide-y divide-border/50",children:[...r].sort((e,s)=>"owner"===e.role?-1:+("owner"===s.role)).map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.image?(0,s.jsx)("img",{src:e.image,alt:e.name,className:"size-7 rounded-full shrink-0"}):(0,s.jsx)("div",{className:"flex size-7 shrink-0 items-center justify-center rounded-full bg-secondary text-xs font-medium",children:(e.name||e.email).charAt(0).toUpperCase()}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-sm font-medium truncate block",children:e.name||e.email}),e.name&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground truncate block",children:e.email})]}),(0,s.jsx)(L.Badge,{variant:"owner"===e.role?"default":"secondary",className:"text-[10px] px-1.5 py-0 shrink-0",children:e.role})]},e.id))})})]})}function es(){let{agents:e,runtimes:a,loading:r,activeTaskCounts:i}=(0,A.useAgentContext)(),{workspaceId:n}=(0,l.useWorkspace)(),[c,o]=(0,t.useState)(null),[m,u]=(0,t.useState)(!1);return((0,t.useEffect)(()=>{if(r)return;let e=!1;return u(!0),(0,d.getWorkspaceOverview)(n).then(s=>{e||o(s)}).catch(()=>{}).finally(()=>{e||u(!1)}),()=>{e=!0}},[r,n]),m||!c)?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(x.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(x.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(x.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(x.Skeleton,{className:"h-44 rounded-xl"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(J,{agents:e,runtimes:a,activeTaskCounts:i,overview:c}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsx)(K,{overview:c}),(0,s.jsx)(Y,{overview:c,agents:e})]}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsx)(X,{runtimes:a,agents:e}),(0,s.jsx)(ee,{overview:c})]})]})}let et=[{id:"general",label:"General"},{id:"pet",label:"Pet"},{id:"instruction",label:"Global Instruction"},{id:"notifications",label:"Notifications"},{id:"members",label:"Members"},{id:"usages",label:"Usages"}];e.s(["default",0,function(){let[e,i]=(0,t.useState)("general");return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between border-b border-border/50 px-3 md:px-5 py-2.5 gap-3",children:(0,s.jsx)("div",{className:"flex items-center gap-3 min-w-0",children:(0,s.jsx)("h1",{className:"text-sm font-medium",children:"Settings"})})}),(0,s.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,s.jsx)("nav",{className:"w-48 shrink-0 border-r border-border/50 py-3 px-2 hidden md:block",children:et.map(t=>(0,s.jsx)("button",{onClick:()=>i(t.id),className:(0,r.cn)("w-full rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",e===t.id?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:t.label},t.id))}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,s.jsx)("div",{className:"px-4 pt-2 md:hidden",children:(0,s.jsx)(a.Tabs,{className:"items-center",value:e,onValueChange:e=>i(e),children:(0,s.jsx)(a.TabsList,{className:"h-auto gap-1",children:et.map(e=>(0,s.jsx)(a.TabsTrigger,{value:e.id,children:e.label},e.id))})})}),(0,s.jsx)("div",{className:(0,r.cn)("flex-1 overflow-y-auto thin-scrollbar","instruction"!==e&&"px-5 py-5"),children:"instruction"===e?(0,s.jsx)(v,{}):"usages"===e?(0,s.jsx)(es,{}):(0,s.jsxs)("div",{className:"mx-auto max-w-md",children:["general"===e&&(0,s.jsx)(f,{}),"pet"===e&&(0,s.jsx)(F,{}),"notifications"===e&&(0,s.jsx)(P,{}),"members"===e&&(0,s.jsx)(S,{})]})})]})]})]})}],716032)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,573404,e=>{"use strict";let t=(0,e.i(419412).default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["default",0,t])},392277,e=>{"use strict";let t=(0,e.i(419412).default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);e.s(["Send",0,t],392277)},888917,e=>{"use strict";let t,n;var r=e.i(653772),a=e.i(511043);function i({groupSize:e,panelElement:t,styleProp:n}){let r,[a,o]=function(e){switch(typeof e){case"number":return[e,"px"];case"string":{let t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}(n);switch(o){case"%":r=a/100*e;break;case"px":r=a;break;case"rem":r=a*parseFloat(getComputedStyle(t.ownerDocument.documentElement).fontSize);break;case"em":r=a*parseFloat(getComputedStyle(t).fontSize);break;case"vh":r=a/100*window.innerHeight;break;case"vw":r=a/100*window.innerWidth}return r}function o(e){return parseFloat(e.toFixed(3))}function l({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>e+="horizontal"===t?n.element.offsetWidth:n.element.offsetHeight,0)}function s(e){let{panels:t}=e,n=l({group:e});return 0===n?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:!0===e.panelConstraints.collapsible,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let t,{element:r,panelConstraints:a}=e,l=0;void 0!==a.collapsedSize&&(l=o(i({groupSize:n,panelElement:r,styleProp:a.collapsedSize})/n*100)),void 0!==a.defaultSize&&(t=o(i({groupSize:n,panelElement:r,styleProp:a.defaultSize})/n*100));let s=0;void 0!==a.minSize&&(s=o(i({groupSize:n,panelElement:r,styleProp:a.minSize})/n*100));let u=100;return void 0!==a.maxSize&&(u=o(i({groupSize:n,panelElement:r,styleProp:a.maxSize})/n*100)),{groupResizeBehavior:a.groupResizeBehavior,collapsedSize:l,collapsible:!0===a.collapsible,defaultSize:t,disabled:a.disabled,minSize:s,maxSize:u,panelId:e.id}})}function u(e,t="Assertion error"){if(!e)throw Error(t)}function d(e,t){return Array.from(t).sort("horizontal"===e?f:p)}function f(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return 0!==n?n:e.element.offsetWidth-t.element.offsetWidth}function p(e,t){let n=e.element.offsetTop-t.element.offsetTop;return 0!==n?n:e.element.offsetHeight-t.element.offsetHeight}function c(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function h(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function g(e){let{element:n,orientation:r,panels:a,separators:i}=e,o=d(r,Array.from(n.children).filter(c).map(e=>({element:e}))).map(({element:e})=>e),s=[],f=!1,p=!1,g=-1,v=-1,m=0,b,y=[];{let e=-1;for(let t of o)t.hasAttribute("data-panel")&&(e++,t.hasAttribute("data-disabled")||(m++,-1===g&&(g=e),v=e))}if(m>1){let n=-1;for(let d of o)if(d.hasAttribute("data-panel")){n++;let i=a.find(e=>e.element===d);if(i){if(b){let a,o=b.element.getBoundingClientRect(),c=d.getBoundingClientRect();if(p){let e="horizontal"===r?new DOMRect(o.right,o.top,0,o.height):new DOMRect(o.left,o.bottom,o.width,0),t="horizontal"===r?new DOMRect(c.left,c.top,0,c.height):new DOMRect(c.left,c.top,c.width,0);switch(y.length){case 0:a=[e,t];break;case 1:{let n=y[0],i=function({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},a,i=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=h(r,n),l="horizontal"===e?t:o;l<i&&(i=l,a=n)}return u(a,"No rect found"),a}({orientation:r,rects:[o,c],targetRect:n.element.getBoundingClientRect()});a=[n,i===o?t:e];break}default:a=y}}else a=y.length?y:["horizontal"===r?new DOMRect(o.right,c.top,c.left-o.right,c.height):new DOMRect(c.left,o.bottom,c.width,c.top-o.bottom)];for(let r of a){let a="width"in r?r:r.element.getBoundingClientRect(),o=(void 0===t&&(t="function"==typeof matchMedia&&!!matchMedia("(pointer:coarse)").matches),t)?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(a.width<o){let e=o-a.width;a=new DOMRect(a.x-e/2,a.y,a.width+e,a.height)}if(a.height<o){let e=o-a.height;a=new DOMRect(a.x,a.y-e/2,a.width,a.height+e)}let u=n<=g||n>v;f||u||s.push({group:e,groupSize:l({group:e}),panels:[b,i],separator:"width"in r?void 0:r,rect:a}),f=!1}}p=!1,b=i,y=[]}}else if(d.hasAttribute("data-separator")){null!==d.ariaDisabled&&(f=!0);let e=i.find(e=>e.element===d);e?y.push(e):(b=void 0,y=[])}else p=!0}return s}class v{#e={};addListener(e,t){let n=this.#e[e];return void 0===n?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(void 0!==n)if(1===n.length)n[0].call(null,t);else{let e=!1,r=null,a=Array.from(n);for(let n=0;n<a.length;n++){let i=a[n];try{i.call(null,t)}catch(t){null===r&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(void 0!==n){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}}let m=new Map,b=new v;function y(e,t){for(let[t]of m)if(t.id===e)return t}function z(e,t){for(let[t,n]of m)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function S(e,t){return b.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function x(e,t){let n=m.get(e);(m=new Map(m)).set(e,t),b.emit("groupChange",{group:e,prev:n,next:t})}let w=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function C(e){let t=e.length;for(;t--;){let n=e[t];if(u(n,"Missing node"),function(e){let t,n=getComputedStyle(e);return!!("fixed"===n.position||"auto"!==n.zIndex&&("static"!==n.position||"flex"===(t=getComputedStyle(R(e)??e).display)||"inline-flex"===t)||1>+n.opacity||"transform"in n&&"none"!==n.transform||"webkitTransform"in n&&"none"!==n.webkitTransform||"mixBlendMode"in n&&"normal"!==n.mixBlendMode||"filter"in n&&"none"!==n.filter||"webkitFilter"in n&&"none"!==n.webkitFilter||"isolation"in n&&"isolate"===n.isolation||w.test(n.willChange)||"touch"===n.webkitOverflowScrolling)}(n))return n}return null}function P(e){return e&&Number(getComputedStyle(e).zIndex)||0}function L(e){let t=[];for(;e;)t.push(e),e=R(e);return t}function R(e){let{parentNode:t}=e;return null!==t&&"object"==typeof t&&"nodeType"in t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t}function E(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let a=g(r),i=function(e,t,n){let r,a={x:1/0,y:1/0};for(let i of t){let t=h(n,i.rect);switch(e){case"horizontal":t.x<=a.x&&(r=i,a=t);break;case"vertical":t.y<=a.y&&(r=i,a=t)}}return r?{distance:a,hitRegion:r}:void 0}(r.orientation,a,{x:e.clientX,y:e.clientY});i&&i.distance.x<=0&&i.distance.y<=0&&function({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!c(n)||n.contains(e)||e.contains(n))return!0;if(function(e,t){let n;if(e===t)throw Error("Cannot compare node with itself");let r={a:L(e),b:L(t)};for(;r.a.at(-1)===r.b.at(-1);)n=r.a.pop(),r.b.pop();u(n,"Stacking order can only be calculated for elements with a common ancestor");let a={a:P(C(r.a)),b:P(C(r.b))};if(a.a===a.b){let e=n.childNodes,t={a:r.a.at(-1),b:r.b.at(-1)},a=e.length;for(;a--;){let n=e[a];if(n===t.a)return 1;if(n===t.b)return -1}}return Math.sign(a.a-a.b)}(n,e)>0){let a=n;for(;a;){var r;if(a.contains(e))break;if(r=a.getBoundingClientRect(),r.x<t.x+t.width&&r.x+r.width>t.x&&r.y<t.y+t.height&&r.y+r.height>t.y)return!1;a=a.parentElement}}return!0}({groupElement:r.element,hitRegion:i.hitRegion.rect,pointerEventTarget:e.target})&&n.push(i.hitRegion)}),n}function M(e,t,n=0){return Math.abs(o(e)-o(t))<=n}function k(e,t){return M(e,t)?0:e>t?1:-1}function D({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:a=0,collapsible:i,disabled:l,maxSize:s=100,minSize:u=0}=t;return l&&!e?n:(0>k(r,u)&&(r=i&&0>k(r,(a+u)/2)?a:u),o(r=Math.min(s,r)))}function T({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:i}){if(M(e,0))return t;let o="imperative-api"===i,l=Object.values(t),s=Object.values(a),d=[...l],[f,p]=r;u(null!=f,"Invalid first pivot index"),u(null!=p,"Invalid second pivot index");let c=0;if("keyboard"===i){{let t=e<0?p:f,r=n[t];u(r,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:i,minSize:o=0}=r;if(i){let n=l[t];if(u(null!=n,`Previous layout not found for panel index ${t}`),M(n,a)){let t=o-n;k(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?f:p,r=n[t];u(r,`No panel constraints found for index ${t}`);let{collapsedSize:a=0,collapsible:i,minSize:o=0}=r;if(i){let n=l[t];if(u(null!=n,`Previous layout not found for panel index ${t}`),M(n,o)){let t=n-a;k(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}else{let t=e<0?p:f,r=n[t];u(r,`Panel constraints not found for index ${t}`);let a=l[t],{collapsible:i,collapsedSize:o,minSize:s}=r;if(i&&0>k(a,s))if(e>0){let t=s-o;0>k(a+e,s)&&(e=0>=k(e,t/2)?0:t)}else{let t=s-o;0>k(a-e,s)&&(e=k(100+e,100-t/2)>0?0:-t)}}{let t=e<0?1:-1,r=e<0?p:f,a=0;for(;;){let e=l[r];if(u(null!=e,`Previous layout not found for panel index ${r}`),a+=D({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e,(r+=t)<0||r>=n.length)break}let i=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-i:i}{let t=e<0?f:p;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(c),a=l[t];u(null!=a,`Previous layout not found for panel index ${t}`);let i=a-r,s=D({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:a,size:i});if(!M(a,s)&&(c+=a-s,d[t]=s,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}(s,d))return a;{let t=e<0?p:f,r=l[t];u(null!=r,`Previous layout not found for panel index ${t}`);let a=r+c,i=D({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:a});if(d[t]=i,!M(i,a)){let t=a-i,r=e<0?p:f;for(;r>=0&&r<n.length;){let a=d[r];u(null!=a,`Previous layout not found for panel index ${r}`);let i=a+t,l=D({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:a,size:i});if(M(a,l)||(t-=l-a,d[r]=l),M(t,0))break;e>0?r--:r++}}}if(!M(Object.values(d).reduce((e,t)=>t+e,0),100,.1))return a;let h=Object.keys(a);return d.reduce((e,t,n)=>(e[h[n]]=t,e),{})}function I(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(void 0===t[n]||0!==k(e[n],t[n]))return!1;return!0}function O({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],a=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(", ")}`);if(!M(a,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];u(null!=t,`No layout data found for index ${e}`);let n=100/a*t;r[e]=n}let i=0;for(let e=0;e<t.length;e++){let a=n[e];u(null!=a,`No layout data found for index ${e}`);let o=r[e];u(null!=o,`No layout data found for index ${e}`);let l=D({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:a,size:o});o!=l&&(i+=o-l,r[e]=l)}if(!M(i,0))for(let e=0;e<t.length;e++){let n=r[e];u(null!=n,`No layout data found for index ${e}`);let a=n+i,o=D({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:a});if(n!==o&&(i-=o-n,r[e]=o,M(i,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function j({groupId:e,panelId:t}){let n=()=>{for(let[t,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:a,groupSize:i,separatorToPanels:o}]of m)if(t.id===e)return{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:t,groupSize:i,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(void 0!==e)return e;throw Error(`Panel constraints not found for Panel ${t}`)},a=()=>{let e=n().group.panels.find(e=>e.id===t);if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},s=()=>{let e=n().layout[t];if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},u=e=>{if(e===s())return;let{defaultLayoutDeferred:r,derivedPanelConstraints:a,group:i,groupSize:l,layout:u,separatorToPanels:d}=n(),f=O({layout:(({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:a})=>{let i=s(),l=n.findIndex(e=>e.id===t),u=0===l,d=l===n.length-1;if(d&&e<i&&(u||n.slice(0,l).every((e,t)=>{let n=a[t];return n?.collapsible&&M(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,l).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:o(100-e)}}return T({delta:d?i-e:e-i,initialLayout:r,panelConstraints:a,pivotIndices:d?[l-1,l]:[l,l+1],prevLayout:r,trigger:"imperative-api"})})({nextSize:e,panels:i.panels,prevLayout:u,derivedPanelConstraints:a}),panelConstraints:a});I(u,f)||x(i,{defaultLayoutDeferred:r,derivedPanelConstraints:a,groupSize:l,layout:f,separatorToPanels:d})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=a(),i=s();e&&i!==t&&(n.expandToSize=i,u(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:i}=a(),o=s();if(e&&o===t){let e=i.expandToSize??n;0===e&&(e=1),u(e)}},getSize:()=>{let{group:e}=n(),t=s(),{element:r}=a();return{asPercentage:t,inPixels:"horizontal"===e.orientation?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=s();return e&&M(t,n)},resize:e=>{let{group:t}=n(),{element:r}=a(),s=l({group:t});u(o(i({groupSize:s,panelElement:r,styleProp:e})/s*100))}}}function N(e){e.defaultPrevented||E(e,m).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>void 0!==e.panelConstraints.defaultSize);if(n){let r=n.panelConstraints.defaultSize,a=j({groupId:t.group.id,panelId:n.id});a&&void 0!==r&&(a.resize(r),e.preventDefault())}}})}function F(e){for(let[t]of m)if(t.separators.some(t=>t.element===e))return t;throw Error("Could not find parent Group for separator element")}function A({groupId:e}){let t=()=>{for(let[t,n]of m)if(t.id===e)return{group:t,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:a,groupSize:i,layout:o,separatorToPanels:l}=t(),s=O({layout:e,panelConstraints:r});return n?o:(I(o,s)||x(a,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:i,layout:s,separatorToPanels:l}),s)}}}function $(e,t){let n=F(e),r=z(n.id,!0),a=n.separators.find(t=>t.element===e);u(a,"Matching separator not found");let i=r.separatorToPanels.get(a);u(i,"Matching panels not found");let o=i.map(e=>n.panels.indexOf(e)),l=A({groupId:n.id}).getLayout(),s=O({layout:T({delta:t,initialLayout:l,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:l,trigger:"keyboard"}),panelConstraints:r.derivedPanelConstraints});I(l,s)||x(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:s,separatorToPanels:r.separatorToPanels})}function G(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=F(t);if(!n.disabled)switch(e.key){case"ArrowDown":e.preventDefault(),"vertical"===n.orientation&&$(t,5);break;case"ArrowLeft":e.preventDefault(),"horizontal"===n.orientation&&$(t,-5);break;case"ArrowRight":e.preventDefault(),"horizontal"===n.orientation&&$(t,5);break;case"ArrowUp":e.preventDefault(),"vertical"===n.orientation&&$(t,-5);break;case"End":e.preventDefault(),$(t,100);break;case"Enter":{e.preventDefault();let n=F(t),{derivedPanelConstraints:r,layout:a,separatorToPanels:i}=z(n.id,!0),o=n.separators.find(e=>e.element===t);u(o,"Matching separator not found");let l=i.get(o);u(l,"Matching panels not found");let s=l[0],d=r.find(e=>e.panelId===s.id);if(u(d,"Panel metadata not found"),d.collapsible){let e=a[s.id];$(t,(d.collapsedSize===e?n.mutableState.expandedPanelSizes[s.id]??d.minSize:d.collapsedSize)-e)}break}case"F6":{e.preventDefault();let n=F(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);u(null!==r,"Index not found");let a=e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0;n[a].focus({preventScroll:!0});break}case"Home":e.preventDefault(),$(t,-100)}}let B={cursorFlags:0,state:"inactive"},W=new v;function H(e){let t=B;B=e,W.emit("change",{prev:t,next:e})}function V(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=m,n=E(e,t),r=new Map,a=!1;n.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),H({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}let X=e=>e,U=()=>{};function Y(){return void 0===n&&(n=!1,"u">typeof window&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(n=!0)),n}let _=new WeakMap;function K(e){if(null===e.defaultView||void 0===e.defaultView)return;let{prevStyle:t,styleSheet:n}=_.get(e)??{};void 0===n&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=B;switch(r.state){case"active":case"hover":{let e=function({cursorFlags:e,groups:t,state:n}){let r=0,a=0;switch(n){case"active":case"hover":t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case"horizontal":r++;break;case"vertical":a++}})}if(0!==r||0!==a){if("active"===n&&e&&Y()){let t=(4&e)!=0,n=(8&e)!=0;if((1&e)!=0)return t?"se-resize":n?"ne-resize":"e-resize";if((2&e)!=0)return t?"sw-resize":n?"nw-resize":"w-resize";if(t)return"s-resize";if(n)return"n-resize"}return Y()?r>0&&a>0?"move":r>0?"ew-resize":"ns-resize":r>0&&a>0?"grab":r>0?"col-resize":"row-resize"}}({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?0===n.cssRules.length?n.insertRule(a):n.replaceSync(a):1===n.cssRules.length&&n.deleteRule(0);break}case"inactive":t=void 0,1===n.cssRules.length&&n.deleteRule(0)}_.set(e,{prevStyle:t,styleSheet:n})}function q({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:a,pointerDownAtPoint:i,prevCursorFlags:o}){var l;let s,u,d=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:l,panels:s}=n,{disableCursor:u}=n.mutableState,f=0;f=i?"horizontal"===l?(t.clientX-i.x)/o*100:(t.clientY-i.y)/o*100:"horizontal"===l?t.clientX<0?-100:100:t.clientY<0?-100:100;let p=r.get(n),c=a.get(n);if(!p||!c)return;let{defaultLayoutDeferred:h,derivedPanelConstraints:g,groupSize:v,layout:m,separatorToPanels:b}=c;if(g&&m&&b){let t=T({delta:f,initialLayout:p,panelConstraints:g,pivotIndices:e.panels.map(e=>s.indexOf(e)),prevLayout:m,trigger:"mouse-or-touch"});if(I(t,m)){if(0!==f&&!u)switch(l){case"horizontal":d|=f<0?1:2;break;case"vertical":d|=f<0?4:8}}else x(e.group,{defaultLayoutDeferred:h,derivedPanelConstraints:g,groupSize:v,layout:t,separatorToPanels:b})}});let f=0;0===t.movementX?f|=3&o:f|=3&d,0===t.movementY?f|=12&o:f|=12&d,l=f,s=B,(u={...B}).cursorFlags=l,B=u,W.emit("change",{prev:s,next:u}),K(e)}function J(e){let t=m,n=B;"active"===n.state&&q({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}function Q(e){if(e.defaultPrevented)return;let t=B,n=m;if("active"===t.state){if(0===e.buttons){H({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(e=>{let t=z(e.group.id,!0);x(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}q({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags})}else{let r=E(e,n);0===r.length?"inactive"!==t.state&&H({cursorFlags:0,state:"inactive"}):H({cursorFlags:0,hitRegions:r,state:"hover"}),K(e.currentTarget)}}function Z(e){e.relatedTarget instanceof HTMLIFrameElement&&"hover"===B.state&&H({cursorFlags:0,state:"inactive"})}function ee(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=B;"active"===t.state&&(H({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(K(e.currentTarget),t.hitRegions.forEach(e=>{let t=z(e.group.id,!0);x(e.group,t)}),e.preventDefault()))}function et(e){let t=0,n=0,r={};for(let a of e)if(void 0!==a.defaultSize){t++;let e=o(a.defaultSize);n+=e,r[a.panelId]=e}else r[a.panelId]=void 0;let a=e.length-t;if(0!==a){let t=o((100-n)/a);for(let n of e)void 0===n.defaultSize&&(r[n.panelId]=t)}return r}let en=new Map;function er(e){let t=(0,a.useId)();return`${e??t}`}let ea="u">typeof window?a.useLayoutEffect:a.useEffect;function ei(e){let t=(0,a.useRef)(e);return ea(()=>{t.current=e},[e]),(0,a.useCallback)((...e)=>t.current?.(...e),[t])}function eo(...e){return ei(t=>{e.forEach(e=>{if(e)switch(typeof e){case"function":e(t);break;case"object":e.current=t}})})}function el(e){let t=(0,a.useRef)({...e});return ea(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}let es=(0,a.createContext)(null);function eu({children:e,className:t,defaultLayout:n,disableCursor:i,disabled:f,elementRef:p,groupRef:c,id:h,onLayoutChange:v,onLayoutChanged:b,orientation:w="horizontal",resizeTargetMinimumSize:C={coarse:20,fine:10},style:P,...L}){let R,E=(0,a.useRef)({onLayoutChange:{},onLayoutChanged:{}}),k=ei(e=>{I(E.current.onLayoutChange,e)||(E.current.onLayoutChange=e,v?.(e))}),D=ei(e=>{I(E.current.onLayoutChanged,e)||(E.current.onLayoutChanged=e,b?.(e))}),T=er(h),j=(0,a.useRef)(null),[F,$]=function(){let[e,t]=(0,a.useState)({});return[e,(0,a.useCallback)(()=>t({}),[])]}(),W=(0,a.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:C,separators:[]}),H=eo(j,p);R=(0,a.useRef)({getLayout:()=>({}),setLayout:X}),(0,a.useImperativeHandle)(c,()=>R.current,[]),ea(()=>{Object.assign(R.current,A({groupId:T}))});let U=ei((e,t)=>{let r=B,a=y(e),i=z(e);if(i){let e=!1;return"active"===r.state&&(e=r.hitRegions.some(e=>e.group===a)),{flexGrow:i.layout[t]??1,pointerEvents:e?"none":void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),Y=el({defaultLayout:n,disableCursor:i}),_=(0,a.useMemo)(()=>({get disableCursor(){return!!Y.disableCursor},getPanelStyles:U,id:T,orientation:w,registerPanel:e=>{let t=W.current;return t.panels=d(w,[...t.panels,e]),$(),()=>{t.panels=t.panels.filter(t=>t!==e),$()}},registerSeparator:e=>{let t=W.current;return t.separators=d(w,[...t.separators,e]),$(),()=>{t.separators=t.separators.filter(t=>t!==e),$()}},updatePanelProps:(e,{disabled:t})=>{let n=W.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=y(T),a=z(T);r&&a&&x(r,{...a,derivedPanelConstraints:s(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=W.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[U,T,$,w,Y]),K=(0,a.useRef)(null);return ea(()=>{let e,t,n,r,a,i,d,p,c,h,v,b,y,C=j.current;if(null===C)return;let P=W.current;if(void 0!==Y.defaultLayout&&Object.keys(Y.defaultLayout).length===P.panels.length)for(let t of(e={},P.panels)){let n=Y.defaultLayout[t.id];void 0!==n&&(e[t.id]=n)}let L={disabled:!!f,element:C,id:T,mutableState:{defaultLayout:e,disableCursor:!!Y.disableCursor,expandedPanelSizes:W.current.lastExpandedPanelSizes,layouts:W.current.layouts},orientation:w,panels:P.panels,resizeTargetMinimumSize:P.resizeTargetMinimumSize,separators:P.separators};K.current=L;let R=(t=!0,u(L.element.ownerDocument.defaultView,"Cannot register an unmounted Group"),n=L.element.ownerDocument.defaultView.ResizeObserver,r=new Set,a=new Set,(i=new n(e=>{for(let n of e){let{borderBoxSize:e,target:r}=n;if(r===L.element){if(t){let e=l({group:L});if(0===e)return;let t=z(L.id);if(!t)return;let n=s(L),r=t.defaultLayoutDeferred?et(n):t.layout,a=O({layout:function({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let a=0,i=0,l=!1,s=new Map,u=[];for(let d of e.panels){let e=r[d.id]??0;if("preserve-pixel-size"===d.panelConstraints.groupResizeBehavior){l=!0;let r=o(e/100*n/t*100);s.set(d.id,r),a+=r}else u.push(d.id),i+=e}if(!l||0===u.length)return r;let d=100-a,f={...r};if(s.forEach((e,t)=>{f[t]=e}),i>0)for(let e of u){let t=r[e]??0;f[e]=o(t/i*d)}else{let e=o(d/u.length);for(let t of u)f[t]=e}return f}({group:L,nextGroupSize:e,prevGroupSize:t.groupSize,prevLayout:r}),panelConstraints:n});if(!t.defaultLayoutDeferred&&I(t.layout,a)&&function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}(t.derivedPanelConstraints,n)&&t.groupSize===e)return;x(L,{defaultLayoutDeferred:!1,derivedPanelConstraints:n,groupSize:e,layout:a,separatorToPanels:t.separatorToPanels})}}else!function(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let a=l({group:e}),i="horizontal"===e.orientation?r.element.offsetWidth:r.element.offsetHeight,s=r.mutableValues.prevSize,u={asPercentage:o(i/a*100),inPixels:i};r.mutableValues.prevSize=u,r.onResize(u,r.id,s)}(L,r,e)}})).observe(L.element),L.panels.forEach(e=>{u(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&i.observe(e.element)}),d=l({group:L}),p=s(L),c=L.panels.map(({id:e})=>e).join(","),(h=L.mutableState.defaultLayout)&&(function(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}(L.panels,h)||(h=void 0)),v=O({layout:L.mutableState.layouts[c]??h??et(p),panelConstraints:p}),b=L.element.ownerDocument,en.set(b,(en.get(b)??0)+1),y=new Map,g(L).forEach(e=>{e.separator&&y.set(e.separator,e.panels)}),x(L,{defaultLayoutDeferred:0===d,derivedPanelConstraints:p,groupSize:d,layout:v,separatorToPanels:y}),L.separators.forEach(e=>{u(!a.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),a.add(e.id),e.element.addEventListener("keydown",G)}),1===en.get(b)&&(b.addEventListener("dblclick",N,!0),b.addEventListener("pointerdown",V,!0),b.addEventListener("pointerleave",J),b.addEventListener("pointermove",Q),b.addEventListener("pointerout",Z),b.addEventListener("pointerup",ee,!0)),function(){t=!1,en.set(b,Math.max(0,(en.get(b)??0)-1)),(m=new Map(m)).delete(L),L.separators.forEach(e=>{e.element.removeEventListener("keydown",G)}),en.get(b)||(b.removeEventListener("dblclick",N,!0),b.removeEventListener("pointerdown",V,!0),b.removeEventListener("pointerleave",J),b.removeEventListener("pointermove",Q),b.removeEventListener("pointerout",Z),b.removeEventListener("pointerup",ee,!0)),i.disconnect()}),{defaultLayoutDeferred:E,derivedPanelConstraints:F,layout:A}=z(L.id,!0);!E&&F.length>0&&(k(A),D(A));let $=S(T,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:r}=e.next;if(t||0===n.length)return;let a=L.panels.map(({id:e})=>e).join(",");L.mutableState.layouts[a]=r,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=M(t.collapsedSize,r[t.panelId]),a=M(t.collapsedSize,n[t.panelId]);e&&!a&&(L.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let i="active"!==B.state;k(r),i&&D(r)});return()=>{K.current=null,R(),$()}},[f,T,D,k,w,F,Y]),(0,a.useEffect)(()=>{let e=K.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!i)}),(0,r.jsx)(es.Provider,{value:_,children:(0,r.jsx)("div",{...L,className:t,"data-group":!0,"data-testid":T,id:T,ref:H,style:{height:"100%",width:"100%",overflow:"hidden",...P,display:"flex",flexDirection:"horizontal"===w?"row":"column",flexWrap:"nowrap",touchAction:"horizontal"===w?"pan-y":"pan-x"},children:e})})}function ed(){let e=(0,a.useContext)(es);return u(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function ef({children:e,className:t,collapsedSize:n="0%",collapsible:i=!1,defaultSize:o,disabled:l,elementRef:s,groupResizeBehavior:u="preserve-relative-size",id:d,maxSize:f="100%",minSize:p="0%",onResize:c,panelRef:h,style:g,...v}){let m,b=!!d,y=er(d),z=el({disabled:l}),x=(0,a.useRef)(null),w=eo(x,s),{getPanelStyles:C,id:P,orientation:L,registerPanel:R,updatePanelProps:E}=ed(),M=null!==c,k=ei((e,t,n)=>{c?.(e,d,n)});ea(()=>{let e=x.current;if(null!==e)return R({element:e,id:y,idIsStable:b,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:M?k:void 0,panelConstraints:{groupResizeBehavior:u,collapsedSize:n,collapsible:i,defaultSize:o,disabled:z.disabled,maxSize:f,minSize:p}})},[u,n,i,o,M,y,b,f,p,k,R,z]),(0,a.useEffect)(()=>{E(y,{disabled:l})},[l,y,E]),function(e,t){let{id:n}=ed(),r=(0,a.useRef)({collapse:U,expand:U,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:U});(0,a.useImperativeHandle)(t,()=>r.current,[]),ea(()=>{Object.assign(r.current,j({groupId:n,panelId:e}))})}(y,h);let D=()=>{let e=C(P,y);if(e)return JSON.stringify(e)},T=(0,a.useSyncExternalStore)(e=>S(P,e),D,D);return m=T?JSON.parse(T):void 0!==o?{flexGrow:void 0,flexShrink:void 0,flexBasis:o}:{flexGrow:1},(0,r.jsx)("div",{...v,"data-disabled":l||void 0,"data-panel":!0,"data-testid":y,id:y,ref:w,style:{...ep,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...m},children:(0,r.jsx)("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...g,touchAction:"horizontal"===L?"pan-y":"pan-x"},children:e})})}eu.displayName="Group",ef.displayName="Panel";let ep={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function ec({children:e,className:t,disabled:n,disableDoubleClick:i,elementRef:o,id:l,style:s,...u}){let d,f,p=er(l),c=el({disabled:n,disableDoubleClick:i}),[h,g]=(0,a.useState)({}),[v,m]=(0,a.useState)("inactive"),[b,y]=(0,a.useState)(!1),z=(0,a.useRef)(null),x=eo(z,o),{disableCursor:w,id:C,orientation:P,registerSeparator:L,updateSeparatorProps:R}=ed();return ea(()=>{let e=z.current;if(null!==e){var t;let n={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:e,id:p},r=L(n),a=(t=e=>{m("inactive"!==e.next.state&&e.next.hitRegions.some(e=>e.separator===n)?e.next.state:"inactive")},W.addListener("change",t)),i=S(C,e=>{let{derivedPanelConstraints:t,layout:r,separatorToPanels:a}=e.next,i=a.get(n);if(i){let e=i[0],n=i.indexOf(e);g(function({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let a,i,o=e[n],l=t.find(e=>e.panelId===n);if(l){let s=l.maxSize,u=l.collapsible?l.collapsedSize:l.minSize,d=[r,r+1];i=O({layout:T({delta:u-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n],a=O({layout:T({delta:s-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:a,valueMin:i,valueNow:o}}({layout:r,panelConstraints:t,panelId:e.id,panelIndex:n}))}});return()=>{a(),i(),r()}}},[C,p,L,c]),(0,a.useEffect)(()=>{R(p,{disabled:n,disableDoubleClick:i})},[n,i,p,R]),n&&!w&&(d="not-allowed"),f=n?"disabled":"active"===v?"active":b?"focus":v,(0,r.jsx)("div",{...u,"aria-controls":h.valueControls,"aria-disabled":n||void 0,"aria-orientation":"horizontal"===P?"vertical":"horizontal","aria-valuemax":h.valueMax,"aria-valuemin":h.valueMin,"aria-valuenow":h.valueNow,children:e,className:t,"data-separator":f,"data-testid":p,id:p,onBlur:()=>y(!1),onFocus:()=>y(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:d,...s,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}ec.displayName="Separator";var eh=e.i(613349);e.s(["ResizableHandle",0,function({withHandle:e,className:t,...n}){return(0,r.jsx)(ec,{"data-slot":"resizable-handle",className:(0,eh.cn)("relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&(0,r.jsx)("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"})})},"ResizablePanel",0,function({...e}){return(0,r.jsx)(ef,{"data-slot":"resizable-panel",...e})},"ResizablePanelGroup",0,function({className:e,...t}){return(0,r.jsx)(eu,{"data-slot":"resizable-panel-group",className:(0,eh.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}],888917)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,222862,636557,e=>{"use strict";var t=e.i(811374);class n extends Error{status;details;constructor(e,t,n){super(e),this.name="ApiError",this.status=t,this.details=n}get isNetworkError(){return 0===this.status}get isRateLimit(){return 429===this.status}get isUnauthorized(){return 401===this.status}}function a(e,t){return"validation error"===e&&t?.length?function(e){let[t,...n]=e.split(":"),a=n.join(":").trim();if(!a)return e;let r=t.trim(),i=r.trim().replace(/[_-]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()),s=a.replace(/^required$/i,"is required"),o=s.toLowerCase().replace(/[_-]+/g," "),c=r.toLowerCase().replace(/[_-]+/g," ");return c&&o.startsWith(`${c} `)&&(s=s.slice(r.length).trimStart()),i?`${i} ${s}`:s}(t[0]):e}async function r(e,t){let r;try{r=await fetch(""+e,{...t,credentials:"include",headers:{"Content-Type":"application/json",...t?.headers}})}catch(e){if(e instanceof TypeError)throw new n("Unable to connect — check your network",0);throw e}if(401===r.status)throw window.location.href="/sign-in",new n("Unauthorized",401);if(!r.ok){let e,t;try{let n=await r.json();e=n.error,t=n.details}catch{}if(429===r.status)throw new n("Please wait a moment before trying again",429);if(r.status>=500)throw new n(a(e,t)||"Something went wrong — please try again",r.status,t);throw new n(a(e,t)||"Something went wrong",r.status,t)}if(204!==r.status)return r.json()}function i(e,t){let n=new URLSearchParams({workspace_id:e,...t});return`?${n.toString()}`}e.s(["ApiError",0,n],636557),parseInt(t.default.env.NEXT_PUBLIC_MOCK_NETWORK_DELAY_MS||"300",10);let s=async(e,t,a,s,o)=>{let c;if(!s||0===s.length)return r(`/api/conversations/${e}/messages${i(a)}`,{method:"POST",body:JSON.stringify({content:t,...o?{metadata:o}:{}})});let l=new FormData;for(let e of(l.append("content",t),o&&l.append("metadata",JSON.stringify(o)),s))l.append("file",e);try{c=await fetch(`/api/conversations/${e}/messages${i(a)}`,{method:"POST",credentials:"include",body:l})}catch(e){if(e instanceof TypeError)throw new n("Unable to connect — check your network",0);throw e}if(401===c.status)throw window.location.href="/sign-in",new n("Unauthorized",401);if(!c.ok){let e,t;try{let n=await c.json();e=n.error,t=n.details}catch{}if(429===c.status)throw new n("Please wait a moment before trying again",429);if(c.status>=500)throw new n(e||"Something went wrong — please try again",c.status,t);throw new n(e||"Something went wrong",c.status,t)}return c.json()},o=async(e,t)=>{let n=new URLSearchParams({workspace_id:t}),a=await fetch(`/api/email/${e}/body?${n}`,{credentials:"include"});if(!a.ok)return{content:"(body not available)",isHtml:!1};let r=a.headers.get("Content-Type")??"";return{content:await a.text(),isHtml:r.includes("text/html")}},c=async(e,t)=>{let a=new FormData;a.append("file",e);let r=await fetch(`/api/email/upload${i(t)}`,{method:"POST",credentials:"include",body:a});if(!r.ok)throw new n(await r.text().catch(()=>"Upload failed"),r.status);return r.json()},l=async(e,t)=>{let a;if(!t.files||0===t.files.length)return r(`/api/issues${i(e)}`,{method:"POST",body:JSON.stringify({agent_id:t.agent_id,title:t.title,description:t.description})});let s=new FormData;for(let e of(t.agent_id&&s.append("agent_id",t.agent_id),s.append("title",t.title),s.append("description",t.description??""),t.files))s.append("file",e);try{a=await fetch(`/api/issues${i(e)}`,{method:"POST",credentials:"include",body:s})}catch(e){if(e instanceof TypeError)throw new n("Unable to connect — check your network",0);throw e}if(401===a.status)throw window.location.href="/sign-in",new n("Unauthorized",401);if(!a.ok){let e,t;try{let n=await a.json();e=n.error,t=n.details}catch{}if(429===a.status)throw new n("Please wait a moment before trying again",429);if(a.status>=500)throw new n(e||"Something went wrong — please try again",a.status,t);throw new n(e||"Something went wrong",a.status,t)}return a.json()},u=async(e,t)=>{let n=new URLSearchParams({workspace_id:t}),a=await fetch(`/api/artifacts/${e}/content?${n}`,{credentials:"include"});return a.ok?a.text():"(content not available)"};e.s(["acceptInvite",0,e=>r(`/api/invite/${e}`,{method:"POST"}),"addWhitelistEmail",0,(e,t,n)=>r(`/api/agents/${e}/whitelist${i(n)}`,{method:"POST",body:JSON.stringify({email:t})}),"approveMeeting",0,(e,t,n)=>r(`/api/agents/${e}/meetings/${t}/approve${i(n)}`,{method:"POST"}),"cancelActiveTask",0,(e,t)=>r(`/api/conversations/${e}/active-task${i(t)}`,{method:"DELETE"}),"chatInit",0,(e,t,n)=>r(`/api/agents/${e}/chat-init${i(t)}`,{method:"POST",body:JSON.stringify({...n?{channel:n}:{}})}),"checkFreshness",0,(e,t)=>{let n={};return e.conversationId&&(n.conversation_id=e.conversationId),e.agentId&&(n.agent_id=e.agentId),e.channel&&(n.channel=e.channel),r(`/api/conversations/check-fresh${i(t,n)}`)},"conversationInit",0,(e,t,n)=>{let a={};return n?.newestMessageId&&(a.newest_message_id=n.newestMessageId),n?.messageCount&&(a.message_count=String(n.messageCount)),r(`/api/conversations/${e}/init${i(t,a)}`)},"createAgent",0,(e,t)=>r(`/api/agents${i(t)}`,{method:"POST",body:JSON.stringify(e)}),"createAgentLink",0,(e,t)=>r(`/api/agent-links${i(t)}`,{method:"POST",body:JSON.stringify(e)}),"createCalendarEvent",0,(e,t)=>r(`/api/calendar${i(t)}`,{method:"POST",body:JSON.stringify(e)}),"createChannelApi",0,(e,t)=>r(`/api/channels${i(e)}`,{method:"POST",body:JSON.stringify({name:t})}),"createConversation",0,(e,t,n)=>r(`/api/conversations${i(t)}`,{method:"POST",body:JSON.stringify({agent_id:e,...n?{channel:n}:{}})}),"createEmailAccount",0,(e,t,n)=>r(`/api/agents/${e}/email-accounts${i(n)}`,{method:"POST",body:JSON.stringify(t)}),"createInvite",0,e=>r(`/api/workspaces/${e}/invites${i(e)}`,{method:"POST"}),"createIssue",0,l,"createMachineToken",0,(e,t)=>r(`/api/machine-tokens${t?i(t):""}`,{method:"POST",body:JSON.stringify({name:e||"default"})}),"createMeeting",0,(e,t,n)=>r(`/api/agents/${e}/meetings${i(t)}`,{method:"POST",body:JSON.stringify(n)}),"createThread",0,(e,t,n,a)=>r(`/api/conversations/${e}/threads${i(a)}`,{method:"POST",body:JSON.stringify({parent_message_id:t,content:n})}),"deleteAgent",0,(e,t)=>r(`/api/agents/${e}${i(t)}`,{method:"DELETE"}),"deleteAgentLink",0,(e,t)=>r(`/api/agent-links/${e}${i(t)}`,{method:"DELETE"}),"deleteCalendarEvent",0,(e,t,n)=>r(`/api/calendar/${e}${i(t)}`,{method:"DELETE",...n&&n.scope?{headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}:{}}),"deleteChannelApi",0,(e,t)=>r(`/api/channels/${e}${i(t)}`,{method:"DELETE"}),"deleteEmail",0,(e,t)=>r(`/api/email/${e}${i(t)}`,{method:"DELETE"}),"deleteEmailAccount",0,(e,t,n)=>r(`/api/agents/${e}/email-accounts/${t}${i(n)}`,{method:"DELETE"}),"deleteIssue",0,(e,t)=>r(`/api/issues/${t}${i(e)}`,{method:"DELETE"}),"deleteMachine",0,(e,t)=>r(`/api/runtimes/machine${i(t,{daemon_id:e})}`,{method:"DELETE"}),"deleteMeeting",0,(e,t,n)=>r(`/api/agents/${e}/meetings/${t}${i(n)}`,{method:"DELETE"}),"deleteWorkspace",0,(e,t)=>r(`/api/workspaces/${e}${i(e)}`,{method:"DELETE",body:JSON.stringify({confirm_name:t})}),"fetchLatestCliVersion",0,()=>r("/api/cli/latest-version"),"fetchModelOptions",0,()=>r("/api/config/model-options"),"flagMessage",0,(e,t)=>r(`/api/flags${i(e)}`,{method:"POST",body:JSON.stringify({messageId:t})}),"getActiveTask",0,(e,t)=>r(`/api/conversations/${e}/active-task${i(t)}`),"getAgentSkills",0,(e,t)=>r(`/api/agents/${e}/skills${i(t)}`),"getArtifactContent",0,u,"getCalendarEvent",0,(e,t)=>r(`/api/calendar/${e}${i(t)}`),"getEmail",0,(e,t)=>r(`/api/email/${e}${i(t)}`),"getEmailBody",0,o,"getEmailThread",0,(e,t)=>r(`/api/email/${e}/thread${i(t)}`),"getFlaggedCount",0,e=>r(`/api/flags/count${i(e)}`),"getInboxCount",0,(e,t)=>{let n={};return t?.types?.length&&(n.types=t.types.join(",")),r(`/api/inbox/count${i(e,n)}`)},"getInviteInfo",0,e=>r(`/api/invite/${e}`),"getIssue",0,(e,t)=>r(`/api/issues/${t}${i(e)}`),"getMachineTokenStatus",0,()=>r("/api/machine-tokens/status"),"getMemberMe",0,e=>r(`/api/members/me${i(e)}`),"getMinCliVersion",0,()=>r("/api/config/min-version"),"getTask",0,(e,t)=>r(`/api/tasks/${e}${i(t)}`),"getTaskMessages",0,(e,t,n)=>r(`/api/tasks/${e}/messages${i(t,n?{since:String(n)}:void 0)}`),"getThreadSummaries",0,(e,t)=>r(`/api/conversations/${e}/threads${i(t)}`),"getTrace",0,(e,t)=>r(`/api/traces/${e}${i(t)}`),"getWorkspaceOverview",0,e=>r(`/api/workspaces/${e}/overview${i(e)}`),"grantAgentAccess",0,(e,t,n)=>r(`/api/agents/${t}/access${i(e)}`,{method:"POST",body:JSON.stringify({user_id:n})}),"listAgentAccess",0,(e,t)=>r(`/api/agents/${t}/access${i(e)}`),"listAgentActiveTaskCounts",0,e=>r(`/api/agents/active-task-counts${i(e)}`),"listAgentActivity",0,(e,t,n)=>{let a={};return n?.limit&&(a.limit=String(n.limit)),n?.before&&(a.before=n.before),n?.beforeId&&(a.before_id=n.beforeId),n?.status&&(a.status=n.status),n?.type&&(a.type=n.type),r(`/api/agents/${e}/activity${i(t,a)}`)},"listAgentLinks",0,e=>r(`/api/agent-links${i(e)}`),"listAgentPins",0,e=>r(`/api/agents/pins${i(e)}`),"listAgents",0,e=>r(`/api/agents${i(e)}`),"listArtifacts",0,(e,t)=>r(`/api/artifacts${i(t,{conversation_id:e})}`),"listCalendarEvents",0,(e,t)=>{let n={};return t?.agentId&&(n.agentId=t.agentId),t?.from&&(n.from=t.from),t?.to&&(n.to=t.to),r(`/api/calendar${i(e,n)}`)},"listChannels",0,e=>r(`/api/channels${i(e)}`),"listEmailAccounts",0,(e,t)=>r(`/api/agents/${e}/email-accounts${i(t)}`),"listEmails",0,(e,t,n,a)=>r(`/api/email${i(t,{agentId:e,...n?{folder:n}:{},...a?{address:a}:{}})}`),"listFlaggedItems",0,(e,t)=>{let n={};return t?.limit&&(n.limit=String(t.limit)),t?.before&&(n.before=t.before),r(`/api/flags${i(e,n)}`)},"listFlaggedMessageIds",0,(e,t)=>r(`/api/flags${i(e,{conversation_id:t,ids_only:"true"})}`),"listInboxItems",0,(e,t)=>{let n={};return t?.limit&&(n.limit=String(t.limit)),t?.before&&(n.before=t.before),t?.types?.length&&(n.types=t.types.join(",")),r(`/api/inbox${i(e,n)}`)},"listInvites",0,e=>r(`/api/workspaces/${e}/invites${i(e)}`),"listIssues",0,(e,t)=>{let n={};return t?.agentId&&(n.agentId=t.agentId),t?.status&&(n.status=t.status),t?.terminal!==void 0&&(n.terminal=String(t.terminal)),r(`/api/issues${i(e,n)}`)},"listMeetings",0,(e,t)=>r(`/api/agents/${e}/meetings${i(t)}`),"listMembers",0,e=>r(`/api/workspaces/${e}/members${i(e)}`),"listMessages",0,(e,t,n)=>{let a={};return n?.limit&&(a.limit=String(n.limit)),n?.before&&(a.before=n.before),n?.beforeId&&(a.before_id=n.beforeId),r(`/api/conversations/${e}/messages${i(t,a)}`)},"listMessagesAroundTask",0,(e,t,n)=>r(`/api/conversations/${e}/messages${i(t,{around_task:n})}`),"listPreviousConversations",0,(e,t,n)=>{let a={exclude:n.exclude,before:n.before};return n.channel&&(a.channel=n.channel),n.limit&&(a.limit=String(n.limit)),r(`/api/agents/${e}/conversations${i(t,a)}`)},"listRuntimes",0,e=>r(`/api/runtimes${i(e)}`),"listTraces",0,(e,t)=>{let n={};return t?.limit&&(n.limit=String(t.limit)),t?.before&&(n.before=t.before),t?.status&&(n.status=t.status),t?.multiAgent&&(n.multiAgent="true"),t?.agentId&&(n.agentId=t.agentId),t?.channel&&(n.channel=t.channel),r(`/api/traces${i(e,n)}`)},"listWhitelist",0,(e,t)=>r(`/api/agents/${e}/whitelist${i(t)}`),"listWorkspaceActiveTasks",0,e=>r(`/api/agents/active-tasks${i(e)}`),"listWorkspaces",0,()=>r("/api/workspaces"),"markAllInboxRead",0,e=>r(`/api/inbox/read-all${i(e)}`,{method:"POST"}),"markInboxRead",0,(e,t)=>r(`/api/inbox/read${i(t)}`,{method:"POST",body:JSON.stringify({conversationId:e})}),"pinAgent",0,(e,t)=>r(`/api/agents/${t}/pin${i(e)}`,{method:"POST"}),"removeMember",0,(e,t)=>r(`/api/workspaces/${e}/members/${t}${i(e)}`,{method:"DELETE"}),"removeWhitelistEmail",0,(e,t,n)=>r(`/api/agents/${e}/whitelist/${t}${i(n)}`,{method:"DELETE"}),"renameChannelApi",0,(e,t,n)=>r(`/api/channels/${e}${i(t)}`,{method:"PATCH",body:JSON.stringify({name:n})}),"reorderAgentPins",0,(e,t)=>r(`/api/agents/pins/reorder${i(e)}`,{method:"PUT",body:JSON.stringify({ordered_agent_ids:t})}),"reorderChannelsApi",0,(e,t)=>r(`/api/channels/reorder${i(e)}`,{method:"PUT",body:JSON.stringify({ordered_channel_ids:t})}),"reorderUnpinnedAgents",0,(e,t)=>r(`/api/agents/sidebar/reorder${i(e)}`,{method:"PUT",body:JSON.stringify({ordered_agent_ids:t})}),"requestWorkspaceBrowse",0,(e,t,n,a)=>r(`/api/agents/${e}/workspace/browse${i(t)}`,{method:"POST",body:JSON.stringify({request_type:n,path:a})}),"retryTask",0,(e,t)=>r(`/api/tasks/${e}/retry${i(t)}`,{method:"POST"}),"revokeAgentAccess",0,(e,t,n,a=!1)=>r(`/api/agents/${t}/access/${n}${i(e)}${a?"&remove_whitelist=true":""}`,{method:"DELETE"}),"revokeInvite",0,(e,t)=>r(`/api/workspaces/${e}/invites/${t}${i(e)}`,{method:"DELETE"}),"sendEmail",0,(e,t,n,a,s,o,c,l)=>r(`/api/email/send${i(s)}`,{method:"POST",body:JSON.stringify({agentId:e,to:t,subject:n,htmlBody:a,attachments:o,...c,customAccountId:l})}),"sendMessage",0,s,"stopMeeting",0,(e,t,n)=>r(`/api/agents/${e}/meetings/${t}/stop${i(n)}`,{method:"POST"}),"syncEmailAccount",0,(e,t,n)=>r(`/api/agents/${e}/email-accounts/${t}/sync${i(n)}`,{method:"POST"}),"triggerRuntimeRescan",0,(e,t)=>r(`/api/runtimes/${e}/rescan${i(t)}`,{method:"POST"}),"triggerRuntimeUpdate",0,(e,t)=>r(`/api/runtimes/${e}/update${i(t)}`,{method:"POST"}),"unflagMessage",0,(e,t)=>r(`/api/flags/${t}${i(e)}`,{method:"DELETE"}),"unpinAgent",0,(e,t)=>r(`/api/agents/${t}/pin${i(e)}`,{method:"DELETE"}),"updateAgent",0,(e,t,n)=>r(`/api/agents/${e}${i(n)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateAgentLink",0,(e,t,n)=>r(`/api/agent-links/${e}${i(n)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateCalendarEvent",0,(e,t,n)=>r(`/api/calendar/${e}${i(n)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateEmailStatus",0,(e,t,n)=>r(`/api/email/${e}${i(t)}`,{method:"PATCH",body:JSON.stringify({status:n})}),"updateIssue",0,(e,t,n)=>r(`/api/issues/${t}${i(e)}`,{method:"PATCH",body:JSON.stringify(n)}),"updateMemberMe",0,(e,t)=>r(`/api/members/me${i(e)}`,{method:"PATCH",body:JSON.stringify({global_instruction:t})}),"updateWorkspace",0,(e,t)=>r(`/api/workspaces/${e}${i(e)}`,{method:"PATCH",body:JSON.stringify(t)}),"uploadEmailAttachment",0,c],222862)},500324,e=>{"use strict";var t=e.i(653772),n=e.i(511043);let a=(0,n.createContext)(null);e.s(["WorkspaceProvider",0,function({workspaceId:e,slug:r,children:i}){return(0,n.useEffect)(()=>{try{localStorage.setItem("lastWorkspace",r)}catch{}},[r]),(0,t.jsx)(a.Provider,{value:{workspaceId:e,slug:r},children:i})},"useWorkspace",0,function(){let e=(0,n.useContext)(a);if(!e)throw Error("useWorkspace must be used within WorkspaceProvider");return e}])},642342,e=>{"use strict";var t=e.i(811374),n=e.i(511043);let a=(0,e.i(613349).isLocalMode)(),r=Number(t.default.env.NEXT_PUBLIC_WS_DO_PORT)||8789,i=Number(t.default.env.NEXT_PUBLIC_WS_RECONNECT_DELAY_MS)||1e3,s=Number(t.default.env.NEXT_PUBLIC_WS_RECONNECT_MAX_DELAY_MS)||3e4;e.s(["useUserWs",0,function(e,t){let o=(0,n.useRef)(null),c=(0,n.useRef)(i),l=(0,n.useRef)(e),u=(0,n.useRef)(t?.onReconnect),d=(0,n.useRef)(null),g=(0,n.useRef)(!1),p=(0,n.useRef)(0),f=(0,n.useRef)(null),m=(0,n.useRef)(null);(0,n.useEffect)(()=>{l.current=e},[e]),(0,n.useEffect)(()=>{u.current=t?.onReconnect},[t?.onReconnect]);let h=(0,n.useRef)(null),$=(0,n.useCallback)(()=>{let e=Math.min(c.current,s);c.current=Math.min(2*e,s),d.current=setTimeout(()=>{h.current?.()},e+500*Math.random())},[]),y=(0,n.useCallback)(async()=>{let e,t,n,s=r;try{let n=await fetch("/api/ws/token");if(!n.ok){console.warn("[ws] token fetch failed:",n.status),$();return}let a=await n.json();e=a.userId,t=a.token,a.wsPort&&(s=a.wsPort)}catch(e){console.warn("[ws] token fetch error:",e),$();return}let d=a?`ws://localhost:${s}/?userId=${e}`:`${location.origin.replace("http","ws")}/api/ws/user?userId=${e}`;try{n=new WebSocket(d)}catch(e){console.warn("[ws] WebSocket creation failed:",e),$();return}o.current=n,n.onopen=()=>{c.current=i,n.send(JSON.stringify({type:"auth",token:t})),g.current&&u.current?.(),g.current=!0,p.current=Date.now(),f.current=setInterval(()=>{n.readyState===WebSocket.OPEN&&n.send("ping")},25e3),m.current=setInterval(()=>{Date.now()-p.current>3e4&&n.close()},5e3)},n.onmessage=e=>{p.current=Date.now();try{let t=JSON.parse(e.data);if("auth.ok"===t.type)return void n.send(JSON.stringify({type:"check_daemon_status"}));l.current(t)}catch{}},n.onerror=()=>{},n.onclose=()=>{n===o.current&&(f.current&&(clearInterval(f.current),f.current=null),m.current&&(clearInterval(m.current),m.current=null),$())}},[$]);return(0,n.useEffect)(()=>{h.current=y},[y]),(0,n.useEffect)(()=>(y(),()=>{null!==d.current&&(clearTimeout(d.current),d.current=null),f.current&&(clearInterval(f.current),f.current=null),m.current&&(clearInterval(m.current),m.current=null);let e=o.current;o.current=null,e?.close()}),[y]),{send:(0,n.useCallback)(e=>{let t=o.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[])}}])},355578,e=>{"use strict";var t=e.i(653772),n=e.i(511043),a=e.i(222862),r=e.i(516266),i=e.i(642342);let s=(0,n.createContext)(null);e.s(["AgentProvider",0,function({workspaceId:e,children:o}){let[c,l]=(0,n.useState)([]),[u,d]=(0,n.useState)([]),[g,p]=(0,n.useState)(!0),[f,m]=(0,n.useState)({}),[h,$]=(0,n.useState)([]),y=(0,n.useRef)(!1),[w,b]=(0,n.useState)([]),[k,S]=(0,n.useState)(null),E=(0,n.useCallback)(()=>S(null),[]),[v,T]=(0,n.useState)(new Map),[O,I]=(0,n.useState)(new Map),_=(0,n.useRef)(!1),C=(0,n.useRef)(new Set),A=(0,n.useRef)(new Set),N=(0,n.useRef)(!0),P=(0,n.useRef)(!1),M=(0,n.useCallback)(e=>(C.current.add(e),()=>{C.current.delete(e)}),[]),L=(0,n.useCallback)(e=>(A.current.add(e),()=>{A.current.delete(e)}),[]),R=(0,n.useRef)(!1),J=(0,n.useCallback)(async()=>{if(!R.current){R.current=!0;try{if(y.current){let t=await (0,a.listWorkspaceActiveTasks)(e);if(!N.current)return;$(t.tasks);let n={};for(let e of t.tasks)n[e.agent_id]=(n[e.agent_id]??0)+1;m(n),y.current=t.tasks.length>0}else{let t=await (0,a.listAgentActiveTaskCounts)(e);if(!N.current)return;if(m(t.counts),Object.values(t.counts).some(e=>e>0)){y.current=!0;let t=await (0,a.listWorkspaceActiveTasks)(e);N.current&&$(t.tasks)}else $([])}}catch{}finally{R.current=!1}}},[e]);(0,n.useEffect)(()=>{N.current=!0,J();let e=setInterval(J,15e3);return()=>{N.current=!1,clearInterval(e)}},[J]);let x=(0,n.useCallback)(async()=>{try{let[t,n,r,i]=await Promise.all([(0,a.listAgents)(e),(0,a.listRuntimes)(e),(0,a.listAgentPins)(e),(0,a.listAgentLinks)(e)]);l(t),d(n),b(i),T(new Map(r.pins.map(e=>[e.agent_id,{created_at:e.created_at,position:e.position}]))),I(new Map(r.sidebar_order.map(e=>[e.agent_id,e.position])))}catch(e){r.toast.error(e instanceof Error?e.message:"Failed to load data")}finally{p(!1),_.current=!0}},[e]),D=(0,n.useCallback)(async()=>{if(!P.current){P.current=!0;try{let t=await (0,a.listRuntimes)(e);d(t)}catch{}finally{P.current=!1}}},[e]);(0,n.useEffect)(()=>{x()},[x]),(0,n.useEffect)(()=>{let e=null,t=setInterval(()=>{"visible"===document.visibilityState&&D()},3e4),n=()=>{"visible"===document.visibilityState&&(e=setTimeout(()=>D(),2e3*Math.random()))};return document.addEventListener("visibilitychange",n),()=>{clearInterval(t),e&&clearTimeout(e),document.removeEventListener("visibilitychange",n)}},[D]);let W=(0,n.useCallback)(t=>{for(let e of C.current)e(t);switch(t.type){case"runtime.registered":if(t.workspaceId!==e)break;x();break;case"runtime.deleted":x();break;case"runtime.status":if(t.workspaceId!==e)break;D();break;case"agent.created":if(t.workspaceId!==e)break;S({agentId:t.agentId,parentAgentId:t.parentAgentId}),x();break;case"task.updated":J()}},[x,D,J,e]),U=(0,n.useCallback)(()=>{for(let e of(D(),A.current))e()},[D]);(0,i.useUserWs)(W,{onReconnect:U});let F=(0,n.useCallback)(async t=>{try{let n=await (0,a.createAgent)(t,e);return await x(),n}catch(e){return r.toast.error(e instanceof Error?e.message:"Failed to create agent"),null}},[x,e]),j=(0,n.useCallback)(async(t,n)=>{try{return await (0,a.updateAgent)(t,n,e),await x(),!0}catch(e){return r.toast.error(e instanceof Error?e.message:"Failed to update agent"),!1}},[x,e]),B=(0,n.useCallback)(async t=>{try{return await (0,a.deleteAgent)(t,e),await x(),!0}catch(e){return r.toast.error(e instanceof Error?e.message:"Failed to remove agent"),!1}},[x,e]),H=(0,n.useCallback)(async t=>{T(e=>{let n=Math.max(-1,...[...e.values()].map(e=>e.position));return new Map(e).set(t,{created_at:new Date().toISOString(),position:n+1})});try{await (0,a.pinAgent)(e,t)}catch{T(e=>{let n=new Map(e);return n.delete(t),n}),r.toast.error("Failed to pin agent")}},[e]),X=(0,n.useCallback)(async t=>{let n;T(e=>{n=e.get(t);let a=new Map(e);return a.delete(t),a});try{await (0,a.unpinAgent)(e,t)}catch{void 0!==n&&T(e=>new Map(e).set(t,n)),r.toast.error("Failed to unpin agent")}},[e]),q=(0,n.useCallback)(async t=>{let n=new Map(v);T(e=>{let n=new Map(e);return t.forEach((e,t)=>{let a=n.get(e);a&&n.set(e,{...a,position:t})}),n});try{await (0,a.reorderAgentPins)(e,t)}catch{T(n),r.toast.error("Failed to reorder pins")}},[e,v]),Y=(0,n.useCallback)(async t=>{let n=new Map(O);I(new Map(t.map((e,t)=>[e,t])));try{await (0,a.reorderUnpinnedAgents)(e,t)}catch{I(n),r.toast.error("Failed to reorder agents")}},[e,O]),z=(0,n.useCallback)(()=>{let e=u.find(e=>"online"===e.status);return e?.id??""},[u]),K=(0,n.useCallback)(async()=>{try{return(await (0,a.createMachineToken)("cli",e)).token}catch(e){return r.toast.error(e instanceof Error?e.message:"Failed to generate token"),null}},[e]),V=(0,n.useCallback)(async t=>{try{return await (0,a.deleteMachine)(t,e),await x(),!0}catch(e){return r.toast.error(e instanceof Error?e.message:"Failed to remove machine"),!1}},[x,e]);return(0,t.jsx)(s.Provider,{value:{workspaceId:e,agents:c,agentLinks:w,runtimes:u,loading:g,activeTaskCounts:f,activeTaskDetails:h,pendingNewAgent:k,clearPendingNewAgent:E,pins:v,reload:x,subscribeWs:M,subscribeReconnect:L,handleCreateAgent:F,handleUpdateAgent:j,handleDeleteAgent:B,handlePinAgent:H,handleUnpinAgent:X,handleReorderPins:q,unpinnedOrder:O,handleReorderUnpinned:Y,getFirstOnlineRuntimeId:z,handleGenerateToken:K,handleDeleteMachine:V},children:o})},"useAgentContext",0,function(){let e=(0,n.useContext)(s);if(!e)throw Error("useAgentContext must be used within AgentProvider");return e},"useAgentContextSafe",0,function(){return(0,n.useContext)(s)}])},899746,e=>{"use strict";let t="browser-notification-enabled",n="browser-notification-events",a=["completed","failed"],r={completed:"Task Completed",failed:"Task Failed"};function i(){return"Notification"in window}function s(){return"true"===localStorage.getItem(t)}function o(){try{let e=localStorage.getItem(n);if(e)return JSON.parse(e)}catch{}return[...a]}async function c(){return!!i()&&("granted"===Notification.permission||"denied"!==Notification.permission&&"granted"===await Notification.requestPermission())}e.s(["NOTIFICATION_EVENTS",0,a,"NOTIFICATION_EVENT_LABELS",0,r,"getNotificationEnabled",0,s,"getNotificationEvents",0,o,"isNotificationSupported",0,i,"requestNotificationPermission",0,c,"sendTaskNotification",0,function(e,t,n){if(!i()||"granted"!==Notification.permission||!s()||!o().includes(e))return;let a=r[e]??`Task ${e}`;new Notification(t?`${t} — ${a}`:a,{body:n??"",icon:"/alook.svg"})},"setNotificationEnabled",0,function(e){localStorage.setItem(t,String(e))},"setNotificationEvents",0,function(e){localStorage.setItem(n,JSON.stringify(e))}])},875494,685835,e=>{"use strict";var t=e.i(653772),n=e.i(511043),a=e.i(222862),r=e.i(355578),i=e.i(500324),s=e.i(899746);let o="inbox-filter-types",c=["user_dm_message","calendar_event","email_notification"],l=["user_dm_message"],u=["user_dm_message"];function d(){try{let e=localStorage.getItem(o);if(!e)return l;let t=JSON.parse(e).filter(e=>c.includes(e));if(0===t.length)return l;for(let e of u)t.includes(e)||t.unshift(e);return t}catch{return l}}e.s(["INBOX_FILTER_LABELS",0,{user_dm_message:"DM",calendar_event:"Calendar",email_notification:"Email"},"INBOX_FILTER_TYPES",0,c,"MANDATORY_INBOX_TYPES",0,u,"getInboxFilterTypes",0,d,"setInboxFilterTypes",0,function(e){let t=[...e];for(let e of u)t.includes(e)||t.unshift(e);localStorage.setItem(o,JSON.stringify(t))}],685835);let g=(0,n.createContext)(null),p={count:0,notificationToken:0,refresh:()=>{},decrement:()=>{}};e.s(["InboxCountProvider",0,function({children:e}){let{workspaceId:o}=(0,i.useWorkspace)(),{subscribeWs:c,agents:l}=(0,r.useAgentContext)(),[u,p]=(0,n.useState)(0),[f,m]=(0,n.useState)(0),h=(0,n.useRef)(null),$=(0,n.useRef)(null),y=(0,n.useRef)(l);(0,n.useEffect)(()=>{y.current=l});let w=(0,n.useCallback)(()=>{let e=d();(0,a.getInboxCount)(o,{types:e}).then(e=>{let t=h.current;if(h.current=e.count,p(e.count),null!==t&&e.count>t){m(e=>e+1);let e=$.current?y.current.find(e=>e.id===$.current):void 0;(0,s.sendTaskNotification)("completed",e?.name)}$.current=null}).catch(()=>{})},[o]),b=(0,n.useCallback)(()=>{p(e=>Math.max(0,e-1))},[]);return(0,n.useEffect)(()=>{w()},[w]),(0,n.useEffect)(()=>c(e=>{"task.updated"===e.type&&("completed"===e.status||"failed"===e.status)&&($.current=e.agentId,w())}),[c,w]),(0,n.useEffect)(()=>{let e=setInterval(w,6e4);return()=>clearInterval(e)},[w]),(0,t.jsx)(g.Provider,{value:{count:u,notificationToken:f,refresh:w,decrement:b},children:e})},"useInboxCount",0,function(){return(0,n.useContext)(g)??p}],875494)},631822,e=>{e.v(t=>Promise.all(["static/chunks/3c9-pu4v167fy.js"].map(t=>e.l(t))).then(()=>t(70725)))}]);
@@ -1,3 +0,0 @@
1
- module.exports=[332432,e=>{"use strict";e.s(["buildEmailMapKey",0,function(e,t){return`email:${e}:${t}`},"extractThreadId",0,function(e,t,a){if(e){let t=e.trim().split(/\s+/)[0];if(t)return t}return t?t.trim():a?a.trim():null}])},397891,e=>{"use strict";var t=e.i(618117),a=e.i(99200),r=e.i(864055),i=e.i(289578),n=e.i(641783),s=e.i(467635),o=e.i(541774),d=e.i(393982),l=e.i(325959),c=e.i(474834),u=e.i(800989),p=e.i(489409),m=e.i(203050),I=e.i(851100),h=e.i(55434),w=e.i(193695);e.i(163438);var g=e.i(118649),f=e.i(931720);e.i(700598);var v=e.i(291109),E=e.i(704024),R=e.i(332432),T=e.i(888247),S=e.i(719436),y=e.i(675139),A=e.i(776227),C=e.i(205054),k=e.i(726089),b=e.i(740580),_=e.i(774078);async function N(e){let{env:t}=(0,f.getCloudflareContext)(),a=(0,y.getDb)(t.DB),[r,i]=await (0,A.parseBody)(e,T.EmailNotifyRequestSchema);if(i)return i;let n=await v.queries.agent.getAgent(a,r.agentId,r.workspaceId),s=await v.queries.email.createEmail(a,{agentId:r.agentId,workspaceId:r.workspaceId,fromEmail:r.from,toEmail:r.to??"",subject:r.subject,r2Key:r.r2Key,isWhitelisted:r.isWhitelisted,forwarded:r.forwarded,messageId:r.messageId,inReplyTo:r.inReplyTo,references:r.references,direction:"inbound",attachments:r.attachments});if(r.meetingInfo&&n){let e=r.meetingInfo;await v.queries.meetingSession.createMeetingSession(a,{agentId:r.agentId,workspaceId:r.workspaceId,title:e.title||r.subject,meetingUrl:e.meetingUrl,status:r.isWhitelisted?E.MeetingStatus.SCHEDULED:E.MeetingStatus.PENDING,fromEmail:r.from,isWhitelisted:r.isWhitelisted,participants:e.attendees.map(e=>e.email),scheduledAt:e.startTime})}let o=null;if(r.isWhitelisted&&n&&n.runtimeId&&n.ownerId){let e,t=(0,R.extractThreadId)(r.references,r.inReplyTo,r.messageId),i=t?(0,R.buildEmailMapKey)(n.id,t):null,d=E.TASK_TYPES.EMAIL_NOTIFICATION;if(i&&(o=await v.queries.conversationMap.findByKey(a,i,r.workspaceId)),o){let t=await v.queries.conversation.getConversation(a,o,r.workspaceId);if(t&&(d=t.type,t.type===E.TASK_TYPES.USER_DM_MESSAGE&&t.userId)){let r=await v.queries.user.getUser(a,t.userId);r&&(e={name:r.name,email:r.email})}}else{let e;if(r.sourceTaskId){let t=await v.queries.task.getTask(a,r.sourceTaskId,r.workspaceId);if(t){let i=await v.queries.conversation.getConversation(a,t.conversationId,r.workspaceId);i&&(e=i.channel)}}o=(await v.queries.conversation.createConversation(a,{workspaceId:n.workspaceId,agentId:n.id,userId:n.ownerId,title:`Email: ${r.subject}`.slice(0,50),type:E.TASK_TYPES.EMAIL_NOTIFICATION,...e&&"default"!==e?{channel:e}:{}})).id,i&&await v.queries.conversationMap.createMapping(a,{key:i,workspaceId:r.workspaceId,conversationId:o})}let l=`New email from ${r.from}: ${r.subject}`,c=r.isInternal&&r.senderConversationId&&r.senderAgentId!==r.agentId?{targetConversationId:r.senderConversationId,targetAgentId:r.senderAgentId}:{},u=JSON.stringify({emailId:s.id,subject:r.subject,from:r.from,to:r.to,direction:"inbound",...c}),p=await v.queries.message.createMessage(a,{conversationId:o,role:"event",content:l,metadata:u});d===E.TASK_TYPES.USER_DM_MESSAGE&&(0,k.broadcastToUser)(n.ownerId,{type:"conversation.message",conversationId:o,message:{id:p.id,conversation_id:p.conversationId,role:p.role,content:p.content,task_id:p.taskId,attachment_ids:null,metadata:{emailId:s.id,subject:r.subject,from:r.from,to:r.to,direction:"inbound"},created_at:p.createdAt}}).catch(()=>{});let m=new C.TaskService(a),I={conversationType:d};e&&(I.dmUser=e),r.isInternal&&(I.isInternal=!0),I.emailId=s.id;let h=r.traceId||"tr_"+(0,S.nanoid)(),w=r.traceId&&r.sourceTaskId||null,g=await m.enqueueTask(n.id,o,n.workspaceId,l,E.TASK_TYPES.EMAIL_NOTIFICATION,{contextKey:o,context:I,traceId:h,parentTaskId:w});v.queries.message.updateMessageTaskId(a,p.id,g.id).catch(()=>{}),d===E.TASK_TYPES.USER_DM_MESSAGE&&(0,k.broadcastToUser)(n.ownerId,{type:"task.created",conversationId:o,task:(0,b.taskToResponse)(g)}).catch(()=>{})}let d=new Date().toISOString().slice(0,10);return await Promise.all([(0,_.invalidate)(_.cacheKeys.overviewEmailStats(r.workspaceId)),(0,_.invalidate)(_.cacheKeys.overviewTaskStats(r.workspaceId,d))]),n?.ownerId&&(0,k.broadcastToUser)(n.ownerId,{type:"email.received",agentId:r.agentId}).catch(()=>{}),(0,A.writeJSON)({ok:!0,...o?{conversationId:o}:{}})}e.s(["POST",0,N],930700);var x=e.i(930700);let M=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/email/notify/route",pathname:"/api/email/notify",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/web/src/app/api/email/notify/route.ts",nextConfigOutput:"standalone",userland:x,...{}}),{workAsyncStorage:P,workUnitAsyncStorage:q,serverHooks:O}=M;async function U(e,t,r){r.requestMeta&&(0,i.setRequestMeta)(e,r.requestMeta),M.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let f="/api/email/notify/route";f=f.replace(/\/index$/,"")||"/";let v=await M.prepare(e,t,{srcPage:f,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:E,deploymentId:R,params:T,nextConfig:S,parsedUrl:y,isDraftMode:A,prerenderManifest:C,routerServerContext:k,isOnDemandRevalidate:b,revalidateOnlyGenerated:_,resolvedPathname:N,clientReferenceManifest:x,serverActionsManifest:P}=v,q=(0,o.normalizeAppPath)(f),O=!!(C.dynamicRoutes[q]||C.routes[N]),U=async()=>((null==k?void 0:k.render404)?await k.render404(e,t,y,!1):t.end("This page could not be found"),null);if(O&&!A){let e=!!C.routes[N],t=C.dynamicRoutes[q];if(t&&!1===t.fallback&&!e){if(S.adapterPath)return await U();throw new w.NoFallbackError}}let D=null;!O||M.isDev||A||(D="/index"===(D=N)?"/":D);let K=!0===M.isDev||!O,H=O&&!K;P&&x&&(0,s.setManifestsSingleton)({page:f,clientReferenceManifest:x,serverActionsManifest:P});let j=e.method||"GET",$=(0,n.getTracer)(),F=$.getActiveScopeSpan(),B=!!(null==k?void 0:k.isWrappedByNextServer),L=!!(0,i.getRequestMeta)(e,"minimalMode"),W=(0,i.getRequestMeta)(e,"incrementalCache")||await M.getIncrementalCache(e,S,C,L);null==W||W.resetRequestCache(),globalThis.__incrementalCache=W;let G={params:T,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!S.experimental.authInterrupts},cacheComponents:!!S.cacheComponents,supportsDynamicResponse:K,incrementalCache:W,cacheLifeProfiles:S.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,i)=>M.onRequestError(e,t,r,i,k)},sharedContext:{buildId:E,deploymentId:R}},Y=new d.NodeNextRequest(e),V=new d.NodeNextResponse(t),X=l.NextRequestAdapter.fromNodeNextRequest(Y,(0,l.signalFromNodeResponse)(t));try{let i,s=async e=>M.handle(X,G).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=$.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==c.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=a.get("next.route");if(r){let t=`${j} ${r}`;e.setAttributes({"next.route":r,"http.route":r,"next.span_name":t}),e.updateName(t),i&&i!==e&&(i.setAttribute("http.route",r),i.updateName(t))}else e.updateName(`${j} ${f}`)}),o=async i=>{var n,o;let d=async({previousCacheEntry:a})=>{try{if(!L&&b&&_&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await s(i);e.fetchMetrics=G.renderOpts.fetchMetrics;let o=G.renderOpts.pendingWaitUntil;o&&r.waitUntil&&(r.waitUntil(o),o=void 0);let d=G.renderOpts.collectedTags;if(!O)return await (0,p.sendResponse)(Y,V,n,G.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,m.toNodeOutgoingHttpHeaders)(n.headers);d&&(t[h.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==G.renderOpts.collectedRevalidate&&!(G.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&G.renderOpts.collectedRevalidate,r=void 0===G.renderOpts.collectedExpire||G.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:G.renderOpts.collectedExpire;return{value:{kind:g.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:r}}}}catch(t){throw(null==a?void 0:a.isStale)&&await M.onRequestError(e,t,{routerKind:"App Router",routePath:f,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:b})},!1,k),t}},l=await M.handleResponse({req:e,nextConfig:S,cacheKey:D,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:b,revalidateOnlyGenerated:_,responseGenerator:d,waitUntil:r.waitUntil,isMinimalMode:L});if(!O)return null;if((null==l||null==(n=l.value)?void 0:n.kind)!==g.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(o=l.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",b?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let c=(0,m.fromNodeOutgoingHttpHeaders)(l.value.headers);return L&&O||c.delete(h.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||t.getHeader("Cache-Control")||c.get("Cache-Control")||c.set("Cache-Control",(0,I.getCacheControlHeader)(l.cacheControl)),await (0,p.sendResponse)(Y,V,new Response(l.value.body,{headers:c,status:l.value.status||200})),null};B&&F?await o(F):(i=$.getActiveScopeSpan(),await $.withPropagatedContext(e.headers,()=>$.trace(c.BaseServerSpan.handleRequest,{spanName:`${j} ${f}`,kind:n.SpanKind.SERVER,attributes:{"http.method":j,"http.target":e.url}},o),void 0,!B))}catch(t){if(t instanceof w.NoFallbackError||await M.onRequestError(e,t,{routerKind:"App Router",routePath:q,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:b})},!1,k),O)throw t;return await (0,p.sendResponse)(Y,V,new Response(null,{status:500})),null}}e.s(["handler",0,U,"patchFetch",0,function(){return(0,r.patchFetch)({workAsyncStorage:P,workUnitAsyncStorage:q})},"routeModule",0,M,"serverHooks",0,O,"workAsyncStorage",0,P,"workUnitAsyncStorage",0,q],397891)}];
2
-
3
- //# sourceMappingURL=_0qy7lt2._.js.map
@@ -1,3 +0,0 @@
1
- module.exports=[995900,a=>{"use strict";let b=(0,a.i(410732).default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);a.s(["default",0,b])},554705,a=>{"use strict";let b=(0,a.i(410732).default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);a.s(["Send",0,b],554705)}];
2
-
3
- //# sourceMappingURL=1b4r_lucide-react_dist_esm_icons_0u7bkx8._.js.map
@@ -1,3 +0,0 @@
1
- module.exports=[845309,a=>{"use strict";var b=a.i(616612),c=a.i(734803),d=a.i(630991),e=a.i(506180),f=a.i(732254),g=a.i(464830),h=a.i(7455),i=a.i(22902),j=a.i(25668),k=a.i(622025),l=a.i(396439),m=a.i(707190),n=a.i(613348),o=a.i(350860),p=a.i(903919),q=a.i(84096),r=a.i(790107);let s=(0,a.i(410732).default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var t=a.i(780956),u=a.i(75118),v=a.i(588339);let w={pending:{label:"Pending",variant:"outline",icon:o.Clock},scheduled:{label:"Scheduled",variant:"secondary",icon:o.Clock},joining:{label:"Joining...",variant:"default",icon:q.Loader2},recording:{label:"Recording",variant:"default",icon:k.Video},completed:{label:"Completed",variant:"secondary",icon:n.Check},failed:{label:"Failed",variant:"destructive",icon:p.AlertCircle}};function x({status:a}){let c=w[a]??w.pending,d=c.icon;return(0,b.jsxs)(g.Badge,{variant:c.variant,className:"gap-1 text-[10px]",children:[(0,b.jsx)(d,{className:(0,u.cn)("size-2.5","joining"===a&&"animate-spin","recording"===a&&"animate-pulse")}),c.label]})}function y(a){return a?new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""}a.s(["default",0,function(){let a=(0,d.useParams)().id,{workspaceId:g}=(0,e.useWorkspace)(),[n,o]=(0,c.useState)([]),[p,w]=(0,c.useState)(!0),[z,A]=(0,c.useState)(!1),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(null),[F,G]=(0,c.useState)(!1),[H,I]=(0,c.useState)(""),[J,K]=(0,c.useState)(""),[L,M]=(0,c.useState)(""),N=(0,c.useCallback)(async()=>{try{let b=await (0,v.listMeetings)(a,g);o(b)}catch{t.toast.error("Failed to load meetings")}finally{w(!1)}},[a,g]);(0,c.useEffect)(()=>{let b=!1;return(0,v.listMeetings)(a,g).then(a=>{b||(o(a),w(!1))}).catch(()=>{b||(t.toast.error("Failed to load meetings"),w(!1))}),()=>{b=!0}},[a,g]),(0,c.useEffect)(()=>{if(!n.some(a=>"joining"===a.status||"recording"===a.status))return;let a=setInterval(N,5e3);return()=>clearInterval(a)},[n,N]);let O=async()=>{if(H){C(!0);try{let b=L.split(/[,\n]/).map(a=>a.trim()).filter(Boolean);await (0,v.createMeeting)(a,g,{meetingUrl:H,title:J||void 0,participants:b.length>0?b:void 0}),t.toast.success("Meeting created"),A(!1),I(""),K(""),M(""),N()}catch(a){t.toast.error(a instanceof Error?a.message:"Failed to create meeting")}finally{C(!1)}}},P=async b=>{try{await (0,v.stopMeeting)(a,b.id,g),t.toast.success("Meeting stopped"),N()}catch{t.toast.error("Failed to stop meeting")}},Q=async b=>{try{await (0,v.approveMeeting)(a,b.id,g),t.toast.success("Meeting approved"),N()}catch{t.toast.error("Failed to approve meeting")}},R=async()=>{if(D){G(!0);try{await (0,v.deleteMeeting)(a,D.id,g),t.toast.success("Meeting deleted"),E(null),N()}catch{t.toast.error("Failed to delete meeting")}finally{G(!1)}}};return(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/50",children:[(0,b.jsx)("h2",{className:"text-sm font-medium",children:"Meetings"}),(0,b.jsxs)(f.Button,{size:"sm",onClick:()=>A(!0),className:"gap-1",children:[(0,b.jsx)(l.Plus,{className:"size-3"}),"Join Meeting"]})]}),(0,b.jsx)("div",{className:"flex-1 overflow-y-auto thin-scrollbar",children:p?(0,b.jsx)("div",{className:"p-4 space-y-3",children:[1,2,3].map(a=>(0,b.jsx)(j.Skeleton,{className:"h-16 w-full rounded-lg"},a))}):0===n.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-muted-foreground gap-2 p-8",children:[(0,b.jsx)(k.Video,{className:"size-8 opacity-40"}),(0,b.jsx)("p",{className:"text-sm",children:"No meetings yet"}),(0,b.jsx)("p",{className:"text-xs",children:"Join a Google Meet to start recording transcripts."})]}):(0,b.jsx)("div",{className:"p-2 space-y-1",children:n.map(a=>(0,b.jsxs)("div",{className:(0,u.cn)("flex items-center gap-3 rounded-lg border border-border/50 px-3 py-2.5 transition-colors","pending"===a.status&&!a.is_whitelisted&&"opacity-60"),children:[(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,b.jsx)("span",{className:"text-sm font-medium truncate",children:a.title||"Untitled Meeting"}),(0,b.jsx)(x,{status:a.status})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"truncate",children:a.meeting_url.replace("https://","")}),a.scheduled_at&&(0,b.jsx)("span",{className:"shrink-0",children:y(a.scheduled_at)}),a.started_at&&!a.completed_at&&(0,b.jsxs)("span",{className:"shrink-0",children:["Started ",y(a.started_at)]}),a.completed_at&&(0,b.jsx)("span",{className:"shrink-0",children:y(a.completed_at)}),a.participants?.length>0&&(0,b.jsxs)("span",{className:"shrink-0",children:[a.participants.length," participants"]})]}),a.error&&(0,b.jsx)("p",{className:"text-xs text-destructive mt-1 truncate",children:a.error})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:["pending"===a.status&&(0,b.jsxs)(f.Button,{variant:"outline",size:"xs",className:"gap-1",onClick:()=>Q(a),children:[(0,b.jsx)(s,{className:"size-3"}),"Approve"]}),("recording"===a.status||"joining"===a.status)&&(0,b.jsxs)(f.Button,{variant:"outline",size:"xs",className:"gap-1 text-destructive",onClick:()=>P(a),children:[(0,b.jsx)(m.Square,{className:"size-3"}),"Stop"]}),(0,b.jsx)(f.Button,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>E(a),children:(0,b.jsx)(r.Trash2,{className:"size-3"})})]})]},a.id))})}),(0,b.jsx)(h.Sheet,{open:z,onOpenChange:A,children:(0,b.jsxs)(h.SheetContent,{children:[(0,b.jsx)(h.SheetHeader,{children:(0,b.jsx)(h.SheetTitle,{children:"Join a Meeting"})}),(0,b.jsxs)(h.SheetBody,{className:"space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Google Meet URL *"}),(0,b.jsx)("input",{type:"url",placeholder:"https://meet.google.com/abc-defg-hij",value:H,onChange:a=>I(a.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Title"}),(0,b.jsx)("input",{type:"text",placeholder:"Weekly Standup",value:J,onChange:a=>K(a.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Participants (one email per line)"}),(0,b.jsx)("textarea",{placeholder:"alice@example.com\nbob@example.com",value:L,onChange:a=>M(a.target.value),rows:3,className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring resize-none"})]})]}),(0,b.jsxs)(h.SheetFooter,{children:[(0,b.jsx)(f.Button,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),(0,b.jsxs)(f.Button,{onClick:O,disabled:B||!H,children:[B&&(0,b.jsx)(q.Loader2,{className:"size-3 animate-spin"}),"Join Meeting"]})]})]})}),(0,b.jsx)(i.ConfirmDialog,{open:!!D,onOpenChange:a=>!a&&E(null),title:"Delete meeting",description:`Remove "${D?.title||"this meeting"}" and its transcript?`,loading:F,onConfirm:R})]})}],845309)}];
2
-
3
- //# sourceMappingURL=src_web_src_app_%28app%29_w_%5Bslug%5D_agents_%5Bid%5D_meetings_page_tsx_0ciapb3._.js.map