@alook/app 0.0.71 → 0.0.73

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 (146) hide show
  1. package/bundled/email-worker/index.js +45 -41
  2. package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
  3. package/bundled/web/.open-next/assets/BUILD_ID +1 -1
  4. package/bundled/web/.open-next/assets/_next/static/chunks/{01-oixdvo.kcw.js → 08py05dvbwpz..js} +15 -15
  5. package/bundled/web/.open-next/assets/_next/static/chunks/08q1jdm7c98jd.js +63 -0
  6. package/bundled/web/.open-next/assets/_next/static/chunks/{08vzc8ntbbjoe.js → 0hxwcjbgkr~0_.js} +1 -1
  7. package/bundled/web/.open-next/assets/_next/static/chunks/{0ymb~iviyjlb_.js → 0o3ol51uyvngq.js} +2 -2
  8. package/bundled/web/.open-next/assets/_next/static/chunks/{0va5axmz5ywg8.js → 0r91umgrdcg_w.js} +2 -2
  9. package/bundled/web/.open-next/assets/_next/static/chunks/0z1nxwsyi9qzp.js +1 -0
  10. package/bundled/web/.open-next/cache/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/_global-error.cache +1 -1
  11. package/bundled/web/.open-next/cache/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/_not-found.cache +1 -1
  12. package/bundled/web/.open-next/cache/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/sitemap.xml.cache +1 -1
  13. package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
  14. package/bundled/web/.open-next/cloudflare/init.js +1 -1
  15. package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
  16. package/bundled/web/.open-next/middleware/handler.mjs +4 -4
  17. package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
  18. package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
  19. package/bundled/web/.open-next/server-functions/default/src/web/.next/prerender-manifest.json +3 -3
  20. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
  21. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/page_client-reference-manifest.js +1 -1
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
  31. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
  32. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/flags/page_client-reference-manifest.js +1 -1
  33. 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
  34. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
  35. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
  36. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
  37. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/page_client-reference-manifest.js +1 -1
  38. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/[traceId]/page_client-reference-manifest.js +1 -1
  39. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/page_client-reference-manifest.js +1 -1
  40. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
  41. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/workspaces/page_client-reference-manifest.js +1 -1
  42. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(auth)/sign-in/page_client-reference-manifest.js +1 -1
  43. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  44. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/agent-links/route.js +2 -2
  45. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/agents/[id]/whitelist/route.js +2 -2
  46. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/agents/active-task-counts/route.js +1 -1
  47. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/agents/route.js +4 -4
  48. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/calendar/[id]/route.js +1 -1
  49. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/calendar/route.js +2 -2
  50. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/channels/[id]/route.js +2 -2
  51. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/channels/route.js +2 -2
  52. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/conversations/[id]/buffered-messages/route.js +2 -2
  53. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/register/route.js +3 -4
  54. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/tasks/[taskId]/complete/route.js +2 -3
  55. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/tasks/[taskId]/fail/route.js +2 -3
  56. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/tasks/[taskId]/messages/route.js +3 -4
  57. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/tasks/[taskId]/start/route.js +2 -3
  58. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/tasks/[taskId]/supersede/route.js +2 -3
  59. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/daemon/tasks/poll/route.js +6 -7
  60. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/email/notify/route.js +1 -1
  61. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/email/send/route.js +3 -3
  62. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/issues/[id]/route.js +1 -1
  63. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/issues/route.js +1 -1
  64. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/machine-tokens/activate/route.js +2 -2
  65. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/runtimes/route.js +4 -4
  66. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/studios/route.js +1 -1
  67. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/api/workspaces/[id]/route.js +2 -2
  68. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page_client-reference-manifest.js +1 -1
  69. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/[id]/page_client-reference-manifest.js +1 -1
  70. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/page_client-reference-manifest.js +1 -1
  71. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0.1vmoe._.js +6 -6
  72. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__027mioa._.js +10 -10
  73. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__02rso~7._.js +3 -0
  74. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__02wurdb._.js +3 -0
  75. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0dkg608._.js +3 -0
  76. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0grx101._.js +1 -1
  77. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/{[root-of-the-server]__0_.051i._.js → [root-of-the-server]__0gzp~d6._.js} +2 -2
  78. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0jvwtv1._.js +1 -1
  79. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0kc1f.6._.js +1 -1
  80. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0niqi98._.js +6 -6
  81. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0p769.0._.js +3 -0
  82. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0s0l_.j._.js +3 -0
  83. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0s9v7kt._.js +3 -0
  84. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0v.x5_r._.js +3 -0
  85. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[turbopack]_runtime.js +14 -14
  86. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0--kvw_._.js +3 -0
  87. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0-r4t0g._.js +1 -1
  88. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0266t8u._.js +2 -2
  89. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_05_d3df._.js +1 -1
  90. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_06.am62._.js +1 -1
  91. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_07-798_._.js +1 -1
  92. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_08mdiy6._.js +1 -1
  93. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_08z6pkf._.js +3 -0
  94. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_09j_99x._.js +2 -2
  95. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0csh82a._.js +3 -0
  96. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0exm5_w._.js +2 -2
  97. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0j.pt~7._.js +1 -1
  98. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0j1t6f2._.js +1 -1
  99. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0lmedw9._.js +1 -1
  100. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0ns9.qo._.js +1 -1
  101. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0u3tu2x._.js +2 -2
  102. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0w6dw.t._.js +2 -2
  103. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/src_0q3gvkd._.js +1 -1
  104. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0r2s1aj._.js +1 -1
  105. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[turbopack]_runtime.js +14 -14
  106. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_063q-hj._.js +1 -1
  107. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_07q6-kr._.js +3 -0
  108. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0ilz5db._.js +1 -1
  109. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0y3mwm6._.js +65 -0
  110. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_11~t2ti._.js +1 -1
  111. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_12e18r-._.js +1 -1
  112. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0j12j81._.js +3 -0
  113. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0~23g-y._.js +2 -2
  114. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
  115. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +5 -5
  116. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.js +1 -1
  117. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.json +1 -1
  118. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +54 -54
  119. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +677 -251
  120. package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +3 -3
  121. package/bundled/web/migrations/0030_task_queue_dispatch_index.sql +5 -0
  122. package/bundled/web/wrangler.toml +1 -1
  123. package/bundled/ws-do/index.js +39 -40
  124. package/dist/cli/index.js +12 -9
  125. package/dist/cli/session-runner.js +12 -9
  126. package/dist/index.js +1 -0
  127. package/package.json +1 -1
  128. package/bundled/web/.open-next/assets/_next/static/chunks/08u3p1v8e1gxg.js +0 -63
  129. package/bundled/web/.open-next/assets/_next/static/chunks/13lom177x6744.js +0 -1
  130. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__10-16_o._.js +0 -3
  131. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_02t7kem._.js +0 -3
  132. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0c9~wb-._.js +0 -3
  133. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0h6e0bb._.js +0 -3
  134. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0piy2kq._.js +0 -3
  135. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0s4qnoj._.js +0 -3
  136. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0sj8mn_._.js +0 -3
  137. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0tarogd._.js +0 -3
  138. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0tcd35h._.js +0 -3
  139. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0x0qvxd._.js +0 -3
  140. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0z.s70x._.js +0 -3
  141. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0st8pau._.js +0 -3
  142. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_13cbsrm._.js +0 -65
  143. /package/bundled/web/.open-next/assets/_next/static/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/_buildManifest.js +0 -0
  144. /package/bundled/web/.open-next/assets/_next/static/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/_clientMiddlewareManifest.js +0 -0
  145. /package/bundled/web/.open-next/assets/_next/static/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/_ssgManifest.js +0 -0
  146. /package/bundled/web/.open-next/cache/{FIBmbDYK-qE7gniasVcTA → hO1_nTdFBzjO6p-ajc4L9}/robots.txt.cache +0 -0
