thursday-agent 0.17.2 → 0.18.0

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 (362) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +6 -0
  6. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +1 -1
  15. package/.next/server/app/_not-found.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/.next/server/app/api/artifact/route.js +7 -7
  20. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  21. package/.next/server/app/api/bot/memory/files/route.js +4 -4
  22. package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
  23. package/.next/server/app/api/bot/memory/route.js +1 -1
  24. package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
  25. package/.next/server/app/api/bot/route.js +1 -1
  26. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  27. package/.next/server/app/api/bot/thread/[id]/route.js +1 -1
  28. package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
  29. package/.next/server/app/api/bot/thread/file/route/app-paths-manifest.json +3 -0
  30. package/.next/server/app/api/bot/thread/file/route/build-manifest.json +12 -0
  31. package/.next/server/app/api/bot/thread/file/route/server-reference-manifest.json +4 -0
  32. package/.next/server/app/api/bot/thread/file/route.js +29 -0
  33. package/.next/server/app/api/bot/thread/file/route.js.map +5 -0
  34. package/.next/server/app/api/bot/thread/file/route.js.nft.json +1 -0
  35. package/.next/server/app/api/bot/thread/file/route_client-reference-manifest.js +3 -0
  36. package/.next/server/app/api/bot/thread/route.js +1 -1
  37. package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
  38. package/.next/server/app/api/config/route.js +1 -1
  39. package/.next/server/app/api/config/route.js.nft.json +1 -1
  40. package/.next/server/app/api/events/route.js +2 -2
  41. package/.next/server/app/api/events/route.js.nft.json +1 -1
  42. package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
  43. package/.next/server/app/api/file/[...path]/route.js +4 -4
  44. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  45. package/.next/server/app/api/llm-model/automatic/route.js +1 -1
  46. package/.next/server/app/api/llm-model/automatic/route.js.nft.json +1 -1
  47. package/.next/server/app/api/llm-model/catalog/route.js +1 -1
  48. package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
  49. package/.next/server/app/api/llm-model/credits/route.js +1 -1
  50. package/.next/server/app/api/llm-model/credits/route.js.nft.json +1 -1
  51. package/.next/server/app/api/llm-model/route.js +1 -1
  52. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  53. package/.next/server/app/api/llm-model/subscription/route.js +1 -1
  54. package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
  55. package/.next/server/app/api/mcp/[name]/route.js +1 -1
  56. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  57. package/.next/server/app/api/mcp/oauth/callback/route.js +2 -2
  58. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  59. package/.next/server/app/api/mcp/route.js +1 -1
  60. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  61. package/.next/server/app/api/mcp/tools/route.js +1 -1
  62. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  63. package/.next/server/app/api/memory/edit/route.js +1 -1
  64. package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
  65. package/.next/server/app/api/memory/route.js +1 -1
  66. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  67. package/.next/server/app/api/reach/route.js +1 -1
  68. package/.next/server/app/api/reach/route.js.nft.json +1 -1
  69. package/.next/server/app/api/routine/route.js +1 -1
  70. package/.next/server/app/api/routine/route.js.nft.json +1 -1
  71. package/.next/server/app/api/signins/route.js +1 -1
  72. package/.next/server/app/api/signins/route.js.nft.json +1 -1
  73. package/.next/server/app/api/skills/[source]/[name]/route.js +1 -1
  74. package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
  75. package/.next/server/app/api/skills/route.js +1 -1
  76. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  77. package/.next/server/app/api/thursday/call/end/route.js +1 -1
  78. package/.next/server/app/api/thursday/call/end/route.js.nft.json +1 -1
  79. package/.next/server/app/api/thursday/call/route.js +1 -1
  80. package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
  81. package/.next/server/app/api/thursday/settings/route.js +1 -1
  82. package/.next/server/app/api/thursday/settings/route.js.nft.json +1 -1
  83. package/.next/server/app/api/thursday/text/route.js +1 -1
  84. package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
  85. package/.next/server/app/api/thursday/tool-call/route.js +1 -1
  86. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  87. package/.next/server/app/api/workspace/files/route.js +1 -1
  88. package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
  89. package/.next/server/app/api/workspace/route.js +1 -1
  90. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  91. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +94 -6
  92. package/.next/server/app/artifact/[...path]/page.js +9 -6
  93. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  94. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  95. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  96. package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  97. package/.next/server/app/page/server-reference-manifest.json +161 -128
  98. package/.next/server/app/page.js +9 -9
  99. package/.next/server/app/page.js.nft.json +1 -1
  100. package/.next/server/app/page_client-reference-manifest.js +1 -1
  101. package/.next/server/app-paths-manifest.json +1 -0
  102. package/.next/server/chunks/{[externals]__12stas-._.js → [externals]__178rv3v._.js} +1 -1
  103. package/.next/server/chunks/[root-of-the-server]__00qyw01._.js +1 -1
  104. package/.next/server/chunks/[root-of-the-server]__02ra64t._.js +5 -0
  105. package/.next/server/chunks/[root-of-the-server]__03xamry._.js +1 -1
  106. package/.next/server/chunks/[root-of-the-server]__04hhvpu._.js +7 -0
  107. package/.next/server/chunks/[root-of-the-server]__05dp5tr._.js +1 -1
  108. package/.next/server/chunks/[root-of-the-server]__0bqveex._.js +1 -1
  109. package/.next/server/chunks/{[root-of-the-server]__1_h4hf9._.js → [root-of-the-server]__0brmiv2._.js} +4 -4
  110. package/.next/server/chunks/[root-of-the-server]__0gvdr2h._.js +5 -0
  111. package/.next/server/chunks/[root-of-the-server]__0h656y-._.js +1 -1
  112. package/.next/server/chunks/[root-of-the-server]__0lvjz0b._.js +5 -0
  113. package/.next/server/chunks/[root-of-the-server]__0mgyt8p._.js +1 -1
  114. package/.next/server/chunks/[root-of-the-server]__0mrk2it._.js +1 -1
  115. package/.next/server/chunks/[root-of-the-server]__0my9geo._.js +3 -0
  116. package/.next/server/chunks/[root-of-the-server]__0qdoc_9._.js +5 -0
  117. package/.next/server/chunks/[root-of-the-server]__0sm5xvm._.js +1 -1
  118. package/.next/server/chunks/[root-of-the-server]__0v_kuor._.js +5 -0
  119. package/.next/server/chunks/[root-of-the-server]__1-rmal0._.js +1 -1
  120. package/.next/server/chunks/[root-of-the-server]__13hng6h._.js +1 -1
  121. package/.next/server/chunks/[root-of-the-server]__1_04mcf._.js +2 -2
  122. package/.next/server/chunks/[root-of-the-server]__1ceammd._.js +1 -1
  123. package/.next/server/chunks/[root-of-the-server]__1dth047._.js +5 -0
  124. package/.next/server/chunks/[root-of-the-server]__1etbk64._.js +3 -0
  125. package/.next/server/chunks/[root-of-the-server]__1izes4_._.js +7 -0
  126. package/.next/server/chunks/[root-of-the-server]__1ksm9m-._.js +12 -0
  127. package/.next/server/chunks/[root-of-the-server]__1m_dmf6._.js +5 -0
  128. package/.next/server/chunks/[root-of-the-server]__1mys2c3._.js +5 -0
  129. package/.next/server/chunks/[root-of-the-server]__1ndi14y._.js +1 -1
  130. package/.next/server/chunks/[root-of-the-server]__1p0njle._.js +5 -0
  131. package/.next/server/chunks/[root-of-the-server]__1p47fbb._.js +2 -2
  132. package/.next/server/chunks/[root-of-the-server]__1ygplx1._.js +1 -1
  133. package/.next/server/chunks/[root-of-the-server]__1zn039k._.js +1 -1
  134. package/.next/server/chunks/_01c32w9._.js +1 -1
  135. package/.next/server/chunks/_02bov6_._.js +1 -1
  136. package/.next/server/chunks/_06hnfi8._.js +2 -2
  137. package/.next/server/chunks/_06u9yo-._.js +1 -1
  138. package/.next/server/chunks/_07nxi75._.js +42 -41
  139. package/.next/server/chunks/_08354bn._.js +12 -11
  140. package/.next/server/chunks/{_08btiir._.js → _08_-9ay._.js} +3 -3
  141. package/.next/server/chunks/_08s4vft._.js +1 -1
  142. package/.next/server/chunks/_0bgjf07._.js +5 -0
  143. package/.next/server/chunks/_0fb6dvr._.js +1 -1
  144. package/.next/server/chunks/_0hgvg55._.js +1 -1
  145. package/.next/server/chunks/_0iw19ig._.js +1 -1
  146. package/.next/server/chunks/_0poi1t2._.js +1 -1
  147. package/.next/server/chunks/_0srlnvd._.js +6 -6
  148. package/.next/server/chunks/_0t_7gji._.js +1 -1
  149. package/.next/server/chunks/_0uzj57i._.js +1 -1
  150. package/.next/server/chunks/_0wyh244._.js +112 -0
  151. package/.next/server/chunks/_0xygcxs._.js +42 -41
  152. package/.next/server/chunks/_1-sk_q4._.js +1 -1
  153. package/.next/server/chunks/_108gsm8._.js +2 -2
  154. package/.next/server/chunks/_136j09a._.js +5 -5
  155. package/.next/server/chunks/_15negpy._.js +2 -2
  156. package/.next/server/chunks/_1d7og_q._.js +1 -1
  157. package/.next/server/chunks/_1dxq827._.js +2 -2
  158. package/.next/server/chunks/_1e54wxa._.js +1 -1
  159. package/.next/server/chunks/_1gn2r2q._.js +6 -6
  160. package/.next/server/chunks/_1i3uucm._.js +1 -1
  161. package/.next/server/chunks/_1jvy78-._.js +5 -0
  162. package/.next/server/chunks/_1q6e56i._.js +6 -6
  163. package/.next/server/chunks/_1qgix-j._.js +1 -1
  164. package/.next/server/chunks/_1wwl_7o._.js +1 -1
  165. package/.next/server/chunks/_1y8w80a._.js +5 -5
  166. package/.next/server/chunks/_1yx285_._.js +3 -0
  167. package/.next/server/chunks/_20qn224._.js +3 -0
  168. package/.next/server/chunks/_211dn2c._.js +1 -1
  169. package/.next/server/chunks/_next-internal_server_app_api_bot_thread_file_route_actions_0q3be0o.js +3 -0
  170. package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
  171. package/.next/server/chunks/features_bot_08z387_._.js +3 -3
  172. package/.next/server/chunks/features_workspace_workspace_ts_13h82gv._.js +3 -3
  173. package/.next/server/chunks/features_workspace_workspace_ts_1iyjroj._.js +3 -3
  174. package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_04oxl25._.js → node_modules_consola_dist_chunks_prompt_mjs_0yd5xa0._.js} +1 -1
  175. package/.next/server/chunks/ssr/[root-of-the-server]__04upd5v._.js +1 -1
  176. package/.next/server/chunks/ssr/[root-of-the-server]__06knwl5._.js +3 -0
  177. package/.next/server/chunks/ssr/[root-of-the-server]__07ehpky._.js +3 -0
  178. package/.next/server/chunks/ssr/[root-of-the-server]__0h6jo0s._.js +3 -0
  179. package/.next/server/chunks/ssr/[root-of-the-server]__128hnrd._.js +3 -0
  180. package/.next/server/chunks/ssr/[root-of-the-server]__1867koj._.js +1 -1
  181. package/.next/server/chunks/ssr/[root-of-the-server]__1gzje-h._.js +3 -0
  182. package/.next/server/chunks/ssr/{[root-of-the-server]__1d7usu0._.js → [root-of-the-server]__1qn0axo._.js} +2 -2
  183. package/.next/server/chunks/ssr/[root-of-the-server]__1r7tj27._.js +3 -0
  184. package/.next/server/chunks/ssr/[root-of-the-server]__1tb5vve._.js +46 -0
  185. package/.next/server/chunks/ssr/{features_bot_1knyan7._.js → _07nmtxo._.js} +2 -2
  186. package/.next/server/chunks/ssr/{_10-_awu._.js → _0f9hx5p._.js} +2 -2
  187. package/.next/server/chunks/ssr/_0fo4552._.js +10 -9
  188. package/.next/server/chunks/ssr/{_123y-ah._.js → _0is8m6y._.js} +2 -2
  189. package/.next/server/chunks/ssr/{_17a4qyk._.js → _0ixe3g3._.js} +3 -3
  190. package/.next/server/chunks/ssr/_0j9vh-8._.js +3 -0
  191. package/.next/server/chunks/ssr/_0l7rjg5._.js +1 -1
  192. package/.next/server/chunks/ssr/{lib_logger_ts_0-olsze._.js → _0mfgsk-._.js} +4 -2
  193. package/.next/server/chunks/ssr/_0mpn6q0._.js +5 -0
  194. package/.next/server/chunks/ssr/{_0e2fnvg._.js → _0osvxkt._.js} +2 -2
  195. package/.next/server/chunks/ssr/_0p6w0ef._.js +3 -0
  196. package/.next/server/chunks/ssr/_0pbav_w._.js +3 -0
  197. package/.next/server/chunks/ssr/{_1aqjk-1._.js → _0wuvkqk._.js} +2 -2
  198. package/.next/server/chunks/ssr/_0x8ophf._.js +1 -1
  199. package/.next/server/chunks/ssr/_0x9f717._.js +60 -0
  200. package/.next/server/chunks/ssr/_1-41lck._.js +1 -1
  201. package/.next/server/chunks/ssr/_10jtmhl._.js +3 -0
  202. package/.next/server/chunks/ssr/{_0xfafez._.js → _12jv_41._.js} +2 -2
  203. package/.next/server/chunks/ssr/{_163dr78._.js → _165wnr4._.js} +2 -2
  204. package/.next/server/chunks/ssr/_16_7zeo._.js +3 -0
  205. package/.next/server/chunks/ssr/{_14oirtb._.js → _1_ogjze._.js} +2 -2
  206. package/.next/server/chunks/ssr/_1bfrntd._.js +6 -0
  207. package/.next/server/chunks/ssr/_1i2swyr._.js +3 -0
  208. package/.next/server/chunks/ssr/{_10_ph1t._.js → _1jd8rjm._.js} +2 -2
  209. package/.next/server/chunks/ssr/_1mdjoak._.js +162 -0
  210. package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
  211. package/.next/server/chunks/ssr/{_1dfv66y._.js → _1oafxdu._.js} +2 -2
  212. package/.next/server/chunks/ssr/_1omom9y._.js +3 -0
  213. package/.next/server/chunks/ssr/_1pgxh81._.js +271 -0
  214. package/.next/server/chunks/ssr/{_0vo_oym._.js → _1r4mc3i._.js} +2 -2
  215. package/.next/server/chunks/ssr/_1soynbw._.js +6 -0
  216. package/.next/server/chunks/ssr/{_01al00i._.js → _1tx-2k7._.js} +2 -2
  217. package/.next/server/chunks/ssr/_1w899wx._.js +3 -0
  218. package/.next/server/chunks/ssr/_1xwtbdz._.js +3 -0
  219. package/.next/server/chunks/ssr/features_0796o8r._.js +1 -1
  220. package/.next/server/chunks/ssr/features_bot_0tb4ui-._.js +2 -2
  221. package/.next/server/chunks/ssr/features_bot_18gqkr_._.js +3 -0
  222. package/.next/server/chunks/ssr/{features_config_09n-q9q._.js → features_config_1ond01n._.js} +3 -3
  223. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
  224. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  225. package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
  226. package/.next/server/chunks/ssr/features_workspace_workspace_ts_1wc7_u_._.js +4 -4
  227. package/.next/server/chunks/ssr/{node_modules_0msrhxf._.js → node_modules_004qt-z._.js} +1 -1
  228. package/.next/server/chunks/ssr/{node_modules_0q-klni._.js → node_modules_06m6e97._.js} +1 -1
  229. package/.next/server/chunks/ssr/{node_modules_13g-d25._.js → node_modules_09dy7tk._.js} +1 -1
  230. package/.next/server/chunks/ssr/{node_modules_0gd9hbz._.js → node_modules_0_hy3i2._.js} +1 -1
  231. package/.next/server/chunks/ssr/{node_modules_1gq3ght._.js → node_modules_0f485jl._.js} +1 -1
  232. package/.next/server/chunks/ssr/{node_modules_096up6a._.js → node_modules_0gbx70b._.js} +1 -1
  233. package/.next/server/chunks/ssr/{node_modules_13bqv6i._.js → node_modules_0i_v0-m._.js} +1 -1
  234. package/.next/server/chunks/ssr/{node_modules_04x5wyv._.js → node_modules_0lrn9ci._.js} +1 -1
  235. package/.next/server/chunks/ssr/{node_modules_0d6j33x._.js → node_modules_0lxwg2v._.js} +1 -1
  236. package/.next/server/chunks/ssr/{node_modules_113l3e5._.js → node_modules_0n2-p5q._.js} +1 -1
  237. package/.next/server/chunks/ssr/node_modules_0nj36zf._.js +3 -0
  238. package/.next/server/chunks/ssr/{node_modules_0cjnmzp._.js → node_modules_0ppirau._.js} +1 -1
  239. package/.next/server/chunks/ssr/{node_modules_0m73b88._.js → node_modules_0pw13ww._.js} +1 -1
  240. package/.next/server/chunks/ssr/node_modules_0qd7p5f._.js +3 -0
  241. package/.next/server/chunks/ssr/{node_modules_0nmkv-v._.js → node_modules_0upwx50._.js} +1 -1
  242. package/.next/server/chunks/ssr/{node_modules_0__0tvm._.js → node_modules_0v__o4h._.js} +1 -1
  243. package/.next/server/chunks/ssr/{node_modules_1k5i-_9._.js → node_modules_1-4q6is._.js} +1 -1
  244. package/.next/server/chunks/ssr/{node_modules_156kv_t._.js → node_modules_10mb0cv._.js} +1 -1
  245. package/.next/server/chunks/ssr/{node_modules_10_fv2a._.js → node_modules_16z7p8b._.js} +1 -1
  246. package/.next/server/chunks/ssr/{node_modules_1lmyts8._.js → node_modules_17o218r._.js} +1 -1
  247. package/.next/server/chunks/ssr/{node_modules_0k8-y89._.js → node_modules_1gpapfv._.js} +1 -1
  248. package/.next/server/chunks/ssr/{node_modules_1_8-jcj._.js → node_modules_1hdaxu9._.js} +1 -1
  249. package/.next/server/chunks/ssr/{node_modules_1ri_eip._.js → node_modules_1hjvwkh._.js} +1 -1
  250. package/.next/server/chunks/ssr/{node_modules_0nw5jz7._.js → node_modules_1j886a5._.js} +1 -1
  251. package/.next/server/chunks/ssr/{node_modules_1xb-ndg._.js → node_modules_1srjf5c._.js} +1 -1
  252. package/.next/server/chunks/ssr/{node_modules_1p_6sq7._.js → node_modules_1tus4vi._.js} +1 -1
  253. package/.next/server/chunks/ssr/{node_modules_021lid9._.js → node_modules_1tv_7lk._.js} +1 -1
  254. package/.next/server/chunks/ssr/{node_modules_1qstb1x._.js → node_modules_20448xv._.js} +1 -1
  255. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0amkw0b._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0lg9pkl._.js} +1 -1
  256. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0zq3l45._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1xgbf5j._.js} +1 -1
  257. package/.next/server/middleware-build-manifest.js +3 -3
  258. package/.next/server/middleware.js +1 -1
  259. package/.next/server/pages/404.html +1 -1
  260. package/.next/server/pages/500.html +1 -1
  261. package/.next/server/server-reference-manifest.js +1 -1
  262. package/.next/server/server-reference-manifest.json +205 -132
  263. package/.next/static/chunks/{166smhw8v-s3j.js → 05uvci-bk-vgp.js} +1 -1
  264. package/.next/static/chunks/09y_43y1cy5jw.js +1 -0
  265. package/.next/static/chunks/0_s4z70lx1tgs.js +1 -0
  266. package/.next/static/chunks/0oqviw3f55nfp.js +58 -0
  267. package/.next/static/chunks/0q9b2n6l4flqb.js +1 -0
  268. package/.next/static/chunks/0ruf3dqs--3ve.js +1 -0
  269. package/.next/static/chunks/0vggwjufw2-6r.js +1 -0
  270. package/.next/static/chunks/{3sla-dm1puqd1.js → 0x4m9nj2fazl2.js} +1 -1
  271. package/.next/static/chunks/{3t2c76awm9k_p.js → 1-1yfu34-3p2p.js} +1 -1
  272. package/.next/static/chunks/10oyyypxn_cpx.js +1 -0
  273. package/.next/static/chunks/{1cglo3a2mbeou.js → 17dx6w478vnb0.js} +1 -1
  274. package/.next/static/chunks/184-r80rv0xay.css +1 -0
  275. package/.next/static/chunks/1_hgdoungpm0o.js +1 -0
  276. package/.next/static/chunks/{0obogzscwwekj.js → 1dpg1u4a16ujt.js} +1 -1
  277. package/.next/static/chunks/{2qgkbdshzpq1c.js → 1h_6rh86q3i4p.js} +1 -1
  278. package/.next/static/chunks/{3b96xy59nl_gd.js → 1pe7i5yu779ta.js} +1 -1
  279. package/.next/static/chunks/{2zbl41hed17g3.js → 240nfv2dtidhc.js} +1 -1
  280. package/.next/static/chunks/{0uxq_vs6uxi-b.js → 27l8qwnk1j66z.js} +1 -1
  281. package/.next/static/chunks/2gxfy__ef51n9.js +3 -0
  282. package/.next/static/chunks/2kjwmo70judc2.js +15 -0
  283. package/.next/static/chunks/{3gsxnqqqphh-1.js → 2lzg4zedtmyic.js} +1 -1
  284. package/.next/static/chunks/2ug8q1x9e-_j6.js +1 -0
  285. package/.next/static/chunks/{01l7kw74vfp32.js → 2uk8rdtr-pk58.js} +1 -1
  286. package/.next/static/chunks/337g9g_ux2gj-.js +1 -0
  287. package/.next/static/chunks/{0o7o0eb7ihxi6.js → 396enq-m0sss5.js} +1 -1
  288. package/.next/static/chunks/{0p2f6uv4xytfm.js → 3r7u1y9xjoh-v.js} +1 -1
  289. package/.next/static/chunks/{3jtcieuk1l6tw.js → 3vg1-oc-zgw_7.js} +1 -1
  290. package/.next/static/chunks/40re_3ukjulg9.js +1 -0
  291. package/.next/static/chunks/41ztsnjn4qrn-.js +1 -0
  292. package/README.md +5 -5
  293. package/bin/autostart.mjs +32 -2
  294. package/bin/lock.mjs +85 -4
  295. package/bin/thursday.mjs +42 -15
  296. package/bin/tools.mjs +18 -1
  297. package/database/migrations/20260926021847_thread_cache_tokens/migration.sql +2 -0
  298. package/database/migrations/20260926021847_thread_cache_tokens/snapshot.json +1949 -0
  299. package/guide/bots.md +173 -317
  300. package/guide/calls.md +98 -146
  301. package/guide/index.md +2 -2
  302. package/guide/memory.md +14 -18
  303. package/guide/phone.md +86 -133
  304. package/guide/setup.md +127 -172
  305. package/guide/trouble.md +42 -65
  306. package/package.json +1 -1
  307. package/seed-skills/concierge/travel/scripts/itinerary.mjs +1 -1
  308. package/skills/artifact/runtime/shell/shell.js +32 -3
  309. package/.next/server/chunks/[root-of-the-server]__01ypm_z._.js +0 -3
  310. package/.next/server/chunks/[root-of-the-server]__021dkui._.js +0 -3
  311. package/.next/server/chunks/[root-of-the-server]__09gdscj._.js +0 -7
  312. package/.next/server/chunks/[root-of-the-server]__0ljizgj._.js +0 -5
  313. package/.next/server/chunks/[root-of-the-server]__0nmust6._.js +0 -5
  314. package/.next/server/chunks/[root-of-the-server]__0svzjwa._.js +0 -7
  315. package/.next/server/chunks/[root-of-the-server]__1c2kwku._.js +0 -12
  316. package/.next/server/chunks/[root-of-the-server]__1t02-1p._.js +0 -3
  317. package/.next/server/chunks/[root-of-the-server]__1t0jj1j._.js +0 -5
  318. package/.next/server/chunks/[root-of-the-server]__1vlxv19._.js +0 -5
  319. package/.next/server/chunks/_0j0-gq6._.js +0 -5
  320. package/.next/server/chunks/_0p6v1fr._.js +0 -5
  321. package/.next/server/chunks/_1ic3bew._.js +0 -5
  322. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0g87zst._.js +0 -3
  323. package/.next/server/chunks/ssr/[root-of-the-server]__0-af_o7._.js +0 -3
  324. package/.next/server/chunks/ssr/[root-of-the-server]__09f39cp._.js +0 -4
  325. package/.next/server/chunks/ssr/[root-of-the-server]__0ouu4qp._.js +0 -3
  326. package/.next/server/chunks/ssr/[root-of-the-server]__0q9g9ea._.js +0 -5
  327. package/.next/server/chunks/ssr/[root-of-the-server]__17h1ggo._.js +0 -46
  328. package/.next/server/chunks/ssr/[root-of-the-server]__1jyeu61._.js +0 -5
  329. package/.next/server/chunks/ssr/_0afrpci._.js +0 -3
  330. package/.next/server/chunks/ssr/_0bgse1c._.js +0 -162
  331. package/.next/server/chunks/ssr/_0qsmpcu._.js +0 -3
  332. package/.next/server/chunks/ssr/_0z38nha._.js +0 -3
  333. package/.next/server/chunks/ssr/_116lfdc._.js +0 -3
  334. package/.next/server/chunks/ssr/_14dfh7a._.js +0 -4
  335. package/.next/server/chunks/ssr/_17qtuv7._.js +0 -3
  336. package/.next/server/chunks/ssr/_1_5xof_._.js +0 -3
  337. package/.next/server/chunks/ssr/_1alxym6._.js +0 -3
  338. package/.next/server/chunks/ssr/_1ou5sj0._.js +0 -3
  339. package/.next/server/chunks/ssr/_1tmw842._.js +0 -5
  340. package/.next/server/chunks/ssr/_1uij_rj._.js +0 -3
  341. package/.next/server/chunks/ssr/_1w9w1ok._.js +0 -3
  342. package/.next/server/chunks/ssr/_20gq_24._.js +0 -3
  343. package/.next/server/chunks/ssr/features_bot_0ouemw8._.js +0 -3
  344. package/.next/server/chunks/ssr/node_modules_@base-ui_react_1j9i1ho._.js +0 -3
  345. package/.next/static/chunks/0a5_-jqhaktjj.js +0 -1
  346. package/.next/static/chunks/0npvak0wpgagb.js +0 -1
  347. package/.next/static/chunks/19l81deo_pyoc.js +0 -1
  348. package/.next/static/chunks/1bnhw-5fj7aiz.js +0 -1
  349. package/.next/static/chunks/1in6nxpu33iab.js +0 -1
  350. package/.next/static/chunks/1u7kg91f9qy3g.js +0 -1
  351. package/.next/static/chunks/1xv4g10m-cl1s.js +0 -1
  352. package/.next/static/chunks/2ajs12-fcdwzm.js +0 -1
  353. package/.next/static/chunks/2i7qtmxc1kuqg.js +0 -1
  354. package/.next/static/chunks/2kz1f6r59nky0.js +0 -3
  355. package/.next/static/chunks/31kn4_h2rvf6k.css +0 -1
  356. package/.next/static/chunks/35jj-5u4te56r.js +0 -1
  357. package/.next/static/chunks/37ixzapa06xlo.js +0 -1
  358. package/.next/static/chunks/3k1d8y03t5nax.js +0 -58
  359. package/.next/static/chunks/3yiqr95d7ybeq.js +0 -15
  360. /package/.next/static/{8I2hKtciyA9LXvd8txuOz → -IBxB5oqr6e3RuOCCmYtL}/_buildManifest.js +0 -0
  361. /package/.next/static/{8I2hKtciyA9LXvd8txuOz → -IBxB5oqr6e3RuOCCmYtL}/_clientMiddlewareManifest.js +0 -0
  362. /package/.next/static/{8I2hKtciyA9LXvd8txuOz → -IBxB5oqr6e3RuOCCmYtL}/_ssgManifest.js +0 -0
