@alook/app 0.1.34 → 0.1.35

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 (86) hide show
  1. package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
  2. package/bundled/web/.open-next/assets/BUILD_ID +1 -1
  3. package/bundled/web/.open-next/assets/_next/static/chunks/0xk3goeel2v01.js +5 -0
  4. package/bundled/web/.open-next/assets/_next/static/chunks/0y253sbff4i0b.js +20 -0
  5. package/bundled/web/.open-next/assets/_next/static/chunks/1f_v2q_s63hoh.js +1 -0
  6. package/bundled/web/.open-next/assets/_next/static/chunks/{3dt849e0jwtu9.js → 1qn5hcu4pid1i.js} +1 -1
  7. package/bundled/web/.open-next/assets/_next/static/chunks/{0uwa452_gtwuc.js → 2sds_4pfwxfef.js} +1 -1
  8. package/bundled/web/.open-next/assets/_next/static/chunks/{3qq-56a5hmhjv.js → 30ia458y2m-z9.js} +1 -1
  9. package/bundled/web/.open-next/assets/_next/static/chunks/{2eysjnlp6hn65.js → 3gbp8j1j9xqt5.js} +1 -1
  10. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/_global-error.cache +1 -1
  11. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/_not-found.cache +1 -1
  12. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/c/me/bots.cache +1 -1
  13. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/c/me/friends.cache +1 -1
  14. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/c/me/machines.cache +1 -1
  15. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/c/me.cache +1 -1
  16. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/c/onboarding-preview.cache +1 -1
  17. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/c.cache +1 -1
  18. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/device.cache +1 -1
  19. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/onboarding-preview.cache +1 -1
  20. package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/privacy.cache +1 -1
  21. package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
  22. package/bundled/web/.open-next/cloudflare/init.js +1 -1
  23. package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
  24. package/bundled/web/.open-next/middleware/handler.mjs +4 -4
  25. package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
  26. package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
  27. package/bundled/web/.open-next/server-functions/default/src/web/.next/prerender-manifest.json +3 -3
  28. package/bundled/web/.open-next/server-functions/default/src/web/.next/required-server-files.json +2 -2
  29. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
  30. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/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]/activity/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/[convId]/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]/chat/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]/email/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]/files/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]/meetings/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/[id]/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/new/page_client-reference-manifest.js +1 -1
  39. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
  40. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
  41. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/flags/page_client-reference-manifest.js +1 -1
  42. 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
  43. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
  44. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
  45. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/page_client-reference-manifest.js +1 -1
  46. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
  47. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/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/[traceId]/page_client-reference-manifest.js +1 -1
  49. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/traces/page_client-reference-manifest.js +1 -1
  50. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
  51. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/workspaces/page_client-reference-manifest.js +1 -1
  52. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(auth)/sign-in/page_client-reference-manifest.js +1 -1
  53. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/channels/[serverId]/[channelId]/page_client-reference-manifest.js +1 -1
  54. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/channels/[serverId]/page_client-reference-manifest.js +1 -1
  55. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/channels/[serverId]/settings/page_client-reference-manifest.js +1 -1
  56. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/invite/[token]/page_client-reference-manifest.js +1 -1
  57. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/me/[dmId]/page_client-reference-manifest.js +1 -1
  58. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/me/bots/page_client-reference-manifest.js +1 -1
  59. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/me/friends/page_client-reference-manifest.js +1 -1
  60. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/me/machines/page_client-reference-manifest.js +1 -1
  61. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/me/page_client-reference-manifest.js +1 -1
  62. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/onboarding-preview/page_client-reference-manifest.js +1 -1
  63. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/c/page_client-reference-manifest.js +1 -1
  64. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__1exc8lx._.js +1 -1
  65. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_06ly4t9._.js +1 -1
  66. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_1dpddg5._.js +1 -1
  67. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_1n-91sn._.js +1 -1
  68. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0-2rpii._.js +1 -1
  69. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0tk6041._.js +1 -1
  70. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_settings_0ag2edj._.js +1 -1
  71. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
  72. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +5 -5
  73. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.js +1 -1
  74. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.json +1 -1
  75. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +9 -9
  76. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +37 -37
  77. package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +4 -4
  78. package/package.json +1 -1
  79. package/bundled/web/.open-next/assets/_next/static/chunks/0mu9kud4850o1.js +0 -5
  80. package/bundled/web/.open-next/assets/_next/static/chunks/2tl7jjpykd3mi.js +0 -1
  81. package/bundled/web/.open-next/assets/_next/static/chunks/41xwnd9igyovr.js +0 -20
  82. /package/bundled/web/.open-next/assets/_next/static/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/_buildManifest.js +0 -0
  83. /package/bundled/web/.open-next/assets/_next/static/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/_clientMiddlewareManifest.js +0 -0
  84. /package/bundled/web/.open-next/assets/_next/static/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/_ssgManifest.js +0 -0
  85. /package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/favicon.ico.cache +0 -0
  86. /package/bundled/web/.open-next/cache/{JPtCnLnN72EaJMxDUPROm → cF14NSMWpDLveF91ebqUj}/robots.txt.cache +0 -0
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,663741,e=>{"use strict";var t=e.i(617663),n=e.i(640138),a=e.i(302841),i=class extends a.QueryObserver{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){let{state:a}=e,i=super.createResult(e,t),{isFetching:r,isRefetching:s,isError:l,isRefetchError:o}=i,c=a.fetchMeta?.fetchMore?.direction,d=l&&"forward"===c,u=r&&"forward"===c,m=l&&"backward"===c,h=r&&"backward"===c;return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:(0,n.hasNextPage)(t,a.data),hasPreviousPage:(0,n.hasPreviousPage)(t,a.data),isFetchNextPageError:d,isFetchingNextPage:u,isFetchPreviousPageError:m,isFetchingPreviousPage:h,isRefetchError:o&&!d&&!m,isRefetching:s&&!u&&!h}}};e.s(["useInfiniteQuery",0,function(e,n){return(0,t.useBaseQuery)(e,i,n)}],663741)},975995,e=>{"use strict";let t=(0,e.i(494916).default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);e.s(["ArrowDown",0,t],975995)},110287,e=>{"use strict";let t=(0,e.i(494916).default)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);e.s(["Ban",0,t],110287)},673660,e=>{"use strict";var t=e.i(631240);e.s(["Check",()=>t.default])},859297,e=>{"use strict";let t=(0,e.i(494916).default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",0,t],859297)},338262,e=>{"use strict";let t=(0,e.i(494916).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);e.s(["default",0,t])},522047,e=>{"use strict";var t=e.i(338262);e.s(["ChevronRight",()=>t.default])},595100,e=>{"use strict";let t=(0,e.i(494916).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["default",0,t])},885526,e=>{"use strict";var t=e.i(595100);e.s(["CircleAlert",()=>t.default])},853068,e=>{"use strict";let t=(0,e.i(494916).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["Copy",0,t],853068)},365965,e=>{"use strict";let t=(0,e.i(494916).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"}]]);e.s(["default",0,t])},270911,e=>{"use strict";var t=e.i(365965);e.s(["ImageIcon",()=>t.default])},997005,e=>{"use strict";let t=(0,e.i(494916).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);e.s(["Search",0,t],997005)},389968,e=>{"use strict";let t=(0,e.i(494916).default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);e.s(["Square",0,t],389968)},921561,e=>{"use strict";let t=(0,e.i(494916).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);e.s(["default",0,t])},180410,e=>{"use strict";let t=(0,e.i(494916).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"}]]);e.s(["UserMinus",0,t],180410)},93952,e=>{"use strict";var t=e.i(973849);e.s(["X",()=>t.default])},978913,e=>{"use strict";var t=e.i(274570);e.s(["EmptyState",0,function({icon:e,label:n}){return(0,t.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 py-12 text-center",children:[(0,t.jsx)("div",{className:"grid size-14 place-items-center rounded-full bg-muted text-muted-foreground",children:(0,t.jsx)(e,{className:"size-7"})}),(0,t.jsx)("p",{className:"max-w-65 text-sm text-muted-foreground",children:n})]})}])},407478,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(865687),i=e.i(139948);e.i(954194);var r=e.i(846367),s=e.i(934351),l=e.i(186339),o=e.i(329686),c=e.i(89164),d=e.i(450463),u=e.i(130901),m=e.i(381153),h=e.i(885526),f=e.i(855372),x=e.i(613349);let g="inline-flex max-w-[160px] items-center gap-2 rounded-md border border-border bg-card px-2 py-1 text-[11px]";function p({runtimes:e}){let n=e??[];if(0===n.length)return null;let a=n.toSorted((e,t)=>Number("unhealthy"===e.status)-Number("unhealthy"===t.status));return(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:a.map(e=>(0,t.jsx)(v,{runtime:e},e.id))})}function v({runtime:e}){let n="unhealthy"===e.status,a=n?e.lastError?`Unavailable (${e.lastError}) — check daemon logs`:"Unavailable — check daemon logs":e.version,i=(0,t.jsxs)(t.Fragment,{children:[n?(0,t.jsx)(h.CircleAlert,{className:"size-3 shrink-0","aria-hidden":!0}):(0,t.jsx)(f.ProviderLogo,{provider:e.id,className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate font-medium text-foreground",children:e.id})]});return a?(0,t.jsxs)(o.Tooltip,{children:[(0,t.jsx)(o.TooltipTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":n?`${e.id} unavailable`:`${e.id} ${e.version}`,className:(0,x.cn)(g,n&&"opacity-40 cursor-not-allowed",!n&&"transition-colors hover:bg-accent","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:i})}),(0,t.jsx)(o.TooltipContent,{side:"top",sideOffset:4,children:a})]}):(0,t.jsx)("span",{className:(0,x.cn)(g,n&&"opacity-40"),children:i})}function y({children:e}){return(0,t.jsx)(s.Card,{className:"flex flex-col gap-3 p-4",children:e})}e.s(["MachineCard",0,function({machine:e,onDelete:s,onReconnect:h,onUpdate:f}){let x=(0,r.isPresenceOnline)(e.status),g=(0,n.useMemo)(()=>e.lastSeenAt?`Last seen \xb7 ${(0,d.timeAgo)(e.lastSeenAt)}`:"Never seen",[e.lastSeenAt]);return(0,t.jsxs)(y,{children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[(0,t.jsx)("div",{className:"grid size-10 shrink-0 place-items-center rounded-xl bg-secondary text-muted-foreground",children:(0,t.jsx)(a.Monitor,{className:"size-5"})}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("span",{className:"truncate text-[15px] font-medium text-foreground",children:(0,u.machineName)(e)}),(0,t.jsxs)("span",{className:["inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium",x?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-muted text-muted-foreground"].join(" "),children:[(0,t.jsx)("span",{className:["inline-block size-1.5 rounded-full",x?"bg-status-online":"bg-muted-foreground"].join(" ")}),x?"Online":"Offline"]})]}),(0,t.jsxs)("span",{className:"truncate text-xs text-muted-foreground",children:[[e.platform,e.arch].filter(Boolean).join(" · "),e.daemonVersion?` \xb7 v${e.daemonVersion}`:""]}),(0,t.jsx)(p,{runtimes:e.availableRuntimes}),(0,t.jsxs)(o.Tooltip,{children:[(0,t.jsx)(o.TooltipTrigger,{render:(0,t.jsx)("span",{className:"text-xs text-muted-foreground"}),children:g}),(0,t.jsx)(o.TooltipContent,{side:"bottom",sideOffset:4,children:e.lastSeenAt??"—"})]}),e.lastRuntimeError&&(0,t.jsxs)("div",{className:"mt-2 rounded-md border border-destructive/20 bg-destructive/5 p-2 text-xs text-destructive",children:[(0,t.jsx)("span",{className:"font-medium",children:"Runtime not available"}),(0,t.jsxs)("span",{className:"ml-1 text-destructive/80",children:["— requested ",e.lastRuntimeError.requested||"runtime",", installed:"," ",e.lastRuntimeError.available.length>0?e.lastRuntimeError.available.join(", "):"none"]})]})]})]}),(0,t.jsxs)(c.DropdownMenu,{children:[(0,t.jsx)(c.DropdownMenuTrigger,{render:(0,t.jsx)("button",{"aria-label":"Machine actions","data-testid":m.tid.machineActions(e.id),className:"grid size-8 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,t.jsx)(i.MoreVertical,{className:"size-4"})})}),(0,t.jsxs)(c.DropdownMenuContent,{align:"end",children:[f&&(0,t.jsx)(c.DropdownMenuItem,{"data-testid":m.tid.machineUpdate(e.id),onClick:f,children:"Update daemon…"}),(0,t.jsx)(c.DropdownMenuItem,{onClick:h,children:"Reconnect…"}),(0,t.jsx)(c.DropdownMenuItem,{onClick:s,className:"text-destructive",children:"Delete"})]})]})]}),!x&&(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(l.Button,{variant:"outline",size:"sm","data-onboarding-target":"reconnect-machine","data-onboarding-id":e.id,onClick:h,children:"Reconnect"})})]})},"MachineCardFrame",0,y],407478)},364904,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(735642),i=e.i(998808),r=e.i(859297),s=e.i(939299);e.i(954194);var l=e.i(846367),o=e.i(907903),c=e.i(908967),d=e.i(186339),u=e.i(728886),m=e.i(575695),h=e.i(849050),f=e.i(545772),x=e.i(613349),g=e.i(130901),p=e.i(407478),v=e.i(110696),y=e.i(468099),b=e.i(617527),j=e.i(985885),k=e.i(923533),N=e.i(374402),w=e.i(381153),C=e.i(366020),S=e.i(622435);e.i(400175);var P=e.i(935608);function M({seed:e,intro:a,stageRef:i,onIntroComplete:r}){let s=(0,n.useRef)(null),l=(0,n.useRef)(null),[o,c]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e;if(!a)return void c(!1);let t=i.current,n=s.current,o=l.current;if(!t||!n||!o)return;let d=function(e,t=window){let n=null,a=t.requestAnimationFrame(()=>{n=t.requestAnimationFrame(e)});return()=>{t.cancelAnimationFrame(a),null!==n&&t.cancelAnimationFrame(n)}}(()=>{var a,i,s;let l,d,u,m,h,f,x,g,p,v,y=n.getBoundingClientRect().width,b=function(){for(let e of document.querySelectorAll(`[data-testid="${w.tid.machineGuideIntroSource}"]`)){let t=e.getBoundingClientRect();if(t.width>0&&t.height>0&&t.right>0&&t.bottom>0&&t.left<window.innerWidth&&t.top<window.innerHeight)return e}return null}(),j=(a=t.getBoundingClientRect(),i=o.getBoundingClientRect(),s=b?.getBoundingClientRect(),l=Math.min(96,Math.max(24,.08*a.width)),d=Math.min(64,Math.max(24,.1*a.height)),u=s?Math.min(a.right-y-16,s.right+16):a.left+l,m=s?Math.min(a.bottom-y-16,Math.max(16,s.top)):a.bottom-y-d,h=i.left,f=i.top,x=h-u,g=f-m,p=Math.min(180,Math.max(72,.28*Math.abs(x))),{startX:u,startY:m,controlX:(v=y<128)?u+.7*x:u+.52*x,controlY:s?m+g*(v?.25:.12):v?m+.26*g:Math.min(m,f)-p,control2X:v?u+.88*x:void 0,control2Y:v?m+g*(s?.45:.42):void 0,endX:h,endY:f,endScale:i.width/y,clearanceScale:Math.min(1,32/y)});n.style.offsetPath=void 0!==j.control2X&&void 0!==j.control2Y?`path("M ${j.startX} ${j.startY} C ${j.controlX} ${j.controlY}, ${j.control2X} ${j.control2Y}, ${j.endX} ${j.endY}")`:`path("M ${j.startX} ${j.startY} Q ${j.controlX} ${j.controlY}, ${j.endX} ${j.endY}")`,n.style.setProperty("--guide-end-scale",String(j.endScale)),n.style.setProperty("--guide-clearance-scale",String(j.clearanceScale)),c(!0),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(e=window.setTimeout(r,140))});return()=>{d(),void 0!==e&&window.clearTimeout(e)}},[a,r,i]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:`community-guide-me-orbit-holder${a?" is-intro":""}${o?" is-ready":""}`,"aria-hidden":"true",children:(0,t.jsx)("span",{className:"community-guide-me-orbit",children:(0,t.jsx)("span",{ref:l,className:"community-guide-me-avatar","data-testid":w.tid.machineGuideAvatarTarget,children:(0,t.jsx)(P.GeneratedAvatar,{seed:e,size:24,className:"rounded-full ring-2 ring-background shadow-sm"})})})}),a?(0,t.jsx)("span",{ref:s,className:`community-first-signup-guide${o?" is-ready":""}`,"data-testid":w.tid.machineFirstSignupGuide,"aria-hidden":"true",onAnimationEnd:e=>{e.target===e.currentTarget&&"community-first-signup-guide-travel"===e.animationName&&r()},children:(0,t.jsx)("span",{className:"community-first-signup-guide-scale",children:(0,t.jsx)("span",{className:"community-first-signup-guide-art",children:(0,t.jsx)(P.GeneratedAvatar,{seed:e,size:"100%",motionParts:!0,className:"rounded-full ring-2 ring-background shadow-lg"})})})}):null]})}let A="flex flex-col items-stretch gap-4 sm:flex-row sm:items-center sm:justify-between",T="flex min-w-0 flex-col gap-1",R="w-full sm:w-fit sm:shrink-0",D="Your computers running the alook daemon.";function I(){return(0,t.jsx)(p.MachineCardFrame,{children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[(0,t.jsx)(u.Skeleton,{className:"size-10 shrink-0 rounded-xl"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,t.jsx)(u.Skeleton,{className:"h-6 w-32 max-w-full rounded"}),(0,t.jsx)(u.Skeleton,{className:"h-4 w-44 max-w-full rounded"}),(0,t.jsx)(u.Skeleton,{className:"h-4 w-24 max-w-full rounded"})]})]}),(0,t.jsx)(u.Skeleton,{className:"size-8 shrink-0 rounded-md"})]})})}function z({heading:e,cards:n}){return(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-6 overflow-y-auto p-6 thin-scrollbar",children:[e,(0,t.jsx)("div",{className:"flex flex-col gap-3",children:n})]})}function $(e,n=!1){return e||n?(0,t.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-border/40 px-6",children:[e?(0,t.jsx)(d.Button,{variant:"ghost",size:"icon-sm",onClick:e,className:"text-muted-foreground hover:text-foreground","aria-label":"Back",children:(0,t.jsx)(r.ChevronLeft,{className:"size-5"})}):(0,t.jsx)(u.Skeleton,{"data-slot":"loading-back-placeholder","aria-hidden":!0,className:"size-8 shrink-0 rounded-md"}),(0,t.jsx)("span",{"data-testid":w.tid.machineGuideIntroSource,className:"ml-1 truncate text-base font-semibold",children:"Machines"})]}):null}function E({onBack:e,reserveBackSlot:n=!1}={}){return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[$(void 0,n||!!e),(0,t.jsx)(z,{heading:(0,t.jsxs)("header",{"data-slot":"community-machines-heading",className:A,children:[(0,t.jsxs)("div",{"data-slot":"community-machines-heading-copy",className:T,children:[(0,t.jsx)(u.Skeleton,{className:"h-7 w-24 rounded"}),(0,t.jsxs)("div",{"aria-hidden":!0,className:"relative w-fit max-w-full",children:[(0,t.jsx)("p",{className:"invisible text-sm",children:D}),(0,t.jsx)(u.Skeleton,{className:"absolute inset-0 rounded"})]})]}),(0,t.jsx)("div",{"data-slot":"community-machines-heading-action",className:R,children:(0,t.jsx)(u.Skeleton,{className:"h-11 w-full rounded-md sm:h-9 sm:w-36"})})]}),cards:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I,{}),(0,t.jsx)(I,{}),(0,t.jsx)(I,{})]})})]})}async function U(e){try{return await (0,h.apiFetch)(`/api/community/machines/${e}/update`,{method:"POST"}),i.toast.success("Update requested — the machine will restart and reconnect"),!0}catch(e){return i.toast.error((0,h.getErrorMessage)(e,"Couldn't request the daemon update")),!1}}function B({machine:e,onOpenChange:n,onConfirm:a}){return(0,t.jsx)(m.AlertDialog,{open:!!e,onOpenChange:n,children:(0,t.jsxs)(m.AlertDialogContent,{children:[(0,t.jsxs)(m.AlertDialogHeader,{children:[(0,t.jsxs)(m.AlertDialogTitle,{children:["Update daemon on ",e?(0,g.machineName)(e):"machine","?"]}),(0,t.jsx)(m.AlertDialogDescription,{children:"The daemon will restart, and any bots currently running on this machine will stop. The machine will reconnect automatically when the update is ready."})]}),(0,t.jsxs)(m.AlertDialogFooter,{children:[(0,t.jsx)(m.AlertDialogCancel,{onClick:()=>n(!1),children:"Cancel"}),(0,t.jsx)(m.AlertDialogAction,{"data-testid":w.tid.machineUpdateConfirm,onClick:()=>e&&a(e),children:"Update daemon"})]})]})})}e.s(["MachineList",0,function({onBack:e}={}){let r=(0,a.useRouter)(),u=(0,a.useSearchParams)(),g=(0,s.useQueryClient)(),{machines:P,isLoading:I}=(0,b.useMachines)(),{bots:L}=(0,j.useBots)(),F=(0,k.usePendingMachineTokenId)(),[O,H]=(0,n.useState)(!1),[_,q]=(0,n.useState)({kind:"pair"}),[K,V]=(0,n.useState)(null),[X,Q]=(0,n.useState)(null),[W,G]=(0,n.useState)(null),[Y,Z]=(0,n.useState)(null),[J,ee]=(0,n.useState)(null),[et,en]=(0,n.useState)("alook-guide"),[ea,ei]=(0,n.useState)(!0),er=(0,n.useRef)(null),es=(0,C.useCommunityOnboarding)(),el=(0,x.getAppMode)();(0,n.useEffect)(()=>{en(`alook-guide-${crypto.randomUUID()}`)},[]),(0,n.useEffect)(()=>{if("dev"===el)return;let e=!0;return(0,f.fetchLatestDaemonVersion)().then(({version:t})=>{e&&ee(t)}).catch(()=>{e&&ee(null)}),()=>{e=!1}},[el]),(0,n.useEffect)(()=>{if(!K)return;let e=P.find(e=>e.lastSeenAt&&(0,l.isPresenceOnline)(e.status)&&F===K);e&&!X&&Q(e.hostname||"machine")},[P,F,K,X]);let eo=(0,n.useCallback)(()=>{q({kind:"pair"}),V(null),Q(null),k.useCommunityStore.getState().setPendingMachineTokenId(null),H(!0)},[]),ec=(0,n.useCallback)(e=>{q({kind:"reconnect",machineId:e.id,hostname:e.hostname||"machine"}),V(null),Q(null),k.useCommunityStore.getState().setPendingMachineTokenId(null),H(!0)},[]),ed=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=u.get("reconnect");if(!e||ed.current===e||I)return;ed.current=e;let t=P.find(t=>t.id===e);t&&ec(t);let n=u.toString(),a=`/c/me/machines${n?`?${n}`:""}`;r.replace((0,S.removeCommunityParam)(a,"reconnect"))},[u,P,I,ec,r]);let eu=(0,n.useCallback)(e=>{H(e),e||(V(null),Q(null),k.useCommunityStore.getState().setPendingMachineTokenId(null))},[]),em=(0,n.useCallback)(async()=>{if(!W)return;let e=W.id;G(null);try{await (0,h.apiFetch)(`/api/community/machines/${e}`,{method:"DELETE"}),g.setQueryData(N.communityKeys.machines(),t=>t?{...t,machines:t.machines.filter(t=>t.id!==e)}:t)}catch(t){let e=t instanceof Error&&"MACHINE_HAS_BOTS"===t.message?"This machine now has bots on it — delete or move them first":t instanceof Error&&t.message?t.message:"Couldn't delete the machine";i.toast.error(e)}},[W,g]),eh=(0,n.useCallback)(e=>{V(e),k.useCommunityStore.getState().setPendingMachineTokenId(e)},[]),ef=(0,n.useCallback)(e=>{Z(null),U(e.id)},[]),ex=(0,n.useCallback)(()=>{ei(!1)},[]),eg=W?L.filter(e=>e.machineId===W.id):[],ep=$(e);return I?(0,t.jsx)(E,{onBack:e}):0===P.length?(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[ep,(0,t.jsxs)("div",{ref:er,className:"flex flex-1 flex-col items-center justify-center gap-4 p-12 text-center",children:[(0,t.jsx)("div",{className:"w-full max-w-70 overflow-hidden rounded-xl",children:(0,t.jsx)("div",{className:"aspect-200/130 w-full",children:(0,t.jsx)(y.ConnectTile,{})})}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-lg font-medium text-foreground",children:"No machines yet"}),(0,t.jsx)("p",{className:"max-w-md text-sm text-muted-foreground",children:"Connect a machine and your bots run on it always-on — reach them from your phone or anywhere, wherever you sign in."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(d.Button,{"data-onboarding-target":"connect-machine","data-testid":w.tid.machinePairOpen,onClick:eo,children:"Connect a machine"}),(0,t.jsxs)("span",{className:"community-guide-me",children:[null===es?(0,t.jsx)(M,{seed:et,intro:ea,stageRef:er,onIntroComplete:ex}):null,(0,t.jsx)(d.Button,{"data-testid":w.tid.onboardingStart,variant:"ghost",onClick:()=>(0,C.startCommunityOnboarding)({guideAvatarSeed:et}),children:"Guide me"})]})]})]}),(0,t.jsx)(v.PairMachineSheet,{open:O,onOpenChange:eu,pendingTokenId:K,setPendingTokenId:eh,connectedHostname:X,mode:_})]}):(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[ep,(0,t.jsx)(z,{heading:(0,t.jsxs)("header",{"data-slot":"community-machines-heading",className:A,children:[(0,t.jsxs)("div",{"data-slot":"community-machines-heading-copy",className:T,children:[(0,t.jsx)("h1",{className:"text-xl font-medium text-foreground",children:"Machines"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:D})]}),(0,t.jsx)("div",{"data-slot":"community-machines-heading-action","data-onboarding-target":"connect-machine",className:R,children:(0,t.jsx)(d.Button,{"data-testid":w.tid.machinePairOpen,className:"min-h-11 w-full sm:min-h-9 sm:w-auto",onClick:eo,children:"Connect a machine"})})]}),cards:P.map(e=>{let n;return(0,t.jsx)(p.MachineCard,{machine:e,onDelete:()=>G(e),onReconnect:()=>ec(e),onUpdate:(n=e.daemonVersion,"dev"!==el&&(0,l.isPresenceOnline)(e.status)&&n&&J&&(0,o.releaseVersionGte)(n,c.SELF_UPDATE_MIN_DAEMON_VERSION)&&(0,o.releaseVersionGte)(J,n)&&!(0,o.releaseVersionGte)(n,J))?()=>Z(e):void 0},e.id)})}),(0,t.jsx)(v.PairMachineSheet,{open:O,onOpenChange:eu,pendingTokenId:K,setPendingTokenId:eh,connectedHostname:X,mode:_}),(0,t.jsx)(B,{machine:Y,onOpenChange:e=>!e&&Z(null),onConfirm:ef}),(0,t.jsx)(m.AlertDialog,{open:!!W,onOpenChange:e=>!e&&G(null),children:(0,t.jsxs)(m.AlertDialogContent,{children:[(0,t.jsxs)(m.AlertDialogHeader,{children:[(0,t.jsx)(m.AlertDialogTitle,{children:eg.length>0?`Can't delete ${W?.hostname||"machine"}`:`Delete ${W?.hostname||"machine"}?`}),(0,t.jsx)(m.AlertDialogDescription,{children:eg.length>0?(0,t.jsxs)(t.Fragment,{children:["This machine still has"," ",1===eg.length?`a bot ("${eg[0].name}")`:`${eg.length} bots (${eg.map(e=>e.name).join(", ")})`," ","bound to it. Delete ",1===eg.length?"it ":"them "," from the Bots page first — machines can't be deleted while they still have bots on them."]}):"The daemon will be disconnected immediately and the pairing key revoked."})]}),(0,t.jsx)(m.AlertDialogFooter,{children:eg.length>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.AlertDialogCancel,{children:"Close"}),(0,t.jsx)(m.AlertDialogAction,{onClick:()=>{let e=W?.id;G(null),k.useCommunityStore.getState().uiHandlers.navigatePath?.(e?`/c/me/bots?machineId=${e}`:"/c/me/bots")},children:"Manage bots"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.AlertDialogCancel,{children:"Cancel"}),(0,t.jsx)(m.AlertDialogAction,{onClick:em,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})})]})})]})},"MachineListSkeleton",0,E],364904)},110696,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(998808),i=e.i(853068),r=e.i(221614),s=e.i(401657),l=e.i(921561),l=l;e.i(954194);var o=e.i(824863),c=e.i(972525),d=e.i(186339),u=e.i(849050),m=e.i(381153),h=e.i(613349),f=e.i(603408);function x(e,t){let n,a=(0,h.isLocalServiceEnvironment)(),i=t?`reconnect --id ${t} --machine-key ${e}`:`start --machine-key ${e}`,r=`${a?"pnpm daemon":"npx --yes @alook/daemon@latest daemon"} ${i}`;if(!a)return r;let{serverUrl:s,wsUrl:l}=(n=(0,f.websocketUrl)("community-daemon",{local:!0,port:h.WS_DO_PORT_DEFAULT}),{serverUrl:location.origin,wsUrl:n});return`${r} --server-url ${s} --ws-url ${l}`}function g(e,t){return"string"==typeof e&&e.trim()?e.trim():e instanceof Error&&e.message?e.message:t}function p({command:e,generating:n,generationError:a=null,onRetry:i,onCopy:r,connectedHostname:s,step1MotionTarget:l,step2MotionTarget:o,step1ClassName:c,step2ClassName:d,headingAs:u="h3",desktopNative:m=!1,checkingRuntime:h=!1,runtimeCapability:f=null,launchError:x=null,connecting:g=!1,started:b=!1,onConnectDesktop:j,concise:k=!1}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-motion-target":l,className:c,children:(0,t.jsx)(v,{command:e,generating:n,generationError:a,onRetry:i,onCopy:r,headingAs:u,desktopNative:m,checkingRuntime:h,runtimeCapability:f,launchError:x,connecting:g,started:b,onConnectDesktop:j,concise:k})}),(0,t.jsx)("div",{"data-motion-target":o,className:d,children:(0,t.jsx)(y,{ready:m&&f?.available?b:!!e,connectedHostname:s,headingAs:u})})]})}function v({command:e,generating:n,generationError:a,onRetry:o,onCopy:c,headingAs:u,desktopNative:h,checkingRuntime:f,runtimeCapability:x,launchError:g,connecting:p,started:y,onConnectDesktop:j,concise:k}){return(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2",children:[(0,t.jsx)(b,{n:1,done:!n}),(0,t.jsx)(u,{className:"font-heading text-sm font-medium leading-tight tracking-[-0.015em] text-foreground",children:k?"Run one command":"Run this on your machine"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:k?(0,t.jsxs)(t.Fragment,{children:["Paste it into"," ",(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 align-middle text-foreground",children:[(0,t.jsx)(l.default,{"aria-hidden":!0,className:"size-3.5"}),"Terminal."]})," ","Node.js and npm are required."]}):"Open a terminal on the computer you want to connect, paste the command, and hit enter. Node.js with npm is required."}),a?(0,t.jsxs)("div",{className:"flex flex-col items-start gap-2 rounded-lg border border-destructive/25 bg-destructive/5 p-3",children:[(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:a}),o?(0,t.jsxs)(d.Button,{type:"button",variant:"outline",size:"sm","data-testid":m.tid.machinePairRetry,onClick:o,children:[(0,t.jsx)(s.RefreshCw,{className:"size-4"}),"Try again"]}):null]}):n?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:[(0,t.jsx)(r.Loader2,{className:"size-4 animate-spin"}),"Preparing your command…"]}):(0,t.jsxs)(t.Fragment,{children:[h&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[x?.available&&(0,t.jsxs)(d.Button,{"data-testid":m.tid.machinePairDesktopConnect,onClick:j,disabled:p||y,className:"w-full",children:[p&&(0,t.jsx)(r.Loader2,{className:"size-4 animate-spin"}),p?"Connecting…":y?"Daemon started":"Connect this computer"]}),(f||!x?.available||g)&&(0,t.jsx)("p",{"data-testid":m.tid.machinePairRuntimeHint,role:g||x?.reason?"status":void 0,className:"text-sm text-muted-foreground",children:g?`${g} The terminal command remains available below.`:f?"Checking this computer for Node.js and npm…":x?.reason??"Node.js and npm are required for one-click connection."})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/30 p-3 font-mono text-xs",children:[(0,t.jsx)("code",{"data-testid":m.tid.machinePairCommand,className:"flex-1 break-all",children:e}),(0,t.jsx)("button",{"data-testid":m.tid.machinePairCopy,onClick:c,className:"grid size-6 shrink-0 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":"Copy command",children:(0,t.jsx)(i.Copy,{className:"size-3.5"})})]})]})]})}function y({ready:e,connectedHostname:n,headingAs:a}){return n?(0,t.jsxs)("section",{"data-testid":m.tid.machinePairStatus,className:"flex flex-col gap-3",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2",children:[(0,t.jsx)(b,{n:2,done:!0}),(0,t.jsx)(a,{className:"font-heading text-sm font-medium leading-tight tracking-[-0.015em] text-foreground",children:"Connected"})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-sm",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[15px] font-medium text-foreground",children:n}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-1 text-[11px] font-medium text-emerald-600 dark:text-emerald-400",children:[(0,t.jsx)("span",{className:"inline-block size-1.5 rounded-full bg-status-online"}),"Online"]})]}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"is ready for your bot friends."})]})]}):(0,t.jsx)("section",{"data-testid":m.tid.machinePairStatus,className:"flex flex-col gap-3",children:(0,t.jsxs)("header",{className:"flex items-center gap-2",children:[(0,t.jsx)(b,{n:2,muted:!e,spinning:e}),(0,t.jsx)(a,{className:["font-heading text-sm font-medium leading-tight tracking-[-0.015em]",e?"text-foreground":"text-muted-foreground"].join(" "),children:"Waiting for the daemon…"})]})})}function b({n:e,muted:n,done:a,spinning:i}){return(0,t.jsxs)("span",{className:["relative grid size-6 place-items-center rounded-full text-xs font-medium",a?"bg-emerald-500 text-white":n?"bg-muted text-muted-foreground":"bg-primary text-primary-foreground"].join(" "),children:[i&&(0,t.jsx)("span",{className:"absolute -inset-0.75 rounded-full border-2 border-primary/30 border-t-primary animate-spin"}),e]})}e.s(["PairMachineSheet",0,function({open:e,onOpenChange:i,pendingTokenId:r,setPendingTokenId:s,connectedHostname:l,mode:m={kind:"pair"}}){let h="reconnect"===m.kind,[f,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[j,k]=(0,n.useState)(!1),[N,w]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[P,M]=(0,n.useState)(null),[A,T]=(0,n.useState)(null),R=(0,n.useRef)(null),D=(0,n.useRef)(!1),I=(0,o.isTauri)()&&(0,o.isDesktop)(),z=(0,n.useCallback)(async()=>{v(!0),b(null);try{let e="reconnect"===m.kind?`/api/community/machines/${m.machineId}/reconnect`:"/api/community/machines/pair",t=await (0,u.apiFetch)(e,{method:"POST"});s(t.tokenId)}catch(t){let e="Couldn't generate a key — try again.";b(e),(0,u.toastApiError)(t,e),console.error(t)}finally{v(!1)}},[s,m]),$=e?"reconnect"===m.kind?`reconnect:${m.machineId}`:"pair":null;(0,n.useEffect)(()=>{if(!$){R.current=null;return}R.current!==$&&(R.current=$,w(!1),s(null),z())},[$,z,s]),(0,n.useEffect)(()=>{if(!e||!I){S(!1),M(null);return}let t=!0;return S(!0),M(null),T(null),(0,o.tauriInvoke)("daemon_runtime_capability").then(e=>{t&&M(e)}).catch(e=>{t&&M({available:!1,reason:g(e,"Alook couldn't check Node.js and npm on this computer."),nodeVersion:null})}).finally(()=>{t&&S(!1)}),()=>{t=!1}},[e,I]);let E=r?x(r,"reconnect"===m.kind?m.machineId:void 0):"",U=(0,n.useCallback)(async()=>{if(E)try{await navigator.clipboard.writeText(E),a.toast.success("Command copied")}catch{a.toast.error("Copy failed")}},[E]),B=(0,n.useCallback)(async()=>{if(r&&!D.current&&P?.available){D.current=!0,k(!0),T(null);try{let e=await (0,o.tauriInvoke)("daemon_pair",{machineKey:r,machineId:"reconnect"===m.kind?m.machineId:null});if(!e.success)throw Error(e.message||"The daemon did not start");w(!0),a.toast.success(h?"Machine reconnected":"This computer is connecting")}catch(t){let e=g(t,"Couldn't start the daemon. Run the command below in a terminal instead.");T(e),a.toast.error(e)}finally{D.current=!1,k(!1)}}},[r,P?.available,h,m]);return(0,t.jsx)(c.CommunitySheet,{open:e,onOpenChange:i,title:h?`Reconnect ${m.hostname||"machine"}`:"Connect a machine",description:h?"Run this command before it expires. It safely replaces the running daemon, then rotates its key.":"Run this on the computer you want to connect. The key is good for 15 minutes.",bodyClassName:"flex flex-col gap-6",footer:e=>(0,t.jsx)(d.Button,{variant:"secondary",className:"min-h-11!",onClick:e,children:"Done"}),children:(0,t.jsx)(p,{command:E,generating:f||!E,generationError:y,onRetry:()=>void z(),onCopy:U,desktopNative:I,checkingRuntime:C,runtimeCapability:P,launchError:A,connecting:j,started:N,onConnectDesktop:B,connectedHostname:l})})},"PairMachineSteps",0,p,"buildPairCommand",0,x],110696)},468099,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(732919),i=e.i(848937),r=e.i(909850),s=e.i(621202);let l={x:100,y:32},o={x:57,y:96},c={x:143,y:96};e.s(["ConnectTile",0,function({idPrefix:e="ot-connect"}){let d=(0,n.useRef)(null),u=(0,r.tileIds)(e);return(0,i.useGSAP)(()=>{if(!d.current)return;let e=(e,t,n,a)=>{var i,r;e.set(".ot-packet",{attr:{cx:t.x,cy:t.y,r:4},opacity:0}).to(".ot-packet",{opacity:1,duration:.2}).to(".ot-packet",{attr:{cx:n.x,cy:n.y},duration:.85,ease:"power1.inOut"}).to(".ot-packet",{opacity:0,duration:.14}),i=n.x,r=n.y,e.set(".ot-flare",{attr:{cx:i,cy:r,r:3},opacity:.9}).to(".ot-flare",{attr:{r:12},opacity:0,duration:.7,ease:"power2.out"}).to(a,{filter:"brightness(1.7)",duration:.14,ease:"power2.out"},"<").to(a,{filter:"brightness(1)",duration:.6,ease:"power1.out"},"<0.14"),e.to({},{duration:.25})},t=a.default.timeline({repeat:-1,defaults:{ease:s.OT_EASE}});e(t,o,l,".ot-alook"),e(t,l,c,".ot-phone"),e(t,c,l,".ot-alook"),e(t,l,o,".ot-machine"),t.to({},{duration:.3})},{scope:d}),(0,t.jsxs)("svg",{ref:d,viewBox:"0 0 200 130",className:"ot-svg h-full w-full",children:[(0,t.jsx)(r.TileDefs,{idPrefix:e}),(0,t.jsx)("line",{className:"ot-art",x1:"83.7",y1:"56.3",x2:"70.1",y2:"76.8",opacity:"0.28"}),(0,t.jsx)("line",{className:"ot-art",x1:"116.3",y1:"56.3",x2:"129.9",y2:"76.8",opacity:"0.28"}),(0,t.jsx)("image",{className:"ot-alook ot-center",href:"/alook.svg",x:"83",y:"15",width:"34",height:"34"}),(0,t.jsx)("g",{className:"ot-machine ot-center",children:(0,t.jsx)("svg",{x:"40",y:"79",width:"34",height:"34",viewBox:"0 0 24 24",children:(0,t.jsx)("use",{href:`#${u.monitor}`})})}),(0,t.jsx)("g",{className:"ot-phone ot-center",children:(0,t.jsx)("svg",{x:"130",y:"83",width:"26",height:"26",viewBox:"0 0 24 24",children:(0,t.jsx)("use",{href:`#${u.phone}`})})}),(0,t.jsx)("circle",{className:"ot-art ot-accent ot-flare",cx:"100",cy:"32",r:"4",opacity:"0",strokeWidth:"2.5"}),(0,t.jsx)("circle",{className:"ot-art-fill ot-accent ot-packet",cx:"100",cy:"32",r:"4",opacity:"0"})]})}])},800989,907919,e=>{"use strict";var t=e.i(274570),n=e.i(765867),a=e.i(915066);function i(){return(0,t.jsxs)("main",{"aria-busy":"true","aria-label":"Resolving conversation","data-community-conversation-subtype":"unknown","data-community-mobile-transition":"suppress",className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,t.jsx)(a.UnresolvedMainSkeleton,{}),(0,t.jsx)("span",{className:"sr-only",children:"Resolving conversation"})]})}e.s(["ConversationResolutionPendingFrame",0,i],907919);var r=e.i(888598),s=e.i(364904),l=e.i(879632),o=e.i(101126),c=e.i(622435),d=e.i(381153);function u(){return(0,t.jsx)("main",{"aria-busy":"true","aria-label":"Loading your space",className:"flex min-h-0 min-w-0 flex-1 flex-col",children:(0,t.jsx)(a.UnresolvedMainSkeleton,{})})}function m(){return(0,t.jsx)("main",{"aria-busy":"true","aria-label":"Resolving community route",className:"flex min-h-0 min-w-0 flex-1 flex-col",children:(0,t.jsx)(a.UnresolvedMainSkeleton,{})})}e.s(["CommunityPendingFrame",0,function({href:e,reserveBackSlot:a=!1,plan:h}){let f,x=h??(0,c.resolveCommunityModulePlan)(e),g=a||"detail"===x.surface&&"me"===x.sidebar.kind;switch(x.main.kind){case"me-root":f=(0,t.jsx)(u,{});break;case"machines":f=(0,t.jsx)(s.MachineListSkeleton,{reserveBackSlot:g});break;case"bots":f=(0,t.jsx)(n.BotListSkeleton,{reserveBackSlot:g});break;case"friends":f=(0,t.jsx)(l.FriendsPage,{friends:[],pending:[],blocked:[],loading:!0,reserveBackSlot:g});break;case"dm":f=(0,t.jsx)(r.DmLoadingFrame,{reserveBackSlot:g});break;case"server-landing":f=(0,t.jsx)(o.ServerLandingPendingFrame,{});break;case"server-conversation":f=(0,t.jsx)(i,{});break;case"route-resolution":f=(0,t.jsx)(m,{});break;case"none":return null}return(0,t.jsx)("div",{"data-testid":d.tid.pendingMain(x.main.kind),"data-community-main-kind":x.main.kind,"data-community-mobile-transition":"suppress",className:"flex min-h-0 min-w-0 flex-1 flex-col",children:f})}],800989)},101126,915066,e=>{"use strict";var t=e.i(274570),n=e.i(728886);function a(){return(0,t.jsx)(n.Skeleton,{"aria-hidden":!0,"data-community-unresolved-main":"",className:"min-h-0 h-full w-full flex-1 rounded-none"})}e.s(["UnresolvedMainSkeleton",0,a],915066),e.s(["ServerLandingPendingFrame",0,function(){return(0,t.jsx)("main",{"aria-busy":"true","aria-label":"Loading server","data-community-mobile-transition":"suppress",className:"flex min-h-0 min-w-0 flex-1 flex-col",children:(0,t.jsx)(a,{})})}],101126)},879632,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(715783),i=e.i(817220),r=e.i(859297),s=e.i(673660),l=e.i(93952);let o=(0,e.i(494916).default)("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);var c=e.i(180410),d=e.i(110287),u=e.i(471885),m=e.i(997005),h=e.i(849050),f=e.i(733182),x=e.i(186339),g=e.i(903477),p=e.i(255334),v=e.i(607711),y=e.i(728886),b=e.i(531342),j=e.i(280958),k=e.i(978913),N=e.i(228918);e.i(954194);var w=e.i(582168),C=e.i(846367),S=e.i(908967),P=e.i(71977),M=e.i(351777);function A({title:e,count:n,emptyLabel:i,children:r}){return(0,t.jsxs)("div",{className:"flex min-h-0 flex-col",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:e}),0===n?(0,t.jsx)(k.EmptyState,{icon:a.Users,label:i}):(0,t.jsx)("div",{className:"flex flex-col gap-1",children:r})]})}function T({withActions:e=!1}){return(0,t.jsx)("div",{className:"flex flex-col gap-1",children:Array.from({length:5}).map((n,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md px-2 py-2",children:[(0,t.jsx)(y.Skeleton,{className:"size-8 shrink-0 rounded-full"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[(0,t.jsx)(y.Skeleton,{className:"h-3.5 w-2/5 rounded"}),(0,t.jsx)(y.Skeleton,{className:"h-3 w-3/5 rounded"})]}),e?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(y.Skeleton,{className:"size-8 shrink-0 rounded-full"}),(0,t.jsx)(y.Skeleton,{className:"size-8 shrink-0 rounded-full"})]}):(0,t.jsx)(y.Skeleton,{className:"size-8 shrink-0 rounded-full"})]},a))})}e.s(["FriendsPage",0,function({friends:e,pending:a,blocked:k,loading:R,onBack:D,reserveBackSlot:I=!1,onAccept:z,onReject:$,onCancelRequest:E,onUnblock:U,onSendRequest:B,onRemoveFriend:L,onBlock:F,onDm:O}){let[H,_]=(0,n.useState)(""),q=(0,n.useMemo)(()=>{let t=H.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.sub??"").toLowerCase().includes(t)||!!e.discriminator&&`#${e.discriminator}`.includes(t)):e},[e,H]),[K,V]=(0,n.useState)(""),[X,Q]=(0,n.useState)([]),W=(0,P.useCommunityWsStore)(e=>e.profilesByUserId),G=(0,n.useRef)(null),Y=(0,n.useMemo)(()=>{let t=new Map;for(let e of a)e.userId&&t.set(e.userId,"pending");for(let n of e)n.userId&&t.set(n.userId,"friend");for(let e of k)e.userId&&t.set(e.userId,"blocked");return t},[e,a,k]),Z=(0,n.useMemo)(()=>a.filter(e=>"incoming"===e.kind),[a]),J=(0,n.useMemo)(()=>a.filter(e=>"outgoing"===e.kind),[a]);return((0,n.useEffect)(()=>{G.current&&clearTimeout(G.current);let e=K.trim();return e.length<S.MIN_SEARCH_LENGTH?void Q([]):(G.current=setTimeout(async()=>{try{let t=await (0,f.apiFetchProfiles)(`/api/community/users/search?q=${encodeURIComponent(e)}`,e=>e.users.map(e=>({id:e.id,identityAbout:{name:e.name,discriminator:e.discriminator},avatar:{avatar:e.image??(0,j.avatarInitial)(e.name),avatarVersion:e.avatarVersion}})));Q(t.users.map(e=>e.id))}catch(e){Q([]),(0,h.toastApiError)(e,"Search failed")}},300),()=>{G.current&&clearTimeout(G.current)})},[K]),R&&0===e.length&&0===a.length&&0===k.length)?(0,t.jsxs)("div",{"aria-busy":"true","aria-label":"Loading friends",className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[(0,t.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-border/40 px-4",children:[(I||!!D)&&(0,t.jsx)(y.Skeleton,{"data-slot":"loading-back-placeholder","aria-hidden":!0,className:"size-8 shrink-0 rounded-md"}),(0,t.jsxs)("div",{"aria-hidden":!0,className:"inline-flex h-8 items-center gap-1 p-0.75 text-muted-foreground",children:[(0,t.jsx)("span",{className:"inline-flex h-[calc(100%-1px)] items-center px-2 py-1 text-sm font-medium",children:"All"}),(0,t.jsx)("span",{className:"inline-flex h-[calc(100%-1px)] items-center px-2 py-1 text-sm font-medium",children:"New"})]})]}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto thin-scrollbar p-4",children:[(0,t.jsx)(y.Skeleton,{className:"mb-4 h-11 w-full rounded-md"}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-col",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"All friends — …"}),(0,t.jsx)(T,{})]}),(0,t.jsxs)("div",{className:"mt-8 flex min-h-0 flex-col",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Blocked — …"}),(0,t.jsx)(T,{withActions:!0})]})]}),(0,t.jsx)("span",{className:"sr-only",children:"Loading friends"})]}):(0,t.jsxs)(p.Tabs,{defaultValue:"all",className:"min-h-0 flex-1",children:[(0,t.jsxs)("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-border/40 px-4",children:[D&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-sm",onClick:D,className:"text-muted-foreground hover:text-foreground","aria-label":"Back",children:(0,t.jsx)(r.ChevronLeft,{className:"size-5"})}),(0,t.jsxs)(p.TabsList,{variant:"line",children:[(0,t.jsx)(p.TabsTrigger,{value:"all",children:"All"}),(0,t.jsx)(p.TabsTrigger,{value:"new",children:"New"})]})]}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto thin-scrollbar p-4",children:[(0,t.jsxs)(p.TabsContent,{value:"all",children:[(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(m.Search,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(g.Input,{className:"h-11 pl-9",placeholder:"Search friends",value:H,onChange:e=>_(e.target.value)})]})}),R&&0===e.length?(0,t.jsxs)("div",{className:"flex min-h-0 flex-col",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"All friends — …"}),(0,t.jsx)(T,{})]}):(0,t.jsx)(A,{title:`All friends — ${q.length}`,count:q.length,emptyLabel:H.trim()?"No friends match that search.":"No friends yet. Add someone from the New tab.",children:q.map(e=>{let n=(0,w.isSelfBotFriendship)(e.id);return(0,t.jsxs)(v.ContextMenu,{children:[(0,t.jsxs)(v.ContextMenuTrigger,{render:(0,t.jsx)("button",{onClick:()=>{e.userId&&O?.(e.userId)},className:"flex w-full items-center gap-3 rounded-md px-2 py-2 text-left hover:bg-accent"}),children:[(0,t.jsx)(b.Avatar,{label:e.avatar,seed:e.userId,size:32,presence:e.status,dim:(0,C.isPresenceOffline)(e.status)}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:`truncate text-sm font-medium ${(0,C.isPresenceOffline)(e.status)?"text-muted-foreground":""}`,children:[e.name,e.discriminator&&(0,t.jsxs)("span",{className:"ml-1 text-xs font-normal tracking-wide text-muted-foreground",children:["#",e.discriminator]})]}),(0,N.hasStatus)(e.statusEmoji,e.statusText)&&(0,t.jsxs)("div",{className:"truncate text-xs text-muted-foreground",children:[e.statusEmoji," ",e.statusText]})]}),(0,t.jsx)("span",{className:"grid size-8 place-items-center rounded-full bg-secondary text-muted-foreground",children:(0,t.jsx)(i.MessagesSquare,{className:"size-4"})})]}),!n&&(0,t.jsxs)(v.ContextMenuContent,{className:"w-44",children:[(0,t.jsxs)(v.ContextMenuItem,{onClick:()=>L?.(e.id),children:[(0,t.jsx)(c.UserMinus,{className:"size-4"})," Remove friend"]}),(0,t.jsx)(v.ContextMenuSeparator,{}),(0,t.jsxs)(v.ContextMenuItem,{onClick:()=>F?.(e.userId??e.id),className:"text-destructive data-highlighted:bg-destructive/10 data-highlighted:text-destructive",children:[(0,t.jsx)(d.Ban,{className:"size-4"})," Block"]})]})]},e.id)})}),R&&0===k.length?(0,t.jsxs)("div",{className:"mt-8 flex min-h-0 flex-col",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Blocked — …"}),(0,t.jsx)(T,{withActions:!0})]}):k.length>0?(0,t.jsxs)("div",{className:"mt-8",children:[(0,t.jsxs)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:["Blocked — ",k.length]}),(0,t.jsx)("div",{className:"flex flex-col gap-1",children:k.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md px-2 py-2 hover:bg-accent",children:[(0,t.jsx)(b.Avatar,{label:e.avatar,seed:e.userId,size:32,dim:!0}),(0,t.jsx)("div",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.name}),(0,t.jsx)(x.Button,{variant:"secondary",size:"sm",onClick:()=>U?.(e.userId??e.id),children:"Unblock"})]},e.id))})]}):null]}),(0,t.jsxs)(p.TabsContent,{value:"new",children:[(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("div",{className:"text-xs font-semibold text-muted-foreground",children:"Add a friend"}),(0,t.jsxs)("div",{className:"relative mt-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(o,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(g.Input,{className:"h-11 pl-9",placeholder:"Search by username",value:K,onChange:e=>V(e.target.value)})]}),X.length>0&&(0,t.jsx)("div",{className:"mt-1 rounded-md border border-border bg-popover p-1 shadow-(--e2)",children:X.map(e=>{let n=(0,M.readCommunityProfile)(W.get(e),e),a=Y.get(e),i="friend"===a?"Friends":"pending"===a?"Pending":"blocked"===a?"Blocked":null;return(0,t.jsxs)("button",{onClick:()=>{a||(B?.({userId:n.id,username:`${n.name}#${n.discriminator}`}),V(""),Q([]))},disabled:!!a,className:"flex w-full items-center gap-3 rounded-md px-3 py-2 text-left hover:bg-accent disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[(0,t.jsx)(b.Avatar,{label:n.avatar,seed:e,size:28}),(0,t.jsxs)("span",{className:`flex-1 min-w-0 truncate text-sm font-medium ${a?"text-muted-foreground":""}`,children:[n.name,(0,t.jsxs)("span",{className:"ml-1 text-xs font-normal tracking-wide text-muted-foreground",children:["#",n.discriminator]})]}),i?(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:i}):(0,t.jsx)(u.UserPlus,{className:"size-4 shrink-0 text-muted-foreground"})]},e)})})]})]}),R&&0===a.length?(0,t.jsxs)("div",{className:"flex min-h-0 flex-col",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Pending — …"}),(0,t.jsx)(T,{withActions:!0})]}):(0,t.jsxs)(t.Fragment,{children:[Z.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:["Incoming — ",Z.length]}),(0,t.jsx)("div",{className:"flex flex-col gap-1",children:Z.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md px-2 py-2 hover:bg-accent",children:[(0,t.jsx)(b.Avatar,{label:e.avatar,seed:e.userId,size:32}),(0,t.jsx)("div",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.name}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(x.Button,{variant:"secondary",size:"icon-sm",onClick:()=>z?.(e.id),className:"rounded-full text-status-online","aria-label":"Accept",children:(0,t.jsx)(s.Check,{className:"size-4"})}),(0,t.jsx)(x.Button,{variant:"secondary",size:"icon-sm",onClick:()=>$?.(e.id),className:"rounded-full text-destructive","aria-label":"Reject",children:(0,t.jsx)(l.X,{className:"size-4"})})]})]},e.id))})]}),J.length>0&&(0,t.jsxs)("div",{className:Z.length>0?"mt-8":"",children:[(0,t.jsxs)("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:["Outgoing — ",J.length]}),(0,t.jsx)("div",{className:"flex flex-col gap-1",children:J.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md px-2 py-2 hover:bg-accent",children:[(0,t.jsx)(b.Avatar,{label:e.avatar,seed:e.userId,size:32}),(0,t.jsx)("div",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.name}),e.needsOwnerApproval?(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:"Waiting on owner approval"}):null,(0,t.jsx)(x.Button,{variant:"secondary",size:"icon-sm",onClick:()=>E?.({id:e.id}),className:"rounded-full","aria-label":"Cancel",children:(0,t.jsx)(l.X,{className:"size-4"})})]},e.id))})]})]})]})]})]})}],879632)},228918,e=>{"use strict";let t=[{emoji:"🎧",text:"Vibing"},{emoji:"🎮",text:"Gaming"},{emoji:"🦥",text:"Chillin'"},{emoji:"🍟",text:"Snack break"},{emoji:"📞",text:"On a call"},{emoji:"🚪",text:"Afk"},{emoji:"😴",text:"Do not disturb"}];e.s(["STATUS_PRESETS",0,t,"hasStatus",0,function(e,t){return!!(e||t)},"matchingPreset",0,function(e,n){return t.find(t=>t.emoji===e&&t.text===n)}])},377633,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(176726),i=e.i(613349),r=e.i(677204);let s=/\.[^/.]+$/;function l(e){let t="number"==typeof e?e:Number.parseFloat(String(e??""));return Number.isFinite(t)&&t>0?t:void 0}async function o(e,t){try{let n=await fetch(e).then(e=>e.blob()),a=new URL(e,window.location.origin).pathname.split("/").pop()||"",i=a.split(".").pop(),r=a.includes(".")&&i&&i.length<=4,l=a;if(!r){let e=n.type.includes("jpeg")||n.type.includes("jpg")?"jpg":n.type.includes("svg")?"svg":n.type.includes("gif")?"gif":n.type.includes("webp")?"webp":"png";l=`${(t||a||"image").replace(s,"")}.${e}`}let o=URL.createObjectURL(n),c=document.createElement("a");c.href=o,c.download=l,document.body.appendChild(c),c.click(),c.remove(),URL.revokeObjectURL(o)}catch{window.open(e,"_blank")}}function c({src:e,alt:s="",className:d,width:u,height:m,node:h,...f}){let[x,g]=(0,r.useRemoteImageEligibility)(!0),[p,v,,y,b,j,k]=(0,r.useRemoteImageAttempt)({eligible:x}),N=l(u),w=l(m),C=N&&w?`${N}/${w}`:"4/3",S=N&&w?Math.min(N,300*N/w):N?Math.min(N,300):300,P=(0,n.useCallback)(()=>{e&&o(e,s)},[s,e]);return e?(0,t.jsxs)("div",{ref:g,"data-streamdown":"image-wrapper","data-remote-image-state":p,className:"group relative my-4 inline-block max-w-full overflow-hidden rounded-lg bg-muted/30",style:{width:`min(100%, ${S}px)`,aspectRatio:C},children:["pending"===p&&(0,t.jsx)("span",{"aria-hidden":!0,"data-remote-image-placeholder":!0,className:"absolute inset-0 bg-muted/70 animate-pulse motion-reduce:animate-none"}),(0,n.createElement)("img",{...f,key:v,ref:y,"data-streamdown":"image","data-remote-image-kind":"content","data-remote-image-state":p,src:e,alt:s,width:N,height:w,loading:"lazy",className:(0,i.cn)("absolute inset-0 size-full rounded-lg object-contain transition-opacity duration-150 ease-out motion-reduce:transition-none","ready"===p?"opacity-100":"opacity-0",d),onLoad:b,onError:j}),"error"===p&&(0,t.jsxs)("div",{role:"status","data-streamdown":"image-fallback",className:"absolute inset-0 z-2 flex flex-col items-center justify-center gap-1 bg-muted px-2 text-center text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:"Image not available"}),(0,t.jsx)("button",{type:"button",onClick:k,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md px-3 font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Retry"})]}),"ready"===p&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-foreground/10 group-hover:block"}),(0,t.jsx)("button",{type:"button",title:"Download image",onClick:P,className:"absolute right-2 bottom-2 flex size-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 opacity-0 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(a.Download,{className:"size-3.5"})})]})]}):null}e.s(["RemoteMarkdownImage",0,function(e){return e.src?(0,t.jsx)(c,{...e},e.src):null}])},575695,e=>{"use strict";var t=e.i(274570);e.s([],101419),e.i(101419);var n=e.i(139721),a=e.i(885932),i=e.i(328112),r=e.i(129831),s=e.i(788547),l=e.i(881554),o=e.i(389250);let c=e.i(630028).DialogTrigger;var d=e.i(22998),u=e.i(325776);class m extends u.DialogHandle{}e.s(["Backdrop",()=>a.DialogBackdrop,"Close",()=>i.DialogClose,"Description",()=>r.DialogDescription,"Handle",0,m,"Popup",()=>s.DialogPopup,"Portal",()=>l.DialogPortal,"Root",0,function(e){return(0,n.useRenderDialogRoot)("alert-dialog",e)},"Title",()=>o.DialogTitle,"Trigger",0,c,"Viewport",()=>d.DialogViewport,"createHandle",0,function(){return new m}],227553);var h=e.i(227553),h=h,f=e.i(613349),x=e.i(186339);function g({...e}){return(0,t.jsx)(h.Portal,{"data-slot":"alert-dialog-portal",...e})}function p({className:e,...n}){return(0,t.jsx)(h.Backdrop,{"data-slot":"alert-dialog-overlay",className:(0,f.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...n})}e.s(["AlertDialog",0,function({...e}){return(0,t.jsx)(h.Root,{"data-slot":"alert-dialog",...e})},"AlertDialogAction",0,function({className:e,...n}){return(0,t.jsx)(x.Button,{"data-slot":"alert-dialog-action",className:(0,f.cn)(e),...n})},"AlertDialogCancel",0,function({className:e,variant:n="outline",size:a="default",...i}){return(0,t.jsx)(h.Close,{"data-slot":"alert-dialog-cancel",className:(0,f.cn)(e),render:(0,t.jsx)(x.Button,{variant:n,size:a}),...i})},"AlertDialogContent",0,function({className:e,size:n="default",...a}){return(0,t.jsxs)(g,{children:[(0,t.jsx)(p,{}),(0,t.jsx)(h.Popup,{"data-slot":"alert-dialog-content","data-size":n,className:(0,f.cn)("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})]})},"AlertDialogDescription",0,function({className:e,...n}){return(0,t.jsx)(h.Description,{"data-slot":"alert-dialog-description",className:(0,f.cn)("text-sm text-balance text-muted-foreground sm:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...n})},"AlertDialogFooter",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,f.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...n})},"AlertDialogHeader",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,f.cn)("grid grid-rows-[auto_1fr] place-items-center gap-2 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...n})},"AlertDialogTitle",0,function({className:e,...n}){return(0,t.jsx)(h.Title,{"data-slot":"alert-dialog-title",className:(0,f.cn)("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...n})}],575695)},520582,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(613349);let i=e=>{e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},r=n.forwardRef(({className:e,onChange:r,...s},l)=>{let o=n.useRef(null),c=n.useCallback(e=>{o.current=e,"function"==typeof l?l(e):l&&(l.current=e),i(e)},[l]);return n.useEffect(()=>{i(o.current)},[s.value]),(0,t.jsx)("textarea",{ref:c,className:(0,a.cn)("resize-none overflow-hidden",e),onChange:e=>{i(e.target),r?.(e)},...s})});r.displayName="AutoResizeTextarea",e.s(["AutoResizeTextarea",0,r])},288329,e=>{"use strict";var t=e.i(274570),n=e.i(318151),a=e.i(613349);e.s(["SheetResizeHandle",0,function({onPointerDown:e,onPointerMove:n,onPointerUp:i,className:r,withHandle:s=!0}){return(0,t.jsx)("div",{onPointerDown:e,onPointerMove:n,onPointerUp:i,onLostPointerCapture:i,className:(0,a.cn)("hidden sm:flex absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 items-center justify-center hover:bg-primary/10 active:bg-primary/20 transition-colors rounded-l-xl",r),children:s&&(0,t.jsx)("div",{className:"h-6 w-1 rounded-lg bg-border"})})},"useSheetResize",0,function({defaultWidth:e=480,minWidth:t=320,maxWidthRatio:a=.8}={}){let[i,r]=(0,n.useState)(e),s=(0,n.useRef)(!1),l=(0,n.useCallback)(e=>{e.preventDefault(),e.target.setPointerCapture(e.pointerId),s.current=!0},[]);return{width:i,onPointerDown:l,onPointerMove:(0,n.useCallback)(e=>{s.current&&r(Math.min(window.innerWidth*a,Math.max(t,window.innerWidth-e.clientX)))},[t,a]),onPointerUp:(0,n.useCallback)(e=>{s.current=!1,e.target.releasePointerCapture(e.pointerId)},[])}}])},332680,e=>{"use strict";var t=e.i(274570),n=e.i(778546),a=e.i(613349),i=e.i(186339),r=e.i(890062);function s({...e}){return(0,t.jsx)(n.Dialog.Portal,{"data-slot":"sheet-portal",...e})}function l({className:e,...i}){return(0,t.jsx)(n.Dialog.Backdrop,{"data-slot":"sheet-overlay",className:(0,a.cn)("fixed inset-0 z-50 bg-black/20 backdrop-blur-[2px] transition-[opacity,backdrop-filter] duration-200 ease-out data-ending-style:opacity-0 data-ending-style:backdrop-blur-none data-starting-style:opacity-0 data-starting-style:backdrop-blur-none",e),...i})}e.s(["Sheet",0,function({...e}){return(0,t.jsx)(n.Dialog.Root,{"data-slot":"sheet",...e})},"SheetBody",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"sheet-body",className:(0,a.cn)("flex-1 overflow-y-auto thin-scrollbar px-4 sm:px-6 py-4",e),...n})},"SheetClose",0,function({...e}){return(0,t.jsx)(n.Dialog.Close,{"data-slot":"sheet-close",...e})},"SheetContent",0,function({className:e,children:o,side:c="right",showCloseButton:d=!0,showOverlay:u=!0,...m}){return(0,t.jsxs)(s,{children:[u&&(0,t.jsx)(l,{forceRender:!0}),(0,t.jsxs)(n.Dialog.Popup,{"data-slot":"sheet-content","data-side":c,className:(0,a.cn)("fixed z-50 flex flex-col bg-background shadow-xl outline-none transition duration-300 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-md data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-10 data-[side=right]:data-starting-style:translate-x-10","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:-translate-x-10 data-[side=left]:data-starting-style:-translate-x-10","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:-translate-y-10 data-[side=top]:data-starting-style:-translate-y-10","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:data-starting-style:translate-y-10",e),...m,children:[o,d&&(0,t.jsxs)(n.Dialog.Close,{"data-slot":"sheet-close",render:(0,t.jsx)(i.Button,{variant:"ghost",className:"absolute top-3 right-3 z-10",size:"icon-sm"}),children:[(0,t.jsx)(r.XIcon,{}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})},"SheetDescription",0,function({className:e,...i}){return(0,t.jsx)(n.Dialog.Description,{"data-slot":"sheet-description",className:(0,a.cn)("text-sm text-muted-foreground",e),...i})},"SheetFooter",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"sheet-footer",className:(0,a.cn)("flex flex-col-reverse gap-2 border-t bg-muted/50 px-4 sm:px-6 py-4 sm:flex-row sm:justify-end",e),...n})},"SheetHeader",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"sheet-header",className:(0,a.cn)("flex flex-col gap-1 border-b px-4 sm:px-6 py-4",e),...n})},"SheetTitle",0,function({className:e,...i}){return(0,t.jsx)(n.Dialog.Title,{"data-slot":"sheet-title",className:(0,a.cn)("font-heading text-lg leading-tight font-semibold",e),...i})},"SheetTrigger",0,function({...e}){return(0,t.jsx)(n.Dialog.Trigger,{"data-slot":"sheet-trigger",...e})}])},985885,e=>{"use strict";var t=e.i(840885),n=e.i(376922),a=e.i(939299),i=e.i(849050),r=e.i(733182),s=e.i(374402),l=e.i(71977),o=e.i(280958),c=e.i(318151),d=e.i(351777);let u=Object.freeze([]);function m(e){return{id:e.id,identityAbout:{name:e.name,kind:"bot"},avatar:{avatar:e.image??(0,o.avatarInitial)(e.name),avatarVersion:e.avatarVersion}}}function h(e,t){e.invalidateQueries({queryKey:s.communityKeys.bots()}),e.invalidateQueries({queryKey:s.communityKeys.friends()}),e.invalidateQueries({queryKey:s.communityKeys.dms()}),t&&e.invalidateQueries({queryKey:s.communityKeys.profile(t)})}e.s(["useBots",0,function(){let e=(0,t.useQuery)({queryKey:s.communityKeys.bots(),queryFn:()=>(0,r.apiFetchProfiles)("/api/community/bots",e=>e.bots.map(m))}),n=(0,l.useCommunityWsStore)(e=>e.profilesByUserId),a=(0,c.useMemo)(()=>(e.data?.bots??u).map(e=>{let t=(0,d.readCommunityProfile)(n.get(e.id),e.id);return{...e,name:t.name,image:t.avatar,avatarVersion:t.avatarVersion}}),[n,e.data?.bots]);return{...e,bots:a}},"useCreateBot",0,function(){let e=(0,a.useQueryClient)();return(0,n.useMutation)({mutationFn:e=>(0,i.apiFetch)("/api/community/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),onSuccess:t=>{let n=l.useCommunityWsStore.getState();n.patchProfiles(n.beginProfileSnapshot(),[m(t.bot)]),h(e,t.bot.id)}})},"useDeleteBot",0,function(){let e=(0,a.useQueryClient)();return(0,n.useMutation)({mutationFn:e=>(0,i.apiFetch)(`/api/community/bots/${e}`,{method:"DELETE"}),onSuccess:(t,n)=>h(e,n)})},"useResetBotSession",0,function(){let e=(0,a.useQueryClient)();return(0,n.useMutation)({mutationFn:e=>(0,i.apiFetch)(`/api/community/bots/${e}/reset-session`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:s.communityKeys.botAuditLog(n)})}})},"useResetMachineAgents",0,function(){return(0,n.useMutation)({mutationFn:e=>(0,i.apiFetch)(`/api/community/machines/${e}/reset-agents`,{method:"POST"})})},"useUpdateBot",0,function(){let e=(0,a.useQueryClient)();return(0,n.useMutation)({mutationFn:e=>(0,i.apiFetch)(`/api/community/bots/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,image:e.image,..."model"in e?{model:e.model}:{},..."runtime"in e?{runtime:e.runtime}:{},..."reasoningEffort"in e?{reasoningEffort:e.reasoningEffort}:{}})}),onSuccess:t=>{let n=l.useCommunityWsStore.getState();n.patchProfiles(n.beginProfileSnapshot(),[m(t.bot)]),h(e,t.bot.id)}})},"useUploadBotAvatar",0,function(){let e=(0,a.useQueryClient)();return(0,n.useMutation)({mutationFn:async({botId:e,file:t})=>{let n=new FormData;n.append("file",t);let a=await fetch(`/api/community/bots/${e}/avatar`,{method:"POST",body:n,credentials:"include"});if(!a.ok)throw await (0,i.readUploadError)(a,"Upload failed");return await a.json()},onSuccess:(t,n)=>{let a=l.useCommunityWsStore.getState();a.patchProfiles(a.beginProfileSnapshot(),[{id:n.botId,avatar:{avatar:t.url,avatarVersion:t.avatarVersion}}]),h(e,n.botId)}})}])},617527,e=>{"use strict";var t=e.i(840885),n=e.i(849050),a=e.i(374402);let i=Object.freeze([]),r=()=>(0,n.apiFetch)("/api/community/machines");e.s(["machinesQueryFn",0,r,"useMachines",0,function(){let e=(0,t.useQuery)({queryKey:a.communityKeys.machines(),queryFn:r});return{...e,machines:e.data?.machines??i}}])},184526,e=>{"use strict";var t=e.i(318151),n=e.i(998808);e.i(954194);var a=e.i(908967);let i=[.8,.7,.6,.5,.4,.3,.2],r=new Set(["image/png","image/jpeg","image/webp","image/gif"]);class s extends Error{}async function l(e){var t;let n;if(!((t=e).type.startsWith("image/")&&"image/svg+xml"!==t.type))return null;try{n=URL.createObjectURL(e);let t=await c(n),{w:a,h:i}=d(t.naturalWidth,t.naturalHeight,200),r=await m(t,a,i,.7);if(!r)return null;return{blob:r,width:t.naturalWidth,height:t.naturalHeight}}catch{return null}finally{n&&URL.revokeObjectURL(n)}}async function o(e){let t;if(!r.has(e.type.toLowerCase()))return null;let n=e.size>a.MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES;try{t=URL.createObjectURL(e);let i=await c(t),r=i.naturalWidth,l=i.naturalHeight;if(!(n=Math.max(r,l)>a.MAX_ATTACHMENT_THUMBNAIL_EDGE_PX||n))return{blob:null,width:r,height:l};let o=await h(i);if(!o)throw new s;return{blob:o,width:r,height:l}}catch(e){if(e instanceof s||n)throw Error("could not generate a required image preview");return null}finally{t&&URL.revokeObjectURL(t)}}function c(e){return new Promise((t,n)=>{let a=new Image;a.onload=()=>t(a),a.onerror=n,a.src=e})}function d(e,t,n){if(e<=n&&t<=n)return{w:e,h:t};let a=Math.min(n/e,n/t);return{w:Math.round(e*a),h:Math.round(t*a)}}function u(e,t,n){return new Promise(a=>e.toBlob(a,t,n))}async function m(e,t,n,a){let i=document.createElement("canvas");i.width=t,i.height=n;let r=i.getContext("2d");return r?(r.drawImage(e,0,0,t,n),u(i,"image/jpeg",a)):null}async function h(e){let t=d(e.naturalWidth,e.naturalHeight,a.MAX_ATTACHMENT_THUMBNAIL_EDGE_PX);for(let n=0;n<10;n++){let r=.85**n,s=Math.max(1,Math.round(t.w*r)),l=Math.max(1,Math.round(t.h*r)),o=document.createElement("canvas");o.width=s,o.height=l;let c=o.getContext("2d");if(!c)break;for(let t of(c.drawImage(e,0,0,s,l),i)){let e=await u(o,"image/jpeg",t);if(!e)return null;if(e.size<=a.MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES)return e}}return null}let f=new Map;function x(e){return e.reduce((e,t)=>e+t.file.size,0)}function g(e,t,n){let a=t.map(e=>({...e,touchedAt:n}));return f.delete(e),a.length>0&&f.set(e,a),a}function p(e,t){return 0===e.length||t-e[0].touchedAt>=864e5}function v(e,t){let n=0;for(let[a,i]of f)a!==e&&p(i,t)&&(f.delete(a),n++);return n}function y(e,t,n=Date.now()){if(0===t.length)return;let a=f.get(e);if(!a)return;let i=new Set(t);g(e,a.filter(e=>!i.has(e.draftId)),n)}let b=0;function j(e){for(let t of e)t.thumbnailUrl&&URL.revokeObjectURL(t.thumbnailUrl)}e.s(["useFileAttachments",0,function(e={}){let a=e.maxFileSize??0xa00000,i=e.maxFiles,r=e.thumbnailPolicy??"legacy",s=(0,t.useRef)({maxFileSize:a,maxFiles:i,thumbnailPolicy:r,draftSessionScope:e.draftSessionScope});(0,t.useLayoutEffect)(()=>{s.current={maxFileSize:a,maxFiles:i,thumbnailPolicy:r,draftSessionScope:e.draftSessionScope}});let[c,d]=(0,t.useState)([]),u=(0,t.useRef)(c),m=(0,t.useRef)(Promise.resolve()),h=(0,t.useRef)(0),k=(0,t.useRef)(new Map),N=(0,t.useRef)(!0),w=(0,t.useCallback)(e=>{let t=u.current,n="function"==typeof e?e(t):e;if(0===n.length){var a;s.current.draftSessionScope&&(a=s.current.draftSessionScope,f.delete(a)),h.current++,k.current.clear(),t.length>0&&j(t)}u.current=n,d(n)},[]),C=(0,t.useCallback)(()=>{var e;let t,n=u.current;return s.current.draftSessionScope&&(e=s.current.draftSessionScope,t=f.get(e)??[],f.delete(e),t.map(({draftId:e,file:t})=>({draftId:e,file:t}))),h.current++,k.current.clear(),u.current=[],d([]),n},[]);(0,t.useEffect)(()=>(N.current=!0,()=>{N.current=!1,j(u.current)}),[]);let S=(0,t.useRef)(null),P=(0,t.useCallback)(async(e,t,a,i)=>{let r=m.current.then(async()=>{let r=await Promise.all(e.map(async({draftId:e,file:r})=>{if("community"===a)try{let t=await o(r),n=t?.blob??(t?r:null);return{draftId:e,file:r,thumbnailUrl:n?URL.createObjectURL(n):null,thumbnailBlob:t?.blob??null,width:t?.width,height:t?.height}}catch{return N.current&&h.current===t&&(n.toast.error(`Could not prepare "${r.name}" for upload`),i&&y(i,[e])),null}let s=await l(r);return{draftId:e,file:r,thumbnailUrl:s?URL.createObjectURL(s.blob):null,thumbnailBlob:s?.blob??null,width:s?.width,height:s?.height}}));for(let{draftId:n}of e)k.current.get(n)===t&&k.current.delete(n);let s=r.filter(e=>null!==e);if(0===s.length)return;if(!N.current||h.current!==t)return void j(s);let c=new Set(u.current.map(e=>e.draftId)),m=[...u.current,...s.filter(e=>!c.has(e.draftId))];u.current=m,d(m)});m.current=r.catch(()=>{}),await r},[]),M=(0,t.useCallback)(async e=>{let{maxFileSize:t,maxFiles:a,thumbnailPolicy:i,draftSessionScope:r}=s.current,l=[];for(let a of e){if(a.size>t){let e=Math.floor(t/1024/1024);n.toast.error(`"${a.name}" exceeds ${e} MB limit`);continue}l.push(a)}if(0===l.length)return;let o=u.current.length+k.current.size;if(void 0!==a&&o+l.length>a)return void n.toast.error(`You can attach up to ${a} files`);let c=l.map(e=>({draftId:globalThis.crypto?.randomUUID?.()??`attachment-draft-${++b}`,file:e}));if(r){let e=function(e,t,n=Date.now()){if(0===t.length)return{accepted:!0,evictedScopes:0};let a=f.get(e)??[],i=new Set(a.map(e=>e.draftId)),r=[...a,...t.filter(e=>!i.has(e.draftId)).map(e=>({...e,touchedAt:n}))];if(x(r)>0x10000000)return{accepted:!1,evictedScopes:0};let s=v(e,n),l=f.has(e),o=()=>f.size+ +!l,c=()=>(function(){let e=0;for(let t of f.values())e+=x(t);return e})()-x(a)+x(r);for(;o()>50||c()>0x10000000;){let t=[...f.keys()].find(t=>t!==e);if(!t)return{accepted:!1,evictedScopes:s};f.delete(t),s++}return g(e,r,n),{accepted:!0,evictedScopes:s}}(r,c);if(e.evictedScopes>0&&n.toast.info("Older attachment drafts were cleared to free memory"),!e.accepted)return void n.toast.error("These files exceed the attachment draft memory limit")}let d=h.current;for(let{draftId:e}of c)k.current.set(e,d);await P(c,d,i,r)},[P]),A=(0,t.useCallback)(async e=>{let t=u.current;h.current++;let n=h.current;k.current.clear(),u.current=[],d([]),j(t);let{maxFiles:a,thumbnailPolicy:i,draftSessionScope:r}=s.current,l=void 0===a?e:e.slice(0,a);for(let{draftId:e}of l)k.current.set(e,n);l.length>0&&await P(l,n,i,r)},[P]);(0,t.useLayoutEffect)(()=>{"community"!==r||A(e.draftSessionScope?function(e,t=Date.now()){let n=f.get(e);if(!n)return v(e,t),[];if(p(n,t))return f.delete(e),v(e,t),[];let a=g(e,n,t);return v(e,t),a.map(({draftId:e,file:t})=>({draftId:e,file:t}))}(e.draftSessionScope):[])},[e.draftSessionScope,A,r]);let T=(0,t.useCallback)(async()=>{for(;;){let e=m.current;if(await e,e===m.current)return u.current}},[]),R=(0,t.useCallback)(e=>{let t=e.target.files;t&&(M(Array.from(t)),e.target.value="")},[M]),D=(0,t.useCallback)(e=>{let t=u.current,n=t[e];n?.draftId&&s.current.draftSessionScope&&y(s.current.draftSessionScope,[n.draftId]),n?.thumbnailUrl&&URL.revokeObjectURL(n.thumbnailUrl);let a=t.filter((t,n)=>n!==e);u.current=a,d(a)},[]),[I,z]=(0,t.useState)(!1),$=(0,t.useRef)(0),E=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),$.current++,e.dataTransfer.types.includes("Files")&&z(!0)},[]),U=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),$.current--,0===$.current&&z(!1)},[]),B=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),L=(0,t.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),z(!1),$.current=0,M(Array.from(e.dataTransfer.files))},[M]);return{pendingFiles:c,setPendingFiles:w,transferPendingFiles:C,restorePendingFiles:A,awaitPendingFiles:T,fileInputRef:S,addPendingFiles:M,handleFileSelect:R,removePendingFile:D,dragging:I,handleDragEnter:E,handleDragLeave:U,handleDragOver:B,handleDrop:L}}],184526)},853049,e=>{"use strict";var t=e.i(318151);e.s(["useHoverCapable",0,function(){let[e,n]=t.useState(!0);return t.useEffect(()=>{if(!window.matchMedia)return;let e=window.matchMedia("(hover: hover) and (pointer: fine)"),t=()=>n(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),e}])},939088,e=>{"use strict";var t=e.i(909832);e.s(["randomBotName",0,function(){return(0,t.uniqueNamesGenerator)({dictionaries:[t.names],length:1,style:"capital"})}])},622435,e=>{"use strict";function t(){return{route:"unknown",surface:"neutral",rail:"none",sidebar:{kind:"none"},main:{kind:"route-resolution"}}}function n(e){let n=function(e){if(!e.startsWith("/"))return null;let t=e.slice(1).split("/");if(""===t.at(-1)&&t.pop(),t.some(e=>0===e.length))return null;try{let e=t.map(e=>decodeURIComponent(e));if(e.some(e=>!e||/[/?#\\]/.test(e)))return null;return e}catch{return null}}(e.split(/[?#]/,1)[0]||"/");if(!n||"c"!==n[0])return t();if(1===n.length)return{route:"community-root-redirect",surface:"neutral",rail:"none",sidebar:{kind:"none"},main:{kind:"route-resolution"}};if("invite"===n[1]&&3===n.length)return{route:"public-invite",surface:"neutral",rail:"none",sidebar:{kind:"none"},main:{kind:"none"}};if("me"===n[1]){if(2===n.length)return{route:"me-root",surface:"list",rail:"community",sidebar:{kind:"me"},main:{kind:"me-root"}};if(3!==n.length)return t();let e=n[2];return"friends"===e?{route:"me-friends",surface:"detail",rail:"community",sidebar:{kind:"me"},main:{kind:"friends"}}:"machines"===e?{route:"me-machines",surface:"detail",rail:"community",sidebar:{kind:"me"},main:{kind:"machines"}}:"bots"===e?{route:"me-bots",surface:"detail",rail:"community",sidebar:{kind:"me"},main:{kind:"bots"}}:{route:"dm-detail",surface:"detail",rail:"community",sidebar:{kind:"me"},main:{kind:"dm",dmId:e}}}if("channels"===n[1]){if(n.length<3||n.length>4)return t();let e=n[2],a={kind:"server",serverId:e};if(3===n.length)return{route:"server-root",surface:"list",rail:"community",sidebar:a,main:{kind:"server-landing",serverId:e}};let i=n[3];return"settings"===i?{route:"server-settings-redirect",canonicalHref:`/c/channels/${encodeURIComponent(e)}`,surface:"list",rail:"community",sidebar:a,main:{kind:"server-landing",serverId:e}}:{route:"server-detail",surface:"detail",rail:"community",sidebar:a,main:{kind:"server-conversation",serverId:e,leafId:i}}}return t()}function a(e){let t=e.indexOf("#"),a=-1===t?e:e.slice(0,t),i=a.indexOf("?"),r=-1===i?a:a.slice(0,i),s=new URLSearchParams(-1===i?"":a.slice(i+1));s.sort();let l=s.toString(),o=n(r);return{href:`${r}${l?`?${l}`:""}`,pathname:r,search:l,scope:"server"===o.sidebar.kind?{kind:"server",serverId:o.sidebar.serverId}:"me"===o.sidebar.kind?{kind:"me"}:{kind:"unknown"},surface:"list"===o.surface?"list":"detail",leafKey:r}}function i(e,t=e.href){return{mode:"committed",surface:e.surface,targetHref:t,rail:{kind:"keep"},sidebar:{kind:"keep"},main:{kind:"keep"}}}function r(e){return`/c/channels/${e}`}function s(e,t){var n,a;let i,r,s,l,o,c,d;return n=e,a=e=>{e.delete(t)},r=-1===(i=n.indexOf("#"))?"":n.slice(i),o=-1===(l=(s=-1===i?n:n.slice(0,i)).indexOf("?"))?s:s.slice(0,l),a(c=new URLSearchParams(-1===l?"":s.slice(l+1))),d=c.toString(),`${o}${d?`?${d}`:""}${r}`}e.s(["advanceCommunityCommittedFrame",0,function(e,t){let n=a(t);return e.leafKey===n.leafKey?e:{...n,revision:e.revision+1}},"channelHref",0,function(e,t){return`${r(e)}/${t}`},"isPublishedNonStructuralCommit",0,function(e,t,n){let i=a(t),r=a(n);return e.leafKey===r.leafKey&&i.href===r.href},"isStructuralFrameCommit",0,function({committedFrame:e,targetHref:t,baselineRevision:n}){return!(e.revision<=n)&&e.leafKey===a(t).leafKey},"normalizeCommunityHref",0,a,"removeCommunityParam",0,s,"resolveCommunityCheckpointPlan",0,function({committedFrame:e,targetHref:t,pending:r,targetReady:s}){var l,o;if(!r||!t)return i(e);let c=a(t),d=n(c.href).main.kind,u="server-conversation"===d||"dm"===d;if("unknown"===c.scope.kind||c.leafKey===e.leafKey)return i(e,c.href);if(l=e.scope,o=c.scope,l.kind===o.kind&&("server"===l.kind&&"server"===o.kind?l.serverId===o.serverId:"unknown"!==l.kind))return{mode:"same-scope-leaf",surface:c.surface,targetHref:c.href,rail:{kind:"keep"},sidebar:{kind:"keep"},main:u?{kind:"target-skeleton",href:c.href}:{kind:"keep"}};if(s)return{...i(e,c.href),mode:"warm-scope",surface:c.surface,main:u?{kind:"target-skeleton",href:c.href}:{kind:"keep"}};let m="server"===c.scope.kind?{kind:"target",view:"server",activeServerId:c.scope.serverId}:{kind:"target",view:"dm"},h="server"===c.scope.kind?{kind:"server-skeleton",serverId:c.scope.serverId}:{kind:"me-skeleton"};return{mode:"cold-scope",surface:c.surface,targetHref:c.href,rail:m,sidebar:h,main:{kind:"target-skeleton",href:c.href}}},"resolveCommunityModulePlan",0,n,"resolveCommunityRoute",0,function(e){let t=n(e);return"dm-detail"===t.route||t.route.startsWith("me-")?"detail"===t.surface?{surface:"detail",parentPath:"/c/me"}:{surface:"list",parentPath:null}:"server"===t.sidebar.kind?"detail"===t.surface?{surface:"detail",parentPath:r(t.sidebar.serverId)}:{surface:"list",parentPath:null}:{surface:"list"===t.surface?"list":"detail",parentPath:null}},"serverModalMarkerCleanupHref",0,function(e,{breakpoint:t,hasChannel:n,hasServerChannels:a}){let i=e.indexOf("#"),r=-1===i?e:e.slice(0,i),l=r.indexOf("?"),o=new URLSearchParams(-1===l?"":r.slice(l+1));return"1"!==o.get("settings")&&"1"!==o.get("invite")||"desktop"===t&&!n&&a?null:s(s(e,"settings"),"invite")},"serverRootHref",0,r])},450463,e=>{"use strict";function t(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let n=Math.floor((new Date().getTime()-t.getTime())/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;let a=Math.floor(n/60);if(a<24)return`${a}h ago`;let i=Math.floor(a/24);return i<7?`${i}d ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"})}e.s(["relativeTime",0,t,"timeAgo",0,function(e){return e?t(e):"never"}])}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,716032,e=>{"use strict";var s=e.i(274570),t=e.i(318151),a=e.i(255334),r=e.i(613349),i=e.i(998808),n=e.i(735642);e.i(954194);var l=e.i(991004),c=e.i(500324),d=e.i(23055);e.i(427681);var o=e.i(822755),m=e.i(186339),u=e.i(903477),x=e.i(473131),h=e.i(728886),p=e.i(553617),f=e.i(205189);function g(){let{workspaceId:e,slug:a}=(0,c.useWorkspace)(),r=(0,d.useSession)(),g=(0,n.useRouter)(),[j,v]=(0,t.useState)(""),[N,b]=(0,t.useState)(!0),[w,y]=(0,t.useState)(""),[k,C]=(0,t.useState)(""),[T,S]=(0,t.useState)(""),[E,_]=(0,t.useState)(""),[M,P]=(0,t.useState)(!1),[z,$]=(0,t.useState)({}),[I,O]=(0,t.useState)(""),[R,A]=(0,t.useState)(!1),F=(0,t.useCallback)(async()=>{b(!0);try{let s=r.data?.user?.id,[t,a]=await Promise.all([(0,o.listMembers)(e),(0,o.listWorkspaces)()]),i=t.find(e=>e.user_id===s);v(i?.role??"");let n=a.find(s=>s.id===e);n&&(y(n.name),C(n.slug),S(n.name),_(n.slug))}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load workspace info")}finally{b(!1)}},[e,r.data?.user?.id]);(0,t.useEffect)(()=>{r.data&&F()},[F,r.data]);let L=w!==T||k!==E,D=async()=>{let s=(0,l.sanitizeSlug)(k);C(s);let t=(0,p.validateWorkspaceForm)({name:w,slug:s});if($(t),!(0,p.hasWorkspaceFormErrors)(t)){P(!0);try{let t=await (0,o.updateWorkspace)(e,{name:w.trim(),slug:s});(0,f.trackSettingsUpdated)({setting_tab:"general"}),S(t.name),_(t.slug),i.toast.success("Workspace updated"),t.slug!==a&&g.replace(`/w/${t.slug}/settings`)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to update workspace")}finally{P(!1)}}},W=async()=>{if(I===T){A(!0);try{await (0,o.deleteWorkspace)(e,T),i.toast.success("Workspace deleted"),g.replace("/workspaces")}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to delete workspace")}finally{A(!1)}}};return N?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(h.Skeleton,{className:"h-4 w-32"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"})]}):"owner"!==j?(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-2",children:[(0,s.jsx)(x.Label,{htmlFor:"workspace-name",children:"Name"}),(0,s.jsx)(u.Input,{id:"workspace-name",value:w,onChange:e=>{let s=e.target.value;y(s),z.name&&s.trim()&&$(e=>({...e,name:void 0}))},placeholder:"Workspace name","aria-invalid":!!z.name,"aria-describedby":z.name?"workspace-name-error":void 0}),z.name&&(0,s.jsx)("p",{id:"workspace-name-error",className:"text-xs text-destructive",children:z.name})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(x.Label,{htmlFor:"workspace-slug",children:"Slug"}),(0,s.jsx)(u.Input,{id:"workspace-slug",value:k,onChange:e=>{let s=e.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,"-");C(s),z.slug&&s.trim()&&$(e=>({...e,slug:void 0}))},onBlur:()=>C(e=>(0,l.sanitizeSlug)(e)),placeholder:"workspace-slug","aria-invalid":!!z.slug,"aria-describedby":z.slug?"workspace-slug-error":void 0}),z.slug&&(0,s.jsx)("p",{id:"workspace-slug-error",className:"text-xs text-destructive",children:z.slug}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/70",children:["Used in URLs: /w/",k,"/"]})]})]}),(0,s.jsx)(m.Button,{size:"sm",onClick:D,disabled:!L||M,children:M?"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-2",children:[(0,s.jsxs)(x.Label,{htmlFor:"delete-confirm",className:"text-xs",children:["Type ",(0,s.jsx)("span",{className:"font-medium text-foreground",children:T})," to confirm"]}),(0,s.jsx)(u.Input,{id:"delete-confirm",value:I,onChange:e=>O(e.target.value),placeholder:T})]}),(0,s.jsx)(m.Button,{size:"sm",variant:"destructive",onClick:W,disabled:I!==T||R,children:R?"Deleting…":"Delete Workspace"})]})]})]})}var j=e.i(740513);function v({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 N(){let{workspaceId:e}=(0,c.useWorkspace)(),[a,r]=(0,t.useState)(""),[n,l]=(0,t.useState)(""),[d,m]=(0,t.useState)(!0),u=(0,t.useRef)(a);(0,t.useEffect)(()=>{u.current=a},[a]);let x=(0,t.useRef)(n);(0,t.useEffect)(()=>{x.current=n},[n]);let p=(0,t.useRef)(null),f=(0,t.useRef)(!1),g=(0,t.useCallback)(async()=>{m(!0);try{let s=await (0,o.getMemberMe)(e);r(s.global_instruction),l(s.global_instruction)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load settings")}finally{m(!1)}},[e]);(0,t.useEffect)(()=>{g()},[g]);let N=(0,t.useRef)(()=>{}),b=(0,t.useCallback)(async()=>{if(f.current)return;let s=u.current;if(s!==x.current){f.current=!0;try{let t=await (0,o.updateMemberMe)(e,s);l(t.global_instruction)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to save")}finally{f.current=!1,u.current!==x.current&&N.current()}}},[e]),w=(0,t.useCallback)(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(b,500)},[b]);(0,t.useEffect)(()=>{N.current=w},[w]);let y=(0,t.useCallback)(e=>{r(e),w()},[w]);(0,t.useEffect)(()=>{let s=()=>{if(p.current&&clearTimeout(p.current),u.current!==x.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!==x.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 k=a.length/5e4;return d?(0,s.jsxs)("div",{className:"px-6 py-6 space-y-4",children:[(0,s.jsx)(h.Skeleton,{className:"h-4 w-48"}),(0,s.jsx)(h.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)(j.MarkdownEditor,{value:a,onChange:y,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)(v,{ratio:k}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"This instruction is prepended to every agent's individual instruction."})]})]})}var b=e.i(853068),w=e.i(963366),y=e.i(784002),k=e.i(180410),C=e.i(329686),T=e.i(132977);e.i(400175);var S=e.i(209274);function E(e){return`${window.location.origin}/invite/${e}`}function _(){let{workspaceId:e}=(0,c.useWorkspace)(),a=(0,d.useSession)(),n=a.data?.user?.id,[l,u]=(0,t.useState)([]),[x,p]=(0,t.useState)([]),[g,j]=(0,t.useState)(!0),[v,N]=(0,t.useState)(!1),_=l.find(e=>e.user_id===n)?.role==="owner",M=(0,t.useCallback)(async()=>{j(!0);try{let[s,t]=await Promise.all([(0,o.listMembers)(e),(0,o.listInvites)(e).catch(()=>[])]);u(s),p(t)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load members")}finally{j(!1)}},[e]);(0,t.useEffect)(()=>{M()},[M]);let P=async()=>{N(!0);try{let s=await (0,o.createInvite)(e);(0,f.trackTeamMemberInvited)({workspace_id:e}),p(e=>[...e,s]);let t=E(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{N(!1)}},z=async e=>{let s=E(e);try{await navigator.clipboard.writeText(s),i.toast.success("Invite link copied")}catch{i.toast.error("Failed to copy link")}},$=async s=>{try{await (0,o.revokeInvite)(e,s),p(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")}},I=async s=>{try{await (0,o.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)(h.Skeleton,{className:"h-4 w-24"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-4 w-24 mt-6"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"})]}):(0,s.jsxs)("div",{className:"space-y-8",children:[_&&(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)(m.Button,{size:"sm",variant:"outline",onClick:P,disabled:v,children:[(0,s.jsx)(y.Plus,{className:"size-3.5 mr-1"}),v?"Generating…":"Generate invite link"]})]}),0===x.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-2",children:x.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-1",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)(m.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>z(e.token)}),children:(0,s.jsx)(b.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)(m.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>$(e.id)}),children:(0,s.jsx)(w.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-2",children:l.map(e=>{let t=e.user_id===n;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)(S.ProfileAvatar,{label:(0,T.displayName)(e),seed:e.user_id,src:e.image,size:28,"data-testid":`members-avatar-${e.user_id}`}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"text-sm font-medium truncate leading-tight",children:[(0,T.displayName)(e),t&&(0,s.jsx)("span",{className:"ml-2 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-2 py-1 rounded shrink-0","owner"===e.role?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:e.role}),_&&!t&&(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)(m.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive shrink-0",onClick:()=>I(e.id)}),children:(0,s.jsx)(k.UserMinus,{className:"size-3.5"})}),(0,s.jsx)(C.TooltipContent,{children:"Remove member"})]})]},e.id)})})]})]})}var M=e.i(885515),P=e.i(254618),z=e.i(980630);function $(){let[e,a]=(0,t.useState)(!1),[r,n]=(0,t.useState)([...z.NOTIFICATION_EVENTS]),[l,c]=(0,t.useState)(!0),[d,o]=(0,t.useState)(!1);(0,t.useEffect)(()=>{c((0,z.isNotificationSupported)()),a((0,z.getNotificationEnabled)()),n((0,z.getNotificationEvents)()),(0,z.isNotificationSupported)()&&o("denied"===Notification.permission)},[]);let m=async e=>{if(!e){a(!1),(0,z.setNotificationEnabled)(!1);return}await (0,z.requestNotificationPermission)()?(a(!0),(0,z.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-1",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)(P.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:"}),z.NOTIFICATION_EVENTS.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[(0,s.jsx)(M.Checkbox,{checked:r.includes(e),onCheckedChange:()=>{n(s=>{let t=s.includes(e)?s.filter(s=>s!==e):[...s,e];return(0,z.setNotificationEvents)(t),t})}}),z.NOTIFICATION_EVENT_LABELS[e]]},e))]})]})]})}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Your browser does not support notifications."})}var I=e.i(494916);let O=(0,I.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 R=e.i(399561),A=e.i(460520),F=e.i(961909),L=e.i(790961);function D(){let[e,a]=(0,t.useState)(!1),[i,n]=(0,t.useState)(R.CLOUD_CODE_MONSTER_PET_PRESETS[0].id),l=(0,R.getCloudCodeMonsterPreset)(i);return(0,t.useEffect)(()=>{a((0,L.readHomePetSettings)().enabled),n((0,R.readCloudCodeMonsterPetPresetId)());let e=e=>{let s=e.detail?.presetId;n(s?(0,R.getCloudCodeMonsterPreset)(s).id:(0,R.readCloudCodeMonsterPetPresetId)())};return window.addEventListener(A.CLOUD_CODE_MONSTER_PRESET_CHANGED_EVENT,e),()=>{window.removeEventListener(A.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-1",children:[(0,s.jsx)(x.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)(P.Switch,{id:"pet-enabled",checked:e,onCheckedChange:e=>{a(e),(0,L.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)(F.CloudCodeMonsterPresetPreview,{preset:l,className:"size-11"})})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:R.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,R.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)(F.CloudCodeMonsterPresetPreview,{preset:e,className:"size-14 transition-transform duration-200 group-hover:scale-105"})}),(0,s.jsxs)("div",{className:"mt-2 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)(O,{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 W=e.i(355578),B=e.i(934351),U=e.i(875061),H=e.i(253928),G=e.i(754535),V=e.i(991369),q=e.i(715783),J=e.i(865687);let K=(0,I.default)("zap",[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]);function Q({icon:e,label:t,value:a,sub:r}){return(0,s.jsx)(B.Card,{size:"sm",children:(0,s.jsxs)(B.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)(U.Badge,{variant:"secondary",className:"text-[10px] px-2 h-4 font-normal",children:r})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground truncate",children:t})]})]})})}function Y({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-6",children:[(0,s.jsx)(Q,{icon:J.Monitor,label:"Machines",value:`${l}/${n}`,sub:"online"}),(0,s.jsx)(Q,{icon:H.Bot,label:"Agents",value:e.length,sub:`${d} online`}),(0,s.jsx)(Q,{icon:q.Users,label:"Members",value:r.members.length,sub:r.pending_invites>0?`${r.pending_invites} pending`:void 0}),(0,s.jsx)(Q,{icon:K,label:"Active Tasks",value:c,sub:r.task_stats.queued>0?`${r.task_stats.queued} queued`:void 0}),(0,s.jsx)(Q,{icon:V.Send,label:"Emails Sent",value:r.email_stats.outbound,sub:`${r.email_stats.unread} unread`}),(0,s.jsx)(Q,{icon:G.Mail,label:"Custom Emails",value:r.email_accounts.length})]})}function Z({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)(B.Card,{children:[(0,s.jsx)(B.CardHeader,{children:(0,s.jsx)(B.CardTitle,{children:"Task Health (Today)"})}),(0,s.jsx)(B.CardContent,{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(X,{label:"Completed",value:t}),(0,s.jsx)(X,{label:"Failed",value:a,className:a>0?"text-destructive":void 0}),(0,s.jsx)(X,{label:"Cancelled",value:r}),(0,s.jsx)(X,{label:"Failure Rate",value:`${c}%`,className:Number(c)>10?"text-destructive":void 0}),(0,s.jsx)(X,{label:"Queue Backlog",value:i,className:i>10?"text-amber-500":void 0}),(0,s.jsx)(X,{label:"Stale Tasks",value:n,className:n>0?"text-destructive":void 0})]})})]})}function X({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 ee({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)(B.Card,{children:[(0,s.jsx)(B.CardHeader,{children:(0,s.jsx)(B.CardTitle,{children:"Email Summary"})}),(0,s.jsxs)(B.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 es=e.i(267767);function et({runtimes:e,agents:t}){let a=(0,n.useRouter)(),{slug:r}=(0,c.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 l=[...i.entries()];return 0===l.length?(0,s.jsxs)(B.Card,{children:[(0,s.jsxs)(B.CardHeader,{children:[(0,s.jsx)(B.CardTitle,{children:"Machines"}),(0,s.jsx)(B.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)(es.ArrowUpRight,{className:"size-4"})})})]}),(0,s.jsx)(B.CardContent,{children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No machines connected."})})]}):(0,s.jsxs)(B.Card,{children:[(0,s.jsx)(B.CardHeader,{children:(0,s.jsx)(B.CardTitle,{children:"Machines"})}),(0,s.jsx)(B.CardContent,{className:"space-y-3",children:l.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)(U.Badge,{variant:"outline",className:"text-[10px] px-2 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-1",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 ea({overview:e}){let t=(0,n.useRouter)(),{slug:a}=(0,c.useWorkspace)(),{members:r,pending_invites:i}=e;return(0,s.jsxs)(B.Card,{children:[(0,s.jsxs)(B.CardHeader,{children:[(0,s.jsx)(B.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)(es.ArrowUpRight,{className:"size-4"})})}),(0,s.jsxs)(B.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)(B.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",children:[(0,s.jsx)(S.ProfileAvatar,{label:(0,T.displayName)(e),seed:e.user_id,src:e.image,size:28,"data-testid":`team-access-avatar-${e.user_id}`}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-sm font-medium truncate block",children:(0,T.displayName)(e)}),e.name&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground truncate block",children:e.email})]}),(0,s.jsx)(U.Badge,{variant:"owner"===e.role?"default":"secondary",className:"text-[10px] px-2 py-0 shrink-0",children:e.role})]},e.id))})})]})}function er(){let{agents:e,runtimes:a,loading:r,activeTaskCounts:i}=(0,W.useAgentContext)(),{workspaceId:n}=(0,c.useWorkspace)(),[l,d]=(0,t.useState)(null),[m,u]=(0,t.useState)(!1);return((0,t.useEffect)(()=>{if(r)return;let e=!1;return u(!0),(0,o.getWorkspaceOverview)(n).then(s=>{e||d(s)}).catch(()=>{}).finally(()=>{e||u(!1)}),()=>{e=!0}},[r,n]),m||!l)?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(Y,{agents:e,runtimes:a,activeTaskCounts:i,overview:l}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsx)(Z,{overview:l}),(0,s.jsx)(ee,{overview:l,agents:e})]}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsx)(et,{runtimes:a,agents:e}),(0,s.jsx)(ea,{overview:l})]})]})}let ei=[{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 sm:px-4 py-2 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.jsxs)("nav",{className:"w-48 shrink-0 border-r border-border/50 py-3 px-2 hidden sm:flex sm:flex-col",children:[(0,s.jsx)("div",{className:"flex-1",children:ei.map(t=>(0,s.jsx)("button",{onClick:()=>i(t.id),className:(0,r.cn)("w-full rounded-md px-2 py-2 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:"px-2 pt-3 border-t border-border/50 text-[11px] text-muted-foreground/60",children:["v","0.1.34"]})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,s.jsx)("div",{className:"px-4 pt-2 sm: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:ei.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-4 py-4"),children:"instruction"===e?(0,s.jsx)(N,{}):"usages"===e?(0,s.jsx)(er,{}):(0,s.jsxs)("div",{className:"mx-auto max-w-md",children:["general"===e&&(0,s.jsx)(g,{}),"pet"===e&&(0,s.jsx)(D,{}),"notifications"===e&&(0,s.jsx)($,{}),"members"===e&&(0,s.jsx)(_,{})]})}),(0,s.jsxs)("div",{className:"px-4 py-2 text-[11px] text-muted-foreground/60 sm:hidden",children:["v","0.1.34"]})]})]})]})}],716032)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,716032,e=>{"use strict";var s=e.i(274570),t=e.i(318151),a=e.i(255334),r=e.i(613349),i=e.i(998808),n=e.i(735642);e.i(954194);var l=e.i(991004),c=e.i(500324),d=e.i(23055);e.i(427681);var o=e.i(822755),m=e.i(186339),u=e.i(903477),x=e.i(473131),h=e.i(728886),p=e.i(553617),f=e.i(205189);function g(){let{workspaceId:e,slug:a}=(0,c.useWorkspace)(),r=(0,d.useSession)(),g=(0,n.useRouter)(),[j,v]=(0,t.useState)(""),[N,b]=(0,t.useState)(!0),[w,y]=(0,t.useState)(""),[k,C]=(0,t.useState)(""),[T,S]=(0,t.useState)(""),[E,_]=(0,t.useState)(""),[M,P]=(0,t.useState)(!1),[z,$]=(0,t.useState)({}),[I,O]=(0,t.useState)(""),[R,A]=(0,t.useState)(!1),F=(0,t.useCallback)(async()=>{b(!0);try{let s=r.data?.user?.id,[t,a]=await Promise.all([(0,o.listMembers)(e),(0,o.listWorkspaces)()]),i=t.find(e=>e.user_id===s);v(i?.role??"");let n=a.find(s=>s.id===e);n&&(y(n.name),C(n.slug),S(n.name),_(n.slug))}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load workspace info")}finally{b(!1)}},[e,r.data?.user?.id]);(0,t.useEffect)(()=>{r.data&&F()},[F,r.data]);let L=w!==T||k!==E,D=async()=>{let s=(0,l.sanitizeSlug)(k);C(s);let t=(0,p.validateWorkspaceForm)({name:w,slug:s});if($(t),!(0,p.hasWorkspaceFormErrors)(t)){P(!0);try{let t=await (0,o.updateWorkspace)(e,{name:w.trim(),slug:s});(0,f.trackSettingsUpdated)({setting_tab:"general"}),S(t.name),_(t.slug),i.toast.success("Workspace updated"),t.slug!==a&&g.replace(`/w/${t.slug}/settings`)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to update workspace")}finally{P(!1)}}},W=async()=>{if(I===T){A(!0);try{await (0,o.deleteWorkspace)(e,T),i.toast.success("Workspace deleted"),g.replace("/workspaces")}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to delete workspace")}finally{A(!1)}}};return N?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(h.Skeleton,{className:"h-4 w-32"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"})]}):"owner"!==j?(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-2",children:[(0,s.jsx)(x.Label,{htmlFor:"workspace-name",children:"Name"}),(0,s.jsx)(u.Input,{id:"workspace-name",value:w,onChange:e=>{let s=e.target.value;y(s),z.name&&s.trim()&&$(e=>({...e,name:void 0}))},placeholder:"Workspace name","aria-invalid":!!z.name,"aria-describedby":z.name?"workspace-name-error":void 0}),z.name&&(0,s.jsx)("p",{id:"workspace-name-error",className:"text-xs text-destructive",children:z.name})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(x.Label,{htmlFor:"workspace-slug",children:"Slug"}),(0,s.jsx)(u.Input,{id:"workspace-slug",value:k,onChange:e=>{let s=e.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,"-");C(s),z.slug&&s.trim()&&$(e=>({...e,slug:void 0}))},onBlur:()=>C(e=>(0,l.sanitizeSlug)(e)),placeholder:"workspace-slug","aria-invalid":!!z.slug,"aria-describedby":z.slug?"workspace-slug-error":void 0}),z.slug&&(0,s.jsx)("p",{id:"workspace-slug-error",className:"text-xs text-destructive",children:z.slug}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/70",children:["Used in URLs: /w/",k,"/"]})]})]}),(0,s.jsx)(m.Button,{size:"sm",onClick:D,disabled:!L||M,children:M?"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-2",children:[(0,s.jsxs)(x.Label,{htmlFor:"delete-confirm",className:"text-xs",children:["Type ",(0,s.jsx)("span",{className:"font-medium text-foreground",children:T})," to confirm"]}),(0,s.jsx)(u.Input,{id:"delete-confirm",value:I,onChange:e=>O(e.target.value),placeholder:T})]}),(0,s.jsx)(m.Button,{size:"sm",variant:"destructive",onClick:W,disabled:I!==T||R,children:R?"Deleting…":"Delete Workspace"})]})]})]})}var j=e.i(740513);function v({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 N(){let{workspaceId:e}=(0,c.useWorkspace)(),[a,r]=(0,t.useState)(""),[n,l]=(0,t.useState)(""),[d,m]=(0,t.useState)(!0),u=(0,t.useRef)(a);(0,t.useEffect)(()=>{u.current=a},[a]);let x=(0,t.useRef)(n);(0,t.useEffect)(()=>{x.current=n},[n]);let p=(0,t.useRef)(null),f=(0,t.useRef)(!1),g=(0,t.useCallback)(async()=>{m(!0);try{let s=await (0,o.getMemberMe)(e);r(s.global_instruction),l(s.global_instruction)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load settings")}finally{m(!1)}},[e]);(0,t.useEffect)(()=>{g()},[g]);let N=(0,t.useRef)(()=>{}),b=(0,t.useCallback)(async()=>{if(f.current)return;let s=u.current;if(s!==x.current){f.current=!0;try{let t=await (0,o.updateMemberMe)(e,s);l(t.global_instruction)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to save")}finally{f.current=!1,u.current!==x.current&&N.current()}}},[e]),w=(0,t.useCallback)(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(b,500)},[b]);(0,t.useEffect)(()=>{N.current=w},[w]);let y=(0,t.useCallback)(e=>{r(e),w()},[w]);(0,t.useEffect)(()=>{let s=()=>{if(p.current&&clearTimeout(p.current),u.current!==x.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!==x.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 k=a.length/5e4;return d?(0,s.jsxs)("div",{className:"px-6 py-6 space-y-4",children:[(0,s.jsx)(h.Skeleton,{className:"h-4 w-48"}),(0,s.jsx)(h.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)(j.MarkdownEditor,{value:a,onChange:y,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)(v,{ratio:k}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"This instruction is prepended to every agent's individual instruction."})]})]})}var b=e.i(853068),w=e.i(963366),y=e.i(784002),k=e.i(180410),C=e.i(329686),T=e.i(132977);e.i(400175);var S=e.i(209274);function E(e){return`${window.location.origin}/invite/${e}`}function _(){let{workspaceId:e}=(0,c.useWorkspace)(),a=(0,d.useSession)(),n=a.data?.user?.id,[l,u]=(0,t.useState)([]),[x,p]=(0,t.useState)([]),[g,j]=(0,t.useState)(!0),[v,N]=(0,t.useState)(!1),_=l.find(e=>e.user_id===n)?.role==="owner",M=(0,t.useCallback)(async()=>{j(!0);try{let[s,t]=await Promise.all([(0,o.listMembers)(e),(0,o.listInvites)(e).catch(()=>[])]);u(s),p(t)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to load members")}finally{j(!1)}},[e]);(0,t.useEffect)(()=>{M()},[M]);let P=async()=>{N(!0);try{let s=await (0,o.createInvite)(e);(0,f.trackTeamMemberInvited)({workspace_id:e}),p(e=>[...e,s]);let t=E(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{N(!1)}},z=async e=>{let s=E(e);try{await navigator.clipboard.writeText(s),i.toast.success("Invite link copied")}catch{i.toast.error("Failed to copy link")}},$=async s=>{try{await (0,o.revokeInvite)(e,s),p(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")}},I=async s=>{try{await (0,o.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)(h.Skeleton,{className:"h-4 w-24"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-4 w-24 mt-6"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"}),(0,s.jsx)(h.Skeleton,{className:"h-10 w-full"})]}):(0,s.jsxs)("div",{className:"space-y-8",children:[_&&(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)(m.Button,{size:"sm",variant:"outline",onClick:P,disabled:v,children:[(0,s.jsx)(y.Plus,{className:"size-3.5 mr-1"}),v?"Generating…":"Generate invite link"]})]}),0===x.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-2",children:x.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-1",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)(m.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>z(e.token)}),children:(0,s.jsx)(b.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)(m.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>$(e.id)}),children:(0,s.jsx)(w.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-2",children:l.map(e=>{let t=e.user_id===n;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)(S.ProfileAvatar,{label:(0,T.displayName)(e),seed:e.user_id,src:e.image,size:28,"data-testid":`members-avatar-${e.user_id}`}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"text-sm font-medium truncate leading-tight",children:[(0,T.displayName)(e),t&&(0,s.jsx)("span",{className:"ml-2 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-2 py-1 rounded shrink-0","owner"===e.role?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:e.role}),_&&!t&&(0,s.jsxs)(C.Tooltip,{children:[(0,s.jsx)(C.TooltipTrigger,{render:(0,s.jsx)(m.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive shrink-0",onClick:()=>I(e.id)}),children:(0,s.jsx)(k.UserMinus,{className:"size-3.5"})}),(0,s.jsx)(C.TooltipContent,{children:"Remove member"})]})]},e.id)})})]})]})}var M=e.i(885515),P=e.i(254618),z=e.i(980630);function $(){let[e,a]=(0,t.useState)(!1),[r,n]=(0,t.useState)([...z.NOTIFICATION_EVENTS]),[l,c]=(0,t.useState)(!0),[d,o]=(0,t.useState)(!1);(0,t.useEffect)(()=>{c((0,z.isNotificationSupported)()),a((0,z.getNotificationEnabled)()),n((0,z.getNotificationEvents)()),(0,z.isNotificationSupported)()&&o("denied"===Notification.permission)},[]);let m=async e=>{if(!e){a(!1),(0,z.setNotificationEnabled)(!1);return}await (0,z.requestNotificationPermission)()?(a(!0),(0,z.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-1",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)(P.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:"}),z.NOTIFICATION_EVENTS.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[(0,s.jsx)(M.Checkbox,{checked:r.includes(e),onCheckedChange:()=>{n(s=>{let t=s.includes(e)?s.filter(s=>s!==e):[...s,e];return(0,z.setNotificationEvents)(t),t})}}),z.NOTIFICATION_EVENT_LABELS[e]]},e))]})]})]})}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Your browser does not support notifications."})}var I=e.i(494916);let O=(0,I.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 R=e.i(399561),A=e.i(460520),F=e.i(961909),L=e.i(790961);function D(){let[e,a]=(0,t.useState)(!1),[i,n]=(0,t.useState)(R.CLOUD_CODE_MONSTER_PET_PRESETS[0].id),l=(0,R.getCloudCodeMonsterPreset)(i);return(0,t.useEffect)(()=>{a((0,L.readHomePetSettings)().enabled),n((0,R.readCloudCodeMonsterPetPresetId)());let e=e=>{let s=e.detail?.presetId;n(s?(0,R.getCloudCodeMonsterPreset)(s).id:(0,R.readCloudCodeMonsterPetPresetId)())};return window.addEventListener(A.CLOUD_CODE_MONSTER_PRESET_CHANGED_EVENT,e),()=>{window.removeEventListener(A.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-1",children:[(0,s.jsx)(x.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)(P.Switch,{id:"pet-enabled",checked:e,onCheckedChange:e=>{a(e),(0,L.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)(F.CloudCodeMonsterPresetPreview,{preset:l,className:"size-11"})})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:R.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,R.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)(F.CloudCodeMonsterPresetPreview,{preset:e,className:"size-14 transition-transform duration-200 group-hover:scale-105"})}),(0,s.jsxs)("div",{className:"mt-2 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)(O,{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 W=e.i(355578),B=e.i(934351),U=e.i(875061),H=e.i(253928),G=e.i(754535),V=e.i(991369),q=e.i(715783),J=e.i(865687);let K=(0,I.default)("zap",[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]);function Q({icon:e,label:t,value:a,sub:r}){return(0,s.jsx)(B.Card,{size:"sm",children:(0,s.jsxs)(B.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)(U.Badge,{variant:"secondary",className:"text-[10px] px-2 h-4 font-normal",children:r})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground truncate",children:t})]})]})})}function Y({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-6",children:[(0,s.jsx)(Q,{icon:J.Monitor,label:"Machines",value:`${l}/${n}`,sub:"online"}),(0,s.jsx)(Q,{icon:H.Bot,label:"Agents",value:e.length,sub:`${d} online`}),(0,s.jsx)(Q,{icon:q.Users,label:"Members",value:r.members.length,sub:r.pending_invites>0?`${r.pending_invites} pending`:void 0}),(0,s.jsx)(Q,{icon:K,label:"Active Tasks",value:c,sub:r.task_stats.queued>0?`${r.task_stats.queued} queued`:void 0}),(0,s.jsx)(Q,{icon:V.Send,label:"Emails Sent",value:r.email_stats.outbound,sub:`${r.email_stats.unread} unread`}),(0,s.jsx)(Q,{icon:G.Mail,label:"Custom Emails",value:r.email_accounts.length})]})}function Z({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)(B.Card,{children:[(0,s.jsx)(B.CardHeader,{children:(0,s.jsx)(B.CardTitle,{children:"Task Health (Today)"})}),(0,s.jsx)(B.CardContent,{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(X,{label:"Completed",value:t}),(0,s.jsx)(X,{label:"Failed",value:a,className:a>0?"text-destructive":void 0}),(0,s.jsx)(X,{label:"Cancelled",value:r}),(0,s.jsx)(X,{label:"Failure Rate",value:`${c}%`,className:Number(c)>10?"text-destructive":void 0}),(0,s.jsx)(X,{label:"Queue Backlog",value:i,className:i>10?"text-amber-500":void 0}),(0,s.jsx)(X,{label:"Stale Tasks",value:n,className:n>0?"text-destructive":void 0})]})})]})}function X({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 ee({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)(B.Card,{children:[(0,s.jsx)(B.CardHeader,{children:(0,s.jsx)(B.CardTitle,{children:"Email Summary"})}),(0,s.jsxs)(B.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 es=e.i(267767);function et({runtimes:e,agents:t}){let a=(0,n.useRouter)(),{slug:r}=(0,c.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 l=[...i.entries()];return 0===l.length?(0,s.jsxs)(B.Card,{children:[(0,s.jsxs)(B.CardHeader,{children:[(0,s.jsx)(B.CardTitle,{children:"Machines"}),(0,s.jsx)(B.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)(es.ArrowUpRight,{className:"size-4"})})})]}),(0,s.jsx)(B.CardContent,{children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No machines connected."})})]}):(0,s.jsxs)(B.Card,{children:[(0,s.jsx)(B.CardHeader,{children:(0,s.jsx)(B.CardTitle,{children:"Machines"})}),(0,s.jsx)(B.CardContent,{className:"space-y-3",children:l.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)(U.Badge,{variant:"outline",className:"text-[10px] px-2 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-1",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 ea({overview:e}){let t=(0,n.useRouter)(),{slug:a}=(0,c.useWorkspace)(),{members:r,pending_invites:i}=e;return(0,s.jsxs)(B.Card,{children:[(0,s.jsxs)(B.CardHeader,{children:[(0,s.jsx)(B.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)(es.ArrowUpRight,{className:"size-4"})})}),(0,s.jsxs)(B.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)(B.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",children:[(0,s.jsx)(S.ProfileAvatar,{label:(0,T.displayName)(e),seed:e.user_id,src:e.image,size:28,"data-testid":`team-access-avatar-${e.user_id}`}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-sm font-medium truncate block",children:(0,T.displayName)(e)}),e.name&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground truncate block",children:e.email})]}),(0,s.jsx)(U.Badge,{variant:"owner"===e.role?"default":"secondary",className:"text-[10px] px-2 py-0 shrink-0",children:e.role})]},e.id))})})]})}function er(){let{agents:e,runtimes:a,loading:r,activeTaskCounts:i}=(0,W.useAgentContext)(),{workspaceId:n}=(0,c.useWorkspace)(),[l,d]=(0,t.useState)(null),[m,u]=(0,t.useState)(!1);return((0,t.useEffect)(()=>{if(r)return;let e=!1;return u(!0),(0,o.getWorkspaceOverview)(n).then(s=>{e||d(s)}).catch(()=>{}).finally(()=>{e||u(!1)}),()=>{e=!0}},[r,n]),m||!l)?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"}),(0,s.jsx)(h.Skeleton,{className:"h-44 rounded-xl"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(Y,{agents:e,runtimes:a,activeTaskCounts:i,overview:l}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsx)(Z,{overview:l}),(0,s.jsx)(ee,{overview:l,agents:e})]}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsx)(et,{runtimes:a,agents:e}),(0,s.jsx)(ea,{overview:l})]})]})}let ei=[{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 sm:px-4 py-2 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.jsxs)("nav",{className:"w-48 shrink-0 border-r border-border/50 py-3 px-2 hidden sm:flex sm:flex-col",children:[(0,s.jsx)("div",{className:"flex-1",children:ei.map(t=>(0,s.jsx)("button",{onClick:()=>i(t.id),className:(0,r.cn)("w-full rounded-md px-2 py-2 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:"px-2 pt-3 border-t border-border/50 text-[11px] text-muted-foreground/60",children:["v","0.1.35"]})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,s.jsx)("div",{className:"px-4 pt-2 sm: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:ei.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-4 py-4"),children:"instruction"===e?(0,s.jsx)(N,{}):"usages"===e?(0,s.jsx)(er,{}):(0,s.jsxs)("div",{className:"mx-auto max-w-md",children:["general"===e&&(0,s.jsx)(g,{}),"pet"===e&&(0,s.jsx)(D,{}),"notifications"===e&&(0,s.jsx)($,{}),"members"===e&&(0,s.jsx)(_,{})]})}),(0,s.jsxs)("div",{className:"px-4 py-2 text-[11px] text-muted-foreground/60 sm:hidden",children:["v","0.1.35"]})]})]})]})}],716032)}]);