@@ -1,3 +1,3 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,949035,e=>{"use strict";let t=(0,e.i(406963).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",0,t],949035)},208020,(e,t,r)=>{t.exports=e.r(170928)},406963,e=>{"use strict";var t=e.i(298699);let r=(...e)=>e.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),n=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var a={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,t.createContext)({}),s=(0,t.forwardRef)(({color:e,size:n,strokeWidth:s,absoluteStrokeWidth:o,className:l="",children:d,iconNode:u,...c},f)=>{let{size:p=24,strokeWidth:g=2,absoluteStrokeWidth:m=!1,color:h="currentColor",className:v=""}=(0,t.useContext)(i)??{},b=o??m?24*Number(s??g)/Number(n??p):s??g;return(0,t.createElement)("svg",{ref:f,...a,width:n??p??a.width,height:n??p??a.height,stroke:e??h,strokeWidth:b,className:r("lucide",v,l),...!d&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(c)&&{"aria-hidden":"true"},...c},[...u.map(([e,r])=>(0,t.createElement)(e,r)),...Array.isArray(d)?d:[d]])});e.s(["default",0,(e,a)=>{let i=(0,t.forwardRef)(({className:i,...o},l)=>(0,t.createElement)(s,{ref:l,iconNode:a,className:r(`lucide-${n(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,i),...o}));return i.displayName=n(e),i}],406963)},616117,484665,e=>{"use strict";e.i(459119);var t=e.i(298699),r=e.i(92615),n=e.i(773825),a=e.i(389068),i=e.i(943891),s=e.i(398258);let o=t.createContext(void 0);function l(e=!1){let r=t.useContext(o);if(void 0===r&&!e)throw Error((0,s.default)(16));return r}function d(e){return(0,r.isHTMLElement)(e)&&"BUTTON"===e.tagName}e.s(["CompositeRootContext",0,o,"useCompositeRootContext",0,l],484665),e.s(["useButton",0,function(e={}){let{disabled:r=!1,focusableWhenDisabled:s,tabIndex:o=0,native:u=!0,composite:c}=e,f=t.useRef(null),p=l(!0),g=c??void 0!==p,{props:m}=function(e){let{focusableWhenDisabled:r,disabled:n,composite:a=!1,tabIndex:i=0,isNativeButton:s}=e,o=a&&!1!==r,l=a&&!1===r;return{props:t.useMemo(()=>{let e={onKeyDown(e){n&&r&&"Tab"!==e.key&&e.preventDefault()}};return a||(e.tabIndex=i,!s&&n&&(e.tabIndex=r?i:-1)),(s&&(r||o)||!s&&n)&&(e["aria-disabled"]=n),s&&(!r||l)&&(e.disabled=n),e},[a,n,r,o,l,s,i])}}({focusableWhenDisabled:s,disabled:r,composite:g,tabIndex:o,isNativeButton:u}),h=t.useCallback(()=>{let e=f.current;d(e)&&g&&r&&void 0===m.disabled&&e.disabled&&(e.disabled=!1)},[r,m.disabled,g]);return(0,a.useIsoLayoutEffect)(h,[h]),{getButtonProps:t.useCallback((e={})=>{let{onClick:t,onMouseDown:n,onKeyUp:a,onKeyDown:s,onPointerDown:o,...l}=e,c=u?"button":void 0;return(0,i.mergeProps)({type:c,onClick(e){r?e.preventDefault():t?.(e)},onMouseDown(e){r||n?.(e)},onKeyDown(e){var n;if(r||((0,i.makeEventPreventable)(e),s?.(e),e.baseUIHandlerPrevented))return;let a=e.target===e.currentTarget,o=e.currentTarget,l=d(o),c=!u&&(n=o,!!(n?.tagName==="A"&&n?.href)),f=a&&(u?l:!c),p="Enter"===e.key,m=" "===e.key,h=o.getAttribute("role"),v=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(a&&g&&m){if(e.defaultPrevented&&v)return;e.preventDefault(),c||u&&l?(o.click(),e.preventBaseUIHandler()):f&&(t?.(e),e.preventBaseUIHandler());return}f&&(!u&&(m||p)&&e.preventDefault(),!u&&p&&t?.(e))},onKeyUp(e){r||(((0,i.makeEventPreventable)(e),a?.(e),e.target===e.currentTarget&&u&&g&&d(e.currentTarget)&&" "===e.key)?e.preventDefault():!e.baseUIHandlerPrevented&&(e.target!==e.currentTarget||u||g||" "!==e.key||t?.(e)))},onPointerDown(e){r?e.preventDefault():o?.(e)}},u?void 0:{role:"button"},m,l)},[r,m,g,u]),buttonRef:(0,n.useStableCallback)(e=>{f.current=e,h()})}}],616117)},294237,e=>{"use strict";var t=e.i(7284);let r=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=t.clsx;e.s(["cva",0,(e,t)=>a=>{var i;if((null==t?void 0:t.variants)==null)return n(e,null==a?void 0:a.class,null==a?void 0:a.className);let{variants:s,defaultVariants:o}=t,l=Object.keys(s).map(e=>{let t=null==a?void 0:a[e],n=null==o?void 0:o[e];if(null===t)return null;let i=r(t)||r(n);return s[e][i]}),d=a&&Object.entries(a).reduce((e,t)=>{let[r,n]=t;return void 0===n||(e[r]=n),e},{});return n(e,l,null==t||null==(i=t.compoundVariants)?void 0:i.reduce((e,t)=>{let{class:r,className:n,...a}=t;return Object.entries(a).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...o,...d}[t]):({...o,...d})[t]===r})?[...e,r,n]:e},[]),null==a?void 0:a.class,null==a?void 0:a.className)}])},186339,e=>{"use strict";var t=e.i(368075);e.i(459119);var r=e.i(298699),n=e.i(616117),a=e.i(597849);let i=r.forwardRef(function(e,t){let{render:r,className:i,disabled:s=!1,focusableWhenDisabled:o=!1,nativeButton:l=!0,style:d,...u}=e,{getButtonProps:c,buttonRef:f}=(0,n.useButton)({disabled:s,focusableWhenDisabled:o,native:l});return(0,a.useRenderElement)("button",e,{state:{disabled:s},ref:[t,f],props:[u,c]})});var s=e.i(294237),o=e.i(613349);let l=(0,s.cva)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});e.s(["Button",0,function({className:e,variant:r="default",size:n="default",...a}){return(0,t.jsx)(i,{"data-slot":"button",className:(0,o.cn)(l({variant:r,size:n,className:e})),...a})},"buttonVariants",0,l],186339)},70738,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"useMergedRef",{enumerable:!0,get:function(){return a}});let n=e.r(298699);function a(e,t){let r=(0,n.useRef)(null),a=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=a.current;t&&(a.current=null,t())}else e&&(r.current=i(e,n)),t&&(a.current=i(t,n))},[e,t])}function i(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},275351,e=>{"use strict";let t,r,n,a,i=(e,t)=>t.some(t=>e instanceof t),s=new WeakMap,o=new WeakMap,l=new WeakMap,d={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return s.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return u(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function u(e){if(e instanceof IDBRequest){let t;return t=new Promise((t,r)=>{let n=()=>{e.removeEventListener("success",a),e.removeEventListener("error",i)},a=()=>{t(u(e.result)),n()},i=()=>{r(e.error),n()};e.addEventListener("success",a),e.addEventListener("error",i)}),l.set(t,e),t}if(o.has(e))return o.get(e);let t=function(e){if("function"==typeof e)return(a||(a=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(c(this),t),u(this.request)}:function(...t){return u(e.apply(c(this),t))};return(e instanceof IDBTransaction&&function(e){if(s.has(e))return;let t=new Promise((t,r)=>{let n=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",i),e.removeEventListener("abort",i)},a=()=>{t(),n()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",a),e.addEventListener("error",i),e.addEventListener("abort",i)});s.set(e,t)}(e),i(e,n||(n=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])))?new Proxy(e,d):e}(e);return t!==e&&(o.set(e,t),l.set(t,e)),t}let c=e=>l.get(e),f=["get","getKey","getAll","getAllKeys","count"],p=["put","add","delete","clear"],g=new Map;function m(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(g.get(t))return g.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,a=p.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(a||f.includes(r)))return;let i=async function(e,...t){let i=this.transaction(e,a?"readwrite":"readonly"),s=i.store;return n&&(s=s.index(t.shift())),(await Promise.all([s[r](...t),a&&i.done]))[0]};return g.set(t,i),i}d={...t=d,get:(e,r,n)=>m(e,r)||t.get(e,r,n),has:(e,r)=>!!m(e,r)||t.has(e,r)};let h=["continue","continuePrimaryKey","advance"],v={},b=new WeakMap,y=new WeakMap,x={get(e,t){if(!h.includes(t))return e[t];let r=v[t];return r||(r=v[t]=function(...e){b.set(this,y.get(this)[t](...e))}),r}};async function*w(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;let r=new Proxy(t,x);for(y.set(r,t),l.set(r,c(t));t;)yield r,t=await (b.get(r)||t.continue()),b.delete(r)}function _(e,t){return t===Symbol.asyncIterator&&i(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&i(e,[IDBIndex,IDBObjectStore])}d={...r=d,get:(e,t,n)=>_(e,t)?w:r.get(e,t,n),has:(e,t)=>_(e,t)||r.has(e,t)};let j=null,C=null;function k(e){return"u"<typeof indexedDB?null:j&&C===e?j:(C=e,j=function(e,{blocked:t,upgrade:r,blocking:n,terminated:a}={}){let i=indexedDB.open(e,1),s=u(i);return r&&i.addEventListener("upgradeneeded",e=>{r(u(i.result),e.oldVersion,e.newVersion,u(i.transaction),e)}),t&&i.addEventListener("blocked",e=>t(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener("close",()=>a()),n&&e.addEventListener("versionchange",e=>n(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}(`alook-chat-cache-${e}`,{upgrade(e){let t=e.createObjectStore("messages",{keyPath:["conversation_id","id"]});t.createIndex("by-conversation","conversation_id",{unique:!1}),t.createIndex("by-created",["conversation_id","created_at"],{unique:!1}),e.createObjectStore("cache_meta",{keyPath:"conversation_id"})}}))}function P(e){return e?k(e):j}async function E(e,t){let r=P(t);if(!r)return null;try{let t=await r,n=await t.getAllFromIndex("messages","by-conversation",e);if(0===n.length)return null;let a=n.filter(e=>"buffered"!==e.status&&!e.id.startsWith("temp-"));a.sort((e,t)=>{let r=e.created_at.localeCompare(t.created_at);return 0!==r?r:e.id.localeCompare(t.id)});let i=await t.get("cache_meta",e);return i&&await t.put("cache_meta",{...i,lastAccessedAt:Date.now()}),a}catch{return null}}async function O(e,t,r,n){let a=P(n);if(a)try{let n=await a,i=t.filter(e=>"buffered"!==e.status&&!e.id.startsWith("temp-"));if(0===i.length)return;let s=n.transaction(["messages","cache_meta"],"readwrite"),o=s.objectStore("messages"),l=s.objectStore("cache_meta");for(let e of i)await o.put(e);let d=await o.index("by-conversation").getAllKeys(e),u=Date.now(),c=i.reduce((e,t)=>e.created_at>t.created_at?e:t),f={conversation_id:e,lastFetchedAt:u,lastAccessedAt:u,messageCount:d.length,newestMessageId:c.id,hasMore:r};await l.put(f),await s.done,I().catch(()=>{})}catch{}}async function S(e,t,r){let n=P(r);if(n&&!("buffered"===t.status||t.id.startsWith("temp-")))try{let r=await n,a=await r.get("messages",[e,t.id]);await r.put("messages",t);let i=await r.get("cache_meta",e);i&&await r.put("cache_meta",{...i,lastAccessedAt:Date.now(),messageCount:a?i.messageCount:i.messageCount+1,newestMessageId:t.id})}catch{}}async function I(e=50){let t=P();if(t)try{let r=await t,n=await r.getAll("cache_meta");if(n.length<=e)return;n.sort((e,t)=>e.lastAccessedAt-t.lastAccessedAt);let a=n.slice(0,n.length-e),i=r.transaction(["messages","cache_meta"],"readwrite"),s=i.objectStore("messages"),o=i.objectStore("cache_meta");for(let e of a){for(let t of(await s.index("by-conversation").getAllKeys(e.conversation_id)))await s.delete(t);await o.delete(e.conversation_id)}await i.done}catch{}}async function D(){if("u">typeof indexedDB)try{j&&((await j).close(),j=null),C&&(await z(`alook-chat-cache-${C}`),C=null)}catch{}}async function z(e){return new Promise((t,r)=>{let n=indexedDB.deleteDatabase(e);n.onsuccess=()=>t(),n.onerror=()=>r(n.error),n.onblocked=()=>t()})}e.s(["appendCachedMessage",0,S,"clearAllCache",0,D,"getCachedMessages",0,E,"mergeCachedMessages",0,O,"openCacheDB",0,k],275351)},934351,e=>{"use strict";var t=e.i(368075),r=e.i(613349);e.s(["Card",0,function({className:e,size:n="default",...a}){return(0,t.jsx)("div",{"data-slot":"card","data-size":n,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...a})},"CardAction",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-action",className:(0,r.cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end",e),...n})},"CardContent",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...n})},"CardHeader",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...n})},"CardTitle",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",e),...n})}])},821752,(e,t,r)=>{"use strict";function n({widthInt:e,heightInt:t,blurWidth:r,blurHeight:a,blurDataURL:i,objectFit:s}){let o=r?40*r:e,l=a?40*a:t,d=o&&l?`viewBox='0 0 ${o} ${l}'`:"";return`%3Csvg xmlns='http://www.w3.org/2000/svg' ${d}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${d?"none":"contain"===s?"xMidYMid":"cover"===s?"xMidYMid slice":"none"}' style='filter: url(%23b);' href='${i}'/%3E%3C/svg%3E`}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"getImageBlurSvg",{enumerable:!0,get:function(){return n}})},498074,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={VALID_LOADERS:function(){return i},imageConfigDefault:function(){return s}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=["default","imgix","cloudinary","akamai","custom"],s={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],path:"/_next/image",loader:"default",loaderFile:"",domains:[],disableStaticImages:!1,minimumCacheTTL:14400,formats:["image/webp"],maximumDiskCacheSize:void 0,maximumRedirects:3,maximumResponseBody:5e7,dangerouslyAllowLocalIP:!1,dangerouslyAllowSVG:!1,contentSecurityPolicy:"script-src 'none'; frame-src 'none'; sandbox;",contentDispositionType:"attachment",localPatterns:void 0,remotePatterns:[],qualities:[75],unoptimized:!1,customCacheHandler:!1}},355477,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"getImgProps",{enumerable:!0,get:function(){return d}}),e.r(611134);let n=e.r(641894),a=e.r(821752),i=e.r(498074),s=["-moz-initial","fill","none","scale-down",void 0];function o(e){return void 0!==e.default}function l(e){return void 0===e?e:"number"==typeof e?Number.isFinite(e)?e:NaN:"string"==typeof e&&/^[0-9]+$/.test(e)?parseInt(e,10):NaN}function d({src:e,sizes:t,unoptimized:r=!1,priority:u=!1,preload:c=!1,loading:f,className:p,quality:g,width:m,height:h,fill:v=!1,style:b,overrideSrc:y,onLoad:x,onLoadingComplete:w,placeholder:_="empty",blurDataURL:j,fetchPriority:C,decoding:k="async",layout:P,objectFit:E,objectPosition:O,lazyBoundary:S,lazyRoot:I,...D},z){var R;let M,N,A,{imgConf:B,showAltText:L,blurComplete:T,defaultLoader:$}=z,W=B||i.imageConfigDefault;if("allSizes"in W)M=W;else{let e=[...W.deviceSizes,...W.imageSizes].sort((e,t)=>e-t),t=W.deviceSizes.sort((e,t)=>e-t),r=W.qualities?.sort((e,t)=>e-t);M={...W,allSizes:e,deviceSizes:t,qualities:r}}if(void 0===$)throw Object.defineProperty(Error("images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config"),"__NEXT_ERROR_CODE",{value:"E163",enumerable:!1,configurable:!0});let U=D.loader||$;delete D.loader,delete D.srcSet;let q="__next_img_default"in U;if(q){if("custom"===M.loader)throw Object.defineProperty(Error(`Image with src "${e}" is missing "loader" prop.
2
- Read more: https://nextjs.org/docs/messages/next-image-missing-loader`),"__NEXT_ERROR_CODE",{value:"E252",enumerable:!1,configurable:!0})}else{let e=U;U=t=>{let{config:r,...n}=t;return e(n)}}if(P){"fill"===P&&(v=!0);let e={intrinsic:{maxWidth:"100%",height:"auto"},responsive:{width:"100%",height:"auto"}}[P];e&&(b={...b,...e});let r={responsive:"100vw",fill:"100vw"}[P];r&&!t&&(t=r)}let F="",V=l(m),H=l(h);if((R=e)&&"object"==typeof R&&(o(R)||void 0!==R.src)){let t=o(e)?e.default:e;if(!t.src)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ${JSON.stringify(t)}`),"__NEXT_ERROR_CODE",{value:"E460",enumerable:!1,configurable:!0});if(!t.height||!t.width)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(t)}`),"__NEXT_ERROR_CODE",{value:"E48",enumerable:!1,configurable:!0});if(N=t.blurWidth,A=t.blurHeight,j=j||t.blurDataURL,F=t.src,!v)if(V||H){if(V&&!H){let e=V/t.width;H=Math.round(t.height*e)}else if(!V&&H){let e=H/t.height;V=Math.round(t.width*e)}}else V=t.width,H=t.height}let K=!u&&!c&&("lazy"===f||void 0===f);(!(e="string"==typeof e?e:F)||e.startsWith("data:")||e.startsWith("blob:"))&&(r=!0,K=!1),M.unoptimized&&(r=!0),q&&!M.dangerouslyAllowSVG&&e.split("?",1)[0].endsWith(".svg")&&(r=!0);let G=l(g),X=Object.assign(v?{position:"absolute",height:"100%",width:"100%",left:0,top:0,right:0,bottom:0,objectFit:E,objectPosition:O}:{},L?{}:{color:"transparent"},b),J=T||"empty"===_?null:"blur"===_?`url("data:image/svg+xml;charset=utf-8,${(0,a.getImageBlurSvg)({widthInt:V,heightInt:H,blurWidth:N,blurHeight:A,blurDataURL:j||"",objectFit:X.objectFit})}")`:`url("${_}")`,Q=s.includes(X.objectFit)?"fill"===X.objectFit?"100% 100%":"cover":X.objectFit,Y=J?{backgroundSize:Q,backgroundPosition:X.objectPosition||"50% 50%",backgroundRepeat:"no-repeat",backgroundImage:J}:{},Z=function({config:e,src:t,unoptimized:r,width:a,quality:i,sizes:s,loader:o}){if(r){if(t.startsWith("/")&&!t.startsWith("//")){let e=(0,n.getDeploymentId)();if(e){let r=t.indexOf("?");if(-1!==r){let n=new URLSearchParams(t.slice(r+1));n.get("dpl")||(n.append("dpl",e),t=t.slice(0,r)+"?"+n.toString())}else t+=`?dpl=${e}`}}return{src:t,srcSet:void 0,sizes:void 0}}let{widths:l,kind:d}=function({deviceSizes:e,allSizes:t},r,n){if(n){let r=/(^|\s)(1?\d?\d)vw/g,a=[];for(let e;e=r.exec(n);)a.push(parseInt(e[2]));if(a.length){let r=.01*Math.min(...a);return{widths:t.filter(t=>t>=e[0]*r),kind:"w"}}return{widths:t,kind:"w"}}return"number"!=typeof r?{widths:e,kind:"w"}:{widths:[...new Set([r,2*r].map(e=>t.find(t=>t>=e)||t[t.length-1]))],kind:"x"}}(e,a,s),u=l.length-1;return{sizes:s||"w"!==d?s:"100vw",srcSet:l.map((r,n)=>`${o({config:e,src:t,quality:i,width:r})} ${"w"===d?r:n+1}${d}`).join(", "),src:o({config:e,src:t,quality:i,width:l[u]})}}({config:M,src:e,unoptimized:r,width:V,quality:G,sizes:t,loader:U}),ee=K?"lazy":f;return{props:{...D,loading:ee,fetchPriority:C,width:V,height:H,decoding:k,className:p,style:{...X,...Y},sizes:Z.sizes,srcSet:Z.srcSet,src:y||Z.src},meta:{unoptimized:r,preload:c||u,placeholder:_,fill:v}}}},477847,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return o}});let n=e.r(298699),a="u"<typeof window,i=a?()=>{}:n.useLayoutEffect,s=a?()=>{}:n.useEffect;function o(e){let{headManager:t,reduceComponentsToState:r}=e;function o(){if(t&&t.mountedInstances){let e=n.Children.toArray(Array.from(t.mountedInstances).filter(Boolean));t.updateHead(r(e))}}return a&&(t?.mountedInstances?.add(e.children),o()),i(()=>(t?.mountedInstances?.add(e.children),()=>{t?.mountedInstances?.delete(e.children)})),i(()=>(t&&(t._pendingUpdate=o),()=>{t&&(t._pendingUpdate=o)})),s(()=>(t&&t._pendingUpdate&&(t._pendingUpdate(),t._pendingUpdate=null),()=>{t&&t._pendingUpdate&&(t._pendingUpdate(),t._pendingUpdate=null)})),null}},769049,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={default:function(){return m},defaultHead:function(){return c}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=e.r(481258),s=e.r(744066),o=e.r(368075),l=s._(e.r(298699)),d=i._(e.r(477847)),u=e.r(951024);function c(){return[(0,o.jsx)("meta",{charSet:"utf-8"},"charset"),(0,o.jsx)("meta",{name:"viewport",content:"width=device-width"},"viewport")]}function f(e,t){return"string"==typeof t||"number"==typeof t?e:t.type===l.default.Fragment?e.concat(l.default.Children.toArray(t.props.children).reduce((e,t)=>"string"==typeof t||"number"==typeof t?e:e.concat(t),[])):e.concat(t)}e.r(611134);let p=["name","httpEquiv","charSet","itemProp"];function g(e){let t,r,n,a;return e.reduce(f,[]).reverse().concat(c().reverse()).filter((t=new Set,r=new Set,n=new Set,a={},e=>{let i=!0,s=!1;if(e.key&&"number"!=typeof e.key&&e.key.indexOf("$")>0){s=!0;let r=e.key.slice(e.key.indexOf("$")+1);t.has(r)?i=!1:t.add(r)}switch(e.type){case"title":case"base":r.has(e.type)?i=!1:r.add(e.type);break;case"meta":for(let t=0,r=p.length;t<r;t++){let r=p[t];if(e.props.hasOwnProperty(r))if("charSet"===r)n.has(r)?i=!1:n.add(r);else{let t=e.props[r],n=a[r]||new Set;("name"!==r||!s)&&n.has(t)?i=!1:(n.add(t),a[r]=n)}}}return i})).reverse().map((e,t)=>{let r=e.key||t;return l.default.cloneElement(e,{key:r})})}let m=function({children:e}){let t=(0,l.useContext)(u.HeadManagerContext);return(0,o.jsx)(d.default,{reduceComponentsToState:g,headManager:t,children:e})};("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},703694,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"ImageConfigContext",{enumerable:!0,get:function(){return i}});let n=e.r(481258)._(e.r(298699)),a=e.r(498074),i=n.default.createContext(a.imageConfigDefault)},507585,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"RouterContext",{enumerable:!0,get:function(){return n}});let n=e.r(481258)._(e.r(298699)).default.createContext(null)},246955,(e,t,r)=>{"use strict";function n(e,t){let r=e||75;return t?.qualities?.length?t.qualities.reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e,t.qualities[0]):r}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"findClosestQuality",{enumerable:!0,get:function(){return n}})},107475,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return s}});let n=e.r(246955),a=e.r(641894);function i({config:e,src:t,width:r,quality:s}){let o=(0,a.getDeploymentId)();if(t.startsWith("/")&&!t.startsWith("//")){let e=t.indexOf("?");if(-1!==e){let r=new URLSearchParams(t.slice(e+1)),n=r.get("dpl");if(n){o=n,r.delete("dpl");let a=r.toString();t=t.slice(0,e)+(a?"?"+a:"")}}}if(t.startsWith("/")&&t.includes("?")&&e.localPatterns?.length===1&&"**"===e.localPatterns[0].pathname&&""===e.localPatterns[0].search)throw Object.defineProperty(Error(`Image with src "${t}" is using a query string which is not configured in images.localPatterns.
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,949035,e=>{"use strict";let t=(0,e.i(406963).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",0,t],949035)},208020,(e,t,r)=>{t.exports=e.r(170928)},406963,e=>{"use strict";var t=e.i(298699);let r=(...e)=>e.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),n=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var a={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,t.createContext)({}),s=(0,t.forwardRef)(({color:e,size:n,strokeWidth:s,absoluteStrokeWidth:o,className:l="",children:d,iconNode:u,...c},f)=>{let{size:p=24,strokeWidth:g=2,absoluteStrokeWidth:m=!1,color:h="currentColor",className:v=""}=(0,t.useContext)(i)??{},b=o??m?24*Number(s??g)/Number(n??p):s??g;return(0,t.createElement)("svg",{ref:f,...a,width:n??p??a.width,height:n??p??a.height,stroke:e??h,strokeWidth:b,className:r("lucide",v,l),...!d&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(c)&&{"aria-hidden":"true"},...c},[...u.map(([e,r])=>(0,t.createElement)(e,r)),...Array.isArray(d)?d:[d]])});e.s(["default",0,(e,a)=>{let i=(0,t.forwardRef)(({className:i,...o},l)=>(0,t.createElement)(s,{ref:l,iconNode:a,className:r(`lucide-${n(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,i),...o}));return i.displayName=n(e),i}],406963)},616117,484665,e=>{"use strict";e.i(459119);var t=e.i(298699),r=e.i(92615),n=e.i(773825),a=e.i(389068),i=e.i(943891),s=e.i(398258);let o=t.createContext(void 0);function l(e=!1){let r=t.useContext(o);if(void 0===r&&!e)throw Error((0,s.default)(16));return r}function d(e){return(0,r.isHTMLElement)(e)&&"BUTTON"===e.tagName}e.s(["CompositeRootContext",0,o,"useCompositeRootContext",0,l],484665),e.s(["useButton",0,function(e={}){let{disabled:r=!1,focusableWhenDisabled:s,tabIndex:o=0,native:u=!0,composite:c}=e,f=t.useRef(null),p=l(!0),g=c??void 0!==p,{props:m}=function(e){let{focusableWhenDisabled:r,disabled:n,composite:a=!1,tabIndex:i=0,isNativeButton:s}=e,o=a&&!1!==r,l=a&&!1===r;return{props:t.useMemo(()=>{let e={onKeyDown(e){n&&r&&"Tab"!==e.key&&e.preventDefault()}};return a||(e.tabIndex=i,!s&&n&&(e.tabIndex=r?i:-1)),(s&&(r||o)||!s&&n)&&(e["aria-disabled"]=n),s&&(!r||l)&&(e.disabled=n),e},[a,n,r,o,l,s,i])}}({focusableWhenDisabled:s,disabled:r,composite:g,tabIndex:o,isNativeButton:u}),h=t.useCallback(()=>{let e=f.current;d(e)&&g&&r&&void 0===m.disabled&&e.disabled&&(e.disabled=!1)},[r,m.disabled,g]);return(0,a.useIsoLayoutEffect)(h,[h]),{getButtonProps:t.useCallback((e={})=>{let{onClick:t,onMouseDown:n,onKeyUp:a,onKeyDown:s,onPointerDown:o,...l}=e,c=u?"button":void 0;return(0,i.mergeProps)({type:c,onClick(e){r?e.preventDefault():t?.(e)},onMouseDown(e){r||n?.(e)},onKeyDown(e){var n;if(r||((0,i.makeEventPreventable)(e),s?.(e),e.baseUIHandlerPrevented))return;let a=e.target===e.currentTarget,o=e.currentTarget,l=d(o),c=!u&&(n=o,!!(n?.tagName==="A"&&n?.href)),f=a&&(u?l:!c),p="Enter"===e.key,m=" "===e.key,h=o.getAttribute("role"),v=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(a&&g&&m){if(e.defaultPrevented&&v)return;e.preventDefault(),c||u&&l?(o.click(),e.preventBaseUIHandler()):f&&(t?.(e),e.preventBaseUIHandler());return}f&&(!u&&(m||p)&&e.preventDefault(),!u&&p&&t?.(e))},onKeyUp(e){r||(((0,i.makeEventPreventable)(e),a?.(e),e.target===e.currentTarget&&u&&g&&d(e.currentTarget)&&" "===e.key)?e.preventDefault():!e.baseUIHandlerPrevented&&(e.target!==e.currentTarget||u||g||" "!==e.key||t?.(e)))},onPointerDown(e){r?e.preventDefault():o?.(e)}},u?void 0:{role:"button"},m,l)},[r,m,g,u]),buttonRef:(0,n.useStableCallback)(e=>{f.current=e,h()})}}],616117)},294237,e=>{"use strict";var t=e.i(7284);let r=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=t.clsx;e.s(["cva",0,(e,t)=>a=>{var i;if((null==t?void 0:t.variants)==null)return n(e,null==a?void 0:a.class,null==a?void 0:a.className);let{variants:s,defaultVariants:o}=t,l=Object.keys(s).map(e=>{let t=null==a?void 0:a[e],n=null==o?void 0:o[e];if(null===t)return null;let i=r(t)||r(n);return s[e][i]}),d=a&&Object.entries(a).reduce((e,t)=>{let[r,n]=t;return void 0===n||(e[r]=n),e},{});return n(e,l,null==t||null==(i=t.compoundVariants)?void 0:i.reduce((e,t)=>{let{class:r,className:n,...a}=t;return Object.entries(a).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...o,...d}[t]):({...o,...d})[t]===r})?[...e,r,n]:e},[]),null==a?void 0:a.class,null==a?void 0:a.className)}])},186339,e=>{"use strict";var t=e.i(368075);e.i(459119);var r=e.i(298699),n=e.i(616117),a=e.i(597849);let i=r.forwardRef(function(e,t){let{render:r,className:i,disabled:s=!1,focusableWhenDisabled:o=!1,nativeButton:l=!0,style:d,...u}=e,{getButtonProps:c,buttonRef:f}=(0,n.useButton)({disabled:s,focusableWhenDisabled:o,native:l});return(0,a.useRenderElement)("button",e,{state:{disabled:s},ref:[t,f],props:[u,c]})});var s=e.i(294237),o=e.i(613349);let l=(0,s.cva)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});e.s(["Button",0,function({className:e,variant:r="default",size:n="default",...a}){return(0,t.jsx)(i,{"data-slot":"button",className:(0,o.cn)(l({variant:r,size:n,className:e})),...a})},"buttonVariants",0,l],186339)},70738,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"useMergedRef",{enumerable:!0,get:function(){return a}});let n=e.r(298699);function a(e,t){let r=(0,n.useRef)(null),a=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=a.current;t&&(a.current=null,t())}else e&&(r.current=i(e,n)),t&&(a.current=i(t,n))},[e,t])}function i(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},275351,e=>{"use strict";let t,r,n,a,i=(e,t)=>t.some(t=>e instanceof t),s=new WeakMap,o=new WeakMap,l=new WeakMap,d={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return s.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return u(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function u(e){if(e instanceof IDBRequest){let t;return t=new Promise((t,r)=>{let n=()=>{e.removeEventListener("success",a),e.removeEventListener("error",i)},a=()=>{t(u(e.result)),n()},i=()=>{r(e.error),n()};e.addEventListener("success",a),e.addEventListener("error",i)}),l.set(t,e),t}if(o.has(e))return o.get(e);let t=function(e){if("function"==typeof e)return(a||(a=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(c(this),t),u(this.request)}:function(...t){return u(e.apply(c(this),t))};return(e instanceof IDBTransaction&&function(e){if(s.has(e))return;let t=new Promise((t,r)=>{let n=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",i),e.removeEventListener("abort",i)},a=()=>{t(),n()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",a),e.addEventListener("error",i),e.addEventListener("abort",i)});s.set(e,t)}(e),i(e,n||(n=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])))?new Proxy(e,d):e}(e);return t!==e&&(o.set(e,t),l.set(t,e)),t}let c=e=>l.get(e),f=["get","getKey","getAll","getAllKeys","count"],p=["put","add","delete","clear"],g=new Map;function m(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(g.get(t))return g.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,a=p.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(a||f.includes(r)))return;let i=async function(e,...t){let i=this.transaction(e,a?"readwrite":"readonly"),s=i.store;return n&&(s=s.index(t.shift())),(await Promise.all([s[r](...t),a&&i.done]))[0]};return g.set(t,i),i}d={...t=d,get:(e,r,n)=>m(e,r)||t.get(e,r,n),has:(e,r)=>!!m(e,r)||t.has(e,r)};let h=["continue","continuePrimaryKey","advance"],v={},b=new WeakMap,y=new WeakMap,x={get(e,t){if(!h.includes(t))return e[t];let r=v[t];return r||(r=v[t]=function(...e){b.set(this,y.get(this)[t](...e))}),r}};async function*w(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;let r=new Proxy(t,x);for(y.set(r,t),l.set(r,c(t));t;)yield r,t=await (b.get(r)||t.continue()),b.delete(r)}function _(e,t){return t===Symbol.asyncIterator&&i(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&i(e,[IDBIndex,IDBObjectStore])}d={...r=d,get:(e,t,n)=>_(e,t)?w:r.get(e,t,n),has:(e,t)=>_(e,t)||r.has(e,t)};let j=null,C=null;function k(e){return"u"<typeof indexedDB?null:j&&C===e?j:(C=e,j=function(e,{blocked:t,upgrade:r,blocking:n,terminated:a}={}){let i=indexedDB.open(e,1),s=u(i);return r&&i.addEventListener("upgradeneeded",e=>{r(u(i.result),e.oldVersion,e.newVersion,u(i.transaction),e)}),t&&i.addEventListener("blocked",e=>t(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener("close",()=>a()),n&&e.addEventListener("versionchange",e=>n(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}(`alook-chat-cache-${e}`,{upgrade(e){let t=e.createObjectStore("messages",{keyPath:["conversation_id","id"]});t.createIndex("by-conversation","conversation_id",{unique:!1}),t.createIndex("by-created",["conversation_id","created_at"],{unique:!1}),e.createObjectStore("cache_meta",{keyPath:"conversation_id"})}}))}function P(e){return e?k(e):j}async function E(e,t){let r=P(t);if(!r)return null;try{let t=await r,n=await t.getAllFromIndex("messages","by-conversation",e);if(0===n.length)return null;let a=n.filter(e=>"buffered"!==e.status&&!e.id.startsWith("temp-"));a.sort((e,t)=>{let r=e.created_at.localeCompare(t.created_at);return 0!==r?r:e.id.localeCompare(t.id)});let i=await t.get("cache_meta",e);return i&&await t.put("cache_meta",{...i,lastAccessedAt:Date.now()}),a}catch{return null}}async function O(e,t,r,n,a){let i=P(a);if(!i)return null;try{let a=await i,s=await a.get("cache_meta",e);if(!s)return null;let o=IDBKeyRange.bound([e,""],[e,t],!1,!1),l=(await a.getAllFromIndex("messages","by-created",o)).filter(e=>!("buffered"===e.status||e.id.startsWith("temp-"))&&(e.created_at!==t||!(e.id>=r)));l.sort((e,t)=>{let r=t.created_at.localeCompare(e.created_at);return 0!==r?r:t.id.localeCompare(e.id)});let d=l.slice(0,n);if(d.length<n&&s.hasMore)return null;return await a.put("cache_meta",{...s,lastAccessedAt:Date.now()}),{messages:d.reverse(),hasMore:l.length>n||s.hasMore}}catch{return null}}async function I(e,t,r,n){let a=P(n);if(a)try{let n=await a,i=t.filter(e=>"buffered"!==e.status&&!e.id.startsWith("temp-"));if(0===i.length)return;let s=n.transaction(["messages","cache_meta"],"readwrite"),o=s.objectStore("messages"),l=s.objectStore("cache_meta");for(let e of i)await o.put(e);let d=await o.index("by-conversation").getAllKeys(e),u=Date.now(),c=i.reduce((e,t)=>e.created_at>t.created_at?e:t),f=await l.get(e),p=r??f?.hasMore??!0,g=f?.newestMessageId&&f.newestMessageId!==c.id?await (async()=>{let t=await o.get([e,f.newestMessageId]);return t&&t.created_at>c.created_at?t.id:c.id})():c.id,m={conversation_id:e,lastFetchedAt:u,lastAccessedAt:u,messageCount:d.length,newestMessageId:g,hasMore:p};await l.put(m),await s.done,D().catch(()=>{})}catch{}}async function S(e,t,r){let n=P(r);if(n&&!("buffered"===t.status||t.id.startsWith("temp-")))try{let r=await n,a=await r.get("cache_meta",e);if(!a)return;let i=await r.get("messages",[e,t.id]);await r.put("messages",t),await r.put("cache_meta",{...a,lastAccessedAt:Date.now(),messageCount:i?a.messageCount:a.messageCount+1,newestMessageId:t.id})}catch{}}async function D(e=50){let t=P();if(t)try{let r=await t,n=await r.getAll("cache_meta");if(n.length<=e)return;n.sort((e,t)=>e.lastAccessedAt-t.lastAccessedAt);let a=n.slice(0,n.length-e),i=r.transaction(["messages","cache_meta"],"readwrite"),s=i.objectStore("messages"),o=i.objectStore("cache_meta");for(let e of a){for(let t of(await s.index("by-conversation").getAllKeys(e.conversation_id)))await s.delete(t);await o.delete(e.conversation_id)}await i.done}catch{}}async function z(){if("u">typeof indexedDB)try{j&&((await j).close(),j=null),C&&(await M(`alook-chat-cache-${C}`),C=null)}catch{}}async function M(e){return new Promise((t,r)=>{let n=indexedDB.deleteDatabase(e);n.onsuccess=()=>t(),n.onerror=()=>r(n.error),n.onblocked=()=>t()})}e.s(["appendCachedMessage",0,S,"clearAllCache",0,z,"getCachedMessages",0,E,"getCachedMessagesBefore",0,O,"mergeCachedMessages",0,I,"openCacheDB",0,k],275351)},934351,e=>{"use strict";var t=e.i(368075),r=e.i(613349);e.s(["Card",0,function({className:e,size:n="default",...a}){return(0,t.jsx)("div",{"data-slot":"card","data-size":n,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...a})},"CardAction",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-action",className:(0,r.cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end",e),...n})},"CardContent",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...n})},"CardHeader",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...n})},"CardTitle",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",e),...n})}])},821752,(e,t,r)=>{"use strict";function n({widthInt:e,heightInt:t,blurWidth:r,blurHeight:a,blurDataURL:i,objectFit:s}){let o=r?40*r:e,l=a?40*a:t,d=o&&l?`viewBox='0 0 ${o} ${l}'`:"";return`%3Csvg xmlns='http://www.w3.org/2000/svg' ${d}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${d?"none":"contain"===s?"xMidYMid":"cover"===s?"xMidYMid slice":"none"}' style='filter: url(%23b);' href='${i}'/%3E%3C/svg%3E`}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"getImageBlurSvg",{enumerable:!0,get:function(){return n}})},498074,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={VALID_LOADERS:function(){return i},imageConfigDefault:function(){return s}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=["default","imgix","cloudinary","akamai","custom"],s={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],path:"/_next/image",loader:"default",loaderFile:"",domains:[],disableStaticImages:!1,minimumCacheTTL:14400,formats:["image/webp"],maximumDiskCacheSize:void 0,maximumRedirects:3,maximumResponseBody:5e7,dangerouslyAllowLocalIP:!1,dangerouslyAllowSVG:!1,contentSecurityPolicy:"script-src 'none'; frame-src 'none'; sandbox;",contentDispositionType:"attachment",localPatterns:void 0,remotePatterns:[],qualities:[75],unoptimized:!1,customCacheHandler:!1}},355477,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"getImgProps",{enumerable:!0,get:function(){return d}}),e.r(611134);let n=e.r(641894),a=e.r(821752),i=e.r(498074),s=["-moz-initial","fill","none","scale-down",void 0];function o(e){return void 0!==e.default}function l(e){return void 0===e?e:"number"==typeof e?Number.isFinite(e)?e:NaN:"string"==typeof e&&/^[0-9]+$/.test(e)?parseInt(e,10):NaN}function d({src:e,sizes:t,unoptimized:r=!1,priority:u=!1,preload:c=!1,loading:f,className:p,quality:g,width:m,height:h,fill:v=!1,style:b,overrideSrc:y,onLoad:x,onLoadingComplete:w,placeholder:_="empty",blurDataURL:j,fetchPriority:C,decoding:k="async",layout:P,objectFit:E,objectPosition:O,lazyBoundary:I,lazyRoot:S,...D},z){var M;let R,A,N,{imgConf:B,showAltText:L,blurComplete:T,defaultLoader:$}=z,W=B||i.imageConfigDefault;if("allSizes"in W)R=W;else{let e=[...W.deviceSizes,...W.imageSizes].sort((e,t)=>e-t),t=W.deviceSizes.sort((e,t)=>e-t),r=W.qualities?.sort((e,t)=>e-t);R={...W,allSizes:e,deviceSizes:t,qualities:r}}if(void 0===$)throw Object.defineProperty(Error("images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config"),"__NEXT_ERROR_CODE",{value:"E163",enumerable:!1,configurable:!0});let U=D.loader||$;delete D.loader,delete D.srcSet;let q="__next_img_default"in U;if(q){if("custom"===R.loader)throw Object.defineProperty(Error(`Image with src "${e}" is missing "loader" prop.
2
+ Read more: https://nextjs.org/docs/messages/next-image-missing-loader`),"__NEXT_ERROR_CODE",{value:"E252",enumerable:!1,configurable:!0})}else{let e=U;U=t=>{let{config:r,...n}=t;return e(n)}}if(P){"fill"===P&&(v=!0);let e={intrinsic:{maxWidth:"100%",height:"auto"},responsive:{width:"100%",height:"auto"}}[P];e&&(b={...b,...e});let r={responsive:"100vw",fill:"100vw"}[P];r&&!t&&(t=r)}let F="",V=l(m),K=l(h);if((M=e)&&"object"==typeof M&&(o(M)||void 0!==M.src)){let t=o(e)?e.default:e;if(!t.src)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ${JSON.stringify(t)}`),"__NEXT_ERROR_CODE",{value:"E460",enumerable:!1,configurable:!0});if(!t.height||!t.width)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(t)}`),"__NEXT_ERROR_CODE",{value:"E48",enumerable:!1,configurable:!0});if(A=t.blurWidth,N=t.blurHeight,j=j||t.blurDataURL,F=t.src,!v)if(V||K){if(V&&!K){let e=V/t.width;K=Math.round(t.height*e)}else if(!V&&K){let e=K/t.height;V=Math.round(t.width*e)}}else V=t.width,K=t.height}let H=!u&&!c&&("lazy"===f||void 0===f);(!(e="string"==typeof e?e:F)||e.startsWith("data:")||e.startsWith("blob:"))&&(r=!0,H=!1),R.unoptimized&&(r=!0),q&&!R.dangerouslyAllowSVG&&e.split("?",1)[0].endsWith(".svg")&&(r=!0);let G=l(g),X=Object.assign(v?{position:"absolute",height:"100%",width:"100%",left:0,top:0,right:0,bottom:0,objectFit:E,objectPosition:O}:{},L?{}:{color:"transparent"},b),J=T||"empty"===_?null:"blur"===_?`url("data:image/svg+xml;charset=utf-8,${(0,a.getImageBlurSvg)({widthInt:V,heightInt:K,blurWidth:A,blurHeight:N,blurDataURL:j||"",objectFit:X.objectFit})}")`:`url("${_}")`,Q=s.includes(X.objectFit)?"fill"===X.objectFit?"100% 100%":"cover":X.objectFit,Y=J?{backgroundSize:Q,backgroundPosition:X.objectPosition||"50% 50%",backgroundRepeat:"no-repeat",backgroundImage:J}:{},Z=function({config:e,src:t,unoptimized:r,width:a,quality:i,sizes:s,loader:o}){if(r){if(t.startsWith("/")&&!t.startsWith("//")){let e=(0,n.getDeploymentId)();if(e){let r=t.indexOf("?");if(-1!==r){let n=new URLSearchParams(t.slice(r+1));n.get("dpl")||(n.append("dpl",e),t=t.slice(0,r)+"?"+n.toString())}else t+=`?dpl=${e}`}}return{src:t,srcSet:void 0,sizes:void 0}}let{widths:l,kind:d}=function({deviceSizes:e,allSizes:t},r,n){if(n){let r=/(^|\s)(1?\d?\d)vw/g,a=[];for(let e;e=r.exec(n);)a.push(parseInt(e[2]));if(a.length){let r=.01*Math.min(...a);return{widths:t.filter(t=>t>=e[0]*r),kind:"w"}}return{widths:t,kind:"w"}}return"number"!=typeof r?{widths:e,kind:"w"}:{widths:[...new Set([r,2*r].map(e=>t.find(t=>t>=e)||t[t.length-1]))],kind:"x"}}(e,a,s),u=l.length-1;return{sizes:s||"w"!==d?s:"100vw",srcSet:l.map((r,n)=>`${o({config:e,src:t,quality:i,width:r})} ${"w"===d?r:n+1}${d}`).join(", "),src:o({config:e,src:t,quality:i,width:l[u]})}}({config:R,src:e,unoptimized:r,width:V,quality:G,sizes:t,loader:U}),ee=H?"lazy":f;return{props:{...D,loading:ee,fetchPriority:C,width:V,height:K,decoding:k,className:p,style:{...X,...Y},sizes:Z.sizes,srcSet:Z.srcSet,src:y||Z.src},meta:{unoptimized:r,preload:c||u,placeholder:_,fill:v}}}},477847,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return o}});let n=e.r(298699),a="u"<typeof window,i=a?()=>{}:n.useLayoutEffect,s=a?()=>{}:n.useEffect;function o(e){let{headManager:t,reduceComponentsToState:r}=e;function o(){if(t&&t.mountedInstances){let e=n.Children.toArray(Array.from(t.mountedInstances).filter(Boolean));t.updateHead(r(e))}}return a&&(t?.mountedInstances?.add(e.children),o()),i(()=>(t?.mountedInstances?.add(e.children),()=>{t?.mountedInstances?.delete(e.children)})),i(()=>(t&&(t._pendingUpdate=o),()=>{t&&(t._pendingUpdate=o)})),s(()=>(t&&t._pendingUpdate&&(t._pendingUpdate(),t._pendingUpdate=null),()=>{t&&t._pendingUpdate&&(t._pendingUpdate(),t._pendingUpdate=null)})),null}},769049,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={default:function(){return m},defaultHead:function(){return c}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=e.r(481258),s=e.r(744066),o=e.r(368075),l=s._(e.r(298699)),d=i._(e.r(477847)),u=e.r(951024);function c(){return[(0,o.jsx)("meta",{charSet:"utf-8"},"charset"),(0,o.jsx)("meta",{name:"viewport",content:"width=device-width"},"viewport")]}function f(e,t){return"string"==typeof t||"number"==typeof t?e:t.type===l.default.Fragment?e.concat(l.default.Children.toArray(t.props.children).reduce((e,t)=>"string"==typeof t||"number"==typeof t?e:e.concat(t),[])):e.concat(t)}e.r(611134);let p=["name","httpEquiv","charSet","itemProp"];function g(e){let t,r,n,a;return e.reduce(f,[]).reverse().concat(c().reverse()).filter((t=new Set,r=new Set,n=new Set,a={},e=>{let i=!0,s=!1;if(e.key&&"number"!=typeof e.key&&e.key.indexOf("$")>0){s=!0;let r=e.key.slice(e.key.indexOf("$")+1);t.has(r)?i=!1:t.add(r)}switch(e.type){case"title":case"base":r.has(e.type)?i=!1:r.add(e.type);break;case"meta":for(let t=0,r=p.length;t<r;t++){let r=p[t];if(e.props.hasOwnProperty(r))if("charSet"===r)n.has(r)?i=!1:n.add(r);else{let t=e.props[r],n=a[r]||new Set;("name"!==r||!s)&&n.has(t)?i=!1:(n.add(t),a[r]=n)}}}return i})).reverse().map((e,t)=>{let r=e.key||t;return l.default.cloneElement(e,{key:r})})}let m=function({children:e}){let t=(0,l.useContext)(u.HeadManagerContext);return(0,o.jsx)(d.default,{reduceComponentsToState:g,headManager:t,children:e})};("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},703694,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"ImageConfigContext",{enumerable:!0,get:function(){return i}});let n=e.r(481258)._(e.r(298699)),a=e.r(498074),i=n.default.createContext(a.imageConfigDefault)},507585,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"RouterContext",{enumerable:!0,get:function(){return n}});let n=e.r(481258)._(e.r(298699)).default.createContext(null)},246955,(e,t,r)=>{"use strict";function n(e,t){let r=e||75;return t?.qualities?.length?t.qualities.reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e,t.qualities[0]):r}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"findClosestQuality",{enumerable:!0,get:function(){return n}})},107475,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return s}});let n=e.r(246955),a=e.r(641894);function i({config:e,src:t,width:r,quality:s}){let o=(0,a.getDeploymentId)();if(t.startsWith("/")&&!t.startsWith("//")){let e=t.indexOf("?");if(-1!==e){let r=new URLSearchParams(t.slice(e+1)),n=r.get("dpl");if(n){o=n,r.delete("dpl");let a=r.toString();t=t.slice(0,e)+(a?"?"+a:"")}}}if(t.startsWith("/")&&t.includes("?")&&e.localPatterns?.length===1&&"**"===e.localPatterns[0].pathname&&""===e.localPatterns[0].search)throw Object.defineProperty(Error(`Image with src "${t}" is using a query string which is not configured in images.localPatterns.
3
3
  Read more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`),"__NEXT_ERROR_CODE",{value:"E871",enumerable:!1,configurable:!0});let l=(0,n.findClosestQuality)(s,e);return`${e.path}?url=${encodeURIComponent(t)}&w=${r}&q=${l}${t.startsWith("/")&&o?`&dpl=${o}`:""}`}i.__next_img_default=!0;let s=i},730145,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"Image",{enumerable:!0,get:function(){return x}});let n=e.r(481258),a=e.r(744066),i=e.r(368075),s=a._(e.r(298699)),o=n._(e.r(550008)),l=n._(e.r(769049)),d=e.r(355477),u=e.r(498074),c=e.r(703694);e.r(611134);let f=e.r(507585),p=n._(e.r(107475)),g=e.r(70738),m={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1};function h(e,t,r,n,a,i,s){let o=e?.src;e&&e["data-loaded-src"]!==o&&(e["data-loaded-src"]=o,("decode"in e?e.decode():Promise.resolve()).catch(()=>{}).then(()=>{if(e.parentElement&&e.isConnected){if("empty"!==t&&a(!0),r?.current){let t=new Event("load");Object.defineProperty(t,"target",{writable:!1,value:e});let n=!1,a=!1;r.current({...t,nativeEvent:t,currentTarget:e,target:e,isDefaultPrevented:()=>n,isPropagationStopped:()=>a,persist:()=>{},preventDefault:()=>{n=!0,t.preventDefault()},stopPropagation:()=>{a=!0,t.stopPropagation()}})}n?.current&&n.current(e)}}))}function v(e){return s.use?{fetchPriority:e}:{fetchpriority:e}}"u"<typeof window&&(globalThis.__NEXT_IMAGE_IMPORTED=!0);let b=(0,s.forwardRef)(({src:e,srcSet:t,sizes:r,height:n,width:a,decoding:o,className:l,style:d,fetchPriority:u,placeholder:c,loading:f,unoptimized:p,fill:m,onLoadRef:b,onLoadingCompleteRef:y,setBlurComplete:x,setShowAltText:w,sizesInput:_,onLoad:j,onError:C,...k},P)=>{let E=(0,s.useCallback)(e=>{e&&(C&&(e.src=e.src),e.complete&&h(e,c,b,y,x,p,_))},[e,c,b,y,x,C,p,_]),O=(0,g.useMergedRef)(P,E);return(0,i.jsx)("img",{...k,...v(u),loading:f,width:a,height:n,decoding:o,"data-nimg":m?"fill":"1",className:l,style:d,sizes:r,srcSet:t,src:e,ref:O,onLoad:e=>{h(e.currentTarget,c,b,y,x,p,_)},onError:e=>{w(!0),"empty"!==c&&x(!0),C&&C(e)}})});function y({isAppRouter:e,imgAttributes:t}){let r={as:"image",imageSrcSet:t.srcSet,imageSizes:t.sizes,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,...v(t.fetchPriority)};return e&&o.default.preload?(o.default.preload(t.src,r),null):(0,i.jsx)(l.default,{children:(0,i.jsx)("link",{rel:"preload",href:t.srcSet?void 0:t.src,...r},"__nimg-"+t.src+t.srcSet+t.sizes)})}let x=(0,s.forwardRef)((e,t)=>{let r=(0,s.useContext)(f.RouterContext),n=(0,s.useContext)(c.ImageConfigContext),a=(0,s.useMemo)(()=>{let e=m||n||u.imageConfigDefault,t=[...e.deviceSizes,...e.imageSizes].sort((e,t)=>e-t),r=e.deviceSizes.sort((e,t)=>e-t),a=e.qualities?.sort((e,t)=>e-t);return{...e,allSizes:t,deviceSizes:r,qualities:a,localPatterns:"u"<typeof window?n?.localPatterns:e.localPatterns}},[n]),{onLoad:o,onLoadingComplete:l}=e,g=(0,s.useRef)(o);(0,s.useEffect)(()=>{g.current=o},[o]);let h=(0,s.useRef)(l);(0,s.useEffect)(()=>{h.current=l},[l]);let[v,x]=(0,s.useState)(!1),[w,_]=(0,s.useState)(!1),{props:j,meta:C}=(0,d.getImgProps)(e,{defaultLoader:p.default,imgConf:a,blurComplete:v,showAltText:w});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b,{...j,unoptimized:C.unoptimized,placeholder:C.placeholder,fill:C.fill,onLoadRef:g,onLoadingCompleteRef:h,setBlurComplete:x,setShowAltText:_,sizesInput:e.sizes,ref:t}),C.preload?(0,i.jsx)(y,{isAppRouter:!r,imgAttributes:j}):null]})});("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},851287,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={default:function(){return u},getImageProps:function(){return d}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=e.r(481258),s=e.r(355477),o=e.r(730145),l=i._(e.r(107475));function d(e){let{props:t}=(0,s.getImgProps)(e,{defaultLoader:l.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1}});for(let[e,r]of Object.entries(t))void 0===r&&delete t[e];return{props:t}}let u=o.Image},736956,(e,t,r)=>{t.exports=e.r(851287)},866519,e=>{"use strict";let t=(0,e.i(406963).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",0,t],866519)},898707,e=>{"use strict";var t=e.i(368075);e.s(["GradientBackground",0,function(){return(0,t.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-0 -z-10 overflow-hidden bg-[oklch(0.93_0.015_80)] dark:bg-transparent"})}])},643486,e=>{"use strict";var t=e.i(368075),r=e.i(298699),n=e.i(635790),a=e.i(736956),i=e.i(613349);let s={sm:{icon:28,text:"text-2xl"},lg:{icon:36,text:"text-4xl"}};e.s(["Logo",0,function({size:e="sm",className:o,iconOnly:l=!1}){let{icon:d,text:u}=s[e],{resolvedTheme:c,setTheme:f}=(0,n.useTheme)(),[p,g]=(0,r.useState)(!1),m=(0,r.useRef)(g);return(0,r.useEffect)(()=>{m.current(!0)},[]),(0,t.jsxs)("button",{type:"button",onClick:()=>{f("dark"===c?"light":"dark")},"aria-label":"Toggle theme",className:(0,i.cn)("flex items-center gap-1.5 cursor-pointer select-none transition-opacity hover:opacity-70",o),children:[p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.default,{src:"/alook.svg",alt:"Alook",width:d,height:d,className:"dark:hidden"}),(0,t.jsx)(a.default,{src:"/alook-dark.svg",alt:"Alook",width:d,height:d,className:"hidden dark:block"})]}):(0,t.jsx)("span",{style:{width:d,height:d}}),!l&&(0,t.jsx)("span",{className:(0,i.cn)(u,"font-black tracking-tight"),style:{fontFamily:"var(--font-brand)"},children:"Alook"})]})}])},12338,e=>{"use strict";var t=e.i(368075),r=e.i(208020),n=e.i(186339),a=e.i(934351),i=e.i(898707),s=e.i(643486),o=e.i(949035);let l=(0,e.i(406963).default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var d=e.i(866519),u=e.i(23055),c=e.i(275351);e.s(["WorkspaceListClient",0,function({workspaces:e}){let f=(0,r.useRouter)();return(0,t.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center justify-center p-6",children:[(0,t.jsx)(i.GradientBackground,{}),(0,t.jsxs)(n.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-muted-foreground",onClick:async()=>{await (0,c.clearAllCache)(),await (0,u.signOut)(),f.push("/sign-in")},children:[(0,t.jsx)(d.LogOut,{className:"size-4"}),"Log out"]}),(0,t.jsxs)("div",{className:"w-full max-w-md space-y-8",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,t.jsx)(s.Logo,{size:"lg"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose a workspace to continue."})]}),(0,t.jsx)("div",{className:"space-y-3",children:e.map(e=>(0,t.jsx)(a.Card,{className:"cursor-pointer transition-colors duration-200 hover:bg-accent/50",onClick:()=>f.push(`/w/${e.slug}/home`),children:(0,t.jsxs)(a.CardContent,{className:"flex items-center justify-between px-3 py-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.slug})]}),(0,t.jsx)(l,{className:"size-3.5 text-muted-foreground shrink-0"})]})},e.id))}),(0,t.jsxs)(n.Button,{variant:"outline",className:"w-full",onClick:()=>f.push("/studio/new"),children:[(0,t.jsx)(o.Plus,{className:"size-4"}),"New workspace"]})]})]})}],12338)}]);
@@ -1,3 +1,3 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,875494,685835,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(222862),r=e.i(355578),n=e.i(500324),l=e.i(980630);let i="inbox-filter-types",o=["user_dm_message","calendar_event","email_notification"],c=["user_dm_message"],d=["user_dm_message"];function u(){try{let e=localStorage.getItem(i);if(!e)return c;let t=JSON.parse(e).filter(e=>o.includes(e));if(0===t.length)return c;for(let e of d)t.includes(e)||t.unshift(e);return t}catch{return c}}e.s(["INBOX_FILTER_LABELS",0,{user_dm_message:"DM",calendar_event:"Calendar",email_notification:"Email"},"INBOX_FILTER_TYPES",0,o,"MANDATORY_INBOX_TYPES",0,d,"getInboxFilterTypes",0,u,"setInboxFilterTypes",0,function(e){let t=[...e];for(let e of d)t.includes(e)||t.unshift(e);localStorage.setItem(i,JSON.stringify(t))}],685835);let m=(0,s.createContext)(null);e.s(["InboxCountProvider",0,function({children:e}){let{workspaceId:i}=(0,n.useWorkspace)(),{subscribeWs:o,agents:c}=(0,r.useAgentContext)(),[d,h]=(0,s.useState)(0),p=(0,s.useRef)(null),f=(0,s.useRef)(null),g=(0,s.useRef)(c);(0,s.useEffect)(()=>{g.current=c});let x=(0,s.useCallback)(()=>{let e=u();(0,a.getInboxCount)(i,{types:e}).then(e=>{let t=p.current;if(p.current=e.count,h(e.count),null!==t&&e.count>t){let e=f.current?g.current.find(e=>e.id===f.current):void 0;(0,l.sendTaskNotification)("completed",e?.name)}f.current=null}).catch(()=>{})},[i]),v=(0,s.useCallback)(()=>{h(e=>{let t=Math.max(0,e-1);return p.current=t,t})},[]);return(0,s.useEffect)(()=>{x()},[x]),(0,s.useEffect)(()=>o(e=>{"task.updated"===e.type&&("completed"===e.status||"failed"===e.status)&&(f.current=e.agentId,x())}),[o,x]),(0,s.useEffect)(()=>{let e=setInterval(x,3e4);return()=>clearInterval(e)},[x]),(0,t.jsx)(m.Provider,{value:{count:d,refresh:x,decrement:v},children:e})},"useInboxCount",0,function(){let e=(0,s.useContext)(m);if(!e)throw Error("useInboxCount must be used within InboxCountProvider");return e}],875494)},74348,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(222862),r=e.i(500324);let n=(0,s.createContext)(null);e.s(["FlagCountProvider",0,function({children:e}){let{workspaceId:l}=(0,r.useWorkspace)(),[i,o]=(0,s.useState)(0),c=(0,s.useCallback)(()=>{(0,a.getFlaggedCount)(l).then(e=>o(e.count)).catch(()=>{})},[l]),d=(0,s.useCallback)(()=>{o(e=>e+1)},[]),u=(0,s.useCallback)(()=>{o(e=>Math.max(0,e-1))},[]);return(0,s.useEffect)(()=>{c()},[c]),(0,t.jsx)(n.Provider,{value:{count:i,refresh:c,increment:d,decrement:u},children:e})},"useFlagCount",0,function(){let e=(0,s.useContext)(n);if(!e)throw Error("useFlagCount must be used within FlagCountProvider");return e}])},49879,618615,844010,e=>{"use strict";e.s(["AgentChatView",()=>eC,"getEventIconType",()=>ej],49879);var t=e.i(368075),s=e.i(298699),a=e.i(550008),r=e.i(208020),n=e.i(500324),l=e.i(186339),i=e.i(875061),o=e.i(613349),c=e.i(541544),d=e.i(64873),u=e.i(406963);let m=(0,u.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);var h=e.i(108281),p=e.i(140483),f=e.i(371522);e.i(112946);var g=e.i(164300);function x(e){return e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}let v=new Set(["status","log"]);function j({item:e,isRunning:a,isLast:r}){let n=(0,s.useMemo)(()=>{if(!e.input)return null;try{return JSON.stringify(e.input,null,2)}catch{return String(e.input)}},[e.input]);return n?(0,t.jsxs)("details",{className:"group/tool",children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground transition-colors duration-150","hover:bg-muted/60 hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/tool:rotate-90"}),(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:x(e.tool)}),a&&r&&(0,t.jsx)("span",{className:"ml-auto size-1.5 rounded-full bg-primary/60 animate-pulse"}),a&&!r&&(0,t.jsx)(c.Check,{className:"ml-auto size-3 text-emerald-500"})]}),(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5",children:(0,t.jsx)("pre",{className:"task-stream-pre overflow-x-auto rounded-md bg-muted/40 p-2.5 font-mono text-xs leading-relaxed text-muted-foreground max-h-48 max-w-full min-w-0 overflow-y-auto",children:n})})]}):(0,t.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md","text-sm text-muted-foreground"),children:[(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:x(e.tool)}),a&&r&&(0,t.jsx)("span",{className:"ml-auto size-1.5 rounded-full bg-primary/60 animate-pulse"}),a&&!r&&(0,t.jsx)(c.Check,{className:"ml-auto size-3 text-emerald-500"})]})}function y({item:e}){return e.content?(0,t.jsxs)("details",{className:"group/think",children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground/60 italic transition-colors duration-150","hover:bg-muted/60 hover:text-muted-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/40 transition-transform duration-150 group-open/think:rotate-90"}),(0,t.jsx)(m,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]}),(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5",children:(0,t.jsx)("p",{className:"text-sm italic text-muted-foreground/60 whitespace-pre-wrap",children:e.content})})]}):(0,t.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md","text-sm text-muted-foreground/60 italic"),children:[(0,t.jsx)(m,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]})}function k({value:e}){let a=(0,s.useRef)(e),[r,n]=(0,s.useState)({current:e,previous:null}),[l,i]=(0,s.useState)("idle");return(0,s.useEffect)(()=>{if(e===a.current)return;let t=a.current;a.current=e,n({current:e,previous:t}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i("animating")})});let s=setTimeout(()=>{i("idle"),n(e=>({...e,previous:null}))},300);return()=>clearTimeout(s)},[e]),(0,t.jsxs)("span",{style:{display:"inline-block",position:"relative",overflow:"hidden",height:"1.2em",lineHeight:"1.2em",verticalAlign:"bottom"},children:[null!==r.previous&&(0,t.jsx)("span",{style:{display:"block",position:"absolute",inset:"0",transition:"animating"===l?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:"animating"===l?"translateY(-100%)":"translateY(0)",opacity:+("animating"!==l)},children:r.previous}),(0,t.jsx)("span",{style:{display:"block",transition:"animating"===l?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:null!==r.previous&&"animating"!==l?"translateY(100%)":"translateY(0)",opacity:+(null===r.previous||"animating"===l)},children:r.current})]})}function b({task:e,messages:a,connectionLost:r,onRetry:n,stepCountHint:l,onExpandSteps:c,stepsLoading:u}){let[m,x]=(0,s.useState)(!1),w=(0,s.useMemo)(()=>(function(e){let t=[],s=new Map;for(let a of e){if(v.has(a.type))continue;let e=a.id||`seq-${a.seq}`;switch(a.type){case"tool-use":{let r=a.call_id,n={kind:"tool-call",id:e,tool:a.tool,input:a.input};r&&s.set(r,n),t.push(n);break}case"tool-result":break;case"text":t.push({kind:"text",id:e,content:a.content});break;case"thinking":t.push({kind:"thinking",id:e,content:a.content});break;case"error":t.push({kind:"status",id:e,content:a.content||a.output,type:"error"})}}return t})(a),[a]),N="completed"!==e.status&&"failed"!==e.status&&"cancelled"!==e.status&&"superseded"!==e.status,C=w.filter(e=>"text"!==e.kind),S=w.filter(e=>"text"===e.kind),_=S.length>0?S[S.length-1]:null,T=(0,s.useRef)(null),M=(0,s.useRef)(null),I=(0,s.useRef)(!1);(0,s.useEffect)(()=>{N&&T.current&&(T.current.scrollTop=T.current.scrollHeight)},[C.length,N]),(0,s.useEffect)(()=>{N&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[S.length,N]);let A=N?S:S.slice(0,-1),z=!N&&null!==_,E=C.length>0?C.length:l??0,R=C.length>0||l&&l>0;return(0,t.jsxs)("div",{className:"space-y-3 min-w-0 max-w-full",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:"running"===e.status?(0,t.jsxs)(i.Badge,{variant:"secondary",className:"gap-1.5 relative overflow-hidden",children:[(0,t.jsx)("span",{className:"size-1.5 rounded-full bg-primary animate-pulse"}),"Working",(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):N?(0,t.jsxs)(i.Badge,{variant:"secondary",className:"relative overflow-hidden",children:[e.status,(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):(0,t.jsx)(i.Badge,{variant:"secondary",children:e.status})}),R&&(0,t.jsxs)("details",{className:"group/stream pl-1",onToggle:e=>{e.currentTarget.open&&!I.current&&c&&(I.current=!0,c())},children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-1.5 py-1 cursor-pointer select-none","text-xs text-muted-foreground transition-colors duration-150","hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:(0,o.cn)("size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/stream:rotate-90",N&&"animate-pulse text-primary")}),(0,t.jsxs)("span",{children:[(0,t.jsx)(k,{value:E})," ",1===E?"step":"steps"]})]}),(0,t.jsxs)("div",{ref:T,className:"mt-1 max-h-80 overflow-y-auto overflow-x-hidden thin-scrollbar space-y-0.5 pl-1",children:[u&&0===C.length&&(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,t.jsx)(f.Loader2,{className:"size-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading steps..."})]}),C.map((e,s)=>{switch(e.kind){case"tool-call":return(0,t.jsx)(j,{item:e,isRunning:N,isLast:s===C.length-1},e.id);case"thinking":return(0,t.jsx)(y,{item:e},e.id);case"status":return(0,t.jsxs)("p",{className:"text-xs text-muted-foreground px-1 wrap-anywhere",children:["error"===e.type&&(0,t.jsx)(h.AlertCircle,{className:"inline size-3 mr-1 -mt-0.5 text-destructive"}),e.content]},e.id);default:return null}})]})]}),A.length>0&&(0,t.jsxs)("details",{className:"group/midtext pl-1",open:!z||void 0,children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-1.5 py-1 cursor-pointer select-none","text-xs text-muted-foreground transition-colors duration-150","hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/midtext:rotate-90"}),(0,t.jsxs)("span",{children:[(0,t.jsx)(k,{value:A.length})," thinking"]})]}),(0,t.jsx)("div",{ref:M,className:"mt-1 space-y-2 pl-1",children:A.map(e=>(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-0.5 text-sm text-muted-foreground",children:(0,t.jsx)(g.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:e.content})},e.id))})]}),z&&!c&&(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,t.jsx)(g.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:_.content})}),"failed"===e.status&&e.error&&(0,t.jsxs)("div",{className:"flex items-start gap-2 mt-2 max-w-full overflow-hidden",children:[(0,t.jsxs)("p",{className:"text-sm text-destructive flex items-start gap-1.5 min-w-0",children:[(0,t.jsx)(h.AlertCircle,{className:"size-3.5 shrink-0 mt-0.5"}),(0,t.jsx)("span",{className:"wrap-anywhere",children:e.error})]}),n&&(0,t.jsxs)("button",{type:"button",onClick:async()=>{x(!0);try{await n()}finally{x(!1)}},disabled:m,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[m?(0,t.jsx)(f.Loader2,{className:"size-3 animate-spin"}):(0,t.jsx)(p.RotateCw,{className:"size-3"}),"Retry"]})]}),r&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground animate-pulse mt-1",children:"Connection lost — retrying..."})]})}var w=e.i(222862),N=e.i(275351),C=e.i(355578),S=e.i(875494),_=e.i(74348),T=e.i(872937),M=e.i(880932),I=e.i(728886),A=e.i(329686),z=e.i(36303);let E=(0,u.default)("bed-double",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]),R=(0,u.default)("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);var F=e.i(872057),P=e.i(6131);let D=(0,u.default)("message-square-quote",[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]),L=(0,u.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);var q=e.i(554468),B=e.i(745925),$=e.i(937091);function W(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function H({agent:e,isSelected:s,onSelect:a}){return(0,t.jsxs)("button",{type:"button","data-mention-item":!0,className:(0,o.cn)("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,t.jsx)("span",{className:"truncate font-medium",children:e.name}),e.email_handle&&(0,t.jsxs)("span",{className:"truncate text-xs text-muted-foreground",children:[e.email_handle,"@alook.ai"]})]})}function O({isOpen:e,relatedAgents:a,otherAgents:r,selectedIndex:n,onSelect:l,anchorPos:i}){let o=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!o.current)return;let e=o.current.querySelectorAll("[data-mention-item]")[n];e?.scrollIntoView({block:"nearest"})},[n]);let c=a.length+r.length;if(!e||0===c)return null;let d=a.length>0&&r.length>0;return(0,t.jsx)("div",{className:"absolute z-50 w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-md transition-opacity duration-150",style:{top:i.top-4,left:i.left,transform:"translateY(-100%)"},children:(0,t.jsxs)("div",{ref:o,className:"max-h-50 overflow-y-auto py-1 thin-scrollbar",children:[a.map((e,s)=>(0,t.jsx)(H,{agent:e,isSelected:s===n,onSelect:l},e.id)),d&&(0,t.jsx)("div",{className:"mx-3 my-1 border-t border-border"}),r.map((e,s)=>(0,t.jsx)(H,{agent:e,isSelected:a.length+s===n,onSelect:l},e.id))]})})}function V(e,t){if(t>=e.length)return!0;let s=e.charCodeAt(t);return(!(s>=48)||!(s<=57))&&(!(s>=65)||!(s<=90))&&(!(s>=97)||!(s<=122))&&95!==s}function U(e,t){if(!e||0===t.length||!e.includes("@"))return e;let s=t.slice().sort((e,t)=>t.name.length-e.name.length),a=[];for(let t=0;t<e.length;t++){if("@"!==e[t]||!function(e,t){if(0===t)return!0;let s=e.charCodeAt(t-1);return(!(s>=48)||!(s<=57))&&(!(s>=65)||!(s<=90))&&(!(s>=97)||!(s<=122))&&95!==s}(e,t))continue;let r=t+1;for(let n of s){let s=r+n.name.length;if(s>e.length||e.slice(r,s).toLowerCase()!==n.name.toLowerCase())continue;let l=s,i=e.slice(s).match(/^ \([a-zA-Z0-9-]+@alook\.ai\)/);if(i&&(l=s+i[0].length),(i||V(e,s))&&(!i||V(e,l))){if(a.some(e=>t>=e.start&&t<e.end))break;a.push({start:t,end:s,name:n.name,agentId:n.id});break}}}let r=e;for(let e=a.length-1;e>=0;e--){let t=a[e],s=r.slice(t.start,t.end);r=r.slice(0,t.start)+`<mention data-agent-id="${t.agentId}">${s}</mention>`+r.slice(t.end)}return r}var Y=e.i(721387),X=e.i(332680),K=e.i(940931);function J({open:e,onOpenChange:a,emailId:r,workspaceId:n}){let[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(500),g=(0,s.useRef)(!1),x=(0,s.useRef)(a);(0,s.useEffect)(()=>{x.current=a}),(0,s.useEffect)(()=>{e&&r&&(m(!0),o(null),d(null),Promise.all([(0,w.getEmail)(r,n),(0,w.getEmailBody)(r,n)]).then(([e,t])=>{o(e),d(t)}).catch(()=>{M.toast.error("Email not found"),x.current(!1)}).finally(()=>m(!1)))},[e,r,n]);let v=e=>{a(e),e||setTimeout(()=>{o(null),d(null)},300)},j=(0,s.useCallback)(e=>{e.preventDefault(),g.current=!0,e.target.setPointerCapture(e.pointerId)},[]),y=(0,s.useCallback)(e=>{g.current&&p(Math.min(.8*window.innerWidth,Math.max(320,window.innerWidth-e.clientX)))},[]),k=(0,s.useCallback)(()=>{g.current=!1},[]);return(0,t.jsx)(X.Sheet,{open:e,onOpenChange:v,children:(0,t.jsxs)(X.SheetContent,{side:"right",showCloseButton:!1,style:{width:`min(${h}px, 100vw)`,maxWidth:"none"},className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,t.jsx)("div",{onPointerDown:j,onPointerMove:y,onPointerUp:k,className:"hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"}),(0,t.jsx)(X.SheetHeader,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(P.Mail,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,t.jsx)(X.SheetTitle,{className:"truncate flex-1",children:u?"Loading...":i?.subject||"Email"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(!1),children:(0,t.jsx)($.X,{className:"h-4 w-4"})})]})}),(0,t.jsx)(X.SheetBody,{className:"flex-1 overflow-y-auto thin-scrollbar",children:u?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(f.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):i?(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"text-sm space-y-1 border-b pb-3",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"From:"}),(0,t.jsx)("span",{className:"truncate",children:i.from_email})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"To:"}),(0,t.jsx)("span",{className:"truncate",children:i.to_email})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Date:"}),(0,t.jsx)("span",{children:new Date(i.created_at).toLocaleString()})]})]}),c?.isHtml?(0,t.jsx)(K.EmailBodyFrame,{html:c.content,className:"max-w-full"}):(0,t.jsx)("pre",{className:"whitespace-pre-wrap text-sm font-mono",children:c?.content}),i.attachments&&i.attachments.length>0&&(0,t.jsxs)("div",{className:"border-t pt-3",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mb-2",children:[i.attachments.length," attachment",i.attachments.length>1?"s":""]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:i.attachments.map(e=>(0,t.jsx)("span",{className:"inline-flex items-center gap-1 text-xs bg-muted rounded px-2 py-1",children:e.filename},e.key))})]})]}):null})]})})}var Z=e.i(169678),Q=e.i(364079);function G({bufferedMessages:e,onDelete:a}){let[r,n]=(0,s.useState)(!1),l=e.length;if(0===l)return null;let i=Math.min(l,3);return(0,t.jsx)("div",{className:"relative px-5 pb-1",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl flex justify-center",children:(0,t.jsxs)("div",{className:"relative w-full max-w-lg transition-[height] duration-200 ease-out",style:{height:r?32*l+(l-1)*4:32+(i-1)*6},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[e.map((e,s)=>{var n;let c=l-1-s,d=s>=l-i;return(0,t.jsx)("div",{className:"absolute right-0 left-0 transition-all duration-200 ease-out",style:{height:32,zIndex:s+1,bottom:r?36*c:d?6*c:0,transform:r?"scale(1)":`scale(${d?1-.03*c:.91})`,opacity:r?1:d?1-.2*c:0,pointerEvents:r||d?"auto":"none"},children:(0,t.jsxs)("div",{className:"h-full rounded-lg border bg-background/95 backdrop-blur-sm shadow-sm flex items-center gap-2 px-3",children:[(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-primary/60 tabular-nums w-4 text-center",children:s+1}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground leading-snug truncate",children:(n=e.content).length<=80?n:n.slice(0,80).trimEnd()+"…"}),e.attachment_ids&&e.attachment_ids.length>0&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 shrink-0 text-[11px] text-muted-foreground/50",children:[(0,t.jsx)(q.Paperclip,{className:"size-2.5"}),e.attachment_ids.length]})]}),(0,t.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),a(e.id)},className:(0,o.cn)("shrink-0 rounded-sm p-0.5 transition-all duration-150","text-muted-foreground/30 hover:text-foreground hover:bg-muted",r?"opacity-100":"opacity-0"),tabIndex:r?0:-1,children:(0,t.jsx)($.X,{className:"size-3"})})]})},e.id)}),!r&&l>i&&(0,t.jsxs)("span",{className:"absolute -top-4 right-1 text-[10px] text-muted-foreground/40 tabular-nums",children:["+",l-i," more"]})]})})})}var ee=e.i(219658);let et={id:"",agent_id:"",runtime_id:"",conversation_id:"",workspace_id:"",prompt:"",status:"completed",priority:0,dispatched_at:null,started_at:null,completed_at:null,result:null,error:null,created_at:"",type:""};function es({taskId:e,stepCount:a,workspaceId:r}){let[n,l]=(0,s.useState)([]),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{if(!c&&!i){o(!0);try{let t=await (0,w.getTaskMessages)(e,r);l(t)}catch{l([])}finally{o(!1),d(!0)}}},[c,i,e,r]);return(0,t.jsx)(b,{task:et,messages:n,stepCountHint:a,onExpandSteps:u,stepsLoading:i})}let ea=(0,u.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var er=e.i(251638);let en=(0,u.default)("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]);e.s(["Flag",0,en],618615);var el=e.i(89440);let ei={mention:["data-agent-id"]},eo=["mention"];function ec({content:e,conversationType:s}){let a=ej(e,s),r="h-4 w-4 mt-0.5 shrink-0";return"issue"===a?(0,t.jsx)(er.CircleDot,{className:r}):"email"===a?(0,t.jsx)(P.Mail,{className:r}):(0,t.jsx)(ea,{className:r})}function ed({attachmentIds:e,artifacts:s,onArtifactClick:a}){let r=e.map(e=>s.find(t=>t.id===e)).filter(e=>!!e);return 0===r.length?null:(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.map(e=>(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),a(e)},className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80 hover:bg-primary-foreground/20 transition-colors cursor-pointer",children:[(0,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.filename})]},e.id))})}function eu({pendingFiles:e,messageId:s}){let a=e.get(s);return a&&0!==a.length?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:a.map((e,s)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80",children:[(0,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.name})]},s))}):null}let em=(0,s.memo)(function({msg:e,agents:a,artifacts:r,activeTask:n,taskMessages:i,connectionLost:d,isLastMessage:u,stepCount:m,targetConvId:h,workspaceId:p,conversationType:f,pendingFilesByMessage:x,onArtifactClick:v,onEmailClick:j,onIssueClick:y,onRetry:k,mentionComponents:w,isFlagged:N,onToggleFlag:C}){let S,_,T,[I,z]=(0,s.useState)(!1),E=n&&"assistant"===e.role&&e.task_id===n.id&&e.conversation_id===n.conversation_id&&i.length>0,R=!E&&h&&"assistant"===e.role&&e.task_id&&m>0?m:0,F=E&&n&&["completed","failed","cancelled","superseded"].includes(n.status),P="assistant"===e.role?(0,t.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs","aria-label":I?"Copied":"Copy message",onClick:async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.content),z(!0),M.toast.success("Copied to clipboard"),setTimeout(()=>z(!1),2e3)}catch{M.toast.error("Failed to copy")}},className:(0,o.cn)("self-start mb-1",I?"text-green-500 opacity-100":"text-muted-foreground opacity-0 group-hover/msg:opacity-100")}),children:I?(0,t.jsx)(c.Check,{className:"size-3.5"}):(0,t.jsx)(el.Copy,{className:"size-3.5"})}),(0,t.jsx)(A.TooltipContent,{children:I?"Copied":"Copy"})]}),C&&(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs",onClick:()=>C(e.id),className:(0,o.cn)("self-start mb-1",N?"text-primary opacity-100":"text-muted-foreground opacity-0 group-hover/msg:opacity-100")}),children:(0,t.jsx)(en,{className:(0,o.cn)("size-3.5",N&&"fill-current")})}),(0,t.jsx)(A.TooltipContent,{children:N?"Unflag":"Flag"})]})]}):null;return(0,t.jsxs)(s.default.Fragment,{children:[E&&(0,t.jsxs)("div",{className:(0,o.cn)("group/msg",N&&"bg-muted/30 rounded-lg px-2 -mx-2"),children:[(0,t.jsx)(b,{task:n,messages:i,connectionLost:d,onRetry:k}),F&&P]}),R>0&&e.task_id&&(0,t.jsx)(es,{taskId:e.task_id,stepCount:R,workspaceId:p}),"user"===e.role?(S=u&&!!n&&"running"!==n.status&&!["completed","failed","cancelled","superseded"].includes(n.status),(0,t.jsx)("div",{className:"flex justify-end","data-message-id":e.id,...e.task_id?{"data-task-id":e.task_id}:{},children:(0,t.jsxs)("div",{className:(0,o.cn)("max-w-[80%] rounded-lg px-4 py-2 bg-primary text-primary-foreground text-base relative"),children:[S&&(0,t.jsx)("div",{className:"absolute inset-0 rounded-lg animate-pulse pointer-events-none",style:{boxShadow:"0 0 0 2px var(--bubble-glow)"}}),(0,t.jsx)("div",{className:"markdown markdown-user",children:(0,t.jsx)(g.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!1,download:!1,fullscreen:!1}},linkSafety:{enabled:!1},allowedTags:ei,literalTagContent:eo,components:w,children:U(e.content,a)})}),e.attachment_ids&&e.attachment_ids.length>0&&(0,t.jsx)(ed,{attachmentIds:e.attachment_ids,artifacts:r,onArtifactClick:v}),!e.attachment_ids&&(0,t.jsx)(eu,{pendingFiles:x,messageId:e.id})]})})):"event"===e.role?(_=e.metadata?.emailId,T=e.metadata?.issueId,(0,t.jsx)("div",{className:"flex justify-start","data-message-id":e.id,...e.task_id?{"data-task-id":e.task_id}:{},children:(0,t.jsxs)("div",{className:(0,o.cn)("w-full rounded-md border bg-muted/50 text-muted-foreground text-sm px-3 py-2 flex items-start gap-2",(!!_||!!T)&&"cursor-pointer hover:bg-muted transition-colors"),onClick:_?()=>j(_):T?()=>y(T):void 0,children:[(0,t.jsx)(ec,{content:e.content,conversationType:f}),(0,t.jsx)("span",{className:"min-w-0 wrap-anywhere",children:e.content})]})})):E?null:(0,t.jsxs)("div",{className:(0,o.cn)("group/msg flex flex-col justify-start min-w-0 overflow-hidden",N&&"bg-muted/30 rounded-lg px-2 -mx-2"),"data-message-id":e.id,"data-quote-source":!0,...e.task_id?{"data-task-id":e.task_id}:{},children:[(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,t.jsx)(g.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},allowedTags:ei,literalTagContent:eo,components:w,children:U(e.content,a)})}),P]})]})});e.i(400175);var eh=e.i(819748),ep=e.i(126366),ef=e.i(309475);function eg({agent:e,isOnline:a,activeTaskCount:r,variant:n="default",isHovered:l}){let[i,d]=(0,s.useState)(!1),u=e.email_handle?`${e.email_handle}@alook.ai`:null,m=(0,s.useCallback)(async()=>{if(u)try{await navigator.clipboard.writeText(u),d(!0),M.toast.success("Email copied to clipboard"),setTimeout(()=>d(!1),2e3)}catch{M.toast.error("Failed to copy email")}},[u]);if("compact"===n){let s;return(0,t.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(s=(0,ep.parseAvatarUrl)(e.avatar_url))?(0,t.jsx)(eh.AnimatedAvatar,{config:s,size:32,className:"shrink-0 rounded-xl",isHovered:l??!1,isWorking:!!a&&(r??0)>0}):(0,t.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:e.name}),u&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:u})]}),void 0!==a&&(0,t.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,t.jsx)(ef.AgentStatusBadge,{isOnline:a,taskCount:r??0,agentId:e.id})})]})]})}return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("span",{className:"flex-1"}),void 0!==a&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full",a?"bg-status-online":"bg-status-offline")}),a?(r??0)>0?"Working":null:"Offline"]})]}),u&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:u}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),m()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:i?(0,t.jsx)(c.Check,{className:"size-3 text-green-500"}):(0,t.jsx)(el.Copy,{className:"size-3"})})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description})]})}e.s(["AgentPreviewCard",0,eg],844010);var ex=e.i(224950);let ev={mention:function(e){let{children:s,...a}=e,{agents:r}=(0,C.useAgentContext)(),n=a["data-agent-id"]??a.dataAgentId,l=n?r.find(e=>e.id===n):void 0;if(!l&&"string"==typeof s){let e=s.startsWith("@")?s.slice(1):s;l=r.find(t=>t.name.toLowerCase()===e.toLowerCase())}return l?(0,t.jsxs)(ex.Popover,{children:[(0,t.jsx)(ex.PopoverTrigger,{openOnHover:!0,delay:300,nativeButton:!1,render:(0,t.jsx)("span",{className:"mention-highlight cursor-pointer"}),children:s}),(0,t.jsx)(ex.PopoverContent,{side:"top",className:"w-fit max-w-80",children:(0,t.jsx)(eg,{agent:l})})]}):(0,t.jsx)("span",{className:"mention-highlight",children:s})},p:({children:e,node:s,...a})=>(0,t.jsx)("div",{"data-md-p":"",...a,children:e})};function ej(e,t){if("issue_event"===t)return"issue";if("email_notification"===t)return"email";if("calendar_event"===t)return"calendar";let s=e.toLowerCase();return s.startsWith("issue ")||s.startsWith("issue:")?"issue":s.includes("email")?"email":"calendar"}function ey(e,t){let s=new Map;for(let t of e)s.set(t.id,t);for(let e of t)s.set(e.id,e);return[...s.values()].slice().sort((e,t)=>{let s=e.created_at.localeCompare(t.created_at);return 0!==s?s:e.id.localeCompare(t.id)})}function ek(e){let t=[],s=[],a=!1;for(let r of e)"message"===r.kind&&"user"===r.data.role?(a=!0,t.push(r)):"message"===r.kind&&"assistant"===r.data.role?(t.push(r),t.push(...s),s=[],a=!1):a&&"artifact"===r.kind?s.push(r):t.push(r);return t.push(...s),t}function eb(e){let t=(0,s.useRef)(e);return(0,s.useEffect)(()=>{t.current=e},[e]),t}function ew({agentName:e}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 py-4 select-none","aria-hidden":!0,children:[(0,t.jsx)("div",{className:"flex-1 border-t border-border/40"}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground/60 whitespace-nowrap",children:[e," took a nap 💤"]}),(0,t.jsx)("div",{className:"flex-1 border-t border-border/40"})]})}function eN({artifact:e,version:s,hasDuplicates:a,onClick:r}){return(0,t.jsxs)("button",{onClick:()=>r(e),className:(0,o.cn)("flex items-center gap-3 w-full max-w-sm rounded-lg border border-border/60 bg-muted/30","px-3.5 py-2.5 text-left transition-colors duration-150","hover:bg-muted/60 hover:border-border"),children:[(0,t.jsx)(F.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium truncate",children:[e.filename,a&&(0,t.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal",children:["v",s]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,Y.formatSize)(e.size)})]})]})}function eC({agentId:e,targetConvId:i,scrollToTaskId:c,scrollToMessageId:d}){let u,m,h,p=(0,r.useParams)(),g=(0,r.useSearchParams)(),{workspaceId:x,slug:v}=(0,n.useWorkspace)(),{agents:j,agentLinks:y,activeTaskCounts:k,subscribeWs:H}=(0,C.useAgentContext)(),{refresh:V}=(0,S.useInboxCount)(),{activeChannel:X,loading:K,setAgentId:et}=(0,T.useChannel)(),es=e??p.id,ea=void 0!==c?c:g.get("task"),er=void 0!==d?d:g.get("msg"),en=void 0!==i?i:g.get("conv"),[el,ei]=(0,s.useState)(null),[eo,ec]=(0,s.useState)([]),[ed,eu]=(0,s.useState)(()=>localStorage.getItem(`chat-draft:${es}:${en??"default"}`)??""),[eh,ep]=(0,s.useState)(!1),[ef,eg]=(0,s.useState)(!1),[ex,ej]=(0,s.useState)(null),[eS,e_]=(0,s.useState)([]),[eT,eM]=(0,s.useState)(!0),[eI,eA]=(0,s.useState)(!1),[ez,eE]=(0,s.useState)(!1),[eR,eF]=(0,s.useState)(!1),[eP,eD]=(0,s.useState)([]),[eL,eq]=(0,s.useState)(!1),[eB,e$]=(0,s.useState)(null),[eW,eH]=(0,s.useState)(null),[eO,eV]=(0,s.useState)(!1),[eU,eY]=(0,s.useState)(null),[eX,eK]=(0,s.useState)(!1),[eJ,eZ]=(0,s.useState)(null),[eQ,eG]=(0,s.useState)(null),[e0,e1]=(0,s.useState)(!1),[e2,e5]=(0,s.useState)(null),[e3,e4]=(0,s.useState)(null),[e6,e8]=(0,s.useState)(448),[e7,e9]=(0,s.useState)([]),[te,tt]=(0,s.useState)([]),[ts,ta]=(0,s.useState)(null),[tr,tn]=(0,s.useState)([]),[tl,ti]=(0,s.useState)(!1),[to,tc]=(0,s.useState)([]),[td,tu]=(0,s.useState)({}),[tm]=(0,s.useState)(()=>Date.now()),[th,tp]=(0,s.useState)(()=>new Map),[tf,tg]=(0,s.useState)(null),[tx,tv]=(0,s.useState)(null),[tj,ty]=(0,s.useState)(new Set),tk=(0,s.useRef)(tj);(0,s.useEffect)(()=>{tk.current=tj});let{increment:tb,decrement:tw,refresh:tN}=(0,_.useFlagCount)(),{cachedMessages:tC,isFromCache:tS,writeToCache:t_}=function(e,t){let[a,r]=(0,s.useState)(null),[n,l]=(0,s.useState)(!1),i=(0,s.useRef)(e);return(0,s.useEffect)(()=>{if(i.current=e,!e||!t){r(null),l(!1);return}(0,N.openCacheDB)(t);let s=!1;return(0,N.getCachedMessages)(e,t).then(t=>{s||i.current!==e||(t&&t.length>0?(r(t),l(!0)):(r(null),l(!1)))}),()=>{s=!0}},[e,t]),{cachedMessages:a,isFromCache:n,writeToCache:(0,s.useCallback)(async(e,s)=>{i.current&&t&&await (0,N.mergeCachedMessages)(i.current,e,s,t)},[t])}}(en??null,x),tT=(0,s.useRef)(tC),tM=(0,s.useRef)(tS),tI=(0,s.useRef)(t_);(0,s.useEffect)(()=>{tT.current=tC,tM.current=tS,tI.current=t_},[tC,tS,t_]),(0,s.useEffect)(()=>{et(es)},[es,et]);let{listening:tA,supported:tz,toggle:tE}=function(e){let[t,a]=(0,s.useState)(!1),[r,n]=(0,s.useState)(!1),l=(0,s.useRef)(null);(0,s.useEffect)(()=>{n(!!W())},[]);let i=(0,s.useCallback)(()=>{let t=W();if(!t)return;let s=new t;s.lang=navigator.language||"zh-CN",s.interimResults=!1,s.continuous=!1,s.onresult=t=>{let s=t.results,a="";for(let e=0;e<s.length;e++)a+=s[e][0].transcript;a&&e(a)},s.onend=()=>{a(!1),l.current=null},s.onerror=()=>{a(!1),l.current=null},l.current=s,s.start(),a(!0)},[e]),o=(0,s.useCallback)(()=>{l.current?.stop()},[]),c=(0,s.useCallback)(()=>{t?o():i()},[t,i,o]);return(0,s.useEffect)(()=>()=>{l.current?.abort()},[]),{listening:t,supported:r,toggle:c}}((0,s.useCallback)(e=>{eu(t=>t?t+" "+e:e)},[])),tR=(0,s.useMemo)(()=>eP.filter(e=>"agent"===e.source),[eP]),{versionMap:tF,duplicateFilenames:tP}=(0,s.useMemo)(()=>(0,Q.computeArtifactVersions)(tR),[tR]),tD=(0,s.useMemo)(()=>"agent"===eW?tR:"issue"===eW?eQ?.artifacts??[]:[],[eW,tR,eQ?.artifacts]),{versionMap:tL,duplicateFilenames:tq}=(0,s.useMemo)(()=>(0,Q.computeArtifactVersions)(tD),[tD]),tB=(0,s.useMemo)(()=>(function(e,t,s,a){if(!a||0===s.length){let a=[...e.map(e=>({kind:"message",data:e})),...t.map(e=>({kind:"artifact",data:e})),...s.map(e=>({kind:"nap",data:e}))];return a.sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);if(0!==s)return s;if("nap"===e.kind||"nap"===t.kind){if("nap"===e.kind&&"nap"!==t.kind)return 1;if("nap"!==e.kind&&"nap"===t.kind)return -1}return e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)}),ek(a)}let r=new Set(s.map(e=>e.id.replace(/^nap-/,""))),n=[...s].sort((e,t)=>e.created_at.localeCompare(t.created_at)),l=s=>ek([...e.filter(e=>e.conversation_id===s).map(e=>({kind:"message",data:e})),...t.filter(e=>e.conversation_id===s).map(e=>({kind:"artifact",data:e}))].sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);return 0!==s?s:e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)})),i=[];for(let e of n){let t=e.id.replace(/^nap-/,"");i.push(...l(t)),i.push({kind:"nap",data:e})}i.push(...l(a));let o=new Set([...r,a]),c=e.filter(e=>!o.has(e.conversation_id)),d=t.filter(e=>!o.has(e.conversation_id));if(c.length>0||d.length>0){let e=[...c.map(e=>({kind:"message",data:e})),...d.map(e=>({kind:"artifact",data:e}))];e.sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);return 0!==s?s:e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)});let t=ek(e),s=i.findIndex(e=>"nap"===e.kind);s>=0?i.splice(s,0,...t):i.push(...t)}return i})(eo,tR,to,el?.id),[eo,tR,to,el?.id]),t$=(0,s.useCallback)(e=>{(0,Q.isPreviewable)(e)?(e$(e),eH("agent"),eq(!0)):window.open((0,Q.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tW=(0,s.useCallback)(e=>{(0,Q.isPreviewable)(e)?(e$(e),eH("issue"),eq(!0)):window.open((0,Q.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tH=(0,s.useRef)(null),tO=(0,s.useRef)(null),tV=(0,s.useRef)(null),tU=(0,s.useRef)(null),tY=(0,s.useRef)(0),tX=(0,s.useRef)(0),tK=(0,s.useRef)(!1),tJ=(0,s.useRef)(!1),tZ=(0,s.useRef)(!0),tQ=(0,s.useRef)(!1),tG=(0,s.useRef)(null),t0=(0,s.useRef)(null),t1=(0,s.useRef)(0),t2=(0,s.useRef)(void 0),t5=(0,s.useRef)(null),t3=(0,s.useRef)(null),t4=function({input:e,caretIndex:t,textareaRef:a,agents:r,agentLinks:n,currentAgentId:l,onInputChange:i}){let[o,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(0),[p,f]=(0,s.useState)({top:0,left:0}),g=(0,s.useRef)(null),x=(0,s.useMemo)(()=>{let e=new Set;for(let t of n)t.source_agent_id===l&&e.add(t.target_agent_id),t.target_agent_id===l&&e.add(t.source_agent_id);return e},[n,l]),{relatedAgents:v,otherAgents:j,allAgents:y}=(0,s.useMemo)(()=>{if(!o)return{relatedAgents:[],otherAgents:[],allAgents:[]};let e=e=>{if(!d)return e.slice(0,20);let t=d.toLowerCase(),s=[],a=[];for(let r of e){let e=r.name.toLowerCase();e.startsWith(t)?s.push(r):e.includes(t)&&a.push(r)}return[...s,...a]},t=[],s=[];for(let e of r)x.has(e.id)?t.push(e):s.push(e);let a=e(t),n=e(s);return{relatedAgents:a,otherAgents:n,allAgents:[...a,...n]}},[o,d,r,x]);(0,s.useEffect)(()=>{h(0)},[y.length,d]),(0,s.useEffect)(()=>{if(null===t)return void c(!1);let s=function(e,t){let s=t-1;for(;s>=0&&t-s<=30;){let a=e.charCodeAt(s);if(64===a)return{start:s,query:e.slice(s+1,t)};if(10===a||13===a)break;s--}return null}(e,t);s?(g.current=s.start,u(s.query),c(!0),a.current&&f(function(e,t){let s=document.createElement("div"),a=window.getComputedStyle(e);for(let t of(s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.visibility="hidden",s.style.overflow="hidden",s.style.width=`${e.offsetWidth}px`,["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing","whiteSpace","wordWrap","overflowWrap"]))s.style[t]=a.getPropertyValue(t.replace(/([A-Z])/g,"-$1").toLowerCase());s.textContent=e.value.slice(0,t);let r=document.createElement("span");r.textContent="​",s.appendChild(r),document.body.appendChild(s);let n=r.offsetTop-e.scrollTop,l=Math.max(0,Math.min(r.offsetLeft,e.offsetWidth-256));return document.body.removeChild(s),{top:n,left:l}}(a.current,s.start))):(c(!1),g.current=null)},[e,t,a]);let k=(0,s.useCallback)(s=>{if(null===t||null===g.current)return;let r=e.slice(0,g.current),n=e.slice(t);i(`${r}@${s.name} ${n}`),c(!1);let l=r.length+1+s.name.length+1;requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(l,l))})},[e,t,a,i]),b=(0,s.useCallback)(e=>!!o&&0!==y.length&&!e.nativeEvent.isComposing&&("ArrowDown"===e.key?(e.preventDefault(),h(e=>(e+1)%y.length),!0):"ArrowUp"===e.key?(e.preventDefault(),h(e=>(e-1+y.length)%y.length),!0):"Enter"===e.key?(e.preventDefault(),k(y[m]),!0):"Escape"===e.key&&(e.preventDefault(),c(!1),!0)),[o,y,m,k]);return{isOpen:o,query:d,selectedIndex:m,anchorPos:p,relatedAgents:v,otherAgents:j,allAgents:y,handleMentionKeyDown:b,selectAgent:k}}({input:ed,caretIndex:ts,textareaRef:t3,agents:(0,s.useMemo)(()=>j.filter(e=>e.id!==es),[j,es]),agentLinks:y,currentAgentId:es,onInputChange:eu});(0,s.useEffect)(()=>{let e=`chat-draft:${es}:${en??"default"}`;ed?localStorage.setItem(e,ed):localStorage.removeItem(e)},[ed,es,en]),(0,s.useEffect)(()=>{eh||t3.current?.focus()},[eh]);let t6=(0,s.useCallback)(()=>{tZ.current=!0,setTimeout(()=>{tH.current?.scrollTo({top:tH.current.scrollHeight,behavior:"smooth"})},50)},[]);(0,s.useEffect)(()=>{if(K)return;tO.current&&clearInterval(tO.current),tO.current=null,tU.current=null;let e=!1,t=tT.current,s=tM.current&&t&&t.length>0;return queueMicrotask(()=>{e||(eM(!s),tK.current=!1,ej(null),e_([]),tt([]),tp(new Map),tc([]),tu({}),tn([]),ti(!1),t0.current=null,eu(localStorage.getItem(`chat-draft:${es}:${en??"default"}`)??""),s?ec(t):ec([]))}),async function(){try{if(en)try{let[t,s,a,r]=await Promise.all([(0,w.getConversation)(en,x),(0,w.listMessages)(en,x),(0,w.listArtifacts)(en,x).catch(()=>[]),(0,w.listBufferedMessages)(en,x).catch(()=>[])]);if(e)return;ei(t),ec(e=>ey(e,s.messages)),eE(s.has_more),eD(a),tt(r),tI.current(s.messages,s.has_more).catch(()=>{});let n=[...new Set(s.messages.filter(e=>"assistant"===e.role&&e.task_id).map(e=>e.task_id))];if(n.length>0&&(0,w.getTaskStepCounts)(n,x).then(t=>{e||tu(t)}).catch(()=>{}),(0,w.listFlaggedMessageIds)(x,en).then(t=>{e||ty(new Set(t.message_ids))}).catch(()=>{}),ea){let t=await (0,w.getTask)(ea,x).catch(()=>null);if(e)return;if(t&&!["completed","failed","cancelled","superseded"].includes(t.status)){ej(t);let s=await (0,w.getTaskMessages)(ea,x).catch(()=>[]);if(e)return;e_(s),s.length>0&&(tY.current=Math.max(...s.map(e=>e.seq))),tG.current?.(t.id,en,tY.current)}}}catch{let t=await (0,w.chatInit)(es,x,X);if(e)return;ei(t.conversation),ec(e=>e.length>0?ey(e,t.messages):t.messages),eE(t.has_more_messages),eD(t.artifacts),tt(t.buffered_messages),ti(t.has_more_conversations),tI.current(t.messages,t.has_more_messages).catch(()=>{}),(0,w.listFlaggedMessageIds)(x,t.conversation.id).then(t=>{e||ty(new Set(t.message_ids))}).catch(()=>{})}else{let t=await (0,w.chatInit)(es,x,X);if(e)return;ei(t.conversation),ec(e=>e.length>0?ey(e,t.messages):t.messages),eE(t.has_more_messages),eD(t.artifacts),tt(t.buffered_messages),ti(t.has_more_conversations),tI.current(t.messages,t.has_more_messages).catch(()=>{}),(0,w.listFlaggedMessageIds)(x,t.conversation.id).then(t=>{e||ty(new Set(t.message_ids))}).catch(()=>{}),t.active_task&&(ej(t.active_task),t.task_messages.length>0&&(e_(t.task_messages),tY.current=Math.max(...t.task_messages.map(e=>e.seq))),["completed","failed","cancelled","superseded"].includes(t.active_task.status)||tG.current?.(t.active_task.id,t.conversation.id,tY.current))}}catch{M.toast.error("Failed to load conversation")}finally{e||eM(!1)}}(),()=>{e=!0}},[es,x,en,ea,X,K]);let t8=(0,s.useRef)(V);(0,s.useEffect)(()=>{t8.current=V},[V]);let t7=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!el?.id||!x||t7.current===el.id)return;t7.current=el.id;let e=setTimeout(()=>{(0,w.markInboxRead)(el.id,x).then(()=>t8.current()).catch(()=>{})},1e3);return()=>{t7.current=null,clearTimeout(e)}},[el?.id,x]),(0,s.useEffect)(()=>{eT||!(eo.length>0)||tK.current||(tK.current=!0,ea||er?tZ.current=!1:i?setTimeout(()=>{let e=tH.current?.querySelectorAll("[data-quote-source]");e&&e.length>0?e[e.length-1].scrollIntoView({behavior:"instant",block:"start"}):tH.current?.scrollTo({top:tH.current.scrollHeight})},50):setTimeout(()=>{tH.current?.scrollTo({top:tH.current.scrollHeight})},50))},[eT,eo.length,ea,er,i]),(0,s.useEffect)(()=>{let e;if(!ea||eT||!el)return;tZ.current=!1,tQ.current=!0;let t=!1,s=()=>{if(t)return!1;let s=document.querySelector(`[data-task-id="${CSS.escape(ea)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tQ.current=!1)},1500),!0)},a=setTimeout(async()=>{if(!t&&!s())try{let e=await (0,w.listMessagesAroundTask)(el.id,x,ea);if(t)return;e.length>0?(ec(t=>ey(t,e)),requestAnimationFrame(()=>{setTimeout(()=>{s()||(tQ.current=!1)},100)})):tQ.current=!1}catch{t||(tQ.current=!1)}},100);return()=>{t=!0,clearTimeout(a),e&&clearTimeout(e)}},[ea,eT,el,x]),(0,s.useEffect)(()=>{let e;if(!er||ea||eT||!el)return;tZ.current=!1,tQ.current=!0;let t=!1,s=setTimeout(()=>{!t&&((()=>{if(t)return!1;let s=document.querySelector(`[data-message-id="${CSS.escape(er)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tQ.current=!1)},1500),!0)})()||(tH.current?.scrollTo({top:tH.current.scrollHeight}),tQ.current=!1))},100);return()=>{t=!0,clearTimeout(s),e&&clearTimeout(e)}},[er,ea,eT,el]);let t9=ex?.status;(0,s.useEffect)(()=>{tQ.current||("running"===t9||"queued"===t9)&&tZ.current&&t6()},[eS.length,t9,t6]);let se=(0,s.useMemo)(()=>j.find(e=>e.id===es)?.name??"Agent",[j,es]),st=eb(eo),ss=eb(ez),sa=eb(tr),sr=eb(tl),sn=eb(se),sl=eb(X),si=(0,s.useCallback)(async(e=!1)=>{if(!el||tJ.current)return;tJ.current=!0;let t=st.current,s=ss.current,r=sr.current,n=sn.current,l=sl.current,i=t[0],o=t0.current?.id??el.id,c=s&&i,d=sa.current;if(!c&&0===d.length&&r){let e=t0.current??{id:el.id,created_at:el.created_at};try{let t=await (0,w.listPreviousConversations)(es,x,{exclude:el.id,before:e.created_at,channel:l});d=t.conversations,tn(t.conversations),ti(t.has_more)}catch{ti(!1)}}let u=d.length>0;if(!c&&!u){tJ.current=!1;return}eF(!0);let m=tH.current;m&&(m.style.overflowAnchor="none");let h=m?.scrollHeight??0;try{let t=[],s=[],u=20,p=!1,f=[];if(c){let e=await (0,w.listMessages)(o,x,{limit:20,before:i.created_at,beforeId:i.id});t=e.messages,u-=e.messages.length,p=e.has_more}if(!p&&u>0){if(0===d.length&&r){let e=t0.current??{id:el.id,created_at:el.created_at};try{let t=await (0,w.listPreviousConversations)(es,x,{exclude:el.id,before:e.created_at,channel:l});d=t.conversations,tn(t.conversations),ti(t.has_more)}catch{ti(!1)}}let e=0,t=0;for(;e<d.length&&u>0&&t<5;){let a=d[e];e++,t++;let r=await (0,w.listMessages)(a.id,x,{limit:u});if(0===r.messages.length){t0.current=a;continue}let l=t0.current?.created_at??el.created_at;f.push({agentName:n,created_at:l,id:`nap-${a.id}`}),s=[...r.messages,...s],u-=r.messages.length,p=r.has_more,t0.current=a}e>0&&tn(t=>t.slice(e))}let g=[...s,...t];if((0,a.flushSync)(()=>{g.length>0?(f.length>0&&tc(e=>{let t=new Set(e.map(e=>e.id)),s=f.filter(e=>!t.has(e.id));return[...e,...s]}),eE(p),ec(e=>{let t=new Set(e.map(e=>e.id));return[...g.filter(e=>!t.has(e.id)),...e]})):eE(!1)}),g.length>0&&el){let e=g.filter(e=>e.conversation_id===el.id);e.length>0&&(0,N.mergeCachedMessages)(el.id,e,p,x).catch(()=>{})}if(tJ.current=!1,(0,a.flushSync)(()=>eF(!1)),m)if(e)m.scrollTop=m.scrollHeight;else{let e=m.scrollHeight;m.scrollTop=e-h}}catch{M.toast.error("Failed to load older messages")}finally{tJ.current=!1,eF(!1),tH.current&&(tH.current.style.overflowAnchor="")}},[el,x,es,st,ss,sr,sn,sl,sa]),so=ez||tr.length>0||tl;(0,s.useEffect)(()=>{el?.id!==t2.current&&(t2.current=el?.id,t1.current=0)},[el?.id]),(0,s.useEffect)(()=>{eT||!el||eo.length>=10||!so||eR||t1.current>=3||(t1.current+=1,si(!0))},[eT,eo.length,so,eR,el,si]);let sc=(0,s.useCallback)(()=>{let e=tH.current;e&&(tZ.current=e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]),sd=(0,s.useCallback)((e,t,s)=>{tO.current&&clearInterval(tO.current),tY.current=s??0,tX.current=0,eA(!1),tU.current=e,tO.current=setInterval(async()=>{if(tU.current===e)try{let[s,a]=await Promise.all([(0,w.getTask)(e,x),(0,w.getTaskMessages)(e,x,tY.current||void 0)]),r=tU.current!==e;if(tX.current=0,eA(!1),a.length>0&&!r&&(e_(e=>{let t=new Set(e.map(e=>e.seq)),s=a.filter(e=>!t.has(e.seq));return s.length>0?[...e,...s]:e}),tY.current=Math.max(...a.map(e=>e.seq),tY.current)),"completed"===s.status||"failed"===s.status||"cancelled"===s.status||"superseded"===s.status){if(r)return void(0,w.listMessages)(t,x).then(({messages:e})=>ec(t=>ey(t,e))).catch(()=>{});tO.current&&clearInterval(tO.current),tO.current=null,tV.current&&clearTimeout(tV.current),tV.current=setTimeout(()=>{(0,w.markInboxRead)(t,x).then(()=>t8.current()).catch(()=>{})},1e3);let a=!tQ.current&&tZ.current;try{let[e,a]=await Promise.all([(0,w.listMessages)(t,x),(0,w.listArtifacts)(t,x).catch(()=>null)]);ec(t=>ey(t,e.messages)),a&&eD(a),ej(s)}catch{ej(s),M.toast.error("Failed to refresh messages")}a&&requestAnimationFrame(()=>{tH.current?.scrollTo({top:tH.current.scrollHeight,behavior:"smooth"})}),setTimeout(async()=>{if(!tO.current)try{let[s,a]=await Promise.all([(0,w.getActiveTask)(t,x),(0,w.listBufferedMessages)(t,x)]);if(tt(a),s&&s.id!==e){let{messages:e}=await (0,w.listMessages)(t,x);ec(t=>ey(t,e)),ej(s),e_([]),tG.current?.(s.id,t)}}catch{}},1e3)}else r||ej(s)}catch{if(tU.current!==e)return;tX.current+=1,tX.current>=3&&eA(!0),tX.current>=10&&(tO.current&&clearInterval(tO.current),tO.current=null,M.toast.error("Lost connection to agent"))}},3e3)},[x]);(0,s.useEffect)(()=>{tG.current=sd},[sd]),(0,s.useEffect)(()=>()=>{tO.current&&clearInterval(tO.current),tV.current&&clearTimeout(tV.current)},[]);let su=(0,s.useRef)(null);(0,s.useEffect)(()=>{su.current=ex?.id??null},[ex]),(0,s.useEffect)(()=>H(e=>{if("task.messages"===e.type&&e.taskId===su.current){let t=e.messages.filter(e=>e.seq>tY.current);t.length>0&&(e_(e=>{let s=new Set(e.map(e=>e.seq)),a=t.filter(e=>!s.has(e.seq));return a.length>0?[...e,...a]:e}),tY.current=Math.max(...t.map(e=>e.seq),tY.current))}if("task.created"===e.type&&e.conversationId===el?.id){(0,w.listMessages)(e.conversationId,x).then(({messages:e})=>ec(t=>ey(t,e))).catch(()=>{});let t=e.task;su.current=t.id,ej(t),e_([]),tY.current=0,tG.current?.(t.id,e.conversationId)}if("conversation.message"===e.type&&e.conversationId===el?.id&&(ec(t=>ey(t,[e.message])),(0,N.appendCachedMessage)(e.conversationId,e.message,x).catch(()=>{})),"artifact.uploaded"===e.type&&e.conversationId===el?.id&&eD(t=>t.some(t=>t.id===e.artifact.id)?t:[...t,e.artifact]),"followup.dispatched"===e.type&&e.conversationId===el?.id){tt(t=>t.filter(t=>t.id!==e.message.id)),(0,w.listBufferedMessages)(e.conversationId,x).then(tt).catch(()=>{}),(0,w.listMessages)(e.conversationId,x).then(({messages:e})=>ec(t=>ey(t,e))).catch(()=>{}),(0,N.appendCachedMessage)(e.conversationId,e.message,x).catch(()=>{});let t=e.task;su.current=t.id,ej(t),e_([]),tG.current?.(t.id,e.conversationId)}"followup.created"===e.type&&e.conversationId===el?.id&&tt(t=>(function(e,t){if(e.some(e=>e.id===t.id))return e;let s=new Date(t.created_at).getTime();return e.some(e=>e.id.startsWith("temp-")&&2e3>Math.abs(new Date(e.created_at).getTime()-s))?e:[...e,t]})(t,e.message)),"followup.deleted"===e.type&&e.conversationId===el?.id&&tt(t=>t.filter(t=>t.id!==e.messageId)),"followup.dispatch_failed"===e.type&&e.conversationId===el?.id&&M.toast.error(e.error||"Failed to dispatch follow-up")}),[H,el?.id,x]);let sm=(0,s.useCallback)(e=>{let t=e.target.files;if(!t)return;let s=[];for(let e of Array.from(t))e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&e9(e=>[...e,...s]),e.target.value=""},[]),sh=(0,s.useCallback)(e=>{e9(t=>t.filter((t,s)=>s!==e))},[]),sp=(0,s.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed||!e.rangeCount)return void tv(null);let t=e.toString().trim();if(!t)return void tv(null);let s=e.getRangeAt(0),a=s.commonAncestorContainer instanceof HTMLElement?s.commonAncestorContainer:s.commonAncestorContainer.parentElement;if(!a?.closest("[data-quote-source]"))return void tv(null);let r=s.getClientRects(),n=r[r.length-1]||s.getBoundingClientRect();tv({text:t,x:n.right,y:n.top-4})},[]);(0,s.useEffect)(()=>(document.addEventListener("selectionchange",sp),()=>document.removeEventListener("selectionchange",sp)),[sp]);let sf=(0,s.useCallback)(()=>{tx&&(tg(tx.text),tv(null),window.getSelection()?.removeAllRanges(),t3.current?.focus())},[tx]),[sg,sx]=(0,s.useState)(!1),sv=(0,s.useRef)(0),sj=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sv.current++,e.dataTransfer.types.includes("Files")&&sx(!0)},[]),sy=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sv.current--,0===sv.current&&sx(!1)},[]),sk=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),sb=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sx(!1),sv.current=0;let t=Array.from(e.dataTransfer.files),s=[];for(let e of t)e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&e9(e=>[...e,...s])},[]),sw=(0,s.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let s=[];for(let e=0;e<t.length;e++){let a=t[e];if("file"===a.kind){let e=a.getAsFile();e&&s.push(e)}}if(0===s.length)return;e.preventDefault();let a=[];for(let e of s)e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):a.push(e);a.length>0&&e9(e=>[...e,...a])},[]),sN=async()=>{if(el&&!ef){eg(!0);try{let e=await (0,w.cancelActiveTask)(el.id,x);if(e){if(su.current&&su.current!==e.id)return;tO.current&&clearInterval(tO.current),tO.current=null;let[t,s]=await Promise.all([(0,w.listMessages)(el.id,x),(0,w.listBufferedMessages)(el.id,x)]);ec(e=>ey(e,t.messages)),tt(s),ej(e),e_([])}}catch{M.toast.error("Failed to cancel task")}finally{eg(!1)}}},sC=async()=>{let e=ed.trim();if(!e&&0===e7.length||eh||!el)return;if(!e)return void M.toast.error("Please type a message");let t=tf?`> ${tf.split("\n").join("\n> ")}
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,875494,685835,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(222862),r=e.i(355578),n=e.i(500324),l=e.i(980630);let i="inbox-filter-types",o=["user_dm_message","calendar_event","email_notification"],c=["user_dm_message"],d=["user_dm_message"];function u(){try{let e=localStorage.getItem(i);if(!e)return c;let t=JSON.parse(e).filter(e=>o.includes(e));if(0===t.length)return c;for(let e of d)t.includes(e)||t.unshift(e);return t}catch{return c}}e.s(["INBOX_FILTER_LABELS",0,{user_dm_message:"DM",calendar_event:"Calendar",email_notification:"Email"},"INBOX_FILTER_TYPES",0,o,"MANDATORY_INBOX_TYPES",0,d,"getInboxFilterTypes",0,u,"setInboxFilterTypes",0,function(e){let t=[...e];for(let e of d)t.includes(e)||t.unshift(e);localStorage.setItem(i,JSON.stringify(t))}],685835);let m=(0,s.createContext)(null);e.s(["InboxCountProvider",0,function({children:e}){let{workspaceId:i}=(0,n.useWorkspace)(),{subscribeWs:o,agents:c}=(0,r.useAgentContext)(),[d,h]=(0,s.useState)(0),p=(0,s.useRef)(null),g=(0,s.useRef)(null),f=(0,s.useRef)(c);(0,s.useEffect)(()=>{f.current=c});let x=(0,s.useCallback)(()=>{let e=u();(0,a.getInboxCount)(i,{types:e}).then(e=>{let t=p.current;if(p.current=e.count,h(e.count),null!==t&&e.count>t){let e=g.current?f.current.find(e=>e.id===g.current):void 0;(0,l.sendTaskNotification)("completed",e?.name)}g.current=null}).catch(()=>{})},[i]),v=(0,s.useCallback)(()=>{h(e=>{let t=Math.max(0,e-1);return p.current=t,t})},[]);return(0,s.useEffect)(()=>{x()},[x]),(0,s.useEffect)(()=>o(e=>{"task.updated"===e.type&&("completed"===e.status||"failed"===e.status)&&(g.current=e.agentId,x())}),[o,x]),(0,s.useEffect)(()=>{let e=setInterval(x,6e4);return()=>clearInterval(e)},[x]),(0,t.jsx)(m.Provider,{value:{count:d,refresh:x,decrement:v},children:e})},"useInboxCount",0,function(){let e=(0,s.useContext)(m);if(!e)throw Error("useInboxCount must be used within InboxCountProvider");return e}],875494)},74348,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(222862),r=e.i(500324);let n=(0,s.createContext)(null);e.s(["FlagCountProvider",0,function({children:e}){let{workspaceId:l}=(0,r.useWorkspace)(),[i,o]=(0,s.useState)(0),c=(0,s.useCallback)(()=>{(0,a.getFlaggedCount)(l).then(e=>o(e.count)).catch(()=>{})},[l]),d=(0,s.useCallback)(()=>{o(e=>e+1)},[]),u=(0,s.useCallback)(()=>{o(e=>Math.max(0,e-1))},[]);return(0,s.useEffect)(()=>{c()},[c]),(0,t.jsx)(n.Provider,{value:{count:i,refresh:c,increment:d,decrement:u},children:e})},"useFlagCount",0,function(){let e=(0,s.useContext)(n);if(!e)throw Error("useFlagCount must be used within FlagCountProvider");return e}])},49879,618615,844010,e=>{"use strict";e.s(["AgentChatView",()=>eC,"getEventIconType",()=>ey],49879);var t=e.i(368075),s=e.i(298699),a=e.i(550008),r=e.i(208020),n=e.i(500324),l=e.i(186339),i=e.i(875061),o=e.i(613349),c=e.i(541544),d=e.i(64873),u=e.i(406963);let m=(0,u.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);var h=e.i(108281),p=e.i(140483),g=e.i(371522);e.i(112946);var f=e.i(164300);function x(e){return e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}let v=new Set(["status","log"]);function y({item:e,isRunning:a,isLast:r}){let n=(0,s.useMemo)(()=>{if(!e.input)return null;try{return JSON.stringify(e.input,null,2)}catch{return String(e.input)}},[e.input]);return n?(0,t.jsxs)("details",{className:"group/tool",children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground transition-colors duration-150","hover:bg-muted/60 hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/tool:rotate-90"}),(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:x(e.tool)}),a&&r&&(0,t.jsx)("span",{className:"ml-auto size-1.5 rounded-full bg-primary/60 animate-pulse"}),a&&!r&&(0,t.jsx)(c.Check,{className:"ml-auto size-3 text-emerald-500"})]}),(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5",children:(0,t.jsx)("pre",{className:"task-stream-pre overflow-x-auto rounded-md bg-muted/40 p-2.5 font-mono text-xs leading-relaxed text-muted-foreground max-h-48 max-w-full min-w-0 overflow-y-auto",children:n})})]}):(0,t.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md","text-sm text-muted-foreground"),children:[(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:x(e.tool)}),a&&r&&(0,t.jsx)("span",{className:"ml-auto size-1.5 rounded-full bg-primary/60 animate-pulse"}),a&&!r&&(0,t.jsx)(c.Check,{className:"ml-auto size-3 text-emerald-500"})]})}function j({item:e}){return e.content?(0,t.jsxs)("details",{className:"group/think",children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground/60 italic transition-colors duration-150","hover:bg-muted/60 hover:text-muted-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/40 transition-transform duration-150 group-open/think:rotate-90"}),(0,t.jsx)(m,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]}),(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5",children:(0,t.jsx)("p",{className:"text-sm italic text-muted-foreground/60 whitespace-pre-wrap",children:e.content})})]}):(0,t.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md","text-sm text-muted-foreground/60 italic"),children:[(0,t.jsx)(m,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]})}function k({value:e}){let a=(0,s.useRef)(e),[r,n]=(0,s.useState)({current:e,previous:null}),[l,i]=(0,s.useState)("idle");return(0,s.useEffect)(()=>{if(e===a.current)return;let t=a.current;a.current=e,n({current:e,previous:t}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i("animating")})});let s=setTimeout(()=>{i("idle"),n(e=>({...e,previous:null}))},300);return()=>clearTimeout(s)},[e]),(0,t.jsxs)("span",{style:{display:"inline-block",position:"relative",overflow:"hidden",height:"1.2em",lineHeight:"1.2em",verticalAlign:"bottom"},children:[null!==r.previous&&(0,t.jsx)("span",{style:{display:"block",position:"absolute",inset:"0",transition:"animating"===l?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:"animating"===l?"translateY(-100%)":"translateY(0)",opacity:+("animating"!==l)},children:r.previous}),(0,t.jsx)("span",{style:{display:"block",transition:"animating"===l?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:null!==r.previous&&"animating"!==l?"translateY(100%)":"translateY(0)",opacity:+(null===r.previous||"animating"===l)},children:r.current})]})}function b({task:e,messages:a,connectionLost:r,onRetry:n,stepCountHint:l,onExpandSteps:c,stepsLoading:u}){let[m,x]=(0,s.useState)(!1),w=(0,s.useMemo)(()=>(function(e){let t=[],s=new Map;for(let a of e){if(v.has(a.type))continue;let e=a.id||`seq-${a.seq}`;switch(a.type){case"tool-use":{let r=a.call_id,n={kind:"tool-call",id:e,tool:a.tool,input:a.input};r&&s.set(r,n),t.push(n);break}case"tool-result":break;case"text":t.push({kind:"text",id:e,content:a.content});break;case"thinking":t.push({kind:"thinking",id:e,content:a.content});break;case"error":t.push({kind:"status",id:e,content:a.content||a.output,type:"error"})}}return t})(a),[a]),N="completed"!==e.status&&"failed"!==e.status&&"cancelled"!==e.status&&"superseded"!==e.status,C=w.filter(e=>"text"!==e.kind),_=w.filter(e=>"text"===e.kind),S=_.length>0?_[_.length-1]:null,T=(0,s.useRef)(null),M=(0,s.useRef)(null),I=(0,s.useRef)(!1);(0,s.useEffect)(()=>{N&&T.current&&(T.current.scrollTop=T.current.scrollHeight)},[C.length,N]),(0,s.useEffect)(()=>{N&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[_.length,N]);let A=N?_:_.slice(0,-1),z=!N&&null!==S,E=C.length>0?C.length:l??0,R=C.length>0||l&&l>0;return(0,t.jsxs)("div",{className:"space-y-3 min-w-0 max-w-full",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:"running"===e.status?(0,t.jsxs)(i.Badge,{variant:"secondary",className:"gap-1.5 relative overflow-hidden",children:[(0,t.jsx)("span",{className:"size-1.5 rounded-full bg-primary animate-pulse"}),"Working",(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):N?(0,t.jsxs)(i.Badge,{variant:"secondary",className:"relative overflow-hidden",children:[e.status,(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):(0,t.jsx)(i.Badge,{variant:"secondary",children:e.status})}),R&&(0,t.jsxs)("details",{className:"group/stream pl-1",onToggle:e=>{e.currentTarget.open&&!I.current&&c&&(I.current=!0,c())},children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-1.5 py-1 cursor-pointer select-none","text-xs text-muted-foreground transition-colors duration-150","hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:(0,o.cn)("size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/stream:rotate-90",N&&"animate-pulse text-primary")}),(0,t.jsxs)("span",{children:[(0,t.jsx)(k,{value:E})," ",1===E?"step":"steps"]})]}),(0,t.jsxs)("div",{ref:T,className:"mt-1 max-h-80 overflow-y-auto overflow-x-hidden thin-scrollbar space-y-0.5 pl-1",children:[u&&0===C.length&&(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,t.jsx)(g.Loader2,{className:"size-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading steps..."})]}),C.map((e,s)=>{switch(e.kind){case"tool-call":return(0,t.jsx)(y,{item:e,isRunning:N,isLast:s===C.length-1},e.id);case"thinking":return(0,t.jsx)(j,{item:e},e.id);case"status":return(0,t.jsxs)("p",{className:"text-xs text-muted-foreground px-1 wrap-anywhere",children:["error"===e.type&&(0,t.jsx)(h.AlertCircle,{className:"inline size-3 mr-1 -mt-0.5 text-destructive"}),e.content]},e.id);default:return null}})]})]}),A.length>0&&(0,t.jsxs)("details",{className:"group/midtext pl-1",open:!z||void 0,children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-1.5 py-1 cursor-pointer select-none","text-xs text-muted-foreground transition-colors duration-150","hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/midtext:rotate-90"}),(0,t.jsxs)("span",{children:[(0,t.jsx)(k,{value:A.length})," thinking"]})]}),(0,t.jsx)("div",{ref:M,className:"mt-1 space-y-2 pl-1",children:A.map(e=>(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-0.5 text-sm text-muted-foreground",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:e.content})},e.id))})]}),z&&!c&&(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:S.content})}),"failed"===e.status&&e.error&&(0,t.jsxs)("div",{className:"flex items-start gap-2 mt-2 max-w-full overflow-hidden",children:[(0,t.jsxs)("p",{className:"text-sm text-destructive flex items-start gap-1.5 min-w-0",children:[(0,t.jsx)(h.AlertCircle,{className:"size-3.5 shrink-0 mt-0.5"}),(0,t.jsx)("span",{className:"wrap-anywhere",children:e.error})]}),n&&(0,t.jsxs)("button",{type:"button",onClick:async()=>{x(!0);try{await n()}finally{x(!1)}},disabled:m,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[m?(0,t.jsx)(g.Loader2,{className:"size-3 animate-spin"}):(0,t.jsx)(p.RotateCw,{className:"size-3"}),"Retry"]})]}),r&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground animate-pulse mt-1",children:"Connection lost — retrying..."})]})}var w=e.i(222862),N=e.i(275351),C=e.i(355578),_=e.i(875494),S=e.i(74348),T=e.i(872937),M=e.i(880932),I=e.i(728886),A=e.i(329686),z=e.i(36303);let E=(0,u.default)("bed-double",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]),R=(0,u.default)("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);var F=e.i(872057),P=e.i(6131);let D=(0,u.default)("message-square-quote",[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]),L=(0,u.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);var B=e.i(554468),q=e.i(745925),$=e.i(937091);function W(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function H({agent:e,isSelected:s,onSelect:a}){return(0,t.jsxs)("button",{type:"button","data-mention-item":!0,className:(0,o.cn)("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,t.jsx)("span",{className:"truncate font-medium",children:e.name}),e.email_handle&&(0,t.jsxs)("span",{className:"truncate text-xs text-muted-foreground",children:[e.email_handle,"@alook.ai"]})]})}function O({isOpen:e,relatedAgents:a,otherAgents:r,selectedIndex:n,onSelect:l,anchorPos:i}){let o=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!o.current)return;let e=o.current.querySelectorAll("[data-mention-item]")[n];e?.scrollIntoView({block:"nearest"})},[n]);let c=a.length+r.length;if(!e||0===c)return null;let d=a.length>0&&r.length>0;return(0,t.jsx)("div",{className:"absolute z-50 w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-md transition-opacity duration-150",style:{top:i.top-4,left:i.left,transform:"translateY(-100%)"},children:(0,t.jsxs)("div",{ref:o,className:"max-h-50 overflow-y-auto py-1 thin-scrollbar",children:[a.map((e,s)=>(0,t.jsx)(H,{agent:e,isSelected:s===n,onSelect:l},e.id)),d&&(0,t.jsx)("div",{className:"mx-3 my-1 border-t border-border"}),r.map((e,s)=>(0,t.jsx)(H,{agent:e,isSelected:a.length+s===n,onSelect:l},e.id))]})})}function V(e,t){if(t>=e.length)return!0;let s=e.charCodeAt(t);return(!(s>=48)||!(s<=57))&&(!(s>=65)||!(s<=90))&&(!(s>=97)||!(s<=122))&&95!==s}function U(e,t){if(!e||0===t.length||!e.includes("@"))return e;let s=t.slice().sort((e,t)=>t.name.length-e.name.length),a=[];for(let t=0;t<e.length;t++){if("@"!==e[t]||!function(e,t){if(0===t)return!0;let s=e.charCodeAt(t-1);return(!(s>=48)||!(s<=57))&&(!(s>=65)||!(s<=90))&&(!(s>=97)||!(s<=122))&&95!==s}(e,t))continue;let r=t+1;for(let n of s){let s=r+n.name.length;if(s>e.length||e.slice(r,s).toLowerCase()!==n.name.toLowerCase())continue;let l=s,i=e.slice(s).match(/^ \([a-zA-Z0-9-]+@alook\.ai\)/);if(i&&(l=s+i[0].length),(i||V(e,s))&&(!i||V(e,l))){if(a.some(e=>t>=e.start&&t<e.end))break;a.push({start:t,end:s,name:n.name,agentId:n.id});break}}}let r=e;for(let e=a.length-1;e>=0;e--){let t=a[e],s=r.slice(t.start,t.end);r=r.slice(0,t.start)+`<mention data-agent-id="${t.agentId}">${s}</mention>`+r.slice(t.end)}return r}var Y=e.i(721387),X=e.i(332680),K=e.i(940931);function J({open:e,onOpenChange:a,emailId:r,workspaceId:n}){let[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(500),f=(0,s.useRef)(!1),x=(0,s.useRef)(a);(0,s.useEffect)(()=>{x.current=a}),(0,s.useEffect)(()=>{e&&r&&(m(!0),o(null),d(null),Promise.all([(0,w.getEmail)(r,n),(0,w.getEmailBody)(r,n)]).then(([e,t])=>{o(e),d(t)}).catch(()=>{M.toast.error("Email not found"),x.current(!1)}).finally(()=>m(!1)))},[e,r,n]);let v=e=>{a(e),e||setTimeout(()=>{o(null),d(null)},300)},y=(0,s.useCallback)(e=>{e.preventDefault(),f.current=!0,e.target.setPointerCapture(e.pointerId)},[]),j=(0,s.useCallback)(e=>{f.current&&p(Math.min(.8*window.innerWidth,Math.max(320,window.innerWidth-e.clientX)))},[]),k=(0,s.useCallback)(()=>{f.current=!1},[]);return(0,t.jsx)(X.Sheet,{open:e,onOpenChange:v,children:(0,t.jsxs)(X.SheetContent,{side:"right",showCloseButton:!1,style:{width:`min(${h}px, 100vw)`,maxWidth:"none"},className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,t.jsx)("div",{onPointerDown:y,onPointerMove:j,onPointerUp:k,className:"hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"}),(0,t.jsx)(X.SheetHeader,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(P.Mail,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,t.jsx)(X.SheetTitle,{className:"truncate flex-1",children:u?"Loading...":i?.subject||"Email"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(!1),children:(0,t.jsx)($.X,{className:"h-4 w-4"})})]})}),(0,t.jsx)(X.SheetBody,{className:"flex-1 overflow-y-auto thin-scrollbar",children:u?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(g.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):i?(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"text-sm space-y-1 border-b pb-3",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"From:"}),(0,t.jsx)("span",{className:"truncate",children:i.from_email})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"To:"}),(0,t.jsx)("span",{className:"truncate",children:i.to_email})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Date:"}),(0,t.jsx)("span",{children:new Date(i.created_at).toLocaleString()})]})]}),c?.isHtml?(0,t.jsx)(K.EmailBodyFrame,{html:c.content,className:"max-w-full"}):(0,t.jsx)("pre",{className:"whitespace-pre-wrap text-sm font-mono",children:c?.content}),i.attachments&&i.attachments.length>0&&(0,t.jsxs)("div",{className:"border-t pt-3",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mb-2",children:[i.attachments.length," attachment",i.attachments.length>1?"s":""]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:i.attachments.map(e=>(0,t.jsx)("span",{className:"inline-flex items-center gap-1 text-xs bg-muted rounded px-2 py-1",children:e.filename},e.key))})]})]}):null})]})})}var Z=e.i(169678),Q=e.i(364079);function G({bufferedMessages:e,onDelete:a}){let[r,n]=(0,s.useState)(!1),l=e.length;if(0===l)return null;let i=Math.min(l,3);return(0,t.jsx)("div",{className:"relative px-5 pb-1",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl flex justify-center",children:(0,t.jsxs)("div",{className:"relative w-full max-w-lg transition-[height] duration-200 ease-out",style:{height:r?32*l+(l-1)*4:32+(i-1)*6},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[e.map((e,s)=>{var n;let c=l-1-s,d=s>=l-i;return(0,t.jsx)("div",{className:"absolute right-0 left-0 transition-all duration-200 ease-out",style:{height:32,zIndex:s+1,bottom:r?36*c:d?6*c:0,transform:r?"scale(1)":`scale(${d?1-.03*c:.91})`,opacity:r?1:d?1-.2*c:0,pointerEvents:r||d?"auto":"none"},children:(0,t.jsxs)("div",{className:"h-full rounded-lg border bg-background/95 backdrop-blur-sm shadow-sm flex items-center gap-2 px-3",children:[(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-primary/60 tabular-nums w-4 text-center",children:s+1}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground leading-snug truncate",children:(n=e.content).length<=80?n:n.slice(0,80).trimEnd()+"…"}),e.attachment_ids&&e.attachment_ids.length>0&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 shrink-0 text-[11px] text-muted-foreground/50",children:[(0,t.jsx)(B.Paperclip,{className:"size-2.5"}),e.attachment_ids.length]})]}),(0,t.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),a(e.id)},className:(0,o.cn)("shrink-0 rounded-sm p-0.5 transition-all duration-150","text-muted-foreground/30 hover:text-foreground hover:bg-muted",r?"opacity-100":"opacity-0"),tabIndex:r?0:-1,children:(0,t.jsx)($.X,{className:"size-3"})})]})},e.id)}),!r&&l>i&&(0,t.jsxs)("span",{className:"absolute -top-4 right-1 text-[10px] text-muted-foreground/40 tabular-nums",children:["+",l-i," more"]})]})})})}var ee=e.i(219658);let et={id:"",agent_id:"",runtime_id:"",conversation_id:"",workspace_id:"",prompt:"",status:"completed",priority:0,dispatched_at:null,started_at:null,completed_at:null,result:null,error:null,created_at:"",type:""};function es({taskId:e,stepCount:a,workspaceId:r}){let[n,l]=(0,s.useState)([]),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{if(!c&&!i){o(!0);try{let t=await (0,w.getTaskMessages)(e,r);l(t)}catch{l([])}finally{o(!1),d(!0)}}},[c,i,e,r]);return(0,t.jsx)(b,{task:et,messages:n,stepCountHint:a,onExpandSteps:u,stepsLoading:i})}let ea=(0,u.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var er=e.i(251638);let en=(0,u.default)("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]);e.s(["Flag",0,en],618615);var el=e.i(89440);let ei={mention:["data-agent-id"]},eo=["mention"];function ec({content:e,conversationType:s}){let a=ey(e,s),r="h-4 w-4 mt-0.5 shrink-0";return"issue"===a?(0,t.jsx)(er.CircleDot,{className:r}):"email"===a?(0,t.jsx)(P.Mail,{className:r}):(0,t.jsx)(ea,{className:r})}function ed({attachmentIds:e,artifacts:s,onArtifactClick:a}){let r=e.map(e=>s.find(t=>t.id===e)).filter(e=>!!e);return 0===r.length?null:(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.map(e=>(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),a(e)},className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80 hover:bg-primary-foreground/20 transition-colors cursor-pointer",children:[(0,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.filename})]},e.id))})}function eu({pendingFiles:e,messageId:s}){let a=e.get(s);return a&&0!==a.length?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:a.map((e,s)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80",children:[(0,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.name})]},s))}):null}let em=(0,s.memo)(function({msg:e,agents:a,artifacts:r,activeTask:n,taskMessages:i,connectionLost:d,isLastMessage:u,stepCount:m,targetConvId:h,workspaceId:p,conversationType:g,pendingFilesByMessage:x,onArtifactClick:v,onEmailClick:y,onIssueClick:j,onRetry:k,mentionComponents:w,isFlagged:N,onToggleFlag:C}){let _,S,T,[I,z]=(0,s.useState)(!1),E=n&&"assistant"===e.role&&e.task_id===n.id&&e.conversation_id===n.conversation_id&&i.length>0,R=!E&&h&&"assistant"===e.role&&e.task_id&&m>0?m:0,F=E&&n&&["completed","failed","cancelled","superseded"].includes(n.status),P="assistant"===e.role?(0,t.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs","aria-label":I?"Copied":"Copy message",onClick:async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.content),z(!0),M.toast.success("Copied to clipboard"),setTimeout(()=>z(!1),2e3)}catch{M.toast.error("Failed to copy")}},className:(0,o.cn)("self-start mb-1",I?"text-green-500 opacity-100":"text-muted-foreground opacity-0 group-hover/msg:opacity-100")}),children:I?(0,t.jsx)(c.Check,{className:"size-3.5"}):(0,t.jsx)(el.Copy,{className:"size-3.5"})}),(0,t.jsx)(A.TooltipContent,{children:I?"Copied":"Copy"})]}),C&&(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs",onClick:()=>C(e.id),className:(0,o.cn)("self-start mb-1",N?"text-primary opacity-100":"text-muted-foreground opacity-0 group-hover/msg:opacity-100")}),children:(0,t.jsx)(en,{className:(0,o.cn)("size-3.5",N&&"fill-current")})}),(0,t.jsx)(A.TooltipContent,{children:N?"Unflag":"Flag"})]})]}):null;return(0,t.jsxs)(s.default.Fragment,{children:[E&&(0,t.jsxs)("div",{className:(0,o.cn)("group/msg",N&&"bg-muted/30 rounded-lg px-2 -mx-2"),children:[(0,t.jsx)(b,{task:n,messages:i,connectionLost:d,onRetry:k}),F&&P]}),R>0&&e.task_id&&(0,t.jsx)(es,{taskId:e.task_id,stepCount:R,workspaceId:p}),"user"===e.role?(_=u&&!!n&&"running"!==n.status&&!["completed","failed","cancelled","superseded"].includes(n.status),(0,t.jsx)("div",{className:"flex justify-end","data-message-id":e.id,...e.task_id?{"data-task-id":e.task_id}:{},children:(0,t.jsxs)("div",{className:(0,o.cn)("max-w-[80%] rounded-lg px-4 py-2 bg-primary text-primary-foreground text-base relative"),children:[_&&(0,t.jsx)("div",{className:"absolute inset-0 rounded-lg animate-pulse pointer-events-none",style:{boxShadow:"0 0 0 2px var(--bubble-glow)"}}),(0,t.jsx)("div",{className:"markdown markdown-user",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!1,download:!1,fullscreen:!1}},linkSafety:{enabled:!1},allowedTags:ei,literalTagContent:eo,components:w,children:U(e.content,a)})}),e.attachment_ids&&e.attachment_ids.length>0&&(0,t.jsx)(ed,{attachmentIds:e.attachment_ids,artifacts:r,onArtifactClick:v}),!e.attachment_ids&&(0,t.jsx)(eu,{pendingFiles:x,messageId:e.id})]})})):"event"===e.role?(S=e.metadata?.emailId,T=e.metadata?.issueId,(0,t.jsx)("div",{className:"flex justify-start","data-message-id":e.id,...e.task_id?{"data-task-id":e.task_id}:{},children:(0,t.jsxs)("div",{className:(0,o.cn)("w-full rounded-md border bg-muted/50 text-muted-foreground text-sm px-3 py-2 flex items-start gap-2",(!!S||!!T)&&"cursor-pointer hover:bg-muted transition-colors"),onClick:S?()=>y(S):T?()=>j(T):void 0,children:[(0,t.jsx)(ec,{content:e.content,conversationType:g}),(0,t.jsx)("span",{className:"min-w-0 wrap-anywhere",children:e.content})]})})):E?null:(0,t.jsxs)("div",{className:(0,o.cn)("group/msg flex flex-col justify-start min-w-0 overflow-hidden",N&&"bg-muted/30 rounded-lg px-2 -mx-2"),"data-message-id":e.id,"data-quote-source":!0,...e.task_id?{"data-task-id":e.task_id}:{},children:[(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},allowedTags:ei,literalTagContent:eo,components:w,children:U(e.content,a)})}),P]})]})});e.i(400175);var eh=e.i(819748),ep=e.i(126366),eg=e.i(309475);function ef({agent:e,isOnline:a,activeTaskCount:r,variant:n="default",isHovered:l}){let[i,d]=(0,s.useState)(!1),u=e.email_handle?`${e.email_handle}@alook.ai`:null,m=(0,s.useCallback)(async()=>{if(u)try{await navigator.clipboard.writeText(u),d(!0),M.toast.success("Email copied to clipboard"),setTimeout(()=>d(!1),2e3)}catch{M.toast.error("Failed to copy email")}},[u]);if("compact"===n){let s;return(0,t.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(s=(0,ep.parseAvatarUrl)(e.avatar_url))?(0,t.jsx)(eh.AnimatedAvatar,{config:s,size:32,className:"shrink-0 rounded-xl",isHovered:l??!1,isWorking:!!a&&(r??0)>0}):(0,t.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:e.name}),u&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:u})]}),void 0!==a&&(0,t.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,t.jsx)(eg.AgentStatusBadge,{isOnline:a,taskCount:r??0,agentId:e.id})})]})]})}return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("span",{className:"flex-1"}),void 0!==a&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full",a?"bg-status-online":"bg-status-offline")}),a?(r??0)>0?"Working":null:"Offline"]})]}),u&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:u}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),m()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:i?(0,t.jsx)(c.Check,{className:"size-3 text-green-500"}):(0,t.jsx)(el.Copy,{className:"size-3"})})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description})]})}e.s(["AgentPreviewCard",0,ef],844010);var ex=e.i(224950);let ev={mention:function(e){let{children:s,...a}=e,{agents:r}=(0,C.useAgentContext)(),n=a["data-agent-id"]??a.dataAgentId,l=n?r.find(e=>e.id===n):void 0;if(!l&&"string"==typeof s){let e=s.startsWith("@")?s.slice(1):s;l=r.find(t=>t.name.toLowerCase()===e.toLowerCase())}return l?(0,t.jsxs)(ex.Popover,{children:[(0,t.jsx)(ex.PopoverTrigger,{openOnHover:!0,delay:300,nativeButton:!1,render:(0,t.jsx)("span",{className:"mention-highlight cursor-pointer"}),children:s}),(0,t.jsx)(ex.PopoverContent,{side:"top",className:"w-fit max-w-80",children:(0,t.jsx)(ef,{agent:l})})]}):(0,t.jsx)("span",{className:"mention-highlight",children:s})},p:({children:e,node:s,...a})=>(0,t.jsx)("div",{"data-md-p":"",...a,children:e})};function ey(e,t){if("issue_event"===t)return"issue";if("email_notification"===t)return"email";if("calendar_event"===t)return"calendar";let s=e.toLowerCase();return s.startsWith("issue ")||s.startsWith("issue:")?"issue":s.includes("email")?"email":"calendar"}function ej(e,t){let s=new Map;for(let t of e)s.set(t.id,t);for(let e of t)s.set(e.id,e);return[...s.values()].slice().sort((e,t)=>{let s=e.created_at.localeCompare(t.created_at);return 0!==s?s:e.id.localeCompare(t.id)})}function ek(e){let t=[],s=[],a=!1;for(let r of e)"message"===r.kind&&"user"===r.data.role?(a=!0,t.push(r)):"message"===r.kind&&"assistant"===r.data.role?(t.push(r),t.push(...s),s=[],a=!1):a&&"artifact"===r.kind?s.push(r):t.push(r);return t.push(...s),t}function eb(e){let t=(0,s.useRef)(e);return(0,s.useEffect)(()=>{t.current=e},[e]),t}function ew({agentName:e}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 py-4 select-none","aria-hidden":!0,children:[(0,t.jsx)("div",{className:"flex-1 border-t border-border/40"}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground/60 whitespace-nowrap",children:[e," took a nap 💤"]}),(0,t.jsx)("div",{className:"flex-1 border-t border-border/40"})]})}function eN({artifact:e,version:s,hasDuplicates:a,onClick:r}){return(0,t.jsxs)("button",{onClick:()=>r(e),className:(0,o.cn)("flex items-center gap-3 w-full max-w-sm rounded-lg border border-border/60 bg-muted/30","px-3.5 py-2.5 text-left transition-colors duration-150","hover:bg-muted/60 hover:border-border"),children:[(0,t.jsx)(F.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium truncate",children:[e.filename,a&&(0,t.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal",children:["v",s]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,Y.formatSize)(e.size)})]})]})}function eC({agentId:e,targetConvId:i,scrollToTaskId:c,scrollToMessageId:d}){let u,m,h,p=(0,r.useParams)(),f=(0,r.useSearchParams)(),{workspaceId:x,slug:v}=(0,n.useWorkspace)(),{agents:y,agentLinks:j,activeTaskCounts:k,subscribeWs:H}=(0,C.useAgentContext)(),{refresh:V}=(0,_.useInboxCount)(),{activeChannel:X,loading:K,setAgentId:et}=(0,T.useChannel)(),es=e??p.id,ea=void 0!==c?c:f.get("task"),er=void 0!==d?d:f.get("msg"),en=void 0!==i?i:f.get("conv"),[el,ei]=(0,s.useState)(null),[eo,ec]=(0,s.useState)([]),[ed,eu]=(0,s.useState)(()=>localStorage.getItem(`chat-draft:${es}:${en??"default"}`)??""),[eh,ep]=(0,s.useState)(!1),[eg,ef]=(0,s.useState)(!1),[ex,ey]=(0,s.useState)(null),[e_,eS]=(0,s.useState)([]),[eT,eM]=(0,s.useState)(!0),[eI,eA]=(0,s.useState)(!1),[ez,eE]=(0,s.useState)(!1),[eR,eF]=(0,s.useState)(!1),[eP,eD]=(0,s.useState)([]),[eL,eB]=(0,s.useState)(!1),[eq,e$]=(0,s.useState)(null),[eW,eH]=(0,s.useState)(null),[eO,eV]=(0,s.useState)(!1),[eU,eY]=(0,s.useState)(null),[eX,eK]=(0,s.useState)(!1),[eJ,eZ]=(0,s.useState)(null),[eQ,eG]=(0,s.useState)(null),[e0,e1]=(0,s.useState)(!1),[e2,e5]=(0,s.useState)(null),[e3,e4]=(0,s.useState)(null),[e6,e8]=(0,s.useState)(448),[e7,e9]=(0,s.useState)([]),[te,tt]=(0,s.useState)([]),[ts,ta]=(0,s.useState)(null),[tr,tn]=(0,s.useState)([]),[tl,ti]=(0,s.useState)(!1),[to,tc]=(0,s.useState)([]),[td,tu]=(0,s.useState)({}),[tm]=(0,s.useState)(()=>Date.now()),[th,tp]=(0,s.useState)(()=>new Map),[tg,tf]=(0,s.useState)(null),[tx,tv]=(0,s.useState)(null),[ty,tj]=(0,s.useState)(new Set),tk=(0,s.useRef)(ty);(0,s.useEffect)(()=>{tk.current=ty});let{increment:tb,decrement:tw,refresh:tN}=(0,S.useFlagCount)(),{writeToCache:tC}=function(e,t){let[a,r]=(0,s.useState)(null),[n,l]=(0,s.useState)(!1),i=(0,s.useRef)(e);return(0,s.useEffect)(()=>{if(i.current=e,!e||!t){r(null),l(!1);return}(0,N.openCacheDB)(t);let s=!1;return(0,N.getCachedMessages)(e,t).then(t=>{s||i.current!==e||(t&&t.length>0?(r(t),l(!0)):(r(null),l(!1)))}),()=>{s=!0}},[e,t]),{cachedMessages:a,isFromCache:n,writeToCache:(0,s.useCallback)(async(e,s)=>{i.current&&t&&await (0,N.mergeCachedMessages)(i.current,e,s,t)},[t])}}(en??null,x),t_=(0,s.useRef)(tC);(0,s.useEffect)(()=>{t_.current=tC},[tC]),(0,s.useEffect)(()=>{et(es)},[es,et]);let{listening:tS,supported:tT,toggle:tM}=function(e){let[t,a]=(0,s.useState)(!1),[r,n]=(0,s.useState)(!1),l=(0,s.useRef)(null);(0,s.useEffect)(()=>{n(!!W())},[]);let i=(0,s.useCallback)(()=>{let t=W();if(!t)return;let s=new t;s.lang=navigator.language||"zh-CN",s.interimResults=!1,s.continuous=!1,s.onresult=t=>{let s=t.results,a="";for(let e=0;e<s.length;e++)a+=s[e][0].transcript;a&&e(a)},s.onend=()=>{a(!1),l.current=null},s.onerror=()=>{a(!1),l.current=null},l.current=s,s.start(),a(!0)},[e]),o=(0,s.useCallback)(()=>{l.current?.stop()},[]),c=(0,s.useCallback)(()=>{t?o():i()},[t,i,o]);return(0,s.useEffect)(()=>()=>{l.current?.abort()},[]),{listening:t,supported:r,toggle:c}}((0,s.useCallback)(e=>{eu(t=>t?t+" "+e:e)},[])),tI=(0,s.useMemo)(()=>eP.filter(e=>"agent"===e.source),[eP]),{versionMap:tA,duplicateFilenames:tz}=(0,s.useMemo)(()=>(0,Q.computeArtifactVersions)(tI),[tI]),tE=(0,s.useMemo)(()=>"agent"===eW?tI:"issue"===eW?eQ?.artifacts??[]:[],[eW,tI,eQ?.artifacts]),{versionMap:tR,duplicateFilenames:tF}=(0,s.useMemo)(()=>(0,Q.computeArtifactVersions)(tE),[tE]),tP=(0,s.useMemo)(()=>(function(e,t,s,a){if(!a||0===s.length){let a=[...e.map(e=>({kind:"message",data:e})),...t.map(e=>({kind:"artifact",data:e})),...s.map(e=>({kind:"nap",data:e}))];return a.sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);if(0!==s)return s;if("nap"===e.kind||"nap"===t.kind){if("nap"===e.kind&&"nap"!==t.kind)return 1;if("nap"!==e.kind&&"nap"===t.kind)return -1}return e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)}),ek(a)}let r=new Set(s.map(e=>e.id.replace(/^nap-/,""))),n=[...s].sort((e,t)=>e.created_at.localeCompare(t.created_at)),l=s=>ek([...e.filter(e=>e.conversation_id===s).map(e=>({kind:"message",data:e})),...t.filter(e=>e.conversation_id===s).map(e=>({kind:"artifact",data:e}))].sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);return 0!==s?s:e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)})),i=[];for(let e of n){let t=e.id.replace(/^nap-/,"");i.push(...l(t)),i.push({kind:"nap",data:e})}i.push(...l(a));let o=new Set([...r,a]),c=e.filter(e=>!o.has(e.conversation_id)),d=t.filter(e=>!o.has(e.conversation_id));if(c.length>0||d.length>0){let e=[...c.map(e=>({kind:"message",data:e})),...d.map(e=>({kind:"artifact",data:e}))];e.sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);return 0!==s?s:e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)});let t=ek(e),s=i.findIndex(e=>"nap"===e.kind);s>=0?i.splice(s,0,...t):i.push(...t)}return i})(eo,tI,to,el?.id),[eo,tI,to,el?.id]),tD=(0,s.useCallback)(e=>{(0,Q.isPreviewable)(e)?(e$(e),eH("agent"),eB(!0)):window.open((0,Q.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tL=(0,s.useCallback)(e=>{(0,Q.isPreviewable)(e)?(e$(e),eH("issue"),eB(!0)):window.open((0,Q.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tB=(0,s.useRef)(null),tq=(0,s.useRef)(null),t$=(0,s.useRef)(null),tW=(0,s.useRef)(null),tH=(0,s.useRef)(0),tO=(0,s.useRef)(0),tV=(0,s.useRef)(!1),tU=(0,s.useRef)(!1),tY=(0,s.useRef)(!0),tX=(0,s.useRef)(!1),tK=(0,s.useRef)(null),tJ=(0,s.useRef)(null),tZ=(0,s.useRef)(0),tQ=(0,s.useRef)(void 0),tG=(0,s.useRef)(null),t0=(0,s.useRef)(null),t1=function({input:e,caretIndex:t,textareaRef:a,agents:r,agentLinks:n,currentAgentId:l,onInputChange:i}){let[o,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(0),[p,g]=(0,s.useState)({top:0,left:0}),f=(0,s.useRef)(null),x=(0,s.useMemo)(()=>{let e=new Set;for(let t of n)t.source_agent_id===l&&e.add(t.target_agent_id),t.target_agent_id===l&&e.add(t.source_agent_id);return e},[n,l]),{relatedAgents:v,otherAgents:y,allAgents:j}=(0,s.useMemo)(()=>{if(!o)return{relatedAgents:[],otherAgents:[],allAgents:[]};let e=e=>{if(!d)return e.slice(0,20);let t=d.toLowerCase(),s=[],a=[];for(let r of e){let e=r.name.toLowerCase();e.startsWith(t)?s.push(r):e.includes(t)&&a.push(r)}return[...s,...a]},t=[],s=[];for(let e of r)x.has(e.id)?t.push(e):s.push(e);let a=e(t),n=e(s);return{relatedAgents:a,otherAgents:n,allAgents:[...a,...n]}},[o,d,r,x]);(0,s.useEffect)(()=>{h(0)},[j.length,d]),(0,s.useEffect)(()=>{if(null===t)return void c(!1);let s=function(e,t){let s=t-1;for(;s>=0&&t-s<=30;){let a=e.charCodeAt(s);if(64===a)return{start:s,query:e.slice(s+1,t)};if(10===a||13===a)break;s--}return null}(e,t);s?(f.current=s.start,u(s.query),c(!0),a.current&&g(function(e,t){let s=document.createElement("div"),a=window.getComputedStyle(e);for(let t of(s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.visibility="hidden",s.style.overflow="hidden",s.style.width=`${e.offsetWidth}px`,["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing","whiteSpace","wordWrap","overflowWrap"]))s.style[t]=a.getPropertyValue(t.replace(/([A-Z])/g,"-$1").toLowerCase());s.textContent=e.value.slice(0,t);let r=document.createElement("span");r.textContent="​",s.appendChild(r),document.body.appendChild(s);let n=r.offsetTop-e.scrollTop,l=Math.max(0,Math.min(r.offsetLeft,e.offsetWidth-256));return document.body.removeChild(s),{top:n,left:l}}(a.current,s.start))):(c(!1),f.current=null)},[e,t,a]);let k=(0,s.useCallback)(s=>{if(null===t||null===f.current)return;let r=e.slice(0,f.current),n=e.slice(t);i(`${r}@${s.name} ${n}`),c(!1);let l=r.length+1+s.name.length+1;requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(l,l))})},[e,t,a,i]),b=(0,s.useCallback)(e=>!!o&&0!==j.length&&!e.nativeEvent.isComposing&&("ArrowDown"===e.key?(e.preventDefault(),h(e=>(e+1)%j.length),!0):"ArrowUp"===e.key?(e.preventDefault(),h(e=>(e-1+j.length)%j.length),!0):"Enter"===e.key?(e.preventDefault(),k(j[m]),!0):"Escape"===e.key&&(e.preventDefault(),c(!1),!0)),[o,j,m,k]);return{isOpen:o,query:d,selectedIndex:m,anchorPos:p,relatedAgents:v,otherAgents:y,allAgents:j,handleMentionKeyDown:b,selectAgent:k}}({input:ed,caretIndex:ts,textareaRef:t0,agents:(0,s.useMemo)(()=>y.filter(e=>e.id!==es),[y,es]),agentLinks:j,currentAgentId:es,onInputChange:eu});(0,s.useEffect)(()=>{let e=`chat-draft:${es}:${en??"default"}`;ed?localStorage.setItem(e,ed):localStorage.removeItem(e)},[ed,es,en]),(0,s.useEffect)(()=>{eh||t0.current?.focus()},[eh]);let t2=(0,s.useCallback)(()=>{tY.current=!0,setTimeout(()=>{tB.current?.scrollTo({top:tB.current.scrollHeight,behavior:"smooth"})},50)},[]);(0,s.useEffect)(()=>{if(K)return;tq.current&&clearInterval(tq.current),tq.current=null,tW.current=null;let e=!1;return eM(!0),tV.current=!1,ey(null),eS([]),tt([]),tp(new Map),tc([]),tu({}),tn([]),ti(!1),tJ.current=null,eu(localStorage.getItem(`chat-draft:${es}:${en??"default"}`)??""),ec([]),async function(){try{if(en){let t=await (0,N.getCachedMessages)(en,x);if(e)return;t&&t.length>0&&(ec(t),eM(!1));try{let[t,s,a,r]=await Promise.all([(0,w.getConversation)(en,x),(0,w.listMessages)(en,x),(0,w.listArtifacts)(en,x).catch(()=>[]),(0,w.listBufferedMessages)(en,x).catch(()=>[])]);if(e)return;ei(t),ec(e=>ej(e,s.messages)),eE(s.has_more),eD(a),tt(r),t_.current(s.messages,s.has_more).catch(()=>{});let n=[...new Set(s.messages.filter(e=>"assistant"===e.role&&e.task_id).map(e=>e.task_id))];if(n.length>0&&(0,w.getTaskStepCounts)(n,x).then(t=>{e||tu(t)}).catch(()=>{}),(0,w.listFlaggedMessageIds)(x,en).then(t=>{e||tj(new Set(t.message_ids))}).catch(()=>{}),ea){let t=await (0,w.getTask)(ea,x).catch(()=>null);if(e)return;if(t&&!["completed","failed","cancelled","superseded"].includes(t.status)){ey(t);let s=await (0,w.getTaskMessages)(ea,x).catch(()=>[]);if(e)return;eS(s),s.length>0&&(tH.current=Math.max(...s.map(e=>e.seq))),tK.current?.(t.id,en,tH.current)}}}catch{let t=await (0,w.chatInit)(es,x,X);if(e)return;ei(t.conversation),ec(e=>e.length>0?ej(e,t.messages):t.messages),eE(t.has_more_messages),eD(t.artifacts),tt(t.buffered_messages),ti(t.has_more_conversations),t_.current(t.messages,t.has_more_messages).catch(()=>{}),(0,w.listFlaggedMessageIds)(x,t.conversation.id).then(t=>{e||tj(new Set(t.message_ids))}).catch(()=>{})}}else{let t=await (0,w.chatInit)(es,x,X);if(e)return;ei(t.conversation),ec(e=>e.length>0?ej(e,t.messages):t.messages),eE(t.has_more_messages),eD(t.artifacts),tt(t.buffered_messages),ti(t.has_more_conversations),t_.current(t.messages,t.has_more_messages).catch(()=>{}),(0,w.listFlaggedMessageIds)(x,t.conversation.id).then(t=>{e||tj(new Set(t.message_ids))}).catch(()=>{}),t.active_task&&(ey(t.active_task),t.task_messages.length>0&&(eS(t.task_messages),tH.current=Math.max(...t.task_messages.map(e=>e.seq))),["completed","failed","cancelled","superseded"].includes(t.active_task.status)||tK.current?.(t.active_task.id,t.conversation.id,tH.current))}}catch{M.toast.error("Failed to load conversation")}finally{e||eM(!1)}}(),()=>{e=!0}},[es,x,en,ea,X,K]);let t5=(0,s.useRef)(V);(0,s.useEffect)(()=>{t5.current=V},[V]);let t3=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!el?.id||!x||t3.current===el.id)return;t3.current=el.id;let e=setTimeout(()=>{(0,w.markInboxRead)(el.id,x).then(()=>t5.current()).catch(()=>{})},1e3);return()=>{t3.current=null,clearTimeout(e)}},[el?.id,x]),(0,s.useEffect)(()=>{eT||!(eo.length>0)||tV.current||(tV.current=!0,ea||er?tY.current=!1:i?setTimeout(()=>{let e=tB.current?.querySelectorAll("[data-quote-source]");e&&e.length>0?e[e.length-1].scrollIntoView({behavior:"instant",block:"start"}):tB.current?.scrollTo({top:tB.current.scrollHeight})},50):setTimeout(()=>{tB.current?.scrollTo({top:tB.current.scrollHeight})},50))},[eT,eo.length,ea,er,i]),(0,s.useEffect)(()=>{let e;if(!ea||eT||!el)return;tY.current=!1,tX.current=!0;let t=!1,s=()=>{if(t)return!1;let s=document.querySelector(`[data-task-id="${CSS.escape(ea)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tX.current=!1)},1500),!0)},a=setTimeout(async()=>{if(!t&&!s())try{let e=await (0,w.listMessagesAroundTask)(el.id,x,ea);if(t)return;e.length>0?(ec(t=>ej(t,e)),requestAnimationFrame(()=>{setTimeout(()=>{s()||(tX.current=!1)},100)})):tX.current=!1}catch{t||(tX.current=!1)}},100);return()=>{t=!0,clearTimeout(a),e&&clearTimeout(e)}},[ea,eT,el,x]),(0,s.useEffect)(()=>{let e;if(!er||ea||eT||!el)return;tY.current=!1,tX.current=!0;let t=!1,s=setTimeout(()=>{!t&&((()=>{if(t)return!1;let s=document.querySelector(`[data-message-id="${CSS.escape(er)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tX.current=!1)},1500),!0)})()||(tB.current?.scrollTo({top:tB.current.scrollHeight}),tX.current=!1))},100);return()=>{t=!0,clearTimeout(s),e&&clearTimeout(e)}},[er,ea,eT,el]);let t4=ex?.status;(0,s.useEffect)(()=>{tX.current||("running"===t4||"queued"===t4)&&tY.current&&t2()},[e_.length,t4,t2]);let t6=(0,s.useMemo)(()=>y.find(e=>e.id===es)?.name??"Agent",[y,es]),t8=eb(eo),t7=eb(ez),t9=eb(tr),se=eb(tl),st=eb(t6),ss=eb(X),sa=(0,s.useCallback)(async(e=!1)=>{if(!el||tU.current)return;tU.current=!0;let t=t8.current,s=t7.current,r=se.current,n=st.current,l=ss.current,i=t[0],o=tJ.current?.id??el.id,c=s&&i,d=t9.current;if(!c&&0===d.length&&r){let e=tJ.current??{id:el.id,created_at:el.created_at};try{let t=await (0,w.listPreviousConversations)(es,x,{exclude:el.id,before:e.created_at,channel:l});d=t.conversations,tn(t.conversations),ti(t.has_more)}catch{ti(!1)}}let u=d.length>0;if(!c&&!u){tU.current=!1;return}eF(!0);let m=tB.current;m&&(m.style.overflowAnchor="none");let h=m?.scrollHeight??0;try{let t=[],s=[],u=20,p=!1,g=[];if(c){let e=o===el.id?await (0,N.getCachedMessagesBefore)(o,i.created_at,i.id,20,x):null;if(e)t=e.messages,u-=e.messages.length,p=e.hasMore;else{let e=await (0,w.listMessages)(o,x,{limit:20,before:i.created_at,beforeId:i.id});t=e.messages,u-=e.messages.length,p=e.has_more}}if(!p&&u>0){if(0===d.length&&r){let e=tJ.current??{id:el.id,created_at:el.created_at};try{let t=await (0,w.listPreviousConversations)(es,x,{exclude:el.id,before:e.created_at,channel:l});d=t.conversations,tn(t.conversations),ti(t.has_more)}catch{ti(!1)}}let e=0,t=0;for(;e<d.length&&u>0&&t<5;){let a=d[e];e++,t++;let r=await (0,w.listMessages)(a.id,x,{limit:u});if(0===r.messages.length){tJ.current=a;continue}let l=tJ.current?.created_at??el.created_at;g.push({agentName:n,created_at:l,id:`nap-${a.id}`}),s=[...r.messages,...s],u-=r.messages.length,p=r.has_more,tJ.current=a}e>0&&tn(t=>t.slice(e))}let f=[...s,...t];if((0,a.flushSync)(()=>{f.length>0?(g.length>0&&tc(e=>{let t=new Set(e.map(e=>e.id)),s=g.filter(e=>!t.has(e.id));return[...e,...s]}),eE(p),ec(e=>{let t=new Set(e.map(e=>e.id));return[...f.filter(e=>!t.has(e.id)),...e]})):eE(!1)}),f.length>0&&el){let e=f.filter(e=>e.conversation_id===el.id);e.length>0&&(0,N.mergeCachedMessages)(el.id,e,p,x).catch(()=>{})}if(tU.current=!1,(0,a.flushSync)(()=>eF(!1)),m)if(e)m.scrollTop=m.scrollHeight;else{let e=m.scrollHeight;m.scrollTop=e-h}}catch{M.toast.error("Failed to load older messages")}finally{tU.current=!1,eF(!1),tB.current&&(tB.current.style.overflowAnchor="")}},[el,x,es,t8,t7,se,st,ss,t9]),sr=ez||tr.length>0||tl;(0,s.useEffect)(()=>{el?.id!==tQ.current&&(tQ.current=el?.id,tZ.current=0)},[el?.id]),(0,s.useEffect)(()=>{eT||!el||eo.length>=10||!sr||eR||tZ.current>=3||(tZ.current+=1,sa(!0))},[eT,eo.length,sr,eR,el,sa]);let sn=(0,s.useCallback)(()=>{let e=tB.current;e&&(tY.current=e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]),sl=(0,s.useCallback)((e,t,s)=>{tq.current&&clearInterval(tq.current),tH.current=s??0,tO.current=0,eA(!1),tW.current=e,tq.current=setInterval(async()=>{if(tW.current===e)try{let[s,a]=await Promise.all([(0,w.getTask)(e,x),(0,w.getTaskMessages)(e,x,tH.current||void 0)]),r=tW.current!==e;if(tO.current=0,eA(!1),a.length>0&&!r&&(eS(e=>{let t=new Set(e.map(e=>e.seq)),s=a.filter(e=>!t.has(e.seq));return s.length>0?[...e,...s]:e}),tH.current=Math.max(...a.map(e=>e.seq),tH.current)),"completed"===s.status||"failed"===s.status||"cancelled"===s.status||"superseded"===s.status){if(r)return void(0,w.listMessages)(t,x).then(({messages:e})=>{ec(t=>ej(t,e)),(0,N.mergeCachedMessages)(t,e,null,x).catch(()=>{})}).catch(()=>{});tq.current&&clearInterval(tq.current),tq.current=null,t$.current&&clearTimeout(t$.current),t$.current=setTimeout(()=>{(0,w.markInboxRead)(t,x).then(()=>t5.current()).catch(()=>{})},1e3);let a=!tX.current&&tY.current;try{let[e,a]=await Promise.all([(0,w.listMessages)(t,x),(0,w.listArtifacts)(t,x).catch(()=>null)]);ec(t=>ej(t,e.messages)),(0,N.mergeCachedMessages)(t,e.messages,null,x).catch(()=>{}),a&&eD(a),ey(s)}catch{ey(s),M.toast.error("Failed to refresh messages")}a&&requestAnimationFrame(()=>{tB.current?.scrollTo({top:tB.current.scrollHeight,behavior:"smooth"})}),setTimeout(async()=>{if(!tq.current)try{let[s,a]=await Promise.all([(0,w.getActiveTask)(t,x),(0,w.listBufferedMessages)(t,x)]);if(tt(a),s&&s.id!==e){let{messages:e}=await (0,w.listMessages)(t,x);ec(t=>ej(t,e)),(0,N.mergeCachedMessages)(t,e,null,x).catch(()=>{}),ey(s),eS([]),tK.current?.(s.id,t)}}catch{}},1e3)}else r||ey(s)}catch{if(tW.current!==e)return;tO.current+=1,tO.current>=3&&eA(!0),tO.current>=10&&(tq.current&&clearInterval(tq.current),tq.current=null,M.toast.error("Lost connection to agent"))}},3e3)},[x]);(0,s.useEffect)(()=>{tK.current=sl},[sl]),(0,s.useEffect)(()=>()=>{tq.current&&clearInterval(tq.current),t$.current&&clearTimeout(t$.current)},[]);let si=(0,s.useRef)(null);(0,s.useEffect)(()=>{si.current=ex?.id??null},[ex]),(0,s.useEffect)(()=>H(e=>{if("task.messages"===e.type&&e.taskId===si.current){let t=e.messages.filter(e=>e.seq>tH.current);t.length>0&&(eS(e=>{let s=new Set(e.map(e=>e.seq)),a=t.filter(e=>!s.has(e.seq));return a.length>0?[...e,...a]:e}),tH.current=Math.max(...t.map(e=>e.seq),tH.current))}if("task.created"===e.type&&e.conversationId===el?.id){(0,w.listMessages)(e.conversationId,x).then(({messages:t})=>{ec(e=>ej(e,t)),(0,N.mergeCachedMessages)(e.conversationId,t,null,x).catch(()=>{})}).catch(()=>{});let t=e.task;si.current=t.id,ey(t),eS([]),tH.current=0,tK.current?.(t.id,e.conversationId)}if("conversation.message"===e.type&&e.conversationId===el?.id&&(ec(t=>ej(t,[e.message])),(0,N.appendCachedMessage)(e.conversationId,e.message,x).catch(()=>{})),"task.updated"===e.type&&e.taskId===si.current&&ey(t=>t?{...t,status:e.status}:t),"artifact.uploaded"===e.type&&e.conversationId===el?.id&&eD(t=>t.some(t=>t.id===e.artifact.id)?t:[...t,e.artifact]),"followup.dispatched"===e.type&&e.conversationId===el?.id){tt(t=>t.filter(t=>t.id!==e.message.id)),(0,w.listBufferedMessages)(e.conversationId,x).then(tt).catch(()=>{}),(0,w.listMessages)(e.conversationId,x).then(({messages:t})=>{ec(e=>ej(e,t)),(0,N.mergeCachedMessages)(e.conversationId,t,null,x).catch(()=>{})}).catch(()=>{});let t=e.task;si.current=t.id,ey(t),eS([]),tK.current?.(t.id,e.conversationId)}"followup.created"===e.type&&e.conversationId===el?.id&&tt(t=>(function(e,t){if(e.some(e=>e.id===t.id))return e;let s=new Date(t.created_at).getTime();return e.some(e=>e.id.startsWith("temp-")&&2e3>Math.abs(new Date(e.created_at).getTime()-s))?e:[...e,t]})(t,e.message)),"followup.deleted"===e.type&&e.conversationId===el?.id&&tt(t=>t.filter(t=>t.id!==e.messageId)),"followup.dispatch_failed"===e.type&&e.conversationId===el?.id&&M.toast.error(e.error||"Failed to dispatch follow-up")}),[H,el?.id,x]);let so=(0,s.useCallback)(e=>{let t=e.target.files;if(!t)return;let s=[];for(let e of Array.from(t))e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&e9(e=>[...e,...s]),e.target.value=""},[]),sc=(0,s.useCallback)(e=>{e9(t=>t.filter((t,s)=>s!==e))},[]),sd=(0,s.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed||!e.rangeCount)return void tv(null);let t=e.toString().trim();if(!t)return void tv(null);let s=e.getRangeAt(0),a=s.commonAncestorContainer instanceof HTMLElement?s.commonAncestorContainer:s.commonAncestorContainer.parentElement;if(!a?.closest("[data-quote-source]"))return void tv(null);let r=s.getClientRects(),n=r[r.length-1]||s.getBoundingClientRect();tv({text:t,x:n.right,y:n.top-4})},[]);(0,s.useEffect)(()=>(document.addEventListener("selectionchange",sd),()=>document.removeEventListener("selectionchange",sd)),[sd]);let su=(0,s.useCallback)(()=>{tx&&(tf(tx.text),tv(null),window.getSelection()?.removeAllRanges(),t0.current?.focus())},[tx]),[sm,sh]=(0,s.useState)(!1),sp=(0,s.useRef)(0),sg=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sp.current++,e.dataTransfer.types.includes("Files")&&sh(!0)},[]),sf=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sp.current--,0===sp.current&&sh(!1)},[]),sx=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),sv=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sh(!1),sp.current=0;let t=Array.from(e.dataTransfer.files),s=[];for(let e of t)e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&e9(e=>[...e,...s])},[]),sy=(0,s.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let s=[];for(let e=0;e<t.length;e++){let a=t[e];if("file"===a.kind){let e=a.getAsFile();e&&s.push(e)}}if(0===s.length)return;e.preventDefault();let a=[];for(let e of s)e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):a.push(e);a.length>0&&e9(e=>[...e,...a])},[]),sj=async()=>{if(el&&!eg){ef(!0);try{let e=await (0,w.cancelActiveTask)(el.id,x);if(e){if(si.current&&si.current!==e.id)return;tq.current&&clearInterval(tq.current),tq.current=null;let[t,s]=await Promise.all([(0,w.listMessages)(el.id,x),(0,w.listBufferedMessages)(el.id,x)]);ec(e=>ej(e,t.messages)),(0,N.mergeCachedMessages)(el.id,t.messages,null,x).catch(()=>{}),tt(s),ey(e),eS([])}}catch{M.toast.error("Failed to cancel task")}finally{ef(!1)}}},sk=async()=>{let e=ed.trim();if(!e&&0===e7.length||eh||!el)return;if(!e)return void M.toast.error("Please type a message");let t=tg?`> ${tg.split("\n").join("\n> ")}
2
2
 
3
- ${e}`:e,s=[...e7];if(eu(""),e9([]),tg(null),ep(!0),ex&&!["completed","failed","cancelled","superseded"].includes(ex.status)){let e=`temp-${Date.now()}`,a={id:e,conversation_id:el.id,role:"user",content:t,task_id:null,attachment_ids:null,status:"buffered",created_at:new Date().toISOString()};tt(e=>[...e,a]);try{let{message:a}=await (0,w.createBufferedMessage)(el.id,t,x,s.length>0?s:void 0);tt(t=>t.some(e=>e.id===a.id)?t.filter(t=>t.id!==e):t.map(t=>t.id===e?a:t))}catch(a){tt(t=>t.filter(t=>t.id!==e)),eu(t),e9(s),M.toast.error(a instanceof Error?a.message:"Failed to queue follow-up")}finally{ep(!1)}return}let a=`temp-${Date.now()}`,r={id:a,conversation_id:el.id,role:"user",content:t,task_id:null,attachment_ids:null,created_at:new Date().toISOString()};s.length>0&&tp(e=>{let t=new Map(e);return t.set(a,s),t}),ec(e=>[...e,r]),t6();try{let{message:e,task:n}=await (0,w.sendMessage)(el.id,t,x,s.length>0?s:void 0);tp(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ec(t=>t.map(t=>t.id===r.id?e:t)),e.attachment_ids&&e.attachment_ids.length>0&&(0,w.listArtifacts)(el.id,x).then(e=>eD(e)).catch(()=>{}),ej(n),e_([]),sd(n.id,el.id)}catch(e){tp(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ec(e=>e.filter(e=>e.id!==r.id)),eu(t),e9(s),M.toast.error(e instanceof Error?e.message:"Failed to send message")}finally{ep(!1),t3.current?.focus()}},sS=(0,s.useCallback)(async()=>{if(!ex||!el)return;let e=await (0,w.retryTask)(ex.id,x);ej(e),e_([]),sd(e.id,el.id)},[ex,el,x,sd]),s_=(0,s.useCallback)(async e=>{let t=tk.current.has(e);ty(s=>{let a=new Set(s);return t?a.delete(e):a.add(e),a}),t?(tw(),(0,w.unflagMessage)(x,e).then(()=>{tN()}).catch(()=>{ty(t=>new Set(t).add(e)),tb()})):(tb(),(0,w.flagMessage)(x,e).then(()=>{tN()}).catch(()=>{ty(t=>{let s=new Set(t);return s.delete(e),s}),tw()}))},[x,tb,tw,tN]),sT=(0,s.useCallback)(async e=>{eZ(e),eK(!0),e1(!0),e5(null),e4(null);try{let t=await (0,w.getIssue)(x,e);eG(t),t.issue.latest_task_id&&(0,w.getTask)(t.issue.latest_task_id,x).then(e=>e4(e)).catch(()=>e4(null)),t.issue.trace_id&&(0,w.getTrace)(t.issue.trace_id,x).then(e=>e5(e.tasks)).catch(()=>e5(null))}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to load issue"),eK(!1)}finally{e1(!1)}},[x]),sM=eQ?.issue?.conversation_id??null,sI=eQ?.issue?.latest_task_id??null;(0,s.useEffect)(()=>{if(eX&&eJ)return H(e=>{if("task.updated"===e.type&&sI&&e.taskId===sI&&(0,w.getTask)(sI,x).then(e=>e4(e)).catch(()=>{}),"conversation.message"===e.type&&sM&&e.conversationId===sM&&(eG(t=>!t||t.messages.some(t=>t.id===e.message.id)?t:{...t,messages:[...t.messages,e.message]}),"event"===e.message.role&&e.message.content.startsWith("Issue status changed:"))){let t=e.message.content.match(/-> (\w+)/);t&&eG(e=>e?{...e,issue:{...e.issue,status:t[1]}}:e)}"issue.comment"===e.type&&e.issueId===eJ&&eG(t=>!t||t.comments.some(t=>t.id===e.comment.id)?t:{...t,comments:[...t.comments,e.comment]})})},[eX,eJ,sM,sI,x,H]);let[sA,sz]=(0,s.useState)(!1),sE=(0,s.useMemo)(()=>!!el&&eo.some(e=>e.conversation_id===el.id),[el,eo]),sR=async()=>{if(el&&sE&&!sA){sz(!0);try{tO.current&&(clearInterval(tO.current),tO.current=null);let e=await (0,w.createConversation)(es,x,X);tc(t=>[...t,{agentName:se,created_at:e.created_at,id:`nap-${el.id}`}]),tn(e=>[{id:el.id,created_at:el.created_at},...e]),ei(e),ej(null),e_([]),eD([]),tt([]),e9([]),tp(new Map),tY.current=0,eA(!1),eE(!1),t0.current=null,t6()}catch{M.toast.error("Failed to start new conversation")}finally{sz(!1)}}},sF=!!ex&&!["completed","failed","cancelled","superseded"].includes(ex.status);return eT?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto px-3 md:px-5",children:(0,t.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4",children:[(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(I.Skeleton,{className:"h-10 w-48 rounded-lg"})}),(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,t.jsx)(I.Skeleton,{className:"h-4 w-72"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-56"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-64"})]})}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(I.Skeleton,{className:"h-10 w-36 rounded-lg"})}),(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,t.jsx)(I.Skeleton,{className:"h-4 w-64"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-48"})]})})]})}),(0,t.jsx)("div",{className:"px-3 md:px-5 py-3",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl",children:(0,t.jsx)(I.Skeleton,{className:"h-18 w-full rounded-xl"})})})]}):el?(0,t.jsxs)(t.Fragment,{children:[tx&&(0,t.jsxs)("button",{type:"button",className:"fixed z-50 flex items-center gap-1 px-2 py-1 rounded-md bg-popover border shadow-md text-xs text-popover-foreground hover:bg-accent transition-colors",style:{left:tx.x,top:tx.y,transform:"translate(-100%, -100%)"},onMouseDown:e=>e.preventDefault(),onClick:sf,children:[(0,t.jsx)(D,{className:"size-3"}),"Quote"]}),(0,t.jsxs)("div",{className:"relative flex-1 min-h-0",children:[(0,t.jsx)("div",{className:"h-full overflow-y-auto overflow-x-hidden px-3 md:px-5 thin-scrollbar",ref:tH,onScroll:sc,onClick:e=>{e.target.closest('[data-streamdown="code-block-actions"] button')&&M.toast.success("Copied to clipboard")},children:(0,t.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4 min-w-0",children:[so&&!eR&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)("button",{onClick:()=>si(),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Load earlier messages"})}),eR&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)(f.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}),0===eo.length&&!ex&&(u=j.find(e=>e.id===es),m=u?.created_at&&tm-new Date(u.created_at).getTime()<3e5,h=(k[es]??0)>0,m&&h&&"default"===X?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-3 animate-[fade-up_400ms_ease-out_both]",children:[(0,t.jsxs)("div",{className:"relative animate-bounce",children:[(0,t.jsx)(P.Mail,{className:"size-8 text-primary"}),(0,t.jsxs)("span",{className:"absolute -top-1 -right-1 flex size-3",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex size-full rounded-full bg-primary/60"}),(0,t.jsx)("span",{className:"relative inline-flex size-3 rounded-full bg-primary"})]})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center max-w-xs",children:"Your agent is sending you a welcome email."}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground/60 text-center max-w-xs",children:"Wait for the email task in the top-left to complete, then check your inbox. Or send a message below to start chatting."})]}):(0,t.jsx)("p",{className:"text-center text-muted-foreground py-20 text-sm",children:"Send a message to start chatting with the agent."})),tB.map(e=>{if("nap"===e.kind)return(0,t.jsx)(ew,{agentName:se},e.data.id);if("artifact"===e.kind)return(0,t.jsx)(eN,{artifact:e.data,version:tF.get(e.data.id)??1,hasDuplicates:tP.has(e.data.filename),onClick:t$},`artifact-${e.data.id}`);let s=e.data;return(0,t.jsx)(em,{msg:s,agents:j,artifacts:eP,activeTask:ex,taskMessages:eS,connectionLost:eI,isLastMessage:eo.length>0&&eo[eo.length-1].id===s.id,stepCount:s.task_id?td[s.task_id]??0:0,targetConvId:en,workspaceId:x,conversationType:el?.type,pendingFilesByMessage:th,onArtifactClick:t$,onEmailClick:e=>{eY(e),eV(!0)},onIssueClick:e=>sT(e),onRetry:sS,mentionComponents:ev,isFlagged:tj.has(s.id),onToggleFlag:"assistant"===s.role?s_:void 0},s.id)}),ex&&ex.conversation_id===el?.id&&!["completed","failed","cancelled","superseded"].includes(ex.status)&&(0,t.jsx)(b,{task:ex,messages:eS,connectionLost:eI})]})}),(0,t.jsx)(ee.ScrollToBottomButton,{scrollRef:tH})]}),el&&(0,t.jsx)(G,{bufferedMessages:te,onDelete:e=>{tt(t=>t.filter(t=>t.id!==e)),(0,w.deleteBufferedMessage)(el.id,e,x).catch(()=>{tt(te),M.toast.error("Failed to delete follow-up")})}}),(0,t.jsx)("div",{className:"px-3 md:px-5 py-3",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl relative",children:(0,t.jsxs)("div",{className:(0,o.cn)("relative flex flex-col rounded-xl border bg-background/60 transition-colors duration-200","focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",eh&&"opacity-50",sg&&"border-ring ring-3 ring-ring/50"),onDragEnter:sj,onDragLeave:sy,onDragOver:sk,onDrop:sb,children:[sg&&(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/80 border-2 border-dashed border-ring pointer-events-none",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground font-medium",children:"Drop files here"})}),tf&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[(0,t.jsx)(D,{className:"size-3.5 shrink-0 mt-0.5 text-muted-foreground"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[tf.slice(0,120),tf.length>120?"...":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tg(null),className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,t.jsx)($.X,{className:"size-3.5"})})]}),(0,t.jsx)(O,{isOpen:t4.isOpen,relatedAgents:t4.relatedAgents,otherAgents:t4.otherAgents,selectedIndex:t4.selectedIndex,onSelect:t4.selectAgent,anchorPos:t4.anchorPos}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{"aria-hidden":!0,className:"mention-backdrop absolute inset-0 px-3.5 py-2.5 text-base chat-input-line-height whitespace-pre-wrap wrap-break-word pointer-events-none overflow-y-auto thin-scrollbar",dangerouslySetInnerHTML:{__html:ed?U(ed.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),j).replace(/<mention[^>]*>/g,'<span class="mention-highlight">').replace(/<\/mention>/g,"</span>")+(ed.endsWith("\n")?"\n":""):""}}),(0,t.jsx)("textarea",{ref:t3,value:ed,onChange:e=>{eu(e.target.value),ta(e.target.selectionStart),requestAnimationFrame(()=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)})},onKeyDown:e=>{!t4.handleMentionKeyDown(e)&&("Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),sC()))},onPaste:sw,onKeyUp:e=>ta(e.target.selectionStart),onClick:e=>ta(e.target.selectionStart),onSelect:e=>ta(e.target.selectionStart),onScroll:e=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)},placeholder:sF?"Type a follow-up...":"Type a message...",rows:1,disabled:eh,className:(0,o.cn)("relative field-sizing-content w-full resize-none bg-transparent px-3.5 py-2.5 text-base chat-input-line-height outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed","min-h-9.5 max-h-50 thin-scrollbar","caret-foreground textarea-text-hidden")})]}),e7.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 px-3.5 pb-1",children:e7.map((e,s)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:[(0,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-30",children:e.name}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:(0,Y.formatSize)(e.size)}),(0,t.jsx)("button",{type:"button",onClick:()=>sh(s),className:"ml-0.5 rounded-sm p-0.5 hover:bg-muted-foreground/20 transition-colors",children:(0,t.jsx)($.X,{className:"size-3"})})]},`${e.name}-${s}`))}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 pb-2 pt-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[!en&&(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:e=>(0,t.jsx)("span",{...e,className:(0,o.cn)("inline-flex",e.className),children:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:sR,disabled:sA||!el||!sE||sF,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200",children:sA?(0,t.jsx)(f.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(E,{className:"size-3.5"})})})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:sF?"Wait for the task to finish":sE?"Take a nap":`${se} is well-rested and ready to go`})]}),(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsxs)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{eH("agent"),eq(!0)},className:"relative rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:[(0,t.jsx)(R,{className:"size-3.5"}),tR.length>0&&(0,t.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex size-3.5 items-center justify-center rounded-full bg-primary text-[9px] font-medium text-primary-foreground",children:tR.length})]}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Artifacts"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("input",{ref:t5,type:"file",multiple:!0,className:"hidden",onChange:sm}),(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:()=>t5.current?.click(),disabled:eh,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:(0,t.jsx)(q.Paperclip,{className:"size-3.5"})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Attach files"})]}),tz&&(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:tE,disabled:eh,className:(0,o.cn)("rounded-lg transition-colors duration-200",tA?"text-red-500 hover:text-red-600 bg-red-500/10":"text-muted-foreground/60 hover:text-foreground")}),children:(0,t.jsx)(L,{className:(0,o.cn)("size-3.5",tA&&"animate-pulse")})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:tA?"Stop recording":"Voice input"})]}),!sF||ed.trim()||eh?(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:sC,disabled:!ed.trim()||eh,className:(0,o.cn)("rounded-lg transition-opacity duration-200",!ed.trim()&&"opacity-40")}),children:eh?(0,t.jsx)(f.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(z.ArrowUp,{className:"size-3.5"})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Send"})]}):(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:sN,disabled:ef,className:"rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-colors duration-200"}),children:ef?(0,t.jsx)(f.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(B.Square,{className:"size-3.5 fill-current"})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Stop task"})]})]})]})]})})}),(0,t.jsx)(Y.ArtifactSheet,{open:eL,onOpenChange:e=>{eq(e),e||setTimeout(()=>{e$(null),eH(null)},300)},artifacts:tD,workspaceId:x,initialArtifact:eB,versionMap:tL,duplicateFilenames:tq}),(0,t.jsx)(J,{open:eO,onOpenChange:e=>{eV(e),e||setTimeout(()=>eY(null),300)},emailId:eU,workspaceId:x}),(0,t.jsx)(Z.IssueSheet,{open:eX,onOpenChange:e=>{eK(e),e||setTimeout(()=>{eZ(null),eG(null),e4(null)},300)},agents:j,issue:eQ?.issue??null,detail:eQ?{messages:eQ.messages,comments:eQ.comments,artifacts:eQ.artifacts,traceId:eQ.issue.trace_id}:null,detailLoading:e0,activeTask:e3,traceTasks:e2,slug:v,workspaceId:x,width:e6,onWidthChange:e8,onUpdate:async(e,t)=>{try{let s=await (0,w.updateIssue)(x,e,t);eG(a=>a&&a.issue.id===e?{...a,issue:{...a.issue,...t,updated_at:s.updated_at}}:a)}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to update issue")}},onStatusChange:async(e,t)=>{try{await (0,w.updateIssue)(x,e,{status:t}),eG(s=>s&&s.issue.id===e?{...s,issue:{...s.issue,status:t}}:s)}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to update status")}},onCommented:()=>{eJ&&sT(eJ)},onArtifactClick:tW})]}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Failed to load conversation"})}}]);
3
+ ${e}`:e,s=[...e7];if(eu(""),e9([]),tf(null),ep(!0),ex&&!["completed","failed","cancelled","superseded"].includes(ex.status)){let e=`temp-${Date.now()}`,a={id:e,conversation_id:el.id,role:"user",content:t,task_id:null,attachment_ids:null,status:"buffered",created_at:new Date().toISOString()};tt(e=>[...e,a]);try{let{message:a}=await (0,w.createBufferedMessage)(el.id,t,x,s.length>0?s:void 0);tt(t=>t.some(e=>e.id===a.id)?t.filter(t=>t.id!==e):t.map(t=>t.id===e?a:t))}catch(a){tt(t=>t.filter(t=>t.id!==e)),eu(t),e9(s),M.toast.error(a instanceof Error?a.message:"Failed to queue follow-up")}finally{ep(!1)}return}let a=`temp-${Date.now()}`,r={id:a,conversation_id:el.id,role:"user",content:t,task_id:null,attachment_ids:null,created_at:new Date().toISOString()};s.length>0&&tp(e=>{let t=new Map(e);return t.set(a,s),t}),ec(e=>[...e,r]),t2();try{let{message:e,task:n}=await (0,w.sendMessage)(el.id,t,x,s.length>0?s:void 0);tp(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ec(t=>t.map(t=>t.id===r.id?e:t)),e.attachment_ids&&e.attachment_ids.length>0&&(0,w.listArtifacts)(el.id,x).then(e=>eD(e)).catch(()=>{}),ey(n),eS([]),sl(n.id,el.id)}catch(e){tp(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ec(e=>e.filter(e=>e.id!==r.id)),eu(t),e9(s),M.toast.error(e instanceof Error?e.message:"Failed to send message")}finally{ep(!1),t0.current?.focus()}},sb=(0,s.useCallback)(async()=>{if(!ex||!el)return;let e=await (0,w.retryTask)(ex.id,x);ey(e),eS([]),sl(e.id,el.id)},[ex,el,x,sl]),sw=(0,s.useCallback)(async e=>{let t=tk.current.has(e);tj(s=>{let a=new Set(s);return t?a.delete(e):a.add(e),a}),t?(tw(),(0,w.unflagMessage)(x,e).then(()=>{tN()}).catch(()=>{tj(t=>new Set(t).add(e)),tb()})):(tb(),(0,w.flagMessage)(x,e).then(()=>{tN()}).catch(()=>{tj(t=>{let s=new Set(t);return s.delete(e),s}),tw()}))},[x,tb,tw,tN]),sN=(0,s.useCallback)(async e=>{eZ(e),eK(!0),e1(!0),e5(null),e4(null);try{let t=await (0,w.getIssue)(x,e);eG(t),t.issue.latest_task_id&&(0,w.getTask)(t.issue.latest_task_id,x).then(e=>e4(e)).catch(()=>e4(null)),t.issue.trace_id&&(0,w.getTrace)(t.issue.trace_id,x).then(e=>e5(e.tasks)).catch(()=>e5(null))}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to load issue"),eK(!1)}finally{e1(!1)}},[x]),sC=eQ?.issue?.conversation_id??null,s_=eQ?.issue?.latest_task_id??null;(0,s.useEffect)(()=>{if(eX&&eJ)return H(e=>{if("task.updated"===e.type&&s_&&e.taskId===s_&&(0,w.getTask)(s_,x).then(e=>e4(e)).catch(()=>{}),"conversation.message"===e.type&&sC&&e.conversationId===sC&&(eG(t=>!t||t.messages.some(t=>t.id===e.message.id)?t:{...t,messages:[...t.messages,e.message]}),"event"===e.message.role&&e.message.content.startsWith("Issue status changed:"))){let t=e.message.content.match(/-> (\w+)/);t&&eG(e=>e?{...e,issue:{...e.issue,status:t[1]}}:e)}"issue.comment"===e.type&&e.issueId===eJ&&eG(t=>!t||t.comments.some(t=>t.id===e.comment.id)?t:{...t,comments:[...t.comments,e.comment]})})},[eX,eJ,sC,s_,x,H]);let[sS,sT]=(0,s.useState)(!1),sM=(0,s.useMemo)(()=>!!el&&eo.some(e=>e.conversation_id===el.id),[el,eo]),sI=async()=>{if(el&&sM&&!sS){sT(!0);try{tq.current&&(clearInterval(tq.current),tq.current=null);let e=await (0,w.createConversation)(es,x,X);tc(t=>[...t,{agentName:t6,created_at:e.created_at,id:`nap-${el.id}`}]),tn(e=>[{id:el.id,created_at:el.created_at},...e]),ei(e),ey(null),eS([]),eD([]),tt([]),e9([]),tp(new Map),tH.current=0,eA(!1),eE(!1),tJ.current=null,t2()}catch{M.toast.error("Failed to start new conversation")}finally{sT(!1)}}},sA=!!ex&&!["completed","failed","cancelled","superseded"].includes(ex.status);return eT?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto px-3 md:px-5",children:(0,t.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4",children:[(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(I.Skeleton,{className:"h-10 w-48 rounded-lg"})}),(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,t.jsx)(I.Skeleton,{className:"h-4 w-72"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-56"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-64"})]})}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(I.Skeleton,{className:"h-10 w-36 rounded-lg"})}),(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,t.jsx)(I.Skeleton,{className:"h-4 w-64"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-48"})]})})]})}),(0,t.jsx)("div",{className:"px-3 md:px-5 py-3",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl",children:(0,t.jsx)(I.Skeleton,{className:"h-18 w-full rounded-xl"})})})]}):el?(0,t.jsxs)(t.Fragment,{children:[tx&&(0,t.jsxs)("button",{type:"button",className:"fixed z-50 flex items-center gap-1 px-2 py-1 rounded-md bg-popover border shadow-md text-xs text-popover-foreground hover:bg-accent transition-colors",style:{left:tx.x,top:tx.y,transform:"translate(-100%, -100%)"},onMouseDown:e=>e.preventDefault(),onClick:su,children:[(0,t.jsx)(D,{className:"size-3"}),"Quote"]}),(0,t.jsxs)("div",{className:"relative flex-1 min-h-0",children:[(0,t.jsx)("div",{className:"h-full overflow-y-auto overflow-x-hidden px-3 md:px-5 thin-scrollbar",ref:tB,onScroll:sn,onClick:e=>{e.target.closest('[data-streamdown="code-block-actions"] button')&&M.toast.success("Copied to clipboard")},children:(0,t.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4 min-w-0",children:[sr&&!eR&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)("button",{onClick:()=>sa(),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Load earlier messages"})}),eR&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)(g.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}),0===eo.length&&!ex&&(u=y.find(e=>e.id===es),m=u?.created_at&&tm-new Date(u.created_at).getTime()<3e5,h=(k[es]??0)>0,m&&h&&"default"===X?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-3 animate-[fade-up_400ms_ease-out_both]",children:[(0,t.jsxs)("div",{className:"relative animate-bounce",children:[(0,t.jsx)(P.Mail,{className:"size-8 text-primary"}),(0,t.jsxs)("span",{className:"absolute -top-1 -right-1 flex size-3",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex size-full rounded-full bg-primary/60"}),(0,t.jsx)("span",{className:"relative inline-flex size-3 rounded-full bg-primary"})]})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center max-w-xs",children:"Your agent is sending you a welcome email."}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground/60 text-center max-w-xs",children:"Wait for the email task in the top-left to complete, then check your inbox. Or send a message below to start chatting."})]}):(0,t.jsx)("p",{className:"text-center text-muted-foreground py-20 text-sm",children:"Send a message to start chatting with the agent."})),tP.map(e=>{if("nap"===e.kind)return(0,t.jsx)(ew,{agentName:t6},e.data.id);if("artifact"===e.kind)return(0,t.jsx)(eN,{artifact:e.data,version:tA.get(e.data.id)??1,hasDuplicates:tz.has(e.data.filename),onClick:tD},`artifact-${e.data.id}`);let s=e.data;return(0,t.jsx)(em,{msg:s,agents:y,artifacts:eP,activeTask:ex,taskMessages:e_,connectionLost:eI,isLastMessage:eo.length>0&&eo[eo.length-1].id===s.id,stepCount:s.task_id?td[s.task_id]??0:0,targetConvId:en,workspaceId:x,conversationType:el?.type,pendingFilesByMessage:th,onArtifactClick:tD,onEmailClick:e=>{eY(e),eV(!0)},onIssueClick:e=>sN(e),onRetry:sb,mentionComponents:ev,isFlagged:ty.has(s.id),onToggleFlag:"assistant"===s.role?sw:void 0},s.id)}),ex&&ex.conversation_id===el?.id&&!["completed","failed","cancelled","superseded"].includes(ex.status)&&(0,t.jsx)(b,{task:ex,messages:e_,connectionLost:eI})]})}),(0,t.jsx)(ee.ScrollToBottomButton,{scrollRef:tB})]}),el&&(0,t.jsx)(G,{bufferedMessages:te,onDelete:e=>{tt(t=>t.filter(t=>t.id!==e)),(0,w.deleteBufferedMessage)(el.id,e,x).catch(()=>{tt(te),M.toast.error("Failed to delete follow-up")})}}),(0,t.jsx)("div",{className:"px-3 md:px-5 py-3",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl relative",children:(0,t.jsxs)("div",{className:(0,o.cn)("relative flex flex-col rounded-xl border bg-background/60 transition-colors duration-200","focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",eh&&"opacity-50",sm&&"border-ring ring-3 ring-ring/50"),onDragEnter:sg,onDragLeave:sf,onDragOver:sx,onDrop:sv,children:[sm&&(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/80 border-2 border-dashed border-ring pointer-events-none",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground font-medium",children:"Drop files here"})}),tg&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[(0,t.jsx)(D,{className:"size-3.5 shrink-0 mt-0.5 text-muted-foreground"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[tg.slice(0,120),tg.length>120?"...":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tf(null),className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,t.jsx)($.X,{className:"size-3.5"})})]}),(0,t.jsx)(O,{isOpen:t1.isOpen,relatedAgents:t1.relatedAgents,otherAgents:t1.otherAgents,selectedIndex:t1.selectedIndex,onSelect:t1.selectAgent,anchorPos:t1.anchorPos}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{"aria-hidden":!0,className:"mention-backdrop absolute inset-0 px-3.5 py-2.5 text-base chat-input-line-height whitespace-pre-wrap wrap-break-word pointer-events-none overflow-y-auto thin-scrollbar",dangerouslySetInnerHTML:{__html:ed?U(ed.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),y).replace(/<mention[^>]*>/g,'<span class="mention-highlight">').replace(/<\/mention>/g,"</span>")+(ed.endsWith("\n")?"\n":""):""}}),(0,t.jsx)("textarea",{ref:t0,value:ed,onChange:e=>{eu(e.target.value),ta(e.target.selectionStart),requestAnimationFrame(()=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)})},onKeyDown:e=>{!t1.handleMentionKeyDown(e)&&("Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),sk()))},onPaste:sy,onKeyUp:e=>ta(e.target.selectionStart),onClick:e=>ta(e.target.selectionStart),onSelect:e=>ta(e.target.selectionStart),onScroll:e=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)},placeholder:sA?"Type a follow-up...":"Type a message...",rows:1,disabled:eh,className:(0,o.cn)("relative field-sizing-content w-full resize-none bg-transparent px-3.5 py-2.5 text-base chat-input-line-height outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed","min-h-9.5 max-h-50 thin-scrollbar","caret-foreground textarea-text-hidden")})]}),e7.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 px-3.5 pb-1",children:e7.map((e,s)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:[(0,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-30",children:e.name}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:(0,Y.formatSize)(e.size)}),(0,t.jsx)("button",{type:"button",onClick:()=>sc(s),className:"ml-0.5 rounded-sm p-0.5 hover:bg-muted-foreground/20 transition-colors",children:(0,t.jsx)($.X,{className:"size-3"})})]},`${e.name}-${s}`))}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 pb-2 pt-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[!en&&(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:e=>(0,t.jsx)("span",{...e,className:(0,o.cn)("inline-flex",e.className),children:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:sI,disabled:sS||!el||!sM||sA,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200",children:sS?(0,t.jsx)(g.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(E,{className:"size-3.5"})})})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:sA?"Wait for the task to finish":sM?"Take a nap":`${t6} is well-rested and ready to go`})]}),(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsxs)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{eH("agent"),eB(!0)},className:"relative rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:[(0,t.jsx)(R,{className:"size-3.5"}),tI.length>0&&(0,t.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex size-3.5 items-center justify-center rounded-full bg-primary text-[9px] font-medium text-primary-foreground",children:tI.length})]}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Artifacts"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("input",{ref:tG,type:"file",multiple:!0,className:"hidden",onChange:so}),(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:()=>tG.current?.click(),disabled:eh,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:(0,t.jsx)(B.Paperclip,{className:"size-3.5"})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Attach files"})]}),tT&&(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:tM,disabled:eh,className:(0,o.cn)("rounded-lg transition-colors duration-200",tS?"text-red-500 hover:text-red-600 bg-red-500/10":"text-muted-foreground/60 hover:text-foreground")}),children:(0,t.jsx)(L,{className:(0,o.cn)("size-3.5",tS&&"animate-pulse")})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:tS?"Stop recording":"Voice input"})]}),!sA||ed.trim()||eh?(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:sk,disabled:!ed.trim()||eh,className:(0,o.cn)("rounded-lg transition-opacity duration-200",!ed.trim()&&"opacity-40")}),children:eh?(0,t.jsx)(g.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(z.ArrowUp,{className:"size-3.5"})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Send"})]}):(0,t.jsxs)(A.Tooltip,{children:[(0,t.jsx)(A.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:sj,disabled:eg,className:"rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-colors duration-200"}),children:eg?(0,t.jsx)(g.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(q.Square,{className:"size-3.5 fill-current"})}),(0,t.jsx)(A.TooltipContent,{side:"top",children:"Stop task"})]})]})]})]})})}),(0,t.jsx)(Y.ArtifactSheet,{open:eL,onOpenChange:e=>{eB(e),e||setTimeout(()=>{e$(null),eH(null)},300)},artifacts:tE,workspaceId:x,initialArtifact:eq,versionMap:tR,duplicateFilenames:tF}),(0,t.jsx)(J,{open:eO,onOpenChange:e=>{eV(e),e||setTimeout(()=>eY(null),300)},emailId:eU,workspaceId:x}),(0,t.jsx)(Z.IssueSheet,{open:eX,onOpenChange:e=>{eK(e),e||setTimeout(()=>{eZ(null),eG(null),e4(null)},300)},agents:y,issue:eQ?.issue??null,detail:eQ?{messages:eQ.messages,comments:eQ.comments,artifacts:eQ.artifacts,traceId:eQ.issue.trace_id}:null,detailLoading:e0,activeTask:e3,traceTasks:e2,slug:v,workspaceId:x,width:e6,onWidthChange:e8,onUpdate:async(e,t)=>{try{let s=await (0,w.updateIssue)(x,e,t);eG(a=>a&&a.issue.id===e?{...a,issue:{...a.issue,...t,updated_at:s.updated_at}}:a)}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to update issue")}},onStatusChange:async(e,t)=>{try{await (0,w.updateIssue)(x,e,{status:t}),eG(s=>s&&s.issue.id===e?{...s,issue:{...s.issue,status:t}}:s)}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to update status")}},onCommented:()=>{eJ&&sN(eJ)},onArtifactClick:tL})]}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Failed to load conversation"})}}]);