@@ -1,15 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,302707,e=>{"use strict";var t=e.i(843476),n=e.i(689664),r=e.i(24071),s=e.i(867927),a=e.i(638292),l=e.i(456420);let i={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]};i.node;let o=(0,l.default)(i),u={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};u.node;let c=(0,l.default)(u);var d=e.i(618566),h=e.i(271645),p=e.i(798120),m=e.i(167881),f=e.i(660302),g=e.i(319036),x=e.i(728231),y=e.i(146538),w=e.i(265402),b=e.i(609507),k=e.i(463625),v=e.i(635963),j=e.i(6799),S=e.i(393080),N=e.i(283653),T=e.i(647163),E=e.i(595078),A=e.i(805995),M=e.i(616816),_=e.i(876268),C=e.i(287746),L=e.i(992112),R=e.i(218080);let I={hello:"Hi, I'm Thursday. One thing first: this is a recording. You'll hear my real voice on our first call.",key:"My real voice comes from OpenAI, and it needs a key — think of it as a password. Paste one in, and I wake up. Don't have one yet? No problem, skip ahead. I'll ask again later.",awake:"There we go — I'm awake. That key is all a call needs. The rest is quick: your microphone, who does the work for you, and what they think with.",mic:"Now let me hear you. Your browser will ask before it turns the microphone on. Say yes, then say anything — and watch the line under me move. It's only on during a call, unless you ask for more.",heard:"I hear you — that line is your voice. If you'd rather wake me by saying my name instead of tapping, switch that on here and give it a try.",bots:"Big jobs go to my helper bots, so you and I can keep talking while they work. They work right here on your computer, with a browser and your files. Signing in and paying always stay with you.",models:"Every bot runs on an A.I. model that you pick. Start small: a small one is fast and cheap, and you can move any bot up later. Your OpenAI key already covers it. A GPT subscription, or a Vercel key, opens up a lot more.",style:"One more, and it's the fun one: who I am to you. There are four of me, and the only difference is how I talk. Pick whoever sounds like someone you'd call — you can change your mind anytime.",call:"That's everything. Call me, tell me what to call you, and ask for one thing — anything you'd ask someone sitting next to you. From here on, it's my real voice. I'll show you the rest as we go.",asleep:"I still don't have a voice of my own, so no calls yet — but everything else works. Have a look around. When you have a key, tap me, and I'll take it from there.",asleepBare:"I still don't have a voice of my own, and my bots have nothing to think with yet — so no calls and no jobs for now. Have a look around. Add a key, or sign in with ChatGPT, and I'll take it from there."},O=Array(R.SPECTRUM_BANDS).fill(0),D="thursday.intro.muted";var P=e.i(567334),F=e.i(387758),z=e.i(877267),$=e.i(377090),B=e.i(732061),q=e.i(298293),U=e.i(922521);let K=[{radii:5,px:64,density:1.05},{radii:3.2,px:40,density:1.1},{radii:2.1,px:26,density:1.2},{radii:1.45,px:16,density:1.3}],H=[.2,1.6,2.5,3.1,3.55],W=["/sounds/opening-rise.ogg","/sounds/opening-step-1.ogg","/sounds/opening-step-2.ogg","/sounds/opening-step-3.ogg","/sounds/opening-land.ogg"],G=[2,3,1],Y=[[],["🤍"],["🤍","☁️"],["☁️","🤍"],["☁️","🕊️"],["🕊️","☁️"],["🕊️","🦢"],["🦢","🕊️","☁️"],["🦢","🤍"],["🤍","⚪","🦢"],["🤍","⚪"],["⚪","🤍"]],V=[[],["🤍","⚪"],["🤍","⚪","🦢"],["🦢","🤍","🕊️"],["🦢","🕊️","☁️"],["🕊️","🦢","☁️"],["🕊️","☁️"],["☁️","🕊️"],["☁️","🖤"],["⚫","🖤","☁️"],["🖤","⚫"],["🖤","⚫"]],J=K[0].px;function X({anchor:e,onArrive:n,onHello:r,onDone:s}){let a=(0,h.useRef)(null),l=(0,U.useIsDark)(),i=(0,h.useRef)({dark:l,onArrive:n,onHello:r,onDone:s});return i.current={dark:l,onArrive:n,onHello:r,onDone:s},(0,h.useEffect)(()=>{let t=a.current,n=e.current,r={arrive:!1,hello:!1,done:!1},s=e=>{r[e]||(r[e]=!0,"arrive"===e?i.current.onArrive():"hello"===e?i.current.onHello():i.current.onDone())};if(!t||!n||window.matchMedia("(prefers-reduced-motion: reduce)").matches){s("arrive"),s("hello"),s("done");return}let l=t.getContext("2d");if(!l){s("arrive"),s("hello"),s("done");return}let o=H.map((e,t)=>e+(t>0?(Math.random()-.5)*.12:0)),u=!function(){try{return"1"===window.localStorage.getItem(D)}catch{return!1}}()?W.map(e=>{let t=new Audio(e);return t.preload="auto",t}):[],c=0,d=50*Math.random(),h=Math.min(2,window.devicePixelRatio||1),p="letters"===(0,z.faceGlyphs)(),m=p?null:function(e,t){let n=Math.round(J*t),r=Math.ceil(1.3*n),s=document.createElement("canvas");s.width=12*r,s.height=r*Math.ceil(e.length/12);let a=s.getContext("2d");if(!a)return null;a.textAlign="center",a.textBaseline="middle",a.font=(0,F.GLYPH_FONT)(n);let l=new Map;return e.forEach((e,t)=>{l.set(e,t),a.fillText(e,t%12*r+r/2,Math.floor(t/12)*r+r/2)}),{canvas:s,at:l,slot:r,scale:r/t/J}}([...new Set([...P.EMOJI_POOL,...Y.flat(),...V.flat(),...G.flatMap(e=>q.WASH_SETS[e-1].emoji)])],h);if(!p&&!m){s("arrive"),s("hello"),s("done");return}let f=P.LEVELS-1,g=[],x=null,y=()=>{let e=window.innerWidth,r=window.innerHeight;t.width=Math.round(e*h),t.height=Math.round(r*h),l.setTransform(h,0,0,h,0,0),l.textAlign="center",l.textBaseline="middle",x=null;let s=n.getBoundingClientRect(),a=Number.parseFloat(getComputedStyle(n).getPropertyValue("--face-bleed"))/100||0,i=s.width*(1+2*a),o=s.left+s.width/2,u=s.top+s.height/2,c=F.DESIGN/i;g=K.map((t,n)=>{let s=.95*t.px/t.density,a=1.25*t.px/t.density,l=.12*n,i=Math.cos(l),h=Math.sin(l),p=70+26*n,m=[];for(let l=0;l*a<r;l++)for(let r=0;r*s<e;r++){let e=r*s+s/2,f=l*a+a/2,g=(e-o)*c,x=(f-u)*c,y=(g*i-x*h)/F.REST_R/t.radii,w=(g*h+x*i)/F.REST_R/t.radii,b=Math.hypot(y,w);if(b>2.6)continue;let k=Math.floor((Math.atan2(w,y)+Math.PI)/(2*Math.PI)*p),v=(0,P.hash)(k+13*n,3.1+d),j=(0,P.hash)(1.3*k,11.1+d);m.push({x:e,y:f,r:b,dx:y*F.REST_R,dy:w*F.REST_R,drift:.02+.14*v*v,go:.15+.9*(0,P.hash)(k,7.7+n),carry:j<.13?G[Math.floor(23*j)%G.length]:0,nx:g*(8/t.px)*.05,ny:x*(8/t.px)*.05,seed:(0,P.hash)(r+101*n,l),grain:(0,P.hash)(5.7*r+19+n,2.3*l+53),gap:.05+.3*(0,P.hash)(7.3*r+11,3.1*l+5+n)})}let g=m.length;return{px:t.px,cells:m,fast:new Float32Array(g),slow:new Float32Array(g),wasLevel:new Int8Array(g).fill(-9),turn:new Int32Array(g).fill(-9),pick:new Int32Array(g),pool:new Int8Array(g),poolFor:new Float32Array(g),byLevel:Array.from({length:f+1},()=>new Int32Array(g)),inLevel:new Int32Array(f+1),glyph:Array(g),over:!1}})};y(),window.addEventListener("resize",y);let w=(0,B.createSmoke)(),b=90*Math.random(),k={dx:0,dy:0,dist:0},v=performance.now(),j=v,S=0,N=0,T=e=>{let n=(e-v)/1e3,r=Math.min(.05,Math.max(0,(e-j)/1e3));j=e,S+=r;let{dark:a}=i.current,d=a?Y:V;p&&x!==a&&(x=a,l.fillStyle=getComputedStyle(t).color),(0,B.stepSmoke)(w,S,r,0,0,-1);let y=(0,$.windAt)(S,b),E=Math.exp(-r/F.TRAIL_FAST),A=Math.exp(-r/1.4);l.clearRect(0,0,t.width/h,t.height/h);let M=0;for(g.forEach((e,t)=>{let s=o[t],a=o[t+1];if(e.over||n<s)return;let i=n-a,u=i<=0?(0,P.smoothstep)(0,1,(n-s)/(0===t?1.2:.35)):1,c=i>0?(0,P.smoothstep)(0,.3,i):0,h=i>.05,g=S+31*t;e.inLevel.fill(0);let x=0,b=e.cells;for(let t=0;t<b.length;t++){let n=b[t],s=0,a=0;if(i<=0)u>0&&n.r<2.6&&(k.dx=n.dx,k.dy=n.dy,k.dist=n.r*F.REST_R,s=(0,B.restValue)(k,g,0,F.REST_R,u,w,y));else{let e=n.r-n.drift*i**.8,t=(1+(1.5*((0,P.smoothstep)(.6,.88,Math.abs(e))*(1-(0,P.smoothstep)(1.2,1.55,Math.abs(e))))-1)*c)*(1-(0,P.smoothstep)(n.go,n.go+.4,i));if(t>0){let r=n.r>0?e/n.r:0;k.dx=n.dx*r,k.dy=n.dy*r,k.dist=Math.abs(e)*F.REST_R,(s=(0,B.restValue)(k,g,0,F.REST_R,1,w,y)*t)>.04&&c>.5&&(a=n.carry)}}(s*=(.66+.72*n.grain)*(.8+.4*(0,P.hash)(Math.floor(n.nx+.5*S),Math.floor(n.ny-.3*S))))>.3&&(0,P.hash)(31.7*Math.floor(1.6*S),613*n.seed)>.992&&(s=Math.max(s,.9)),a?(e.pool[t]=a,e.poolFor[t]=.35*(.5+n.grain)):e.poolFor[t]>0?(e.poolFor[t]-=r,e.poolFor[t]<=0&&(e.pool[t]=0)):e.pool[t]=0;let l=e.fast[t]=s>e.fast[t]*E?s:e.fast[t]*E,o=e.slow[t]=s>e.slow[t]*A?s:e.slow[t]*A;if((s=l>.55*o?l:.55*o)<n.gap+.05*Math.sin(.28*S+6.283*n.seed))continue;let m=(s>1?1:s)*f|0;if(0===m)continue;x++;let v=S*(p?F.CHURN_LETTERS:F.CHURN_EMOJI)+7*n.seed|0;(v!==e.turn[t]||m-e.wasLevel[t]>=2||e.wasLevel[t]-m>=2)&&(e.turn[t]=v,e.wasLevel[t]=m,e.pick[t]=(997*n.seed|0)+v+m);let j=e.pick[t],N=e.pool[t]?q.WASH_SETS[e.pool[t]-1]:null,T=p?N?.letters??P.RAMP[m]:N?.emoji??(h?d[m]:P.EMOJI_POOL);e.glyph[t]=T[j%T.length],e.byLevel[m][e.inLevel[m]++]=t}M+=x,i>1.45&&0===x&&(e.over=!0),m||(l.font=(0,F.GLYPH_FONT)(e.px));for(let t=1;t<=f;t++){let n=e.inLevel[t];if(0===n)continue;let r=e.byLevel[t];if(!m){l.globalAlpha=P.ALPHA_TOP*(t/f);for(let t=0;t<n;t++){let n=b[r[t]];l.fillText(e.glyph[r[t]],n.x,n.y)}continue}l.globalAlpha=(0,P.emojiAlpha)(t,f);let s=e.px*m.scale*(.5+.5*(0,P.emojiWeight)(t,f));for(let t=0;t<n;t++){let n=b[r[t]],a=m.at.get(e.glyph[r[t]])??0;l.drawImage(m.canvas,a%12*m.slot,Math.floor(a/12)*m.slot,m.slot,m.slot,n.x-s/2,n.y-s/2,s,s)}}}),l.globalAlpha=1;c<u.length&&n>=o[c];c++)u[c].play().catch(()=>{});if(n>=o[4]&&s("arrive"),n>=4.7&&s("hello"),n>o[4]+1.6&&0===M){l.clearRect(0,0,t.width/h,t.height/h),s("done");return}N=requestAnimationFrame(T)};return N=requestAnimationFrame(T),()=>{if(cancelAnimationFrame(N),window.removeEventListener("resize",y),!r.done)for(let e of u)!function(e,t=.4){if(e.paused)return;let n=e.volume,r=performance.now(),s=a=>{let l=Math.min(1,(a-r)/1e3/t);e.volume=n*(1-l),l<1?requestAnimationFrame(s):e.pause()};requestAnimationFrame(s)}(e)}},[e]),(0,t.jsx)("canvas",{ref:a,"aria-hidden":!0,className:"pointer-events-none absolute inset-0 size-full text-foreground"})}var Z=e.i(745747),Q=e.i(333495),ee=e.i(435135),et=e.i(692888),en=e.i(114923),er=e.i(234916),es=e.i(67045),ea=e.i(297825),el=e.i(895499),ei=e.i(656572),eo=e.i(609856);let eu=["key","mic","bots","models","style","call"];function ec({children:e}){return(0,t.jsxs)("p",{className:"text-[17px] leading-[1.675] tracking-[0.3px]",children:[(0,t.jsx)("span",{className:"mr-4 inline-block size-2.5 rounded-full bg-foreground align-middle opacity-55"}),e]})}let ed=({children:e})=>(0,t.jsx)("p",{className:"font-mono text-[11px] leading-relaxed text-pretty text-muted-foreground/70",children:e});function eh({children:e,tail:r}){return(0,t.jsxs)("p",{className:"flex items-center gap-2.5 text-sm",children:[(0,t.jsx)("span",{className:"grid size-5 shrink-0 animate-in place-items-center rounded-full bg-primary text-primary-foreground duration-300 zoom-in-50",children:(0,t.jsx)(n.Check,{className:"size-3"})}),(0,t.jsx)("span",{className:"animate-in delay-150 duration-300 fill-mode-backwards fade-in slide-in-from-left-1",children:e}),r&&(0,t.jsx)("span",{className:"truncate font-mono text-[11px] text-muted-foreground/70",children:r})]})}function ep({keyed:e,onSaved:n}){return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh,{children:"OpenAI key saved"}),(0,t.jsx)(ed,{children:"Change it any time in Settings › API keys."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec,{children:"Paste your OpenAI API key"}),(0,t.jsx)(M.VoiceKeys,{dense:!0,plain:!0,autoFocus:!0,onSaved:n}),(0,t.jsx)(M.GetKeyLink,{}),(0,t.jsx)("ol",{className:"flex flex-col gap-1.75 text-[13px] text-muted-foreground",children:["Sign in, or make an account","Create new secret key, and copy it","Paste it here"].map((e,n)=>(0,t.jsxs)("li",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"grid size-4.5 shrink-0 place-items-center rounded font-mono text-[10px] text-foreground bg-secondary",children:n+1}),e]},e))}),(0,t.jsx)(ed,{children:"OpenAI bills it by the minute of call, separately from ChatGPT."})]})}function em({mic:e}){let r=(0,es.useThursdayStore)(e=>e.wake),s=(0,es.useThursdayStore)(e=>e.patch),[l,i]=(0,h.useState)(!1),[o,u]=(0,h.useState)(null);return((0,ei.useWakeWord)({enabled:e.on&&r.enabled&&!o,phrases:[r.phrase],onWake:()=>i(!0),onError:u}),e.on)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh,{children:"Microphone is on"}),(0,t.jsxs)("label",{className:"mt-1.5 flex cursor-pointer items-start gap-3",children:[(0,t.jsxs)("span",{className:"flex flex-1 flex-col gap-0.75",children:[(0,t.jsx)("span",{className:"text-sm",children:"Wake her by voice"}),(0,t.jsxs)(ed,{children:["Say ",(0,t.jsxs)("span",{className:"text-foreground",children:['"',r.phrase,'"']})," and she picks up. The microphone stays open for as long as this tab is, and the browser does the listening: Chrome sends what it hears to Google."]}),r.enabled&&!o&&(l?(0,t.jsxs)("span",{className:"mt-1.5 flex items-center gap-2 text-[13px]",children:[(0,t.jsx)("span",{className:"grid size-5 shrink-0 animate-in place-items-center rounded-full bg-foreground text-background duration-300 zoom-in-50",children:(0,t.jsx)(n.Check,{className:"size-3"})}),"Heard you. That is how you call her."]}):(0,t.jsxs)("span",{className:"mt-1.5 flex items-center gap-2 text-[13px]",children:[(0,t.jsx)(a.Mic,{className:"size-4 shrink-0"}),(0,t.jsx)(f.ShinyText,{text:`Try it now: say "${r.phrase}"`,speed:2.2})]})),o&&(0,t.jsx)(ed,{children:o})]}),(0,t.jsx)(g.Switch,{checked:r.enabled,onCheckedChange:e=>s({wake:{...r,enabled:e}})})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec,{children:"Turn on the microphone"}),(0,t.jsxs)(m.Button,{onClick:()=>void e.turnOn(),className:"h-11 self-start rounded-full px-5 pl-4 text-sm",children:[(0,t.jsx)(a.Mic,{className:""}),"Turn it on"]}),e.failed?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:(0,T.cn)("text-[13px] leading-normal",T.WAITING_INK),children:e.failed.what}),(0,t.jsx)(ed,{children:e.failed.next})]}):(0,t.jsx)(ed,{children:"Used on a call, and nowhere else unless you switch on waking her by voice."})]})}function ef({picked:e,face:n,onToggle:r}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec,{children:"Pick who comes along"}),(0,t.jsx)("div",{className:"flex flex-col",children:k.BOT_SEEDS.map(s=>{let a=!!e[s.name];return(0,t.jsxs)("label",{className:"flex h-9.5 cursor-pointer items-center gap-2.75",children:[(0,t.jsx)(v.BotMark,{size:24,seed:s.name,...n(s),notify:!1,className:(0,T.cn)("shrink-0 transition-opacity",!a&&"opacity-40")}),(0,t.jsx)("span",{className:(0,T.cn)("w-17.5 shrink-0 text-[13.5px] font-medium",!a&&"text-muted-foreground"),children:s.name}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:s.hint}),(0,t.jsx)(g.Switch,{checked:a,onCheckedChange:()=>r(s.name)})]},s.name)})}),(0,t.jsx)(ed,{children:"Every one comes along. Switch off any you will not use: Settings › Bots has them all, and you can make your own."})]})}function eg(){let{settings:e,patch:n}=(0,ea.useLiveSettings)(),r=Math.max(0,b.PERSONAS.findIndex(t=>t.id===e?.persona)),s=b.PERSONAS[r],a=e=>n({persona:b.PERSONAS[(r+e+b.PERSONAS.length)%b.PERSONAS.length].id});return(0,t.jsxs)("div",{className:"flex w-full max-w-md flex-col gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-2xl font-semibold",children:s.label}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s.about})]}),(0,t.jsx)("p",{className:"min-h-20 text-left text-sm leading-relaxed text-foreground/80",children:s.lines}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)(m.Button,{variant:"outline",size:"sm",onClick:()=>a(-1),children:"Someone else"}),(0,t.jsx)(m.Button,{variant:"outline",size:"sm",onClick:()=>a(1),children:"Next"})]}),(0,t.jsx)("div",{className:"flex justify-center gap-1.5",children:b.PERSONAS.map((e,n)=>(0,t.jsx)("span",{className:(0,T.cn)("h-0.5 w-5 rounded-full",n===r?"bg-foreground":"bg-border")},e.id))})]})}function ex(){let{data:e}=(0,N.useServerRoute)(p.queryKey.config),n=(0,w.parseTextModel)(e?.find(e=>e.key===L.DEFAULT_MODEL_KEY)?.value),r=e?.find(e=>e.key===L.DEFAULT_EFFORT_KEY)?.value,[s,a]=(0,h.useState)(null),[l]=(0,eo.useServerAction)(C.setConfigAction,{onOk:()=>(0,N.revalidate)(p.queryKey.config)}),[i]=(0,eo.useServerAction)(_.removeConfigAction,{onOk:()=>(0,N.revalidate)(p.queryKey.config)});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec,{children:"Pick what they think with"}),(0,t.jsx)(A.AccountsSetup,{withoutVoice:!0}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"shrink-0 text-[13px] text-muted-foreground",children:"Bots think with"}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(y.ModelPicker,{provider:s??n?.provider??null,model:s?"":n?.model??"",unset:"Automatic",onChange:e=>{if(!e.model.trim())return a(e.provider);a(null),l(L.DEFAULT_MODEL_KEY,`${e.provider}/${e.model.trim()}`)},onUnset:()=>{a(null),n&&(i(L.DEFAULT_MODEL_KEY),r&&i(L.DEFAULT_EFFORT_KEY))}})})]})]})}function ey({mic:e,bots:r}){let s=["voice",e?"microphone":null,r>0?`${r} ${1===r?"bot":"bots"}`:null].filter(e=>null!==e);return(0,t.jsx)("span",{className:"flex items-center gap-2 text-xs",children:s.map((e,r)=>(0,t.jsxs)("span",{style:{animationDelay:`${300+260*r}ms`},className:"flex animate-in items-center gap-2 duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:[r>0&&(0,t.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(n.Check,{className:"size-3.25"}),e]})]},e))})}let ew={ask:"Find me flights to Osaka in October.",onIt:`On it. ${k.ERRANDS_BOT} is looking. Keep talking, I will say when it is back.`,back:`${k.ERRANDS_BOT} is back. The Tuesday morning flight is the pick. The page is on your screen.`},eb={threadId:"demo",label:"Osaka flights, October",bot:k.ERRANDS_BOT,words:"Three fares compared. The Tuesday morning one is the pick: direct, and the cheapest by a little.",paths:[]};function ek({stage:e,icons:n}){return(0,t.jsxs)(t.Fragment,{children:["landed"===e&&(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-5 left-5 w-90 text-left",children:(0,t.jsx)(el.FinishedCard,{row:eb,bot:{icon:n[k.BOT_SEEDS.findIndex(e=>e.name===eb.bot)]},onOpen:()=>{},onClose:()=>{}})}),(0,t.jsxs)("div",{className:"absolute right-5 bottom-5 flex h-10 items-center gap-2.5 rounded-full bg-background pr-3.5 pl-2.5 ring-1 ring-border",children:[(0,t.jsx)("span",{className:"flex",children:k.BOT_SEEDS.map((r,s)=>(0,t.jsx)(v.BotMark,{size:22,seed:r.name,...n[s],state:"working"===e&&r.name===k.ERRANDS_BOT?"thinking":"idle",notify:!1,className:(0,T.cn)("shrink-0",s>0&&"-ml-1.5")},r.name))}),(0,t.jsx)("span",{className:"w-40 truncate text-left text-[13px] text-muted-foreground",children:"working"===e?`${k.ERRANDS_BOT} \xb7 reading fares`:"landed"===e?`${k.ERRANDS_BOT} finished`:"Need a hand?"})]})]})}e.s(["Intro",0,function({ready:e,firstRun:n,forced:a,icons:l}){let i=n||a,u=(0,d.useRouter)(),[f,g]=(0,h.useState)("hello"),[y,w]=(0,h.useState)(!1),[b,v]=(0,h.useState)(!1),[A,M]=(0,h.useState)(e),[_,C]=(0,h.useState)(null),[L,P]=(0,h.useState)(()=>Object.fromEntries(k.BOT_SEEDS.map(e=>[e.name,!0]))),[F,z]=(0,h.useState)("echoes"),$="hello"===F||"over"===F,B=(0,h.useRef)(null),q=function(e){let[t,n]=(0,h.useState)("off"),[r,s]=(0,h.useState)(!1),[a,l]=(0,h.useState)(""),i=(0,h.useRef)(null),o=(0,h.useRef)(null),u=(0,h.useCallback)(()=>{for(let e of o.current?.getTracks()??[])e.stop();o.current=null},[]);return(0,h.useEffect)(()=>{e||(u(),n(e=>"on"===e?"off":e))},[e,u]),(0,h.useEffect)(()=>u,[u]),{on:"on"===t,failed:"object"==typeof t?t:null,allowed:r,label:a,turnOn:(0,h.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});o.current=e,i.current??=(0,R.createAudioTap)(),i.current.open(),i.current.hear?.(e),l(e.getAudioTracks()[0]?.label??""),n("on"),s(!0)}catch(e){n(function(e){let t=e instanceof DOMException?e.name:"";if("NotAllowedError"===t)return{what:"This page is not allowed the microphone yet.",next:"The icon at the left of the address bar opens the site's settings: set Microphone to Allow and come back. Or just go on."};if("NotFoundError"===t)return{what:"No microphone was found.",next:"Plug one in or switch it on, then turn it on here again. Or just go on."};if("NotReadableError"===t)return{what:"The microphone would not start.",next:"Another app may be using it: close that app and turn it on here again. Or just go on."};let n=e instanceof Error&&e.message||t||String(e);return{what:"The microphone did not open.",next:`The browser said "${n}". Or just go on.`}}(e))}},[]),spectrum:(0,h.useCallback)(()=>i.current?.readMic()??[],[])}}("mic"===f&&!y),U=function(e){let[t,n]=(0,h.useState)(0);(0,h.useEffect)(()=>{if(!e)return;let t=performance.now(),r=setInterval(()=>n((performance.now()-t)%16e3),120);return()=>clearInterval(r)},[e]);let r=(e,t,n)=>({id:e,role:t,text:n}),s=[];t>900&&s.push(r("ask","user",ew.ask)),t>4700&&s.push(r("onIt","assistant",ew.onIt)),t>11500&&s.push(r("back","assistant",ew.back));let a=t>4700&&t<8300||t>11500&&t<14500;return{turns:s,status:a?"speaking":t>900&&t<4700?"listening":"idle",stage:t>9600?"landed":t>5400?"working":t>900?"asked":"rest",saying:a,voice:er.silentVoice}}("hello"===f&&i&&!y&&$),K=i&&!y;(0,h.useEffect)(()=>(Z.callSignal.hold(K),()=>Z.callSignal.hold(!1)),[K]),(0,h.useEffect)(()=>{if(!y)return;let e=setTimeout(()=>v(!0),700);return()=>clearTimeout(e)},[y]);let H=eu.indexOf(f),{data:W}=(0,N.useServerRoute)(p.queryKey.automaticModel),G=!!W?.ref,Y=(0,h.useMemo)(()=>{var e,t,n,r;let s,a;return e=f,t=A,n=q.on,r=G,s=(e,t)=>({id:e,role:"assistant",text:t}),a=[],"hello"===e||(a.push(s("key","I am Thursday. My voice comes from OpenAI, so the first thing I need is a key: paste one and I wake up. No key yet? Go on without it, and I will ask again when you call.")),t&&a.push(s("awake","There, I am awake, and that key is everything a call needs. From here on it is quick: your microphone, who works for you, and what they think with.")),"key"===e||(a.push(s("mic","Now let me hear you. Your browser asks before it opens the microphone: say yes, then say anything at all and watch the line under me move. It is only open on a call, unless you ask for more.")),n&&a.push(s("heard","I hear you: that line is your voice. If you would rather wake me by saying my name than by tapping me, switch it on here and try it once.")),"mic"===e||(a.push(s("bots","Long work goes to bots, so we can keep talking while they are at it. They work on this computer, with a shell, a browser and your files, and signing in or paying always stays with you.")),"bots"===e||(a.push(s("models","Bots think with a model you choose. Start small: a small model is quick and costs little, and any bot can move up later. An OpenAI key already covers it; a GPT subscription or one Vercel key opens far more.")),"models"===e||(a.push(s("style","One more, and it is the fun one: who I am to you. Four of them, and the only difference is how I talk — pick whoever sounds like someone you would call, and change your mind whenever you like.")),"style"===e||a.push(t?s("call","That is everything I need. Call me, tell me what to call you, and ask for one thing, anything you would ask a person at the next desk. I will show you the rest as we go."):r?s("asleep","I still have no voice of my own, so there is no call yet, but everything else works. Look around; tap me whenever you have a key and I will take it from there."):s("asleepBare","I still have no voice of my own, and my bots have nothing to think with yet, so there is no call and no job for now. Look around; add a key or sign in with ChatGPT whenever you like, and I will take it from there."))))))),a},[f,A,q.on,G]),V="hello"===f?U.turns:Y,J=(0,ee.useTurnFocus)(V,K),es=function(e){let t=(0,h.useRef)(null),n=(0,h.useRef)(new Set),r=(0,h.useRef)([]),s=(0,h.useRef)(!1),[a,l]=(0,h.useState)(!1),[i,o]=(0,h.useState)(!1),u=(0,h.useRef)(!1);(0,h.useEffect)(()=>{try{let e="1"===window.localStorage.getItem(D);u.current=e,o(e)}catch{}},[]);let c=(0,h.useCallback)(()=>{r.current=[],t.current?.audio.pause()},[]),d=(0,h.useCallback)(()=>{let e=r.current.shift();if(!e||!t.current)return;let{audio:n,clip:s}=t.current;s.resume(),n.src=`/voices/intro/${e}-${function(e){let t=0x811c9dc5;for(let n of`marin|${e}`)t^=n.codePointAt(0)??0,t=Math.imul(t,0x1000193);return(t>>>0).toString(16).padStart(8,"0")}(I[e])}.ogg`,n.play().catch(()=>{})},[]),p=(0,h.useCallback)((...e)=>{let a=e.filter(e=>!n.current.has(e));if(!u.current&&a.length){if(!t.current){let e=new Audio,n=e=>()=>{s.current=e,l(e)};for(let t of(e.addEventListener("playing",n(!0)),["pause","ended","error"]))e.addEventListener(t,n(!1));e.addEventListener("ended",d),e.addEventListener("error",d),t.current={audio:e,clip:(0,R.createClipTap)(e)}}for(let e of a)n.current.add(e);r.current=a,d()}},[d]);(0,h.useEffect)(()=>{e&&t.current&&p(e)},[e,p]),(0,h.useEffect)(()=>()=>{t.current?.audio.pause(),t.current?.clip.close(),t.current=null},[]);let m=(0,h.useCallback)(()=>{let t=!u.current;u.current=t,o(t);try{window.localStorage.setItem(D,t?"1":"0")}catch{}if(t)return c();e&&(n.current.delete(e),p(e))},[c,e,p]);return{say:p,hush:c,speaking:a,muted:i,toggle:m,spectrum:(0,h.useCallback)(()=>t.current&&s.current?t.current.clip.read():O,[])}}(y?null:Y.at(-1)?.id??null);if(b||!i)return null;let ea=e=>l[k.BOT_SEEDS.indexOf(e)],el=e=>{let t;es.hush(),w(!0),(t=k.BOT_SEEDS.filter(e=>L[e.name]).map(e=>({name:e.name,icon:ea(e)}))??k.BOT_SEEDS.map(e=>({name:e.name}))).length&&(0,E.createSeedBotsAction)(t).then(S.unwrapResult).then(()=>(0,N.revalidate)(p.queryKey.bot)).catch(e=>j.toast.add({type:"warning",title:"Could not set up the bots",description:(0,T.errorToString)(e)})),e&&Z.callSignal.place(),u.replace("/"),u.refresh()},ei="hello"===f?U.status:es.speaking?"speaking":"mic"===f&&q.on?"listening":"idle",eo="call"===f;return(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Getting started",className:(0,T.cn)("fixed inset-0 z-40 bg-background transition-opacity duration-700",y&&"pointer-events-none opacity-0"),children:["over"!==F&&(0,t.jsx)(X,{anchor:B,onArrive:()=>z("her"),onHello:()=>z("hello"),onDone:()=>z("over")}),$&&(0,t.jsx)(x.TooltipProvider,{children:(0,t.jsxs)(x.Tooltip,{children:[(0,t.jsx)(x.TooltipTrigger,{render:(0,t.jsx)(m.Button,{size:"icon",variant:"ghost",onClick:es.toggle,"aria-label":es.muted?"Let her speak":"Mute her","aria-pressed":es.muted,className:"absolute top-5 right-5 z-10 text-muted-foreground hover:text-foreground"}),children:es.muted?(0,t.jsx)(c,{}):(0,t.jsx)(o,{})}),(0,t.jsx)(x.TooltipContent,{side:"bottom",children:es.muted?"Let her speak":"Mute her voice"})]})}),(0,t.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-5 pt-[7vh]",children:[(0,t.jsxs)("div",{ref:B,className:"relative w-[min(20rem,52vw,37.5vh)] [--face-bleed:19.5%]",children:[(0,t.jsx)("button",{type:"button",disabled:!eo||!A,onClick:()=>el(!0),"aria-label":eo&&A?"Call Thursday":void 0,className:(0,T.cn)("block w-full rounded-full outline-none transition-all duration-700 ease-out focus-visible:ring-3 focus-visible:ring-ring/50","hello"!==f&&!A&&"opacity-35"),children:"echoes"!==F?(0,t.jsx)(Q.Face,{status:ei,failed:!1,word:_,getSpectrum:"hello"===f?U.voice:es.spectrum,waking:!0,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"}):(0,t.jsx)("div",{className:"aspect-square w-full"})}),(0,t.jsx)(ee.SideCaptions,{turns:V,pinned:J.pinned,live:"hello"===f?U.saying:es.speaking,onPick:J.pick}),"hello"!==f&&(0,t.jsxs)("div",{className:"absolute top-1/2 left-full ml-[calc(var(--face-bleed)+0.375rem)] flex w-[min(22rem,26vw)] -translate-y-1/2 animate-in flex-col gap-4 text-left fade-in slide-in-from-bottom-1 duration-300",children:["key"===f&&(0,t.jsx)(ep,{keyed:A,onSaved:()=>{M(!0),C((0,en.awake)())}}),"mic"===f&&(0,t.jsx)(em,{mic:q}),"bots"===f&&(0,t.jsx)(ef,{picked:L,face:ea,onToggle:e=>P(t=>({...t,[e]:!t[e]}))}),"models"===f&&(0,t.jsx)(ex,{}),"style"===f&&(0,t.jsx)(eg,{})]},f)]}),(0,t.jsxs)("div",{className:"flex w-full max-w-3xl flex-col items-center gap-4 px-6 text-center",children:[(0,t.jsx)("div",{className:"flex h-14 items-center gap-2 text-[13px] text-muted-foreground",children:"hello"===f?$&&(0,t.jsx)("p",{className:"max-w-130 animate-in text-[20px] leading-[1.5] text-balance text-foreground duration-700 fill-mode-backwards fade-in slide-in-from-bottom-2",children:"Just talk to her. She gets it done on this computer, and tells you when it is ready."}):"mic"===f&&q.on?(0,t.jsx)(et.Ear,{live:!0,getMicSpectrum:q.spectrum}):A?eo?(0,t.jsx)(ey,{mic:q.allowed,bots:k.BOT_SEEDS.filter(e=>L[e.name]).length}):null:"Asleep"}),"hello"!==f||$?(0,t.jsxs)(m.Button,{variant:"brand",onClick:()=>{"hello"===f?(es.say("hello",A?"awake":"key"),g("key")):eo?el(A):g(eu[H+1])},className:(0,T.cn)("h-12 px-7 pl-8 text-[15px]","hello"===f&&"animate-in delay-300 duration-700 fill-mode-backwards fade-in slide-in-from-bottom-2"),children:["hello"===f?"Start":eo?A?"Call her":"Look around":"Continue",(0,t.jsx)(s.ChevronRight,{})]}):(0,t.jsx)("div",{className:"h-12"}),(0,t.jsx)("p",{className:"h-4 font-mono text-[11px] text-muted-foreground/70",children:"hello"===f?$&&(0,t.jsx)("span",{className:"block animate-in delay-500 duration-700 fill-mode-backwards fade-in",children:"two minutes · every step can wait"}):"key"!==f||A?"mic"!==f||q.on?eo&&A?"or tap her":"":"or allow it when the first call asks":"no key is fine — it can go in from the call screen"})]})]}),"hello"===f?$&&(0,t.jsx)(ek,{stage:U.stage,icons:l}):(0,t.jsxs)("div",{className:"absolute inset-x-0 bottom-6 grid grid-cols-[1fr_auto_1fr] items-center gap-4.5 font-mono text-[11px] text-muted-foreground/70 [@media(max-height:720px)]:bottom-3",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>g(H>0?eu[H-1]:"hello"),className:"flex items-center gap-1 justify-self-end rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,t.jsx)(r.ChevronLeft,{className:"size-3"}),"Back"]}),(0,t.jsxs)("span",{className:"flex items-center gap-4.5",children:[(0,t.jsx)("span",{className:"flex items-center gap-1.75",children:eu.map((e,n)=>(0,t.jsx)("span",{className:(0,T.cn)("h-1.75 rounded-full transition-all duration-300",n===H?"w-5.5 bg-foreground":"w-1.75",n<H&&"bg-foreground/40",n>H&&"bg-border")},e))}),(0,t.jsxs)("span",{children:[H+1," of ",eu.length]})]}),eo&&!A?(0,t.jsx)("span",{}):(0,t.jsx)("button",{type:"button",onClick:()=>el(!1),className:(0,T.cn)("justify-self-start rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",eo&&"text-muted-foreground"),children:eo?"Look around first":"Skip all"})]})]})}],302707)},756958,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(511769),s=e.i(798120),a=e.i(917162),l=e.i(6799),i=e.i(393080),o=e.i(283653),u=e.i(647163),c=e.i(95187);let d=(0,c.createServerReference)("7fc83d2da596e3f013f3149b3f955003bd36429c0c",c.callServer,void 0,c.findSourceMapURL,"allowReachAction"),h=(0,c.createServerReference)("7f96f3a16118b81613f09d0c2e2e4f9f24a6c1a4fa",c.callServer,void 0,c.findSourceMapURL,"declineReachAction");var p=e.i(36174);e.s(["ReachAsk",0,function(){let{data:e}=(0,o.useServerRoute)(s.queryKey.reach);(0,r.useAppEvent)({reach:()=>void(0,o.revalidate)(s.queryKey.reach)});let c=(0,n.useRef)(null),m=e?.channels.find(e=>e.asking)??null,f=m?.asking??null,g=m?.name??null,x=f&&g?`${g}:${f.chat}:${f.code}`:null;return(0,n.useEffect)(()=>{if(c.current?.key===x||(c.current?.close.abort(),c.current=null,!x||!f||!g))return;let e=new AbortController;c.current={key:x,close:e};let n={chat:f.chat,code:f.code};a.notify.confirm({title:`Let ${f.name} reach Thursday from a phone?`,description:(0,t.jsxs)("span",{className:"line-clamp-2",children:[[p.REACH_LABEL[g],f.name,f.handle].filter(Boolean).join(" · "),f.said&&` wrote “${f.said}”`]}),body:(0,t.jsxs)("div",{className:"grid gap-4",children:[(0,t.jsxs)("div",{className:"grid place-items-center gap-1.5 rounded-lg bg-muted p-4",children:[(0,t.jsx)("span",{className:"pl-[0.32em] font-mono text-3xl font-medium tracking-[0.32em]",children:f.code}),(0,t.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:"the code their phone was sent"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Allow only if the phone in your hand shows this code. Whoever you let in can talk to Thursday from there — and through her, start work on this computer."})]}),okText:"Allow",cancelText:"Not them",cautious:!0,signal:e.signal}).then(t=>{if(!e.signal.aborted)return(t?d(g,n):h(g,n)).then(i.unwrapResult).catch(e=>l.toast.add({type:"error",title:t?`Could not let ${f.name} in`:`Could not turn ${f.name} away`,description:(0,u.errorToString)(e)}))})},[x,f,g]),null}],756958)},252284,e=>{"use strict";var t=e.i(843476),n=e.i(271645);e.s(["Boot",0,function(){let[e,r]=(0,n.useState)(!1);return((0,n.useEffect)(()=>r(!0),[]),e)?null:(0,t.jsx)("p",{"aria-hidden":!0,className:"pointer-events-none fixed inset-x-0 bottom-16 z-50 animate-stalled text-center text-[13px] text-muted-foreground opacity-0",children:"The page did not start. Reload it."})}])},692888,638292,745747,234916,895499,656572,114923,435135,e=>{"use strict";var t,n,r=e.i(843476),s=e.i(989366),a=e.i(716327),l=e.i(456420);let i={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};i.node;let o=(0,l.default)(i),u={name:"flag",size:24,node:[["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"}]]};u.node;let c=(0,l.default)(u),d={name:"mic",size:24,node:[["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"}]]};d.node;let h=(0,l.default)(d);e.s(["Mic",0,h],638292);let p={name:"mic-off",size:24,node:[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]]};p.node;let m=(0,l.default)(p),f={name:"phone-missed",size:24,node:[["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"m22 2-6 6",key:"6f0sa0"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]};f.node;let g=(0,l.default)(f),x={name:"settings-2",size:24,node:[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]};x.node;let y=(0,l.default)(x);var w=e.i(263676),b=e.i(271645),k=e.i(798120),v=e.i(167881),j=e.i(225913),S=e.i(647163);let N=(0,j.cva)("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-1.5 [&>*]:relative [&>*]:focus-visible:z-10",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function T({className:e,orientation:t="horizontal",...n}){return(0,r.jsx)("div",{"data-slot":"button-group","data-orientation":t,role:"group",className:(0,S.cn)(N({orientation:t}),e),...n})}let E=new Intl.Segmenter(void 0,{granularity:"grapheme"});function A({text:e,wraps:t=[]}){let n=(0,b.useMemo)(()=>Array.from(E.segment(e),e=>e.segment),[e]),s=(0,b.useRef)([]),a=0;for(;a<n.length&&n[a]===s.current[a];)a++;(0,b.useEffect)(()=>{s.current=n},[n]);let l=e=>(0,r.jsx)(M,{wait:25*Math.max(0,e-a),children:n[e]},`${n[e]}${e}`),i=[];for(let e=0;e<n.length;){let s=t.find(t=>t.from===e&&t.to>e);if(!s){i.push(l(e)),e+=1;continue}let a=Math.min(s.to,n.length),o=[];for(let t=e;t<a;t++)o.push(l(t));i.push((0,r.jsx)(b.Fragment,{children:s.render(o)},`wrap${e}`)),e=a}return(0,r.jsx)("span",{children:i})}function M({wait:e,children:t}){let[n]=(0,b.useState)(e);return(0,r.jsx)("span",{style:{animationDelay:`${n}ms`},className:"animate-letter motion-reduce:animate-none",children:t})}var _=e.i(660302),C=e.i(633669),L=e.i(728231),R=e.i(41533),I=e.i(149666),O=e.i(265402),D=e.i(451888),P=e.i(635963);let F={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};F.node;let z=(0,l.default)(F);var $=e.i(511769);let B={wave:740,done:740,ask:820,took:740,give:900,take:520,stop:1150,read:560},q={wave:{body:"animate-crew-hop",shape:"animate-crew-hop-shape"},took:{body:"animate-crew-hop",shape:"animate-crew-hop-shape"},done:{body:"animate-crew-hop",shape:"animate-crew-hop-shape",turn:"animate-crew-spin"},ask:{body:"animate-crew-hop",shape:"animate-crew-hop-shape",turn:"animate-crew-ask-turn"},give:{turn:"animate-crew-give"},take:{body:"animate-crew-take",shape:"animate-crew-take-shape"},stop:{body:"animate-crew-sink",shape:"animate-crew-sink-shape"},read:{body:"animate-crew-nod",shape:"animate-crew-nod-shape"}},U={key:0,body:"",shape:"animate-crew-breath",turn:"",delayMs:0};var K=e.i(399512),H=e.i(256604),W=e.i(319841),G=e.i(245629),Y=e.i(661504),V=e.i(283653),J=e.i(978411),X=e.i(351866),Z=e.i(401851),Q=e.i(677241),ee=e.i(24708),et=e.i(845110),en=e.i(980797),er=e.i(383482),es=e.i(24071),ea=e.i(931619),el=e.i(632781),ei=e.i(671428),eo=e.i(127341),eu=e.i(835878),ec=e.i(431594);function ed(){let e=(0,J.useBotThreads)(),t=(0,J.useRingingThreads)();return(0,b.useMemo)(()=>[...e].reverse().filter(e=>!t.includes(e.id)&&(0,D.needsThreadReply)(e)),[e,t])}function eh({tab:e,current:t,onTab:n,onClose:s}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-3 pr-3.5 pb-1.5 pl-2.5",children:[(0,r.jsx)(eo.Tabs,{value:e,onValueChange:e=>n(e),className:"gap-0",children:(0,r.jsxs)(eo.TabsList,{className:"gap-1 rounded-none bg-transparent p-0 group-data-horizontal/tabs:h-auto",children:[(0,r.jsxs)(eo.TabsTrigger,{value:"now",className:X.TAB,children:["Now",t>0&&(0,r.jsx)("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:t})]}),(0,r.jsx)(eo.TabsTrigger,{value:"history",className:X.TAB,children:"History"})]})}),(0,r.jsx)("span",{className:"flex-1"}),(0,r.jsx)(X.FoldButton,{onClick:s})]})}function ep({bots:e}){return(0,r.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:e?.length?"Nothing handed over yet — ask for something that takes a while.":`Thursday hands work to ${D.DEFAULT_BOT.name} until you make bots of your own in Settings › Bots.`})}function em(){return(0,r.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:"Nothing running or waiting."})}function ef({pages:e,threads:t,scroll:n,onPick:s}){let a=(0,b.useCallback)(e=>{e&&(e.scrollTop=n.current)},[n]),l=[];for(let e of t){let t=function(e){let t=(0,G.toDate)(e);return(0,en.isToday)(t)?"today":(0,er.isYesterday)(t)?"yesterday":(0,Z.format)(t,function(e,t){let[n,r]=(0,et.normalizeDates)(void 0,e,t);return n.getFullYear()===r.getFullYear()}((0,Q.constructFrom)(t,t),(0,ee.constructNow)(t))?"MMM d":"MMM d, yyyy").toLowerCase()}(e.updatedAt),n=l.at(-1);n?.day===t?n.rows.push(e):l.push({day:t,rows:[e]})}return(0,r.jsx)("div",{ref:a,onScroll:e=>{n.current=e.currentTarget.scrollTop},className:"flex max-h-[50vh] min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-1 pb-2 scrollbar-none",children:e.error?(0,r.jsx)("p",{className:"px-2.5 py-3 text-[12px] text-destructive",children:e.error.message}):e.isLoading?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"flex h-6 items-center px-2.5 pt-1",children:(0,r.jsx)(ei.Skeleton,{className:"h-2.5 w-16"})}),(0,r.jsx)(ex,{})]}):(0,r.jsxs)(r.Fragment,{children:[l.map((e,t)=>(0,r.jsxs)(b.Fragment,{children:[(0,r.jsxs)("p",{className:(0,S.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===t?"pt-1":"pt-3"),children:[e.day," · ",e.rows.length]}),e.rows.map(e=>(0,r.jsx)(eb,{thread:e,onPick:()=>s(e.id)},e.id))]},e.day)),e.hasMore?(0,r.jsx)("div",{ref:e.sentinelRef,children:(0,r.jsx)(ex,{})}):0===l.length&&(0,r.jsx)("p",{className:"px-6 pt-3 pb-4 text-center text-[12px] text-muted-foreground",children:"Nothing has ended yet."})]})})}function eg({onBack:e,onClose:t}){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[(0,r.jsx)("button",{type:"button",onClick:e,"aria-label":"Back to the list",className:"shrink-0 rounded-md p-1 text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:(0,r.jsx)(es.ChevronLeft,{className:"size-4"})}),(0,r.jsx)(ei.Skeleton,{className:"size-5.5 shrink-0 rounded-md"}),(0,r.jsx)("span",{className:"flex min-w-0 flex-1",children:(0,r.jsx)(ei.Skeleton,{className:"h-3.5 w-2/5"})}),(0,r.jsx)(X.FoldButton,{onClick:t})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 px-4 py-4",children:[(0,r.jsx)(ei.Skeleton,{className:"h-3 w-4/5"}),(0,r.jsx)(ei.Skeleton,{className:"h-3 w-3/5"}),(0,r.jsx)(ei.Skeleton,{className:"h-3 w-2/3"})]})]})}function ex(){return(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-2 py-1.5",children:[(0,r.jsx)(ei.Skeleton,{className:"size-8 shrink-0 rounded-[10px]"}),(0,r.jsxs)("span",{className:"flex h-9 min-w-0 flex-1 flex-col justify-center gap-1.5",children:[(0,r.jsx)(ei.Skeleton,{className:"h-3.5 w-2/5"}),(0,r.jsx)(ei.Skeleton,{className:"h-2.5 w-3/5"})]})]})}let ey=[{id:"needsYou",label:"needs you"},{id:"working",label:"working"}];function ew({threads:e,onPick:t}){let n=new Map;for(let t of e){let e=(0,D.standOf)(t),r=n.get(e);r?r.push(t):n.set(e,[t])}return(0,r.jsx)("div",{className:"flex max-h-[50vh] min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-1 pb-1 scrollbar-none",children:ey.map((e,s)=>{let a=n.get(e.id)??[];return a.length?(0,r.jsxs)(b.Fragment,{children:[(0,r.jsxs)("p",{className:(0,S.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===s?"pt-1":"pt-3"),children:[e.label," · ",a.length]}),a.map(e=>(0,r.jsx)(eb,{thread:e,onPick:()=>t(e.id)},e.id))]},e.id):null})})}function eb({thread:e,onPick:t,lines:n=1}){let s=(0,D.needsThreadReply)(e),a=e.lines.at(-1),l=(0,b.useMemo)(()=>(function(e){let t=e.room.questions[0];if(t)return{text:(0,S.plainText)(t.text),tone:"text-foreground"};if("waiting"===e.status&&e.ask)return{text:(0,D.isAppStop)(e.ask)?(0,S.plainText)(e.outcome??e.ask.question):e.ask.question,tone:S.WAITING_INK};let n=e.seen;if("cancelled"===e.status)return{text:"Stopped",tone:"text-muted-foreground"};if("done"===e.status)return{text:(0,S.plainText)(e.outcome??"Done"),tone:n?"text-muted-foreground":"text-foreground"};let r=(0,J.lastSaid)(e);return r?{text:"tool"===r.kind&&r.tool?r.tool.note??`${r.tool.name} \xb7 ${r.tool.input}`:r.text,tone:"text-muted-foreground"}:{text:`${e.bot.name} is taking it on…`,tone:"text-muted-foreground italic"}})(e),[e.status,e.outcome,e.seen,e.ask,e.room.questions,a?.id]),[i,o]=(0,K.useAnswerThread)(),[u,c]=(0,b.useState)(null),d=e.room.questions[0],h=d?d.options??[]:"waiting"===e.status&&(0,D.isAppStop)(e.ask)?e.ask?.options??[]:[];return(0,r.jsxs)("div",{className:"rounded-xl transition-colors hover:bg-muted/60",children:[(0,r.jsxs)("button",{type:"button",onClick:t,className:"flex w-full items-center gap-2.5 rounded-xl px-2 py-1.5 text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)("span",{className:"relative flex size-8 shrink-0 items-center justify-center overflow-visible",title:e.bot.name,children:(0,r.jsx)(P.BotMark,{size:32,seed:e.bot.name,color:e.bot.icon?.color,shape:e.bot.icon?.shape,outline:e.bot.icon?.outline,paint:e.bot.icon?.paint,state:"working"===e.status?"thinking":"idle",notify:s||(0,D.isUnread)(e),crossed:"cancelled"===e.status})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[s&&!d&&(0,D.isAppStop)(e.ask)&&(0,r.jsx)("span",{className:"block font-mono text-[10px] tracking-wide text-muted-foreground",children:"Paused"}),(0,r.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:(0,S.cn)("min-w-0 truncate text-[14px] leading-5 tracking-[-0.15px]",s?"text-foreground":"text-foreground/80",(s||(0,D.isUnread)(e))&&"font-medium"),children:e.label}),e.routineId&&(0,r.jsx)("span",{title:"Started by a routine",className:"shrink-0",children:(0,r.jsx)(ec.RoutineMark,{className:"size-3 text-muted-foreground/80"})}),(0,r.jsx)(eu.BotRoster,{bots:e.roster}),(0,r.jsx)("span",{className:"flex-1"}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-[11px] leading-4 text-muted-foreground/70 tabular-nums",children:(0,G.shortAgo)(e.updatedAt)})]}),(0,r.jsxs)("span",{className:(0,S.cn)("mt-px flex items-center gap-1.5",1===n&&"h-4"),children:["working"===e.status&&(0,r.jsx)(el.Loader2,{className:"size-3 shrink-0 animate-spin text-muted-foreground/70"}),"working"===e.status||d?(0,r.jsx)(_.ShinyText,{text:l.text,speed:d?3.4:2.2,tone:d?"reading":void 0,className:(0,S.cn)("min-w-0 flex-1 text-[12px] leading-4",1===n?"truncate":"line-clamp-2",l.tone.includes("italic")&&"italic")}):(0,r.jsx)("span",{className:(0,S.cn)("min-w-0 flex-1 text-[12px] leading-4",1===n?"truncate":"line-clamp-2",l.tone),children:l.text})]})]})]}),h.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-0.5 pr-2 pb-2 pl-12.5",children:h.map(t=>(0,r.jsxs)(v.Button,{size:"sm",variant:"secondary",loading:u===t,disabled:o,onClick:async()=>{c(t),await i(e,t,d?.bot,d?.id),c(null)},className:"h-7 gap-1.5 rounded-full px-3 text-[12px]",children:[t===D.THREAD_CONTINUE&&(0,r.jsx)(ea.ChevronsRight,{className:"size-3.5"}),t]},t))})]})}var ek=e.i(689664);let ev={name:"circle-pause",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],aliases:["pause-circle"]};ev.node;let ej=(0,l.default)(ev);var eS=e.i(51481),eN=e.i(77071),eT=e.i(825398);function eE({bot:e,icon:t,line:n,children:s}){return(0,r.jsxs)(L.Tooltip,{children:[(0,r.jsx)(L.TooltipTrigger,{render:(0,r.jsx)("span",{}),children:s}),(0,r.jsxs)(L.TooltipContent,{className:"flex items-center gap-2 py-1 pr-2.5 pl-1",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-background/15 py-0.5 pr-2 pl-1",children:[(0,r.jsx)(P.BotMark,{size:15,seed:e,color:t?.color,shape:t?.shape,outline:t?.outline,paint:t?.paint}),(0,r.jsx)("span",{className:"font-medium text-[11px]",children:e})]}),n&&(0,r.jsx)("span",{className:"text-[11.5px] opacity-80",children:n})]})]})}let eA=[[0,[21,117,208]],[.4,[90,157,222]],[.75,[179,210,239]],[1,[252,252,254]]],eM=eA[0][1],e_=[{pace:.075,wide:.75,tall:1.15,seed:3.1,gustWide:.4,gustTall:.2,sky:1},{pace:.16,wide:1.3,tall:2.2,seed:11.7,gustWide:0,gustTall:0,sky:1},{pace:.3,wide:2.4,tall:4,seed:19.3,gustWide:0,gustTall:0,sky:1},{pace:.21,wide:1.65,tall:2.9,seed:27.7,gustWide:0,gustTall:0,sky:1.3}],eC=(e,t,n)=>e<t?t:e>n?n:e,eL=e=>e*e*(3-2*e),eR=(e,t,n)=>eL(eC((n-e)/(t-e),0,1)),eI=(e,t)=>{let n=0x165667b1*e+0x27d4eb2f*t|0;return(((n=(n^n>>>13)*0x4bf19f61)^n>>>16)>>>0)/0xffffffff},eO=(e,t)=>{let n=Math.floor(e),r=Math.floor(t),s=eL(e-n),a=eL(t-r);return(eI(n,r)*(1-s)+eI(n+1,r)*s)*(1-a)+(eI(n,r+1)*(1-s)+eI(n+1,r+1)*s)*a},eD=(e,t,n)=>.74*eO(e+n,t+.7*n)+.26*eO(2.2*e+n,2.2*t+1.3*n);function eP({on:e,className:t}){let n=(0,b.useRef)(null),[s,a]=(0,b.useState)(e),[l,i]=(0,b.useState)(!1);return((0,b.useEffect)(()=>{if(e){a(!0);let e=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(e)}i(!1);let t=setTimeout(()=>a(!1),200);return()=>clearTimeout(t)},[e]),(0,b.useEffect)(()=>{let e=n.current,t=e?.getContext("2d");if(!e||!t)return;e.width=48,e.height=48;let r=t.createImageData(48,48),s=r.data,a=[0,0,0],l=900*Math.random(),i=400*Math.random(),o=e=>{let n=e+l,o=n+1.7*Math.sin(.33*n),u=(.5+.5*Math.sin(.27*n))**2*.72+(.5+.5*Math.sin(.41*n+2.1))**3*.28,c=.1*Math.sin(.19*n),d=e_.map(e=>({seed:e.seed,shift:o*e.pace,wide:e.wide*(1-e.gustWide*u),tall:e.tall*(1+e.gustTall*u),sky:i*e.sky})),h=0;for(let e=0;e<48;e+=1){let t=(e+.5)/48*2-1;for(let e=0;e<48;e+=1,h+=4){let r=(e+.5)/48*2-1,l=eO(.55*r+.03*n,.55*t+i)-.5,o=eO(.55*r+9.1+i,.55*t-.024*n)-.5,u=r+1.15*l,p=t+ +o+c,[m,f,g,x]=d.map(e=>eD((u-e.shift)*e.wide+e.sky,p*e.tall,e.seed)),y=eC((.52-m)/.34,0,1);y*=.7+.6*eC((.56-f)/.4,0,1);let w=.97-.92*(y=eC(y+(.5-g)*.42,0,1))**1.2-.1*eC((.5-g)/.6,0,1)+(x-.5)*.38,b=Math.sqrt(r*r+t*t);!function(e,t){let n=eC(e,0,1),r=1;for(;r<eA.length-1&&n>eA[r][0];)r+=1;let[s,a]=eA[r-1],[l,i]=eA[r],o=(n-s)/(l-s);t[0]=a[0]+(i[0]-a[0])*o,t[1]=a[1]+(i[1]-a[1])*o,t[2]=a[2]+(i[2]-a[2])*o}(w+=.16*eC(1-Math.hypot(r+.42,t+.48)/1.5,0,1)+eR(.84,1,b)*eC(.15+.85*(.8*t+.45*r),0,1)*.45,a);let k=eC(b,0,1)**2.4*.26;s[h]=a[0]+(eM[0]-a[0])*k,s[h+1]=a[1]+(eM[1]-a[1])*k,s[h+2]=a[2]+(eM[2]-a[2])*k,s[h+3]=255*(1-eR(.94,1,b))}}t.putImageData(r,0,0)},u=performance.now();if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void o(6);let c=0,d=0,h=e=>{c=requestAnimationFrame(h),e-d<33||(d=e,o((e-u)/1e3))};return c=requestAnimationFrame(h),()=>cancelAnimationFrame(c)},[s]),s)?(0,r.jsx)("canvas",{ref:n,"aria-hidden":!0,className:(0,S.cn)("pointer-events-none absolute inset-0 size-full transition-opacity",l?"opacity-100":"opacity-0",t),style:{transitionDuration:"200ms"}}):null}var eF=e.i(864723);let ez={done:ek.Check,cancelled:w.X,question:eS.CircleQuestionMark,stopped:ej,resumed:eT.RotateCw},e$={question:S.WAITING_INK,stopped:S.WAITING_INK},eB=e=>{let t=(0,S.plainText)(e).replace(/\s+/g," ").trim();return t.length>28?`${t.slice(0,27)}…`:t};function eq({crew:e,more:t,bubble:n,rows:s,count:a,busy:l,pending:i,playing:o,onPick:u,onOpen:c}){let d=(0,J.useWriteLineUp)(),h=s.length>0&&!d;return(0,r.jsxs)("div",{className:(0,S.cn)("pointer-events-auto w-fit max-w-full bg-background/78 ring-1 ring-border/50 backdrop-blur-md transition-shadow duration-300",h?"w-132 rounded-3xl shadow-lg shadow-black/8":"rounded-full shadow-sm shadow-black/3"),children:[(0,r.jsx)("div",{className:(0,S.cn)("grid overflow-hidden contain-inline-size transition-[grid-template-rows] duration-300 ease-out",h?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:(0,r.jsxs)("div",{className:"min-h-0 overflow-hidden",inert:!h,children:[(0,r.jsxs)("p",{className:"px-3 py-2 font-mono text-[10px] tracking-wide text-muted-foreground",children:[i," ",1===i?"needs":"need"," a reply"]}),(0,r.jsx)("div",{className:"max-h-[34vh] overflow-y-auto px-1.5 pb-2",children:(0,r.jsx)("div",{children:s.map((e,t)=>(0,r.jsx)("div",{style:{animationDelay:`${120+60*t}ms`},className:"animate-in duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:(0,r.jsx)(eb,{thread:e,onPick:()=>u(e.id)})},e.id))},String(h))}),(0,r.jsx)("span",{className:"block h-1.5"})]})}),(0,r.jsx)(eU,{crew:e,more:t,bubble:h?null:n,label:a?`Threads (${a})`:"Bots",onClick:c,playing:o,side:(0,r.jsx)(eK,{busy:l,pending:i,grown:h}),onWrite:J.writeLine.open,writing:d})]})}function eU({crew:e,more:t,bubble:n,playing:s,side:a,label:l,onClick:i,onWrite:o,writing:u}){return(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 py-1.5 pr-3 pl-1.5",children:[(0,r.jsxs)(L.Tooltip,{children:[(0,r.jsxs)(L.TooltipTrigger,{render:(0,r.jsx)("button",{type:"button",onClick:o,"aria-label":"Write to Thursday or a bot","aria-pressed":u,className:(0,S.cn)("relative grid size-7 shrink-0 place-items-center overflow-hidden rounded-full outline-none transition-[background-color,box-shadow] duration-300 focus-visible:ring-3 focus-visible:ring-ring/50",u?"shadow-[0_6px_14px_-7px_color-mix(in_oklab,var(--brand)_60%,transparent)]":"bg-muted text-foreground hover:bg-accent")}),children:[(0,r.jsx)(eP,{on:!!u}),(0,r.jsx)(eN.Plus,{className:(0,S.cn)("size-3.5 transition-opacity duration-200",u?"opacity-0":"opacity-100")})]}),(0,r.jsxs)(L.TooltipContent,{children:["Write to Thursday or a bot",(0,r.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:"/"})]})]}),(0,r.jsxs)("button",{type:"button",onClick:i,"aria-label":l,className:"flex min-w-0 flex-1 items-center gap-2 rounded-full text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)(eW,{crew:e,more:t,bubble:n,playing:s}),a]})]})}function eK(e){let t=function({busy:e,pending:t,grown:n}){return t>0?{text:1===t?"waiting on you":`${t} waiting on you`,shine:!0}:e>0?{text:"working",shine:!0,spin:!0}:n?null:{text:"Need a hand?",shine:!1}}(e);return t?(0,r.jsxs)("span",{className:"ml-auto flex h-7 min-w-0 shrink items-center gap-1.5",children:[t.shine?(0,r.jsx)(_.ShinyText,{text:t.text,speed:2.6,className:"block truncate text-[14px] leading-5 tracking-[-0.15px]"}):(0,r.jsx)("span",{className:"block animate-in truncate text-[14px] leading-5 tracking-[-0.15px] text-muted-foreground fade-in duration-300",children:t.text},t.text),t.spin&&(0,r.jsx)(el.Loader2,{className:"size-4 shrink-0 animate-spin text-muted-foreground/70"})]}):null}let eH=["alto","brio","cinder","delta"].map((e,t,n)=>({name:e,icon:{color:eF.MARK_PALETTE[Math.floor(t*eF.MARK_PALETTE.length/n.length)],shape:eF.MARK_SHAPES[t%eF.MARK_SHAPES.length]},awake:!1,waiting:!1,unread:!1,word:null,standIn:!0}));function eW({crew:e,more:t,bubble:n,playing:s}){return(0,r.jsxs)("span",{className:"flex min-w-0 shrink items-center",children:[e.map((t,a)=>{let l=t.standIn?e.every(e=>e.standIn)?"No bots yet":null:t.waiting?"Waiting on you":t.word?t.word:t.unread?"Left you a result":t.awake?"Working":"Idle",i=(0,r.jsx)("span",{className:(0,S.cn)("flex transition-transform duration-500 ease-out",t.awake&&"-translate-y-0.5 scale-110"),children:(0,r.jsx)(eG,{face:t,motion:function(e,t){if(!e)return{...U,delayMs:-370*t};let n=q[e.gesture];return{key:e.id,body:n.body??"",shape:n.shape??"animate-crew-breath",turn:n.turn??"",delayMs:"wave"===e.gesture?70*t:0}}(s.get(t.name),a)})});return(0,r.jsxs)(b.Fragment,{children:[(0,r.jsxs)("span",{className:(0,S.cn)("relative shrink-0 transition-[margin] duration-500 ease-out",a>0&&!e[a-1].word&&"-ml-2",t.standIn&&"opacity-35"),style:{zIndex:e.length-a},children:[null===l?(0,r.jsx)("span",{children:i}):(0,r.jsx)(eE,{bot:t.name,icon:t.icon,line:l,children:i}),n?.at===t.name&&(0,r.jsx)(eV,{handoff:n})]}),t.word&&(0,r.jsx)("span",{className:"mx-2.5 min-w-0 shrink truncate",children:(0,r.jsx)(_.ShinyText,{text:t.word,speed:2.6,className:"truncate text-[13px] leading-5 tracking-[-0.1px]"})})]},t.name)}),t>0&&(0,r.jsx)("span",{className:"ml-2 flex h-[18px] shrink-0 items-center rounded-full bg-brand/10 px-2 font-mono text-[10.5px] leading-none font-medium text-brand",title:`${t} more`,children:"+"})]})}function eG({face:e,motion:t}){let n=t.delayMs?{animationDelay:`${t.delayMs}ms`}:void 0;return(0,r.jsx)("span",{"data-crew-motion":!0,className:(0,S.cn)("flex",t.body),style:n,children:(0,r.jsx)("span",{"data-crew-motion":!0,className:(0,S.cn)("flex origin-bottom",t.shape),style:n,children:(0,r.jsx)("span",{"data-crew-motion":!0,className:(0,S.cn)("flex",t.turn),style:n,children:(0,r.jsx)(eY,{face:e})})})},t.key)}function eY({face:e}){return(0,r.jsx)(P.BotMark,{size:28,seed:e.name,color:e.icon?.color,shape:e.icon?.shape,outline:e.icon?.outline,paint:e.icon?.paint,notify:e.waiting||e.unread})}function eV({handoff:e}){return(0,r.jsxs)("span",{className:"pointer-events-none absolute bottom-[calc(100%+10px)] left-1/2 flex w-max -translate-x-1/2 animate-in flex-col items-center fade-in zoom-in-95 duration-200",children:[(0,r.jsx)("span",{className:"flex rounded-full bg-background py-2 pr-3.5 pl-2.5 shadow-lg shadow-black/10 ring-1 ring-border",children:(0,r.jsx)(eX,{handoff:e})}),(0,r.jsx)("span",{className:"-mt-px size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-border"}),(0,r.jsx)("span",{className:"-mt-[7.5px] size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-background"})]})}function eJ({handoff:e}){return(0,r.jsx)("span",{className:"ml-auto flex h-7 min-w-0 shrink animate-in items-center pl-4 fade-in duration-200",children:(0,r.jsx)(eX,{handoff:e})})}function eX({handoff:e}){let t=e.sign?ez[e.sign]:null,n=e.sign?e$[e.sign]:void 0;return(0,r.jsxs)("span",{className:(0,S.cn)("flex min-w-0 items-center gap-2 text-[13px] leading-[18px] tracking-[-0.1px] whitespace-nowrap",n),children:[(0,r.jsx)(eZ,{from:e.from,to:e.to}),t&&(0,r.jsx)(t,{className:(0,S.cn)("size-3.5 shrink-0",!n&&"text-muted-foreground/70")}),e.shine?(0,r.jsx)(_.ShinyText,{text:e.text,speed:2.2,className:"min-w-0 truncate"}):(0,r.jsx)("span",{className:"min-w-0 truncate",children:e.text})]})}function eZ({from:e,to:t}){let n=[e,...t];return(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:n.map((e,t)=>(0,r.jsx)("span",{className:(0,S.cn)("relative flex",t>0&&"-ml-1.25"),style:{zIndex:n.length-t},children:(0,r.jsx)(eQ,{bot:e})},e.name))})}function eQ({bot:e}){return e.name===X.THURSDAY.name?(0,r.jsx)(H.ThursdayMark,{size:18,className:"shrink-0"}):(0,r.jsx)(P.BotMark,{size:18,seed:e.name,color:e.icon?.color,shape:e.icon?.shape,outline:e.icon?.outline,paint:e.icon?.paint,notify:!1,className:"shrink-0"})}let e0=(0,b.memo)(function(){let e=(0,J.useBotThreads)(),t=ed(),{data:n}=(0,V.useServerRoute)(k.queryKey.bot),[s,a]=(0,b.useState)(!1),[l,i]=(0,b.useState)(null),o=s&&null!==l;(0,b.useEffect)(()=>(J.roomOpen.set(s?o?"thread":"list":null),()=>J.roomOpen.set(null)),[s,o]);let[u,c]=(0,b.useState)({}),[d,h]=(0,b.useState)("now"),p=(0,b.useRef)(0),m=[...e].reverse(),f=m.filter(e=>"finished"!==(0,D.standOf)(e)),g=s&&"history"===d,x=(0,Y.useServerPages)({key:(e,t)=>{if(!g)return null;if(0===e)return k.queryKey.threadHistory(null);let n=t?.at(-1);return n?k.queryKey.threadHistory((0,G.toDate)(n.updatedAt).toISOString()):null},size:R.PAGE_SIZE}),{refresh:y}=x,w=(0,b.useRef)(!1);w.current=x.items.length>0,(0,b.useEffect)(()=>{g&&w.current&&y()},[g,y]);let v=(0,b.useMemo)(()=>x.items.filter(e=>"done"===e.status||"cancelled"===e.status).map(e=>(0,J.threadFromRow)(e,n)),[x.items,n]),j=l?m.find(e=>e.id===l)??v.find(e=>e.id===l)??null:null,{data:N,isLoading:T}=(0,V.useServerRoute)(l?k.queryKey.thread(l):null),E=(0,b.useMemo)(()=>N&&N.id===l?(0,J.threadFromRow)(N,n):null,[N,l,n])??(j?.lines.length?j:null),[A,M]=function(){let[e,t]=(0,b.useState)(null),n=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]),[e,(0,b.useCallback)(e=>{t(e),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{n.current=null,t(null)},3400)},[])]}(),_=(0,b.useMemo)(()=>A??function(e,t){for(let n of e){if("working"!==n.status)continue;let e=n.room.deliveries.find(e=>!e.delivered&&n.room.participants.some(t=>t.bot===e.bot&&"running"===t.state));if(e)return{at:e.bot,from:t(e.bot),to:[],text:"Step-in · waits for its next step",shine:!0}}return null}(e,e=>({name:e,icon:n?.find(t=>t.name===e)?.icon??null})),[A,e,n]),{crew:C,more:L}=(0,b.useMemo)(()=>(function(e,t){let n=new Set(t.filter(D.isUnread).map(e=>e.bot.name)),r=function(e){let t=new Map;for(let r of e){let e=new Set(r.room.questions.map(e=>e.bot));for(let s of("waiting"!==r.status||e.size||e.add(r.bot.name),r.room.participants)){var n;if(e.has(s.bot)){t.set(s.bot,{waiting:!0,word:null});continue}if(t.get(s.bot)?.waiting||"running"!==s.state&&"queued"!==s.state)continue;let a="running"===s.state?r.lines.findLast(e=>e.bot.name===s.bot&&"user"!==e.kind&&"note"!==e.kind&&"stop"!==e.kind):null;t.set(s.bot,{waiting:!1,word:(n=a??null,n?.kind==="tool"||n?.kind==="say"?eB((0,X.stepOf)(n)):null)})}}return t}(t),s=new Map;for(let t of e??[])s.set(t.name,{name:t.name,icon:t.icon,awake:r.has(t.name),waiting:r.get(t.name)?.waiting??!1,unread:n.has(t.name),word:r.get(t.name)?.word??null});for(let[e,t]of r)s.has(e)||s.set(e,{name:e,icon:null,awake:!0,waiting:t.waiting,unread:n.has(e),word:t.word});let a=[...s.values()];if(!a.length)return{crew:eH.slice(0,3),more:0};for(let e of eH){if(a.length>=3)break;s.has(e.name)||a.push(e)}let l=e=>e.waiting?0:e.awake?1:e.unread?2:e.standIn?4:3,i=a.map((e,t)=>({face:e,at:t})).sort((e,t)=>l(e.face)-l(t.face)||e.at-t.at).map(e=>e.face);return{crew:i.slice(0,14),more:Math.max(0,i.length-14)}})(n,e),[n,e]),[I,O]=function(){let[e,t]=(0,b.useState)(new Map),n=(0,b.useRef)(new Map),r=(0,b.useRef)(0);return(0,b.useEffect)(()=>{let e=n.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),[e,(0,b.useCallback)(e=>{e.length&&t(s=>{let a=new Map(s);for(let{bot:s,gesture:l}of e){r.current+=1,a.set(s,{gesture:l,id:r.current});let e=n.current.get(s);e&&clearTimeout(e),n.current.set(s,setTimeout(()=>{n.current.delete(s),t(e=>{let t=new Map(e);return t.delete(s),t})},B[l]+1400*("wave"===l)))}return a})},[])]}(),P=(0,b.useRef)(!1);(0,b.useEffect)(()=>{!P.current&&n?.length&&(P.current=!0,O(n.map(e=>({bot:e.name,gesture:"wave"}))))},[n,O]);let F=(0,b.useRef)(null),z=(0,b.useRef)(new Map),q=(0,b.useRef)(new Set);(0,b.useEffect)(()=>{if(!J.botThreads.primed())return;let t=F.current;F.current=new Map(e.map(e=>[e.id,e.status]));let n=z.current;z.current=function(e){let t=new Map;for(let n of e)for(let e of n.room.participants)t.set(`${n.id}
2
- ${e.bot}`,e.state);return t}(e);let r=q.current;if(q.current=new Set(e.flatMap(e=>e.lines.map(e=>e.id))),!t)return;let s=null,a=[];for(let l of e){let{moments:e,gestures:i}=function(e,t,n,r,s){let a=e.bot,l=[];if(!t)return"working"===e.status?{moments:[{rank:1,at:a.name,from:X.THURSDAY,to:[a],text:`took on “${eB(e.label)}”`}],gestures:[{bot:a.name,gesture:"took"}]}:{moments:[],gestures:[]};let i=[],o=e.lines.filter(e=>!n.has(e.id)),u=new Map;for(let e of o)"user"===e.kind?(e.steppedIn?l.push({bot:e.bot.name,gesture:"read"}):l.push({bot:e.bot.name,gesture:"took"}),i.push(e.steppedIn?{rank:1,at:e.bot.name,from:e.bot,to:[],text:"Step-in · read"}:{rank:1,at:e.bot.name,from:X.THURSDAY,to:[e.bot],text:eB(e.text)})):"stop"===e.kind?(l.push({bot:e.bot.name,gesture:"stop"}),i.push({rank:3,at:e.bot.name,from:e.bot,to:[],sign:"stopped",text:(0,X.leadOf)(e.text)})):"ask"===e.kind&&e.to?.name===X.THURSDAY.name?(e.question&&l.push({bot:e.bot.name,gesture:"ask"}),i.push(e.question?{rank:4,at:e.bot.name,from:e.bot,to:[],sign:"question",text:`asks you \xb7 ${eB(e.text)}`}:{rank:2,at:e.bot.name,from:e.bot,to:[X.THURSDAY],text:eB(e.text)})):"ask"===e.kind&&e.to&&u.set(e.bot.name,[...u.get(e.bot.name)??[],e]);for(let[e,t]of u){let n=new Map;for(let e of t)e.to&&n.set(e.to.name,e.to);for(let t of(l.push({bot:e,gesture:"give"}),n.values()))l.push({bot:t.name,gesture:"take"});i.push({rank:2,at:e,from:t[0].bot,to:[...n.values()],text:1===t.length?eB(t[0].text):`sent ${t.length} parts out`})}for(let t of e.roster){let n=`${e.id}
3
- ${t.name}`;t.name===a.name||"running"!==r.get(n)||"done"!==s.get(n)||o.some(e=>e.bot.name===t.name&&("ask"===e.kind||"say"===e.kind))||(l.push({bot:t.name,gesture:"done"}),i.push({rank:1,at:t.name,from:t,to:[],sign:"done",text:"finished its part"}))}if(t===e.status)return{moments:i,gestures:l};let c=eB(e.label);return"cancelled"===e.status?(l.push({bot:a.name,gesture:"stop"}),i.push({rank:3,at:a.name,from:a,to:[],sign:"cancelled",text:`stopped \xb7 ${c}`})):"done"===e.status?l.push({bot:a.name,gesture:"done"}):"working"===e.status?o.some(e=>"user"===e.kind)||(l.push({bot:a.name,gesture:"took"}),i.push({rank:1,at:a.name,from:a,to:[],sign:"resumed",text:"picked it back up"})):(0,D.isAppStop)(e.ask)&&!i.some(e=>"question"===e.sign||"stopped"===e.sign)&&(l.push({bot:a.name,gesture:"stop"}),i.push({rank:3,at:a.name,from:a,to:[],sign:"stopped",text:"paused"})),{moments:i,gestures:l}}(l,t.get(l.id),r,n,z.current);for(let t of(a.push(...i),e))(!s||t.rank>=s.rank)&&(s=t)}s&&M(s),O(a)},[e,M,O]),(0,J.useSeenOnDetail)(s?E:null),(0,$.useAppEvent)({showThread:e=>{i(e.threadId),a(!0)}}),(0,b.useEffect)(()=>J.roomOpens.subscribe(e=>{i(e),h("now"),a(!0)}),[]);let U=e.filter(e=>"working"===e.status).length,H=m.filter(D.needsThreadReply).length,Z=(0,b.useMemo)(()=>C.map(e=>({...e,word:null})),[C]),Q=()=>{a(!1),i(null),h("now"),p.current=0},ee=(0,J.useCallWaits)();(0,W.useEscape)(s,()=>o?i(null):Q());let et=(0,b.useRef)(Q);et.current=Q,(0,b.useEffect)(()=>J.writeLine.subscribe(()=>et.current()),[]);let en=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!o)return;let e=e=>{if("/"!==e.key||e.metaKey||e.ctrlKey||e.altKey||!(0,W.windowKey)(e))return;let t=en.current?.querySelector("textarea:not(:disabled)");t&&(e.preventDefault(),t.focus())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o]),(0,r.jsx)("div",{className:(0,S.cn)("pointer-events-none flex min-h-0 items-end justify-end",s?"col-span-3 row-start-1 self-stretch":"col-span-3 row-start-2"),children:s?(0,r.jsxs)("div",{ref:en,"data-room":!0,className:"pointer-events-auto flex max-h-full w-160 max-w-full animate-in flex-col overflow-hidden rounded-3xl bg-background/75 shadow-2xl shadow-black/6 ring-1 ring-border/50 backdrop-blur-xl fade-in slide-in-from-bottom-1 duration-200",children:[ee&&(0,r.jsx)(e1,{onBack:Q}),!E&&l&&T?(0,r.jsx)(eg,{onBack:()=>i(null),onClose:Q}):E?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(X.ThreadHeader,{thread:E,onBack:()=>i(null),onClose:Q}),(0,r.jsx)(X.Conversation,{thread:E,tab:u[E.id]??null,onTab:e=>c(t=>({...t,[E.id]:e})),className:"min-h-0 flex-1"}),(0,r.jsx)(K.ThreadReply,{thread:{id:E.id,label:E.label,bot:E.bot.name,ask:E.ask,room:E.room},status:"working"===E.status?"running":E.status,faces:E.roster,to:u[E.id]??E.bot.name,className:"mx-3 mb-2 shrink-0"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eh,{tab:d,current:f.length,onTab:h,onClose:Q}),"history"===d?(0,r.jsx)(ef,{pages:x,threads:v,scroll:p,onPick:i}):f.length?(0,r.jsx)(ew,{threads:f,onPick:i}):m.length?(0,r.jsx)(em,{}):(0,r.jsx)(ep,{bots:n}),(0,r.jsx)(eU,{crew:Z,more:L,bubble:null,playing:I,label:"Fold the room away",onClick:Q,onWrite:J.writeLine.open,side:_?(0,r.jsx)(eJ,{handoff:_}):(0,r.jsx)(eK,{busy:U,pending:H,grown:!0})})]})]}):(0,r.jsx)(eq,{crew:C,more:L,bubble:_,playing:I,rows:t,count:e.length,busy:U,pending:H,onPick:e=>{i(e),a(!0)},onOpen:()=>a(!0)})})});function e1({onBack:e}){return(0,r.jsxs)("button",{type:"button",onClick:e,className:"group/waits flex shrink-0 items-center gap-2.5 bg-brand/8 py-2.5 pr-3 pl-4 text-left outline-none transition-colors hover:bg-brand/12 focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-brand/14 dark:hover:bg-brand/20",children:[(0,r.jsx)(H.ThursdayMark,{size:22,className:"shrink-0"}),(0,r.jsxs)("span",{className:"min-w-0 flex-1 text-[13px] leading-5",children:[(0,r.jsx)("span",{className:"font-medium",children:"Thursday is still on the line"}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" ","— in writing. She is here when this closes."]})]}),(0,r.jsxs)("span",{className:"flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 font-medium text-[12.5px] text-brand ring-1 ring-brand/40 transition-colors group-hover/waits:bg-brand/10",children:["Back to her",(0,r.jsx)(z,{className:"size-3.5"})]})]})}var e2=e.i(222055),e5=e.i(616816),e3=e.i(992112);let e4={name:"app-window-mac",size:24,node:[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]};e4.node;let e6=(0,l.default)(e4);var e7=e.i(375775);let e9="thursday.install-asked",e8=null,te=new Set,tt=()=>{for(let e of te)e()};function tn(){return(0,b.useSyncExternalStore)(e=>(te.add(e),()=>te.delete(e)),()=>e8,()=>null)}async function tr(){let e=e8;e&&(e8=null,tt(),await e.prompt(),await e.userChoice.catch(()=>void 0))}function ts({hidden:e}){let t=null!==tn(),[n,s]=(0,b.useState)(!0);if((0,b.useEffect)(()=>{try{s(null!==window.localStorage.getItem(e9))}catch{}},[]),!t||n||e)return null;let a=()=>{s(!0);try{window.localStorage.setItem(e9,"1")}catch{}};return(0,r.jsxs)("div",{className:"flex w-76 animate-in items-start gap-3 rounded-2xl bg-background p-3.5 shadow-[0_22px_44px_-20px_rgb(0_0_0/0.22)] ring-1 ring-border duration-300 fade-in slide-in-from-top-1",children:[(0,r.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg bg-muted",children:(0,r.jsx)(e6,{className:"size-4"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 space-y-2.5",children:[(0,r.jsxs)("p",{className:"text-[13px] leading-snug",children:[(0,r.jsx)("span",{className:"block font-medium",children:"Keep her in her own window"}),(0,r.jsx)("span",{className:"block text-muted-foreground",children:"Install Thursday as an app, with its own icon. A closed tab no longer takes her calls with it."})]}),(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)(v.Button,{size:"sm",className:"rounded-full px-3.5",onClick:()=>{a(),tr()},children:"Install"}),(0,r.jsx)(v.Button,{size:"sm",variant:"ghost",className:"rounded-full px-3 text-muted-foreground",onClick:a,children:"Not now"})]})]})]})}function ta(){return null===tn()?null:(0,r.jsx)("button",{type:"button",onClick:()=>void tr(),className:"group/install flex w-full items-start gap-2.5 rounded-xl px-3 py-2.5 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-sm font-medium",children:["Install app",(0,r.jsx)(e7.ArrowUpRight,{className:"ml-auto size-3.5 text-muted-foreground transition-transform group-hover/install:translate-x-px group-hover/install:-translate-y-px"})]}),(0,r.jsx)("span",{className:"block text-xs leading-snug text-muted-foreground",children:"Its own window, apart from your tabs"})]})})}window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),e8=e,tt()}),window.addEventListener("appinstalled",()=>{e8=null,tt()});let tl={name:"aperture",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]};tl.node;let ti=(0,l.default)(tl);var to=e.i(758925),tu=e.i(218964),tc=e.i(97923);let td={name:"monitor",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]};td.node;let th=(0,l.default)(td),tp={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};tp.node;let tm=(0,l.default)(tp),tf={name:"smartphone",size:24,node:[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]};tf.node;let tg=(0,l.default)(tf),tx={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};tx.node;let ty=(0,l.default)(tx);var tw=e.i(770703),tb=e.i(630374),tk=e.i(917162),tv=e.i(421429),tj=e.i(895836);function tS(){let{data:e}=(0,V.useServerRoute)(k.queryKey.bot);return e&&0===e.length?"waiting":null}function tN(){let{data:e}=(0,V.useServerRoute)(k.queryKey.threads);return{owed:(e??[]).filter(e=>(0,D.needsThreadReply)(e)||(0,D.isUnread)(e)).length}}function tT(){let{data:e,isLoading:t}=(0,V.useServerRoute)(k.queryKey.config);if(t)return null;let n=t=>(0,e3.isConfigSet)(e,t);return e3.CONFIG_GROUPS.some(e=>"keys"===e.section&&!(0,e3.groupSatisfied)(e,n))?"waiting":null}let tE=e3.CONFIG_GROUPS.filter(e=>"models"===e.section).flatMap(e=>e.entries.filter(e=>e.kind).map(e=>e.key));function tA(){let{data:e,isLoading:t}=(0,V.useServerRoute)(k.queryKey.config);return t||!e?null:tE.every(t=>!(0,e3.isConfigSet)(e,t))?"waiting":null}function tM(){let{data:e}=(0,V.useServerRoute)(k.queryKey.mcp);return e?.some(e=>e.lastError)?"red":null}var t_=e.i(991322),tC=e.i(852116);function tL(){let{data:e}=(0,V.useServerRoute)(k.queryKey.reach);return e?.channels.some(e=>e.refused)?"red":null}var tR=e.i(589128);let tI=e.i(569644).FolderOpen;var tO=e.i(922521),tD=e.i(734080),tP=e.i(989409);function tF({d:e,className:t}){return(0,r.jsx)("svg",{viewBox:"-2 -2 28 28","aria-hidden":!0,className:t,children:(0,r.jsx)("path",{d:e,fill:"currentColor"})})}let tz=[{label:"Ask on Discord",href:"https://discord.gg/Qmysdh9Fy8",mark:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"},{label:"GitHub",href:"https://github.com/cgoinglove/thursday",mark:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"}];function t$(){return(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:tz.map(e=>(0,r.jsxs)("a",{href:e.href,target:"_blank",rel:"noreferrer",className:(0,S.cn)((0,v.buttonVariants)({variant:"ghost"}),"justify-start text-muted-foreground"),children:[(0,r.jsx)(tF,{d:e.mark,className:"mr-1"}),(0,r.jsx)("span",{className:"truncate text-sm",children:e.label})]},e.href))})}var tB=tj;let tq=(e,t=tB.SettingSkeleton)=>(0,tw.default)(e,{loading:()=>(0,r.jsx)(t,{})}),tU=tq(()=>e.A(48663).then(e=>({default:e.MemorySetting}))),tK=tq(()=>e.A(959484).then(e=>({default:e.BotSetting})),tB.SettingPanesSkeleton),tH=tq(()=>e.A(954404).then(e=>({default:e.ThreadSetting}))),tW=tq(()=>e.A(483782).then(e=>({default:e.RoutineSetting}))),tG=tq(()=>e.A(711454).then(e=>({default:e.ModelsSetting}))),tY=tq(()=>e.A(711454).then(e=>({default:e.KeysSetting}))),tV=tq(()=>e.A(711454).then(e=>({default:e.PhoneSetting}))),tJ=tq(()=>e.A(17613).then(e=>({default:e.ThursdaySetting}))),tX=tq(()=>e.A(706108).then(e=>({default:e.ArtifactSetting})),tB.SettingPanesSkeleton),tZ=tq(()=>e.A(194379).then(e=>({default:e.WorkspaceSetting})),tB.SettingPanesSkeleton),tQ=tq(()=>e.A(832663).then(e=>({default:e.SkillsSetting}))),t0=tq(()=>e.A(959108).then(e=>({default:e.McpSetting}))),t1=tq(()=>e.A(663973).then(e=>({default:e.SignInsSetting})));function t2({tabs:e}){let[t,n]=(0,b.useState)(0),s=e[t].Component;return(0,r.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,r.jsx)("div",{className:"shrink-0 px-8 pt-5",children:(0,r.jsx)(tB.SettingColumn,{children:(0,r.jsx)(tv.Segmented,{view:!0,"aria-label":"Screens of this section",options:e.map((e,t)=>({value:String(t),label:e.label})),value:String(t),onChange:e=>n(Number(e))})})}),(0,r.jsx)("div",{className:"min-h-0 flex-1",children:(0,r.jsx)(s,{})})]})}let t5=[{label:"Finished",Component:tX},{label:"All files",Component:tZ}],t3=["call","work","app"],t4="px-3 pt-3 pb-1 font-mono text-[10px] text-muted-foreground/60",t6=[{id:"thursday",label:"Thursday",group:"call",hint:"Captions, models, and how a call starts",icon:H.ThursdayMark,Component:tJ},{id:"memory",label:"Memory",group:"call",hint:"What Thursday remembers about you",icon:tC.MemoryMark,Component:tU},{id:"bot",label:"Bots",group:"work",hint:"Who Thursday hands work to",icon:P.BotsMark,Component:tK,Badge:function(){return tS()?(0,r.jsx)(tj.NavBadge,{tone:"waiting"}):null}},{id:"threads",label:"Threads",group:"work",hint:"Work the bots were handed",icon:tu.ListChecks,Component:tH,Badge:function(){return(0,r.jsx)(tj.NavBadge,{tone:"waiting",count:tN().owed})}},{id:"routines",label:"Routines",group:"work",hint:"Work that starts by itself, on a schedule",icon:ec.RoutineMark,Component:tW},{id:"files",label:"Files",group:"work",hint:"What the bots finished, and everything else they wrote",icon:tI,Component:()=>(0,r.jsx)(t2,{tabs:t5})},{id:"skills",label:"Skills",group:"work",hint:"Instructions the bots load on demand",icon:tR.SkillsMark,Component:tQ},{id:"mcp",label:"Connectors",group:"work",hint:"Apps the bots can use, from MCP servers",icon:t_.McpMark,Component:t0,Badge:function(){return tM()?(0,r.jsx)(tj.NavBadge,{tone:"red"}):null}},{id:"signins",label:"Sign-ins",group:"work",hint:"The sites you signed in to, and the bots that may use each",icon:tc.LogIn,Component:t1},{id:"models",label:"Models",group:"app",hint:"What bots think with, and what they draw, film and speak with",icon:ti,Component:tG,Badge:function(){return tA()?(0,r.jsx)(tj.NavBadge,{tone:"waiting"}):null}},{id:"keys",label:"API keys",group:"app",hint:"The accounts the app runs on",icon:to.KeyRound,Component:tY,Badge:function(){return tT()?(0,r.jsx)(tj.NavBadge,{tone:"waiting"}):null}},{id:"phone",label:"Phone",group:"app",hint:"Write to Thursday from a chat app",icon:tg,Component:tV,Badge:function(){return tL()?(0,r.jsx)(tj.NavBadge,{tone:"red"}):null}}],t7={system:{label:"System",icon:th},light:{label:"Light",icon:ty},dark:{label:"Dark",icon:tm}};function t9(){let e=(0,tO.useTheme)();return(0,r.jsx)(tv.Segmented,{"aria-label":"Theme",className:"w-full gap-0.5 *:flex-1 *:py-1.5",options:tD.THEMES.map(e=>{let{label:t,icon:n}=t7[e];return{value:e,title:t,label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n,{className:"size-3.5"}),(0,r.jsx)("span",{className:"sr-only",children:t})]})}}),value:e,onChange:tO.setTheme})}function t8({children:e}){let t=(0,tP.useSettingsStore)(e=>e.open),n=(0,tP.useSettingsStore)(e=>e.section),s=(0,tP.useSettingsStore)(e=>e.show),a=(0,tP.useSettingsStore)(e=>e.hide),l=(0,tP.useSettingsStore)(e=>e.pick),i=(0,tP.useSettingsStore)(e=>e.unsaved),o=async e=>{(!i?.()||await tk.notify.discard())&&e()},u=(0,b.useRef)(null),c=t6.find(e=>e.id===n)??t6[0];return(0,b.useEffect)(()=>{if(!t)return;let e=e=>{if(!e.metaKey&&!e.ctrlKey)return;if("k"===e.key){let t=u.current?.querySelector("[data-setting-filter]");if(!t)return;e.preventDefault(),t.focus(),t.select();return}let t=Number(e.key);Number.isInteger(t)&&t>=1&&t<=t6.length&&(e.preventDefault(),o(()=>l(t6[t-1].id)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,l]),(0,r.jsxs)(tb.Dialog,{open:t,onOpenChange:e=>e?s():void o(a),children:[e&&(0,r.jsx)(tb.DialogTrigger,{render:e}),(0,r.jsxs)(tb.DialogContent,{className:"block h-[min(52rem,calc(100vh-3rem))] overflow-hidden p-0 sm:max-w-[min(80rem,calc(100vw-3rem))]",children:[(0,r.jsx)(tb.DialogTitle,{className:"sr-only",children:"Settings"}),(0,r.jsxs)("div",{className:"flex h-full min-h-0",children:[(0,r.jsxs)("nav",{"aria-label":"Settings sections",onKeyDown:e=>{let t,r="ArrowDown"===e.key?1:"ArrowUp"===e.key?-1:0;if(!r)return;e.preventDefault();let s=(t=(t6.findIndex(e=>e.id===n)+r+t6.length)%t6.length,t6[t].id);o(()=>l(s)),e.currentTarget.querySelector(`[data-section="${s}"]`)?.focus()},className:"flex w-52 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border/60 bg-muted/30 p-3",children:[t3.map(e=>(0,r.jsxs)(b.Fragment,{children:[(0,r.jsx)("span",{className:t4,children:e}),t6.filter(t=>t.group===e).map(e=>(0,r.jsxs)(v.Button,{"data-section":e.id,onClick:()=>void o(()=>l(e.id)),variant:e.id===n?"secondary":"ghost",className:(0,S.cn)("justify-start",e.id===n?"text-foreground bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]":"text-muted-foreground"),children:[(0,r.jsx)(e.icon,{className:(0,S.cn)("mr-1")}),(0,r.jsx)("span",{className:"truncate text-sm",children:e.label}),e.Badge&&(0,r.jsx)("span",{className:"ml-auto flex items-center",children:(0,r.jsx)(e.Badge,{})})]},e.id))]},e)),(0,r.jsx)("span",{className:t4,children:"community"}),(0,r.jsx)(t$,{}),(0,r.jsxs)("div",{className:"mt-auto flex flex-col gap-2 pt-3",children:[(0,r.jsx)(ta,{}),(0,r.jsx)("div",{className:"px-1",children:(0,r.jsx)(t9,{})})]})]}),(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"shrink-0 px-8 pt-10",children:(0,r.jsxs)(tB.SettingColumn,{className:"animate-in space-y-0.5 fade-in slide-in-from-bottom-1 duration-300",children:[(0,r.jsx)("p",{className:"truncate text-2xl font-semibold",children:c.label}),(0,r.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:c.hint})]},c.id)}),(0,r.jsx)("div",{ref:u,className:"min-h-0 min-w-0 flex-1",children:(0,r.jsx)(c.Component,{})})]})]})]})]})}function ne(e){return e.includes("red")?"red":e.includes("waiting")?"waiting":null}function nt(){let e=tS(),t=tN().owed>0?"waiting":null,n=tM(),r=tT();return{bot:e,threads:t,mcp:n,keys:r,models:tA(),phone:tL()}}let nn=!1,nr=new Set,ns=new Set,na={hold(e){if(e!==nn)for(let t of(nn=e,nr))t()},place(){for(let e of ns)e()},onPlace:e=>(ns.add(e),()=>{ns.delete(e)})};function nl(){return(0,b.useSyncExternalStore)(e=>(nr.add(e),()=>nr.delete(e)),()=>nn,()=>!1)}e.s(["callSignal",0,na,"useCallHeld",0,nl],745747);var ni=e.i(218080);function no(){let e=performance.now()/1e3;return Array.from({length:ni.SPECTRUM_BANDS},(t,n)=>.18+.16*Math.sin(e*(5+.9*n)+1.7*n)**2)}e.s(["silentVoice",0,no],234916);var nu=e.i(671228),nc=e.i(67045),nd=e.i(297825),nh=e.i(670097),np=e.i(640262),nm=e.i(6799),nf=e.i(213377),ng=e.i(95187);let nx=(0,ng.createServerReference)("7ff8ae93caf5511c6d47121b2dfaa3cc9d23ae1f07",ng.callServer,void 0,ng.findSourceMapURL,"acceptThreadRelaysAction");var ny=e.i(393080),nw=e.i(609856);let nb=new Set,nk=e=>new Set(nT(e).filter(e=>"question"!==e.kind).map(e=>e.key)),nv={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},nj={question:0,stopped:1,done:2,progress:3};function nS(e){let t=(0,S.captionText)(e.replace(/!\[[^\]]*\]\([^)]*\)/g," ")).replace(S.MARKDOWN_LINK,"$1").replace(/^• /gm,"").trim();if(t.length<=R.CALL_RELAY.chars)return t;let n=t.slice(0,R.CALL_RELAY.chars),r=Math.max(n.lastIndexOf("\n\n"),n.lastIndexOf(". "),n.lastIndexOf(".\n"),n.lastIndexOf("。")),s=(r>R.CALL_RELAY.chars/3?n.slice(0,r+1):n).trim();return`${s}
4
- [The message goes on; the rest is in its thread on screen.]`}let nN=e=>`question:${e}`;function nT(e){let t=[];for(let n of e){let{relays:e,questions:r}=n.room,s=(0,G.toDate)(n.updatedAt).getTime(),a=(e,t)=>`[${e} → Thursday, thread "${n.label}" (${n.id}), ${t}.]`,l=(e,t)=>({kind:"relay",name:n.label,line:t,done:!0,bot:e});for(let s of r){let r=s.options?.length?` Options: ${s.options.join(" / ")}.`:"";t.push({rank:nj.question,key:nN(s.id),kind:"question",line:`${a(s.bot,"question")}
5
- ${nS(s.text)}${r}`,relayIds:e.filter(e=>e.messageId===s.id).map(e=>e.id),threadId:n.id,text:s.text,show:l(s.bot,`${s.bot} asks`)})}let i=e.filter(e=>!r.some(t=>t.id===e.messageId)),o="done"===n.status,u="waiting"===n.status&&(0,D.isAppStop)(n.ask);if(o||u){if(n.seen)continue;let e=u?"stopped":"done",r=(u?n.ask?.question:null)??n.outcome??"",o="stopped"===e?`It stopped before finishing. Where it got to: ${nS(r)}`:`Done. Its answer: ${nS(r)}`;t.push({rank:nj[e],key:`${e}:${n.id}@${s}`,kind:"ending",line:`${a(n.bot,e)}
6
- ${o}`,relayIds:i.map(e=>e.id),threadId:n.id,text:r,show:l(n.bot,"stopped"===e?`${n.bot} stopped`:`${n.bot} finished`)});continue}for(let e of i)t.push({rank:nj.progress,key:`progress:${e.id}`,kind:"progress",line:`${a(e.bot,e.kind)}
7
- ${nS(e.text)}`,relayIds:[e.id],threadId:n.id,text:e.text,show:l(e.bot,`${e.bot} ${nv[e.kind]}`)})}return t.sort((e,t)=>e.rank-t.rank)}function nE(e){return"answered"===e.kind?`The user sent a message on screen to ${e.recipient??"the coordinator"} in thread "${e.label}" (${e.id})${e.replyTo?`, replying to ${e.replyTo}`:""}: ${e.answer}. It has reached that participant.`:"stopped"===e.kind?`The user stopped thread "${e.label}" on screen. It is no longer running.`:`The user put ${1===e.paths.length?"a file":`${e.paths.length} files`} down on screen, kept on this computer at ${e.paths.join(", ")}.`}let nA=(0,ng.createServerReference)("7f09e9996601a994ba8dfee65b6cfbca50439e2c71",ng.callServer,void 0,ng.findSourceMapURL,"endCallAction"),nM=(0,ng.createServerReference)("7fb0749dc87efe8412873b8a86b42018aabb0ed20e",ng.callServer,void 0,ng.findSourceMapURL,"openTextCallAction"),n_=(0,ng.createServerReference)("7fe2aae79cb9011ddb4ae9d0d0ebb034e9956fc0ca",ng.callServer,void 0,ng.findSourceMapURL,"tellTextCallAction");var nC=e.i(561540);let nL=new np.DefaultChatTransport({api:k.queryKey.textCall}),nR=()=>nc.useThursdayStore.getState().textModel,nI=e=>({type:`data-${nu.TEXT_CALL_NOTE}`,id:e.id,data:e});async function nO(e,t,n,r){try{let s=await fetch(k.queryKey.toolCall,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolCallId:t.id,callId:e,...n,name:t.name,input:t.arguments?JSON.parse(t.arguments):{}}),signal:r}),{output:a}=(0,ny.unwrapResult)(await s.json());return"string"==typeof a?a:JSON.stringify(a??null)}catch(e){return`Error: ${(0,S.errorToString)(e)}`}}var nD=e.i(844601),nP=e.i(807038),nF=e.i(83928),nz=e.i(616172),n$=e.i(621285);function nB(){return(0,r.jsx)(n$.FileViewer,{children:(0,r.jsx)(nV,{})})}let nq={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},nU="thursday.corner-dismissed";function nK(){try{let e=JSON.parse(window.localStorage.getItem(nU)??"[]");return Array.isArray(e)?e:[]}catch{return[]}}function nH(e){try{let t=[...e,...nK().filter(t=>!e.includes(t))].slice(0,50);window.localStorage.setItem(nU,JSON.stringify(t))}catch{}}function nW(){"u"<typeof Notification||"default"===Notification.permission&&Notification.requestPermission().catch(()=>void 0)}function nG(e){return{threadId:e.id,label:e.label,bot:e.bot.name,words:(0,S.plainText)(e.outcome??"").slice(0,R.FINISHED_NOTICE.words),paths:(0,nz.leadFirst)((0,nz.pathsIn)(e.outcome??"")),unchecked:!0}}function nY({row:e,children:t}){let n=e.unchecked&&e.paths.length>0,{data:r}=(0,V.useServerRoute)(n?k.queryKey.workspaceFiles(e.paths):null);if(!n)return t(e);if(!r)return null;let s=new Set(r.map(e=>e.path));return t({...e,paths:(0,nz.leadFirst)(e.paths.filter(e=>s.has(e)))})}function nV(){let[e,t]=(0,b.useState)([]),{data:n}=(0,V.useServerRoute)(k.queryKey.bot),s=(0,J.useBotThreads)(),a=(0,n$.useOpenFile)();(0,b.useEffect)(()=>J.fileOpens.subscribe(e=>{a(e)}),[a]),(0,$.useAppEvent)({showFile:e=>a(e.paths[0],e.paths.filter(e=>"image"===(0,nz.viewKindOf)(e)),!0),finished:e=>{!function(e,t,n){if(!("u"<typeof Notification)&&"granted"===Notification.permission&&!("visible"===document.visibilityState&&document.hasFocus()))try{let r=new Notification(t,{body:n,tag:e,icon:"/icon.svg"});r.onclick=()=>{window.focus(),r.close()}}catch{}}(e.threadId,e.label,e.words),t(t=>[{threadId:e.threadId,label:e.label,bot:e.bot,words:e.words,paths:e.paths},...t.filter(t=>t.threadId!==e.threadId)].slice(0,R.FINISHED_NOTICE.rows))}});let l=(0,b.useRef)(new Set);(0,b.useEffect)(()=>{if(!J.botThreads.primed())return;for(let e of s)("done"===e.status||"cancelled"===e.status)&&l.current.add(e.id);let e=new Set(nK()),n=s.filter(t=>(0,D.isUnread)(t)&&!e.has(t.id)).sort((e,t)=>(0,G.toDate)(t.updatedAt).getTime()-(0,G.toDate)(e.updatedAt).getTime()),r=new Set(n.map(e=>e.id));t(e=>{let t=e.filter(e=>!l.current.has(e.threadId)||r.has(e.threadId)),s=[...n.filter(e=>!t.some(t=>t.threadId===e.id)).map(nG),...t].slice(0,R.FINISHED_NOTICE.rows);return s.length===e.length&&s.every((t,n)=>t.threadId===e[n].threadId)?e:s})},[s]);let i=e=>{nH([e]),t(t=>t.filter(t=>t.threadId!==e))};if(!e.length)return null;let o=e.slice(0,R.FINISHED_NOTICE.shown),u=e.slice(R.FINISHED_NOTICE.shown),c=e=>{nH(e),t(t=>t.filter(t=>!e.includes(t.threadId))),(0,nD.markSeenAction)(e).then(ny.unwrapResult).then(()=>(0,V.revalidate)(k.queryKey.threads)).catch(t=>nm.toast.add({type:"error",title:e.length>1?"Could not mark the threads as read":"Could not mark the thread as read",description:(0,S.errorToString)(t)}))};return(0,r.jsx)("div",{className:"pointer-events-none relative col-start-1 row-start-2 w-82 max-w-full",children:(0,r.jsxs)("div",{className:"pointer-events-auto absolute bottom-0 left-0 -m-2 flex max-h-[80vh] w-82 max-w-full flex-col-reverse gap-2 overflow-y-auto p-2 scrollbar-none",children:[o.map(e=>(0,r.jsx)(nY,{row:e,children:e=>(0,r.jsx)(nX,{row:e,bot:n?.find(t=>t.name===e.bot),onOpen:t=>{t?(a(t,e.paths.filter(e=>"image"===(0,nz.viewKindOf)(e))),c([e.threadId])):(J.roomOpens.open(e.threadId),i(e.threadId))},onClose:()=>i(e.threadId)})},e.threadId)),u.map(e=>(0,r.jsx)(nY,{row:e,children:e=>(0,r.jsx)(nJ,{row:e,bot:n?.find(t=>t.name===e.bot),onOpen:()=>{J.roomOpens.open(e.threadId),i(e.threadId)},onClose:()=>i(e.threadId)})},e.threadId)),e.length>1&&(0,r.jsxs)("p",{className:"flex shrink-0 items-center gap-2 px-1.5 font-mono text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{children:[e.length," new"]}),(0,r.jsx)("span",{className:"flex-1"}),(0,r.jsx)("button",{type:"button",onClick:()=>c(e.map(e=>e.threadId)),className:"rounded-md px-1 font-sans text-[11px] outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"Clear all"})]})]})})}function nJ({row:e,bot:t,onOpen:n,onClose:s}){let a=e.paths.length-3;return(0,r.jsxs)("div",{className:"flex shrink-0 animate-in items-center gap-2 rounded-2xl bg-background py-1.5 pr-1.5 pl-2.5 shadow-black/8 shadow-md ring-1 ring-border fade-in slide-in-from-bottom-1 duration-300",children:[(0,r.jsxs)("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)(P.BotMark,{size:18,seed:e.bot,color:t?.icon?.color,shape:t?.icon?.shape,outline:t?.icon?.outline,paint:t?.icon?.paint,notify:!1,className:"shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] leading-5",children:e.label}),e.paths.length>0&&(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[e.paths.slice(0,3).map(e=>(0,r.jsx)(nF.FileThumb,{path:e,glyph:"size-2.5",className:"size-5 rounded-[6px] ring-1 ring-border"},e)),a>0&&(0,r.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",a]})]})]}),(0,r.jsx)(v.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:s,className:"shrink-0 text-muted-foreground",children:(0,r.jsx)(w.X,{})})]})}function nX({row:e,bot:t,onOpen:n,onClose:s}){let a,l=(a=e.paths.length)<=2?2:3===a?3:4,i=e.paths.slice(0,l),o=e.paths.length-i.length;return(0,r.jsxs)("div",{className:"flex shrink-0 animate-in gap-2.5 rounded-[20px] bg-background py-2.5 pr-2 pl-2.5 shadow-black/10 shadow-lg ring-1 ring-border fade-in slide-in-from-bottom-2 duration-300",children:[(0,r.jsx)(P.BotMark,{size:32,seed:e.bot,color:t?.icon?.color,shape:t?.icon?.shape,outline:t?.icon?.outline,paint:t?.icon?.paint,notify:!1,className:"shrink-0"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[(0,r.jsxs)("div",{className:"flex items-start gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e.paths[0]??null),className:"flex min-w-0 flex-1 flex-col gap-1.5 rounded-lg text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsxs)("span",{className:"flex min-h-8 flex-col justify-center",children:[(0,r.jsx)("span",{className:"truncate font-medium text-[14px] leading-5 tracking-[-0.15px]",children:e.label}),(0,r.jsx)("span",{className:"truncate font-mono text-[10px] leading-[13px] text-muted-foreground",children:e.bot})]}),e.words&&(0,r.jsx)("span",{className:"line-clamp-2 break-keep wrap-anywhere text-[12.5px] leading-normal text-muted-foreground",children:(0,nP.shortenPaths)(e.words)})]}),(0,r.jsx)(v.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:s,className:"shrink-0 text-muted-foreground",children:(0,r.jsx)(w.X,{})})]}),i.length>0&&(0,r.jsx)("div",{className:(0,S.cn)("grid gap-1.5 pt-0.5",nq[l]),children:i.map((e,t)=>(0,r.jsxs)("button",{type:"button",title:e.split("/").pop(),onClick:()=>n(e),className:"relative rounded-[10px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)(nF.FileThumb,{path:e,glyph:2===l?"size-6":"size-4",className:"aspect-square w-full rounded-[10px] ring-1 ring-border"}),o>0&&t===i.length-1&&(0,r.jsxs)("span",{className:"absolute inset-0 grid place-items-center rounded-[10px] bg-black/45 font-medium text-[14px] text-white",children:["+",o]})]},e))})]})]})}e.s(["ArtifactView",0,nB,"FinishedCard",0,nX,"askToNotify",0,nW],895499);let nZ={"not-allowed":"The microphone is not allowed","service-not-allowed":"The microphone is not allowed","audio-capture":"There is no microphone","language-not-supported":"This browser cannot listen in that language"},nQ=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(Boolean),n0=(e,t,n)=>Math.abs(e.length-t.length)<=n&&function(e,t){let n=Array.from({length:e.length+1},(e,t)=>t),r=Array(e.length+1).fill(0);for(let s=1;s<=t.length;s++){r[0]=s;for(let a=1;a<=e.length;a++){let l=n[a-1]+ +(t[s-1]!==e[a-1]);r[a]=Math.min(l,n[a]+1,r[a-1]+1)}[n,r]=[r,n]}return n[e.length]}(e,t)<=n;function n1({enabled:e,onWake:t,phrases:n,onError:r}){let s=(0,b.useRef)({onWake:t,onError:r,phrases:n});s.current={onWake:t,onError:r,phrases:n},(0,b.useEffect)(()=>{if(!e)return;let t=window,n=t.SpeechRecognition??t.webkitSpeechRecognition;if(!n)return void s.current.onError?.("This browser cannot listen for a wake word");let r=new n,a=!0,l=!0,i=null,o=300;r.lang="en-US",r.continuous=!0,r.interimResults=!0,r.maxAlternatives=3;let u=()=>{if(a){l=!0;try{r.start()}catch{}}};return r.onresult=({resultIndex:e,results:t})=>{if(!a||!l)return;o=300;let{phrases:n,onWake:i}=s.current,u=n.map(nQ).filter(e=>e.length);for(let n=e;n<t.length;n++){let e=t[n];for(let t=0;t<e.length;t++){let n=e[t].transcript,s=nQ(n);if(u.some(e=>(function(e,t,n){for(let r=0;r<e.length;r++)if(function e(t,n,r,s,a){if(s===r.length)return!0;if(n>=t.length)return!1;let l=r[s],i=Math.max(1,Math.round(l.length*a));return!!(n0(t[n],l,i)&&e(t,n+1,r,s+1,a))||n+1<t.length&&n0(t[n]+t[n+1],l,i)&&e(t,n+2,r,s+1,a)}(e,r,t,0,n))return!0;return!1})(s,e,R.WAKE_TOLERANCE))){l=!1,r.abort(),i(n.trim());return}}}},r.onerror=({error:e})=>{let t=nZ[e];t?(a=!1,s.current.onError?.(t)):"network"===e&&(o=Math.min(2*o,1e4))},r.onend=()=>{a&&(i=setTimeout(u,o))},u(),()=>{a=!1,i&&clearTimeout(i),r.onresult=null,r.onerror=null,r.onend=null,r.abort()}},[e])}e.s(["useWakeWord",0,n1],656572);let n2={silent:{level:-1},fatal:{level:0},error:{level:0},warn:{level:1},log:{level:2},info:{level:3},success:{level:3},fail:{level:3},ready:{level:3},start:{level:3},box:{level:3},debug:{level:4},trace:{level:5},verbose:{level:1/0}};function n5(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.iterator in e)&&(!(Symbol.toStringTag in e)||"[object Module]"===Object.prototype.toString.call(e))}let n3=!1,n4=[];class n6{options;_lastLog;_mockFn;constructor(e={}){const t=e.types||n2;for(const n in this.options=((...e)=>e.reduce((e,t)=>(function e(t,n,r=".",s){if(!n5(n))return e(t,{},r,s);let a=Object.assign({},n);for(let n in t){if("__proto__"===n||"constructor"===n)continue;let l=t[n];null!=l&&(s&&s(a,n,l,r)||(Array.isArray(l)&&Array.isArray(a[n])?a[n]=[...l,...a[n]]:n5(l)&&n5(a[n])?a[n]=e(l,a[n],(r?`${r}.`:"")+n.toString(),s):a[n]=l))}return a})(e,t,"",void 0),{}))({...e,defaults:{...e.defaults},level:n7(e.level,t),reporters:[...e.reporters||[]]},{types:n2,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}}),t){const e={type:n,...this.options.defaults,...t[n]};this[n]=this._wrapLogFn(e),this[n].raw=this._wrapLogFn(e,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=n7(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error("prompt is not supported!");return this.options.prompt(e,t)}create(e){let t=new n6({...this.options,...e});return this._mockFn&&t.mockTypes(this._mockFn),t}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(-1!==t)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console["__"+e]||(console["__"+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console["__"+e]&&(console[e]=console["__"+e],delete console["__"+e])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(e,t){e&&(e.__write||(e.__write=e.write),e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){n3=!0}resumeLogs(){for(let e of(n3=!1,n4.splice(0)))e[0]._logFn(e[1],e[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,"function"==typeof t)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>n3?void n4.push([this,e,n,t]):this._logFn(e,n,t)}_logFn(e,t,n){var r,s;if((e.level||0)>this.level)return!1;let a={date:new Date,args:[],...e,level:n7(e.level,this.options.types)};n||1!==t.length||+(s=r=t[0],"[object Object]"!==Object.prototype.toString.call(s)||!r.message&&!r.args||!!r.stack)?a.args=[...t]:Object.assign(a,t[0]),a.message&&(a.args.unshift(a.message),delete a.message),a.additional&&(Array.isArray(a.additional)||(a.additional=a.additional.split("\n")),a.args.push("\n"+a.additional.join("\n")),delete a.additional),a.type="string"==typeof a.type?a.type.toLowerCase():"log",a.tag="string"==typeof a.tag?a.tag:"";let l=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=a,this._log(a))};clearTimeout(this._lastLog.timeout);let i=this._lastLog.time&&a.date?a.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=a.date,i<this.options.throttle)try{let e=JSON.stringify([a.type,a.tag,a.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(l,this.options.throttle);return}}catch{}l(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}}function n7(e,t={},n=3){return void 0===e?n:"number"==typeof e?e:t[e]&&void 0!==t[e].level?t[e].level:n}n6.prototype.add=n6.prototype.addReporter,n6.prototype.remove=n6.prototype.removeReporter,n6.prototype.clear=n6.prototype.removeReporter,n6.prototype.withScope=n6.prototype.withTag,n6.prototype.mock=n6.prototype.mockTypes,n6.prototype.pause=n6.prototype.pauseLogs,n6.prototype.resume=n6.prototype.resumeLogs;class n9{options;defaultColor;levelColorMap;typeColorMap;constructor(e){this.options={...e},this.defaultColor="#7f8c8d",this.levelColorMap={0:"#c0392b",1:"#f39c12",3:"#00BCD4"},this.typeColorMap={success:"#2ecc71"}}_getLogFn(e){return e<1?console.__error||console.error:1===e?console.__warn||console.warn:console.__log||console.log}log(e){let t=this._getLogFn(e.level),n="log"===e.type?"":e.type,r=e.tag||"",s=this.typeColorMap[e.type]||this.levelColorMap[e.level]||this.defaultColor,a=`
8
- background: ${s};
9
- border-radius: 0.5em;
10
- color: white;
11
- font-weight: bold;
12
- padding: 2px 0.5em;
13
- `,l=`%c${[r,n].filter(Boolean).join(":")}`;"string"==typeof e.args[0]?t(`${l}%c ${e.args[0]}`,a,"",...e.args.slice(1)):t(l,a,...e.args)}}function n8(e={}){return function(e={}){return new n6(e)}({reporters:e.reporters||[new n9({})],prompt:(e,t={})=>"confirm"===t.type?Promise.resolve(confirm(e)):Promise.resolve(prompt(e)),...e})}n8();var re=e.i(247167),rt=e.i(379227);let{env:rn={},argv:rr=[],platform:rs=""}=void 0===re.default?{}:re.default,ra="NO_COLOR"in rn||rr.includes("--no-color"),rl="FORCE_COLOR"in rn||rr.includes("--color"),ri="dumb"===rn.TERM,ro=rt&&rt.isatty&&rt.isatty(1)&&rn.TERM&&!ri,ru="CI"in rn&&("GITHUB_ACTIONS"in rn||"GITLAB_CI"in rn||"CIRCLECI"in rn),rc=!ra&&(rl||"win32"===rs&&!ri||ro||ru);function rd(e,t,n){return function(e,t,n=e,r=e.length+1){return s=>{var a;return s||""!==s&&void 0!==s?(a=(""+s).indexOf(t,r),a<0?e+s+t:e+function e(t,n,r,s,a=n.slice(0,Math.max(0,t))+s,l=n.slice(Math.max(0,t+r.length)),i=l.indexOf(r)){return a+(i<0?l:e(i,l,r,s))}(a,s,t,n)+t):""}}(`\x1b[${e}m`,`\x1b[${t}m`,n)}let rh={reset:rd(0,0),bold:rd(1,22,"\x1b[22m\x1b[1m"),dim:rd(2,22,"\x1b[22m\x1b[2m"),italic:rd(3,23),underline:rd(4,24),inverse:rd(7,27),hidden:rd(8,28),strikethrough:rd(9,29),black:rd(30,39),red:rd(31,39),green:rd(32,39),yellow:rd(33,39),blue:rd(34,39),magenta:rd(35,39),cyan:rd(36,39),white:rd(37,39),gray:rd(90,39),bgBlack:rd(40,49),bgRed:rd(41,49),bgGreen:rd(42,49),bgYellow:rd(43,49),bgBlue:rd(44,49),bgMagenta:rd(45,49),bgCyan:rd(46,49),bgWhite:rd(47,49),blackBright:rd(90,39),redBright:rd(91,39),greenBright:rd(92,39),yellowBright:rd(93,39),blueBright:rd(94,39),magentaBright:rd(95,39),cyanBright:rd(96,39),whiteBright:rd(97,39),bgBlackBright:rd(100,49),bgRedBright:rd(101,49),bgGreenBright:rd(102,49),bgYellowBright:rd(103,49),bgBlueBright:rd(104,49),bgMagentaBright:rd(105,49),bgCyanBright:rd(106,49),bgWhiteBright:rd(107,49)},rp=function(e=rc){return e?rh:Object.fromEntries(Object.keys(rh).map(e=>[e,String]))}();[String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");let rm=n8({level:R.IS_DEV?4:3}),rf=(t=R.APP_NAME,rm.withDefaults({message:(n=`${t}: `,(function(e,t="reset"){return rp[e]||rp[t]})("blackBright")(n))}));var rg=e.i(413168);let rx={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},ry=new TextEncoder;async function rw(e){let t=rk(e);try{return await t.connect(),t}catch(e){throw await t.close(),e}}let rb=["response.completed","response.failed","response.incomplete","response.cancelled"],rk=({initialize:e,audio:t,on:n})=>{let r,s,a,l,i,o,u,c,d=!1,h=!1,p=!1,m=0,f=0,g="",x=[],y=new Set,w=new Set,b=new Set,k=new Map,v=!1,j=new Map,N=new Map,T=[],E=null,A=-1/0,M=()=>{for(let e of(clearTimeout(u),u=void 0,y))n.turn({...e.turn,fragments:[...e.fragments],done:!0});y.clear()},_=()=>{if(!p){for(let e of(p=!0,clearTimeout(i),clearTimeout(c),clearInterval(o),M(),E=null,T.splice(0)))e.settle(!1);z.close(),a?.()}},C=e=>{s?.(Error(e)),_(),d&&!h?n.failed(e):h&&n.warn(e)},L=-1/0,I=()=>{if(p||h)return;let e=performance.now(),r=t.levels?.();r&&r.output>.01&&(A=e);let s={speaking:e-A<300,working:[...k.values()].some(e=>!e.terminal)||N.size>0||e-L<5e3,tools:[...N.values()]},a=JSON.stringify(s);(a!==g||s.speaking||s.working)&&(g=a,n.activity(s))},O=()=>{if(!d||p||h||E||!T.length)return;let[e]=T;E=crypto.randomUUID(),z.send({type:`session.${e.kind}.append`,event_id:E,delegation_id:null,content:e.chunks[0]}),c=setTimeout(()=>{n.warn("Live did not acknowledge the conversation update; delivery is unknown."),D(!1)},R.LIVE_CALL.appendMs)},D=e=>{clearTimeout(c),E=null;let[t]=T;t&&(e&&t.chunks.shift(),e&&t.chunks.length||(T.shift(),t.settle(e)),O())},P=(e,t)=>{if(!e.delta||void 0===e.start_ms||void 0===e.end_ms)return;let r=e.start_ms,s=e.end_ms,a=x.findLast(e=>e.turn.role===t&&r>=e.turn.seq-R.LIVE_CALL.transcriptGapMs&&r<=e.end+R.LIVE_CALL.transcriptGapMs&&("user"===t||!x.some(t=>"user"===t.turn.role&&t.turn.seq>e.turn.seq&&t.turn.seq<r)));a||(a={turn:{id:`live-${f++}`,role:t,text:"",seq:r,done:!1},end:s,fragments:[]},x.push(a)),a.fragments.push({start:r,end:s,text:e.delta}),a.fragments.sort((e,t)=>e.start-t.start),a.end=Math.max(a.end,s),a.turn.text=a.fragments.map(e=>e.text).join(""),n.turn({...a.turn,done:!1}),y.add(a),u??=setTimeout(M,R.LIVE_CALL.transcriptSaveMs)},F=async e=>{e.terminal&&!e.continued&&e.calls.size&&(e.continued=!0,await Promise.all(e.calls.values()),h||p||(L=performance.now(),z.send({type:"response.create",event_id:crypto.randomUUID()})),I())},z=function({negotiate:e,audio:t,on:n}){let r,s,a=null,l=null,i=null,o=!1,u=!1,c=!1,d=e=>{for(let t of e?.getTracks()??[])t.stop()};return{async connect(){let h=new RTCPeerConnection;a=h;let p=h.createDataChannel("oai-events");l=p;let m=new Promise((e,t)=>{r=t;let s=e=>{o||c||(c=!0,u?n.dropped(e):t(Error(e)))};p.onopen=()=>{u=!0,e()},p.onclose=()=>s("The connection to OpenAI Live closed."),p.onerror=()=>s("The connection to OpenAI Live dropped."),h.onconnectionstatechange=()=>{["failed","closed"].includes(h.connectionState)&&s("Could not reach OpenAI Live.")}});m.catch(()=>{}),p.onmessage=({data:e})=>{let t;if(!o&&"string"==typeof e){try{t=JSON.parse(e)}catch{n.dropped("OpenAI Live sent an unreadable event.");return}n.event(t)}},h.ontrack=e=>{if(o)return;let n=e.streams[0]??new MediaStream([e.track]);t.element.srcObject=n,t.listen(n)};let f=await navigator.mediaDevices.getUserMedia({audio:rx});if(o)throw d(f),Error("The call closed before connecting.");for(let e of(i=f,t.hear?.(f),f.getAudioTracks()))h.addTrack(e,f);await h.setLocalDescription(await h.createOffer()),"complete"!==h.iceGatheringState&&await new Promise((e,t)=>{let n=n=>{clearTimeout(a),h.removeEventListener("icegatheringstatechange",r),s=void 0,n?t(n):e()},r=()=>{"complete"===h.iceGatheringState&&n()},a=setTimeout(()=>n(Error("ICE gathering timed out.")),1e4);s=()=>n(Error("The call closed before connecting.")),h.addEventListener("icegatheringstatechange",r),r()});let g=h.localDescription?.sdp;if(!g||o)throw Error("No live SDP offer is available.");let x=await e(g);if(o)throw Error("The call closed before connecting.");await h.setRemoteDescription({type:"answer",sdp:x}),await m},send(e){o||l?.readyState!=="open"||l.send(JSON.stringify(e))},close:()=>{o||(o=!0,r?.(Error("The call closed before connecting.")),s?.(),d(i),i=null,l?.close(),a?.close(),t.element.srcObject=null)}}}({audio:t,negotiate:async t=>{let n=await e(t);if(!n)throw Error("OpenAI Live returned no SDP answer.");return n},on:{event:e=>{if(!p){if(e.event_id){if(w.has(e.event_id))return;w.add(e.event_id)}switch(m=Math.max(m,e.offset_ms??0,e.end_ms??0),e.type){case"session.started":d=!0,r?.(),O();break;case"session.closed":n.finalized?.({reason:e.reason??"closed",seconds:e.usage?.seconds??null}),rf.info("Live session closed",{reason:e.reason,seconds:e.usage?.seconds}),s?.(Error("OpenAI Live closed before startup completed.")),_(),h||n.failed(`The Live call ended (${e.reason??"closed"}).`);break;case"session.input_transcript.delta":P(e,"user");break;case"session.output_transcript.delta":P(e,"assistant");break;case"session.instructions.appended":case"session.commentary.appended":case"session.thinking.appended":E&&e.client_event_id===E&&D(!0);break;case"error":{let t=e.error?.message??"OpenAI Live reported an error.";if(!d){C(t);break}for(let r of(n.warn(t),E&&e.error?.client_event_id===E&&D(!1),k.values()))r.terminal||r.calls.size||(r.terminal=!0,r.stale=!0);I();break}case"response.event":{let t=e.event;if(!t||h)break;"response.created"===t.type&&(L=-1/0),"response.created"===t.type&&t.response&&e.delegation_id&&j.set(e.delegation_id,t.response.id);let r=t.response?.id??t.response_id??(e.delegation_id?j.get(e.delegation_id):void 0);if(!r)break;let s=k.get(r);if(s||(s={calls:new Map,terminal:!1,continued:!1},k.set(r,s)),s.stale&&!rb.includes(t.type)&&(s.stale=!1,s.terminal=!1),"response.reasoning_summary_text.done"===t.type&&n.reasoning?.({id:`${t.item_id}:${t.summary_index??0}`,text:t.text??"",seq:m}),("response.output_item.added"===t.type||"response.output_item.done"===t.type)&&t.item?.type===rg.LIVE_HOSTED_TOOLS.webSearch.item){let e=t.item,s="response.output_item.done"===t.type;s&&rf.debug("Live web search",e),n.search?.({id:e.id,responseId:r,query:(e.action?.query??e.action?.queries?.join(" · "))?.trim()||null,sources:[...new Set((e.action?.sources??[]).flatMap(e=>e.url?[e.url]:[]))].map(e=>({url:e})),done:s,seq:m})}if("response.output_item.done"===t.type&&t.item?.type==="message"){let e=function(e){let t=new Map;for(let n of e??[])for(let e of n.annotations??[])"url_citation"===e.type&&e.url&&!t.has(e.url)&&t.set(e.url,{url:e.url,...e.title?{title:e.title}:{}});return[...t.values()]}(t.item.content);e.length&&n.cited?.(r,e)}if("response.output_item.done"===t.type&&t.item?.type==="function_call"){let e=t.item;if(b.has(e.call_id))break;if(b.add(e.call_id),"incomplete"===e.status){s.terminal=!0,rf.warn("Live backend call cut off; not run",{responseId:r,name:e.name,arguments:e.arguments.slice(0,200)}),s.calls.size&&!v?(v=!0,F(s)):s.continued=!0;break}n.turn({id:e.id,role:"tool",tool:e.name,text:e.arguments,seq:m,done:!0}),M(),N.set(e.call_id,e.name);let a=Promise.resolve().then(()=>n.runTool({id:e.call_id,name:e.name,arguments:e.arguments,item:e.id})).catch(e=>`Error: ${(0,S.errorToString)(e)}`).then(t=>{N.delete(e.call_id),p||h||z.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"function_call_output",call_id:e.call_id,output:t}}),I()});s.calls.set(e.call_id,a),F(s)}rb.includes(t.type)&&(s.terminal=!0,s.stale=!1,"response.completed"===t.type?(v=!1,rf.debug("Live backend usage",{responseId:r,usage:t.response?.usage}),F(s)):"response.incomplete"===t.type&&s.calls.size&&!v?(v=!0,rf.warn("Live backend response incomplete; continuing once",{responseId:r}),F(s)):(v=!1,s.continued=!0,n.warn(t.response?.error?.message??`The Live backend ${t.type.slice(9)}.`)))}}I()}},dropped:C}});return{async connect(){t.element.muted=!1;let e=new Promise((e,t)=>{r=e,s=t});e.catch(()=>{});let n=setTimeout(()=>C("OpenAI Live did not start in time."),R.LIVE_CALL.startupMs);try{if(await Promise.all([z.connect(),e]),p)throw Error("The Live call closed during startup.");o=setInterval(I,100)}catch(e){throw _(),e}finally{clearTimeout(n),s=void 0}},close:()=>l||(p?Promise.resolve():(h=!0,M(),d)?(l=new Promise(e=>{a=e}),i=setTimeout(()=>{n.warn("Live disconnected without confirming final session usage."),_()},R.LIVE_CALL.closeMs),t.element.muted=!0,z.send({type:"session.close",event_id:crypto.randomUUID()}),l):(_(),Promise.resolve())),append(e,t){let n=function(e){let t=[],n="",r=0,s=e=>{let s=ry.encode(e).length;if(r+s>480&&n&&(t.push(n),n="",r=0),s<=480){n+=e,r+=s;return}for(let s of e){let e=ry.encode(s).length;r+e>480&&(t.push(n),n="",r=0),n+=s,r+=e}};for(let t of e.split(/(?<=\s)/))s(t);return n&&t.push(n),t}(t);return p||h||!n.length?Promise.resolve(!1):new Promise(t=>{T.push({kind:e,chunks:n,settle:t}),O()})},brief(e){let t=e.trim();p||h||!t||z.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"developer",content:[{type:"input_text",text:t}]}})}}};var rv=e.i(567334);let rj=["NIGHT","G'NIGHT","NITE","SLEEP ♥","ZZZ","BYE"],rS=[[22,rj],[17,["BYE","SEE YA","LATER","SO LONG","BYE ♥","CIAO"]],[11,["BYE","SEE YA","LATER","CIAO","BYE BYE","PEACE"]],[5,["ENJOY!","SEE YA","BYE","LATER","CIAO"]],[0,rj]],rN=(e,t)=>({text:e,at:Date.now(),hold:t});function rT(e=new Date){let t,n=e.getHours();return rN((t=rS.find(([e])=>n>=e)?.[1]??["BYE"])[Math.floor(Math.random()*t.length)],1.6)}let rE=()=>rN("OK",1);e.s(["awake",0,()=>rN("HI",1.6),"finished",0,rE,"goodbye",0,rT],114923);let rA=(0,ng.createServerReference)("7f6f647d71d168e1e9bcdac5ca8738873ff04c8b71",ng.callServer,void 0,ng.findSourceMapURL,"openCallAction"),rM=(0,ng.createServerReference)("7fec677a08d594109570e284dc801a4880a176afd0",ng.callServer,void 0,ng.findSourceMapURL,"saveThoughtAction"),r_=(0,ng.createServerReference)("7fd137568a222ac055b58f659b4a8b13dc549abcf8",ng.callServer,void 0,ng.findSourceMapURL,"saveTurnsAction");class rC extends Error{}let rL=Array(ni.SPECTRUM_BANDS).fill(0),rR=!1;function rI(e){let t=e.replace(/\[[^\]]*\]?|\]/g,"").trim();return/[\p{L}\p{N}]/u.test(t)?t:""}function rO(e,t,n="This call is not being saved"){e.failures>=R.CALL_PAGE.saveFailures||t().then(e=>(0,ny.unwrapResult)(e)).catch(t=>{e.failures+=1,e.failures===R.CALL_PAGE.saveFailures&&nm.toast.add({type:"warning",title:n,description:(0,S.errorToString)(t)})})}var rD=e.i(672203);let rP=new Intl.Segmenter(void 0,{granularity:"grapheme"}),rF=e=>Array.from(rP.segment(e)).length;function rz({text:e,animate:t}){let{shown:n,links:s}=(0,b.useMemo)(()=>{let t=[],n="",r=0;for(let s of e.matchAll(S.MARKDOWN_LINK)){let a=rF(n+=e.slice(r,s.index));n+=s[1],t.push({from:a,to:rF(n),href:s[2]}),r=s.index+s[0].length}return{shown:n+e.slice(r),links:t}},[e]);if(t)return(0,r.jsx)(A,{text:n,wraps:s.map(e=>({from:e.from,to:e.to,render:t=>(0,r.jsx)(rB,{href:e.href,children:t})}))});let a=Array.from(rP.segment(n),e=>e.segment),l=[],i=0;for(let e of s)l.push(a.slice(i,e.from).join("")),l.push((0,r.jsx)(rB,{href:e.href,children:a.slice(e.from,e.to).join("")},e.from)),i=e.to;return l.push(a.slice(i).join("")),(0,r.jsx)(r.Fragment,{children:l})}let r$="pointer-events-auto underline decoration-current/35 underline-offset-4 transition-colors hover:decoration-current";function rB({href:e,children:t}){let[n]=(0,nw.useServerAction)(rD.openFileAction);if(/^https?:\/\//i.test(e))return(0,r.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",className:r$,onClick:e=>e.stopPropagation(),children:t});let s=(0,nz.workspaceRelative)(e);return s?(0,r.jsx)("a",{href:k.queryKey.fileView(s),className:r$,onClick:t=>{t.preventDefault(),t.stopPropagation();let r=(0,n$.fileTarget)(e);"os"===r.how?n(e):J.fileOpens.open(r.path)||window.open(k.queryKey.fileView(r.path),"_blank")},children:t}):t}var rq=e.i(174080),rU=e.i(877267);let rK="700 9px ui-monospace, SFMono-Regular, Menlo, monospace",rH=Math.ceil(13.5);function rW(e){let t=document.createElement("canvas");t.width=rH*e.length,t.height=rH;let n=t.getContext("2d");return n?(n.textAlign="center",n.textBaseline="middle",n.font=rK,e.forEach((e,t)=>{n.fillText(e,t*rH+rH/2,rH/2)}),t):null}function rG({status:e}){let t=(0,b.useRef)(null),n=(0,b.useRef)(null),s=(0,b.useRef)(e),[a,l]=(0,b.useState)(!1),i=(0,b.useRef)(null);return(0,b.useEffect)(()=>{"emoji"===(0,rU.faceGlyphs)()&&(i.current=rW(rv.EMOJI_POOL))},[]),(0,b.useEffect)(()=>{let t=s.current;s.current=e,"connecting"!==t||"connecting"===e||"idle"===e||"ending"===e||window.matchMedia("(prefers-reduced-motion: reduce)").matches||l(!0)},[e]),(0,b.useEffect)(()=>{let e=n.current,r=t.current?.getBoundingClientRect();if(!a||!e||!r)return;let s=window.innerWidth,o=window.innerHeight,u=r.left+r.width/2,c=r.top+r.height/2,d=Math.hypot(Math.max(u,s-u),Math.max(c,o-c)),h=Math.ceil(s/11),p=Math.ceil(o/11),m=[];for(let e=0;e<p;e++)for(let t=0;t<h;t++){if((0,rv.hash)(t+53,e+5)>.4)continue;let n=11*t+5.5,r=11*e+5.5,s=Math.atan2(r-c,n-u),a=(0,rv.hash)(t+31,e+17),l=Math.hypot(n-u,r-c)/d*(1+.1*Math.sin(3*s+1.3)+.05*Math.sin(7*s-.7)+(a-.5)*.1);l<.1||m.push({x:n,y:r,dd:l,seed:(0,rv.hash)(t,e),grain:a,speck:(0,rv.hash)(t+7,e+101)})}m.sort((e,t)=>e.dd-t.dd);let f=e=>{let t=0,n=m.length;for(;t<n;){let r=t+n>>1;m[r].dd<e?t=r+1:n=r}return t};e.width=s,e.height=o;let g=e.getContext("2d"),x="letters"===(0,rU.faceGlyphs)(),y=x?null:i.current??rW(rv.EMOJI_POOL);if(!g||!x&&!y)return;x&&(g.textAlign="center",g.textBaseline="middle",g.font=rK,g.fillStyle=getComputedStyle(e).color);let w=rv.LEVELS-1,b=x?rv.CHAR_RATE:rv.EMOJI_CHAR_RATE,k=rH/2,v=performance.now(),j=0,S=0,N=()=>{let e=(performance.now()-v)/1e3;if(e>1.9736842105263157)return l(!1);if(S=requestAnimationFrame(N),j++%2)return;let t=.95*e;g.clearRect(0,0,s,o);for(let n=f(t-.2-.475);n<m.length;n++){let r=m[n],s=t-r.dd;if(s<-.03)break;let a=(0,rv.smoothstep)(-.03,.02,s)*(1-(0,rv.smoothstep)(.02,.2,s))*(.72+.28*Math.sin(46*r.dd-7*e+6.283*r.seed));if(r.speck<.06){let e=.18+.32*r.grain,t=(s-.2)/.95;a=Math.max(a,(.3+.4*r.grain)*(1-(0,rv.smoothstep)(.4*e,e,t)))}let l=Math.round(a*w);if(l<1)continue;let i=Math.floor(e*b+10*r.seed);if(y){g.globalAlpha=(0,rv.emojiAlpha)(l,w);let e=Math.floor((0,rv.hash)(97*r.seed,i)*rv.EMOJI_POOL.length);g.drawImage(y,e*rH,0,rH,rH,r.x-k,r.y-k,rH,rH);continue}g.globalAlpha=rv.ALPHA_TOP*(l/w);let o=rv.RAMP[l];g.fillText(o[Math.floor((0,rv.hash)(131*r.seed,i)*o.length)],r.x,r.y)}g.globalAlpha=1};return S=requestAnimationFrame(N),()=>cancelAnimationFrame(S)},[a]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{ref:t,"aria-hidden":!0,className:"pointer-events-none absolute inset-0"}),a&&(0,rq.createPortal)((0,r.jsx)("canvas",{ref:n,"aria-hidden":!0,className:"pointer-events-none fixed inset-0 z-30 size-full text-foreground"}),document.body)]})}var rY=e.i(333495);function rV(e){let t=[];for(let n of e){let e=t.at(-1);e?.role!==n.role||n.fresh?t.push({id:n.id,role:n.role,text:n.text}):e.text=`${e.text} ${n.text}`}return t}let rJ={assistant:null,user:null};function rX(e,t){let[n,r]=(0,b.useState)(rJ);return(0,b.useEffect)(()=>{t||r(rJ)},[t]),(0,b.useEffect)(()=>{if(!t)return;let e=e=>{"ArrowDown"!==e.key||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(0,W.windowKey)(e)&&(e.preventDefault(),r(rJ))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),{pinned:n,pick:(0,b.useCallback)((t,n)=>{let s=e.filter(e=>e.role===t).length-1;r(e=>({...e,[t]:n>=s?null:n}))},[e]),back:null!==n.assistant||null!==n.user}}let rZ="(under)";function rQ({turns:e,pinned:t,live:n,onPick:s,under:a=null,ahead:l=!1,workOf:i,typed:o=!1}){let u=e.at(-1);return(0,r.jsx)(r.Fragment,{children:["assistant","user"].map(c=>(0,r.jsx)(r0,{role:c,turns:e.filter(e=>e.role===c),pinned:t[c],saying:n?u?.id:void 0,onPick:e=>s(c,e),under:"assistant"===c?a:null,ahead:"assistant"===c&&l,workOf:"assistant"===c?i:void 0,whole:o&&"user"===c},c))})}function r0({role:e,turns:t,pinned:n,saying:s,onPick:a,under:l,ahead:i,workOf:o,whole:u}){let c="user"===e,[d,h]=(0,b.useState)({}),p=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>p.current?.disconnect(),[]);let m=(0,b.useCallback)(e=>{if(e)return p.current??=new ResizeObserver(e=>{h(t=>{let n=t;for(let r of e){let e=r.target,s=e.dataset.turn;s&&t[s]!==e.offsetHeight&&(n===t&&(n={...t}),n[s]=e.offsetHeight)}return n})}),p.current.observe(e),()=>p.current?.unobserve(e)},[]),f=t.length-1,g=null===n&&(i||!t.length)?t.length:Math.min(n??f,f),x=(0,b.useRef)(null);if((0,b.useEffect)(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[t[g]?.text]),!t.length&&!l)return null;let y=e=>1150/(1150+700*Math.abs(e-g)),w=e=>e===g?1:.78,k=e=>(d[t[e].id]??28.475)*y(e)*w(e),v=g===t.length?l:o?.(t[g].id)??null,j=Array(t.length+1).fill(0);j[g]=-28.475/2;for(let e=g-1;e>=0;e--)j[e]=j[e+1]-49-k(e);let N=v&&g<t.length?(d[rZ]??0)+8:0;for(let e=g+1;e<t.length;e++)j[e]=j[e-1]+k(e-1)+49+(e-1===g?N:0);let T=v?g===t.length?j[g]:j[g]+(d[t[g].id]??28.475)+8:null;return(0,r.jsxs)("div",{className:(0,S.cn)("pointer-events-none absolute h-0 w-[min(21.25rem,24vw)]",c?"left-full ml-[calc(var(--face-bleed,0px)+0.375rem)] [perspective-origin:0_0]":"right-full mr-[calc(var(--face-bleed,0px)+0.375rem)] [perspective-origin:100%_0]"),style:{top:"calc(50% + -40px)",perspective:1150},children:[t.map((e,n)=>{let l=Math.abs(n-g),i=n<g?g-n<=2:n-g<=2,o=n===g,d=i?o?1:.56*.6**(l-1):0,h=i&&!o,p=14*l*(c?-1:1)/y(n),f=j[n]/y(n);return(0,r.jsx)("div",{ref:m,"data-turn":e.id,"aria-hidden":!i,onClick:h?()=>a(n):void 0,style:{transform:`translate(${p.toFixed(1)}px, ${f.toFixed(1)}px) translateZ(${-700*l}px) scale(${w(n)})`,"--ink":d,"--lift":Math.max(d,.9)},className:(0,S.cn)("group/turn absolute top-0 w-max max-w-full text-[17px] leading-[1.675] tracking-[0.3px] text-foreground transition-transform duration-[520ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&n===t.length-1&&"animate-in fade-in duration-200 motion-reduce:animate-none",c?"left-0 origin-top-left":"right-0 origin-top-right",!i&&"invisible",h&&"pointer-events-auto cursor-pointer",o&&"pointer-events-auto"),children:(0,r.jsxs)("p",{ref:o?x:void 0,className:(0,S.cn)("break-keep wrap-anywhere text-pretty whitespace-pre-line opacity-(--ink) transition-opacity duration-[520ms] motion-reduce:transition-none",!o&&"line-clamp-4",o&&"overflow-y-auto overscroll-contain scrollbar-none",h&&"group-hover/turn:opacity-(--lift)"),style:o?{maxHeight:284.75}:void 0,children:[o&&(0,r.jsx)("span",{className:(0,S.cn)("mr-4 inline-block size-2.5 rounded-full align-middle",e.id===s?"animate-pulse motion-reduce:animate-none":"opacity-55",c?"bg-foreground":"bg-brand")}),(0,r.jsx)(rz,{text:e.text,animate:n===t.length-1&&!u})]})},e.id)}),v&&(0,r.jsx)("div",{ref:m,"data-turn":rZ,style:{transform:`translateY(${(T??0).toFixed(1)}px)`},className:"absolute inset-x-0 top-0 transition-transform duration-[520ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",children:v})]})}e.s(["SideCaptions",0,rQ,"turnsOf",0,rV,"useTurnFocus",0,rX],435135);var r1=e.i(454263);let r2=["▁▄▇▄","▂▆▆▂","▄▇▄▁","▆▆▂▂","▇▄▁▄","▆▂▂▆","▄▁▄▇","▂▂▆▆"];function r5({live:e,ringing:t}){let{owed:n}=tN(),r=ne(Object.values(nt()).map(e=>e??null)),s="waiting"===r?null:r;return(0,b.useEffect)(()=>{let r=t?`${R.APP_NAME} is calling`:R.APP_NAME,s=n>0?`(${n}) ${r}`:r;if(!e){document.title=s;return}let a=0;document.title=`${s} ${r2[a]}`;let l=setInterval(()=>{a=(a+1)%r2.length,document.title=`${s} ${r2[a]}`},100);return()=>clearInterval(l)},[e,n,t]),(0,b.useEffect)(()=>{let e=document.head.querySelector("link[data-tab-icon]");e||((e=document.createElement("link")).rel="icon",e.type="image/svg+xml",e.setAttribute("sizes","any"),e.dataset.tabIcon="",document.head.append(e)),e.href=`data:image/svg+xml,${encodeURIComponent(function(e){let{head:t,eyes:n}=(0,r1.markAtRest)(H.THURSDAY_SEED),r=e?`<circle cx="200" cy="200" r="${66}"/>`:"",s=e?`<circle class="${e}" cx="200" cy="200" r="46"/>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 252 252"><style>.ink{fill:#0a0a0a}.red{fill:#e7000b}@media (prefers-color-scheme:dark){.ink{fill:#fafafa}.red{fill:#ff6467}}</style><mask id="m" maskUnits="userSpaceOnUse"><path d="${t}" fill="#fff"/><path d="${n[0]}"/><path d="${n[1]}"/>${r}</mask><path class="ink" d="${t}" mask="url(#m)"/>${s}</svg>`}(s))}`},[s]),null}let r3={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]};r3.node;let r4=(0,l.default)(r3);var r6=e.i(96892),r7=e.i(64801),r9=e.i(59377),r8=e.i(184762),se=e.i(146538);let st=(0,ng.createServerReference)("7f3915d3eeea5d7f779f25cc0cc886151fc9db441e",ng.callServer,void 0,ng.findSourceMapURL,"startThreadAction");var sn=e.i(553429),sr=e.i(709190);let ss={name:sn.ROOM_THURSDAY,description:"A call in writing — she answers here"},sa=e=>/^@(\S*)$/.exec(e.split(/\s/,1)[0]);function sl({written:e,onCall:t=!1}){let{data:n}=(0,V.useServerRoute)(k.queryKey.bot),s=(0,b.useMemo)(()=>[...e?[ss]:[],...n?.length?n.filter(e=>!e.disabled).map(({name:e,icon:t,description:n})=>({name:e,icon:t,description:n})):[D.DEFAULT_BOT]],[n,e]),[l,i]=(0,b.useState)(!1),[o,u]=(0,b.useState)(!1),[c,d]=(0,b.useState)(!1),[h,p]=(0,b.useState)(""),m=(0,b.useRef)(t);m.current=t;let f=(0,sr.useGivenFiles)({onKept:e=>{if(m.current)return J.screenActs.announce({kind:"gave",paths:e}),"she knows it is here"}}),g=(0,b.useRef)(null),x=(0,b.useRef)(null),y=!!e?.on,[w,j]=(0,b.useState)(null);(0,b.useEffect)(()=>{y||j(null)},[y]);let N=s.find(e=>e.name===w)??(e?ss:s[0]),T=N===ss,E=nl(),A=(0,b.useCallback)(()=>{E||(i(!0),requestAnimationFrame(()=>g.current?.focus()))},[E]),M=(0,J.useRoomOpen)(),{take:_}=f,C=(0,b.useCallback)(e=>{J.writeLine.open(),_(e)},[_]);(0,b.useEffect)(()=>J.writeLine.subscribe(A),[A]),(0,b.useEffect)(()=>{if("thread"===M)return;let e=e=>{"/"!==e.key||e.metaKey||e.ctrlKey||e.altKey||(0,W.windowKey)(e)&&(e.preventDefault(),J.writeLine.open())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[M]),(0,b.useEffect)(()=>{if(E)return;let e=e=>!!e.dataTransfer?.types.includes("Files"),t=t=>{e(t)&&(t.preventDefault(),d(!0))},n=e=>{null===e.relatedTarget&&d(!1)},r=t=>{if(!e(t))return;t.preventDefault(),d(!1);let n=[...t.dataTransfer?.files??[]];sr.roomDrop.offer(t.target,n)||C(n)};return window.addEventListener("dragover",t),window.addEventListener("dragleave",n),window.addEventListener("drop",r),()=>{window.removeEventListener("dragover",t),window.removeEventListener("dragleave",n),window.removeEventListener("drop",r)}},[C,E]);let[L,R]=(0,nw.useServerAction)(st,{onOk:({id:e})=>{(0,V.revalidate)(k.queryKey.threads),p(""),f.clear(),i(!1),j(null),J.roomOpens.open(e)}}),[I,O]=(0,b.useState)(0),[P,F]=(0,b.useState)(!1),z=e=>{u(!1),p(e=>sa(e)?e.replace(/^@\S*\s?/,""):e),O(0),g.current?.focus(),j(e.name===ss.name?null:e.name)},$=P?null:sa(h),B=$?s.filter(e=>e.name.toLowerCase().startsWith($[1].toLowerCase())):s,q=B.length?I%B.length:0,[U,K]=(0,b.useState)(!1),H=R||U,G=!!h.trim()&&!$&&!f.arriving&&!H&&!(T&&!e?.runsOn),Y=()=>{if(!G)return;let t=f.withPaths(h);T?e&&(K(!0),e.say(t).then(()=>{p(""),f.clear()}).catch(()=>{}).finally(()=>K(!1))):L(N.name,t)},X=()=>{if(w)return j(null);y&&e?.end(),i(!1)},Z=(0,b.useRef)(t);(0,b.useEffect)(()=>{let e=t&&!Z.current;Z.current=t,!e||h.trim()||f.files.length||i(!1)},[t,h,f.files.length]);let Q=(l||c||y)&&!M;(0,W.useEscape)(Q,X);let ee=R||U;(0,b.useEffect)(()=>{Q&&!ee&&g.current?.focus()},[Q,ee]),(0,b.useEffect)(()=>(J.writeLine.shown(Q),()=>J.writeLine.shown(!1)),[Q]);let et=y&&!!M;(0,b.useEffect)(()=>(J.writeLine.waits(et),()=>J.writeLine.waits(!1)),[et]);let en=ed(),[er,es]=(0,b.useState)(Q);return((0,b.useEffect)(()=>{if(Q)return void es(!0);let e=setTimeout(()=>es(!1),200);return()=>clearTimeout(e)},[Q]),er)?(0,r.jsxs)(r.Fragment,{children:[c&&(0,r.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-0 bg-background/60",children:(0,r.jsx)("div",{className:"absolute inset-3 rounded-3xl border-[1.5px] border-dashed border-foreground/30"})}),(0,r.jsx)("div",{className:"col-start-2 row-start-1 flex min-w-0 items-end justify-center",children:(0,r.jsxs)("div",{className:(0,S.cn)("flex w-160 max-w-full flex-col gap-2",Q?"pointer-events-auto animate-in duration-200 fade-in slide-in-from-bottom-2":"pointer-events-none animate-out duration-200 fade-out fill-mode-forwards slide-out-to-bottom-2"),children:[en.length>0&&(0,r.jsxs)("div",{className:"rounded-3xl bg-background/78 p-1.5 shadow-sm shadow-black/3 ring-1 ring-border/50 backdrop-blur-md",children:[(0,r.jsxs)("p",{className:"px-3 pt-1 pb-1 font-mono text-[10px] tracking-wide text-muted-foreground",children:[en.length," ",1===en.length?"needs":"need"," a reply"]}),(0,r.jsx)("div",{className:"max-h-[30vh] overflow-y-auto",children:en.map(e=>(0,r.jsx)(eb,{thread:e,lines:2,onPick:()=>J.roomOpens.open(e.id)},e.id))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 rounded-[26px] bg-background p-2 shadow-[0_22px_44px_-20px_rgb(0_0_0/0.22)] ring-1 ring-border",children:[(f.files.length>0||c)&&(0,r.jsx)(sr.GivenFiles,{files:f.files,onRemove:f.remove,className:"px-0.5 pt-0.5",children:c&&(0,r.jsxs)("span",{className:"flex h-13 items-center gap-2 rounded-[14px] border-[1.5px] border-dashed border-foreground/60 px-4 text-[13px]",children:[(0,r.jsx)(r4,{className:"size-4"}),"Let go — it waits here"]})}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),Y()},className:"flex items-end gap-2",children:[(0,r.jsxs)(r9.Popover,{open:o||!!$,onOpenChange:u,children:[(0,r.jsxs)(r9.PopoverTrigger,{render:(0,r.jsx)("button",{type:"button","aria-label":`To ${N.name}. Choose someone else`,className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-muted pr-2.5 pl-1.5 text-[13px] font-medium outline-none transition-colors hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50"}),children:[(0,r.jsx)(sc,{bot:N,size:22}),N.name,(0,r.jsx)(a.ChevronDown,{className:"size-3 text-muted-foreground"})]}),(0,r.jsxs)(r9.PopoverContent,{side:"top",align:"start",sideOffset:14,initialFocus:!$&&void 0,className:"w-90 gap-0 rounded-[18px] p-1.5",children:[(0,r.jsx)("p",{className:"px-2.5 pt-1.5 pb-1 font-mono text-[10px] text-muted-foreground",children:"to"}),B.map((e,t)=>(0,r.jsxs)("button",{type:"button",onClick:()=>z(e),className:(0,S.cn)("flex h-11.5 w-full items-center gap-2.5 rounded-xl px-2.5 text-left outline-none hover:bg-muted focus-visible:bg-muted",($?t===q:e.name===N.name)&&"bg-muted"),children:[(0,r.jsx)(sc,{bot:e,size:24}),(0,r.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.jsx)("span",{className:"text-[13.5px] leading-4.5 font-medium",children:e.name}),(0,r.jsx)("span",{className:"truncate text-xs leading-4 text-muted-foreground",children:e.description})]})]},e.name)),0===B.length&&(0,r.jsx)("p",{className:"px-2.5 py-2 text-[13px] text-muted-foreground",children:"Nobody by that name."})]})]}),(0,r.jsx)(r8.Textarea,{ref:g,value:h,rows:1,disabled:R||U,onChange:e=>{let t=e.target.value;p(t),O(0),sa(t)||F(!1)},onPaste:e=>{let t=[...e.clipboardData.files];t.length&&(e.preventDefault(),C(t))},onKeyDown:e=>{let t=(0,W.composing)(e);if("Escape"===e.key&&!t)return(e.preventDefault(),$)?F(!0):X();let n="ArrowDown"===e.key||"ArrowUp"===e.key;if($&&n&&!t){let t;return e.preventDefault(),t="ArrowDown"===e.key?1:-1,O(e=>B.length?(e+t+B.length)%B.length:0)}if("Enter"===e.key&&!e.shiftKey&&!t){if(e.preventDefault(),$){B[q]&&z(B[q]);return}Y()}},placeholder:f.files.length?"Say what to do with them":y&&T?"Write back":T?"Write to her instead of calling":`Say the whole job — ${N.name} cannot hear the call`,"aria-label":`Message for ${N.name}`,className:"max-h-36 min-h-9 flex-1 resize-none border-0 bg-transparent px-0 py-1.5 text-[15px] leading-6 shadow-none focus-visible:ring-0 dark:bg-transparent"}),(0,r.jsx)("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:e=>{C([...e.target.files??[]]),e.target.value=""}}),(0,r.jsx)("button",{type:"button","aria-label":"Add files",onClick:()=>x.current?.click(),className:"grid size-9 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:(0,r.jsx)(r7.Paperclip,{className:"size-4"})}),(0,r.jsx)("button",{type:"submit","aria-label":"Send",disabled:!G,className:(0,S.cn)("grid size-9 shrink-0 place-items-center rounded-full outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50",G?"bg-primary text-primary-foreground hover:bg-primary/85":"bg-muted text-muted-foreground/40"),children:H?(0,r.jsx)("span",{className:"size-3.5 animate-spin rounded-full border-2 border-current/30 border-t-current"}):(0,r.jsx)(r6.ArrowUp,{className:"size-4"})})]})]}),T&&e?.error&&(0,r.jsx)("p",{className:"px-4 text-center text-xs leading-5 text-destructive",children:e.error}),T&&e?.error&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,r.jsxs)(v.Button,{type:"button",size:"sm",variant:"brand",disabled:e.busy,onClick:()=>{e.fallback&&nc.useThursdayStore.getState().patch({textModel:e.fallback}),e.again()},children:[(0,r.jsx)(eT.RotateCw,{}),e.fallback?"Send it again on your OpenAI key":"Send it again"]}),(0,r.jsx)("span",{className:"font-mono text-[10.5px] text-muted-foreground/70",children:(0,r.jsx)(su,{children:"API keys"})})]}),(0,r.jsx)("p",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1 font-mono text-[10.5px] text-muted-foreground/70",children:$?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sd,{children:"↑↓"})," walk",(0,r.jsx)(so,{}),(0,r.jsx)(sd,{children:"Enter"})," take",(0,r.jsx)(so,{}),(0,r.jsx)(sd,{children:"Esc"})," close the list"]}):(0,r.jsxs)(r.Fragment,{children:[T&&!e?.runsOn?(0,r.jsx)(si,{runsOn:null}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sd,{children:"Enter"})," send",(0,r.jsx)(so,{}),(0,r.jsx)(sd,{children:"@"})," ",T?"a bot":"pick a bot",T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(so,{}),(0,r.jsx)(si,{runsOn:e?.runsOn??null})]})]}),(0,r.jsx)(so,{}),(0,r.jsx)(sd,{children:"Esc"})," ",y?T?"to end":"back to her":"close"]})})]})})]}):null}function si({runsOn:e}){let t=O.TEXT_MODEL_PROVIDERS.chatgpt.label,n=(0,r.jsx)(se.ModelPicker,{compact:!0,provider:e?.provider??null,model:e?.model??"",unset:"pick a model",onChange:e=>nc.useThursdayStore.getState().patch({textModel:e})});return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"runs on"}),n]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{children:["Writing to her needs a ",t,", an OpenAI key, or"]}),n,(0,r.jsx)(so,{}),(0,r.jsx)(su,{children:"API keys"})]})}let so=()=>(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"});function su({children:e}){return(0,r.jsx)("button",{type:"button",onClick:()=>(0,tP.openSettings)("keys"),className:"rounded-sm text-foreground/80 underline underline-offset-3 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:e})}function sc({bot:e,size:t}){return e===ss?(0,r.jsx)(H.ThursdayMark,{size:t,className:"shrink-0"}):(0,r.jsx)(P.BotMark,{size:t,seed:e.name,color:e.icon?.color,shape:e.icon?.shape,outline:e.icon?.outline,paint:e.icon?.paint,notify:!1,className:"shrink-0"})}function sd({children:e}){return(0,r.jsx)("kbd",{className:"rounded-md border border-border bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground/80 shadow-[0_1px_0_var(--border)]",children:e})}function sh({status:e,failed:t=!1,messages:n,tool:s,thinkingSince:a=null,thinkingTitle:l=null,ended:i=null,faceWord:o=null,onTap:u,ringing:c=null,onDecline:d,wakePhrase:h=null,hotkeyLabel:p=null,idleLeft:m=null,since:f=null,getSpectrum:g,getMicSpectrum:x,captionView:y="sides",callable:w=!0,written:k=null}){var v;let[j,N]=(0,b.useState)(!1),T=!w&&"idle"===e,E="connecting"===e||"ending"===e,A=!!k?.on,M="idle"!==e&&!E&&!A,_=n.findLast(e=>"assistant"===e.role)?.text??"",C=(v=sg,(0,b.useSyncExternalStore)(e=>{let t=window.matchMedia(`(min-width: ${v}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia(`(min-width: ${v}px)`).matches,()=>!0)),L="sides"===y&&"idle"!==e&&C,I=(0,b.useMemo)(()=>rV(n),[n]),O=rX(I,L),D=I.at(-1)?.role,P=function(e,t){let[n,r]=(0,b.useState)(e),s=(0,b.useRef)(e?[e]:[]),a=(0,b.useRef)(Date.now()),l=(0,b.useRef)(!1),i=(0,b.useRef)(null),o=(0,b.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=null,(s.current.length>1||l.current)&&s.current.length&&(i.current=setTimeout(()=>{s.current.shift(),a.current=Date.now(),r(s.current[0]??null),o()},Math.max(0,a.current+R.CALL_LINE.dwellMs-Date.now())))},[]);return(0,b.useEffect)(()=>{if(!e){l.current=!0,s.current.length<=1&&(s.current=[],r(null)),o();return}l.current=!1;let t=s.current.findIndex(t=>t.id===e.id);t>=0?(s.current[t]=e,0===t&&r(e)):(s.current=[...s.current.map((e,t)=>0===t?e:{...e,done:!0}),e],1===s.current.length&&(a.current=Date.now(),r(e))),o()},[e,o]),(0,b.useEffect)(()=>{if(!t)return;let e=s.current.at(-1);s.current=e&&!l.current?[e]:[],a.current=Date.now(),r(s.current[0]??null),o()},[t,o]),(0,b.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]),n}(s,"speaking"===e),F=function(e,t){let n=null!==e||t,[r,s]=(0,b.useState)([]),[a,l]=(0,b.useState)(n);return(0,b.useEffect)(()=>{s(t=>{let n=t.some(e=>!e.done)?t.map(e=>e.done?e:{...e,done:!0}):t;if(!e)return n;let r=t.findIndex(t=>sE(t)===sE(e));return r>=0?t.map((t,n)=>n===r?e:t):[...n,e].slice(-4)})},[e]),(0,b.useEffect)(()=>{if(n)return void l(!0);let e=setTimeout(()=>{l(!1),s([])},300);return()=>clearTimeout(e)},[n]),{lines:r,on:n,held:a}}(P,null!==a),[z,$]=(0,b.useState)(!1);(0,b.useEffect)(()=>{"user"!==D?$(!1):F.on&&$(!0)},[D,F.on]);let B=function(e,t,n){let[r,s]=(0,b.useState)(sA),a=e.findLast(e=>"assistant"===e.role),l=a?.id??null,i=a?`${a.id}:${a.text.length}`:null,o=!n&&e.at(-1)?.role==="assistant";(0,b.useEffect)(()=>{s(e=>{let n=e;for(let e of t){let t=sE(e),r=n.owner[t];if(void 0===r){let e=t in n.seen?n.seen[t]:i;if(t in n.seen||(n={...n,seen:{...n.seen,[t]:i}}),!l||e===i&&!o)continue;r=l,n={...n,owner:{...n.owner,[t]:r}}}let s=n.turns[r]??[],a=s.findIndex(e=>sE(e)===t);a>=0&&s[a]===e||(n={...n,turns:{...n.turns,[r]:a>=0?s.map((t,n)=>n===a?e:t):[...s,e]}})}return n})},[t,i,l,o]),(0,b.useEffect)(()=>{e.length||s(sA)},[e.length]);let u=(0,b.useMemo)(()=>t.filter(e=>void 0===r.owner[sE(e)]),[t,r.owner]);return{turns:r.turns,pending:u,latest:l}}(I,F.lines,F.on),q="assistant"===D&&"speaking"===e||"user"===D&&"listening"===e&&!A,U=null!==c&&null===c.missedAt,K=function(e){let[t,n]=(0,b.useState)(null);return(0,b.useEffect)(()=>{if(!e)return void n(null);let t=()=>n({...s_,at:Date.now()});t();let r=setInterval(t,2600);return()=>clearInterval(r)},[e]),t}(U),H=nl();return(0,r.jsxs)("div",{className:"relative flex h-full flex-col",inert:H,children:[(0,r.jsxs)("div",{className:"absolute top-5 right-5 z-10 flex flex-col items-end gap-3",children:[(0,r.jsx)(sx,{}),(0,r.jsx)(ts,{hidden:"idle"!==e||null!==c||A})]}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-5 pt-[7vh]",children:[(0,r.jsxs)("div",{className:"relative w-[min(20rem,52vw,37.5vh)] [--face-bleed:19.5%]",children:[(0,r.jsx)("button",{type:"button",disabled:E,onClick:T?()=>N(!0):A&&!w?void 0:u,"aria-label":T?"Add a speech key":M?"End the call":U?"Answer Thursday":"Call Thursday",className:(0,S.cn)("block w-full rounded-full outline-none transition-all duration-700 ease-out focus-visible:ring-3 focus-visible:ring-ring/50 enabled:active:scale-[0.99] disabled:opacity-70",T&&"opacity-35"),children:(0,r.jsx)("span",{className:"block",children:(0,r.jsx)(rY.Face,{status:e,failed:t,word:K??o,getSpectrum:g,covered:H,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"})})}),(0,r.jsx)(rG,{status:e}),L&&(0,r.jsx)(rQ,{turns:I,pinned:O.pinned,live:q,onPick:O.pick,under:F.held&&B.pending.length>0?(0,r.jsx)(sM,{lines:B.pending,shown:F.on}):null,ahead:z&&F.held&&B.pending.length>0,typed:A,workOf:e=>{let t=[...B.turns[e]??[],...e===B.latest&&"assistant"===D?B.pending:[]];return t.length?(0,r.jsx)(sM,{lines:t,shown:!0}):null}})]}),(0,r.jsxs)("div",{className:"relative flex w-full max-w-3xl flex-col items-center gap-2 px-6 text-center",children:[c&&(0,r.jsx)(sL,{ringing:c,wakePhrase:h,onAnswer:u,onDecline:()=>d?.()}),(0,r.jsxs)("div",{className:(0,S.cn)("contents",c&&"*:invisible"),children:[(0,r.jsx)(sN,{tool:L?null:P,toolUp:null!==P,thinkingSince:a,thinkingTitle:l,micOpen:!A&&("listening"===e||"working"===e||"delegating"===e),getMicSpectrum:x}),(0,r.jsx)(sy,{text:L||"idle"===e?"":_,fadeIn:!0,className:"w-full max-w-160 text-center text-base"}),(0,r.jsx)("div",{className:(0,S.cn)("flex flex-col items-center","idle"===e&&"order-first"),children:T?(0,r.jsx)(sq,{open:j,onOpen:()=>N(!0),onClose:()=>N(!1)}):A?(0,r.jsx)("span",{className:"h-6"}):(0,r.jsx)(sF,{status:e,idleLeft:m,since:f,ended:i,behind:L&&O.back,wakePhrase:h,hotkeyLabel:p})})]})]})]}),(0,r.jsxs)(sp,{children:[(0,r.jsx)(nB,{}),(0,r.jsx)(sl,{written:k,onCall:M}),(0,r.jsx)(e0,{})]})]})}function sp({children:e}){return(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] grid-rows-[minmax(0,1fr)_auto] items-end gap-x-4 gap-y-2 p-5",children:e})}let sm=["thursday","memory","bot"];function sf({alert:e}){return e?(0,r.jsx)("span",{"aria-hidden":!0,className:(0,S.cn)("absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2 ring-background","red"===e?"bg-destructive":"bg-waiting")}):null}let sg=1e3;function sx(){let e=nt(),t=ne(t6.filter(e=>!sm.includes(e.id)).map(t=>e[t.id]??null));return(0,r.jsxs)(L.TooltipProvider,{children:[(0,r.jsxs)(T,{className:"bg-background/75 backdrop-blur-md",children:[(0,r.jsx)(T,{children:sm.map(t=>{let n=t6.find(e=>e.id===t);return n?(0,r.jsxs)(L.Tooltip,{children:[(0,r.jsxs)(L.TooltipTrigger,{render:(0,r.jsx)(v.Button,{size:"icon",variant:"outline","aria-label":n.label,onClick:()=>(0,tP.openSettings)(t)}),children:[(0,r.jsx)(n.icon,{className:"text-muted-foreground"}),(0,r.jsx)(sf,{alert:e[t]??null})]}),(0,r.jsx)(L.TooltipContent,{side:"bottom",children:n.label})]},t):null})}),(0,r.jsx)(T,{children:(0,r.jsxs)(v.Button,{variant:"outline",onClick:()=>(0,tP.openSettings)(),className:"gap-1.5 px-2.5 text-[12.5px] font-normal",children:[(0,r.jsx)(y,{className:"text-muted-foreground"}),"Settings",(0,r.jsx)(sf,{alert:t})]})})]}),(0,r.jsx)(t8,{})]})}function sy({text:e,lines:t=3,fadeIn:n=!1,className:s}){let l=(0,b.useRef)(null),[i,u]=(0,b.useState)(t),[c,d]=(0,b.useState)(0),[h,p]=(0,b.useState)(e);h!==e&&(p(e),d(0)),(0,b.useEffect)(()=>{let e=l.current;if(!e)return;let t=()=>{let t=Number.parseFloat(getComputedStyle(e).lineHeight);t&&u(Math.max(1,Math.round(e.scrollHeight/t)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]);let m=Math.ceil(Math.max(0,i-t)/t),f=Math.max(0,i-t-Math.min(c,m)*t),g=`calc(${t} * 1.625em)`,x=(0,r.jsx)("p",{ref:l,style:{lineHeight:1.625,transform:`translateY(-${1.625*f}em)`},className:"break-keep wrap-anywhere whitespace-pre-line transition-transform duration-200",children:(0,r.jsx)(rz,{text:e,animate:n})});return(0,r.jsxs)("div",{className:"relative flex w-full justify-center",children:[(0,r.jsx)("div",{style:{height:g},onClick:m>0?()=>d(e=>e>=m?0:e+1):void 0,className:(0,S.cn)("overflow-hidden",m>0&&"cursor-pointer",s),children:x}),m>0&&(0,r.jsxs)("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 flex-col items-center gap-0.5",children:[(0,r.jsx)(sw,{look:o,label:"Earlier lines",shown:c<m,onPick:()=>d(e=>Math.min(m,e+1))}),(0,r.jsx)(sw,{look:a.ChevronDown,label:"Later lines",shown:c>0,onPick:()=>d(e=>Math.max(0,e-1))})]})]})}function sw({look:e,label:t,shown:n,onPick:s}){return(0,r.jsx)("button",{type:"button","aria-label":t,"aria-hidden":!n,tabIndex:n?void 0:-1,onClick:e=>{e.stopPropagation(),s()},className:(0,S.cn)("grid size-7 place-items-center rounded-full text-muted-foreground/60 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",!n&&"invisible"),children:(0,r.jsx)(e,{className:"size-3.5"})})}let sb=[{id:"a",from:0,to:1,gain:.8},{id:"b",from:1,to:3,gain:1},{id:"c",from:3,to:5,gain:1.15},{id:"d",from:5,to:6,gain:1.35},{id:"e",from:6,to:8,gain:1.55}];function sk({live:e,getMicSpectrum:t}){let n=(0,b.useRef)({}),s=(0,b.useRef)(sb.map(()=>0));return(0,b.useEffect)(()=>{if(!e||!t)return;let r=requestAnimationFrame(function e(){let a=t();sb.forEach((e,t)=>{let r=0;for(let t=e.from;t<e.to;t++)r=Math.max(r,a[t]??0);let l=Math.min(1,(r*e.gain)**.8),i=s.current[t],o=i+(l-i)*(l>i?.6:.16);s.current[t]=o;let u=n.current[e.id];u&&(u.style.height=`${2+12*o}px`)}),r=requestAnimationFrame(e)});return()=>cancelAnimationFrame(r)},[e,t]),(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-[18px] shrink-0 items-center gap-0.5",children:sb.map(e=>(0,r.jsx)("span",{ref:t=>{n.current[e.id]=t},style:{height:2},className:"w-0.5 rounded-full bg-muted-foreground/70"},e.id))})}function sv({live:e,getMicSpectrum:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] leading-5 text-muted-foreground",children:[(0,r.jsx)(sk,{live:e,getMicSpectrum:t}),"Listening"]})}function sj({tool:e}){let t="relay"===e.kind?c:(0,e2.toolIcon)(e.name),n=e.line??e.name,s=e.line?"min-w-0 truncate text-[13px] leading-5 break-keep":"min-w-0 truncate font-mono text-xs leading-5",a=(0,V.useServerRoute)(k.queryKey.bot).data,l=e.bot?a?.find(t=>t.name===e.bot)??null:null;return(0,r.jsxs)("span",{className:"flex max-w-full items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"relative grid size-[18px] shrink-0 place-items-center",children:[(0,r.jsx)(sS,{tool:e,bot:l,icon:t}),!e.done&&(0,r.jsx)("span",{className:"absolute inset-0 grid animate-ink place-items-center",children:(0,r.jsx)(sS,{tool:e,bot:l,icon:t,running:!0})})]}),e.done&&e.sources?.length?(0,r.jsx)(C.SourceChips,{sources:e.sources,limit:2,className:"flex-nowrap"}):e.done?(0,r.jsx)("span",{className:(0,S.cn)(s,"text-muted-foreground"),children:n}):(0,r.jsx)(_.ShinyText,{text:n,className:s})]})}function sS({tool:e,bot:t,icon:n,running:s}){return e.bot?(0,r.jsx)("span",{className:(0,S.cn)("flex",!s&&!e.done&&"opacity-40"),children:(0,r.jsx)(P.BotMark,{size:16,seed:e.bot,color:t?.icon?.color,shape:t?.icon?.shape,outline:t?.icon?.outline,paint:t?.icon?.paint,notify:!1})}):(0,r.jsx)(n,{className:(0,S.cn)("size-3.5",s?"text-foreground":"text-muted-foreground",!s&&!e.done&&"opacity-40")})}function sN({tool:e,toolUp:t,thinkingSince:n,thinkingTitle:s,micOpen:a,getMicSpectrum:l}){let[i,o]=(0,b.useState)(e);(0,b.useEffect)(()=>{e&&o(e)},[e]);let{thought:u,title:c}=function(e,t){let[n,r]=(0,b.useState)(null!==e),[s,a]=(0,b.useState)(t);return(0,b.useEffect)(()=>{null!==e&&(r(!0),a(t))},[e,t]),{thought:n,title:s}}(n,s),d=null!==e,h=null!==n&&!t,p=a&&!d&&!h,m=e=>a&&(0,r.jsx)(sk,{live:e,getMicSpectrum:l});return(0,r.jsx)("div",{className:"flex h-7 max-w-full items-center justify-center",children:(0,r.jsxs)("div",{className:"grid min-w-0 items-center justify-items-center",children:[i&&(0,r.jsx)(sD,{at:"col-start-1 row-start-1 max-w-full",shown:d,children:(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[m(d),(0,r.jsx)(sj,{tool:i})]})}),u&&(0,r.jsx)(sD,{at:"col-start-1 row-start-1 max-w-full",shown:h,children:(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[m(h),(0,r.jsx)(sU,{title:c})]})}),(0,r.jsx)(sD,{at:"col-start-1 row-start-1",shown:p,children:(0,r.jsx)(sv,{live:p,getMicSpectrum:l})})]})})}let sT=[1,.7,.45],sE=e=>e.id??`${e.kind??"tool"}:${e.name}`,sA={turns:{},owner:{},seen:{}};function sM({lines:e,shown:t}){let n=Math.max(0,e.length-3),s=e.length-n;return(0,r.jsx)("div",{"aria-hidden":!t,className:(0,S.cn)("pointer-events-auto relative w-full transition-opacity duration-300 ease-out",!t&&"pointer-events-none opacity-0"),style:{height:26*s},children:e.map((t,s)=>{let a=s-n;return(0,r.jsx)("div",{style:{transform:`translateY(${26*a}px)`,opacity:a<0?0:sT[e.length-1-s],height:26},className:"absolute inset-x-0 top-0 flex items-center transition-[transform,opacity] duration-300 ease-out motion-reduce:transition-none",children:(0,r.jsx)("div",{className:"flex min-w-0 animate-in duration-300 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",children:(0,r.jsx)(sj,{tool:t})})},sE(t))})})}let s_={text:"CALL",hold:1.5},sC="rounded-md border border-border bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground/80 shadow-[0_1px_0_var(--border)]";function sL({ringing:e,wakePhrase:t,onAnswer:n,onDecline:s}){let a=(0,V.useServerRoute)(k.queryKey.bot).data,l=(e,t)=>{let n=a?.find(t=>t.name===e.bot)?.icon;return(0,r.jsx)(P.BotMark,{size:t,seed:e.bot,color:n?.color,shape:n?.shape,outline:n?.outline,paint:n?.paint,notify:!1,className:"shrink-0"})},{first:i,others:o,missedAt:u}=e,[c,d]=(0,K.useAnswerThread)(),[h,p]=(0,b.useState)(null);if(null!==u){let e=[i,...o];return(0,r.jsxs)("div",{className:"absolute inset-x-0 -top-20 z-10 flex animate-in flex-col items-center px-6 fade-in duration-300",children:[(0,r.jsxs)("div",{className:"flex w-full max-w-140 flex-col text-left",children:[(0,r.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)(g,{className:"size-3"}),(0,r.jsxs)("span",{children:["Missed · ",(0,r.jsx)(sR,{at:u})]}),(0,r.jsxs)("button",{type:"button",onClick:s,className:"ml-auto flex items-center gap-1.5 rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)("kbd",{className:sC,children:"Esc"}),"clear"]})]}),e.slice(0,3).map(e=>(0,r.jsxs)("div",{className:"flex h-8.5 items-center gap-2.5",children:[l(e,20),(0,r.jsx)("span",{className:"w-32 shrink-0 truncate text-[13.5px]",children:e.label}),(0,r.jsx)("span",{className:"w-14 shrink-0 font-mono text-[10.5px] text-muted-foreground",children:sO[e.kind]}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px] text-muted-foreground",children:(0,S.plainText)(e.text)})]},e.id)),e.length>3&&(0,r.jsxs)("p",{className:"mt-1 font-mono text-[10.5px] text-muted-foreground/70",children:["+",e.length-3," more in the room"]})]}),(0,r.jsx)(v.Button,{variant:"brand",onClick:n,className:"mt-5 h-12 px-8 text-[15px]",children:"Call back"}),t&&(0,r.jsxs)("span",{className:"mt-3 flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground/70",children:["or say ",(0,r.jsx)(sI,{phrase:t})]})]})}return(0,r.jsxs)("div",{className:"absolute inset-x-0 -top-20 z-10 flex animate-in flex-col items-center gap-3 px-6 fade-in duration-300",children:[(0,r.jsxs)("span",{className:"flex max-w-full items-center gap-2 text-sm",children:[l(i,18),(0,r.jsx)("span",{children:i.bot}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:i.label})]}),(0,r.jsx)("p",{className:"line-clamp-3 max-w-150 text-base/relaxed text-pretty break-keep wrap-anywhere [@media(min-height:860px)]:line-clamp-5",children:(0,S.plainText)(i.text)}),i.options.length>0&&(0,r.jsx)("span",{className:"flex max-w-full flex-wrap justify-center gap-1.5",children:i.options.map(e=>(0,r.jsx)(v.Button,{size:"sm",variant:"secondary",loading:h===e,disabled:d,onClick:async()=>{p(e),await c(i,e,i.bot,i.questionId??void 0),p(null)},className:"h-7 max-w-60 rounded-full px-3 text-[12.5px]",children:(0,r.jsx)("span",{className:"truncate",children:e})},e))}),(0,r.jsx)(v.Button,{variant:"brand",onClick:n,className:"mt-3 h-12 px-8 text-[15px]",children:"Answer"}),o.length>0&&(0,r.jsxs)("span",{className:"flex max-w-full flex-wrap items-center justify-center gap-x-4.5 gap-y-1 text-[13px] text-muted-foreground",children:[o.slice(0,2).map(e=>(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[l(e,16),(0,r.jsx)("span",{className:"max-w-44 truncate text-foreground",children:e.label}),sO[e.kind]]},e.id)),o.length>2&&(0,r.jsxs)("span",{children:["+",o.length-2]})]}),(0,r.jsxs)("span",{className:"mt-1 flex items-center gap-3 font-mono text-[11px] text-muted-foreground/70",children:[t&&(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:["say ",(0,r.jsx)(sI,{phrase:t})," to answer"]}),(0,r.jsxs)("button",{type:"button",onClick:s,className:"flex items-center gap-2 rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)("kbd",{className:sC,children:"Esc"}),"not now"]})]})]})}function sR({at:e}){let[t,n]=(0,b.useState)(()=>Date.now());return(0,b.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),3e4);return()=>clearInterval(e)},[]),t-e<6e4?"just now":(0,s.formatDistanceStrict)(e,t,{addSuffix:!0})}function sI({phrase:e}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-foreground/80",children:[(0,r.jsx)(h,{className:"size-3"}),e]})}let sO={question:"asks",done:"finished",stopped:"stopped"};function sD({at:e,shown:t,children:n}){return(0,r.jsx)("span",{"aria-hidden":!t,className:(0,S.cn)("flex transition-opacity duration-300 ease-out",e,t?"opacity-100":"pointer-events-none opacity-0"),children:n})}let sP={quiet:`${R.CALL_IDLE.hangUpMs/1e3}s of quiet`,hungUp:"Thursday hung up",closed:"Live closed the call",expired:"the call ran to Live's time limit",dropped:"the connection dropped"};function sF({status:e,idleLeft:t,since:n,ended:s,behind:a,wakePhrase:l,hotkeyLabel:i}){let o,u,c="connecting"===e||"ending"===e,d="idle"!==e&&!c;return c?(u=e,o=(0,r.jsx)(_.ShinyText,{text:"connecting"===e?"Connecting…":"Ending…",className:"text-muted-foreground/70"})):d&&null!==t?(u="quiet",o=`Quiet — ending in ${t}s. Say anything to stay.`):d?(u=a?"behind":"live",o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Tap Thursday to end"}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("kbd",{className:sC,children:"↓"}),(0,r.jsx)("span",{children:"back to now"})]}):(0,r.jsx)(sK,{since:n})]})):s?(u=`ended:${s}`,o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{children:["Ended — ",sP[s]]}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("span",{children:"Tap to call again"})]})):l?(u=`wake:${l}`,o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A,{text:"Tap Thursday, or say"}),(0,r.jsx)(s$,{at:500,children:(0,r.jsx)(sI,{phrase:l})}),(0,r.jsx)(s$,{at:sz,children:(0,r.jsx)(sB,{})})]})):i?(u=`key:${i}`,o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A,{text:"Tap Thursday, or press"}),(0,r.jsx)(s$,{at:550,children:(0,r.jsx)("kbd",{className:sC,children:i})}),(0,r.jsx)(s$,{at:sz,children:(0,r.jsx)(sB,{})})]})):(u="tap",o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A,{text:"Tap Thursday to talk"}),(0,r.jsx)(s$,{at:sz,children:(0,r.jsx)(sB,{})})]})),(0,r.jsx)("span",{className:"flex h-6 animate-in items-center gap-1.5 font-mono text-[11px] text-muted-foreground fade-in duration-700",children:o},u)}let sz=900;function s$({at:e,children:t}){return(0,r.jsx)("span",{style:{animationDelay:`${e}ms`},className:"flex animate-in items-center gap-1.5 duration-700 fill-mode-backwards fade-in",children:t})}function sB(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"px-1.5 text-muted-foreground/30",children:"·"}),(0,r.jsx)("span",{className:"text-muted-foreground/70",children:"/ to write"})]})}function sq({open:e,onOpen:t,onClose:n}){let{data:s}=(0,V.useServerRoute)(k.queryKey.automaticModel);return e?(0,r.jsxs)("div",{className:"w-[min(26rem,84vw)] animate-in space-y-2.5 rounded-2xl bg-background/80 p-3 ring-1 ring-border/60 backdrop-blur-md fade-in duration-300",children:[(0,r.jsxs)("div",{className:"flex h-6 items-center justify-between gap-2 pl-0.5",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium",children:"Paste your OpenAI API key"}),(0,r.jsx)(v.Button,{type:"button",size:"icon",variant:"ghost","aria-label":"Not now",onClick:n,className:"-my-1 size-6",children:(0,r.jsx)(w.X,{className:"size-3.5"})})]}),(0,r.jsx)(e5.VoiceKeys,{dense:!0,plain:!0,autoFocus:!0}),(0,r.jsx)(e5.GetKeyLink,{})]}):(0,r.jsxs)("span",{className:"flex animate-in items-center gap-2 rounded-full bg-muted/60 py-1 pr-1 pl-1.5 ring-1 ring-border/60 fade-in duration-500",children:[(0,r.jsxs)("span",{className:"relative flex size-6 shrink-0 items-center justify-center",children:[(0,r.jsx)(P.BotMark,{size:24,seed:D.DEFAULT_BOT.name,color:D.DEFAULT_BOT.icon?.color,shape:D.DEFAULT_BOT.icon?.shape,outline:D.DEFAULT_BOT.icon?.outline,notify:!1}),(0,r.jsx)(m,{className:"absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full bg-muted text-muted-foreground"})]}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground break-keep wrap-anywhere",children:s&&!s.ref?"Calls need one speech key, and bots a model key or a ChatGPT sign-in.":"Calls need one speech key. Everything else here already works."}),(0,r.jsx)(v.Button,{size:"sm",variant:"brand",onClick:t,className:"h-7 px-3.5",children:"Add key"})]})}function sU({title:e}){let t=e?`Thinking \xb7 ${e}`:"Thinking";return(0,r.jsx)("span",{className:"flex max-w-full items-center text-[13px] leading-5",children:(0,r.jsx)(_.ShinyText,{text:t,className:"min-w-0 animate-in truncate fade-in duration-300"},t)})}function sK({since:e}){let[t,n]=(0,b.useState)(()=>Date.now());if((0,b.useEffect)(()=>{if(null===e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),null===e)return null;let s=Math.max(0,Math.floor((t-e)/1e3)),a=String(Math.floor(s/60)).padStart(2,"0"),l=String(s%60).padStart(2,"0");return(0,r.jsxs)("span",{className:"tabular-nums",children:[a,":",l]})}e.s(["Ear",0,sv,"Thursday",0,function({ready:e}){let t=function(){let[e,t]=(0,b.useState)(null),n=(0,b.useRef)(e);n.current=e;let r=(0,b.useRef)(new Set),[s]=(0,nw.useServerAction)(nM),a=(0,b.useRef)(null),l=(0,b.useRef)([]),[i,o]=(0,b.useState)([]),u=(0,b.useCallback)(e=>{l.current=e,o(e)},[]),c=(0,b.useRef)(new Map),d=(0,b.useRef)(0),[h,p]=(0,b.useState)(null),m=(0,b.useRef)(()=>{}),{messages:f,sendMessage:g,setMessages:x,status:y,stop:w,error:v,clearError:j}=(0,nh.useChat)({transport:nL,onFinish:e=>m.current(e)}),N="submitted"===y||"streaming"===y,T=(0,b.useRef)(f);T.current=f;let E=(0,b.useRef)(v);E.current=v;let A=(0,b.useRef)(""),M=(0,b.useCallback)(e=>{let t=n.current;if(!t)return;let r=l.current;u([]);let s=crypto.randomUUID();a.current=s;let i=nR();A.current=JSON.stringify(i??null);let o=[...r.map(nI),...e?[{type:"text",text:e}]:[]];g(o.length?{parts:o}:void 0,{body:{callId:t.callId,standing:t.standing,runsOn:i,turn:s}})},[g,u]),_=(0,b.useCallback)(()=>{let e=n.current;if(e){for(let e of(n.current=null,t(null),a.current=null,c.current.values()))nb.delete(e.key);c.current.clear(),u([]),d.current=0,p(null),w(),x([]),j(),nA(e.callId).then(ny.unwrapResult).finally(()=>(0,V.revalidate)(k.queryKey.callHistory(null)))}},[w,x,j,u]),C=(0,b.useRef)(_);C.current=_,(0,b.useEffect)(()=>()=>C.current(),[]);let L=(0,b.useCallback)(e=>{u([...l.current,e]);let t=n.current,r=a.current;t&&r&&n_(t.callId,r,e).then(ny.unwrapResult).catch(()=>{})},[u]);(0,b.useEffect)(()=>J.screenActs.subscribe(e=>{n.current&&L({id:crypto.randomUUID(),text:nE(e),said:!1})}),[L]);let I=(0,b.useCallback)(async e=>{let l=n.current;if(l||(n.current=l={...await s(nR()),at:Date.now()},r.current=nk(P.current??[]),t(l)),d.current=0,a.current)return L({id:crypto.randomUUID(),text:e,said:!0});j(),M(e)},[s,L,j,M]),O=(0,b.useCallback)(()=>{let e=T.current,t=e.at(-1);if(n.current&&t){if("assistant"===t.role){let n=A.current!==JSON.stringify(nR()??null)?-1:t.parts.findLastIndex(e=>(0,np.isToolUIPart)(e)&&!e.providerExecuted&&("output-available"===e.state||"output-error"===e.state));u([...(0,nu.notesIn)([{...t,parts:t.parts.slice(n+1)}]),...l.current]),x(n<0?e.slice(0,-1):[...e.slice(0,-1),{...t,parts:t.parts.slice(0,n+1)}])}j(),M(null)}},[M,x,j,u]),{data:D}=(0,V.useServerRoute)(k.queryKey.threads),P=(0,b.useRef)(D);P.current=D;let F=(0,b.useCallback)(()=>{if(!n.current||!P.current)return;let e=nT(P.current),t=new Set(e.map(e=>e.key)),s=l.current.filter(e=>{let n=c.current.get(e.id);return void 0!==n&&!t.has(n.key)});if(s.length){for(let e of s){let t=c.current.get(e.id);t&&nb.delete(t.key),c.current.delete(e.id)}u(l.current.filter(e=>!s.includes(e)))}for(let t of e){if(nb.has(t.key)||r.current.has(t.key))continue;nb.add(t.key);let e={id:crypto.randomUUID(),text:t.line,said:!1};c.current.set(e.id,{key:t.key,rows:t.relayIds,show:t.show}),a.current&&p(t.show),L(e)}if(a.current||E.current||d.current>=R.TEXT_CALL.autoTurns)return;let i=l.current.filter(e=>c.current.has(e.id)),o=i.length?c.current.get(i[i.length-1].id):null;o&&(d.current+=1,p(o.show),M(null))},[u,L,M]),z=null!==e;(0,b.useEffect)(()=>{z&&D&&F()},[z,D,F]),m.current=({message:e,messages:t,isAbort:r,isError:s,isDisconnect:i})=>{if(r||!n.current)return;a.current=null;let o=new Set((0,nu.notesIn)([e]).map(e=>e.id));if(u(l.current.filter(e=>!o.has(e.id))),s||i)return;let d=new Set((0,nu.notesIn)(t).map(e=>e.id)),h=[];for(let[e,t]of c.current)d.has(e)&&(h.push(...t.rows),c.current.delete(e));if(h.length&&nx(h).then(ny.unwrapResult).catch(e=>nm.toast.add({type:"error",title:"Could not record relay delivery",description:(0,S.errorToString)(e)})),l.current.some(e=>e.said))return M(null);F()},(0,b.useEffect)(()=>{if(N||!h)return;let e=setTimeout(()=>p(null),R.CALL_LINE.lingerMs);return()=>clearTimeout(e)},[N,h]);let $=f.at(-1)?.role==="assistant"?f.at(-1):null,B=$?.parts??[],q=B.at(-1),U=(0,b.useMemo)(()=>{let e=[],t=!1,n=(n,r,s)=>{if(!s)return;let a=t&&"assistant"===r;"assistant"===r&&(t=!1),e.push({id:n,role:r,text:s,...a?{fresh:!0}:{}})};for(let e of f){if("system"===e.role)continue;let r=e.role,s=[],a=0,l=()=>{let t=s.join("\n\n").trim();s=[],n(`${e.id}:${a++}`,r,"assistant"===r?(0,S.captionText)(t):t)};for(let r of e.parts){"text"===r.type&&s.push(r.text);let e=(0,nu.noteOf)(r);e&&(l(),e.said?n(e.id,"user",e.text):t=!0)}l()}let r=new Set((0,nu.notesIn)(f).map(e=>e.id));for(let e of i)e.said&&!r.has(e.id)&&n(e.id,"user",e.text);return e},[f,i]),K=[...B].reverse().find(np.isToolUIPart),H=K?.toolCallId??null,W=K?(0,np.getToolName)(K):null,G=K?.state==="output-available"||K?.state==="output-error",Y=K?.output,X=(0,b.useMemo)(()=>G&&W===nf.TOOL_NAMES.web_search?(0,nC.searchSourcesOf)(JSON.stringify(Y??null)):[],[G,W,Y]),Z=Y?.action?.query,Q=JSON.stringify({..."string"==typeof Z?{query:Z}:{},...K?.input??{}}),ee=W?(0,nC.toolBot)(W,Q,P.current,void 0===Y?void 0:JSON.stringify(Y)):null,et=W?(0,nC.toolLine)(W,Q,ee):null,en=q?.type==="text",er=(0,b.useMemo)(()=>H&&W&&(!en||X.length)?{id:H,name:W,line:et,bot:ee,done:G,...X.length?{sources:X}:{}}:null,[H,W,et,ee,G,X,en]),[es,ea]=(0,b.useState)(null),el=er?.done&&!er.sources?er.id:null;(0,b.useEffect)(()=>{if(!el)return;let e=setTimeout(()=>ea(el),R.CALL_LINE.lingerMs);return()=>clearTimeout(e)},[el]);let ei=er&&er.id!==es?er:h,eo=!!N&&q?.type!=="text"&&(!er||!!er.done),[eu,ec]=(0,b.useState)(null);(0,b.useEffect)(()=>{ec(eo?Date.now():null)},[eo]);let ed=[...B].reverse().find(e=>"reasoning"===e.type),eh=eo&&ed?.type==="reasoning"&&(0,nC.reasoningTitle)(ed.text)||null,ep=e?N?q?.type==="text"?"speaking":er&&!er.done&&er.name===nf.TOOL_NAMES.thread_start?"delegating":"working":"listening":"idle";return{on:null!==e,busy:N,status:ep,messages:U,tool:ei,thinkingSince:eu,thinkingTitle:eh,since:e?.at??null,error:v?v.message:null,say:I,again:O,end:_}}(),{status:n,failed:s,messages:a,tool:l,thinkingSince:i,thinkingTitle:o,ended:u,faceWord:c,idleLeft:d,since:h,call:p,ringing:m,decline:f,getSpectrum:g,getMicSpectrum:x,wakePhrase:y,hotkey:w}=function(e=!1){let t,n,r=(0,b.useRef)(null),s=(0,b.useRef)(null),a=(0,b.useRef)(null),[l,i]=(0,b.useState)("idle"),[o,u]=(0,b.useState)(!1),c=(0,b.useRef)(null),d=(0,b.useCallback)(e=>{c.current&&clearTimeout(c.current),c.current=e?setTimeout(()=>u(!1),6e3):null,u(e)},[]),[h,p]=(0,b.useState)([]),[m,f]=(0,b.useState)(null),[g,x]=(0,b.useState)(null),[y,w]=(0,b.useState)(null),[v,j]=(0,b.useState)(null),[N,T]=(0,b.useState)(null),[E,A]=(0,b.useState)(null),[M,_]=(0,b.useState)(null),C=(0,b.useRef)(null),L=(0,b.useRef)(null),O=(0,b.useRef)({on:!1,spoke:!1,giveUp:null}),D=(0,b.useRef)(null),P=(0,b.useRef)(0),F=(0,b.useRef)(null),z=(0,b.useRef)(!1),B=(0,b.useRef)(null),q=(0,b.useRef)(null),U=(0,b.useRef)(null),K=(0,b.useRef)(nb),H=(0,b.useRef)(new Set),Y=(0,b.useRef)(new Set),X=(0,b.useRef)([]),Z=(0,b.useRef)([]),Q=(0,b.useRef)(0),ee=(0,b.useRef)(null),et=(0,b.useRef)(0),en=(0,b.useRef)(!1),er=(0,b.useRef)(!1),es=(0,b.useRef)(void 0),ea=(0,b.useRef)(null),el=ea.current??=(t=[],n=null,{send(e){n?n(e):t.push(e)},open(e){n=e;let r=t;for(let n of(t=[],r))e(n)},close(){n=null},clear(){let e=t;return t=[],e}}),ei=(0,b.useRef)(!1),eo=(0,b.useRef)(!1),eu=(0,b.useRef)(!1),ec=(0,b.useRef)(0),ed=(0,b.useCallback)(e=>{F.current&&clearTimeout(F.current),z.current=!1;let t=(0,nC.toolBot)(e.name,e.arguments,es.current);f({id:e.id,name:e.name,line:(0,nC.toolLine)(e.name,e.arguments,t),bot:t,done:!1})},[]),eh=(0,b.useCallback)((e,t)=>{let n=(0,nC.toolBot)(e.name,e.arguments,es.current,t);n&&f(t=>t?.id===e.id&&t.bot!==n?{...t,bot:n,line:(0,nC.toolLine)(e.name,e.arguments,n)}:t)},[]),ep=(0,b.useCallback)(e=>{F.current&&clearTimeout(F.current),z.current=!0,f({...e,done:!1})},[]),em=(0,b.useCallback)(e=>{f(t=>t?.id===e?{...t,done:!0}:t),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>f(e=>e?.done?null:e),R.CALL_LINE.lingerMs)},[]),ef=(0,b.useCallback)(()=>{if(O.current.giveUp&&clearTimeout(O.current.giveUp),O.current.spoke){for(let e of X.current)H.current.delete(e);let e=Z.current;e.length&&nx(e).then(ny.unwrapResult).catch(e=>nm.toast.add({type:"error",title:"Could not record relay delivery",description:(0,S.errorToString)(e)}))}Z.current=[],X.current=[],O.current={on:!1,spoke:!1,giveUp:null},z.current&&(z.current=!1,f(e=>e?.kind==="relay"?{...e,done:!0}:e),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>f(e=>e?.kind==="relay"?null:e),R.CALL_LINE.relayLingerMs))},[]),eg=(0,b.useCallback)(()=>{O.current.giveUp&&clearTimeout(O.current.giveUp),O.current={on:!0,spoke:!1,giveUp:setTimeout(ef,R.CALL_RELAY.readMs)}},[ef]),ex=(0,b.useCallback)(e=>{C.current=e,T(e),A(null)},[]),ey=(0,b.useCallback)((e,t)=>{let n=()=>{L.current&&clearTimeout(L.current),L.current=null};if(t){n(),null!==C.current&&ex(null);return}if(e){n(),null===C.current&&ex(Date.now());return}null===C.current||L.current||(L.current=setTimeout(()=>{L.current=null,ex(null)},R.CALL_LINE.thinkingTailMs))},[ex]),ew=(0,b.useCallback)(()=>{let e=r.current,t=es.current;if(!e||!t||O.current.on||er.current||null!==C.current||ee.current)return;let n=en.current;if(en.current=!1,!n&&Date.now()-et.current<R.CALL_RELAY.quietMs)return;let s=nT(t).filter(e=>!K.current.has(e.key)&&!Y.current.has(e.key)),a=s[0];if(!a)return;let l=s.filter(e=>e.kind===a.kind).slice(0,R.CALL_RELAY.perTurn),i=l.map(e=>e.line);for(let e of l)K.current.add(e.key),H.current.add(e.key);a.key.startsWith("done:")&&_(rE()),eg(),X.current=l.map(e=>e.key),Z.current=l.flatMap(e=>e.relayIds),ep((l.at(-1)??a).show),e.append("commentary",1===i.length?i.join(""):`[${i.length} updates.]
14
-
15
- ${i.join("\n\n")}`).then(e=>{e||(Z.current=[],ef())})},[eg,ef,ep]),eb=(0,b.useRef)(l);(0,b.useEffect)(()=>{eb.current=l},[l]);let ek=(0,b.useRef)("listening"),ev=(0,b.useRef)(null),ej=(0,b.useCallback)(()=>{ev.current&&clearTimeout(ev.current),ev.current=null},[]),eS=(0,b.useCallback)(e=>{eb.current=e,i(e)},[]),eN=(0,b.useCallback)(e=>{ek.current=e;let t=eb.current;if("speaking"===e){ej(),eS(e);return}let n="working"===e||"delegating"===e;if(n&&("working"===t||"delegating"===t)){ej(),eS(e);return}n||"listening"!==t?ev.current||(ev.current=setTimeout(()=>{ev.current=null,eS(ek.current)},n?800:600)):ej()},[ej,eS]),eT="idle"!==l&&"connecting"!==l&&"ending"!==l,{data:eE}=(0,V.useServerRoute)(k.queryKey.threads,{refreshInterval:R.INBOX_POLL_MS}),eA=(0,b.useRef)(!1);(0,$.useAppEvent)({hello:()=>{if(!eA.current){eA.current=!0;return}(0,V.revalidateAll)()},threads:()=>void(0,V.revalidate)(k.queryKey.threads),routines:()=>void(0,V.revalidate)(k.queryKey.routines),memory:()=>void(0,V.revalidate)(k.queryKey.memory),mcp:()=>{(0,V.revalidate)(k.queryKey.mcp),(0,V.revalidate)(k.queryKey.mcpTools)},config:()=>{(0,V.revalidate)(k.queryKey.config),(0,V.revalidate)(k.queryKey.llmModel)}});let{data:eM}=(0,V.useServerRoute)(k.queryKey.bot);(0,b.useEffect)(()=>{eE&&J.botThreads.sync(eE,eM)},[eE,eM]),(0,b.useEffect)(()=>{es.current=eE},[eE]);let e_=function({threads:e,resting:t,writing:n}){let r=(0,b.useRef)(Date.now()),[s,a]=(0,b.useState)([]),[l,i]=(0,b.useState)(null),o=s.length>0,u=(0,nc.useThursdayStore)(e=>e.callBack);(0,b.useEffect)(()=>{if(!e)return;let s=new Set(e.filter(e=>{let t,n;return t=e,"off"!==(n=u)&&!t.seen&&(t.room.questions.length>0||"any"===n&&"running"!==t.status)}).map(e=>e.id));if(a(e=>e.every(e=>s.has(e))?e:e.filter(e=>s.has(e))),!t||n)return;let l=r.current,o=e.filter(e=>s.has(e.id)&&(0,G.toDate)(e.updatedAt).getTime()>l);o.length&&(r.current=Math.max(...o.map(e=>(0,G.toDate)(e.updatedAt).getTime())),i(null),a(e=>[...e,...o.map(e=>e.id).filter(t=>!e.includes(t))]))},[e,u,t,n]),(0,b.useEffect)(()=>{n?(a([]),i(null)):r.current=Date.now()},[n]);let c=(0,b.useCallback)(()=>{a([]),i(null)},[]);(0,W.useEscape)(o,c),(0,b.useEffect)(()=>{if(!o||null!==l)return;let e=setTimeout(()=>i(Date.now()),R.CALL_BACK.ringMs);return()=>clearTimeout(e)},[o,l]),(0,b.useEffect)(()=>{if(o&&null===l){let e;return(e=new Audio("/sounds/ring.ogg")).play().catch(()=>{}),()=>e.pause()}},[o,l]);let d=(0,b.useMemo)(()=>{let[t,...n]=s.flatMap(t=>{let n=e?.find(e=>e.id===t);if(!n)return[];let r=n.room.questions[0];return[{id:n.id,bot:r?.bot??n.bot,kind:r?"question":"done"===n.status?"done":"stopped",label:n.label,text:r?.text??n.outcome??n.ask?.question??n.label,options:r?.options??[],questionId:r?.id??null}]});return t?{first:t,others:n,missedAt:l}:null},[s,e,l]);(0,b.useEffect)(()=>{J.ringingThreads.set(s)},[s]);let h=(0,b.useCallback)(()=>{a([]),i(null)},[]);return{ringing:d,isRinging:o,ringingFor:s,answered:h,unanswered:(0,b.useCallback)(e=>{e.length&&(a(t=>[...e,...t.filter(t=>!e.includes(t))]),i(Date.now()))},[]),settle:(0,b.useCallback)(()=>{r.current=Date.now()},[]),decline:c}}({threads:eE,resting:"idle"===l,writing:e}),{answered:eC,unanswered:eL,settle:eR}=e_;(0,b.useEffect)(()=>J.screenActs.subscribe(e=>{ei.current&&el.send(nE(e))}),[el]);let eI=(0,b.useCallback)(async(e=null)=>{if(eu.current)return;eu.current=!0,ee.current&&clearInterval(ee.current),ee.current=null,ec.current+=1;let t=r.current,n=q.current;for(let e of(r.current=null,q.current=null,ei.current=!1,eo.current=!1,en.current=!1,H.current))K.current.delete(e);H.current.clear(),el.close(),el.clear(),B.current?.abort(),B.current=null,O.current.spoke=!1,ef(),F.current&&clearTimeout(F.current),ej(),eR(),w(null),x(null),i(t?"ending":"idle"),t&&_(rT()),p([]),f(null),ex(null),L.current&&clearTimeout(L.current),L.current=null,z.current=!1,await t?.close(),U.current?.(),U.current=null;let s=D.current;D.current=null,eu.current=!1,i("idle"),t&&j(e),n&&nA(n,s),t&&a.current&&(a.current.currentTime=0,a.current.play().catch(()=>{}))},[el,ej,ef,ex]);(0,b.useEffect)(()=>{let e=()=>{let e=q.current;e&&navigator.sendBeacon(k.queryKey.callEnd,e)};return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[]),(0,b.useEffect)(()=>()=>{ec.current+=1,U.current?.(),U.current=null,r.current?.close(),r.current=null;let e=q.current;for(let t of(q.current=null,ei.current=!1,eo.current=!1,e&&nA(e),H.current))K.current.delete(t);H.current.clear(),B.current?.abort(),B.current=null,F.current&&clearTimeout(F.current),ev.current&&clearTimeout(ev.current),O.current.giveUp&&clearTimeout(O.current.giveUp),L.current&&clearTimeout(L.current),c.current&&clearTimeout(c.current),ee.current&&clearInterval(ee.current)},[]);let eO=(0,b.useCallback)(()=>{if(ee.current)return;let e=Date.now();ee.current=setInterval(()=>{let t=Date.now();((Q.current>e-R.CALL_END.unsaidMs?t-Math.max(Q.current,e)>=R.CALL_END.quietMs:t-e>=R.CALL_END.unsaidMs)||t-e>=R.CALL_END.maxMs)&&eI("hungUp")},100)},[eI]);(0,b.useEffect)(()=>{if(!eT)return;P.current=Date.now();let e=setInterval(()=>{if(!r.current)return;let e=R.CALL_IDLE.hangUpMs-(Date.now()-P.current);w(e<=R.CALL_IDLE.warnMs?Math.max(0,Math.ceil(e/1e3)):null),e<=0&&!O.current.on&&eI("quiet")},1e3);return()=>clearInterval(e)},[eT,eI]),(0,b.useEffect)(()=>{if(!eT)return;let e=setInterval(ew,1e3);return()=>clearInterval(e)},[eT,ew]);let eD=(0,b.useCallback)(async()=>{let e=e_.isRinging,t=e_.ringingFor;if(eo.current||eu.current)return;if(ei.current||"idle"!==l)return eI();eC(),nW(),i("connecting"),j(null),d(!1),eo.current=!0,ei.current=!0,D.current=null,el.clear(),ec.current+=1;let n=ec.current,o=()=>ei.current&&ec.current===n;try{s.current??=(0,ni.createAudioTap)(),function(e){if("suspended"!==e.state||rR)return;rR=!0;let t=()=>{rR=!1,window.removeEventListener("pointerdown",t),window.removeEventListener("keydown",t),e.resume().catch(()=>{})};window.addEventListener("pointerdown",t),window.addEventListener("keydown",t),nm.toast.add({type:"warning",title:"Tap anywhere to hear her",description:"This call opened on its own, so the browser is holding the audio."})}(s.current.open().context);let t=new Audio("/sounds/start_voice.ogg");a.current??=new Audio("/sounds/end_voice.ogg");let n=await (!("locks"in navigator)?Promise.resolve(()=>{}):new Promise(e=>{navigator.locks.request("thursday-spoken-call",{ifAvailable:!0},t=>t?new Promise(t=>e(()=>t())):void e(null))}));if(!n)throw new rC("A call is already on in another tab of this app. Hang up there, or go on there.");U.current=n;let l=new AbortController;B.current=l;let i={failures:0},u={failures:0},c={callId:"",opening:null,standing:null,opened:{webSearch:I.LIVE_DEFAULTS.webSearch,readSkills:I.LIVE_DEFAULTS.readSkills}},h=new Map,m=new Map,g=null,y=e=>{let t={query:e.query,sources:e.sources};return rO(i,()=>r_(c.callId,[{id:e.row,role:"tool",tool:nf.TOOL_NAMES.web_search,text:JSON.stringify(t),seq:Math.max(0,Math.round(e.seq)),fragments:null}])),!!e.sources.length&&g===e.id&&(F.current&&clearTimeout(F.current),f(n=>n&&n.id!==e.id?n:{id:e.id,name:nf.TOOL_NAMES.web_search,line:(0,nC.toolLine)(nf.TOOL_NAMES.web_search,JSON.stringify(t)),done:!0,bot:null,sources:e.sources}),!0)},w=await rw({initialize:async t=>{let n=(0,ny.unwrapResult)(await rA(t,e));if(!o())throw nA(n.callId),Error("The call closed during startup.");return q.current=n.callId,c.callId=n.callId,c.opening=n.opening,c.standing=n.standing,c.opened=n.opened,n.sdp},audio:s.current,on:{runTool:async e=>{if(e.name===nf.TOOL_NAMES.end_call)return eO(),"Ending the call.";if(e.name===nf.TOOL_NAMES.emote){let{word:t,reply:n}=function(e){let t="";try{let n=JSON.parse(e);n&&"object"==typeof n&&"text"in n&&(t=String(n.text??"").trim())}catch{t=""}let n=Array.from(t).length;if(!n)return{word:null,reply:"Nothing was shown: text is empty."};if(n>rv.FACE_WORD_MAX)return{word:null,reply:`Too long: ${n} characters, ${rv.FACE_WORD_MAX} at most. Nothing was shown.`};let r=(0,rv.undrawable)(t);return r?{word:null,reply:`Cannot draw "${r}"; use only the characters \`text\` lists. Nothing was shown.`}:{word:t.toUpperCase(),reply:"Shown."}}(e.arguments);return t&&_({text:t,at:Date.now()}),n}ed(e);let t=e.name===nf.TOOL_NAMES.web_search;t&&(g=e.id);let n=!1;try{let r=await nO(c.callId,e,c.opened,l.signal);eh(e,r);let s=e.name===nf.TOOL_NAMES.thread_start?function(e){try{let{threadId:t,bot:n,label:r}=JSON.parse(e);return"string"==typeof t&&"string"==typeof n&&"string"==typeof r?{bot:n,label:r}:null}catch{return null}}(r):null;return s&&el.send((({bot:e,label:t})=>`${e} took "${t}" and is working on it now.`)(s)),t&&(n=y({id:e.id,row:e.item??e.id,query:(0,nC.searchQueryOf)(e.arguments),sources:(0,nC.searchSourcesOf)(r),seq:0})),r}finally{n||em(e.id)}},search:e=>{if(!e.done){g=e.id,ed({id:e.id,name:nf.TOOL_NAMES.web_search,arguments:JSON.stringify({query:e.query})});return}let t={id:e.id,row:e.id,query:e.query,sources:e.sources,seq:e.seq};m.set(e.responseId,t),y(t)||em(t.id)},cited:(e,t)=>{let n=m.get(e);if(!n)return;let r=new Set(n.sources.map(e=>e.url));n.sources=[...n.sources.map(e=>t.find(t=>t.url===e.url)??e),...t.filter(e=>!r.has(e.url))],y(n)},reasoning:e=>{let t=(0,nC.reasoningTitle)(e.text);t&&A(t),rO(u,()=>rM(c.callId,{...e,seq:Math.max(0,Math.round(e.seq))}),"The backend's thinking is not being saved")},turn:e=>{let t="tool"===e.role?"":rI(e.text),n=!!t&&t!==rI(h.get(e.id)?.text??"");if(n&&(et.current=Date.now()),n&&"user"===e.role&&(P.current=Date.now(),g)){let e=g;g=null,f(t=>t?.id===e?null:t)}"tool"!==e.role&&q.current===c.callId&&(h.set(e.id,{seq:e.seq,id:e.id,role:e.role,text:e.text}),p([...h.values()].sort((e,t)=>e.seq-t.seq).slice(-R.CALL_PAGE.scrollback))),e.done&&rO(i,()=>r_(c.callId,[{id:e.id,role:e.role,tool:e.tool,text:e.text,seq:Math.max(0,Math.round(e.seq)),fragments:e.fragments??null}]))},activity:e=>{var t;eN((t=e).speaking?"speaking":t.working||t.tools.length?t.tools.includes(nf.TOOL_NAMES.thread_start)?"delegating":"working":"listening");let n=e.working||e.tools.length>0;er.current=n,ey(n,e.speaking),e.speaking&&(Q.current=Date.now()),(e.speaking&&!O.current.on||e.working||e.tools.length)&&(P.current=Date.now()),O.current.on&&(e.speaking?O.current.spoke=!0:O.current.spoke&&ef())},finalized:e=>{D.current=e},warn:e=>nm.toast.add({type:"warning",title:"Call warning",description:e}),failed:e=>{let t=D.current?.reason;if("expired"===t||"remote_hangup"===t)return void eI("expired"===t?"expired":"closed");if("content"===t){nm.toast.add({type:"warning",title:"Live ended the call",description:"Its safety filter stopped the conversation."}),eI("closed");return}nm.toast.add({type:"error",title:"Call failed",description:e}),d(!0),eI(D.current?"closed":"dropped")}}});if(!o())return void await w.close();r.current=w,eo.current=!1,en.current=e,Y.current=e?new Set:nk(es.current??[]),el.open(e=>void w.append("thinking",e)),et.current=Date.now(),c.opening&&(eg(),w.append("instructions",c.opening).then(e=>{e||ef()})),c.standing&&w.brief(c.standing),eS("listening"),x(Date.now()),t.play().catch(()=>{})}catch(r){if(U.current?.(),U.current=null,o()&&r instanceof rC?nm.toast.add({type:"warning",title:"One call at a time",description:r.message}):o()&&(nm.toast.add({type:"error",title:"Could not start the call",description:(0,S.errorToString)(r)}),d(!0),e&&eL(t)),ec.current!==n)return;q.current&&nA(q.current),q.current=null,eo.current=!1,ei.current=!1,B.current=null,el.clear(),i("idle")}},[l,eI,ed,eh,em,eN,eS,el,eg,ef,ey,d,eO,e_.isRinging,e_.ringingFor,eC,eL]);(0,b.useEffect)(()=>{if(!v)return;let e=setTimeout(()=>j(null),R.CALL_ENDED_MS);return()=>clearTimeout(e)},[v]);let eP=(0,b.useCallback)(()=>s.current?.read()??rL,[]),eF=(0,b.useCallback)(()=>s.current?.readMic()??rL,[]),ez=(0,nc.useThursdayStore)(e=>e.wake),[e$,eB]=(0,b.useState)(!1),eq=nl();(0,b.useEffect)(()=>na.onPlace(()=>void eD()),[eD]),n1({enabled:"idle"===l&&ez.enabled&&!e$&&!eq,phrases:[ez.phrase],onWake:()=>void eD(),onError:e=>{eB(!0),nm.toast.add({type:"error",title:"Wake word off",description:e})}});let eU=(0,nc.useThursdayStore)(e=>e.hotkey),eK="connecting"===l||"ending"===l;return(0,W.useHotkey)({enabled:eU.enabled&&!eK&&!eq,combo:eU.enabled&&(0,W.isCombo)(eU.combo)?eU.combo:null,onPress:()=>void eD()}),{status:l,failed:o,messages:h,tool:m,ended:v,thinkingSince:N,thinkingTitle:E,faceWord:M,idleLeft:y,since:g,call:eD,ringing:e_.ringing,decline:e_.decline,getSpectrum:eP,getMicSpectrum:eF,wakePhrase:ez.enabled&&!e$?ez.phrase:null,hotkey:eU.enabled&&(0,W.isCombo)(eU.combo)?eU.combo:null}}(t.on),v=(0,W.useHotkeyLabel)(w),j=(0,nc.useThursdayStore)(e=>e.captionView),{data:N}=(0,V.useServerRoute)(k.queryKey.config),T=N?(0,e3.isConfigSet)(N,I.LIVE_PROVIDER.apiKeyName):e,E="idle"!==n,A=t.end;(0,b.useEffect)(()=>{E&&t.on&&A()},[E,t.on,A]);let M=t.on&&!E,_=(0,nc.useThursdayStore)(e=>e.textModel),{settings:C}=(0,nd.useLiveSettings)(),L=C?.backendModel??I.LIVE_DEFAULTS.backendModel,D=(0,b.useMemo)(()=>{let e=e=>(0,e3.isConfigSet)(N,e),n=(0,nu.textCallRunsOn)(e),r=_&&e(O.TEXT_MODEL_PROVIDERS[_.provider].apiKeyName)?_:n?{provider:n,model:L}:null;return{on:M,busy:t.busy,error:t.error,say:t.say,again:t.again,end:t.end,runsOn:r,fallback:r?.provider!=="openai"&&e(O.TEXT_MODEL_PROVIDERS.openai.apiKeyName)?{provider:"openai",model:L}:null}},[M,t.busy,t.error,t.say,t.again,t.end,N,_,L]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r5,{live:"idle"!==n,ringing:null!==m}),(0,r.jsx)(sh,{status:M?t.status:n,failed:M?null!==t.error:s,messages:M?t.messages:a,tool:M?t.tool:l,thinkingSince:M?t.thinkingSince:i,thinkingTitle:M?t.thinkingTitle:o,ended:u,faceWord:c,onTap:p,ringing:T?m:null,onDecline:f,wakePhrase:y,hotkeyLabel:v,idleLeft:d,since:h,getSpectrum:M?no:g,getMicSpectrum:x,captionView:j,callable:T,written:E?null:D})]})}],692888)},379227,(e,t,n)=>{var r;"u">typeof __nccwpck_require__&&(__nccwpck_require__.ab="/ROOT/node_modules/next/dist/compiled/tty-browserify/"),(r={}).isatty=function(){return!1},r.ReadStream=function(){throw Error("tty.ReadStream is not implemented")},r.WriteStream=function(){throw Error("tty.WriteStream is not implemented")},t.exports=r},90317,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={bindSnapshot:function(){return u},createAsyncLocalStorage:function(){return o},createSnapshot:function(){return c}};for(var s in r)Object.defineProperty(n,s,{enumerable:!0,get:r[s]});let a=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class l{disable(){throw a}getStore(){}run(){throw a}exit(){throw a}enterWith(){throw a}static bind(e){return e}}let i="u">typeof globalThis&&globalThis.AsyncLocalStorage;function o(){return i?new i:new l}function u(e){return i?i.bind(e):l.bind(e)}function c(){return i?i.snapshot():function(e,...t){return e(...t)}}},242344,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"workAsyncStorageInstance",{enumerable:!0,get:function(){return r}});let r=(0,e.r(90317).createAsyncLocalStorage)()},563599,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"workAsyncStorage",{enumerable:!0,get:function(){return r.workAsyncStorageInstance}});let r=e.r(242344)},309885,(e,t,n)=>{"use strict";function r(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"encodeURIPath",{enumerable:!0,get:function(){return r}})},667585,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let r=e.r(132061);function s({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new r.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},652157,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return o}});let r=e.r(843476),s=e.r(174080),a=e.r(563599),l=e.r(309885),i=e.r(543369);function o({moduleIds:e}){if("u">typeof window)return null;let t=a.workAsyncStorage.getStore();if(void 0===t)return null;let n=[];if(t.reactLoadableManifest&&e){let r=t.reactLoadableManifest;for(let t of e){if(!r[t])continue;let e=r[t].files;n.push(...e)}}if(0===n.length)return null;let u=(0,i.getAssetTokenQuery)();return(0,r.jsx)(r.Fragment,{children:n.map(e=>{let n=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${u}`;return e.endsWith(".css")?(0,r.jsx)("link",{precedence:"dynamic",href:n,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,s.preload)(n,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},869093,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return u}});let r=e.r(843476),s=e.r(271645),a=e.r(667585),l=e.r(652157);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},u=function(e){let t={...o,...e},n=(0,s.lazy)(()=>t.loader().then(i)),u=t.loading;function c(e){let i=u?(0,r.jsx)(u,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,c=o?s.Suspense:s.Fragment,d=t.ssr?(0,r.jsxs)(r.Fragment,{children:["u"<typeof window?(0,r.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(a.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(c,{...o?{fallback:i}:{},children:d})}return c.displayName="LoadableComponent",c}},770703,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return s}});let r=e.r(555682)._(e.r(869093));function s(e,t){let n={};"function"==typeof e&&(n.loader=e);let s={...n,...t};return(0,r.default)({...s,modules:s.loadableGenerated?.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},618566,(e,t,n)=>{t.exports=e.r(976562)}]);