thursday-agent 0.30.0 → 0.31.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.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/artifact/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/file/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/lessons/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/tool-result/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/automatic/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/catalog/[provider]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/credits/[provider]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
- package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
- package/.next/server/app/api/reach/route.js.nft.json +1 -1
- package/.next/server/app/api/routine/route.js.nft.json +1 -1
- package/.next/server/app/api/signins/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/end/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/plan/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/settings/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
- package/.next/server/app/api/update/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/route.js.nft.json +1 -1
- package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +11 -11
- package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
- package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page/server-reference-manifest.json +71 -71
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0sg3_9d._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0wnd1ac._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__10x2qg8._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__1bk734v._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1rs2v4h._.js +1 -1
- package/.next/server/chunks/_0jzv71c._.js +2 -2
- package/.next/server/chunks/ssr/[root-of-the-server]__0auk-ke._.js +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__0rpm20m._.js → [root-of-the-server]__0k7utnr._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__0x2--_p._.js → [root-of-the-server]__0q3gl-j._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__0ama9d0._.js → [root-of-the-server]__0w1mcuc._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__145268e._.js → [root-of-the-server]__188x-0h._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__0p0cgo1._.js → [root-of-the-server]__1e4oxhz._.js} +2 -2
- package/.next/server/chunks/ssr/[root-of-the-server]__1j-bkt7._.js +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__153-ebp._.js → [root-of-the-server]__20dnr0-._.js} +2 -2
- package/.next/server/chunks/ssr/{_1fua8fv._.js → _058z7m3._.js} +2 -2
- package/.next/server/chunks/ssr/{_0rm-9aj._.js → _0a6m-4f._.js} +2 -2
- package/.next/server/chunks/ssr/_0akma_h._.js +1 -1
- package/.next/server/chunks/ssr/{_1q30h74._.js → _0bapnk-._.js} +2 -2
- package/.next/server/chunks/ssr/_0e7c-z3._.js +3 -0
- package/.next/server/chunks/ssr/_0gx6qzr._.js +1 -1
- package/.next/server/chunks/ssr/{_0k06tdw._.js → _0mwfawz._.js} +3 -3
- package/.next/server/chunks/ssr/_0pg2mgq._.js +1 -1
- package/.next/server/chunks/ssr/{_18cjc9o._.js → _0r-q97k._.js} +2 -2
- package/.next/server/chunks/ssr/{_1x_6jyh._.js → _0xs4a-f._.js} +2 -2
- package/.next/server/chunks/ssr/{_0732nef._.js → _0zajldg._.js} +2 -2
- package/.next/server/chunks/ssr/_14f64h2._.js +1 -1
- package/.next/server/chunks/ssr/_16_7zeo._.js +1 -1
- package/.next/server/chunks/ssr/_17fa2ns._.js +5 -5
- package/.next/server/chunks/ssr/{_0p18b0z._.js → _18dem-7._.js} +2 -2
- package/.next/server/chunks/ssr/_1_px1o-._.js +1 -1
- package/.next/server/chunks/ssr/_1e_9qjr._.js +1 -1
- package/.next/server/chunks/ssr/_1ehd80b._.js +1 -1
- package/.next/server/chunks/ssr/_1f59vze._.js +1 -1
- package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
- package/.next/server/chunks/ssr/{_0l_qakv._.js → _1p5s8eb._.js} +2 -2
- package/.next/server/chunks/ssr/_1soynbw._.js +2 -2
- package/.next/server/chunks/ssr/{components_ui_markdown-body_tsx_0ywzjrl._.js → components_ui_markdown-body_tsx_0qqkcnl._.js} +2 -2
- package/.next/server/chunks/ssr/features_0rrgq_t._.js +1 -1
- package/.next/server/chunks/ssr/features_ai_components_model-picker_tsx_0ucb1y9._.js +1 -1
- package/.next/server/chunks/ssr/features_bot_components_01ye2wp._.js +1 -1
- package/.next/server/chunks/ssr/features_bot_components_bot-setting_tsx_01ajft6._.js +1 -1
- package/.next/server/chunks/ssr/features_bot_components_thread-setting_tsx_0yae7zy._.js +1 -1
- package/.next/server/chunks/ssr/features_config_components_config-setting_tsx_0xfwqdg._.js +1 -1
- package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
- package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
- package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
- package/.next/server/chunks/ssr/features_skills_components_skills-setting_tsx_1wtuuip._.js +1 -1
- package/.next/server/chunks/ssr/features_thursday_components_thursday-setting_tsx_1_6ydrc._.js +1 -1
- package/.next/server/chunks/ssr/{node_modules_0er1nmg._.js → node_modules_0-1vgbg._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_0a1kt26._.js → node_modules_0-ckar9._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0ze7604._.js → node_modules_00k__rl._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1bjctcm._.js → node_modules_00pm_md._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1axn4aw._.js → node_modules_01awxzc._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_0ahwwc6._.js → node_modules_02r5cr9._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1vmqt-a._.js → node_modules_02y56-t._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_060s01j._.js → node_modules_03qy_-5._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_116k0n3._.js → node_modules_04-wxwz._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0u78wn3._.js → node_modules_062omwz._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0ntw_qg._.js → node_modules_06bncpv._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1mwxdhp._.js → node_modules_06c813r._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_08xo4p2._.js → node_modules_0bnvlu3._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1d7evv9._.js → node_modules_0bo8_3v._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1le-lim._.js → node_modules_0cmpor-._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_0py4_6y._.js → node_modules_0dmey3c._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0mujceo._.js → node_modules_0e82d9d._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_03gt5eg._.js → node_modules_0fv219v._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_09e0lw8._.js → node_modules_0i60h5u._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1ih7lxu._.js → node_modules_0p6fpim._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1dm5c-u._.js → node_modules_0qfnopf._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1tfn213._.js → node_modules_0upd5np._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1lnx_h4._.js → node_modules_0uqdbkl._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1cxx8tm._.js → node_modules_0v_sl8f._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1_c3zat._.js → node_modules_0vz0i7n._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1fdivhl._.js → node_modules_0wuqamc._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1depc7o._.js → node_modules_0ww0cj5._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_16hmz5b._.js → node_modules_0xyg93a._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1kpg87p._.js → node_modules_0yt7v4_._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1q2a30m._.js → node_modules_10d_dh1._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_03ytewb._.js → node_modules_12mf6-b._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0i2j6g6._.js → node_modules_16gjro8._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_05yikon._.js → node_modules_16n2qm5._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1soi3y1._.js → node_modules_17cgr9d._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_208s6_i._.js → node_modules_18-rz5f._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0ka66-h._.js → node_modules_1_sver8._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_15_65ve._.js → node_modules_1_w2wh5._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0f3769j._.js → node_modules_1aa913r._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_19xrd6b._.js → node_modules_1aptu5w._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_0fi5we8._.js → node_modules_1cu3h7h._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0sk7kv9._.js → node_modules_1d3101y._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0mihldg._.js → node_modules_1d3tnng._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_07k-xj6._.js → node_modules_1dd8593._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0c2vpni._.js → node_modules_1evm05k._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1sphzx9._.js → node_modules_1fs4p56._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0qu8a5o._.js → node_modules_1jsmkvt._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0ted14c._.js → node_modules_1lj69na._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_02p2t58._.js → node_modules_1p53mn1._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1gxpcyd._.js → node_modules_1tecvpz._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1w8ljz0._.js → node_modules_1voere2._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_16ki2uq._.js → node_modules_1wa6ii9._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0e7nwfw._.js → node_modules_1wvsdzr._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0umtxxj._.js → node_modules_1x6dj-b._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1k-0av-._.js → node_modules_1yr3qqm._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0-s3xam._.js → node_modules_1z14x_s._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0keiwh2._.js → node_modules_1zjjxof._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_katex_dist_katex_mjs_0jhievg._.js → node_modules_katex_dist_katex_mjs_0lovye-._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_katex_dist_katex_mjs_1zcod1m._.js → node_modules_katex_dist_katex_mjs_1zzajtz._.js} +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +72 -72
- package/.next/static/chunks/{38rbtwatw658l.js → 02p1qzv-y8ojn.js} +1 -1
- package/.next/static/chunks/{21wm184xoke98.js → 0c8kcm5bf10hs.js} +5 -5
- package/.next/static/chunks/{0piazplcpaho6.js → 0msqr7mircvg3.js} +1 -1
- package/.next/static/chunks/{3da8rr3q6pt0b.js → 0tal1quf58fcp.js} +1 -1
- package/.next/static/chunks/{3iwdx3_gikxbg.js → 0tbosthr28whk.js} +2 -2
- package/.next/static/chunks/{0ocx6nt76fc71.js → 0yqy8h5u32vok.js} +1 -1
- package/.next/static/chunks/{3odtl00mfb4u7.js → 0zc0u62q44d6f.js} +1 -1
- package/.next/static/chunks/{0u_wx1-lmoae2.js → 17gy2mvd8ek83.js} +1 -1
- package/.next/static/chunks/{3x2goglbfw5t7.js → 1_8pwrnp1_qvs.js} +1 -1
- package/.next/static/chunks/{2v486bh_6kl11.js → 1ck5wi_ba02gc.js} +1 -1
- package/.next/static/chunks/{3i12sqqp1v8a8.js → 1hqsq7opotb1d.js} +1 -1
- package/.next/static/chunks/{29p2mdrn-z1oz.js → 1ih5j-j1he9w6.js} +1 -1
- package/.next/static/chunks/1jreuiyyp97su.js +1 -0
- package/.next/static/chunks/{2biit-egkb-xl.js → 1nt0py_w8q-id.js} +2 -2
- package/.next/static/chunks/{0oo3vqzbrckzw.js → 2ay3fjagqli-o.js} +1 -1
- package/.next/static/chunks/{25-zh-0nfxqyg.js → 2p7lpzd59ius6.js} +1 -1
- package/.next/static/chunks/{1fignuuc030t2.js → 2rzym-27bm4t_.js} +1 -1
- package/.next/static/chunks/2sg43yk9jd5-z.js +4 -0
- package/.next/static/chunks/{2cciu1ow-svbf.js → 2twk4sgtkwgxo.js} +1 -1
- package/.next/static/chunks/{0totfwrzgu9zy.js → 3jpa6ycdis1fh.js} +2 -2
- package/.next/static/chunks/{0nev6q2iq077s.js → 3mc-k-4e4apqr.js} +1 -1
- package/.next/static/chunks/{3k_xm_e4grb9u.js → 3o8wxqca38o3_.js} +1 -1
- package/.next/static/chunks/{3wblbyhomh9va.js → 3t1sluk82tekr.js} +1 -1
- package/.next/static/chunks/{078xraafllix3.js → 42zzm744prmio.js} +1 -1
- package/.next/static/chunks/{152u4p6c_6spk.js → 43tcpam1sdo85.js} +1 -1
- package/package.json +1 -1
- package/.next/server/chunks/ssr/_0lqzdd0._.js +0 -3
- package/.next/static/chunks/03m85vcsjg0qk.js +0 -1
- package/.next/static/chunks/2kt0nc5m372ie.js +0 -4
- /package/.next/static/{nXUvWsiGKRvNRk8kqeJ-u → UR_YhoU23yPaytwfmeAS2}/_buildManifest.js +0 -0
- /package/.next/static/{nXUvWsiGKRvNRk8kqeJ-u → UR_YhoU23yPaytwfmeAS2}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{nXUvWsiGKRvNRk8kqeJ-u → UR_YhoU23yPaytwfmeAS2}/_ssgManifest.js +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
module.exports=[102928,a=>{"use strict";var b=a.i(187924),c=a.i(752562),d=a.i(707963),e=a.i(141146),f=a.i(540990),g=a.i(164831);let h={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"}]]};h.node;let i=(0,g.default)(h),j={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"}]]};j.node;let k=(0,g.default)(j);var l=a.i(819721),m=a.i(50944),n=a.i(572131),o=a.i(767561),p=a.i(340695),q=a.i(280281),r=a.i(654816),s=a.i(905441),t=a.i(398026),u=a.i(913834),v=a.i(983874),w=a.i(864037),x=a.i(576271),y=a.i(759497),z=a.i(497895),A=a.i(111716),B=a.i(249049),C=a.i(483253);let D={hello:"Hi, I'm Thursday. One thing first: this is a recording. You'll hear my real voice on our first call.",key:"First, I need a voice. Sign in with ChatGPT, and I talk on the plan you already have. Or paste an OpenAI key, if you'd rather. Neither one yet? No problem, skip ahead. I'll ask again later.",awake:"There we go — I'm awake. That's all a call needs. The rest is quick: your microphone, and who does the work for you.",mic:"Now let me hear you. Your browser will ask before it turns the microphone on — just say yes. From then on, say 'hey Thursday' anytime, and I'll pick up.",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.",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 sign in, or 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."},E=Array(C.SPECTRUM_BANDS).fill(0),F="thursday.intro.muted";var G=a.i(647509),H=a.i(590513),I=a.i(663390),J=a.i(510072),K=a.i(661779),L=a.i(539341),M=a.i(730357);let N=[{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}],O=[.2,1.6,2.5,3.1,3.55],P=["/sounds/opening-rise.ogg","/sounds/opening-step-1.ogg","/sounds/opening-step-2.ogg","/sounds/opening-step-3.ogg","/sounds/opening-land.ogg"],Q=[2,3,1],R=[[],["🤍"],["🤍","☁️"],["☁️","🤍"],["☁️","🕊️"],["🕊️","☁️"],["🕊️","🦢"],["🦢","🕊️","☁️"],["🦢","🤍"],["🤍","⚪","🦢"],["🤍","⚪"],["⚪","🤍"]],S=[[],["🤍","⚪"],["🤍","⚪","🦢"],["🦢","🤍","🕊️"],["🦢","🕊️","☁️"],["🕊️","🦢","☁️"],["🕊️","☁️"],["☁️","🕊️"],["☁️","🖤"],["⚫","🖤","☁️"],["🖤","⚫"],["🖤","⚫"]],T=N[0].px;function U({anchor:a,onArrive:c,onHello:d,onDone:e}){let f=(0,n.useRef)(null),g=(0,M.useIsDark)(),h=(0,n.useRef)({dark:g,onArrive:c,onHello:d,onDone:e});return h.current={dark:g,onArrive:c,onHello:d,onDone:e},(0,n.useEffect)(()=>{let b=f.current,c=a.current,d={arrive:!1,hello:!1,done:!1},e=a=>{d[a]||(d[a]=!0,"arrive"===a?h.current.onArrive():"hello"===a?h.current.onHello():h.current.onDone())};if(!b||!c||window.matchMedia("(prefers-reduced-motion: reduce)").matches){e("arrive"),e("hello"),e("done");return}let g=b.getContext("2d");if(!g){e("arrive"),e("hello"),e("done");return}let i=O.map((a,b)=>a+(b>0?(Math.random()-.5)*.12:0)),j=!function(){try{return"1"===window.localStorage.getItem(F)}catch{return!1}}()?P.map(a=>{let b=new Audio(a);return b.preload="auto",b}):[],k=0,l=50*Math.random(),m=Math.min(2,window.devicePixelRatio||1),n="letters"===(0,I.faceGlyphs)(),o=n?null:function(a,b){let c=Math.round(T*b),d=Math.ceil(1.3*c),e=document.createElement("canvas");e.width=12*d,e.height=d*Math.ceil(a.length/12);let f=e.getContext("2d");if(!f)return null;f.textAlign="center",f.textBaseline="middle",f.font=(0,H.GLYPH_FONT)(c);let g=new Map;return a.forEach((a,b)=>{g.set(a,b),f.fillText(a,b%12*d+d/2,Math.floor(b/12)*d+d/2)}),{canvas:e,at:g,slot:d,scale:d/b/T}}([...new Set([...G.EMOJI_POOL,...R.flat(),...S.flat(),...Q.flatMap(a=>L.WASH_SETS[a-1].emoji)])],m);if(!n&&!o){e("arrive"),e("hello"),e("done");return}let p=G.LEVELS-1,q=[],r=null,s=()=>{let a=window.innerWidth,d=window.innerHeight;b.width=Math.round(a*m),b.height=Math.round(d*m),g.setTransform(m,0,0,m,0,0),g.textAlign="center",g.textBaseline="middle",r=null;let e=c.getBoundingClientRect(),f=Number.parseFloat(getComputedStyle(c).getPropertyValue("--face-bleed"))/100||0,h=e.width*(1+2*f),i=e.left+e.width/2,j=e.top+e.height/2,k=H.DESIGN/h;q=N.map((b,c)=>{let e=.95*b.px/b.density,f=1.25*b.px/b.density,g=.12*c,h=Math.cos(g),m=Math.sin(g),n=70+26*c,o=[];for(let g=0;g*f<d;g++)for(let d=0;d*e<a;d++){let a=d*e+e/2,p=g*f+f/2,q=(a-i)*k,r=(p-j)*k,s=(q*h-r*m)/H.REST_R/b.radii,t=(q*m+r*h)/H.REST_R/b.radii,u=Math.hypot(s,t);if(u>2.6)continue;let v=Math.floor((Math.atan2(t,s)+Math.PI)/(2*Math.PI)*n),w=(0,G.hash)(v+13*c,3.1+l),x=(0,G.hash)(1.3*v,11.1+l);o.push({x:a,y:p,r:u,dx:s*H.REST_R,dy:t*H.REST_R,drift:.02+.14*w*w,go:.15+.9*(0,G.hash)(v,7.7+c),carry:x<.13?Q[Math.floor(23*x)%Q.length]:0,nx:q*(8/b.px)*.05,ny:r*(8/b.px)*.05,seed:(0,G.hash)(d+101*c,g),grain:(0,G.hash)(5.7*d+19+c,2.3*g+53),gap:.05+.3*(0,G.hash)(7.3*d+11,3.1*g+5+c)})}let q=o.length;return{px:b.px,cells:o,fast:new Float32Array(q),slow:new Float32Array(q),wasLevel:new Int8Array(q).fill(-9),turn:new Int32Array(q).fill(-9),pick:new Int32Array(q),pool:new Int8Array(q),poolFor:new Float32Array(q),byLevel:Array.from({length:p+1},()=>new Int32Array(q)),inLevel:new Int32Array(p+1),glyph:Array(q),over:!1}})};s(),window.addEventListener("resize",s);let t=(0,K.createSmoke)(),u=90*Math.random(),v={dx:0,dy:0,dist:0},w=performance.now(),x=w,y=0,z=0,A=a=>{let c=(a-w)/1e3,d=Math.min(.05,Math.max(0,(a-x)/1e3));x=a,y+=d;let{dark:f}=h.current,l=f?R:S;n&&r!==f&&(r=f,g.fillStyle=getComputedStyle(b).color),(0,K.stepSmoke)(t,y,d,0,0,-1);let s=(0,J.windAt)(y,u),B=Math.exp(-d/H.TRAIL_FAST),C=Math.exp(-d/1.4);g.clearRect(0,0,b.width/m,b.height/m);let D=0;for(q.forEach((a,b)=>{let e=i[b],f=i[b+1];if(a.over||c<e)return;let h=c-f,j=h<=0?(0,G.smoothstep)(0,1,(c-e)/(0===b?1.2:.35)):1,k=h>0?(0,G.smoothstep)(0,.3,h):0,m=h>.05,q=y+31*b;a.inLevel.fill(0);let r=0,u=a.cells;for(let b=0;b<u.length;b++){let c=u[b],e=0,f=0;if(h<=0)j>0&&c.r<2.6&&(v.dx=c.dx,v.dy=c.dy,v.dist=c.r*H.REST_R,e=(0,K.restValue)(v,q,0,H.REST_R,j,t,s));else{let a=c.r-c.drift*h**.8,b=(1+(1.5*((0,G.smoothstep)(.6,.88,Math.abs(a))*(1-(0,G.smoothstep)(1.2,1.55,Math.abs(a))))-1)*k)*(1-(0,G.smoothstep)(c.go,c.go+.4,h));if(b>0){let d=c.r>0?a/c.r:0;v.dx=c.dx*d,v.dy=c.dy*d,v.dist=Math.abs(a)*H.REST_R,(e=(0,K.restValue)(v,q,0,H.REST_R,1,t,s)*b)>.04&&k>.5&&(f=c.carry)}}(e*=(.66+.72*c.grain)*(.8+.4*(0,G.hash)(Math.floor(c.nx+.5*y),Math.floor(c.ny-.3*y))))>.3&&(0,G.hash)(31.7*Math.floor(1.6*y),613*c.seed)>.992&&(e=Math.max(e,.9)),f?(a.pool[b]=f,a.poolFor[b]=.35*(.5+c.grain)):a.poolFor[b]>0?(a.poolFor[b]-=d,a.poolFor[b]<=0&&(a.pool[b]=0)):a.pool[b]=0;let g=a.fast[b]=e>a.fast[b]*B?e:a.fast[b]*B,i=a.slow[b]=e>a.slow[b]*C?e:a.slow[b]*C;if((e=g>.55*i?g:.55*i)<c.gap+.05*Math.sin(.28*y+6.283*c.seed))continue;let o=(e>1?1:e)*p|0;if(0===o)continue;r++;let w=y*(n?H.CHURN_LETTERS:H.CHURN_EMOJI)+7*c.seed|0;(w!==a.turn[b]||o-a.wasLevel[b]>=2||a.wasLevel[b]-o>=2)&&(a.turn[b]=w,a.wasLevel[b]=o,a.pick[b]=(997*c.seed|0)+w+o);let x=a.pick[b],z=a.pool[b]?L.WASH_SETS[a.pool[b]-1]:null,A=n?z?.letters??G.RAMP[o]:z?.emoji??(m?l[o]:G.EMOJI_POOL);a.glyph[b]=A[x%A.length],a.byLevel[o][a.inLevel[o]++]=b}D+=r,h>1.45&&0===r&&(a.over=!0),o||(g.font=(0,H.GLYPH_FONT)(a.px));for(let b=1;b<=p;b++){let c=a.inLevel[b];if(0===c)continue;let d=a.byLevel[b];if(!o){g.globalAlpha=G.ALPHA_TOP*(b/p);for(let b=0;b<c;b++){let c=u[d[b]];g.fillText(a.glyph[d[b]],c.x,c.y)}continue}g.globalAlpha=(0,G.emojiAlpha)(b,p);let e=a.px*o.scale*(.5+.5*(0,G.emojiWeight)(b,p));for(let b=0;b<c;b++){let c=u[d[b]],f=o.at.get(a.glyph[d[b]])??0;g.drawImage(o.canvas,f%12*o.slot,Math.floor(f/12)*o.slot,o.slot,o.slot,c.x-e/2,c.y-e/2,e,e)}}}),g.globalAlpha=1;k<j.length&&c>=i[k];k++)j[k].play().catch(()=>{});if(c>=i[4]&&e("arrive"),c>=4.7&&e("hello"),c>i[4]+1.6&&0===D){g.clearRect(0,0,b.width/m,b.height/m),e("done");return}z=requestAnimationFrame(A)};return z=requestAnimationFrame(A),()=>{if(cancelAnimationFrame(z),window.removeEventListener("resize",s),!d.done)for(let a of j)!function(a,b=.4){if(a.paused)return;let c=a.volume,d=performance.now(),e=f=>{let g=Math.max(0,Math.min(1,(f-d)/1e3/b));a.volume=c*(1-g),g<1?requestAnimationFrame(e):a.pause()};requestAnimationFrame(e)}(a)}},[a]),(0,b.jsx)("canvas",{ref:f,"aria-hidden":!0,className:"pointer-events-none absolute inset-0 size-full text-foreground"})}var V=a.i(405050);let W=(0,V.createServerReference)("7ff5d09eddb7f084b59a295dcc8ef93a3ec14e667d",V.callServer,void 0,V.findSourceMapURL,"passIntroAction");var X=a.i(444324),Y=a.i(445432),Z=a.i(587479),$=a.i(152659),_=a.i(158697),aa=a.i(650485),ab=a.i(359006),ac=a.i(926919),ad=a.i(645323),ae=a.i(77453),af=a.i(199169);let ag=["key","mic","bots","style","call"],ah=(0,l.default)(async()=>{},{loadableGenerated:{modules:[590714]},ssr:!1}),ai="Everyone did their part. The team is ready for you.";function aj({children:a}){return(0,b.jsxs)("p",{className:"text-[17px] leading-[1.675] tracking-[0.3px]",children:[(0,b.jsx)("span",{className:"mr-4 inline-block size-2.5 rounded-full bg-foreground align-middle opacity-55"}),a]})}let ak=({children:a})=>(0,b.jsx)("p",{className:"font-mono text-[11px] leading-relaxed text-pretty text-muted-foreground",children:a});function al({children:a,tail:d}){return(0,b.jsxs)("p",{className:"flex items-center gap-2.5 text-sm",children:[(0,b.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,b.jsx)(c.Check,{className:"size-3"})}),(0,b.jsx)("span",{className:"animate-in delay-150 duration-300 fill-mode-backwards fade-in slide-in-from-left-1",children:a}),d&&(0,b.jsx)("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:d})]})}function am({onSaved:a}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Give her a voice"}),(0,b.jsx)(B.CallLines,{onSaved:a})]})}function an({mic:a}){let c=(0,ab.useThursdayStore)(a=>a.wake);return a.allowed?(0,b.jsx)(al,{children:`Microphone on, and "${c.phrase}" calls her`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Turn on the microphone"}),a.failed?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:(0,z.cn)("text-[13px] leading-normal",z.WAITING_INK),children:a.failed.what}),(0,b.jsx)(ak,{children:a.failed.next})]}):(0,b.jsxs)(ak,{children:['On a call, and to hear "',c.phrase,'" while this tab is open. Chrome does that listening and sends what it hears to Google; Settings › Thursday switches it off.']})]})}function ao({picked:a,onToggle:c}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Pick who comes along"}),(0,b.jsx)("div",{className:"flex flex-col",children:t.BOT_SEEDS.map(d=>{let e=!!a[d.name];return(0,b.jsxs)("label",{className:"flex min-h-9.5 cursor-pointer items-center gap-2.75 py-1",children:[(0,b.jsx)(u.BotMark,{size:24,seed:d.name,...d.icon,notify:!1,className:(0,z.cn)("shrink-0 transition-opacity",!e&&"opacity-40")}),(0,b.jsx)("span",{className:(0,z.cn)("w-17.5 shrink-0 text-[13.5px] font-medium",!e&&"text-muted-foreground"),children:d.name}),(0,b.jsx)("span",{className:"min-w-0 flex-1 text-xs leading-snug text-pretty text-muted-foreground",children:d.hint}),(0,b.jsx)(q.Switch,{checked:e,onCheckedChange:()=>c(d.name)})]},d.name)})}),(0,b.jsx)(ak,{children:"Every one comes along. Switch off any you will not use: Settings › Bots has them all, and you can make your own."})]})}function ap(){let{settings:a,patch:c}=(0,ac.useLiveSettings)(),f=Math.max(0,s.PERSONAS.findIndex(b=>b.id===a?.persona)),g=s.PERSONAS[f],h=a=>c({persona:s.PERSONAS[(f+a+s.PERSONAS.length)%s.PERSONAS.length].id});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Pick how she talks"}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("div",{className:"text-2xl font-semibold",children:g.label}),(0,b.jsx)("p",{className:"min-h-10 text-sm text-muted-foreground",children:g.about})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>h(-1),children:[(0,b.jsx)(d.ChevronLeft,{}),"Previous"]}),(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>h(1),children:["Next",(0,b.jsx)(e.ChevronRight,{})]})]}),(0,b.jsx)("div",{className:"flex gap-1.5",children:s.PERSONAS.map((a,c)=>(0,b.jsx)("span",{className:(0,z.cn)("h-0.5 w-5 rounded-full",c===f?"bg-foreground":"bg-border")},a.id))})]})}function aq({mic:a,bots:d}){let e=["voice",a?"microphone":null,d>0?`${d} ${1===d?"bot":"bots"}`:null].filter(a=>null!==a);return(0,b.jsx)("span",{className:"flex items-center gap-2 text-xs",children:e.map((a,d)=>(0,b.jsxs)("span",{style:{animationDelay:`${300+260*d}ms`},className:"flex animate-in items-center gap-2 duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:[d>0&&(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(c.Check,{className:"size-3.25"}),a]})]},a))})}let ar={ask:"Find me flights to Osaka in October.",onIt:`On it. ${t.ERRANDS_BOT} is looking. Keep talking, I will say when it is back.`,back:`${t.ERRANDS_BOT} is back. The Tuesday morning flight is the pick. The page is on your screen.`},as={threadId:"demo",label:"Osaka flights, October",bot:t.ERRANDS_BOT,words:"Three fares compared. The Tuesday morning one is the pick: direct, and the cheapest by a little.",paths:[]};function at({stage:a}){return(0,b.jsxs)(b.Fragment,{children:["landed"===a&&(0,b.jsx)("div",{className:"pointer-events-none absolute bottom-5 left-5 w-90 text-left",children:(0,b.jsx)(ad.FinishedCard,{row:as,bot:{icon:(0,t.findBotSeed)(as.bot)?.icon??null},onOpen:()=>{},onClose:()=>{}})}),(0,b.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,b.jsx)("span",{className:"flex",children:t.BOT_SEEDS.map((c,d)=>(0,b.jsx)(u.BotMark,{size:22,seed:c.name,...c.icon,state:"working"===a&&c.name===t.ERRANDS_BOT?"thinking":"idle",notify:!1,className:(0,z.cn)("shrink-0",d>0&&"-ml-1.5")},c.name))}),(0,b.jsx)("span",{className:"w-40 truncate text-left text-[13px] text-muted-foreground",children:"working"===a?`${t.ERRANDS_BOT} \xb7 reading fares`:"landed"===a?`${t.ERRANDS_BOT} finished`:"Need a hand?"})]})]})}a.s(["Intro",0,function({ready:a,firstRun:c,forced:g}){let h=c||g,j=(0,m.useRouter)(),[l,q]=(0,n.useState)("hello"),[s,u]=(0,n.useState)(!1),[G,H]=(0,n.useState)(!1),[I,J]=(0,n.useState)(a),K=(0,B.useVoiceLine)(),L=I||null!==K.line,M=(0,n.useRef)(L);(0,n.useEffect)(()=>{L&&!M.current&&O((0,$.awake)()),M.current=L},[L]);let[N,O]=(0,n.useState)(null),[P,Q]=(0,n.useState)(()=>Object.fromEntries(t.BOT_SEEDS.map(a=>[a.name,!0]))),[R,S]=(0,n.useState)("echoes"),T=(0,ab.useThursdayStore)(a=>a.wake),V=(0,ab.useThursdayStore)(a=>a.patch),ac="bots"===l,ad=(0,ae.useAwayAfter)(ac,700),[aj,ak]=(0,n.useState)(!1),[al,as]=(0,n.useState)(null),[au,av]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(ac){as(new Date),av(!1),ak(!0);let a=setTimeout(()=>av(!0),5e3);return()=>clearTimeout(a)}let a=setTimeout(()=>ak(!1),250);return()=>clearTimeout(a)},[ac]);let aw=(0,n.useMemo)(()=>al&&function(a,b,c){let[d,...e]=a;if(!d)return null;let f=a=>({name:a,icon:(0,t.findBotSeed)(a)?.icon??null}),g=new Date(b.getTime()-95e3),h=a=>new Date(g.getTime()+1e3*a),i=e.flatMap((a,b)=>{let e=(0,t.findBotSeed)(a)?.hint??a,g=2+2.5*b;return[{id:`intro-ask-${a}-0`,bot:f(d),to:f(a),text:e,kind:"ask",exchange:`intro-${a}`,parent:"intro-lead",at:h(g)},{id:`intro-step-${a}-0`,bot:f(a),to:null,text:e,kind:"say",parent:`intro-${a}`,at:h(g+1.2)},...c?[{id:`intro-back-${a}-0`,bot:f(a),to:null,text:"Done.",kind:"say",parent:`intro-${a}`,at:h(100)}]:[]]});return c&&i.push({id:"intro-report-0",bot:f(d),to:null,text:ai,kind:"result",parent:"intro-lead",at:h(100)}),{id:`intro-team-${b.getTime()}`,request:"Who works for you",label:"Who works for you",bot:f(d),roster:a.map(f),lines:i.sort((a,b)=>(0,af.toDate)(a.at??g).getTime()-(0,af.toDate)(b.at??g).getTime()),room:{participants:a.map(a=>({bot:a,state:c?"done":a===d?"waiting":"running"})),questions:[],deliveries:[],relays:[],exchanges:[{id:"intro-lead",bot:d,caller:v.ROOM_THURSDAY,state:c?"done":"waiting",waitsFor:[]},...e.map(a=>({id:`intro-${a}`,bot:a,caller:d,state:c?"done":"running",waitsFor:[]}))]},status:c?"done":"working",outcome:c?ai:null,ask:null,seen:!0,routineId:null,tokens:{input:0,output:0},contextTokens:0,contextBudget:0,createdAt:g,updatedAt:c?h(100):b}}(t.BOT_SEEDS.filter(a=>P[a.name]).map(a=>a.name),al,au),[P,al,au]),ax="hello"===R||"over"===R,ay=(0,n.useRef)(null),az=function(){let[a,b]=(0,n.useState)("off"),[c,d]=(0,n.useState)(!1);return{asking:"asking"===a,failed:"object"==typeof a?a:null,allowed:c,turnOn:(0,n.useCallback)(async()=>{b("asking");try{for(let a of(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks())a.stop();return b("off"),d(!0),!0}catch(a){return b(function(a){let b=a instanceof DOMException?a.name:"",c=(0,_.micProblem)(a);if("refused"===c)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("missing"===c)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("busy"===c)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 d=a instanceof Error&&a.message||b||String(a);return{what:"The microphone did not open.",next:`The browser said "${d}". Or just go on.`}}(a)),!1}},[])}}(),aA=function(a){let[b,c]=(0,n.useState)(0);(0,n.useEffect)(()=>{if(!a)return;let b=performance.now(),d=setInterval(()=>c((performance.now()-b)%16e3),120);return()=>clearInterval(d)},[a]);let d=(a,b,c)=>({id:a,role:b,text:c}),e=[];b>900&&e.push(d("ask","user",ar.ask)),b>4700&&e.push(d("onIt","assistant",ar.onIt)),b>11500&&e.push(d("back","assistant",ar.back));let f=b>4700&&b<8300||b>11500&&b<14500;return{turns:e,status:f?"speaking":b>900&&b<4700?"listening":"idle",stage:b>9600?"landed":b>5400?"working":b>900?"asked":"rest",saying:f,voice:aa.silentVoice}}("hello"===l&&h&&!s&&ax),aB=h&&!s;(0,n.useEffect)(()=>(X.callSignal.hold(aB),()=>X.callSignal.hold(!1)),[aB]),(0,n.useEffect)(()=>{if(!s)return;let a=setTimeout(()=>H(!0),700);return()=>clearTimeout(a)},[s]);let aC=ag.indexOf(l),{data:aD}=(0,y.useServerRoute)(o.queryKey.automaticModel),aE=!!aD?.ref,aF=(0,n.useMemo)(()=>{var a,b,c;let d,e;return a=l,b=L,c=aE,d=(a,b)=>({id:a,role:"assistant",text:b}),e=[],"hello"===a||(e.push(d("key","I am Thursday, and the first thing I need is a voice. Sign in with ChatGPT and I talk on your plan, or paste an OpenAI key. Neither yet? Go on without it, and I will ask again when you call.")),b&&e.push(d("awake","There, I am awake, and that is everything a call needs. From here on it is quick: your microphone, and who works for you.")),"key"===a||(e.push(d("mic","Now let me hear you. Your browser asks before it opens the microphone: say yes. From then on, saying hey Thursday calls me.")),"mic"===a||(e.push(d("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"===a||(e.push(d("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"===a||e.push(b?d("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."):c?d("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 sign in or have a key, and I will take it from there."):d("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.")))))),e},[l,L,aE]),aG="hello"===l?aA.turns:aF,aH=(0,Z.useTurnFocus)(aG,aB),aI=function(a){let b=(0,n.useRef)(null),c=(0,n.useRef)(new Set),d=(0,n.useRef)([]),e=(0,n.useRef)(!1),[f,g]=(0,n.useState)(!1),[h,i]=(0,n.useState)(!1),j=(0,n.useRef)(!1);(0,n.useEffect)(()=>{try{let a="1"===window.localStorage.getItem(F);j.current=a,i(a)}catch{}},[]);let k=(0,n.useCallback)(()=>{d.current=[],b.current?.audio.pause()},[]),l=(0,n.useCallback)(()=>{let a=d.current.shift();if(!a||!b.current)return;let{audio:c,clip:e}=b.current;e.resume(),c.src=`/voices/intro/${a}-${function(a){let b=0x811c9dc5;for(let c of`marin|${a}`)b^=c.codePointAt(0)??0,b=Math.imul(b,0x1000193);return(b>>>0).toString(16).padStart(8,"0")}(D[a])}.ogg`,c.play().catch(()=>{})},[]),m=(0,n.useCallback)((...a)=>{let f=a.filter(a=>!c.current.has(a));if(!j.current&&f.length){if(!b.current){let a=new Audio,c=a=>()=>{e.current=a,g(a)};for(let b of(a.addEventListener("playing",c(!0)),["pause","ended","error"]))a.addEventListener(b,c(!1));a.addEventListener("ended",l),a.addEventListener("error",l),b.current={audio:a,clip:(0,C.createClipTap)(a)}}for(let a of f)c.current.add(a);d.current=f,l()}},[l]);(0,n.useEffect)(()=>{a&&b.current&&m(a)},[a,m]),(0,n.useEffect)(()=>()=>{b.current?.audio.pause(),b.current?.clip.close(),b.current=null},[]);let o=(0,n.useCallback)(()=>{let b=!j.current;j.current=b,i(b);try{window.localStorage.setItem(F,b?"1":"0")}catch{}if(b)return k();a&&(c.current.delete(a),m(a))},[k,a,m]);return{say:m,hush:k,speaking:f,muted:h,toggle:o,spectrum:(0,n.useCallback)(()=>b.current&&e.current?b.current.clip.read():E,[])}}(s?null:aF.at(-1)?.id??null);if(G||!h)return null;let aJ=a=>{if(aI.hush(),u(!0),c){let a;(a=t.BOT_SEEDS.filter(a=>P[a.name]).map(a=>({name:a.name}))??t.BOT_SEEDS.map(a=>({name:a.name}))).length&&(0,A.createSeedBotsAction)(a).then(x.unwrapResult).then(()=>(0,y.revalidate)(o.queryKey.bot)).catch(a=>w.toast.add({type:"warning",title:"Could not set up the bots",description:(0,z.errorToString)(a)})),W()}a&&X.callSignal.place(),j.replace("/"),j.refresh()},aK="hello"===l?aA.status:aI.speaking?"speaking":"idle",aL="call"===l,aM="hello"!==l;return(0,b.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Getting started",className:(0,z.cn)("fixed inset-0 z-40 bg-background transition-opacity duration-700 [--face-w:min(20rem,52vw,37.5vh)]",s&&"pointer-events-none opacity-0"),children:[aj&&aw&&(0,b.jsx)(ah,{thread:aw,leaving:!ac,className:"absolute inset-y-0 left-0 right-[calc(50%-var(--face-w)*0.695)] mask-[linear-gradient(to_right,black_80%,transparent)]"}),"over"!==R&&(0,b.jsx)(U,{anchor:ay,onArrive:()=>S("her"),onHello:()=>S("hello"),onDone:()=>S("over")}),ax&&(0,b.jsx)(r.TooltipProvider,{children:(0,b.jsxs)(r.Tooltip,{children:[(0,b.jsx)(r.TooltipTrigger,{render:(0,b.jsx)(p.Button,{size:"icon",variant:"ghost",onClick:aI.toggle,"aria-label":aI.muted?"Let her speak":"Mute her","aria-pressed":aI.muted,className:"absolute top-5 right-5 z-10 text-muted-foreground hover:text-foreground"}),children:aI.muted?(0,b.jsx)(k,{}):(0,b.jsx)(i,{})}),(0,b.jsx)(r.TooltipContent,{side:"bottom",children:aI.muted?"Let her speak":"Mute her voice"})]})}),(0,b.jsxs)("div",{className:(0,z.cn)("relative flex h-full flex-col items-center justify-center gap-5 pt-[7vh]",ac&&"pointer-events-none",aM&&"max-[900px]:pointer-events-auto max-[900px]:justify-start max-[900px]:overflow-y-auto max-[900px]:pb-20"),children:[(0,b.jsxs)("div",{ref:ay,className:(0,z.cn)("relative w-(--face-w) [--face-bleed:19.5%]",aM&&"max-[900px]:flex max-[900px]:w-full max-[900px]:flex-col max-[900px]:items-center max-[900px]:gap-7"),children:[(0,b.jsx)("button",{type:"button",disabled:!aL||!L,onClick:()=>aJ(!0),"aria-label":aL&&L?"Call Thursday":void 0,className:(0,z.cn)("block w-full rounded-full outline-none transition-all duration-700 ease-out focus-visible:ring-3 focus-visible:ring-ring/50","hello"!==l&&!L&&"opacity-35",ac&&"pointer-events-none opacity-0",aM&&"max-[900px]:mt-6 max-[900px]:w-[min(8rem,20vh)]"),children:"echoes"!==R?(0,b.jsx)(Y.Face,{status:aK,failed:!1,word:N,getSpectrum:"hello"===l?aA.voice:aI.spectrum,waking:!0,covered:ad,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"}):(0,b.jsx)("div",{className:"aspect-square w-full"})}),(0,b.jsx)("div",{className:(0,z.cn)(aM&&"max-[900px]:hidden",ac&&"hidden"),children:(0,b.jsx)(Z.SideCaptions,{turns:aG,pinned:aH.pinned,live:"hello"===l?aA.saying:aI.speaking,onPick:aH.pick})}),aM&&(0,b.jsx)("p",{className:"hidden w-[min(22rem,calc(100vw-2rem))] text-left text-[15px] leading-[1.6] text-foreground max-[900px]:block",children:aF.at(-1)?.text}),"hello"!==l&&(0,b.jsxs)("div",{className:"pointer-events-auto 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 max-[900px]:static max-[900px]:ml-0 max-[900px]:w-[min(22rem,calc(100vw-2rem))] max-[900px]:translate-y-0",children:["key"===l&&(0,b.jsx)(am,{onSaved:()=>J(!0)}),"mic"===l&&(0,b.jsx)(an,{mic:az}),"bots"===l&&(0,b.jsx)("p",{className:"text-[15px] leading-[1.6] text-foreground max-[900px]:hidden",children:aF.at(-1)?.text}),"bots"===l&&(0,b.jsx)(ao,{picked:P,onToggle:a=>Q(b=>({...b,[a]:!b[a]}))}),"style"===l&&(0,b.jsx)(ap,{})]},l)]}),(0,b.jsxs)("div",{className:(0,z.cn)("relative flex w-full max-w-3xl flex-col items-center gap-4 px-6 text-center transition-transform duration-700 ease-out","hello"===l&&"translate-y-[calc(var(--face-w)*0.195)]"),children:[(0,b.jsx)("div",{className:"flex h-14 items-center gap-2 text-[13px] text-muted-foreground",children:"hello"===l?ax&&(0,b.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."}):ac?null:L?aL?(0,b.jsx)(aq,{mic:az.allowed,bots:t.BOT_SEEDS.filter(a=>P[a.name]).length}):null:"Asleep"}),"hello"!==l||ax?(0,b.jsxs)(p.Button,{variant:"key"!==l||L?"brand":"default",loading:"mic"===l&&az.asking,onClick:()=>{"hello"===l?(aI.say("hello",L?"awake":"key"),q("key")):"mic"!==l||az.allowed?aL?aJ(L):q(ag[aC+1]):az.turnOn().then(a=>{a&&(V({wake:{...T,enabled:!0}}),q(a=>"mic"===a?"bots":a))})},className:(0,z.cn)("pointer-events-auto h-12 rounded-full px-7 pl-8 text-[15px]","mic"===l&&!az.allowed&&"pl-6","hello"===l&&"animate-in delay-300 duration-700 fill-mode-backwards fade-in slide-in-from-bottom-2"),children:["mic"===l&&!az.allowed&&!az.asking&&(0,b.jsx)(f.Mic,{}),"hello"===l?"Start":"mic"!==l||az.allowed?aL?L?"Call her":"Look around":"Continue":"Turn on the microphone",(0,b.jsx)(e.ChevronRight,{})]}):(0,b.jsx)("div",{className:"h-12"}),(0,b.jsx)("p",{className:"h-4 font-mono text-[11px] text-muted-foreground",children:"hello"===l?ax&&(0,b.jsx)("span",{className:"block animate-in delay-500 duration-700 fill-mode-backwards fade-in",children:"two minutes · every step can wait"}):"key"!==l||L?"mic"===l&&az.asking?"your browser is asking — allow it at the top of the window":"mic"!==l||az.allowed?aL&&L?"or tap her":"":(0,b.jsx)("button",{type:"button",onClick:()=>q(ag[aC+1]),className:"rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"not now — allow it when the first call asks"}):"neither is fine — both can wait for the call screen"})]})]}),"hello"===l?ax&&(0,b.jsx)(at,{stage:aA.stage}):(0,b.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 [@media(max-height:720px)]:bottom-3",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>q(aC>0?ag[aC-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,b.jsx)(d.ChevronLeft,{className:"size-3"}),"Back"]}),(0,b.jsxs)("span",{className:"flex items-center gap-4.5",children:[(0,b.jsx)("span",{className:"flex items-center gap-1.75",children:ag.map((a,c)=>(0,b.jsx)("span",{className:(0,z.cn)("h-1.75 rounded-full transition-all duration-300",c===aC?"w-5.5 bg-foreground":"w-1.75",c<aC&&"bg-foreground/40",c>aC&&"bg-border")},a))}),(0,b.jsxs)("span",{children:[aC+1," of ",ag.length]})]}),aL&&!L?(0,b.jsx)("span",{}):(0,b.jsx)("button",{type:"button",onClick:()=>aJ(!1),className:(0,z.cn)("justify-self-start rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",aL&&"text-muted-foreground"),children:aL?"Look around first":"Skip all"})]})]})}],102928)},484267,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(986368),e=a.i(767561),f=a.i(446181),g=a.i(864037),h=a.i(576271),i=a.i(759497),j=a.i(497895),k=a.i(405050);let l=(0,k.createServerReference)("7f19cb96e2b6e0a07fa86d114c6f48ffddb3efece0",k.callServer,void 0,k.findSourceMapURL,"allowReachAction"),m=(0,k.createServerReference)("7f1525333b0c35ec169735256e078d365306bf6afd",k.callServer,void 0,k.findSourceMapURL,"declineReachAction");var n=a.i(907602);a.s(["ReachAsk",0,function(){let{data:a}=(0,i.useServerRoute)(e.queryKey.reach);(0,d.useAppEvent)({reach:()=>void(0,i.revalidate)(e.queryKey.reach)});let k=(0,c.useRef)(null),o=a?.channels.find(a=>a.asking)??null,p=o?.asking??null,q=o?.name??null,r=p&&q?`${q}:${p.chat}:${p.code}`:null;return(0,c.useEffect)(()=>{if(k.current?.key===r||(k.current?.close.abort(),k.current=null,!r||!p||!q))return;let a=new AbortController;k.current={key:r,close:a};let c={chat:p.chat,code:p.code};f.notify.confirm({title:`Let ${p.name} reach Thursday from a phone?`,description:(0,b.jsxs)("span",{className:"line-clamp-2",children:[[n.REACH_LABEL[q],p.name,p.handle].filter(Boolean).join(" · "),p.said&&` wrote “${p.said}”`]}),body:(0,b.jsxs)("div",{className:"grid gap-4",children:[(0,b.jsxs)("div",{className:"grid place-items-center gap-1.5 rounded-lg bg-muted p-4",children:[(0,b.jsx)("span",{className:"pl-[0.32em] font-mono text-3xl font-medium tracking-[0.32em]",children:p.code}),(0,b.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:"the code their phone was sent"})]}),(0,b.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:a.signal}).then(b=>{if(!a.signal.aborted)return(b?l(q,c):m(q,c)).then(h.unwrapResult).catch(a=>g.toast.add({type:"error",title:b?`Could not let ${p.name} in`:`Could not turn ${p.name} away`,description:(0,j.errorToString)(a)}))})},[r,p,q]),null}],484267)},72962,a=>{"use strict";var b=a.i(187924),c=a.i(572131);a.s(["Boot",0,function(){let[a,d]=(0,c.useState)(!1);return((0,c.useEffect)(()=>d(!0),[]),a)?null:(0,b.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."})}])},137079,a=>{"use strict";var b,c,d=a.i(187924),e=a.i(830988),f=a.i(589027),g=a.i(113608),h=a.i(164831);let i={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"}]]};i.node;let j=(0,h.default)(i);var k=a.i(540990);let l={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"}]]};l.node;let m=(0,h.default)(l),n={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"}]]};n.node;let o=(0,h.default)(n);var p=a.i(639466),q=a.i(474215),r=a.i(819721),s=a.i(572131),t=a.i(767561),u=a.i(340695),v=a.i(400187),w=a.i(497895);let x=(0,v.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 y({className:a,orientation:b="horizontal",...c}){return(0,d.jsx)("div",{"data-slot":"button-group","data-orientation":b,role:"group",className:(0,w.cn)(x({orientation:b}),a),...c})}var z=a.i(511576),A=a.i(545097),B=a.i(446334),C=a.i(654816),D=a.i(287702),E=a.i(96340),F=a.i(61876),G=a.i(411509),H=a.i(913834);let I={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};I.node;let J=(0,h.default)(I);var K=a.i(986368),L=a.i(777794),M=a.i(36304),N=a.i(988422),O=a.i(346075);function P(a,b){let c=(0,s.useRef)(b);c.current=b,(0,s.useEffect)(()=>{if(!a)return;let b=document.activeElement,d=b instanceof HTMLElement&&b!==document.body?b:null,e=c.current;return()=>{let a=0,b=()=>{let c=document.activeElement;if(!c||c===document.body){let a=d?.isConnected?d:e?document.querySelector(`[data-focus-home="${CSS.escape(e)}"]`):null;if(a)return void a.focus({preventScroll:!0})}++a<30&&requestAnimationFrame(b)};requestAnimationFrame(b)}},[a])}var Q=a.i(332033);function R(a){return(0,s.useSyncExternalStore)(b=>{let c=window.matchMedia(`(min-width: ${a}px)`);return c.addEventListener("change",b),()=>c.removeEventListener("change",b)},()=>window.matchMedia(`(min-width: ${a}px)`).matches,()=>!0)}var S=a.i(199169),T=a.i(862966),U=a.i(759497),V=a.i(135432),W=a.i(181809),X=a.i(256711),Y=a.i(42724),Z=a.i(934754),$=a.i(57270),_=a.i(912402),aa=a.i(11065),ab=a.i(707963),ac=a.i(231500),ad=a.i(875160),ae=a.i(19895),af=a.i(446181),ag=a.i(950463),ah=a.i(621958),ai=a.i(405050);let aj=(0,ai.createServerReference)("7f4f5258872eb7ef18217b671341eeb693eb372e20",ai.callServer,void 0,ai.findSourceMapURL,"cancelRunningThreadsAction");var ak=a.i(42380),al=a.i(156819),am=a.i(28996),an=a.i(313237);function ao(){let a=(0,V.useBotThreads)(),b=(0,V.useRingingThreads)();return(0,s.useMemo)(()=>[...a].reverse().filter(a=>!b.includes(a.id)&&(0,G.needsThreadReply)(a)),[a,b])}function ap({tab:a,current:b,working:c,onTab:e,onClose:f}){let[g,h]=(0,an.useServerAction)(aj,{onOk:({stopped:a})=>{for(let b of((0,U.revalidate)(t.queryKey.threads),a))V.screenActs.announce({kind:"stopped",id:b.id,label:b.label})}}),i=async()=>{await af.notify.confirm({title:1===c?"Stop the thread at work?":`Stop the ${c} threads at work?`,description:"Each bot stops where it is. The threads are kept, and saying more to one carries it on. A thread waiting on your answer is left as it is.",okText:"Stop all",destructive:!0})&&g()};return(0,d.jsxs)("div",{className:"flex items-center gap-2 pt-3 pr-3.5 pb-1.5 pl-2.5",children:[(0,d.jsx)(ah.Tabs,{value:a,onValueChange:a=>e(a),className:"gap-0",children:(0,d.jsxs)(ah.TabsList,{className:"gap-1 rounded-none bg-transparent p-0 group-data-horizontal/tabs:h-auto",children:[(0,d.jsxs)(ah.TabsTrigger,{value:"now",className:W.TAB,children:["Now",b>0&&(0,d.jsx)("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:b})]}),(0,d.jsx)(ah.TabsTrigger,{value:"history",className:W.TAB,children:"History"})]})}),(0,d.jsx)("span",{className:"flex-1"}),"now"===a&&c>0&&(0,d.jsxs)(u.Button,{type:"button",size:"sm",variant:"ghost",loading:h,onClick:i,className:"h-7 shrink-0 gap-1.5 rounded-full px-2.5 text-[12px]",children:[!h&&(0,d.jsx)(ae.Square,{className:"size-2.5 fill-current"}),"Stop all"]}),(0,d.jsx)(W.FoldButton,{onClick:f})]})}function aq({bots:a}){return(0,d.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:a?.length?"Nothing handed over yet — ask for something that takes a while.":`Thursday hands work to ${G.DEFAULT_BOT.name} until you make bots of your own in Settings › Bots.`})}function ar(){return(0,d.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:"Nothing running or waiting."})}function as({pages:a,threads:b,scroll:c,onPick:e}){let f=(0,s.useCallback)(a=>{a&&(a.scrollTop=c.current)},[c]),g=[];for(let a of b){let b=function(a){let b=(0,S.toDate)(a);return(0,_.isToday)(b)?"today":(0,aa.isYesterday)(b)?"yesterday":(0,X.format)(b,function(a,b){let[c,d]=(0,$.normalizeDates)(void 0,a,b);return c.getFullYear()===d.getFullYear()}((0,Y.constructFrom)(b,b),(0,Z.constructNow)(b))?"MMM d":"MMM d, yyyy").toLowerCase()}(a.updatedAt),c=g.at(-1);c?.day===b?c.rows.push(a):g.push({day:b,rows:[a]})}return(0,d.jsx)("div",{ref:f,onScroll:a=>{c.current=a.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:a.error?(0,d.jsx)("p",{className:"px-2.5 py-3 text-[12px] text-destructive",children:a.error.message}):a.isLoading?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"flex h-6 items-center px-2.5 pt-1",children:(0,d.jsx)(ag.Skeleton,{className:"h-2.5 w-16"})}),(0,d.jsx)(au,{})]}):(0,d.jsxs)(d.Fragment,{children:[g.map((a,b)=>(0,d.jsxs)(s.Fragment,{children:[(0,d.jsxs)("p",{className:(0,w.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===b?"pt-1":"pt-3"),children:[a.day," · ",a.rows.length]}),a.rows.map(a=>(0,d.jsx)(ax,{thread:a,onPick:()=>e(a.id)},a.id))]},a.day)),a.hasMore?(0,d.jsx)("div",{ref:a.sentinelRef,children:(0,d.jsx)(au,{})}):0===g.length&&(0,d.jsx)("p",{className:"px-6 pt-3 pb-4 text-center text-[12px] text-muted-foreground",children:"Nothing has ended yet."})]})})}function at({onBack:a,onClose:b}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[(0,d.jsx)("button",{type:"button",onClick:a,"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,d.jsx)(ab.ChevronLeft,{className:"size-4"})}),(0,d.jsx)(ag.Skeleton,{className:"size-5.5 shrink-0 rounded-md"}),(0,d.jsx)("span",{className:"flex min-w-0 flex-1",children:(0,d.jsx)(ag.Skeleton,{className:"h-3.5 w-2/5"})}),(0,d.jsx)(W.FoldButton,{onClick:b})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 px-4 py-4",children:[(0,d.jsx)(ag.Skeleton,{className:"h-3 w-4/5"}),(0,d.jsx)(ag.Skeleton,{className:"h-3 w-3/5"}),(0,d.jsx)(ag.Skeleton,{className:"h-3 w-2/3"})]})]})}function au(){return(0,d.jsxs)("div",{className:"flex items-center gap-2.5 px-2 py-1.5",children:[(0,d.jsx)(ag.Skeleton,{className:"size-8 shrink-0 rounded-[10px]"}),(0,d.jsxs)("span",{className:"flex h-9 min-w-0 flex-1 flex-col justify-center gap-1.5",children:[(0,d.jsx)(ag.Skeleton,{className:"h-3.5 w-2/5"}),(0,d.jsx)(ag.Skeleton,{className:"h-2.5 w-3/5"})]})]})}let av=[{id:"needsYou",label:"needs you"},{id:"working",label:"working"}];function aw({threads:a,onPick:b}){let c=new Map;for(let b of a){let a=(0,G.standOf)(b),d=c.get(a);d?d.push(b):c.set(a,[b])}return(0,d.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:av.map((a,e)=>{let f=c.get(a.id)??[];return f.length?(0,d.jsxs)(s.Fragment,{children:[(0,d.jsxs)("p",{className:(0,w.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===e?"pt-1":"pt-3"),children:[a.label," · ",f.length]}),f.map(a=>(0,d.jsx)(ax,{thread:a,onPick:()=>b(a.id)},a.id))]},a.id):null})})}function ax({thread:a,onPick:b,lines:c=1}){let e=(0,G.needsThreadReply)(a),f=a.lines.at(-1),g=(0,s.useMemo)(()=>(function(a){let b=a.room.questions[0];if(b)return{text:(0,w.plainText)(b.text),tone:"text-foreground"};if("waiting"===a.status&&a.ask)return{text:a.ask.refused?`${(0,F.refusedWords)(a.ask.refused)}.`:(0,G.isAppStop)(a.ask)?(0,w.plainText)(a.outcome??a.ask.question):a.ask.question,tone:w.WAITING_INK};let c=a.seen;if("cancelled"===a.status)return{text:"Stopped",tone:"text-muted-foreground"};if("done"===a.status)return{text:(0,w.plainText)(a.outcome??"Done"),tone:c?"text-muted-foreground":"text-foreground"};let d=(0,V.lastSaid)(a);return d?{text:"tool"===d.kind&&d.tool?d.tool.note??`${d.tool.name} \xb7 ${d.tool.input}`:d.text,tone:"text-muted-foreground"}:{text:`${a.bot.name} is taking it on…`,tone:"text-muted-foreground italic"}})(a),[a.status,a.outcome,a.seen,a.ask,a.room.questions,f?.id]),[h,i]=(0,N.useAnswerThread)(),[j,k]=(0,s.useState)(null),l=a.room.questions[0],m=l?l.options??[]:"waiting"===a.status&&(0,G.isAppStop)(a.ask)?a.ask?.options??[]:[];return(0,d.jsxs)("div",{className:"rounded-xl transition-colors hover:bg-muted/60",children:[(0,d.jsxs)("button",{type:"button",onClick:b,"data-focus-home":`thread-${a.id}`,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,d.jsx)("span",{className:"relative flex size-8 shrink-0 items-center justify-center overflow-visible",title:a.bot.name,children:(0,d.jsx)(H.BotMark,{size:32,seed:a.bot.name,color:a.bot.icon?.color,shape:a.bot.icon?.shape,outline:a.bot.icon?.outline,paint:a.bot.icon?.paint,state:"working"===a.status?"thinking":"idle",notify:e||(0,G.isUnread)(a),crossed:"cancelled"===a.status})}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[e&&!l&&(0,G.isAppStop)(a.ask)&&(0,d.jsx)("span",{className:"block font-mono text-[10px] tracking-wide text-muted-foreground",children:"Paused"}),(0,d.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:(0,w.cn)("min-w-0 truncate text-[14px] leading-5 tracking-[-0.15px]",e?"text-foreground":"text-foreground/80",(e||(0,G.isUnread)(a))&&"font-medium"),children:a.label}),a.routineId&&(0,d.jsx)("span",{title:"Started by a routine",className:"shrink-0",children:(0,d.jsx)(al.RoutineMark,{className:"size-3 text-muted-foreground/80"})}),(0,d.jsx)(ak.BotRoster,{bots:a.roster}),(0,d.jsx)("span",{className:"flex-1"}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-[11px] leading-4 text-muted-foreground tabular-nums",children:(0,S.shortAgo)(a.updatedAt)})]}),(0,d.jsxs)("span",{className:(0,w.cn)("mt-px flex items-center gap-1.5",1===c&&"h-4"),children:["working"===a.status&&(0,d.jsx)(ad.Loader2,{className:"size-3 shrink-0 animate-spin text-muted-foreground/70"}),"working"===a.status||l?(0,d.jsx)(A.ShinyText,{text:g.text,speed:l?3.4:2.2,tone:l?"reading":void 0,className:(0,w.cn)("min-w-0 flex-1 text-[12px] leading-4",1===c?"truncate":"line-clamp-2",g.tone.includes("italic")&&"italic")}):(0,d.jsx)("span",{className:(0,w.cn)("min-w-0 flex-1 text-[12px] leading-4",1===c?"truncate":"line-clamp-2",g.tone),children:g.text})]})]})]}),m.length>0&&(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-0.5 pr-2 pb-2 pl-12.5",children:[!l&&a.ask?.refused&&(0,d.jsxs)(u.Button,{size:"sm",variant:"secondary",onClick:()=>(0,am.openSettings)("keys"),className:"h-7 gap-1.5 rounded-full px-3 text-[12px]",children:[(0,d.jsx)(p.Settings2,{className:"size-3.5"}),"Open Settings"]}),m.map(b=>(0,d.jsxs)(u.Button,{size:"sm",variant:"secondary",loading:j===b,disabled:i,onClick:async()=>{k(b),await h(a,b,l?.bot,l?.id),k(null)},className:"h-7 gap-1.5 rounded-full px-3 text-[12px]",children:[b===G.THREAD_CONTINUE&&(0,d.jsx)(ac.ChevronsRight,{className:"size-3.5"}),b]},b))]})]})}let ay={name:"at-sign",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]};ay.node;let az=(0,h.default)(ay);var aA=a.i(752562);let aB={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"]};aB.node;let aC=(0,h.default)(aB);var aD=a.i(802550),aE=a.i(748819);function aF({bot:a,icon:b,line:c,children:e}){return(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsx)(C.TooltipTrigger,{render:(0,d.jsx)("span",{}),children:e}),(0,d.jsxs)(C.TooltipContent,{className:"flex items-center gap-2 py-1 pr-2.5 pl-1",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-background/15 py-0.5 pr-2 pl-1",children:[(0,d.jsx)(H.BotMark,{size:15,seed:a,color:b?.color,shape:b?.shape,outline:b?.outline,paint:b?.paint}),(0,d.jsx)("span",{className:"font-medium text-[11px]",children:a})]}),c&&(0,d.jsx)("span",{className:"text-[11.5px] opacity-80",children:c})]})]})}let aG=[[0,[21,117,208]],[.4,[90,157,222]],[.75,[179,210,239]],[1,[252,252,254]]],aH=aG[0][1],aI=[{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}],aJ=(a,b,c)=>a<b?b:a>c?c:a,aK=a=>a*a*(3-2*a),aL=(a,b,c)=>aK(aJ((c-a)/(b-a),0,1)),aM=(a,b)=>{let c=0x165667b1*a+0x27d4eb2f*b|0;return(((c=(c^c>>>13)*0x4bf19f61)^c>>>16)>>>0)/0xffffffff},aN=(a,b)=>{let c=Math.floor(a),d=Math.floor(b),e=aK(a-c),f=aK(b-d);return(aM(c,d)*(1-e)+aM(c+1,d)*e)*(1-f)+(aM(c,d+1)*(1-e)+aM(c+1,d+1)*e)*f},aO=(a,b,c)=>.74*aN(a+c,b+.7*c)+.26*aN(2.2*a+c,2.2*b+1.3*c);function aP({on:a,className:b}){let c=(0,s.useRef)(null),[e,f]=(0,s.useState)(a),[g,h]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{if(a){f(!0);let a=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(a)}h(!1);let b=setTimeout(()=>f(!1),200);return()=>clearTimeout(b)},[a]),(0,s.useEffect)(()=>{let a=c.current,b=a?.getContext("2d");if(!a||!b)return;a.width=48,a.height=48;let d=b.createImageData(48,48),e=d.data,f=[0,0,0],g=900*Math.random(),h=400*Math.random(),i=a=>{let c=a+g,i=c+1.7*Math.sin(.33*c),j=(.5+.5*Math.sin(.27*c))**2*.72+(.5+.5*Math.sin(.41*c+2.1))**3*.28,k=.1*Math.sin(.19*c),l=aI.map(a=>({seed:a.seed,shift:i*a.pace,wide:a.wide*(1-a.gustWide*j),tall:a.tall*(1+a.gustTall*j),sky:h*a.sky})),m=0;for(let a=0;a<48;a+=1){let b=(a+.5)/48*2-1;for(let a=0;a<48;a+=1,m+=4){let d=(a+.5)/48*2-1,g=aN(.55*d+.03*c,.55*b+h)-.5,i=aN(.55*d+9.1+h,.55*b-.024*c)-.5,j=d+1.15*g,n=b+ +i+k,[o,p,q,r]=l.map(a=>aO((j-a.shift)*a.wide+a.sky,n*a.tall,a.seed)),s=aJ((.52-o)/.34,0,1);s*=.7+.6*aJ((.56-p)/.4,0,1);let t=.97-.92*(s=aJ(s+(.5-q)*.42,0,1))**1.2-.1*aJ((.5-q)/.6,0,1)+(r-.5)*.38,u=Math.sqrt(d*d+b*b);!function(a,b){let c=aJ(a,0,1),d=1;for(;d<aG.length-1&&c>aG[d][0];)d+=1;let[e,f]=aG[d-1],[g,h]=aG[d],i=(c-e)/(g-e);b[0]=f[0]+(h[0]-f[0])*i,b[1]=f[1]+(h[1]-f[1])*i,b[2]=f[2]+(h[2]-f[2])*i}(t+=.16*aJ(1-Math.hypot(d+.42,b+.48)/1.5,0,1)+aL(.84,1,u)*aJ(.15+.85*(.8*b+.45*d),0,1)*.45,f);let v=aJ(u,0,1)**2.4*.26;e[m]=f[0]+(aH[0]-f[0])*v,e[m+1]=f[1]+(aH[1]-f[1])*v,e[m+2]=f[2]+(aH[2]-f[2])*v,e[m+3]=255*(1-aL(.94,1,u))}}b.putImageData(d,0,0)},j=performance.now();if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void i(6);let k=0,l=0,m=a=>{k=requestAnimationFrame(m),a-l<33||(l=a,i((a-j)/1e3))};return k=requestAnimationFrame(m),()=>cancelAnimationFrame(k)},[e]),e)?(0,d.jsx)("canvas",{ref:c,"aria-hidden":!0,className:(0,w.cn)("pointer-events-none absolute inset-0 size-full transition-opacity",g?"opacity-100":"opacity-0",b),style:{transitionDuration:"200ms"}}):null}var aQ=a.i(324835);let aR={done:aA.Check,cancelled:q.X,question:aD.CircleQuestionMark,stopped:aC,resumed:aE.RotateCw},aS={question:w.WAITING_INK,stopped:w.WAITING_INK},aT=a=>{let b=(0,w.plainText)(a).replace(/\s+/g," ").trim();return b.length>28?`${b.slice(0,27)}…`:b};function aU({crew:a,more:b,bubble:c,rows:e,count:f,busy:g,pending:h,playing:i,resting:j=!1,onPick:k,onOpen:l}){let m=(0,V.useWriteLineUp)(),n=e.length>0&&!m;return(0,d.jsxs)("div",{className:(0,w.cn)("pointer-events-auto w-fit max-w-full bg-background/78 ring-1 ring-border/50 backdrop-blur-md transition-shadow duration-300",n?"w-132 rounded-3xl shadow-lg shadow-black/8":"rounded-full shadow-sm shadow-black/3"),children:[(0,d.jsx)("div",{className:(0,w.cn)("grid overflow-hidden contain-inline-size transition-[grid-template-rows] duration-300 ease-out",n?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:(0,d.jsxs)("div",{className:"min-h-0 overflow-hidden",inert:!n,children:[(0,d.jsxs)("p",{className:"px-3 py-2 font-mono text-[10px] tracking-wide text-muted-foreground",children:[h," ",1===h?"needs":"need"," a reply"]}),(0,d.jsx)("div",{className:"max-h-[34vh] overflow-y-auto px-1.5 pb-2",children:(0,d.jsx)("div",{children:e.map((a,b)=>(0,d.jsx)("div",{style:{animationDelay:`${120+60*b}ms`},className:"animate-in duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:(0,d.jsx)(ax,{thread:a,onPick:()=>k(a.id)})},a.id))},String(n))}),(0,d.jsx)("span",{className:"block h-1.5"})]})}),(0,d.jsx)(aV,{crew:a,more:b,bubble:n?null:c,label:f?`Threads (${f})`:"Bots",onClick:l,playing:i,resting:j,side:(0,d.jsx)(aW,{busy:g,pending:h,grown:n}),onWrite:V.writeLine.choose,writing:m})]})}function aV({crew:a,more:b,bubble:c,playing:e,resting:f=!1,side:g,label:h,onClick:i,onWrite:j,writing:k}){return(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2 py-1.5 pr-3 pl-1.5",children:[(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsxs)(C.TooltipTrigger,{render:(0,d.jsx)("button",{type:"button",onClick:j,"aria-label":"Write to Thursday or a bot","data-focus-home":"write","aria-pressed":k,className:(0,w.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",k?"shadow-[0_6px_14px_-7px_color-mix(in_oklab,var(--brand)_60%,transparent)]":"bg-muted text-foreground hover:bg-accent")}),children:[(0,d.jsx)(aP,{on:!!k}),(0,d.jsx)(az,{className:(0,w.cn)("size-3.5 transition-opacity duration-200",k?"opacity-0":"opacity-100")})]}),(0,d.jsxs)(C.TooltipContent,{children:["Write to Thursday or a bot",(0,d.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:"@"})]})]}),(0,d.jsxs)("button",{type:"button",onClick:i,"aria-label":h,"data-focus-home":"room",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,d.jsx)(aY,{crew:a,more:b,bubble:c,playing:e,resting:f}),g]})]})}function aW(a){let b=function({busy:a,pending:b,grown:c}){return b>0?{text:1===b?"waiting on you":`${b} waiting on you`,shine:!0}:a>0?{text:"working",shine:!0,spin:!0}:c?null:{text:"Need a hand?",shine:!1}}(a);return b?(0,d.jsxs)("span",{className:"ml-auto flex h-7 min-w-0 shrink items-center gap-1.5",children:[b.shine?(0,d.jsx)(A.ShinyText,{text:b.text,speed:2.6,className:"block truncate text-[14px] leading-5 tracking-[-0.15px]"}):(0,d.jsx)("span",{className:"block animate-in truncate text-[14px] leading-5 tracking-[-0.15px] text-muted-foreground fade-in duration-300",children:b.text},b.text),b.spin&&(0,d.jsx)(ad.Loader2,{className:"size-4 shrink-0 animate-spin text-muted-foreground/70"})]}):null}let aX=["alto","brio","cinder","delta"].map((a,b,c)=>({name:a,icon:{color:aQ.MARK_PALETTE[Math.floor(b*aQ.MARK_PALETTE.length/c.length)],shape:aQ.MARK_SHAPES[b%aQ.MARK_SHAPES.length]},awake:!1,waiting:!1,unread:!1,word:null,standIn:!0}));function aY({crew:a,more:b,bubble:c,playing:e,resting:f}){return(0,d.jsxs)("span",{className:"flex min-w-0 shrink items-center",children:[a.map((b,g)=>{let h=b.standIn?a.every(a=>a.standIn)?"No bots yet":null:b.waiting?"Waiting on you":b.word?b.word:b.unread?"Left you a result":b.awake?"Working":"Idle",i=(0,d.jsx)("span",{className:(0,w.cn)("flex transition-transform duration-500 ease-out",b.awake&&"-translate-y-0.5 scale-110"),children:(0,d.jsx)(aZ,{face:b,motion:(0,M.motionOf)(e.get(b.name),g),asleep:f&&!b.awake&&!b.waiting&&!e.has(b.name)})});return(0,d.jsxs)(s.Fragment,{children:[(0,d.jsxs)("span",{className:(0,w.cn)("relative shrink-0 transition-[margin] duration-500 ease-out",g>0&&!a[g-1].word&&"-ml-2",b.standIn&&"opacity-35"),style:{zIndex:a.length-g},children:[null===h?(0,d.jsx)("span",{children:i}):(0,d.jsx)(aF,{bot:b.name,icon:b.icon,line:h,children:i}),c?.at===b.name&&(0,d.jsx)(a_,{handoff:c})]}),b.word&&(0,d.jsx)("span",{className:"mx-2.5 min-w-0 shrink truncate",children:(0,d.jsx)(A.ShinyText,{text:b.word,speed:2.6,className:"truncate text-[13px] leading-5 tracking-[-0.1px]"})})]},b.name)}),b>0&&(0,d.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:`${b} more`,children:"+"})]})}function aZ({face:a,motion:b,asleep:c}){let e=b.delayMs?{animationDelay:`${b.delayMs}ms`}:void 0;return(0,d.jsx)("span",{"data-crew-motion":!0,className:(0,w.cn)("flex",b.body),style:e,children:(0,d.jsx)("span",{"data-crew-motion":!0,className:(0,w.cn)("flex origin-bottom",!c&&b.shape),style:e,children:(0,d.jsx)("span",{"data-crew-motion":!0,className:(0,w.cn)("flex",b.turn),style:e,children:(0,d.jsx)(a$,{face:a,asleep:c})})})},b.key)}function a$({face:a,asleep:b}){return(0,d.jsx)(H.BotMark,{resting:b,size:28,seed:a.name,color:a.icon?.color,shape:a.icon?.shape,outline:a.icon?.outline,paint:a.icon?.paint,notify:a.waiting||a.unread})}function a_({handoff:a}){return(0,d.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,d.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,d.jsx)(a1,{handoff:a})}),(0,d.jsx)("span",{className:"-mt-px size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-border"}),(0,d.jsx)("span",{className:"-mt-[7.5px] size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-background"})]})}function a0({handoff:a}){return(0,d.jsx)("span",{className:"ml-auto flex h-7 min-w-0 shrink animate-in items-center pl-4 fade-in duration-200",children:(0,d.jsx)(a1,{handoff:a})})}function a1({handoff:a}){let b=a.sign?aR[a.sign]:null,c=a.sign?aS[a.sign]:void 0;return(0,d.jsxs)("span",{className:(0,w.cn)("flex min-w-0 items-center gap-2 text-[13px] leading-[18px] tracking-[-0.1px] whitespace-nowrap",c),children:[(0,d.jsx)(a2,{from:a.from,to:a.to}),b&&(0,d.jsx)(b,{className:(0,w.cn)("size-3.5 shrink-0",!c&&"text-muted-foreground/70")}),a.shine?(0,d.jsx)(A.ShinyText,{text:a.text,speed:2.2,className:"min-w-0 truncate"}):(0,d.jsx)("span",{className:"min-w-0 truncate",children:a.text})]})}function a2({from:a,to:b}){let c=[a,...b];return(0,d.jsx)("span",{className:"flex shrink-0 items-center",children:c.map((a,b)=>(0,d.jsx)("span",{className:(0,w.cn)("relative flex",b>0&&(c[b-1].name===W.YOU.name?"ml-1":"-ml-1.25")),style:{zIndex:c.length-b},children:(0,d.jsx)(a3,{bot:a})},a.name))})}function a3({bot:a}){return a.name===W.YOU.name?(0,d.jsx)("span",{className:"shrink-0 font-mono text-[10.5px] text-muted-foreground",children:"You"}):a.name===W.THURSDAY.name?(0,d.jsx)(O.ThursdayMark,{size:18,className:"shrink-0"}):(0,d.jsx)(H.BotMark,{size:18,seed:a.name,color:a.icon?.color,shape:a.icon?.shape,outline:a.icon?.outline,paint:a.icon?.paint,notify:!1,className:"shrink-0"})}let a4=(0,r.default)(async()=>{},{loadableGenerated:{modules:[590714]},ssr:!1}),a5=(0,s.memo)(function(){let a=(0,V.useBotThreads)(),b=ao(),{data:c}=(0,U.useServerRoute)(t.queryKey.bot),[e,f]=(0,s.useState)(!1),[g,h]=(0,s.useState)(!1),[i,j]=(0,s.useState)(null),k=e&&null!==i;(0,s.useEffect)(()=>(V.roomOpen.set(e?k?"thread":"list":null),()=>V.roomOpen.set(null)),[e,k]),P(e,"room"),P(k,i?`thread-${i}`:void 0);let[l,m]=(0,s.useState)({}),[n,o]=(0,s.useState)("now"),p=(0,s.useRef)(0),q=[...a].reverse(),r=q.filter(a=>"finished"!==(0,G.standOf)(a)),u=e&&"history"===n,v=(0,T.useServerPages)({key:(a,b)=>{if(!u)return null;if(0===a)return t.queryKey.threadHistory(null);let c=b?.at(-1);return c?t.queryKey.threadHistory((0,S.toDate)(c.updatedAt).toISOString()):null},size:D.PAGE_SIZE}),{refresh:x}=v,y=(0,s.useRef)(!1);y.current=v.items.length>0,(0,s.useEffect)(()=>{u&&y.current&&x()},[u,x]);let z=(0,s.useMemo)(()=>v.items.filter(a=>"done"===a.status||"cancelled"===a.status).map(a=>(0,V.threadFromRow)(a,c)),[v.items,c]),A=i?q.find(a=>a.id===i)??z.find(a=>a.id===i)??null:null,{data:B,isLoading:C}=(0,U.useServerRoute)(i?t.queryKey.thread(i):null),E=(0,s.useMemo)(()=>B&&B.id===i?(0,V.threadFromRow)(B,c):null,[B,i,c])??(A?.lines.length?A:null),F=null!==i&&(null!==E||C),H=R(1280),I=(0,V.useRoomReadAs)(),J=k&&H&&"office"===I&&!g&&(null!==E||C);(0,s.useEffect)(()=>V.roomOffice.set(J),[J]),(0,s.useEffect)(()=>()=>V.roomOffice.set(!1),[]);let L=function(a){let[b,c]=(0,s.useState)(a);null!==a&&a!==b&&c(a);let d=null===a,[e,f]=(0,s.useState)(d);!d&&e&&f(!1),(0,s.useEffect)(()=>{if(!d)return;let a=setTimeout(()=>f(!0),250);return()=>clearTimeout(a)},[d,250]);let g=a??b;return e||null===g?null:{value:g,leaving:d}}(J?E:null);(0,s.useEffect)(()=>V.roomThread.set(e&&!g?i:null),[e,g,i]),(0,s.useEffect)(()=>()=>V.roomThread.set(null),[]);let[O,X]=function(){let[a,b]=(0,s.useState)(null),c=(0,s.useRef)(null);return(0,s.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]),[a,(0,s.useCallback)(a=>{b(a),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,b(null)},3400)},[])]}(),Y=(0,s.useMemo)(()=>O??function(a,b){for(let c of a){if("working"!==c.status)continue;let a=c.room.deliveries.find(a=>!a.delivered&&c.room.participants.some(b=>b.bot===a.bot&&"running"===b.state));if(a)return{at:a.bot,from:b(a.bot),to:[],text:"Step-in · waits for its next step",shine:!0}}return null}(a,a=>({name:a,icon:c?.find(b=>b.name===a)?.icon??null})),[O,a,c]),{crew:Z,more:$}=(0,s.useMemo)(()=>(function(a,b){let c=new Set(b.filter(G.isUnread).map(a=>a.bot.name)),d=function(a){let b=new Map;for(let d of a){let a=new Set(d.room.questions.map(a=>a.bot));for(let e of("waiting"!==d.status||a.size||a.add(d.bot.name),d.room.participants)){var c;if(a.has(e.bot)){b.set(e.bot,{waiting:!0,word:null});continue}if(b.get(e.bot)?.waiting||"running"!==e.state&&"queued"!==e.state)continue;let f="running"===e.state?d.lines.findLast(a=>a.bot.name===e.bot&&"user"!==a.kind&&"note"!==a.kind&&"stop"!==a.kind):null;b.set(e.bot,{waiting:!1,word:(c=f??null,c?.kind==="tool"||c?.kind==="say"?aT((0,W.stepOf)(c)):null)})}}return b}(b),e=new Map;for(let b of a??[])e.set(b.name,{name:b.name,icon:b.icon,awake:d.has(b.name),waiting:d.get(b.name)?.waiting??!1,unread:c.has(b.name),word:d.get(b.name)?.word??null});for(let[a,b]of d)e.has(a)||e.set(a,{name:a,icon:null,awake:!0,waiting:b.waiting,unread:c.has(a),word:b.word});let f=[...e.values()].filter(a=>a.awake||a.waiting),g=f.length?f:[...e.values()];if(!g.length)return{crew:aX.slice(0,3),more:0};for(let a of f.length?[]:aX){if(g.length>=3)break;e.has(a.name)||g.push(a)}let h=a=>a.waiting?0:a.awake?1:a.unread?2:a.standIn?4:3,i=g.map((a,b)=>({face:a,at:b})).sort((a,b)=>h(a.face)-h(b.face)||a.at-b.at).map(a=>a.face);return{crew:i.slice(0,14),more:Math.max(0,i.length-14)}})(c,a),[c,a]),[_,aa]=(0,M.useCrewGestures)(),ab=(0,M.useCrewAwake)(),ac=(0,s.useRef)(!1);(0,s.useEffect)(()=>{!ac.current&&c?.length&&(ac.current=!0,aa(c.map(a=>({bot:a.name,gesture:"wave"}))))},[c,aa]);let ad=(0,s.useRef)(null),ae=(0,s.useRef)(new Map),af=(0,s.useRef)(new Set);(0,s.useEffect)(()=>{if(!V.botThreads.primed())return;let b=ad.current;ad.current=new Map(a.map(a=>[a.id,a.status]));let c=ae.current;ae.current=function(a){let b=new Map;for(let c of a)for(let a of c.room.participants)b.set(`${c.id}
|
|
1
|
+
module.exports=[102928,a=>{"use strict";var b=a.i(187924),c=a.i(752562),d=a.i(707963),e=a.i(141146),f=a.i(540990),g=a.i(164831);let h={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"}]]};h.node;let i=(0,g.default)(h),j={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"}]]};j.node;let k=(0,g.default)(j);var l=a.i(819721),m=a.i(50944),n=a.i(572131),o=a.i(767561),p=a.i(340695),q=a.i(280281),r=a.i(654816),s=a.i(905441),t=a.i(398026),u=a.i(913834),v=a.i(983874),w=a.i(864037),x=a.i(576271),y=a.i(759497),z=a.i(497895),A=a.i(603095),B=a.i(249049),C=a.i(483253);let D={hello:"Hi, I'm Thursday. One thing first: this is a recording. You'll hear my real voice on our first call.",key:"First, I need a voice. Sign in with ChatGPT, and I talk on the plan you already have. Or paste an OpenAI key, if you'd rather. Neither one yet? No problem, skip ahead. I'll ask again later.",awake:"There we go — I'm awake. That's all a call needs. The rest is quick: your microphone, and who does the work for you.",mic:"Now let me hear you. Your browser will ask before it turns the microphone on — just say yes. From then on, say 'hey Thursday' anytime, and I'll pick up.",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.",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 sign in, or 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."},E=Array(C.SPECTRUM_BANDS).fill(0),F="thursday.intro.muted";var G=a.i(647509),H=a.i(590513),I=a.i(663390),J=a.i(510072),K=a.i(661779),L=a.i(539341),M=a.i(730357);let N=[{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}],O=[.2,1.6,2.5,3.1,3.55],P=["/sounds/opening-rise.ogg","/sounds/opening-step-1.ogg","/sounds/opening-step-2.ogg","/sounds/opening-step-3.ogg","/sounds/opening-land.ogg"],Q=[2,3,1],R=[[],["🤍"],["🤍","☁️"],["☁️","🤍"],["☁️","🕊️"],["🕊️","☁️"],["🕊️","🦢"],["🦢","🕊️","☁️"],["🦢","🤍"],["🤍","⚪","🦢"],["🤍","⚪"],["⚪","🤍"]],S=[[],["🤍","⚪"],["🤍","⚪","🦢"],["🦢","🤍","🕊️"],["🦢","🕊️","☁️"],["🕊️","🦢","☁️"],["🕊️","☁️"],["☁️","🕊️"],["☁️","🖤"],["⚫","🖤","☁️"],["🖤","⚫"],["🖤","⚫"]],T=N[0].px;function U({anchor:a,onArrive:c,onHello:d,onDone:e}){let f=(0,n.useRef)(null),g=(0,M.useIsDark)(),h=(0,n.useRef)({dark:g,onArrive:c,onHello:d,onDone:e});return h.current={dark:g,onArrive:c,onHello:d,onDone:e},(0,n.useEffect)(()=>{let b=f.current,c=a.current,d={arrive:!1,hello:!1,done:!1},e=a=>{d[a]||(d[a]=!0,"arrive"===a?h.current.onArrive():"hello"===a?h.current.onHello():h.current.onDone())};if(!b||!c||window.matchMedia("(prefers-reduced-motion: reduce)").matches){e("arrive"),e("hello"),e("done");return}let g=b.getContext("2d");if(!g){e("arrive"),e("hello"),e("done");return}let i=O.map((a,b)=>a+(b>0?(Math.random()-.5)*.12:0)),j=!function(){try{return"1"===window.localStorage.getItem(F)}catch{return!1}}()?P.map(a=>{let b=new Audio(a);return b.preload="auto",b}):[],k=0,l=50*Math.random(),m=Math.min(2,window.devicePixelRatio||1),n="letters"===(0,I.faceGlyphs)(),o=n?null:function(a,b){let c=Math.round(T*b),d=Math.ceil(1.3*c),e=document.createElement("canvas");e.width=12*d,e.height=d*Math.ceil(a.length/12);let f=e.getContext("2d");if(!f)return null;f.textAlign="center",f.textBaseline="middle",f.font=(0,H.GLYPH_FONT)(c);let g=new Map;return a.forEach((a,b)=>{g.set(a,b),f.fillText(a,b%12*d+d/2,Math.floor(b/12)*d+d/2)}),{canvas:e,at:g,slot:d,scale:d/b/T}}([...new Set([...G.EMOJI_POOL,...R.flat(),...S.flat(),...Q.flatMap(a=>L.WASH_SETS[a-1].emoji)])],m);if(!n&&!o){e("arrive"),e("hello"),e("done");return}let p=G.LEVELS-1,q=[],r=null,s=()=>{let a=window.innerWidth,d=window.innerHeight;b.width=Math.round(a*m),b.height=Math.round(d*m),g.setTransform(m,0,0,m,0,0),g.textAlign="center",g.textBaseline="middle",r=null;let e=c.getBoundingClientRect(),f=Number.parseFloat(getComputedStyle(c).getPropertyValue("--face-bleed"))/100||0,h=e.width*(1+2*f),i=e.left+e.width/2,j=e.top+e.height/2,k=H.DESIGN/h;q=N.map((b,c)=>{let e=.95*b.px/b.density,f=1.25*b.px/b.density,g=.12*c,h=Math.cos(g),m=Math.sin(g),n=70+26*c,o=[];for(let g=0;g*f<d;g++)for(let d=0;d*e<a;d++){let a=d*e+e/2,p=g*f+f/2,q=(a-i)*k,r=(p-j)*k,s=(q*h-r*m)/H.REST_R/b.radii,t=(q*m+r*h)/H.REST_R/b.radii,u=Math.hypot(s,t);if(u>2.6)continue;let v=Math.floor((Math.atan2(t,s)+Math.PI)/(2*Math.PI)*n),w=(0,G.hash)(v+13*c,3.1+l),x=(0,G.hash)(1.3*v,11.1+l);o.push({x:a,y:p,r:u,dx:s*H.REST_R,dy:t*H.REST_R,drift:.02+.14*w*w,go:.15+.9*(0,G.hash)(v,7.7+c),carry:x<.13?Q[Math.floor(23*x)%Q.length]:0,nx:q*(8/b.px)*.05,ny:r*(8/b.px)*.05,seed:(0,G.hash)(d+101*c,g),grain:(0,G.hash)(5.7*d+19+c,2.3*g+53),gap:.05+.3*(0,G.hash)(7.3*d+11,3.1*g+5+c)})}let q=o.length;return{px:b.px,cells:o,fast:new Float32Array(q),slow:new Float32Array(q),wasLevel:new Int8Array(q).fill(-9),turn:new Int32Array(q).fill(-9),pick:new Int32Array(q),pool:new Int8Array(q),poolFor:new Float32Array(q),byLevel:Array.from({length:p+1},()=>new Int32Array(q)),inLevel:new Int32Array(p+1),glyph:Array(q),over:!1}})};s(),window.addEventListener("resize",s);let t=(0,K.createSmoke)(),u=90*Math.random(),v={dx:0,dy:0,dist:0},w=performance.now(),x=w,y=0,z=0,A=a=>{let c=(a-w)/1e3,d=Math.min(.05,Math.max(0,(a-x)/1e3));x=a,y+=d;let{dark:f}=h.current,l=f?R:S;n&&r!==f&&(r=f,g.fillStyle=getComputedStyle(b).color),(0,K.stepSmoke)(t,y,d,0,0,-1);let s=(0,J.windAt)(y,u),B=Math.exp(-d/H.TRAIL_FAST),C=Math.exp(-d/1.4);g.clearRect(0,0,b.width/m,b.height/m);let D=0;for(q.forEach((a,b)=>{let e=i[b],f=i[b+1];if(a.over||c<e)return;let h=c-f,j=h<=0?(0,G.smoothstep)(0,1,(c-e)/(0===b?1.2:.35)):1,k=h>0?(0,G.smoothstep)(0,.3,h):0,m=h>.05,q=y+31*b;a.inLevel.fill(0);let r=0,u=a.cells;for(let b=0;b<u.length;b++){let c=u[b],e=0,f=0;if(h<=0)j>0&&c.r<2.6&&(v.dx=c.dx,v.dy=c.dy,v.dist=c.r*H.REST_R,e=(0,K.restValue)(v,q,0,H.REST_R,j,t,s));else{let a=c.r-c.drift*h**.8,b=(1+(1.5*((0,G.smoothstep)(.6,.88,Math.abs(a))*(1-(0,G.smoothstep)(1.2,1.55,Math.abs(a))))-1)*k)*(1-(0,G.smoothstep)(c.go,c.go+.4,h));if(b>0){let d=c.r>0?a/c.r:0;v.dx=c.dx*d,v.dy=c.dy*d,v.dist=Math.abs(a)*H.REST_R,(e=(0,K.restValue)(v,q,0,H.REST_R,1,t,s)*b)>.04&&k>.5&&(f=c.carry)}}(e*=(.66+.72*c.grain)*(.8+.4*(0,G.hash)(Math.floor(c.nx+.5*y),Math.floor(c.ny-.3*y))))>.3&&(0,G.hash)(31.7*Math.floor(1.6*y),613*c.seed)>.992&&(e=Math.max(e,.9)),f?(a.pool[b]=f,a.poolFor[b]=.35*(.5+c.grain)):a.poolFor[b]>0?(a.poolFor[b]-=d,a.poolFor[b]<=0&&(a.pool[b]=0)):a.pool[b]=0;let g=a.fast[b]=e>a.fast[b]*B?e:a.fast[b]*B,i=a.slow[b]=e>a.slow[b]*C?e:a.slow[b]*C;if((e=g>.55*i?g:.55*i)<c.gap+.05*Math.sin(.28*y+6.283*c.seed))continue;let o=(e>1?1:e)*p|0;if(0===o)continue;r++;let w=y*(n?H.CHURN_LETTERS:H.CHURN_EMOJI)+7*c.seed|0;(w!==a.turn[b]||o-a.wasLevel[b]>=2||a.wasLevel[b]-o>=2)&&(a.turn[b]=w,a.wasLevel[b]=o,a.pick[b]=(997*c.seed|0)+w+o);let x=a.pick[b],z=a.pool[b]?L.WASH_SETS[a.pool[b]-1]:null,A=n?z?.letters??G.RAMP[o]:z?.emoji??(m?l[o]:G.EMOJI_POOL);a.glyph[b]=A[x%A.length],a.byLevel[o][a.inLevel[o]++]=b}D+=r,h>1.45&&0===r&&(a.over=!0),o||(g.font=(0,H.GLYPH_FONT)(a.px));for(let b=1;b<=p;b++){let c=a.inLevel[b];if(0===c)continue;let d=a.byLevel[b];if(!o){g.globalAlpha=G.ALPHA_TOP*(b/p);for(let b=0;b<c;b++){let c=u[d[b]];g.fillText(a.glyph[d[b]],c.x,c.y)}continue}g.globalAlpha=(0,G.emojiAlpha)(b,p);let e=a.px*o.scale*(.5+.5*(0,G.emojiWeight)(b,p));for(let b=0;b<c;b++){let c=u[d[b]],f=o.at.get(a.glyph[d[b]])??0;g.drawImage(o.canvas,f%12*o.slot,Math.floor(f/12)*o.slot,o.slot,o.slot,c.x-e/2,c.y-e/2,e,e)}}}),g.globalAlpha=1;k<j.length&&c>=i[k];k++)j[k].play().catch(()=>{});if(c>=i[4]&&e("arrive"),c>=4.7&&e("hello"),c>i[4]+1.6&&0===D){g.clearRect(0,0,b.width/m,b.height/m),e("done");return}z=requestAnimationFrame(A)};return z=requestAnimationFrame(A),()=>{if(cancelAnimationFrame(z),window.removeEventListener("resize",s),!d.done)for(let a of j)!function(a,b=.4){if(a.paused)return;let c=a.volume,d=performance.now(),e=f=>{let g=Math.max(0,Math.min(1,(f-d)/1e3/b));a.volume=c*(1-g),g<1?requestAnimationFrame(e):a.pause()};requestAnimationFrame(e)}(a)}},[a]),(0,b.jsx)("canvas",{ref:f,"aria-hidden":!0,className:"pointer-events-none absolute inset-0 size-full text-foreground"})}var V=a.i(405050);let W=(0,V.createServerReference)("7f517a35f65cf8f644a4c74cb8b50463dc99b08e3c",V.callServer,void 0,V.findSourceMapURL,"passIntroAction");var X=a.i(444324),Y=a.i(445432),Z=a.i(587479),$=a.i(152659),_=a.i(158697),aa=a.i(650485),ab=a.i(359006),ac=a.i(926919),ad=a.i(645323),ae=a.i(77453),af=a.i(199169);let ag=["key","mic","bots","style","call"],ah=(0,l.default)(async()=>{},{loadableGenerated:{modules:[590714]},ssr:!1}),ai="Everyone did their part. The team is ready for you.";function aj({children:a}){return(0,b.jsxs)("p",{className:"text-[17px] leading-[1.675] tracking-[0.3px]",children:[(0,b.jsx)("span",{className:"mr-4 inline-block size-2.5 rounded-full bg-foreground align-middle opacity-55"}),a]})}let ak=({children:a})=>(0,b.jsx)("p",{className:"font-mono text-[11px] leading-relaxed text-pretty text-muted-foreground",children:a});function al({children:a,tail:d}){return(0,b.jsxs)("p",{className:"flex items-center gap-2.5 text-sm",children:[(0,b.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,b.jsx)(c.Check,{className:"size-3"})}),(0,b.jsx)("span",{className:"animate-in delay-150 duration-300 fill-mode-backwards fade-in slide-in-from-left-1",children:a}),d&&(0,b.jsx)("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:d})]})}function am({onSaved:a}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Give her a voice"}),(0,b.jsx)(B.CallLines,{onSaved:a})]})}function an({mic:a}){let c=(0,ab.useThursdayStore)(a=>a.wake);return a.allowed?(0,b.jsx)(al,{children:`Microphone on, and "${c.phrase}" calls her`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Turn on the microphone"}),a.failed?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:(0,z.cn)("text-[13px] leading-normal",z.WAITING_INK),children:a.failed.what}),(0,b.jsx)(ak,{children:a.failed.next})]}):(0,b.jsxs)(ak,{children:['On a call, and to hear "',c.phrase,'" while this tab is open. Chrome does that listening and sends what it hears to Google; Settings › Thursday switches it off.']})]})}function ao({picked:a,onToggle:c}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Pick who comes along"}),(0,b.jsx)("div",{className:"flex flex-col",children:t.BOT_SEEDS.map(d=>{let e=!!a[d.name];return(0,b.jsxs)("label",{className:"flex min-h-9.5 cursor-pointer items-center gap-2.75 py-1",children:[(0,b.jsx)(u.BotMark,{size:24,seed:d.name,...d.icon,notify:!1,className:(0,z.cn)("shrink-0 transition-opacity",!e&&"opacity-40")}),(0,b.jsx)("span",{className:(0,z.cn)("w-17.5 shrink-0 text-[13.5px] font-medium",!e&&"text-muted-foreground"),children:d.name}),(0,b.jsx)("span",{className:"min-w-0 flex-1 text-xs leading-snug text-pretty text-muted-foreground",children:d.hint}),(0,b.jsx)(q.Switch,{checked:e,onCheckedChange:()=>c(d.name)})]},d.name)})}),(0,b.jsx)(ak,{children:"Every one comes along. Switch off any you will not use: Settings › Bots has them all, and you can make your own."})]})}function ap(){let{settings:a,patch:c}=(0,ac.useLiveSettings)(),f=Math.max(0,s.PERSONAS.findIndex(b=>b.id===a?.persona)),g=s.PERSONAS[f],h=a=>c({persona:s.PERSONAS[(f+a+s.PERSONAS.length)%s.PERSONAS.length].id});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aj,{children:"Pick how she talks"}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("div",{className:"text-2xl font-semibold",children:g.label}),(0,b.jsx)("p",{className:"min-h-10 text-sm text-muted-foreground",children:g.about})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>h(-1),children:[(0,b.jsx)(d.ChevronLeft,{}),"Previous"]}),(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>h(1),children:["Next",(0,b.jsx)(e.ChevronRight,{})]})]}),(0,b.jsx)("div",{className:"flex gap-1.5",children:s.PERSONAS.map((a,c)=>(0,b.jsx)("span",{className:(0,z.cn)("h-0.5 w-5 rounded-full",c===f?"bg-foreground":"bg-border")},a.id))})]})}function aq({mic:a,bots:d}){let e=["voice",a?"microphone":null,d>0?`${d} ${1===d?"bot":"bots"}`:null].filter(a=>null!==a);return(0,b.jsx)("span",{className:"flex items-center gap-2 text-xs",children:e.map((a,d)=>(0,b.jsxs)("span",{style:{animationDelay:`${300+260*d}ms`},className:"flex animate-in items-center gap-2 duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:[d>0&&(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(c.Check,{className:"size-3.25"}),a]})]},a))})}let ar={ask:"Find me flights to Osaka in October.",onIt:`On it. ${t.ERRANDS_BOT} is looking. Keep talking, I will say when it is back.`,back:`${t.ERRANDS_BOT} is back. The Tuesday morning flight is the pick. The page is on your screen.`},as={threadId:"demo",label:"Osaka flights, October",bot:t.ERRANDS_BOT,words:"Three fares compared. The Tuesday morning one is the pick: direct, and the cheapest by a little.",paths:[]};function at({stage:a}){return(0,b.jsxs)(b.Fragment,{children:["landed"===a&&(0,b.jsx)("div",{className:"pointer-events-none absolute bottom-5 left-5 w-90 text-left",children:(0,b.jsx)(ad.FinishedCard,{row:as,bot:{icon:(0,t.findBotSeed)(as.bot)?.icon??null},onOpen:()=>{},onClose:()=>{}})}),(0,b.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,b.jsx)("span",{className:"flex",children:t.BOT_SEEDS.map((c,d)=>(0,b.jsx)(u.BotMark,{size:22,seed:c.name,...c.icon,state:"working"===a&&c.name===t.ERRANDS_BOT?"thinking":"idle",notify:!1,className:(0,z.cn)("shrink-0",d>0&&"-ml-1.5")},c.name))}),(0,b.jsx)("span",{className:"w-40 truncate text-left text-[13px] text-muted-foreground",children:"working"===a?`${t.ERRANDS_BOT} \xb7 reading fares`:"landed"===a?`${t.ERRANDS_BOT} finished`:"Need a hand?"})]})]})}a.s(["Intro",0,function({ready:a,firstRun:c,forced:g}){let h=c||g,j=(0,m.useRouter)(),[l,q]=(0,n.useState)("hello"),[s,u]=(0,n.useState)(!1),[G,H]=(0,n.useState)(!1),[I,J]=(0,n.useState)(a),K=(0,B.useVoiceLine)(),L=I||null!==K.line,M=(0,n.useRef)(L);(0,n.useEffect)(()=>{L&&!M.current&&O((0,$.awake)()),M.current=L},[L]);let[N,O]=(0,n.useState)(null),[P,Q]=(0,n.useState)(()=>Object.fromEntries(t.BOT_SEEDS.map(a=>[a.name,!0]))),[R,S]=(0,n.useState)("echoes"),T=(0,ab.useThursdayStore)(a=>a.wake),V=(0,ab.useThursdayStore)(a=>a.patch),ac="bots"===l,ad=(0,ae.useAwayAfter)(ac,700),[aj,ak]=(0,n.useState)(!1),[al,as]=(0,n.useState)(null),[au,av]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(ac){as(new Date),av(!1),ak(!0);let a=setTimeout(()=>av(!0),5e3);return()=>clearTimeout(a)}let a=setTimeout(()=>ak(!1),250);return()=>clearTimeout(a)},[ac]);let aw=(0,n.useMemo)(()=>al&&function(a,b,c){let[d,...e]=a;if(!d)return null;let f=a=>({name:a,icon:(0,t.findBotSeed)(a)?.icon??null}),g=new Date(b.getTime()-95e3),h=a=>new Date(g.getTime()+1e3*a),i=e.flatMap((a,b)=>{let e=(0,t.findBotSeed)(a)?.hint??a,g=2+2.5*b;return[{id:`intro-ask-${a}-0`,bot:f(d),to:f(a),text:e,kind:"ask",exchange:`intro-${a}`,parent:"intro-lead",at:h(g)},{id:`intro-step-${a}-0`,bot:f(a),to:null,text:e,kind:"say",parent:`intro-${a}`,at:h(g+1.2)},...c?[{id:`intro-back-${a}-0`,bot:f(a),to:null,text:"Done.",kind:"say",parent:`intro-${a}`,at:h(100)}]:[]]});return c&&i.push({id:"intro-report-0",bot:f(d),to:null,text:ai,kind:"result",parent:"intro-lead",at:h(100)}),{id:`intro-team-${b.getTime()}`,request:"Who works for you",label:"Who works for you",bot:f(d),roster:a.map(f),lines:i.sort((a,b)=>(0,af.toDate)(a.at??g).getTime()-(0,af.toDate)(b.at??g).getTime()),room:{participants:a.map(a=>({bot:a,state:c?"done":a===d?"waiting":"running"})),questions:[],deliveries:[],relays:[],exchanges:[{id:"intro-lead",bot:d,caller:v.ROOM_THURSDAY,state:c?"done":"waiting",waitsFor:[]},...e.map(a=>({id:`intro-${a}`,bot:a,caller:d,state:c?"done":"running",waitsFor:[]}))]},status:c?"done":"working",outcome:c?ai:null,ask:null,seen:!0,routineId:null,tokens:{input:0,output:0},contextTokens:0,contextBudget:0,createdAt:g,updatedAt:c?h(100):b}}(t.BOT_SEEDS.filter(a=>P[a.name]).map(a=>a.name),al,au),[P,al,au]),ax="hello"===R||"over"===R,ay=(0,n.useRef)(null),az=function(){let[a,b]=(0,n.useState)("off"),[c,d]=(0,n.useState)(!1);return{asking:"asking"===a,failed:"object"==typeof a?a:null,allowed:c,turnOn:(0,n.useCallback)(async()=>{b("asking");try{for(let a of(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks())a.stop();return b("off"),d(!0),!0}catch(a){return b(function(a){let b=a instanceof DOMException?a.name:"",c=(0,_.micProblem)(a);if("refused"===c)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("missing"===c)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("busy"===c)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 d=a instanceof Error&&a.message||b||String(a);return{what:"The microphone did not open.",next:`The browser said "${d}". Or just go on.`}}(a)),!1}},[])}}(),aA=function(a){let[b,c]=(0,n.useState)(0);(0,n.useEffect)(()=>{if(!a)return;let b=performance.now(),d=setInterval(()=>c((performance.now()-b)%16e3),120);return()=>clearInterval(d)},[a]);let d=(a,b,c)=>({id:a,role:b,text:c}),e=[];b>900&&e.push(d("ask","user",ar.ask)),b>4700&&e.push(d("onIt","assistant",ar.onIt)),b>11500&&e.push(d("back","assistant",ar.back));let f=b>4700&&b<8300||b>11500&&b<14500;return{turns:e,status:f?"speaking":b>900&&b<4700?"listening":"idle",stage:b>9600?"landed":b>5400?"working":b>900?"asked":"rest",saying:f,voice:aa.silentVoice}}("hello"===l&&h&&!s&&ax),aB=h&&!s;(0,n.useEffect)(()=>(X.callSignal.hold(aB),()=>X.callSignal.hold(!1)),[aB]),(0,n.useEffect)(()=>{if(!s)return;let a=setTimeout(()=>H(!0),700);return()=>clearTimeout(a)},[s]);let aC=ag.indexOf(l),{data:aD}=(0,y.useServerRoute)(o.queryKey.automaticModel),aE=!!aD?.ref,aF=(0,n.useMemo)(()=>{var a,b,c;let d,e;return a=l,b=L,c=aE,d=(a,b)=>({id:a,role:"assistant",text:b}),e=[],"hello"===a||(e.push(d("key","I am Thursday, and the first thing I need is a voice. Sign in with ChatGPT and I talk on your plan, or paste an OpenAI key. Neither yet? Go on without it, and I will ask again when you call.")),b&&e.push(d("awake","There, I am awake, and that is everything a call needs. From here on it is quick: your microphone, and who works for you.")),"key"===a||(e.push(d("mic","Now let me hear you. Your browser asks before it opens the microphone: say yes. From then on, saying hey Thursday calls me.")),"mic"===a||(e.push(d("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"===a||(e.push(d("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"===a||e.push(b?d("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."):c?d("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 sign in or have a key, and I will take it from there."):d("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.")))))),e},[l,L,aE]),aG="hello"===l?aA.turns:aF,aH=(0,Z.useTurnFocus)(aG,aB),aI=function(a){let b=(0,n.useRef)(null),c=(0,n.useRef)(new Set),d=(0,n.useRef)([]),e=(0,n.useRef)(!1),[f,g]=(0,n.useState)(!1),[h,i]=(0,n.useState)(!1),j=(0,n.useRef)(!1);(0,n.useEffect)(()=>{try{let a="1"===window.localStorage.getItem(F);j.current=a,i(a)}catch{}},[]);let k=(0,n.useCallback)(()=>{d.current=[],b.current?.audio.pause()},[]),l=(0,n.useCallback)(()=>{let a=d.current.shift();if(!a||!b.current)return;let{audio:c,clip:e}=b.current;e.resume(),c.src=`/voices/intro/${a}-${function(a){let b=0x811c9dc5;for(let c of`marin|${a}`)b^=c.codePointAt(0)??0,b=Math.imul(b,0x1000193);return(b>>>0).toString(16).padStart(8,"0")}(D[a])}.ogg`,c.play().catch(()=>{})},[]),m=(0,n.useCallback)((...a)=>{let f=a.filter(a=>!c.current.has(a));if(!j.current&&f.length){if(!b.current){let a=new Audio,c=a=>()=>{e.current=a,g(a)};for(let b of(a.addEventListener("playing",c(!0)),["pause","ended","error"]))a.addEventListener(b,c(!1));a.addEventListener("ended",l),a.addEventListener("error",l),b.current={audio:a,clip:(0,C.createClipTap)(a)}}for(let a of f)c.current.add(a);d.current=f,l()}},[l]);(0,n.useEffect)(()=>{a&&b.current&&m(a)},[a,m]),(0,n.useEffect)(()=>()=>{b.current?.audio.pause(),b.current?.clip.close(),b.current=null},[]);let o=(0,n.useCallback)(()=>{let b=!j.current;j.current=b,i(b);try{window.localStorage.setItem(F,b?"1":"0")}catch{}if(b)return k();a&&(c.current.delete(a),m(a))},[k,a,m]);return{say:m,hush:k,speaking:f,muted:h,toggle:o,spectrum:(0,n.useCallback)(()=>b.current&&e.current?b.current.clip.read():E,[])}}(s?null:aF.at(-1)?.id??null);if(G||!h)return null;let aJ=a=>{if(aI.hush(),u(!0),c){let a;(a=t.BOT_SEEDS.filter(a=>P[a.name]).map(a=>({name:a.name}))??t.BOT_SEEDS.map(a=>({name:a.name}))).length&&(0,A.createSeedBotsAction)(a).then(x.unwrapResult).then(()=>(0,y.revalidate)(o.queryKey.bot)).catch(a=>w.toast.add({type:"warning",title:"Could not set up the bots",description:(0,z.errorToString)(a)})),W()}a&&X.callSignal.place(),j.replace("/"),j.refresh()},aK="hello"===l?aA.status:aI.speaking?"speaking":"idle",aL="call"===l,aM="hello"!==l;return(0,b.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Getting started",className:(0,z.cn)("fixed inset-0 z-40 bg-background transition-opacity duration-700 [--face-w:min(20rem,52vw,37.5vh)]",s&&"pointer-events-none opacity-0"),children:[aj&&aw&&(0,b.jsx)(ah,{thread:aw,leaving:!ac,className:"absolute inset-y-0 left-0 right-[calc(50%-var(--face-w)*0.695)] mask-[linear-gradient(to_right,black_80%,transparent)]"}),"over"!==R&&(0,b.jsx)(U,{anchor:ay,onArrive:()=>S("her"),onHello:()=>S("hello"),onDone:()=>S("over")}),ax&&(0,b.jsx)(r.TooltipProvider,{children:(0,b.jsxs)(r.Tooltip,{children:[(0,b.jsx)(r.TooltipTrigger,{render:(0,b.jsx)(p.Button,{size:"icon",variant:"ghost",onClick:aI.toggle,"aria-label":aI.muted?"Let her speak":"Mute her","aria-pressed":aI.muted,className:"absolute top-5 right-5 z-10 text-muted-foreground hover:text-foreground"}),children:aI.muted?(0,b.jsx)(k,{}):(0,b.jsx)(i,{})}),(0,b.jsx)(r.TooltipContent,{side:"bottom",children:aI.muted?"Let her speak":"Mute her voice"})]})}),(0,b.jsxs)("div",{className:(0,z.cn)("relative flex h-full flex-col items-center justify-center gap-5 pt-[7vh]",ac&&"pointer-events-none",aM&&"max-[900px]:pointer-events-auto max-[900px]:justify-start max-[900px]:overflow-y-auto max-[900px]:pb-20"),children:[(0,b.jsxs)("div",{ref:ay,className:(0,z.cn)("relative w-(--face-w) [--face-bleed:19.5%]",aM&&"max-[900px]:flex max-[900px]:w-full max-[900px]:flex-col max-[900px]:items-center max-[900px]:gap-7"),children:[(0,b.jsx)("button",{type:"button",disabled:!aL||!L,onClick:()=>aJ(!0),"aria-label":aL&&L?"Call Thursday":void 0,className:(0,z.cn)("block w-full rounded-full outline-none transition-all duration-700 ease-out focus-visible:ring-3 focus-visible:ring-ring/50","hello"!==l&&!L&&"opacity-35",ac&&"pointer-events-none opacity-0",aM&&"max-[900px]:mt-6 max-[900px]:w-[min(8rem,20vh)]"),children:"echoes"!==R?(0,b.jsx)(Y.Face,{status:aK,failed:!1,word:N,getSpectrum:"hello"===l?aA.voice:aI.spectrum,waking:!0,covered:ad,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"}):(0,b.jsx)("div",{className:"aspect-square w-full"})}),(0,b.jsx)("div",{className:(0,z.cn)(aM&&"max-[900px]:hidden",ac&&"hidden"),children:(0,b.jsx)(Z.SideCaptions,{turns:aG,pinned:aH.pinned,live:"hello"===l?aA.saying:aI.speaking,onPick:aH.pick})}),aM&&(0,b.jsx)("p",{className:"hidden w-[min(22rem,calc(100vw-2rem))] text-left text-[15px] leading-[1.6] text-foreground max-[900px]:block",children:aF.at(-1)?.text}),"hello"!==l&&(0,b.jsxs)("div",{className:"pointer-events-auto 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 max-[900px]:static max-[900px]:ml-0 max-[900px]:w-[min(22rem,calc(100vw-2rem))] max-[900px]:translate-y-0",children:["key"===l&&(0,b.jsx)(am,{onSaved:()=>J(!0)}),"mic"===l&&(0,b.jsx)(an,{mic:az}),"bots"===l&&(0,b.jsx)("p",{className:"text-[15px] leading-[1.6] text-foreground max-[900px]:hidden",children:aF.at(-1)?.text}),"bots"===l&&(0,b.jsx)(ao,{picked:P,onToggle:a=>Q(b=>({...b,[a]:!b[a]}))}),"style"===l&&(0,b.jsx)(ap,{})]},l)]}),(0,b.jsxs)("div",{className:(0,z.cn)("relative flex w-full max-w-3xl flex-col items-center gap-4 px-6 text-center transition-transform duration-700 ease-out","hello"===l&&"translate-y-[calc(var(--face-w)*0.195)]"),children:[(0,b.jsx)("div",{className:"flex h-14 items-center gap-2 text-[13px] text-muted-foreground",children:"hello"===l?ax&&(0,b.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."}):ac?null:L?aL?(0,b.jsx)(aq,{mic:az.allowed,bots:t.BOT_SEEDS.filter(a=>P[a.name]).length}):null:"Asleep"}),"hello"!==l||ax?(0,b.jsxs)(p.Button,{variant:"key"!==l||L?"brand":"default",loading:"mic"===l&&az.asking,onClick:()=>{"hello"===l?(aI.say("hello",L?"awake":"key"),q("key")):"mic"!==l||az.allowed?aL?aJ(L):q(ag[aC+1]):az.turnOn().then(a=>{a&&(V({wake:{...T,enabled:!0}}),q(a=>"mic"===a?"bots":a))})},className:(0,z.cn)("pointer-events-auto h-12 rounded-full px-7 pl-8 text-[15px]","mic"===l&&!az.allowed&&"pl-6","hello"===l&&"animate-in delay-300 duration-700 fill-mode-backwards fade-in slide-in-from-bottom-2"),children:["mic"===l&&!az.allowed&&!az.asking&&(0,b.jsx)(f.Mic,{}),"hello"===l?"Start":"mic"!==l||az.allowed?aL?L?"Call her":"Look around":"Continue":"Turn on the microphone",(0,b.jsx)(e.ChevronRight,{})]}):(0,b.jsx)("div",{className:"h-12"}),(0,b.jsx)("p",{className:"h-4 font-mono text-[11px] text-muted-foreground",children:"hello"===l?ax&&(0,b.jsx)("span",{className:"block animate-in delay-500 duration-700 fill-mode-backwards fade-in",children:"two minutes · every step can wait"}):"key"!==l||L?"mic"===l&&az.asking?"your browser is asking — allow it at the top of the window":"mic"!==l||az.allowed?aL&&L?"or tap her":"":(0,b.jsx)("button",{type:"button",onClick:()=>q(ag[aC+1]),className:"rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"not now — allow it when the first call asks"}):"neither is fine — both can wait for the call screen"})]})]}),"hello"===l?ax&&(0,b.jsx)(at,{stage:aA.stage}):(0,b.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 [@media(max-height:720px)]:bottom-3",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>q(aC>0?ag[aC-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,b.jsx)(d.ChevronLeft,{className:"size-3"}),"Back"]}),(0,b.jsxs)("span",{className:"flex items-center gap-4.5",children:[(0,b.jsx)("span",{className:"flex items-center gap-1.75",children:ag.map((a,c)=>(0,b.jsx)("span",{className:(0,z.cn)("h-1.75 rounded-full transition-all duration-300",c===aC?"w-5.5 bg-foreground":"w-1.75",c<aC&&"bg-foreground/40",c>aC&&"bg-border")},a))}),(0,b.jsxs)("span",{children:[aC+1," of ",ag.length]})]}),aL&&!L?(0,b.jsx)("span",{}):(0,b.jsx)("button",{type:"button",onClick:()=>aJ(!1),className:(0,z.cn)("justify-self-start rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",aL&&"text-muted-foreground"),children:aL?"Look around first":"Skip all"})]})]})}],102928)},484267,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(986368),e=a.i(767561),f=a.i(446181),g=a.i(864037),h=a.i(576271),i=a.i(759497),j=a.i(497895),k=a.i(405050);let l=(0,k.createServerReference)("7fc605e92ae460fa516b2abc9f4d386bab170e2a4b",k.callServer,void 0,k.findSourceMapURL,"allowReachAction"),m=(0,k.createServerReference)("7fa3c1db87b15cc867a1d55213f1b2cdfcf8fe18bf",k.callServer,void 0,k.findSourceMapURL,"declineReachAction");var n=a.i(907602);a.s(["ReachAsk",0,function(){let{data:a}=(0,i.useServerRoute)(e.queryKey.reach);(0,d.useAppEvent)({reach:()=>void(0,i.revalidate)(e.queryKey.reach)});let k=(0,c.useRef)(null),o=a?.channels.find(a=>a.asking)??null,p=o?.asking??null,q=o?.name??null,r=p&&q?`${q}:${p.chat}:${p.code}`:null;return(0,c.useEffect)(()=>{if(k.current?.key===r||(k.current?.close.abort(),k.current=null,!r||!p||!q))return;let a=new AbortController;k.current={key:r,close:a};let c={chat:p.chat,code:p.code};f.notify.confirm({title:`Let ${p.name} reach Thursday from a phone?`,description:(0,b.jsxs)("span",{className:"line-clamp-2",children:[[n.REACH_LABEL[q],p.name,p.handle].filter(Boolean).join(" · "),p.said&&` wrote “${p.said}”`]}),body:(0,b.jsxs)("div",{className:"grid gap-4",children:[(0,b.jsxs)("div",{className:"grid place-items-center gap-1.5 rounded-lg bg-muted p-4",children:[(0,b.jsx)("span",{className:"pl-[0.32em] font-mono text-3xl font-medium tracking-[0.32em]",children:p.code}),(0,b.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:"the code their phone was sent"})]}),(0,b.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:a.signal}).then(b=>{if(!a.signal.aborted)return(b?l(q,c):m(q,c)).then(h.unwrapResult).catch(a=>g.toast.add({type:"error",title:b?`Could not let ${p.name} in`:`Could not turn ${p.name} away`,description:(0,j.errorToString)(a)}))})},[r,p,q]),null}],484267)},72962,a=>{"use strict";var b=a.i(187924),c=a.i(572131);a.s(["Boot",0,function(){let[a,d]=(0,c.useState)(!1);return((0,c.useEffect)(()=>d(!0),[]),a)?null:(0,b.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."})}])},137079,a=>{"use strict";var b,c,d=a.i(187924),e=a.i(830988),f=a.i(589027),g=a.i(113608),h=a.i(164831);let i={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"}]]};i.node;let j=(0,h.default)(i);var k=a.i(540990);let l={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"}]]};l.node;let m=(0,h.default)(l),n={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"}]]};n.node;let o=(0,h.default)(n);var p=a.i(639466),q=a.i(474215),r=a.i(819721),s=a.i(572131),t=a.i(767561),u=a.i(340695),v=a.i(400187),w=a.i(497895);let x=(0,v.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 y({className:a,orientation:b="horizontal",...c}){return(0,d.jsx)("div",{"data-slot":"button-group","data-orientation":b,role:"group",className:(0,w.cn)(x({orientation:b}),a),...c})}var z=a.i(511576),A=a.i(545097),B=a.i(446334),C=a.i(654816),D=a.i(287702),E=a.i(96340),F=a.i(61876),G=a.i(411509),H=a.i(913834);let I={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};I.node;let J=(0,h.default)(I);var K=a.i(986368),L=a.i(777794),M=a.i(36304),N=a.i(988422),O=a.i(346075);function P(a,b){let c=(0,s.useRef)(b);c.current=b,(0,s.useEffect)(()=>{if(!a)return;let b=document.activeElement,d=b instanceof HTMLElement&&b!==document.body?b:null,e=c.current;return()=>{let a=0,b=()=>{let c=document.activeElement;if(!c||c===document.body){let a=d?.isConnected?d:e?document.querySelector(`[data-focus-home="${CSS.escape(e)}"]`):null;if(a)return void a.focus({preventScroll:!0})}++a<30&&requestAnimationFrame(b)};requestAnimationFrame(b)}},[a])}var Q=a.i(332033);function R(a){return(0,s.useSyncExternalStore)(b=>{let c=window.matchMedia(`(min-width: ${a}px)`);return c.addEventListener("change",b),()=>c.removeEventListener("change",b)},()=>window.matchMedia(`(min-width: ${a}px)`).matches,()=>!0)}var S=a.i(199169),T=a.i(862966),U=a.i(759497),V=a.i(135432),W=a.i(181809),X=a.i(256711),Y=a.i(42724),Z=a.i(934754),$=a.i(57270),_=a.i(912402),aa=a.i(11065),ab=a.i(707963),ac=a.i(231500),ad=a.i(875160),ae=a.i(19895),af=a.i(446181),ag=a.i(950463),ah=a.i(621958),ai=a.i(405050);let aj=(0,ai.createServerReference)("7f36088897110388fe4cd7f8bf70cd99d0b7d24cf2",ai.callServer,void 0,ai.findSourceMapURL,"cancelRunningThreadsAction");var ak=a.i(42380),al=a.i(156819),am=a.i(28996),an=a.i(313237);function ao(){let a=(0,V.useBotThreads)(),b=(0,V.useRingingThreads)();return(0,s.useMemo)(()=>[...a].reverse().filter(a=>!b.includes(a.id)&&(0,G.needsThreadReply)(a)),[a,b])}function ap({tab:a,current:b,working:c,onTab:e,onClose:f}){let[g,h]=(0,an.useServerAction)(aj,{onOk:({stopped:a})=>{for(let b of((0,U.revalidate)(t.queryKey.threads),a))V.screenActs.announce({kind:"stopped",id:b.id,label:b.label})}}),i=async()=>{await af.notify.confirm({title:1===c?"Stop the thread at work?":`Stop the ${c} threads at work?`,description:"Each bot stops where it is. The threads are kept, and saying more to one carries it on. A thread waiting on your answer is left as it is.",okText:"Stop all",destructive:!0})&&g()};return(0,d.jsxs)("div",{className:"flex items-center gap-2 pt-3 pr-3.5 pb-1.5 pl-2.5",children:[(0,d.jsx)(ah.Tabs,{value:a,onValueChange:a=>e(a),className:"gap-0",children:(0,d.jsxs)(ah.TabsList,{className:"gap-1 rounded-none bg-transparent p-0 group-data-horizontal/tabs:h-auto",children:[(0,d.jsxs)(ah.TabsTrigger,{value:"now",className:W.TAB,children:["Now",b>0&&(0,d.jsx)("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:b})]}),(0,d.jsx)(ah.TabsTrigger,{value:"history",className:W.TAB,children:"History"})]})}),(0,d.jsx)("span",{className:"flex-1"}),"now"===a&&c>0&&(0,d.jsxs)(u.Button,{type:"button",size:"sm",variant:"ghost",loading:h,onClick:i,className:"h-7 shrink-0 gap-1.5 rounded-full px-2.5 text-[12px]",children:[!h&&(0,d.jsx)(ae.Square,{className:"size-2.5 fill-current"}),"Stop all"]}),(0,d.jsx)(W.FoldButton,{onClick:f})]})}function aq({bots:a}){return(0,d.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:a?.length?"Nothing handed over yet — ask for something that takes a while.":`Thursday hands work to ${G.DEFAULT_BOT.name} until you make bots of your own in Settings › Bots.`})}function ar(){return(0,d.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:"Nothing running or waiting."})}function as({pages:a,threads:b,scroll:c,onPick:e}){let f=(0,s.useCallback)(a=>{a&&(a.scrollTop=c.current)},[c]),g=[];for(let a of b){let b=function(a){let b=(0,S.toDate)(a);return(0,_.isToday)(b)?"today":(0,aa.isYesterday)(b)?"yesterday":(0,X.format)(b,function(a,b){let[c,d]=(0,$.normalizeDates)(void 0,a,b);return c.getFullYear()===d.getFullYear()}((0,Y.constructFrom)(b,b),(0,Z.constructNow)(b))?"MMM d":"MMM d, yyyy").toLowerCase()}(a.updatedAt),c=g.at(-1);c?.day===b?c.rows.push(a):g.push({day:b,rows:[a]})}return(0,d.jsx)("div",{ref:f,onScroll:a=>{c.current=a.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:a.error?(0,d.jsx)("p",{className:"px-2.5 py-3 text-[12px] text-destructive",children:a.error.message}):a.isLoading?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"flex h-6 items-center px-2.5 pt-1",children:(0,d.jsx)(ag.Skeleton,{className:"h-2.5 w-16"})}),(0,d.jsx)(au,{})]}):(0,d.jsxs)(d.Fragment,{children:[g.map((a,b)=>(0,d.jsxs)(s.Fragment,{children:[(0,d.jsxs)("p",{className:(0,w.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===b?"pt-1":"pt-3"),children:[a.day," · ",a.rows.length]}),a.rows.map(a=>(0,d.jsx)(ax,{thread:a,onPick:()=>e(a.id)},a.id))]},a.day)),a.hasMore?(0,d.jsx)("div",{ref:a.sentinelRef,children:(0,d.jsx)(au,{})}):0===g.length&&(0,d.jsx)("p",{className:"px-6 pt-3 pb-4 text-center text-[12px] text-muted-foreground",children:"Nothing has ended yet."})]})})}function at({onBack:a,onClose:b}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[(0,d.jsx)("button",{type:"button",onClick:a,"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,d.jsx)(ab.ChevronLeft,{className:"size-4"})}),(0,d.jsx)(ag.Skeleton,{className:"size-5.5 shrink-0 rounded-md"}),(0,d.jsx)("span",{className:"flex min-w-0 flex-1",children:(0,d.jsx)(ag.Skeleton,{className:"h-3.5 w-2/5"})}),(0,d.jsx)(W.FoldButton,{onClick:b})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 px-4 py-4",children:[(0,d.jsx)(ag.Skeleton,{className:"h-3 w-4/5"}),(0,d.jsx)(ag.Skeleton,{className:"h-3 w-3/5"}),(0,d.jsx)(ag.Skeleton,{className:"h-3 w-2/3"})]})]})}function au(){return(0,d.jsxs)("div",{className:"flex items-center gap-2.5 px-2 py-1.5",children:[(0,d.jsx)(ag.Skeleton,{className:"size-8 shrink-0 rounded-[10px]"}),(0,d.jsxs)("span",{className:"flex h-9 min-w-0 flex-1 flex-col justify-center gap-1.5",children:[(0,d.jsx)(ag.Skeleton,{className:"h-3.5 w-2/5"}),(0,d.jsx)(ag.Skeleton,{className:"h-2.5 w-3/5"})]})]})}let av=[{id:"needsYou",label:"needs you"},{id:"working",label:"working"}];function aw({threads:a,onPick:b}){let c=new Map;for(let b of a){let a=(0,G.standOf)(b),d=c.get(a);d?d.push(b):c.set(a,[b])}return(0,d.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:av.map((a,e)=>{let f=c.get(a.id)??[];return f.length?(0,d.jsxs)(s.Fragment,{children:[(0,d.jsxs)("p",{className:(0,w.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===e?"pt-1":"pt-3"),children:[a.label," · ",f.length]}),f.map(a=>(0,d.jsx)(ax,{thread:a,onPick:()=>b(a.id)},a.id))]},a.id):null})})}function ax({thread:a,onPick:b,lines:c=1}){let e=(0,G.needsThreadReply)(a),f=a.lines.at(-1),g=(0,s.useMemo)(()=>(function(a){let b=a.room.questions[0];if(b)return{text:(0,w.plainText)(b.text),tone:"text-foreground"};if("waiting"===a.status&&a.ask)return{text:a.ask.refused?`${(0,F.refusedWords)(a.ask.refused)}.`:(0,G.isAppStop)(a.ask)?(0,w.plainText)(a.outcome??a.ask.question):a.ask.question,tone:w.WAITING_INK};let c=a.seen;if("cancelled"===a.status)return{text:"Stopped",tone:"text-muted-foreground"};if("done"===a.status)return{text:(0,w.plainText)(a.outcome??"Done"),tone:c?"text-muted-foreground":"text-foreground"};let d=(0,V.lastSaid)(a);return d?{text:"tool"===d.kind&&d.tool?d.tool.note??`${d.tool.name} \xb7 ${d.tool.input}`:d.text,tone:"text-muted-foreground"}:{text:`${a.bot.name} is taking it on…`,tone:"text-muted-foreground italic"}})(a),[a.status,a.outcome,a.seen,a.ask,a.room.questions,f?.id]),[h,i]=(0,N.useAnswerThread)(),[j,k]=(0,s.useState)(null),l=a.room.questions[0],m=l?l.options??[]:"waiting"===a.status&&(0,G.isAppStop)(a.ask)?a.ask?.options??[]:[];return(0,d.jsxs)("div",{className:"rounded-xl transition-colors hover:bg-muted/60",children:[(0,d.jsxs)("button",{type:"button",onClick:b,"data-focus-home":`thread-${a.id}`,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,d.jsx)("span",{className:"relative flex size-8 shrink-0 items-center justify-center overflow-visible",title:a.bot.name,children:(0,d.jsx)(H.BotMark,{size:32,seed:a.bot.name,color:a.bot.icon?.color,shape:a.bot.icon?.shape,outline:a.bot.icon?.outline,paint:a.bot.icon?.paint,state:"working"===a.status?"thinking":"idle",notify:e||(0,G.isUnread)(a),crossed:"cancelled"===a.status})}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[e&&!l&&(0,G.isAppStop)(a.ask)&&(0,d.jsx)("span",{className:"block font-mono text-[10px] tracking-wide text-muted-foreground",children:"Paused"}),(0,d.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:(0,w.cn)("min-w-0 truncate text-[14px] leading-5 tracking-[-0.15px]",e?"text-foreground":"text-foreground/80",(e||(0,G.isUnread)(a))&&"font-medium"),children:a.label}),a.routineId&&(0,d.jsx)("span",{title:"Started by a routine",className:"shrink-0",children:(0,d.jsx)(al.RoutineMark,{className:"size-3 text-muted-foreground/80"})}),(0,d.jsx)(ak.BotRoster,{bots:a.roster}),(0,d.jsx)("span",{className:"flex-1"}),(0,d.jsx)("span",{className:"shrink-0 font-mono text-[11px] leading-4 text-muted-foreground tabular-nums",children:(0,S.shortAgo)(a.updatedAt)})]}),(0,d.jsxs)("span",{className:(0,w.cn)("mt-px flex items-center gap-1.5",1===c&&"h-4"),children:["working"===a.status&&(0,d.jsx)(ad.Loader2,{className:"size-3 shrink-0 animate-spin text-muted-foreground/70"}),"working"===a.status||l?(0,d.jsx)(A.ShinyText,{text:g.text,speed:l?3.4:2.2,tone:l?"reading":void 0,className:(0,w.cn)("min-w-0 flex-1 text-[12px] leading-4",1===c?"truncate":"line-clamp-2",g.tone.includes("italic")&&"italic")}):(0,d.jsx)("span",{className:(0,w.cn)("min-w-0 flex-1 text-[12px] leading-4",1===c?"truncate":"line-clamp-2",g.tone),children:g.text})]})]})]}),m.length>0&&(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-0.5 pr-2 pb-2 pl-12.5",children:[!l&&a.ask?.refused&&(0,d.jsxs)(u.Button,{size:"sm",variant:"secondary",onClick:()=>(0,am.openSettings)("keys"),className:"h-7 gap-1.5 rounded-full px-3 text-[12px]",children:[(0,d.jsx)(p.Settings2,{className:"size-3.5"}),"Open Settings"]}),m.map(b=>(0,d.jsxs)(u.Button,{size:"sm",variant:"secondary",loading:j===b,disabled:i,onClick:async()=>{k(b),await h(a,b,l?.bot,l?.id),k(null)},className:"h-7 gap-1.5 rounded-full px-3 text-[12px]",children:[b===G.THREAD_CONTINUE&&(0,d.jsx)(ac.ChevronsRight,{className:"size-3.5"}),b]},b))]})]})}let ay={name:"at-sign",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]};ay.node;let az=(0,h.default)(ay);var aA=a.i(752562);let aB={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"]};aB.node;let aC=(0,h.default)(aB);var aD=a.i(802550),aE=a.i(748819);function aF({bot:a,icon:b,line:c,children:e}){return(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsx)(C.TooltipTrigger,{render:(0,d.jsx)("span",{}),children:e}),(0,d.jsxs)(C.TooltipContent,{className:"flex items-center gap-2 py-1 pr-2.5 pl-1",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-background/15 py-0.5 pr-2 pl-1",children:[(0,d.jsx)(H.BotMark,{size:15,seed:a,color:b?.color,shape:b?.shape,outline:b?.outline,paint:b?.paint}),(0,d.jsx)("span",{className:"font-medium text-[11px]",children:a})]}),c&&(0,d.jsx)("span",{className:"text-[11.5px] opacity-80",children:c})]})]})}let aG=[[0,[21,117,208]],[.4,[90,157,222]],[.75,[179,210,239]],[1,[252,252,254]]],aH=aG[0][1],aI=[{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}],aJ=(a,b,c)=>a<b?b:a>c?c:a,aK=a=>a*a*(3-2*a),aL=(a,b,c)=>aK(aJ((c-a)/(b-a),0,1)),aM=(a,b)=>{let c=0x165667b1*a+0x27d4eb2f*b|0;return(((c=(c^c>>>13)*0x4bf19f61)^c>>>16)>>>0)/0xffffffff},aN=(a,b)=>{let c=Math.floor(a),d=Math.floor(b),e=aK(a-c),f=aK(b-d);return(aM(c,d)*(1-e)+aM(c+1,d)*e)*(1-f)+(aM(c,d+1)*(1-e)+aM(c+1,d+1)*e)*f},aO=(a,b,c)=>.74*aN(a+c,b+.7*c)+.26*aN(2.2*a+c,2.2*b+1.3*c);function aP({on:a,className:b}){let c=(0,s.useRef)(null),[e,f]=(0,s.useState)(a),[g,h]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{if(a){f(!0);let a=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(a)}h(!1);let b=setTimeout(()=>f(!1),200);return()=>clearTimeout(b)},[a]),(0,s.useEffect)(()=>{let a=c.current,b=a?.getContext("2d");if(!a||!b)return;a.width=48,a.height=48;let d=b.createImageData(48,48),e=d.data,f=[0,0,0],g=900*Math.random(),h=400*Math.random(),i=a=>{let c=a+g,i=c+1.7*Math.sin(.33*c),j=(.5+.5*Math.sin(.27*c))**2*.72+(.5+.5*Math.sin(.41*c+2.1))**3*.28,k=.1*Math.sin(.19*c),l=aI.map(a=>({seed:a.seed,shift:i*a.pace,wide:a.wide*(1-a.gustWide*j),tall:a.tall*(1+a.gustTall*j),sky:h*a.sky})),m=0;for(let a=0;a<48;a+=1){let b=(a+.5)/48*2-1;for(let a=0;a<48;a+=1,m+=4){let d=(a+.5)/48*2-1,g=aN(.55*d+.03*c,.55*b+h)-.5,i=aN(.55*d+9.1+h,.55*b-.024*c)-.5,j=d+1.15*g,n=b+ +i+k,[o,p,q,r]=l.map(a=>aO((j-a.shift)*a.wide+a.sky,n*a.tall,a.seed)),s=aJ((.52-o)/.34,0,1);s*=.7+.6*aJ((.56-p)/.4,0,1);let t=.97-.92*(s=aJ(s+(.5-q)*.42,0,1))**1.2-.1*aJ((.5-q)/.6,0,1)+(r-.5)*.38,u=Math.sqrt(d*d+b*b);!function(a,b){let c=aJ(a,0,1),d=1;for(;d<aG.length-1&&c>aG[d][0];)d+=1;let[e,f]=aG[d-1],[g,h]=aG[d],i=(c-e)/(g-e);b[0]=f[0]+(h[0]-f[0])*i,b[1]=f[1]+(h[1]-f[1])*i,b[2]=f[2]+(h[2]-f[2])*i}(t+=.16*aJ(1-Math.hypot(d+.42,b+.48)/1.5,0,1)+aL(.84,1,u)*aJ(.15+.85*(.8*b+.45*d),0,1)*.45,f);let v=aJ(u,0,1)**2.4*.26;e[m]=f[0]+(aH[0]-f[0])*v,e[m+1]=f[1]+(aH[1]-f[1])*v,e[m+2]=f[2]+(aH[2]-f[2])*v,e[m+3]=255*(1-aL(.94,1,u))}}b.putImageData(d,0,0)},j=performance.now();if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void i(6);let k=0,l=0,m=a=>{k=requestAnimationFrame(m),a-l<33||(l=a,i((a-j)/1e3))};return k=requestAnimationFrame(m),()=>cancelAnimationFrame(k)},[e]),e)?(0,d.jsx)("canvas",{ref:c,"aria-hidden":!0,className:(0,w.cn)("pointer-events-none absolute inset-0 size-full transition-opacity",g?"opacity-100":"opacity-0",b),style:{transitionDuration:"200ms"}}):null}var aQ=a.i(324835);let aR={done:aA.Check,cancelled:q.X,question:aD.CircleQuestionMark,stopped:aC,resumed:aE.RotateCw},aS={question:w.WAITING_INK,stopped:w.WAITING_INK},aT=a=>{let b=(0,w.plainText)(a).replace(/\s+/g," ").trim();return b.length>28?`${b.slice(0,27)}…`:b};function aU({crew:a,more:b,bubble:c,rows:e,count:f,busy:g,pending:h,playing:i,resting:j=!1,onPick:k,onOpen:l}){let m=(0,V.useWriteLineUp)(),n=e.length>0&&!m;return(0,d.jsxs)("div",{className:(0,w.cn)("pointer-events-auto w-fit max-w-full bg-background/78 ring-1 ring-border/50 backdrop-blur-md transition-shadow duration-300",n?"w-132 rounded-3xl shadow-lg shadow-black/8":"rounded-full shadow-sm shadow-black/3"),children:[(0,d.jsx)("div",{className:(0,w.cn)("grid overflow-hidden contain-inline-size transition-[grid-template-rows] duration-300 ease-out",n?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:(0,d.jsxs)("div",{className:"min-h-0 overflow-hidden",inert:!n,children:[(0,d.jsxs)("p",{className:"px-3 py-2 font-mono text-[10px] tracking-wide text-muted-foreground",children:[h," ",1===h?"needs":"need"," a reply"]}),(0,d.jsx)("div",{className:"max-h-[34vh] overflow-y-auto px-1.5 pb-2",children:(0,d.jsx)("div",{children:e.map((a,b)=>(0,d.jsx)("div",{style:{animationDelay:`${120+60*b}ms`},className:"animate-in duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:(0,d.jsx)(ax,{thread:a,onPick:()=>k(a.id)})},a.id))},String(n))}),(0,d.jsx)("span",{className:"block h-1.5"})]})}),(0,d.jsx)(aV,{crew:a,more:b,bubble:n?null:c,label:f?`Threads (${f})`:"Bots",onClick:l,playing:i,resting:j,side:(0,d.jsx)(aW,{busy:g,pending:h,grown:n}),onWrite:V.writeLine.choose,writing:m})]})}function aV({crew:a,more:b,bubble:c,playing:e,resting:f=!1,side:g,label:h,onClick:i,onWrite:j,writing:k}){return(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2 py-1.5 pr-3 pl-1.5",children:[(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsxs)(C.TooltipTrigger,{render:(0,d.jsx)("button",{type:"button",onClick:j,"aria-label":"Write to Thursday or a bot","data-focus-home":"write","aria-pressed":k,className:(0,w.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",k?"shadow-[0_6px_14px_-7px_color-mix(in_oklab,var(--brand)_60%,transparent)]":"bg-muted text-foreground hover:bg-accent")}),children:[(0,d.jsx)(aP,{on:!!k}),(0,d.jsx)(az,{className:(0,w.cn)("size-3.5 transition-opacity duration-200",k?"opacity-0":"opacity-100")})]}),(0,d.jsxs)(C.TooltipContent,{children:["Write to Thursday or a bot",(0,d.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:"@"})]})]}),(0,d.jsxs)("button",{type:"button",onClick:i,"aria-label":h,"data-focus-home":"room",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,d.jsx)(aY,{crew:a,more:b,bubble:c,playing:e,resting:f}),g]})]})}function aW(a){let b=function({busy:a,pending:b,grown:c}){return b>0?{text:1===b?"waiting on you":`${b} waiting on you`,shine:!0}:a>0?{text:"working",shine:!0,spin:!0}:c?null:{text:"Need a hand?",shine:!1}}(a);return b?(0,d.jsxs)("span",{className:"ml-auto flex h-7 min-w-0 shrink items-center gap-1.5",children:[b.shine?(0,d.jsx)(A.ShinyText,{text:b.text,speed:2.6,className:"block truncate text-[14px] leading-5 tracking-[-0.15px]"}):(0,d.jsx)("span",{className:"block animate-in truncate text-[14px] leading-5 tracking-[-0.15px] text-muted-foreground fade-in duration-300",children:b.text},b.text),b.spin&&(0,d.jsx)(ad.Loader2,{className:"size-4 shrink-0 animate-spin text-muted-foreground/70"})]}):null}let aX=["alto","brio","cinder","delta"].map((a,b,c)=>({name:a,icon:{color:aQ.MARK_PALETTE[Math.floor(b*aQ.MARK_PALETTE.length/c.length)],shape:aQ.MARK_SHAPES[b%aQ.MARK_SHAPES.length]},awake:!1,waiting:!1,unread:!1,word:null,standIn:!0}));function aY({crew:a,more:b,bubble:c,playing:e,resting:f}){return(0,d.jsxs)("span",{className:"flex min-w-0 shrink items-center",children:[a.map((b,g)=>{let h=b.standIn?a.every(a=>a.standIn)?"No bots yet":null:b.waiting?"Waiting on you":b.word?b.word:b.unread?"Left you a result":b.awake?"Working":"Idle",i=(0,d.jsx)("span",{className:(0,w.cn)("flex transition-transform duration-500 ease-out",b.awake&&"-translate-y-0.5 scale-110"),children:(0,d.jsx)(aZ,{face:b,motion:(0,M.motionOf)(e.get(b.name),g),asleep:f&&!b.awake&&!b.waiting&&!e.has(b.name)})});return(0,d.jsxs)(s.Fragment,{children:[(0,d.jsxs)("span",{className:(0,w.cn)("relative shrink-0 transition-[margin] duration-500 ease-out",g>0&&!a[g-1].word&&"-ml-2",b.standIn&&"opacity-35"),style:{zIndex:a.length-g},children:[null===h?(0,d.jsx)("span",{children:i}):(0,d.jsx)(aF,{bot:b.name,icon:b.icon,line:h,children:i}),c?.at===b.name&&(0,d.jsx)(a_,{handoff:c})]}),b.word&&(0,d.jsx)("span",{className:"mx-2.5 min-w-0 shrink truncate",children:(0,d.jsx)(A.ShinyText,{text:b.word,speed:2.6,className:"truncate text-[13px] leading-5 tracking-[-0.1px]"})})]},b.name)}),b>0&&(0,d.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:`${b} more`,children:"+"})]})}function aZ({face:a,motion:b,asleep:c}){let e=b.delayMs?{animationDelay:`${b.delayMs}ms`}:void 0;return(0,d.jsx)("span",{"data-crew-motion":!0,className:(0,w.cn)("flex",b.body),style:e,children:(0,d.jsx)("span",{"data-crew-motion":!0,className:(0,w.cn)("flex origin-bottom",!c&&b.shape),style:e,children:(0,d.jsx)("span",{"data-crew-motion":!0,className:(0,w.cn)("flex",b.turn),style:e,children:(0,d.jsx)(a$,{face:a,asleep:c})})})},b.key)}function a$({face:a,asleep:b}){return(0,d.jsx)(H.BotMark,{resting:b,size:28,seed:a.name,color:a.icon?.color,shape:a.icon?.shape,outline:a.icon?.outline,paint:a.icon?.paint,notify:a.waiting||a.unread})}function a_({handoff:a}){return(0,d.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,d.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,d.jsx)(a1,{handoff:a})}),(0,d.jsx)("span",{className:"-mt-px size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-border"}),(0,d.jsx)("span",{className:"-mt-[7.5px] size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-background"})]})}function a0({handoff:a}){return(0,d.jsx)("span",{className:"ml-auto flex h-7 min-w-0 shrink animate-in items-center pl-4 fade-in duration-200",children:(0,d.jsx)(a1,{handoff:a})})}function a1({handoff:a}){let b=a.sign?aR[a.sign]:null,c=a.sign?aS[a.sign]:void 0;return(0,d.jsxs)("span",{className:(0,w.cn)("flex min-w-0 items-center gap-2 text-[13px] leading-[18px] tracking-[-0.1px] whitespace-nowrap",c),children:[(0,d.jsx)(a2,{from:a.from,to:a.to}),b&&(0,d.jsx)(b,{className:(0,w.cn)("size-3.5 shrink-0",!c&&"text-muted-foreground/70")}),a.shine?(0,d.jsx)(A.ShinyText,{text:a.text,speed:2.2,className:"min-w-0 truncate"}):(0,d.jsx)("span",{className:"min-w-0 truncate",children:a.text})]})}function a2({from:a,to:b}){let c=[a,...b];return(0,d.jsx)("span",{className:"flex shrink-0 items-center",children:c.map((a,b)=>(0,d.jsx)("span",{className:(0,w.cn)("relative flex",b>0&&(c[b-1].name===W.YOU.name?"ml-1":"-ml-1.25")),style:{zIndex:c.length-b},children:(0,d.jsx)(a3,{bot:a})},a.name))})}function a3({bot:a}){return a.name===W.YOU.name?(0,d.jsx)("span",{className:"shrink-0 font-mono text-[10.5px] text-muted-foreground",children:"You"}):a.name===W.THURSDAY.name?(0,d.jsx)(O.ThursdayMark,{size:18,className:"shrink-0"}):(0,d.jsx)(H.BotMark,{size:18,seed:a.name,color:a.icon?.color,shape:a.icon?.shape,outline:a.icon?.outline,paint:a.icon?.paint,notify:!1,className:"shrink-0"})}let a4=(0,r.default)(async()=>{},{loadableGenerated:{modules:[590714]},ssr:!1}),a5=(0,s.memo)(function(){let a=(0,V.useBotThreads)(),b=ao(),{data:c}=(0,U.useServerRoute)(t.queryKey.bot),[e,f]=(0,s.useState)(!1),[g,h]=(0,s.useState)(!1),[i,j]=(0,s.useState)(null),k=e&&null!==i;(0,s.useEffect)(()=>(V.roomOpen.set(e?k?"thread":"list":null),()=>V.roomOpen.set(null)),[e,k]),P(e,"room"),P(k,i?`thread-${i}`:void 0);let[l,m]=(0,s.useState)({}),[n,o]=(0,s.useState)("now"),p=(0,s.useRef)(0),q=[...a].reverse(),r=q.filter(a=>"finished"!==(0,G.standOf)(a)),u=e&&"history"===n,v=(0,T.useServerPages)({key:(a,b)=>{if(!u)return null;if(0===a)return t.queryKey.threadHistory(null);let c=b?.at(-1);return c?t.queryKey.threadHistory((0,S.toDate)(c.updatedAt).toISOString()):null},size:D.PAGE_SIZE}),{refresh:x}=v,y=(0,s.useRef)(!1);y.current=v.items.length>0,(0,s.useEffect)(()=>{u&&y.current&&x()},[u,x]);let z=(0,s.useMemo)(()=>v.items.filter(a=>"done"===a.status||"cancelled"===a.status).map(a=>(0,V.threadFromRow)(a,c)),[v.items,c]),A=i?q.find(a=>a.id===i)??z.find(a=>a.id===i)??null:null,{data:B,isLoading:C}=(0,U.useServerRoute)(i?t.queryKey.thread(i):null),E=(0,s.useMemo)(()=>B&&B.id===i?(0,V.threadFromRow)(B,c):null,[B,i,c])??(A?.lines.length?A:null),F=null!==i&&(null!==E||C),H=R(1280),I=(0,V.useRoomReadAs)(),J=k&&H&&"office"===I&&!g&&(null!==E||C);(0,s.useEffect)(()=>V.roomOffice.set(J),[J]),(0,s.useEffect)(()=>()=>V.roomOffice.set(!1),[]);let L=function(a){let[b,c]=(0,s.useState)(a);null!==a&&a!==b&&c(a);let d=null===a,[e,f]=(0,s.useState)(d);!d&&e&&f(!1),(0,s.useEffect)(()=>{if(!d)return;let a=setTimeout(()=>f(!0),250);return()=>clearTimeout(a)},[d,250]);let g=a??b;return e||null===g?null:{value:g,leaving:d}}(J?E:null);(0,s.useEffect)(()=>V.roomThread.set(e&&!g?i:null),[e,g,i]),(0,s.useEffect)(()=>()=>V.roomThread.set(null),[]);let[O,X]=function(){let[a,b]=(0,s.useState)(null),c=(0,s.useRef)(null);return(0,s.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]),[a,(0,s.useCallback)(a=>{b(a),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,b(null)},3400)},[])]}(),Y=(0,s.useMemo)(()=>O??function(a,b){for(let c of a){if("working"!==c.status)continue;let a=c.room.deliveries.find(a=>!a.delivered&&c.room.participants.some(b=>b.bot===a.bot&&"running"===b.state));if(a)return{at:a.bot,from:b(a.bot),to:[],text:"Step-in · waits for its next step",shine:!0}}return null}(a,a=>({name:a,icon:c?.find(b=>b.name===a)?.icon??null})),[O,a,c]),{crew:Z,more:$}=(0,s.useMemo)(()=>(function(a,b){let c=new Set(b.filter(G.isUnread).map(a=>a.bot.name)),d=function(a){let b=new Map;for(let d of a){let a=new Set(d.room.questions.map(a=>a.bot));for(let e of("waiting"!==d.status||a.size||a.add(d.bot.name),d.room.participants)){var c;if(a.has(e.bot)){b.set(e.bot,{waiting:!0,word:null});continue}if(b.get(e.bot)?.waiting||"running"!==e.state&&"queued"!==e.state)continue;let f="running"===e.state?d.lines.findLast(a=>a.bot.name===e.bot&&"user"!==a.kind&&"note"!==a.kind&&"stop"!==a.kind):null;b.set(e.bot,{waiting:!1,word:(c=f??null,c?.kind==="tool"||c?.kind==="say"?aT((0,W.stepOf)(c)):null)})}}return b}(b),e=new Map;for(let b of a??[])e.set(b.name,{name:b.name,icon:b.icon,awake:d.has(b.name),waiting:d.get(b.name)?.waiting??!1,unread:c.has(b.name),word:d.get(b.name)?.word??null});for(let[a,b]of d)e.has(a)||e.set(a,{name:a,icon:null,awake:!0,waiting:b.waiting,unread:c.has(a),word:b.word});let f=[...e.values()].filter(a=>a.awake||a.waiting),g=f.length?f:[...e.values()];if(!g.length)return{crew:aX.slice(0,3),more:0};for(let a of f.length?[]:aX){if(g.length>=3)break;e.has(a.name)||g.push(a)}let h=a=>a.waiting?0:a.awake?1:a.unread?2:a.standIn?4:3,i=g.map((a,b)=>({face:a,at:b})).sort((a,b)=>h(a.face)-h(b.face)||a.at-b.at).map(a=>a.face);return{crew:i.slice(0,14),more:Math.max(0,i.length-14)}})(c,a),[c,a]),[_,aa]=(0,M.useCrewGestures)(),ab=(0,M.useCrewAwake)(),ac=(0,s.useRef)(!1);(0,s.useEffect)(()=>{!ac.current&&c?.length&&(ac.current=!0,aa(c.map(a=>({bot:a.name,gesture:"wave"}))))},[c,aa]);let ad=(0,s.useRef)(null),ae=(0,s.useRef)(new Map),af=(0,s.useRef)(new Set);(0,s.useEffect)(()=>{if(!V.botThreads.primed())return;let b=ad.current;ad.current=new Map(a.map(a=>[a.id,a.status]));let c=ae.current;ae.current=function(a){let b=new Map;for(let c of a)for(let a of c.room.participants)b.set(`${c.id}
|
|
2
2
|
${a.bot}`,a.state);return b}(a);let d=af.current;if(af.current=new Set(a.flatMap(a=>a.lines.map(a=>a.id))),!b)return;let e=null,f=[];for(let g of a){let{moments:a,gestures:h}=function(a,b,c,d,e){let f=a.bot,g=[];if(!b)return"working"===a.status?{moments:[{rank:1,at:f.name,from:"user"===a.startedBy?W.YOU:W.THURSDAY,to:[f],text:`took on “${aT(a.label)}”`}],gestures:[{bot:f.name,gesture:"took"}]}:{moments:[],gestures:[]};let h=[],i=a.lines.filter(a=>!c.has(a.id)),j=new Map;for(let a of i)"user"===a.kind?(a.steppedIn?g.push({bot:a.bot.name,gesture:"read"}):g.push({bot:a.bot.name,gesture:"took"}),h.push(a.steppedIn?{rank:1,at:a.bot.name,from:a.bot,to:[],text:"Step-in · read"}:{rank:1,at:a.bot.name,from:(0,V.speakerOf)(a),to:[a.bot],text:aT(a.text)})):"stop"===a.kind?(g.push({bot:a.bot.name,gesture:"stop"}),h.push({rank:3,at:a.bot.name,from:a.bot,to:[],sign:"stopped",text:(0,W.leadOf)(a.text)})):"ask"===a.kind&&a.to?.name===W.THURSDAY.name?(a.question&&g.push({bot:a.bot.name,gesture:"ask"}),h.push(a.question?{rank:4,at:a.bot.name,from:a.bot,to:[],sign:"question",text:`asks you \xb7 ${aT(a.text)}`}:{rank:2,at:a.bot.name,from:a.bot,to:[W.THURSDAY],text:aT(a.text)})):"ask"===a.kind&&a.to&&j.set(a.bot.name,[...j.get(a.bot.name)??[],a]);for(let[a,b]of j){let c=new Map;for(let a of b)a.to&&c.set(a.to.name,a.to);for(let b of(g.push({bot:a,gesture:"give"}),c.values()))g.push({bot:b.name,gesture:"take"});h.push({rank:2,at:a,from:b[0].bot,to:[...c.values()],text:1===b.length?aT(b[0].text):`sent ${b.length} parts out`})}for(let b of a.roster){let c=`${a.id}
|
|
3
|
-
${b.name}`;b.name===f.name||"running"!==d.get(c)||"done"!==e.get(c)||i.some(a=>a.bot.name===b.name&&("ask"===a.kind||"say"===a.kind))||(g.push({bot:b.name,gesture:"done"}),h.push({rank:1,at:b.name,from:b,to:[],sign:"done",text:"finished its part"}))}if(b===a.status)return{moments:h,gestures:g};let k=aT(a.label);return"cancelled"===a.status?(g.push({bot:f.name,gesture:"stop"}),h.push({rank:3,at:f.name,from:f,to:[],sign:"cancelled",text:`stopped \xb7 ${k}`})):"done"===a.status?g.push({bot:f.name,gesture:"done"}):"working"===a.status?i.some(a=>"user"===a.kind)||(g.push({bot:f.name,gesture:"took"}),h.push({rank:1,at:f.name,from:f,to:[],sign:"resumed",text:"picked it back up"})):(0,G.isAppStop)(a.ask)&&!h.some(a=>"question"===a.sign||"stopped"===a.sign)&&(g.push({bot:f.name,gesture:"stop"}),h.push({rank:3,at:f.name,from:f,to:[],sign:"stopped",text:"paused"})),{moments:h,gestures:g}}(g,b.get(g.id),d,c,ae.current);for(let b of(f.push(...h),a))(!e||b.rank>=e.rank)&&(e=b)}e&&X(e),aa(f)},[a,X,aa]),(0,V.useSeenOnDetail)(e?E:null),(0,K.useAppEvent)({showThread:a=>{j(a.threadId),h(!1),f(!0)}}),(0,s.useEffect)(()=>V.roomOpens.subscribe(a=>{j(a),o("now"),h(!1),f(!0)}),[]);let ag=a.filter(a=>"working"===a.status).length,ah=q.filter(G.needsThreadReply).length,ai=(0,s.useMemo)(()=>Z.map(a=>({...a,word:null})),[Z]),aj=()=>{f(!1),h(!1),j(null),o("now"),p.current=0},ak=()=>h(!0),al=(0,s.useRef)(aj);al.current=aj,(0,s.useEffect)(()=>{if(!g)return;let a=setTimeout(()=>al.current(),250);return()=>clearTimeout(a)},[g]);let am=(0,V.useCallWaits)();(0,Q.useEscape)(e&&!g,()=>k?j(null):ak()),(0,s.useEffect)(()=>V.writeLine.subscribe(()=>al.current()),[]);let an=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!k)return;let a=a=>{if(!(0,Q.typed)(a,"@")||!(0,Q.windowKey)(a))return;let b=an.current?.querySelector("textarea:not(:disabled)");b&&(a.preventDefault(),b.focus())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[k]),(0,d.jsxs)("div",{className:(0,w.cn)("pointer-events-none flex min-h-0 items-end justify-end",e?"col-span-3 row-start-1 self-stretch":"col-span-3 row-start-2"),children:[e&&L&&(0,d.jsx)(a4,{thread:L.value,leaving:L.leaving,onBot:a=>m(b=>({...b,[L.value.id]:a===L.value.bot.name?null:a})),onAnswer:()=>(an.current?.querySelector("[data-continue]:not(:disabled)")??an.current?.querySelector("textarea:not(:disabled)"))?.focus(),className:"pointer-events-auto mr-4 min-h-0 min-w-0 flex-1 self-stretch"}),e?(0,d.jsxs)("div",{ref:an,"data-room":!0,className:(0,w.cn)("pointer-events-auto flex max-h-full w-160 max-w-full shrink-0 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",F&&"h-[calc(64vh+11rem)]",g&&"pointer-events-none translate-y-1 opacity-0 transition-[opacity,translate] duration-250 ease-in"),children:[am&&(0,d.jsx)(a7,{onBack:ak}),!E&&i&&C?(0,d.jsx)(at,{onBack:()=>j(null),onClose:ak}):E?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(W.ThreadHeader,{thread:E,onBack:()=>j(null),onClose:ak,titled:!J,children:H&&(0,d.jsx)(a6,{})}),(0,d.jsx)(W.Conversation,{thread:E,tab:l[E.id]??null,onTab:a=>m(b=>({...b,[E.id]:a})),className:"max-h-none min-h-0 flex-1"}),(0,d.jsx)(N.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:l[E.id]??E.bot.name,className:"mx-3 mb-2 shrink-0"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ap,{tab:n,current:r.length,working:r.filter(a=>"working"===a.status).length,onTab:o,onClose:ak}),"history"===n?(0,d.jsx)(as,{pages:v,threads:z,scroll:p,onPick:j}):r.length?(0,d.jsx)(aw,{threads:r,onPick:j}):q.length?(0,d.jsx)(ar,{}):(0,d.jsx)(aq,{bots:c}),(0,d.jsx)(aV,{crew:ai,more:$,bubble:null,playing:_,label:"Fold the room away",onClick:ak,onWrite:V.writeLine.choose,side:Y?(0,d.jsx)(a0,{handoff:Y}):(0,d.jsx)(aW,{busy:ag,pending:ah,grown:!0})})]})]}):(0,d.jsx)(aU,{crew:Z,more:$,bubble:Y,playing:_,resting:!ab,rows:b,count:a.length,busy:ag,pending:ah,onPick:a=>{j(a),h(!1),f(!0)},onOpen:()=>{h(!1),f(!0)}})]})});function a6(){let a=(0,V.useRoomReadAs)();return(0,d.jsx)(L.Segmented,{view:!0,size:"sm","aria-label":"How the thread is shown",value:a,onChange:V.roomReadAs.set,options:[{value:"office",label:"Office",title:"The thread beside its office, where her face stands"},{value:"chat",label:"Chat",title:"The conversation alone, her face kept"}],className:"shrink-0"})}function a7({onBack:a}){return(0,d.jsxs)("button",{type:"button",onClick:a,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,d.jsx)(O.ThursdayMark,{size:22,className:"shrink-0"}),(0,d.jsxs)("span",{className:"min-w-0 flex-1 text-[13px] leading-5",children:[(0,d.jsx)("span",{className:"font-medium",children:"Thursday is still on the line"}),(0,d.jsxs)("span",{className:"text-muted-foreground",children:[" ","— in writing. She is here when this closes."]})]}),(0,d.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,d.jsx)(J,{className:"size-3.5"})]})]})}var a8=a.i(8468),a9=a.i(249049),ba=a.i(478978);let bb={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"}]]};bb.node;let bc=(0,h.default)(bb);var bd=a.i(823319);let be="thursday.install-asked",bf=null,bg=new Set;function bh(){return(0,s.useSyncExternalStore)(a=>(bg.add(a),()=>bg.delete(a)),()=>bf,()=>null)}async function bi(){let a=bf;if(a){for(let a of(bf=null,bg))a();await a.prompt(),await a.userChoice.catch(()=>void 0)}}function bj({hidden:a}){let b=null!==bh(),[c,e]=(0,s.useState)(!0);if((0,s.useEffect)(()=>{try{e(null!==window.localStorage.getItem(be))}catch{}},[]),!b||c||a)return null;let f=()=>{e(!0);try{window.localStorage.setItem(be,"1")}catch{}};return(0,d.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,d.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg bg-muted",children:(0,d.jsx)(bc,{className:"size-4"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1 space-y-2.5",children:[(0,d.jsxs)("p",{className:"text-[13px] leading-snug",children:[(0,d.jsx)("span",{className:"block font-medium",children:"Keep her in her own window"}),(0,d.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,d.jsxs)("div",{className:"flex gap-1.5",children:[(0,d.jsx)(u.Button,{size:"sm",className:"rounded-full px-3.5",onClick:()=>{f(),bi()},children:"Install"}),(0,d.jsx)(u.Button,{size:"sm",variant:"ghost",className:"rounded-full px-3 text-muted-foreground",onClick:f,children:"Not now"})]})]})]})}function bk(){return null===bh()?null:(0,d.jsx)("button",{type:"button",onClick:()=>void bi(),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,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1 text-sm font-medium",children:["Install app",(0,d.jsx)(bd.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,d.jsx)("span",{className:"block text-xs leading-snug text-muted-foreground",children:"Its own window, apart from your tabs"})]})})}let bl={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"}]]};bl.node;let bm=(0,h.default)(bl);var bn=a.i(126766),bo=a.i(62140),bp=a.i(474896);let bq={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"}]]};bq.node;let br=(0,h.default)(bq),bs={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"}]]};bs.node;let bt=(0,h.default)(bs),bu={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"}]]};bu.node;let bv=(0,h.default)(bu),bw={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"}]]};bw.node;let bx=(0,h.default)(bw);var by=a.i(965733),bz=a.i(619477);function bA(){let{data:a}=(0,U.useServerRoute)(t.queryKey.bot);return a&&0===a.length?"waiting":null}function bB(){let{data:a}=(0,U.useServerRoute)(t.queryKey.threads);return{owed:(a??[]).filter(a=>(0,G.needsThreadReply)(a)||(0,G.isUnread)(a)).length}}var bC=a.i(907602);let bD=Object.values(bC.REACH_KEYS).flat();function bE(){let{data:a,isLoading:b}=(0,U.useServerRoute)(t.queryKey.config),c=(0,a9.useVoiceLine)();if(b)return null;let d=b=>(0,ba.isConfigSet)(a,b),e=ba.CONFIG_GROUPS.some(a=>"keys"===a.section&&!(0,ba.groupSatisfied)(a,a.id===ba.VOICE_GROUP_ID?c.countsForCall:d)),f=!!a?.some(a=>a.unreadable&&!bD.includes(a.key));return e||f?"waiting":null}let bF=ba.CONFIG_GROUPS.filter(a=>"models"===a.section).flatMap(a=>a.entries.filter(a=>a.kind).map(a=>a.key)),bG=Object.keys(ba.MEDIA_MODEL_KEYS);function bH(){let{data:a,isLoading:b}=(0,U.useServerRoute)(t.queryKey.config),{data:c}=(0,U.useServerRoute)(t.queryKey.llmModel);if(b||!a||!c)return null;let d=c.find(a=>a.signIn),e=d?.hasKey?{plan:d.plan??null}:null;return!bG.some(a=>(0,F.planMediaOf)(a,e))&&bF.every(b=>!(0,ba.isConfigSet)(a,b))?"waiting":null}function bI(){let{data:a}=(0,U.useServerRoute)(t.queryKey.mcp);return a?.some(a=>a.lastError)?"red":null}var bJ=a.i(107340),bK=a.i(86922);function bL(){let{data:a}=(0,U.useServerRoute)(t.queryKey.reach),{data:b}=(0,U.useServerRoute)(t.queryKey.config),c=Object.values(bC.REACH_KEYS).flat().some(a=>(0,ba.isConfigUnreadable)(b,a));return a?.channels.some(a=>a.refused)||c?"red":null}var bM=a.i(600154),bN=a.i(844561);let bO=bN.FolderOpen;var bP=a.i(730357),bQ=a.i(682823);function bR({d:a,className:b}){return(0,d.jsx)("svg",{viewBox:"-2 -2 28 28","aria-hidden":!0,className:b,children:(0,d.jsx)("path",{d:a,fill:"currentColor"})})}let bS=[{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-agent",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 bT(){return(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:bS.map(a=>(0,d.jsxs)("a",{href:a.href,target:"_blank",rel:"noreferrer",className:(0,w.cn)((0,u.buttonVariants)({variant:"ghost"}),"justify-start text-muted-foreground"),children:[(0,d.jsx)(bR,{d:a.mark,className:"mr-1"}),(0,d.jsx)("span",{className:"truncate text-sm",children:a.label})]},a.href))})}var bU=bz;let bV=(a,b=bU.SettingSkeleton)=>(0,r.default)(a,{loading:()=>(0,d.jsx)(b,{})}),bW=bV(()=>a.A(277297).then(a=>({default:a.MemorySetting}))),bX=bV(()=>a.A(348436).then(a=>({default:a.BotSetting})),bU.SettingPanesSkeleton),bY=bV(()=>a.A(315458).then(a=>({default:a.ThreadSetting}))),bZ=bV(()=>a.A(553433).then(a=>({default:a.RoutineSetting}))),b$=bV(()=>a.A(228887).then(a=>({default:a.ModelsSetting}))),b_=bV(()=>a.A(228887).then(a=>({default:a.KeysSetting}))),b0=bV(()=>a.A(228887).then(a=>({default:a.PhoneSetting}))),b1=bV(()=>a.A(502073).then(a=>({default:a.ThursdaySetting}))),b2=bV(()=>a.A(436788).then(a=>({default:a.ArtifactSetting})),bU.SettingPanesSkeleton),b3=bV(()=>a.A(895186).then(a=>({default:a.WorkspaceSetting})),bU.SettingPanesSkeleton),b4=bV(()=>a.A(479648).then(a=>({default:a.SkillsSetting}))),b5=bV(()=>a.A(930209).then(a=>({default:a.McpSetting}))),b6=bV(()=>a.A(15022).then(a=>({default:a.SignInsSetting})));function b7({tabs:a}){let[b,c]=(0,s.useState)(0),e=a[b].Component;return(0,d.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,d.jsx)("div",{className:"shrink-0 px-8 pt-5",children:(0,d.jsx)(bU.SettingColumn,{children:(0,d.jsx)(L.Segmented,{view:!0,"aria-label":"Screens of this section",options:a.map((a,b)=>({value:String(b),label:a.label})),value:String(b),onChange:a=>c(Number(a))})})}),(0,d.jsx)("div",{className:"min-h-0 flex-1",children:(0,d.jsx)(e,{})})]})}let b8=[{label:"Finished",Component:b2},{label:"All files",Component:b3}],b9=["call","work","app"],ca="px-3 pt-3 pb-1 font-mono text-[10px] text-muted-foreground",cb=[{id:"thursday",label:"Thursday",group:"call",hint:"Captions, models, and how a call starts",icon:O.ThursdayMark,Component:b1},{id:"memory",label:"Memory",group:"call",hint:"What Thursday remembers about you",icon:bK.MemoryMark,Component:bW},{id:"bot",label:"Bots",group:"work",hint:"Who Thursday hands work to",icon:H.BotsMark,Component:bX,Badge:function(){return bA()?(0,d.jsx)(bz.NavBadge,{tone:"waiting"}):null}},{id:"threads",label:"Threads",group:"work",hint:"Work the bots were handed",icon:bo.ListChecks,Component:bY,Badge:function(){return(0,d.jsx)(bz.NavBadge,{tone:"waiting",count:bB().owed})}},{id:"routines",label:"Routines",group:"work",hint:"Work that starts by itself, on a schedule",icon:al.RoutineMark,Component:bZ},{id:"files",label:"Files",group:"work",hint:"What the bots finished, and everything else they wrote",icon:bO,Component:()=>(0,d.jsx)(b7,{tabs:b8})},{id:"skills",label:"Skills",group:"work",hint:"Instructions the bots load on demand",icon:bM.SkillsMark,Component:b4},{id:"mcp",label:"Connectors",group:"work",hint:"Apps the bots can use, from MCP servers",icon:bJ.McpMark,Component:b5,Badge:function(){return bI()?(0,d.jsx)(bz.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:bp.LogIn,Component:b6},{id:"models",label:"Models",group:"app",hint:"What bots think with, and what they draw, film and speak with",icon:bm,Component:b$,Badge:function(){return bH()?(0,d.jsx)(bz.NavBadge,{tone:"waiting"}):null}},{id:"keys",label:"API keys",group:"app",hint:"The accounts the app runs on",icon:bn.KeyRound,Component:b_,Badge:function(){return bE()?(0,d.jsx)(bz.NavBadge,{tone:"waiting"}):null}},{id:"phone",label:"Phone",group:"app",hint:"Write to Thursday from a chat app or by email",icon:bv,Component:b0,Badge:function(){return bL()?(0,d.jsx)(bz.NavBadge,{tone:"red"}):null}}],cc={system:{label:"System",icon:br},light:{label:"Light",icon:bx},dark:{label:"Dark",icon:bt}};function cd(){let a=(0,bP.useTheme)();return(0,d.jsx)(L.Segmented,{"aria-label":"Theme",className:"w-full gap-0.5 *:flex-1 *:py-1.5",options:bQ.THEMES.map(a=>{let{label:b,icon:c}=cc[a];return{value:a,title:b,label:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{className:"size-3.5"}),(0,d.jsx)("span",{className:"sr-only",children:b})]})}}),value:a,onChange:bP.setTheme})}function ce({children:a}){let b=(0,am.useSettingsStore)(a=>a.open),c=(0,am.useSettingsStore)(a=>a.section),e=(0,am.useSettingsStore)(a=>a.show),f=(0,am.useSettingsStore)(a=>a.hide),g=(0,am.useSettingsStore)(a=>a.pick),h=async a=>{let b=am.useSettingsStore.getState().unsaved;(!b?.()||await af.notify.discard())&&a()},i=(0,s.useRef)(null),j=cb.find(a=>a.id===c)??cb[0];return(0,s.useEffect)(()=>{if(!b)return;let a=a=>{if(!a.metaKey&&!a.ctrlKey)return;if("k"===a.key){let b=i.current?.querySelector("[data-setting-filter]");if(!b)return;a.preventDefault(),b.focus(),b.select();return}let b=Number(a.key);Number.isInteger(b)&&b>=1&&b<=cb.length&&(a.preventDefault(),h(()=>g(cb[b-1].id)))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[b,g]),(0,d.jsxs)(by.Dialog,{open:b,onOpenChange:a=>a?e():void h(f),children:[a&&(0,d.jsx)(by.DialogTrigger,{render:a}),(0,d.jsxs)(by.DialogContent,{className:"block h-[min(52rem,calc(100vh-3rem))] overflow-hidden p-0 sm:max-w-[min(80rem,calc(100vw-3rem))]",children:[(0,d.jsx)(by.DialogTitle,{className:"sr-only",children:"Settings"}),(0,d.jsxs)("div",{className:"flex h-full min-h-0",children:[(0,d.jsxs)("nav",{"aria-label":"Settings sections",onKeyDown:a=>{let b,d="ArrowDown"===a.key?1:"ArrowUp"===a.key?-1:0;if(!d)return;a.preventDefault();let e=(b=(cb.findIndex(a=>a.id===c)+d+cb.length)%cb.length,cb[b].id);h(()=>g(e)),a.currentTarget.querySelector(`[data-section="${e}"]`)?.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:[b9.map(a=>(0,d.jsxs)(s.Fragment,{children:[(0,d.jsx)("span",{className:ca,children:a}),cb.filter(b=>b.group===a).map(a=>(0,d.jsxs)(u.Button,{"data-section":a.id,tabIndex:a.id===c?0:-1,"aria-current":a.id===c?"page":void 0,onClick:()=>void h(()=>g(a.id)),variant:a.id===c?"secondary":"ghost",className:(0,w.cn)("justify-start",a.id===c?"text-foreground bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]":"text-muted-foreground"),children:[(0,d.jsx)(a.icon,{className:(0,w.cn)("mr-1")}),(0,d.jsx)("span",{className:"truncate text-sm",children:a.label}),a.Badge&&(0,d.jsx)("span",{className:"ml-auto flex items-center",children:(0,d.jsx)(a.Badge,{})})]},a.id))]},a)),(0,d.jsx)("span",{className:ca,children:"community"}),(0,d.jsx)(bT,{}),(0,d.jsxs)("div",{className:"mt-auto flex flex-col gap-2 pt-3",children:[(0,d.jsx)(bk,{}),(0,d.jsx)("div",{className:"px-1",children:(0,d.jsx)(cd,{})})]})]}),(0,d.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,d.jsx)("div",{className:"shrink-0 px-8 pt-10",children:(0,d.jsxs)(bU.SettingColumn,{className:"animate-in space-y-0.5 fade-in slide-in-from-bottom-1 duration-300",children:[(0,d.jsx)("h3",{className:"truncate text-2xl font-semibold",children:j.label}),(0,d.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:j.hint})]},j.id)}),(0,d.jsx)("div",{ref:i,className:"min-h-0 min-w-0 flex-1",children:(0,d.jsx)(j.Component,{})})]})]})]})]})}let cf=(0,ai.createServerReference)("7f012c9a963134dc7aa4a34b1ca1870ca98ded70b5",ai.callServer,void 0,ai.findSourceMapURL,"closeUpdateNoticeAction");var cg=a.i(663364);function ch({hidden:a}){let{data:b}=(0,U.useServerRoute)(t.queryKey.update,{onError:()=>{}}),{to:c,failed:e}=(0,cg.useUpdateStore)(),f=b?.moving&&!b.moving.failed?b.moving.to:null;(0,s.useEffect)(()=>{f&&(0,cg.followUpdate)(f)},[f]);let g=(0,s.useRef)(null),h=b?.current??null;(0,s.useEffect)(()=>{h&&(g.current?g.current!==h&&window.location.reload():g.current=h)},[h]);let[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(null),m=(0,am.useSettingsStore)(a=>a.open);if(a||m)return null;if(c)return(0,d.jsxs)(ci,{children:[(0,d.jsx)("p",{className:"mt-3 text-[15px] leading-tight font-medium",children:(0,d.jsx)(A.ShinyText,{text:`Updating to ${c}…`})}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Thursday restarts in a moment."})]});if(e&&k!==e)return(0,d.jsxs)(ci,{children:[(0,d.jsxs)("p",{className:"mt-3 text-[15px] leading-tight font-medium",children:["Could not update to ",e.to]}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.running?"The one before runs on.":"Thursday is not answering."}),(0,d.jsx)(cj,{primary:"See why",onPrimary:()=>(0,am.openSettings)("thursday"),secondary:"Close",onSecondary:()=>l(e)})]});let n=b?.notice?b.newer:null;return n&&i!==n?(0,d.jsxs)(ci,{children:[(0,d.jsxs)("p",{className:"mt-3 text-[15px] leading-tight font-medium",children:["Thursday ",n," is out"]}),(0,d.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["You run ",b?.current]}),(0,d.jsx)(cj,{primary:b?.byButton?"Update":"How to update",onPrimary:()=>b?.byButton?void(0,cg.moveTo)(n):(0,am.openSettings)("thursday"),secondary:"Not today",onSecondary:()=>{j(n),cf().then(()=>(0,U.revalidate)(t.queryKey.update))}})]}):null}function ci({children:a}){return(0,d.jsx)("div",{className:"inverse",children:(0,d.jsxs)("div",{className:"flex size-60 animate-in flex-col items-center rounded-[28px] bg-background p-5 text-center text-foreground shadow-[0_22px_44px_-20px_rgb(0_0_0/0.22)] duration-300 fade-in slide-in-from-top-1",children:[(0,d.jsx)(O.ThursdayMark,{size:72,className:"mt-1"}),a]})})}function cj({primary:a,onPrimary:b,secondary:c,onSecondary:e}){return(0,d.jsxs)("div",{className:"mt-auto flex w-full gap-1.5",children:[(0,d.jsx)(u.Button,{className:"flex-1 rounded-full",onClick:b,children:a}),(0,d.jsx)(u.Button,{variant:"ghost",className:"rounded-full px-3 text-muted-foreground",onClick:e,children:c})]})}function ck(a){return a.includes("red")?"red":a.includes("waiting")?"waiting":null}function cl(){let a=bA(),b=bB().owed>0?"waiting":null,c=bI(),d=bE();return{bot:a,threads:b,mcp:c,keys:d,models:bH(),phone:bL()}}var cm=a.i(444324);let cn=null,co=0,cp=new Set,cq=()=>{for(let a of cp)a()},cr=()=>{"hidden"===document.visibilityState&&cs.clear()},cs={show:a=>!cn&&"visible"===document.visibilityState&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(cn={moment:a,phase:null,id:++co},document.addEventListener("visibilitychange",cr),cq(),!0),tell(a,b){if(cn&&cn.id===a&&cn.phase!==b){if("done"===b)return cs.clear();cn={...cn,phase:b},cq()}},clear(){cn&&(cn=null,document.removeEventListener("visibilitychange",cr),cq())},current:()=>cn};function ct(){return(0,s.useSyncExternalStore)(a=>(cp.add(a),()=>cp.delete(a)),()=>cn,()=>null)}var cu=a.i(650485),cv=a.i(461512),cw=a.i(359006),cx=a.i(926919),cy=a.i(275086),cz=a.i(172654),cA=a.i(864037),cB=a.i(421042);let cC=(0,ai.createServerReference)("7f3f007427176104f464c9fccecdff82e480365c7b",ai.callServer,void 0,ai.findSourceMapURL,"acceptThreadRelaysAction");var cD=a.i(559553),cE=a.i(576271);let cF=new Set,cG=a=>new Set(cL(a).filter(a=>"question"!==a.kind).map(a=>a.key)),cH={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},cI={question:0,stopped:1,done:2,progress:3};function cJ(a){let b=(0,w.captionText)(a.replace(/!\[[^\]]*\]\([^)]*\)/g," ")).replace(w.MARKDOWN_LINK,"$1").replace(/^• /gm,"").trim();if(b.length<=D.CALL_RELAY.chars)return b;let c=b.slice(0,D.CALL_RELAY.chars),d=Math.max(c.lastIndexOf("\n\n"),c.lastIndexOf(". "),c.lastIndexOf(".\n"),c.lastIndexOf("。")),e=(d>D.CALL_RELAY.chars/3?c.slice(0,d+1):c).trim();return`${e}
|
|
3
|
+
${b.name}`;b.name===f.name||"running"!==d.get(c)||"done"!==e.get(c)||i.some(a=>a.bot.name===b.name&&("ask"===a.kind||"say"===a.kind))||(g.push({bot:b.name,gesture:"done"}),h.push({rank:1,at:b.name,from:b,to:[],sign:"done",text:"finished its part"}))}if(b===a.status)return{moments:h,gestures:g};let k=aT(a.label);return"cancelled"===a.status?(g.push({bot:f.name,gesture:"stop"}),h.push({rank:3,at:f.name,from:f,to:[],sign:"cancelled",text:`stopped \xb7 ${k}`})):"done"===a.status?g.push({bot:f.name,gesture:"done"}):"working"===a.status?i.some(a=>"user"===a.kind)||(g.push({bot:f.name,gesture:"took"}),h.push({rank:1,at:f.name,from:f,to:[],sign:"resumed",text:"picked it back up"})):(0,G.isAppStop)(a.ask)&&!h.some(a=>"question"===a.sign||"stopped"===a.sign)&&(g.push({bot:f.name,gesture:"stop"}),h.push({rank:3,at:f.name,from:f,to:[],sign:"stopped",text:"paused"})),{moments:h,gestures:g}}(g,b.get(g.id),d,c,ae.current);for(let b of(f.push(...h),a))(!e||b.rank>=e.rank)&&(e=b)}e&&X(e),aa(f)},[a,X,aa]),(0,V.useSeenOnDetail)(e?E:null),(0,K.useAppEvent)({showThread:a=>{j(a.threadId),h(!1),f(!0)}}),(0,s.useEffect)(()=>V.roomOpens.subscribe(a=>{j(a),o("now"),h(!1),f(!0)}),[]);let ag=a.filter(a=>"working"===a.status).length,ah=q.filter(G.needsThreadReply).length,ai=(0,s.useMemo)(()=>Z.map(a=>({...a,word:null})),[Z]),aj=()=>{f(!1),h(!1),j(null),o("now"),p.current=0},ak=()=>h(!0),al=(0,s.useRef)(aj);al.current=aj,(0,s.useEffect)(()=>{if(!g)return;let a=setTimeout(()=>al.current(),250);return()=>clearTimeout(a)},[g]);let am=(0,V.useCallWaits)();(0,Q.useEscape)(e&&!g,()=>k?j(null):ak()),(0,s.useEffect)(()=>V.writeLine.subscribe(()=>al.current()),[]);let an=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!k)return;let a=a=>{if(!(0,Q.typed)(a,"@")||!(0,Q.windowKey)(a))return;let b=an.current?.querySelector("textarea:not(:disabled)");b&&(a.preventDefault(),b.focus())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[k]),(0,d.jsxs)("div",{className:(0,w.cn)("pointer-events-none flex min-h-0 items-end justify-end",e?"col-span-3 row-start-1 self-stretch":"col-span-3 row-start-2"),children:[e&&L&&(0,d.jsx)(a4,{thread:L.value,leaving:L.leaving,onBot:a=>m(b=>({...b,[L.value.id]:a===L.value.bot.name?null:a})),onAnswer:()=>(an.current?.querySelector("[data-continue]:not(:disabled)")??an.current?.querySelector("textarea:not(:disabled)"))?.focus(),className:"pointer-events-auto mr-4 min-h-0 min-w-0 flex-1 self-stretch"}),e?(0,d.jsxs)("div",{ref:an,"data-room":!0,className:(0,w.cn)("pointer-events-auto flex max-h-full w-160 max-w-full shrink-0 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",F&&"h-[calc(64vh+11rem)]",g&&"pointer-events-none translate-y-1 opacity-0 transition-[opacity,translate] duration-250 ease-in"),children:[am&&(0,d.jsx)(a7,{onBack:ak}),!E&&i&&C?(0,d.jsx)(at,{onBack:()=>j(null),onClose:ak}):E?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(W.ThreadHeader,{thread:E,onBack:()=>j(null),onClose:ak,titled:!J,children:H&&(0,d.jsx)(a6,{})}),(0,d.jsx)(W.Conversation,{thread:E,tab:l[E.id]??null,onTab:a=>m(b=>({...b,[E.id]:a})),className:"max-h-none min-h-0 flex-1"}),(0,d.jsx)(N.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:l[E.id]??E.bot.name,className:"mx-3 mb-2 shrink-0"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ap,{tab:n,current:r.length,working:r.filter(a=>"working"===a.status).length,onTab:o,onClose:ak}),"history"===n?(0,d.jsx)(as,{pages:v,threads:z,scroll:p,onPick:j}):r.length?(0,d.jsx)(aw,{threads:r,onPick:j}):q.length?(0,d.jsx)(ar,{}):(0,d.jsx)(aq,{bots:c}),(0,d.jsx)(aV,{crew:ai,more:$,bubble:null,playing:_,label:"Fold the room away",onClick:ak,onWrite:V.writeLine.choose,side:Y?(0,d.jsx)(a0,{handoff:Y}):(0,d.jsx)(aW,{busy:ag,pending:ah,grown:!0})})]})]}):(0,d.jsx)(aU,{crew:Z,more:$,bubble:Y,playing:_,resting:!ab,rows:b,count:a.length,busy:ag,pending:ah,onPick:a=>{j(a),h(!1),f(!0)},onOpen:()=>{h(!1),f(!0)}})]})});function a6(){let a=(0,V.useRoomReadAs)();return(0,d.jsx)(L.Segmented,{view:!0,size:"sm","aria-label":"How the thread is shown",value:a,onChange:V.roomReadAs.set,options:[{value:"office",label:"Office",title:"The thread beside its office, where her face stands"},{value:"chat",label:"Chat",title:"The conversation alone, her face kept"}],className:"shrink-0"})}function a7({onBack:a}){return(0,d.jsxs)("button",{type:"button",onClick:a,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,d.jsx)(O.ThursdayMark,{size:22,className:"shrink-0"}),(0,d.jsxs)("span",{className:"min-w-0 flex-1 text-[13px] leading-5",children:[(0,d.jsx)("span",{className:"font-medium",children:"Thursday is still on the line"}),(0,d.jsxs)("span",{className:"text-muted-foreground",children:[" ","— in writing. She is here when this closes."]})]}),(0,d.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,d.jsx)(J,{className:"size-3.5"})]})]})}var a8=a.i(8468),a9=a.i(249049),ba=a.i(478978);let bb={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"}]]};bb.node;let bc=(0,h.default)(bb);var bd=a.i(823319);let be="thursday.install-asked",bf=null,bg=new Set;function bh(){return(0,s.useSyncExternalStore)(a=>(bg.add(a),()=>bg.delete(a)),()=>bf,()=>null)}async function bi(){let a=bf;if(a){for(let a of(bf=null,bg))a();await a.prompt(),await a.userChoice.catch(()=>void 0)}}function bj({hidden:a}){let b=null!==bh(),[c,e]=(0,s.useState)(!0);if((0,s.useEffect)(()=>{try{e(null!==window.localStorage.getItem(be))}catch{}},[]),!b||c||a)return null;let f=()=>{e(!0);try{window.localStorage.setItem(be,"1")}catch{}};return(0,d.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,d.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg bg-muted",children:(0,d.jsx)(bc,{className:"size-4"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1 space-y-2.5",children:[(0,d.jsxs)("p",{className:"text-[13px] leading-snug",children:[(0,d.jsx)("span",{className:"block font-medium",children:"Keep her in her own window"}),(0,d.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,d.jsxs)("div",{className:"flex gap-1.5",children:[(0,d.jsx)(u.Button,{size:"sm",className:"rounded-full px-3.5",onClick:()=>{f(),bi()},children:"Install"}),(0,d.jsx)(u.Button,{size:"sm",variant:"ghost",className:"rounded-full px-3 text-muted-foreground",onClick:f,children:"Not now"})]})]})]})}function bk(){return null===bh()?null:(0,d.jsx)("button",{type:"button",onClick:()=>void bi(),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,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1 text-sm font-medium",children:["Install app",(0,d.jsx)(bd.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,d.jsx)("span",{className:"block text-xs leading-snug text-muted-foreground",children:"Its own window, apart from your tabs"})]})})}let bl={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"}]]};bl.node;let bm=(0,h.default)(bl);var bn=a.i(126766),bo=a.i(62140),bp=a.i(474896);let bq={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"}]]};bq.node;let br=(0,h.default)(bq),bs={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"}]]};bs.node;let bt=(0,h.default)(bs),bu={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"}]]};bu.node;let bv=(0,h.default)(bu),bw={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"}]]};bw.node;let bx=(0,h.default)(bw);var by=a.i(965733),bz=a.i(619477);function bA(){let{data:a}=(0,U.useServerRoute)(t.queryKey.bot);return a&&0===a.length?"waiting":null}function bB(){let{data:a}=(0,U.useServerRoute)(t.queryKey.threads);return{owed:(a??[]).filter(a=>(0,G.needsThreadReply)(a)||(0,G.isUnread)(a)).length}}var bC=a.i(907602);let bD=Object.values(bC.REACH_KEYS).flat();function bE(){let{data:a,isLoading:b}=(0,U.useServerRoute)(t.queryKey.config),c=(0,a9.useVoiceLine)();if(b)return null;let d=b=>(0,ba.isConfigSet)(a,b),e=ba.CONFIG_GROUPS.some(a=>"keys"===a.section&&!(0,ba.groupSatisfied)(a,a.id===ba.VOICE_GROUP_ID?c.countsForCall:d)),f=!!a?.some(a=>a.unreadable&&!bD.includes(a.key));return e||f?"waiting":null}let bF=ba.CONFIG_GROUPS.filter(a=>"models"===a.section).flatMap(a=>a.entries.filter(a=>a.kind).map(a=>a.key)),bG=Object.keys(ba.MEDIA_MODEL_KEYS);function bH(){let{data:a,isLoading:b}=(0,U.useServerRoute)(t.queryKey.config),{data:c}=(0,U.useServerRoute)(t.queryKey.llmModel);if(b||!a||!c)return null;let d=c.find(a=>a.signIn),e=d?.hasKey?{plan:d.plan??null}:null;return!bG.some(a=>(0,F.planMediaOf)(a,e))&&bF.every(b=>!(0,ba.isConfigSet)(a,b))?"waiting":null}function bI(){let{data:a}=(0,U.useServerRoute)(t.queryKey.mcp);return a?.some(a=>a.lastError)?"red":null}var bJ=a.i(107340),bK=a.i(86922);function bL(){let{data:a}=(0,U.useServerRoute)(t.queryKey.reach),{data:b}=(0,U.useServerRoute)(t.queryKey.config),c=Object.values(bC.REACH_KEYS).flat().some(a=>(0,ba.isConfigUnreadable)(b,a));return a?.channels.some(a=>a.refused)||c?"red":null}var bM=a.i(600154),bN=a.i(844561);let bO=bN.FolderOpen;var bP=a.i(730357),bQ=a.i(682823);function bR({d:a,className:b}){return(0,d.jsx)("svg",{viewBox:"-2 -2 28 28","aria-hidden":!0,className:b,children:(0,d.jsx)("path",{d:a,fill:"currentColor"})})}let bS=[{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-agent",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 bT(){return(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:bS.map(a=>(0,d.jsxs)("a",{href:a.href,target:"_blank",rel:"noreferrer",className:(0,w.cn)((0,u.buttonVariants)({variant:"ghost"}),"justify-start text-muted-foreground"),children:[(0,d.jsx)(bR,{d:a.mark,className:"mr-1"}),(0,d.jsx)("span",{className:"truncate text-sm",children:a.label})]},a.href))})}var bU=bz;let bV=(a,b=bU.SettingSkeleton)=>(0,r.default)(a,{loading:()=>(0,d.jsx)(b,{})}),bW=bV(()=>a.A(277297).then(a=>({default:a.MemorySetting}))),bX=bV(()=>a.A(348436).then(a=>({default:a.BotSetting})),bU.SettingPanesSkeleton),bY=bV(()=>a.A(315458).then(a=>({default:a.ThreadSetting}))),bZ=bV(()=>a.A(553433).then(a=>({default:a.RoutineSetting}))),b$=bV(()=>a.A(228887).then(a=>({default:a.ModelsSetting}))),b_=bV(()=>a.A(228887).then(a=>({default:a.KeysSetting}))),b0=bV(()=>a.A(228887).then(a=>({default:a.PhoneSetting}))),b1=bV(()=>a.A(502073).then(a=>({default:a.ThursdaySetting}))),b2=bV(()=>a.A(436788).then(a=>({default:a.ArtifactSetting})),bU.SettingPanesSkeleton),b3=bV(()=>a.A(895186).then(a=>({default:a.WorkspaceSetting})),bU.SettingPanesSkeleton),b4=bV(()=>a.A(479648).then(a=>({default:a.SkillsSetting}))),b5=bV(()=>a.A(930209).then(a=>({default:a.McpSetting}))),b6=bV(()=>a.A(15022).then(a=>({default:a.SignInsSetting})));function b7({tabs:a}){let[b,c]=(0,s.useState)(0),e=a[b].Component;return(0,d.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,d.jsx)("div",{className:"shrink-0 px-8 pt-5",children:(0,d.jsx)(bU.SettingColumn,{children:(0,d.jsx)(L.Segmented,{view:!0,"aria-label":"Screens of this section",options:a.map((a,b)=>({value:String(b),label:a.label})),value:String(b),onChange:a=>c(Number(a))})})}),(0,d.jsx)("div",{className:"min-h-0 flex-1",children:(0,d.jsx)(e,{})})]})}let b8=[{label:"Finished",Component:b2},{label:"All files",Component:b3}],b9=["call","work","app"],ca="px-3 pt-3 pb-1 font-mono text-[10px] text-muted-foreground",cb=[{id:"thursday",label:"Thursday",group:"call",hint:"Captions, models, and how a call starts",icon:O.ThursdayMark,Component:b1},{id:"memory",label:"Memory",group:"call",hint:"What Thursday remembers about you",icon:bK.MemoryMark,Component:bW},{id:"bot",label:"Bots",group:"work",hint:"Who Thursday hands work to",icon:H.BotsMark,Component:bX,Badge:function(){return bA()?(0,d.jsx)(bz.NavBadge,{tone:"waiting"}):null}},{id:"threads",label:"Threads",group:"work",hint:"Work the bots were handed",icon:bo.ListChecks,Component:bY,Badge:function(){return(0,d.jsx)(bz.NavBadge,{tone:"waiting",count:bB().owed})}},{id:"routines",label:"Routines",group:"work",hint:"Work that starts by itself, on a schedule",icon:al.RoutineMark,Component:bZ},{id:"files",label:"Files",group:"work",hint:"What the bots finished, and everything else they wrote",icon:bO,Component:()=>(0,d.jsx)(b7,{tabs:b8})},{id:"skills",label:"Skills",group:"work",hint:"Instructions the bots load on demand",icon:bM.SkillsMark,Component:b4},{id:"mcp",label:"Connectors",group:"work",hint:"Apps the bots can use, from MCP servers",icon:bJ.McpMark,Component:b5,Badge:function(){return bI()?(0,d.jsx)(bz.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:bp.LogIn,Component:b6},{id:"models",label:"Models",group:"app",hint:"What bots think with, and what they draw, film and speak with",icon:bm,Component:b$,Badge:function(){return bH()?(0,d.jsx)(bz.NavBadge,{tone:"waiting"}):null}},{id:"keys",label:"API keys",group:"app",hint:"The accounts the app runs on",icon:bn.KeyRound,Component:b_,Badge:function(){return bE()?(0,d.jsx)(bz.NavBadge,{tone:"waiting"}):null}},{id:"phone",label:"Phone",group:"app",hint:"Write to Thursday from a chat app or by email",icon:bv,Component:b0,Badge:function(){return bL()?(0,d.jsx)(bz.NavBadge,{tone:"red"}):null}}],cc={system:{label:"System",icon:br},light:{label:"Light",icon:bx},dark:{label:"Dark",icon:bt}};function cd(){let a=(0,bP.useTheme)();return(0,d.jsx)(L.Segmented,{"aria-label":"Theme",className:"w-full gap-0.5 *:flex-1 *:py-1.5",options:bQ.THEMES.map(a=>{let{label:b,icon:c}=cc[a];return{value:a,title:b,label:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{className:"size-3.5"}),(0,d.jsx)("span",{className:"sr-only",children:b})]})}}),value:a,onChange:bP.setTheme})}function ce({children:a}){let b=(0,am.useSettingsStore)(a=>a.open),c=(0,am.useSettingsStore)(a=>a.section),e=(0,am.useSettingsStore)(a=>a.show),f=(0,am.useSettingsStore)(a=>a.hide),g=(0,am.useSettingsStore)(a=>a.pick),h=async a=>{let b=am.useSettingsStore.getState().unsaved;(!b?.()||await af.notify.discard())&&a()},i=(0,s.useRef)(null),j=cb.find(a=>a.id===c)??cb[0];return(0,s.useEffect)(()=>{if(!b)return;let a=a=>{if(!a.metaKey&&!a.ctrlKey)return;if("k"===a.key){let b=i.current?.querySelector("[data-setting-filter]");if(!b)return;a.preventDefault(),b.focus(),b.select();return}let b=Number(a.key);Number.isInteger(b)&&b>=1&&b<=cb.length&&(a.preventDefault(),h(()=>g(cb[b-1].id)))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[b,g]),(0,d.jsxs)(by.Dialog,{open:b,onOpenChange:a=>a?e():void h(f),children:[a&&(0,d.jsx)(by.DialogTrigger,{render:a}),(0,d.jsxs)(by.DialogContent,{className:"block h-[min(52rem,calc(100vh-3rem))] overflow-hidden p-0 sm:max-w-[min(80rem,calc(100vw-3rem))]",children:[(0,d.jsx)(by.DialogTitle,{className:"sr-only",children:"Settings"}),(0,d.jsxs)("div",{className:"flex h-full min-h-0",children:[(0,d.jsxs)("nav",{"aria-label":"Settings sections",onKeyDown:a=>{let b,d="ArrowDown"===a.key?1:"ArrowUp"===a.key?-1:0;if(!d)return;a.preventDefault();let e=(b=(cb.findIndex(a=>a.id===c)+d+cb.length)%cb.length,cb[b].id);h(()=>g(e)),a.currentTarget.querySelector(`[data-section="${e}"]`)?.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:[b9.map(a=>(0,d.jsxs)(s.Fragment,{children:[(0,d.jsx)("span",{className:ca,children:a}),cb.filter(b=>b.group===a).map(a=>(0,d.jsxs)(u.Button,{"data-section":a.id,tabIndex:a.id===c?0:-1,"aria-current":a.id===c?"page":void 0,onClick:()=>void h(()=>g(a.id)),variant:a.id===c?"secondary":"ghost",className:(0,w.cn)("justify-start",a.id===c?"text-foreground bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]":"text-muted-foreground"),children:[(0,d.jsx)(a.icon,{className:(0,w.cn)("mr-1")}),(0,d.jsx)("span",{className:"truncate text-sm",children:a.label}),a.Badge&&(0,d.jsx)("span",{className:"ml-auto flex items-center",children:(0,d.jsx)(a.Badge,{})})]},a.id))]},a)),(0,d.jsx)("span",{className:ca,children:"community"}),(0,d.jsx)(bT,{}),(0,d.jsxs)("div",{className:"mt-auto flex flex-col gap-2 pt-3",children:[(0,d.jsx)(bk,{}),(0,d.jsx)("div",{className:"px-1",children:(0,d.jsx)(cd,{})})]})]}),(0,d.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,d.jsx)("div",{className:"shrink-0 px-8 pt-10",children:(0,d.jsxs)(bU.SettingColumn,{className:"animate-in space-y-0.5 fade-in slide-in-from-bottom-1 duration-300",children:[(0,d.jsx)("h3",{className:"truncate text-2xl font-semibold",children:j.label}),(0,d.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:j.hint})]},j.id)}),(0,d.jsx)("div",{ref:i,className:"min-h-0 min-w-0 flex-1",children:(0,d.jsx)(j.Component,{})})]})]})]})]})}let cf=(0,ai.createServerReference)("7ff43781f1d3ba545961dbbb3841c0dd929a1ee100",ai.callServer,void 0,ai.findSourceMapURL,"closeUpdateNoticeAction");var cg=a.i(663364);function ch({hidden:a}){let{data:b}=(0,U.useServerRoute)(t.queryKey.update,{onError:()=>{}}),{to:c,failed:e}=(0,cg.useUpdateStore)(),f=b?.moving&&!b.moving.failed?b.moving.to:null;(0,s.useEffect)(()=>{f&&(0,cg.followUpdate)(f)},[f]);let g=(0,s.useRef)(null),h=b?.current??null;(0,s.useEffect)(()=>{h&&(g.current?g.current!==h&&window.location.reload():g.current=h)},[h]);let[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(null),m=(0,am.useSettingsStore)(a=>a.open);if(a||m)return null;if(c)return(0,d.jsxs)(ci,{children:[(0,d.jsx)("p",{className:"mt-3 text-[15px] leading-tight font-medium",children:(0,d.jsx)(A.ShinyText,{text:`Updating to ${c}…`})}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Thursday restarts in a moment."})]});if(e&&k!==e)return(0,d.jsxs)(ci,{children:[(0,d.jsxs)("p",{className:"mt-3 text-[15px] leading-tight font-medium",children:["Could not update to ",e.to]}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.running?"The one before runs on.":"Thursday is not answering."}),(0,d.jsx)(cj,{primary:"See why",onPrimary:()=>(0,am.openSettings)("thursday"),secondary:"Close",onSecondary:()=>l(e)})]});let n=b?.notice?b.newer:null;return n&&i!==n?(0,d.jsxs)(ci,{children:[(0,d.jsxs)("p",{className:"mt-3 text-[15px] leading-tight font-medium",children:["Thursday ",n," is out"]}),(0,d.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["You run ",b?.current]}),(0,d.jsx)(cj,{primary:b?.byButton?"Update":"How to update",onPrimary:()=>b?.byButton?void(0,cg.moveTo)(n):(0,am.openSettings)("thursday"),secondary:"Not today",onSecondary:()=>{j(n),cf().then(()=>(0,U.revalidate)(t.queryKey.update))}})]}):null}function ci({children:a}){return(0,d.jsx)("div",{className:"inverse",children:(0,d.jsxs)("div",{className:"flex size-60 animate-in flex-col items-center rounded-[28px] bg-background p-5 text-center text-foreground shadow-[0_22px_44px_-20px_rgb(0_0_0/0.22)] duration-300 fade-in slide-in-from-top-1",children:[(0,d.jsx)(O.ThursdayMark,{size:72,className:"mt-1"}),a]})})}function cj({primary:a,onPrimary:b,secondary:c,onSecondary:e}){return(0,d.jsxs)("div",{className:"mt-auto flex w-full gap-1.5",children:[(0,d.jsx)(u.Button,{className:"flex-1 rounded-full",onClick:b,children:a}),(0,d.jsx)(u.Button,{variant:"ghost",className:"rounded-full px-3 text-muted-foreground",onClick:e,children:c})]})}function ck(a){return a.includes("red")?"red":a.includes("waiting")?"waiting":null}function cl(){let a=bA(),b=bB().owed>0?"waiting":null,c=bI(),d=bE();return{bot:a,threads:b,mcp:c,keys:d,models:bH(),phone:bL()}}var cm=a.i(444324);let cn=null,co=0,cp=new Set,cq=()=>{for(let a of cp)a()},cr=()=>{"hidden"===document.visibilityState&&cs.clear()},cs={show:a=>!cn&&"visible"===document.visibilityState&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(cn={moment:a,phase:null,id:++co},document.addEventListener("visibilitychange",cr),cq(),!0),tell(a,b){if(cn&&cn.id===a&&cn.phase!==b){if("done"===b)return cs.clear();cn={...cn,phase:b},cq()}},clear(){cn&&(cn=null,document.removeEventListener("visibilitychange",cr),cq())},current:()=>cn};function ct(){return(0,s.useSyncExternalStore)(a=>(cp.add(a),()=>cp.delete(a)),()=>cn,()=>null)}var cu=a.i(650485),cv=a.i(461512),cw=a.i(359006),cx=a.i(926919),cy=a.i(275086),cz=a.i(172654),cA=a.i(864037),cB=a.i(421042);let cC=(0,ai.createServerReference)("7f3d0e628e9ae79c3152899b035d5f3a2d8a3256d8",ai.callServer,void 0,ai.findSourceMapURL,"acceptThreadRelaysAction");var cD=a.i(559553),cE=a.i(576271);let cF=new Set,cG=a=>new Set(cL(a).filter(a=>"question"!==a.kind).map(a=>a.key)),cH={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},cI={question:0,stopped:1,done:2,progress:3};function cJ(a){let b=(0,w.captionText)(a.replace(/!\[[^\]]*\]\([^)]*\)/g," ")).replace(w.MARKDOWN_LINK,"$1").replace(/^• /gm,"").trim();if(b.length<=D.CALL_RELAY.chars)return b;let c=b.slice(0,D.CALL_RELAY.chars),d=Math.max(c.lastIndexOf("\n\n"),c.lastIndexOf(". "),c.lastIndexOf(".\n"),c.lastIndexOf("。")),e=(d>D.CALL_RELAY.chars/3?c.slice(0,d+1):c).trim();return`${e}
|
|
4
4
|
[The message goes on; the rest is in its thread on screen.]`}let cK=a=>`question:${a}`;function cL(a){let b=[];for(let c of a){let{relays:a,questions:d}=c.room,e=(0,S.toDate)(c.updatedAt).getTime(),f=(a,b)=>`[${a} → Thursday, thread "${c.label}" (${c.id}), ${b}.]`,g=(a,b)=>({kind:"relay",name:c.label,line:b,done:!0,bot:a});for(let e of d){let d=e.options?.length?` Options: ${e.options.join(" / ")}.`:"";b.push({rank:cI.question,key:cK(e.id),kind:"question",line:`${f(e.bot,"question")}
|
|
5
5
|
${cJ(e.text)}${d}`,relayIds:a.filter(a=>a.messageId===e.id).map(a=>a.id),threadId:c.id,text:e.text,show:g(e.bot,`${e.bot} asks`)})}let h=a.filter(a=>!d.some(b=>b.id===a.messageId)),i="done"===c.status,j="waiting"===c.status&&(0,G.isAppStop)(c.ask);if(i||j){if(c.seen)continue;let a=j?"stopped":"done",d=(j?c.ask?.question:null)??c.outcome??"",i="stopped"===a?`It stopped before finishing. Where it got to: ${cJ(d)}`:`Done. Its answer: ${cJ(d)}`;b.push({rank:cI[a],key:`${a}:${c.id}@${e}`,kind:"ending",line:`${f(c.bot,a)}
|
|
6
6
|
${i}`,relayIds:h.map(a=>a.id),threadId:c.id,text:d,show:g(c.bot,"stopped"===a?`${c.bot} stopped`:`${c.bot} finished`)});continue}for(let a of h)b.push({rank:cI.progress,key:`progress:${a.id}`,kind:"progress",line:`${f(a.bot,a.kind)}
|
|
7
|
-
${cJ(a.text)}`,relayIds:[a.id],threadId:c.id,text:a.text,show:g(a.bot,`${a.bot} ${cH[a.kind]}`)})}return b.sort((a,b)=>a.rank-b.rank)}function cM(a){return"answered"===a.kind?`The user sent a message on screen to ${a.recipient??"the coordinator"} in thread "${a.label}" (${a.id})${a.replyTo?`, replying to ${a.replyTo}`:""}: ${a.answer}. It has reached that participant.`:"stopped"===a.kind?`The user stopped thread "${a.label}" on screen. It is no longer running.`:"showed"===a.kind?`The user drew a picture on screen and showed it to you, kept on this computer at ${a.path}.`:`The user put ${1===a.paths.length?"a file":`${a.paths.length} files`} down on screen, kept on this computer at ${a.paths.join(", ")}.`}let cN=(0,ai.createServerReference)("7f9935113c3df431c544173411d1ec0e9e70040fac",ai.callServer,void 0,ai.findSourceMapURL,"endCallAction"),cO=(0,ai.createServerReference)("7fec51d7495459d5ad52bacebc88ee4fe729fd6008",ai.callServer,void 0,ai.findSourceMapURL,"openTextCallAction"),cP=(0,ai.createServerReference)("7fefcbe05c398788d9c2b0591b66225afb4c7a1a73",ai.callServer,void 0,ai.findSourceMapURL,"tellTextCallAction");var cQ=a.i(27418);let cR=null,cS=null;async function cT(a,b){let c=await fetch(a,{signal:b});if(!c.ok)throw Error(`${new URL(a).host} answered ${c.status}`);return c.json()}async function cU(a,b){let c=await cT(`https://api.bigdatacloud.net/data/reverse-geocode-client?${new URLSearchParams({latitude:String(a.latitude),longitude:String(a.longitude),localityLanguage:"en"})}`,b);return{name:[c.city||c.locality,c.countryName].filter(Boolean).join(", ")||null,country:/^[A-Z]{2}$/.test(c.countryCode??"")?c.countryCode:null}}async function cV(a,b){let c=a=>(Math.round(100*a)/100).toString(),d=await cT(`https://api.open-meteo.com/v1/forecast?${new URLSearchParams({latitude:c(a.latitude),longitude:c(a.longitude),current:"temperature_2m,weather_code,wind_gusts_10m",daily:"temperature_2m_max,temperature_2m_min,sunrise,sunset",timezone:"auto",forecast_days:"1"})}`,b),e=d.current.wind_gusts_10m;return{code:d.current.weather_code,temperature:d.current.temperature_2m,low:d.daily.temperature_2m_min[0],high:d.daily.temperature_2m_max[0],sunrise:d.daily.sunrise[0].slice(11,16),sunset:d.daily.sunset[0].slice(11,16),gusts:"number"==typeof e?e:null}}async function cW(){let a=await new Promise((a,b)=>navigator.geolocation.getCurrentPosition(({coords:b})=>a(b),b,{maximumAge:D.HERE.keptMs})),b=new AbortController,c=setTimeout(()=>b.abort(),D.HERE.lookMs),[d,e]=await Promise.allSettled([cU(a,b.signal),cV(a,b.signal)]);for(let[a,b]of(clearTimeout(c),[["place",d],["weather",e]]))"rejected"===b.status&&console.warn(`No ${a} for the call: ${(0,w.errorToString)(b.reason)}`);let f="fulfilled"===d.status?d.value:null,g={place:f?.name??null,weather:"fulfilled"===e.status?e.value:null};return g.place||g.weather?{where:g,position:{lat:a.latitude,lon:a.longitude},country:f?.country??null}:null}function cX(){if(cS&&Date.now()-cS.asked<D.HERE.keptMs)return cS.done;let a=cW().then(a=>{a&&(cR={found:a,at:Date.now()})},a=>{a?.code===1?cR=null:console.warn(`No position for the call: ${(0,w.errorToString)(a)}`)}).then(()=>{cS?.done===a&&(cS=null)});return cS={done:a,asked:Date.now()},a}function cY(){return cR&&Date.now()-cR.at<D.HERE.keptMs?cR.found:(navigator.geolocation&&cX(),cR?.found.where.place)?{...cR.found,where:{place:cR.found.where.place,weather:null}}:null}async function cZ(){let a;if((!cR||Date.now()-cR.at>=D.HERE.keptMs-D.HERE.lookMs)&&navigator.geolocation&&navigator.permissions){try{a="granted"===(await navigator.permissions.query({name:"geolocation"})).state}catch{return}a&&await cX()}}let c$=new cz.DefaultChatTransport({api:t.queryKey.textCall}),c_=()=>cw.useThursdayStore.getState().textModel,c0=a=>({type:`data-${cv.TEXT_CALL_NOTE}`,id:a.id,data:a});async function c1(a,b,c,d){try{let e=await fetch(t.queryKey.toolCall,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolCallId:b.id,callId:a,...c,name:b.name,input:b.arguments?JSON.parse(b.arguments):{}}),signal:d}),{output:f}=(0,cE.unwrapResult)(await e.json());return"string"==typeof f?f:JSON.stringify(f??null)}catch(a){return`Error: ${(0,w.errorToString)(a)}`}}var c2=a.i(645323);let c3={"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"},c4=a=>a.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(Boolean),c5=(a,b,c)=>Math.abs(a.length-b.length)<=c&&function(a,b){let c=Array.from({length:a.length+1},(a,b)=>b),d=Array(a.length+1).fill(0);for(let e=1;e<=b.length;e++){d[0]=e;for(let f=1;f<=a.length;f++){let g=c[f-1]+ +(b[e-1]!==a[f-1]);d[f]=Math.min(g,c[f]+1,d[f-1]+1)}[c,d]=[d,c]}return c[a.length]}(a,b)<=c,c6={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 c7(a){if(null===a||"object"!=typeof a)return!1;let b=Object.getPrototypeOf(a);return(null===b||b===Object.prototype||null===Object.getPrototypeOf(b))&&!(Symbol.iterator in a)&&(!(Symbol.toStringTag in a)||"[object Module]"===Object.prototype.toString.call(a))}let c8=!1,c9=[];class da{options;_lastLog;_mockFn;constructor(a={}){const b=a.types||c6;for(const c in this.options=((...a)=>a.reduce((a,b)=>(function a(b,c,d=".",e){if(!c7(c))return a(b,{},d,e);let f=Object.assign({},c);for(let c in b){if("__proto__"===c||"constructor"===c)continue;let g=b[c];null!=g&&(e&&e(f,c,g,d)||(Array.isArray(g)&&Array.isArray(f[c])?f[c]=[...g,...f[c]]:c7(g)&&c7(f[c])?f[c]=a(g,f[c],(d?`${d}.`:"")+c.toString(),e):f[c]=g))}return f})(a,b,"",void 0),{}))({...a,defaults:{...a.defaults},level:db(a.level,b),reporters:[...a.reporters||[]]},{types:c6,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}}),b){const a={type:c,...this.options.defaults,...b[c]};this[c]=this._wrapLogFn(a),this[c].raw=this._wrapLogFn(a,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(a){this.options.level=db(a,this.options.types,this.options.level)}prompt(a,b){if(!this.options.prompt)throw Error("prompt is not supported!");return this.options.prompt(a,b)}create(a){let b=new da({...this.options,...a});return this._mockFn&&b.mockTypes(this._mockFn),b}withDefaults(a){return this.create({...this.options,defaults:{...this.options.defaults,...a}})}withTag(a){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+a:a})}addReporter(a){return this.options.reporters.push(a),this}removeReporter(a){if(a){let b=this.options.reporters.indexOf(a);if(-1!==b)return this.options.reporters.splice(b,1)}else this.options.reporters.splice(0);return this}setReporters(a){return this.options.reporters=Array.isArray(a)?a:[a],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let a in this.options.types)console["__"+a]||(console["__"+a]=console[a]),console[a]=this[a].raw}restoreConsole(){for(let a in this.options.types)console["__"+a]&&(console[a]=console["__"+a],delete console["__"+a])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(a,b){a&&(a.__write||(a.__write=a.write),a.write=a=>{this[b].raw(String(a).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(a){a&&a.__write&&(a.write=a.__write,delete a.__write)}pauseLogs(){c8=!0}resumeLogs(){for(let a of(c8=!1,c9.splice(0)))a[0]._logFn(a[1],a[2])}mockTypes(a){let b=a||this.options.mockFn;if(this._mockFn=b,"function"==typeof b)for(let a in this.options.types)this[a]=b(a,this.options.types[a])||this[a],this[a].raw=this[a]}_wrapLogFn(a,b){return(...c)=>c8?void c9.push([this,a,c,b]):this._logFn(a,c,b)}_logFn(a,b,c){var d,e;if((a.level||0)>this.level)return!1;let f={date:new Date,args:[],...a,level:db(a.level,this.options.types)};c||1!==b.length||+(e=d=b[0],"[object Object]"!==Object.prototype.toString.call(e)||!d.message&&!d.args||!!d.stack)?f.args=[...b]:Object.assign(f,b[0]),f.message&&(f.args.unshift(f.message),delete f.message),f.additional&&(Array.isArray(f.additional)||(f.additional=f.additional.split("\n")),f.args.push("\n"+f.additional.join("\n")),delete f.additional),f.type="string"==typeof f.type?f.type.toLowerCase():"log",f.tag="string"==typeof f.tag?f.tag:"";let g=(a=!1)=>{let b=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&b>0){let a=[...this._lastLog.object.args];b>1&&a.push(`(repeated ${b} times)`),this._log({...this._lastLog.object,args:a}),this._lastLog.count=1}a&&(this._lastLog.object=f,this._log(f))};clearTimeout(this._lastLog.timeout);let h=this._lastLog.time&&f.date?f.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=f.date,h<this.options.throttle)try{let a=JSON.stringify([f.type,f.tag,f.args]),b=this._lastLog.serialized===a;if(this._lastLog.serialized=a,b&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(g,this.options.throttle);return}}catch{}g(!0)}_log(a){for(let b of this.options.reporters)b.log(a,{options:this.options})}}function db(a,b={},c=3){return void 0===a?c:"number"==typeof a?a:b[a]&&void 0!==b[a].level?b[a].level:c}da.prototype.add=da.prototype.addReporter,da.prototype.remove=da.prototype.removeReporter,da.prototype.clear=da.prototype.removeReporter,da.prototype.withScope=da.prototype.withTag,da.prototype.mock=da.prototype.mockTypes,da.prototype.pause=da.prototype.pauseLogs,da.prototype.resume=da.prototype.resumeLogs;var dc=a.i(812057),dd=a.i(750227);function de(a,b){let c=process.cwd()+dd.sep;return a.split("\n").splice(b.split("\n").length).map(a=>a.trim().replace("file://","").replace(c,""))}let df=a=>a?`[${a}]`:"";class dg{formatStack(a,b,c){let d=" ".repeat((c?.errorLevel||0)+1);return d+de(a,b).join(`
|
|
7
|
+
${cJ(a.text)}`,relayIds:[a.id],threadId:c.id,text:a.text,show:g(a.bot,`${a.bot} ${cH[a.kind]}`)})}return b.sort((a,b)=>a.rank-b.rank)}function cM(a){return"answered"===a.kind?`The user sent a message on screen to ${a.recipient??"the coordinator"} in thread "${a.label}" (${a.id})${a.replyTo?`, replying to ${a.replyTo}`:""}: ${a.answer}. It has reached that participant.`:"stopped"===a.kind?`The user stopped thread "${a.label}" on screen. It is no longer running.`:"showed"===a.kind?`The user drew a picture on screen and showed it to you, kept on this computer at ${a.path}.`:`The user put ${1===a.paths.length?"a file":`${a.paths.length} files`} down on screen, kept on this computer at ${a.paths.join(", ")}.`}let cN=(0,ai.createServerReference)("7f0c31d206f3159feab1ef89f4b82fdd7c742a87ce",ai.callServer,void 0,ai.findSourceMapURL,"endCallAction"),cO=(0,ai.createServerReference)("7fce3d7635ae0c076e34a12149989992a015562496",ai.callServer,void 0,ai.findSourceMapURL,"openTextCallAction"),cP=(0,ai.createServerReference)("7f8b308a9a7bd147caa8f224bec7c807cc53e2f014",ai.callServer,void 0,ai.findSourceMapURL,"tellTextCallAction");var cQ=a.i(27418);let cR=null,cS=null;async function cT(a,b){let c=await fetch(a,{signal:b});if(!c.ok)throw Error(`${new URL(a).host} answered ${c.status}`);return c.json()}async function cU(a,b){let c=await cT(`https://api.bigdatacloud.net/data/reverse-geocode-client?${new URLSearchParams({latitude:String(a.latitude),longitude:String(a.longitude),localityLanguage:"en"})}`,b);return{name:[c.city||c.locality,c.countryName].filter(Boolean).join(", ")||null,country:/^[A-Z]{2}$/.test(c.countryCode??"")?c.countryCode:null}}async function cV(a,b){let c=a=>(Math.round(100*a)/100).toString(),d=await cT(`https://api.open-meteo.com/v1/forecast?${new URLSearchParams({latitude:c(a.latitude),longitude:c(a.longitude),current:"temperature_2m,weather_code,wind_gusts_10m",daily:"temperature_2m_max,temperature_2m_min,sunrise,sunset",timezone:"auto",forecast_days:"1"})}`,b),e=d.current.wind_gusts_10m;return{code:d.current.weather_code,temperature:d.current.temperature_2m,low:d.daily.temperature_2m_min[0],high:d.daily.temperature_2m_max[0],sunrise:d.daily.sunrise[0].slice(11,16),sunset:d.daily.sunset[0].slice(11,16),gusts:"number"==typeof e?e:null}}async function cW(){let a=await new Promise((a,b)=>navigator.geolocation.getCurrentPosition(({coords:b})=>a(b),b,{maximumAge:D.HERE.keptMs})),b=new AbortController,c=setTimeout(()=>b.abort(),D.HERE.lookMs),[d,e]=await Promise.allSettled([cU(a,b.signal),cV(a,b.signal)]);for(let[a,b]of(clearTimeout(c),[["place",d],["weather",e]]))"rejected"===b.status&&console.warn(`No ${a} for the call: ${(0,w.errorToString)(b.reason)}`);let f="fulfilled"===d.status?d.value:null,g={place:f?.name??null,weather:"fulfilled"===e.status?e.value:null};return g.place||g.weather?{where:g,position:{lat:a.latitude,lon:a.longitude},country:f?.country??null}:null}function cX(){if(cS&&Date.now()-cS.asked<D.HERE.keptMs)return cS.done;let a=cW().then(a=>{a&&(cR={found:a,at:Date.now()})},a=>{a?.code===1?cR=null:console.warn(`No position for the call: ${(0,w.errorToString)(a)}`)}).then(()=>{cS?.done===a&&(cS=null)});return cS={done:a,asked:Date.now()},a}function cY(){return cR&&Date.now()-cR.at<D.HERE.keptMs?cR.found:(navigator.geolocation&&cX(),cR?.found.where.place)?{...cR.found,where:{place:cR.found.where.place,weather:null}}:null}async function cZ(){let a;if((!cR||Date.now()-cR.at>=D.HERE.keptMs-D.HERE.lookMs)&&navigator.geolocation&&navigator.permissions){try{a="granted"===(await navigator.permissions.query({name:"geolocation"})).state}catch{return}a&&await cX()}}let c$=new cz.DefaultChatTransport({api:t.queryKey.textCall}),c_=()=>cw.useThursdayStore.getState().textModel,c0=a=>({type:`data-${cv.TEXT_CALL_NOTE}`,id:a.id,data:a});async function c1(a,b,c,d){try{let e=await fetch(t.queryKey.toolCall,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolCallId:b.id,callId:a,...c,name:b.name,input:b.arguments?JSON.parse(b.arguments):{}}),signal:d}),{output:f}=(0,cE.unwrapResult)(await e.json());return"string"==typeof f?f:JSON.stringify(f??null)}catch(a){return`Error: ${(0,w.errorToString)(a)}`}}var c2=a.i(645323);let c3={"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"},c4=a=>a.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(Boolean),c5=(a,b,c)=>Math.abs(a.length-b.length)<=c&&function(a,b){let c=Array.from({length:a.length+1},(a,b)=>b),d=Array(a.length+1).fill(0);for(let e=1;e<=b.length;e++){d[0]=e;for(let f=1;f<=a.length;f++){let g=c[f-1]+ +(b[e-1]!==a[f-1]);d[f]=Math.min(g,c[f]+1,d[f-1]+1)}[c,d]=[d,c]}return c[a.length]}(a,b)<=c,c6={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 c7(a){if(null===a||"object"!=typeof a)return!1;let b=Object.getPrototypeOf(a);return(null===b||b===Object.prototype||null===Object.getPrototypeOf(b))&&!(Symbol.iterator in a)&&(!(Symbol.toStringTag in a)||"[object Module]"===Object.prototype.toString.call(a))}let c8=!1,c9=[];class da{options;_lastLog;_mockFn;constructor(a={}){const b=a.types||c6;for(const c in this.options=((...a)=>a.reduce((a,b)=>(function a(b,c,d=".",e){if(!c7(c))return a(b,{},d,e);let f=Object.assign({},c);for(let c in b){if("__proto__"===c||"constructor"===c)continue;let g=b[c];null!=g&&(e&&e(f,c,g,d)||(Array.isArray(g)&&Array.isArray(f[c])?f[c]=[...g,...f[c]]:c7(g)&&c7(f[c])?f[c]=a(g,f[c],(d?`${d}.`:"")+c.toString(),e):f[c]=g))}return f})(a,b,"",void 0),{}))({...a,defaults:{...a.defaults},level:db(a.level,b),reporters:[...a.reporters||[]]},{types:c6,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}}),b){const a={type:c,...this.options.defaults,...b[c]};this[c]=this._wrapLogFn(a),this[c].raw=this._wrapLogFn(a,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(a){this.options.level=db(a,this.options.types,this.options.level)}prompt(a,b){if(!this.options.prompt)throw Error("prompt is not supported!");return this.options.prompt(a,b)}create(a){let b=new da({...this.options,...a});return this._mockFn&&b.mockTypes(this._mockFn),b}withDefaults(a){return this.create({...this.options,defaults:{...this.options.defaults,...a}})}withTag(a){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+a:a})}addReporter(a){return this.options.reporters.push(a),this}removeReporter(a){if(a){let b=this.options.reporters.indexOf(a);if(-1!==b)return this.options.reporters.splice(b,1)}else this.options.reporters.splice(0);return this}setReporters(a){return this.options.reporters=Array.isArray(a)?a:[a],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let a in this.options.types)console["__"+a]||(console["__"+a]=console[a]),console[a]=this[a].raw}restoreConsole(){for(let a in this.options.types)console["__"+a]&&(console[a]=console["__"+a],delete console["__"+a])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(a,b){a&&(a.__write||(a.__write=a.write),a.write=a=>{this[b].raw(String(a).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(a){a&&a.__write&&(a.write=a.__write,delete a.__write)}pauseLogs(){c8=!0}resumeLogs(){for(let a of(c8=!1,c9.splice(0)))a[0]._logFn(a[1],a[2])}mockTypes(a){let b=a||this.options.mockFn;if(this._mockFn=b,"function"==typeof b)for(let a in this.options.types)this[a]=b(a,this.options.types[a])||this[a],this[a].raw=this[a]}_wrapLogFn(a,b){return(...c)=>c8?void c9.push([this,a,c,b]):this._logFn(a,c,b)}_logFn(a,b,c){var d,e;if((a.level||0)>this.level)return!1;let f={date:new Date,args:[],...a,level:db(a.level,this.options.types)};c||1!==b.length||+(e=d=b[0],"[object Object]"!==Object.prototype.toString.call(e)||!d.message&&!d.args||!!d.stack)?f.args=[...b]:Object.assign(f,b[0]),f.message&&(f.args.unshift(f.message),delete f.message),f.additional&&(Array.isArray(f.additional)||(f.additional=f.additional.split("\n")),f.args.push("\n"+f.additional.join("\n")),delete f.additional),f.type="string"==typeof f.type?f.type.toLowerCase():"log",f.tag="string"==typeof f.tag?f.tag:"";let g=(a=!1)=>{let b=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&b>0){let a=[...this._lastLog.object.args];b>1&&a.push(`(repeated ${b} times)`),this._log({...this._lastLog.object,args:a}),this._lastLog.count=1}a&&(this._lastLog.object=f,this._log(f))};clearTimeout(this._lastLog.timeout);let h=this._lastLog.time&&f.date?f.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=f.date,h<this.options.throttle)try{let a=JSON.stringify([f.type,f.tag,f.args]),b=this._lastLog.serialized===a;if(this._lastLog.serialized=a,b&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(g,this.options.throttle);return}}catch{}g(!0)}_log(a){for(let b of this.options.reporters)b.log(a,{options:this.options})}}function db(a,b={},c=3){return void 0===a?c:"number"==typeof a?a:b[a]&&void 0!==b[a].level?b[a].level:c}da.prototype.add=da.prototype.addReporter,da.prototype.remove=da.prototype.removeReporter,da.prototype.clear=da.prototype.removeReporter,da.prototype.withScope=da.prototype.withTag,da.prototype.mock=da.prototype.mockTypes,da.prototype.pause=da.prototype.pauseLogs,da.prototype.resume=da.prototype.resumeLogs;var dc=a.i(812057),dd=a.i(750227);function de(a,b){let c=process.cwd()+dd.sep;return a.split("\n").splice(b.split("\n").length).map(a=>a.trim().replace("file://","").replace(c,""))}let df=a=>a?`[${a}]`:"";class dg{formatStack(a,b,c){let d=" ".repeat((c?.errorLevel||0)+1);return d+de(a,b).join(`
|
|
8
8
|
${d}`)}formatError(a,b){let c=a.message??(0,dc.formatWithOptions)(b,a),d=a.stack?this.formatStack(a.stack,c,b):"",e=b?.errorLevel||0;return(e>0?`${" ".repeat(e)}[cause]: `:"")+c+"\n"+d+(a.cause?"\n\n"+this.formatError(a.cause,{...b,errorLevel:e+1}):"")}formatArgs(a,b){let c=a.map(a=>a&&"string"==typeof a.stack?this.formatError(a,b):a);return(0,dc.formatWithOptions)(b,...c)}formatDate(a,b){return b.date?a.toLocaleTimeString():""}filterAndJoin(a){return a.filter(Boolean).join(" ")}formatLogObj(a,b){let c=this.formatArgs(a.args,b);return"box"===a.type?"\n"+[df(a.tag),a.title&&a.title,...c.split("\n")].filter(Boolean).map(a=>" > "+a).join("\n")+"\n":this.filterAndJoin([df(a.type),df(a.tag),c])}log(a,b){var c,d;return c=this.formatLogObj(a,{columns:b.options.stdout.columns||0,...b.options.formatOptions})+"\n",((d=a.level<2?b.options.stderr||process.stderr:b.options.stdout||process.stdout).__write||d.write).call(d,c)}}var dh=a.i(59639),di=a.i(509656);let{env:dj={},argv:dk=[],platform:dl=""}="u"<typeof process?{}:process,dm="NO_COLOR"in dj||dk.includes("--no-color"),dn="FORCE_COLOR"in dj||dk.includes("--color"),dp="dumb"===dj.TERM,dq=di&&di.isatty&&di.isatty(1)&&dj.TERM&&!dp,dr="CI"in dj&&("GITHUB_ACTIONS"in dj||"GITLAB_CI"in dj||"CIRCLECI"in dj),ds=!dm&&(dn||"win32"===dl&&!dp||dq||dr);function dt(a,b,c){return function(a,b,c=a,d=a.length+1){return e=>{var f;return e||""!==e&&void 0!==e?(f=(""+e).indexOf(b,d),f<0?a+e+b:a+function a(b,c,d,e,f=c.slice(0,Math.max(0,b))+e,g=c.slice(Math.max(0,b+d.length)),h=g.indexOf(d)){return f+(h<0?g:a(h,g,d,e))}(f,e,b,c)+b):""}}(`\x1b[${a}m`,`\x1b[${b}m`,c)}let du={reset:dt(0,0),bold:dt(1,22,"\x1b[22m\x1b[1m"),dim:dt(2,22,"\x1b[22m\x1b[2m"),italic:dt(3,23),underline:dt(4,24),inverse:dt(7,27),hidden:dt(8,28),strikethrough:dt(9,29),black:dt(30,39),red:dt(31,39),green:dt(32,39),yellow:dt(33,39),blue:dt(34,39),magenta:dt(35,39),cyan:dt(36,39),white:dt(37,39),gray:dt(90,39),bgBlack:dt(40,49),bgRed:dt(41,49),bgGreen:dt(42,49),bgYellow:dt(43,49),bgBlue:dt(44,49),bgMagenta:dt(45,49),bgCyan:dt(46,49),bgWhite:dt(47,49),blackBright:dt(90,39),redBright:dt(91,39),greenBright:dt(92,39),yellowBright:dt(93,39),blueBright:dt(94,39),magentaBright:dt(95,39),cyanBright:dt(96,39),whiteBright:dt(97,39),bgBlackBright:dt(100,49),bgRedBright:dt(101,49),bgGreenBright:dt(102,49),bgYellowBright:dt(103,49),bgBlueBright:dt(104,49),bgMagentaBright:dt(105,49),bgCyanBright:dt(106,49),bgWhiteBright:dt(107,49)},dv=function(a=ds){return a?du:Object.fromEntries(Object.keys(du).map(a=>[a,String]))}();function dw(a,b="reset"){return dv[a]||dv[b]}let dx=[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("|");function dy(a){return a.replace(RegExp(dx,"g"),"")}let dz={solid:{tl:"┌",tr:"┐",bl:"└",br:"┘",h:"─",v:"│"},double:{tl:"╔",tr:"╗",bl:"╚",br:"╝",h:"═",v:"║"},doubleSingle:{tl:"╓",tr:"╖",bl:"╙",br:"╜",h:"─",v:"║"},doubleSingleRounded:{tl:"╭",tr:"╮",bl:"╰",br:"╯",h:"─",v:"║"},singleThick:{tl:"┏",tr:"┓",bl:"┗",br:"┛",h:"━",v:"┃"},singleDouble:{tl:"╒",tr:"╕",bl:"╘",br:"╛",h:"═",v:"│"},singleDoubleRounded:{tl:"╭",tr:"╮",bl:"╰",br:"╯",h:"═",v:"│"},rounded:{tl:"╭",tr:"╮",bl:"╰",br:"╯",h:"─",v:"│"}},dA={borderColor:"white",borderStyle:"rounded",valign:"center",padding:2,marginLeft:1,marginTop:1,marginBottom:1};var dB={get url(){return a.F("node_modules/consola/dist/index.mjs")},env:{DEV:!1,PROD:!0,MODE:"production",BASE_URL:"/",SSR:!0}};let dC=Object.create(null),dD=a=>globalThis.process?.env||dB.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(a?dC:globalThis),dE=new Proxy(dC,{get:(a,b)=>dD()[b]??dC[b],has:(a,b)=>b in dD()||b in dC,set:(a,b,c)=>(dD(!0)[b]=c,!0),deleteProperty(a,b){if(!b)return!1;let c=dD(!0);return delete c[b],!0},ownKeys:()=>Object.keys(dD(!0))}),dF="u">typeof process&&process.env&&"production"||"",dG=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]],dH=function(){if(globalThis.process?.env)for(let a of dG){let b=a[1]||a[0];if(globalThis.process?.env[b])return{name:a[0].toLowerCase(),...a[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}();function dI(a){return!!a&&"false"!==a}dH.name;let dJ=globalThis.process?.platform||"",dK=dI(dE.CI)||!1!==dH.ci,dL=dI(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),dM=dI(dE.DEBUG),dN="test"===dF||dI(dE.TEST);dI(dE.MINIMAL);let dO=/^win/i.test(dJ);!dI(dE.NO_COLOR)&&(dI(dE.FORCE_COLOR)||(dL||dO)&&dE.TERM);let dP=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null;dP?.split(".")[0];let dQ=globalThis.process||Object.create(null),dR={versions:{}};new Proxy(dQ,{get:(a,b)=>"env"===b?dE:b in a?a[b]:b in dR?dR[b]:void 0});let dS=globalThis.process?.release?.name==="node",dT=!!globalThis.Bun||!!globalThis.process?.versions?.bun,dU=!!globalThis.Deno,dV=!!globalThis.fastly,dW=[[!!globalThis.Netlify,"netlify"],[!!globalThis.EdgeRuntime,"edge-light"],[globalThis.navigator?.userAgent==="Cloudflare-Workers","workerd"],[dV,"fastly"],[dU,"deno"],[dT,"bun"],[dS,"node"]],dX=function(){let a=dW.find(a=>a[0]);if(a)return{name:a[1]}}();dX?.name;let dY=function({onlyFirst:a=!1}={}){return RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))",a?void 0:"g")}(),dZ=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,d$=globalThis.Intl?.Segmenter?new Intl.Segmenter:{segment:a=>a.split("")},d_=/^\p{Default_Ignorable_Code_Point}$/u,d0={info:"cyan",fail:"red",success:"green",ready:"green",start:"magenta"},d1={0:"red",1:"yellow"},d2=function(){let{env:a}=dh.default,{TERM:b,TERM_PROGRAM:c}=a;return"win32"!==dh.default.platform?"linux"!==b:!!a.WT_SESSION||!!a.TERMINUS_SUBLIME||"{cmd::Cmder}"===a.ConEmuTask||"Terminus-Sublime"===c||"vscode"===c||"xterm-256color"===b||"alacritty"===b||"rxvt-unicode"===b||"rxvt-unicode-256color"===b||"JetBrains-JediTerm"===a.TERMINAL_EMULATOR}(),d3=(a,b)=>d2?a:b,d4={error:d3("✖","×"),fatal:d3("✖","×"),ready:d3("✔","√"),warn:d3("⚠","‼"),info:d3("ℹ","i"),success:d3("✔","√"),debug:d3("⚙","D"),trace:d3("→","→"),fail:d3("✖","×"),start:d3("◐","o"),log:""};function d5(a){return"object"==typeof Intl&&Intl.Segmenter?function(a,b={}){if("string"!=typeof a||0===a.length)return 0;let{ambiguousIsNarrow:c=!0,countAnsiEscapeCodes:d=!1}=b;if(d||(a=function(a){if("string"!=typeof a)throw TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(dY,"")}(a)),0===a.length)return 0;let e=0,f={ambiguousAsWide:!c};for(let{segment:b}of d$.segment(a)){let a=b.codePointAt(0);if(!(a<=31)&&(!(a>=127)||!(a<=159))&&(!(a>=8203)||!(a<=8207))&&65279!==a&&(!(a>=768)||!(a<=879))&&(!(a>=6832)||!(a<=6911))&&(!(a>=7616)||!(a<=7679))&&(!(a>=8400)||!(a<=8447))&&(!(a>=65056)||!(a<=65071))&&(!(a>=55296)||!(a<=57343))&&(!(a>=65024)||!(a<=65039))&&!d_.test(b)){if(dZ().test(b)){e+=2;continue}e+=function(a,{ambiguousAsWide:b=!1}={}){var c;if(!Number.isSafeInteger(a))throw TypeError(`Expected a code point, got \`${typeof a}\`.`);return 12288===a||a>=65281&&a<=65376||a>=65504&&a<=65510||(c=a)>=4352&&c<=4447||8986===c||8987===c||9001===c||9002===c||c>=9193&&c<=9196||9200===c||9203===c||9725===c||9726===c||9748===c||9749===c||c>=9776&&c<=9783||c>=9800&&c<=9811||9855===c||c>=9866&&c<=9871||9875===c||9889===c||9898===c||9899===c||9917===c||9918===c||9924===c||9925===c||9934===c||9940===c||9962===c||9970===c||9971===c||9973===c||9978===c||9981===c||9989===c||9994===c||9995===c||10024===c||10060===c||10062===c||c>=10067&&c<=10069||10071===c||c>=10133&&c<=10135||10160===c||10175===c||11035===c||11036===c||11088===c||11093===c||c>=11904&&c<=11929||c>=11931&&c<=12019||c>=12032&&c<=12245||c>=12272&&c<=12287||c>=12289&&c<=12350||c>=12353&&c<=12438||c>=12441&&c<=12543||c>=12549&&c<=12591||c>=12593&&c<=12686||c>=12688&&c<=12773||c>=12783&&c<=12830||c>=12832&&c<=12871||c>=12880&&c<=42124||c>=42128&&c<=42182||c>=43360&&c<=43388||c>=44032&&c<=55203||c>=63744&&c<=64255||c>=65040&&c<=65049||c>=65072&&c<=65106||c>=65108&&c<=65126||c>=65128&&c<=65131||c>=94176&&c<=94180||94192===c||94193===c||c>=94208&&c<=100343||c>=100352&&c<=101589||c>=101631&&c<=101640||c>=110576&&c<=110579||c>=110581&&c<=110587||110589===c||110590===c||c>=110592&&c<=110882||110898===c||c>=110928&&c<=110930||110933===c||c>=110948&&c<=110951||c>=110960&&c<=111355||c>=119552&&c<=119638||c>=119648&&c<=119670||126980===c||127183===c||127374===c||c>=127377&&c<=127386||c>=127488&&c<=127490||c>=127504&&c<=127547||c>=127552&&c<=127560||127568===c||127569===c||c>=127584&&c<=127589||c>=127744&&c<=127776||c>=127789&&c<=127797||c>=127799&&c<=127868||c>=127870&&c<=127891||c>=127904&&c<=127946||c>=127951&&c<=127955||c>=127968&&c<=127984||127988===c||c>=127992&&c<=128062||128064===c||c>=128066&&c<=128252||c>=128255&&c<=128317||c>=128331&&c<=128334||c>=128336&&c<=128359||128378===c||128405===c||128406===c||128420===c||c>=128507&&c<=128591||c>=128640&&c<=128709||128716===c||c>=128720&&c<=128722||c>=128725&&c<=128727||c>=128732&&c<=128735||128747===c||128748===c||c>=128756&&c<=128764||c>=128992&&c<=129003||129008===c||c>=129292&&c<=129338||c>=129340&&c<=129349||c>=129351&&c<=129535||c>=129648&&c<=129660||c>=129664&&c<=129673||c>=129679&&c<=129734||c>=129742&&c<=129756||c>=129759&&c<=129769||c>=129776&&c<=129784||c>=131072&&c<=196605||c>=196608&&c<=262141||b&&(161===a||164===a||167===a||168===a||170===a||173===a||174===a||a>=176&&a<=180||a>=182&&a<=186||a>=188&&a<=191||198===a||208===a||215===a||216===a||a>=222&&a<=225||230===a||a>=232&&a<=234||236===a||237===a||240===a||242===a||243===a||a>=247&&a<=250||252===a||254===a||257===a||273===a||275===a||283===a||294===a||295===a||299===a||a>=305&&a<=307||312===a||a>=319&&a<=322||324===a||a>=328&&a<=331||333===a||338===a||339===a||358===a||359===a||363===a||462===a||464===a||466===a||468===a||470===a||472===a||474===a||476===a||593===a||609===a||708===a||711===a||a>=713&&a<=715||717===a||720===a||a>=728&&a<=731||733===a||735===a||a>=768&&a<=879||a>=913&&a<=929||a>=931&&a<=937||a>=945&&a<=961||a>=963&&a<=969||1025===a||a>=1040&&a<=1103||1105===a||8208===a||a>=8211&&a<=8214||8216===a||8217===a||8220===a||8221===a||a>=8224&&a<=8226||a>=8228&&a<=8231||8240===a||8242===a||8243===a||8245===a||8251===a||8254===a||8308===a||8319===a||a>=8321&&a<=8324||8364===a||8451===a||8453===a||8457===a||8467===a||8470===a||8481===a||8482===a||8486===a||8491===a||8531===a||8532===a||a>=8539&&a<=8542||a>=8544&&a<=8555||a>=8560&&a<=8569||8585===a||a>=8592&&a<=8601||8632===a||8633===a||8658===a||8660===a||8679===a||8704===a||8706===a||8707===a||8711===a||8712===a||8715===a||8719===a||8721===a||8725===a||8730===a||a>=8733&&a<=8736||8739===a||8741===a||a>=8743&&a<=8748||8750===a||a>=8756&&a<=8759||8764===a||8765===a||8776===a||8780===a||8786===a||8800===a||8801===a||a>=8804&&a<=8807||8810===a||8811===a||8814===a||8815===a||8834===a||8835===a||8838===a||8839===a||8853===a||8857===a||8869===a||8895===a||8978===a||a>=9312&&a<=9449||a>=9451&&a<=9547||a>=9552&&a<=9587||a>=9600&&a<=9615||a>=9618&&a<=9621||9632===a||9633===a||a>=9635&&a<=9641||9650===a||9651===a||9654===a||9655===a||9660===a||9661===a||9664===a||9665===a||a>=9670&&a<=9672||9675===a||a>=9678&&a<=9681||a>=9698&&a<=9701||9711===a||9733===a||9734===a||9737===a||9742===a||9743===a||9756===a||9758===a||9792===a||9794===a||9824===a||9825===a||a>=9827&&a<=9829||a>=9831&&a<=9834||9836===a||9837===a||9839===a||9886===a||9887===a||9919===a||a>=9926&&a<=9933||a>=9935&&a<=9939||a>=9941&&a<=9953||9955===a||9960===a||9961===a||a>=9963&&a<=9969||9972===a||a>=9974&&a<=9977||9979===a||9980===a||9982===a||9983===a||10045===a||a>=10102&&a<=10111||a>=11094&&a<=11097||a>=12872&&a<=12879||a>=57344&&a<=63743||a>=65024&&a<=65039||65533===a||a>=127232&&a<=127242||a>=127248&&a<=127277||a>=127280&&a<=127337||a>=127344&&a<=127373||127375===a||127376===a||a>=127387&&a<=127404||a>=917760&&a<=917999||a>=983040&&a<=1048573||a>=1048576&&a<=1114109)?2:1}(a,f)}}return e}(a):dy(a).length}class d6 extends dg{formatStack(a,b,c){let d=" ".repeat((c?.errorLevel||0)+1);return`
|
|
9
9
|
${d}`+de(a,b).map(a=>" "+a.replace(/^at +/,a=>dv.gray(a)).replace(/\((.+)\)/,(a,b)=>`(${dv.cyan(b)})`)).join(`
|
|
10
|
-
${d}`)}formatType(a,b,c){let d=d0[a.type]||d1[a.level]||"gray";if(b)return(function(a="bgWhite"){return dv[`bg${a[0].toUpperCase()}${a.slice(1)}`]||dv.bgWhite})(d)(dv.black(` ${a.type.toUpperCase()} `));let e="string"==typeof d4[a.type]?d4[a.type]:a.icon||a.type;return e?(function(a="white"){return dv[a]||dv.white})(d)(e):""}formatLogObj(a,b){let c,[d,...e]=this.formatArgs(a.args,b).split("\n");if("box"===a.type)return function(a,b={}){let c={...b,style:{...dA,...b.style}},d=a.split("\n"),e=[],f=dw(c.style.borderColor),g={..."string"==typeof c.style.borderStyle?dz[c.style.borderStyle]||dz.solid:c.style.borderStyle};if(f)for(let a in g)g[a]=f(g[a]);let h=c.style.padding%2==0?c.style.padding:c.style.padding+1,i=d.length+h,j=Math.max(...d.map(a=>dy(a).length),c.title?dy(c.title).length:0)+h,k=j+h,l=c.style.marginLeft>0?" ".repeat(c.style.marginLeft):"";if(c.style.marginTop>0&&e.push("".repeat(c.style.marginTop)),c.title){let a=f?f(c.title):c.title,b=g.h.repeat(Math.floor((j-dy(c.title).length)/2)),d=g.h.repeat(j-dy(c.title).length-dy(b).length+h);e.push(`${l}${g.tl}${b}${a}${d}${g.tr}`)}else e.push(`${l}${g.tl}${g.h.repeat(k)}${g.tr}`);let m="center"===c.style.valign?Math.floor((i-d.length)/2):"top"===c.style.valign?i-d.length-h:i-d.length;for(let a=0;a<i;a++)if(a<m||a>=m+d.length)e.push(`${l}${g.v}${" ".repeat(k)}${g.v}`);else{let b=d[a-m],c=" ".repeat(h),f=" ".repeat(j-dy(b).length);e.push(`${l}${g.v}${c}${b}${f}${g.v}`)}return e.push(`${l}${g.bl}${g.h.repeat(k)}${g.br}`),c.style.marginBottom>0&&e.push("".repeat(c.style.marginBottom)),e.join("\n")}(d7(d+(e.length>0?"\n"+e.join("\n"):"")),{title:a.title?d7(a.title):void 0,style:a.style});let f=this.formatDate(a.date,b),g=f&&dv.gray(f),h=a.badge??a.level<2,i=this.formatType(a,h,b),j=a.tag?dv.gray(a.tag):"",k=this.filterAndJoin([i,d7(d)]),l=this.filterAndJoin(b.columns?[j,g]:[j]),m=(b.columns||0)-d5(k)-d5(l)-2;if(c=(m>0&&(b.columns||0)>=80?k+" ".repeat(m)+l:(l?`${dv.gray(`[${l}]`)} `:"")+k)+d7(e.length>0?"\n"+e.join("\n"):""),"trace"===a.type){let b=Error("Trace: "+a.message);c+=this.formatStack(b.stack||"",b.message)}return h?"\n"+c+"\n":c}}function d7(a){return a.replace(/`([^`]+)`/gm,(a,b)=>dv.cyan(b)).replace(/\s+_([^_]+)_\s+/gm,(a,b)=>` ${dv.underline(b)} `)}function d8(b={}){let c=dM?4:dN?1:3;return process.env.CONSOLA_LEVEL&&(c=Number.parseInt(process.env.CONSOLA_LEVEL)??c),function(a={}){return new da(a)}({level:c,defaults:{level:c},stdout:process.stdout,stderr:process.stderr,prompt:(...b)=>a.A(715837).then(a=>a.prompt(...b)),reporters:b.reporters||[b.fancy??!(dK||dN)?new d6:new dg],...b})}d8();let d9=d8({level:D.IS_DEV?4:3}),ea=(b=D.APP_NAME,d9.withDefaults({message:(c=`${b}: `,dw("blackBright")(c))}));var eb=a.i(249890);let ec={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},ed=new TextEncoder;async function ee(a){let b=eg(a);try{return await b.connect(),b}catch(a){throw await b.close(),a}}let ef=["response.completed","response.failed","response.incomplete","response.cancelled"],eg=({initialize:a,audio:b,on:c})=>{let d,e,f,g,h,i,j,k,l,m=!1,n=!1,o=!1,p=0,q=0,r="",s=[],t=new Set,u=new Set,v=new Set,x=new Map,y=!1,z=new Map,A=new Map,B=[],C=null,E=-1/0,F=null,G=()=>{clearTimeout(l),!F||F.unmute||o||n||(F.unmute=crypto.randomUUID(),Y.send({type:"session.input_audio.unmute",event_id:F.unmute}))},H=()=>{for(let a of(clearTimeout(j),j=void 0,t))c.turn({...a.turn,fragments:[...a.fragments],done:!0});t.clear()},I=()=>{if(!o){for(let a of(o=!0,clearTimeout(h),clearTimeout(k),clearTimeout(l),R&&clearTimeout(R.timer),R=null,clearInterval(i),H(),C=null,B.splice(0)))a.settle(!1);Y.close(),f?.()}},J=a=>{e?.(Error(a)),I(),m&&!n?c.failed(a):n&&c.warn(a)},K=-1/0,L=()=>{if(o||n)return;let a=performance.now(),d=b.levels?.();d&&d.output>.01&&(E=a);let e={speaking:a-E<300,working:[...x.values()].some(a=>!a.terminal)||A.size>0||a-K<5e3,tools:[...A.values()]},f=JSON.stringify(e);(f!==r||e.speaking||e.working)&&(r=f,c.activity(e))},M=()=>{if(!m||o||n||C||!B.length)return;let[a]=B;C=crypto.randomUUID(),Y.send({type:`session.${a.kind}.append`,event_id:C,delegation_id:null,content:a.chunks[0]}),k=setTimeout(()=>{c.warn("Live did not acknowledge the conversation update; delivery is unknown."),N(!1)},D.LIVE_CALL.appendMs)},N=a=>{clearTimeout(k),C=null;let[b]=B;b&&(a&&b.chunks.shift(),a&&b.chunks.length||(B.shift(),b.settle(a)),M())},O=(a,b)=>{if(!a.delta||void 0===a.start_ms||void 0===a.end_ms)return;let d=a.start_ms,e=a.end_ms,f=s.findLast(a=>a.turn.role===b&&d>=a.turn.seq-D.LIVE_CALL.transcriptGapMs&&d<=a.end+D.LIVE_CALL.transcriptGapMs&&("user"===b||!s.some(b=>"user"===b.turn.role&&b.turn.seq>a.turn.seq&&b.turn.seq<d)));f||(f={turn:{id:`live-${q++}`,role:b,text:"",seq:d,done:!1},end:e,fragments:[]},s.push(f)),f.fragments.push({start:d,end:e,text:a.delta}),f.fragments.sort((a,b)=>a.start-b.start),f.end=Math.max(f.end,e),f.turn.text=f.fragments.map(a=>a.text).join(""),c.turn({...f.turn,done:!1}),t.add(f),j??=setTimeout(H,D.LIVE_CALL.transcriptSaveMs)},P=()=>{K=performance.now(),Y.send({type:"response.create",event_id:crypto.randomUUID()})},Q=(a,b=!1)=>{for(let b of(a.settled=!0,a.held.splice(0)))"fact"in b?W(b.fact):X(b);let c=a.rerun;a.rerun=!1,c&&!b&&P()},R=null,S=()=>{let a=R;if((R=null,a)&&(clearTimeout(a.timer),!o&&!n)){for(let b of a.held)"fact"in b?W(b.fact):X(b);a.rerun&&P()}},T=()=>{let a,b=(a=[...x.values()].at(-1))&&!a.settled&&(!a.terminal||a.calls.size>0)?a:void 0;if(b)return b;let c=performance.now()-K;if(!(c>=5e3))return R??={held:[],rerun:!1,timer:setTimeout(S,5e3-c)}},U=async a=>{if(a.terminal&&!a.continued){if(!a.calls.size)return Q(a);a.continued=!0,await Promise.all(a.calls.values()),n||o||(Q(a,!0),P()),L()}},V=async a=>{a.continued=!0,a.calls.size&&await Promise.all(a.calls.values()),n||o||Q(a),L()},W=a=>Y.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"developer",content:[{type:"input_text",text:a}]}}),X=({image:a,path:b})=>{try{Y.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"user",content:[{type:"input_text",text:`${b}, as an image:`},{type:"input_image",image_url:a}]}})}catch(e){let d=(0,w.errorToString)(e);ea.warn("Live picture not sent",{reason:d,bytes:a.length}),W(`The picture of ${b} did not go through, so nothing on it was seen: ${d}`),c.warn(`${b} did not go through to her: ${d}`)}},Y=function({negotiate:a,audio:b,on:c}){let d,e,f,g=null,h=null,i=null,j=!1,k=!1,l=!1,m=null,n=null,o=!1,p=Promise.resolve(),q=!1,r=a=>{for(let b of a?.getTracks()??[])b.stop()},s=a=>{j||l||(l=!0,k?c.dropped(a):e?.(Error(a)))},t=()=>{!k&&q&&(!m||o)&&(k=!0,d?.())};return{async connect(){let k=new RTCPeerConnection;g=k;let l=k.createDataChannel("oai-events");h=l;let p=new Promise((a,b)=>{d=a,e=b});l.onopen=()=>{q=!0,t()},l.onclose=()=>s("The connection to OpenAI Live closed."),l.onerror=()=>s("The connection to OpenAI Live dropped."),k.onconnectionstatechange=()=>{["failed","closed"].includes(k.connectionState)&&s("Could not reach OpenAI Live.")},p.catch(()=>{}),l.onmessage=({data:a})=>{let b;if(!j&&!m&&"string"==typeof a){try{b=JSON.parse(a)}catch{c.dropped("OpenAI Live sent an unreadable event.");return}c.event(b)}},k.ontrack=a=>{if(j)return;let c=a.streams[0]??new MediaStream([a.track]);b.element.srcObject=c,b.listen(c)};let u=await navigator.mediaDevices.getUserMedia({audio:ec});if(j)throw r(u),Error("The call closed before connecting.");for(let a of(i=u,b.hear?.(u),u.getAudioTracks()))k.addTrack(a,u);await k.setLocalDescription(await k.createOffer()),"complete"!==k.iceGatheringState&&await new Promise((a,b)=>{let c=c=>{clearTimeout(e),k.removeEventListener("icegatheringstatechange",d),f=void 0,c?b(c):a()},d=()=>{"complete"===k.iceGatheringState&&c()},e=setTimeout(()=>c(Error("ICE gathering timed out.")),1e4);f=()=>c(Error("The call closed before connecting.")),k.addEventListener("icegatheringstatechange",d),d()});let v=k.localDescription?.sdp;if(!v||j)throw Error("No live SDP offer is available.");let w=await a(v);if(j)throw Error("The call closed before connecting.");if("string"!=typeof w){let a;m=w.relay,await (a=m,new Promise((b,d)=>{let e=new EventSource(a);n=e,e.onopen=()=>b(),e.onmessage=({data:a})=>{let b;if(!j&&"string"==typeof a){try{b=JSON.parse(a)}catch{c.dropped("The call on the plan sent an unreadable event.");return}c.event(b)}},e.onerror=()=>{e.close(),d(Error("Could not follow the call on the plan.")),s("The line to her on the plan dropped.")}})),o=!0}await k.setRemoteDescription({type:"answer",sdp:"string"==typeof w?w:w.sdp}),t(),await p},send(a){if(!j){if(m){let b=m;p=p.then(async()=>{let c=await fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:[a]})}),d=await c.json().catch(()=>null);if(!c.ok||!(0,cE.isResultOk)(d))throw Error((0,cE.isResultError)(d)&&d.message||`${c.status}`)}).catch(a=>{s(`The call on the plan did not take what was sent: ${a instanceof Error?a.message:String(a)}`)});return}h?.readyState==="open"&&h.send(JSON.stringify(a))}},limit:()=>m?D.PLAN_CALL.pictureBytes:g?.sctp?.maxMessageSize??null,relayed:()=>null!==m,hush(){r(i)},close:()=>{j||(j=!0,e?.(Error("The call closed before connecting.")),f?.(),r(i),i=null,n?.close(),h?.close(),g?.close(),b.element.srcObject=null)}}}({audio:b,negotiate:async b=>{let c=await a(b);if(!("string"==typeof c?c:c.sdp))throw Error("OpenAI Live returned no SDP answer.");return c},on:{event:a=>{if(!o){if(a.event_id){if(u.has(a.event_id))return;u.add(a.event_id)}switch(p=Math.max(p,a.offset_ms??0,a.end_ms??0),a.type){case"session.started":m=!0,d?.(),M();break;case"session.closed":c.finalized?.({reason:a.reason??"closed",seconds:a.usage?.seconds??null}),ea.info("Live session closed",{reason:a.reason,seconds:a.usage?.seconds}),e?.(Error("OpenAI Live closed before startup completed.")),I(),n||c.failed(`The Live call ended (${a.reason??"closed"}).`);break;case"session.input_transcript.delta":O(a,"user");break;case"session.output_transcript.delta":G(),O(a,"assistant");break;case"session.input_audio.unmuted":F&&a.client_event_id===F.unmute&&(F=null);break;case"session.instructions.appended":case"session.commentary.appended":case"session.thinking.appended":C&&a.client_event_id===C&&N(!0);break;case"error":{let b=a.error?.message??"OpenAI Live reported an error.";if(!m){J(b);break}if(F?.unmute&&a.error?.client_event_id===F.unmute){J(`She could not hear the microphone again: ${b}`);break}for(let d of(F&&a.error?.client_event_id===F.mute&&(clearTimeout(l),F=null),c.warn(b),C&&a.error?.client_event_id===C&&N(!1),x.values()))d.terminal||d.calls.size||(d.terminal=!0,d.stale=!0,Q(d));L();break}case"session.delegation.created":K=performance.now();break;case"response.event":{let b=a.event;if(!b||n)break;"response.created"===b.type&&(K=-1/0),"response.created"===b.type&&b.response&&a.delegation_id&&z.set(a.delegation_id,b.response.id);let d=b.response?.id??b.response_id??(a.delegation_id?z.get(a.delegation_id):void 0);if(!d)break;let e=x.get(d);if(!e){let a=[],b=!1;for(let c of x.values())c.settled||c.continued||(c.settled=!0,a.push(...c.held.splice(0)),b||=!!c.rerun);R&&(clearTimeout(R.timer),a.push(...R.held),b||=R.rerun,R=null),e={calls:new Map,held:a,terminal:!1,continued:!1,rerun:b},x.set(d,e)}if(e.stale&&!ef.includes(b.type)&&(e.stale=!1,e.terminal=!1,e.settled=!1),"response.reasoning_summary_text.done"===b.type&&c.reasoning?.({id:`${b.item_id}:${b.summary_index??0}`,text:b.text??"",seq:p}),("response.output_item.added"===b.type||"response.output_item.done"===b.type)&&b.item?.type===eb.LIVE_HOSTED_TOOLS.webSearch.item){let a=b.item,e="response.output_item.done"===b.type;e&&ea.debug("Live web search",a),c.search?.({id:a.id,responseId:d,query:(a.action?.query??a.action?.queries?.join(" · "))?.trim()||null,sources:[...new Set((a.action?.sources??[]).flatMap(a=>a.url?[a.url]:[]))].map(a=>({url:a})),done:e,seq:p})}if("response.output_item.done"===b.type&&b.item?.type==="message"){let a=function(a){let b=new Map;for(let c of a??[])for(let a of c.annotations??[])"url_citation"===a.type&&a.url&&!b.has(a.url)&&b.set(a.url,{url:a.url,...a.title?{title:a.title}:{}});return[...b.values()]}(b.item.content);a.length&&c.cited?.(d,a)}if("response.output_item.done"===b.type&&b.item?.type==="function_call"){let a=b.item;if(v.has(a.call_id))break;if(v.add(a.call_id),"incomplete"===a.status){e.terminal=!0,ea.warn("Live backend call cut off; not run",{responseId:d,name:a.name,arguments:a.arguments.slice(0,200)}),e.calls.size&&!y?(y=!0,U(e)):(y=!1,V(e));break}c.turn({id:a.id,role:"tool",tool:a.name,text:a.arguments,seq:p,done:!0}),H(),A.set(a.call_id,a.name);let f=Promise.resolve().then(()=>c.runTool({id:a.call_id,name:a.name,arguments:a.arguments,item:a.id})).catch(a=>`Error: ${(0,w.errorToString)(a)}`).then(b=>{A.delete(a.call_id),o||n||((a,b)=>{let c=b=>Y.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"function_call_output",call_id:a,output:b}});try{c(b)}catch(d){let a=(0,w.errorToString)(d);ea.warn("Live tool output not sent",{reason:a,chars:b.length});try{c(`Error: the result was too large to return (${b.length.toLocaleString("en")} characters: ${a}). Ask for a smaller part of it.`)}catch(a){ea.warn("Live tool output not answered",{reason:(0,w.errorToString)(a)})}}})(a.call_id,b),L()});e.calls.set(a.call_id,f),U(e)}ef.includes(b.type)&&(e.terminal=!0,e.stale=!1,"response.completed"===b.type?(y=!1,ea.debug("Live backend usage",{responseId:d,usage:b.response?.usage}),U(e)):"response.incomplete"===b.type&&e.calls.size&&!y?(y=!0,ea.warn("Live backend response incomplete; continuing once",{responseId:d}),U(e)):(y=!1,V(e),c.warn(b.response?.error?.message??`The Live backend ${b.type.slice(9)}.`)))}}L()}},dropped:J}});return{async connect(){b.element.muted=!1;let a=new Promise((a,b)=>{d=a,e=b});a.catch(()=>{});let c=setTimeout(()=>J("OpenAI Live did not start in time."),D.LIVE_CALL.startupMs);try{if(await Promise.all([Y.connect(),a]),o)throw Error("The Live call closed during startup.");i=setInterval(L,100)}catch(a){throw I(),a}finally{clearTimeout(c),e=void 0}},close:()=>g||(o?Promise.resolve():(n=!0,H(),m)?(g=new Promise(a=>{f=a}),h=setTimeout(()=>{c.warn("Live disconnected without confirming final session usage."),I()},D.LIVE_CALL.closeMs),b.element.muted=!0,Y.hush(),Y.send({type:"session.close",event_id:crypto.randomUUID()}),g):(I(),Promise.resolve())),append(a,b){let c=function(a){let b=[],c="",d=0,e=a=>{let e=ed.encode(a).length;if(d+e>480&&c&&(b.push(c),c="",d=0),e<=480){c+=a,d+=e;return}for(let e of a){let a=ed.encode(e).length;d+a>480&&(b.push(c),c="",d=0),c+=e,d+=a}};for(let b of a.split(/(?<=\s)/))e(b);return c&&b.push(c),b}(b);return o||n||!c.length?Promise.resolve(!1):new Promise(b=>{B.push({kind:a,chunks:c,settle:b}),M()})},holdInput(a){Y.relayed()||!m||o||n||F||a<=0||(F={mute:crypto.randomUUID(),unmute:null},Y.send({type:"session.input_audio.mute",event_id:F.mute}),l=setTimeout(G,a))},pictureRoom:a=>{let b=Y.limit();return(b&&Number.isFinite(b)&&b>2048?b:65536)-1024-ed.encode(a).length-64},brief(a){let b=a.trim();if(o||n||!b)return;let c=T();c?c.held.push({fact:b}):W(b)},picture(a,b){if(o||n)return;let c=T();c?c.held.push({image:a,path:b}):X({image:a,path:b})},run(){if(o||n)return;let a=T();a?a.rerun=!0:P(),L()}}};var eh=a.i(483253);function ei(){let a=[],b=null;return{send(c){b?b(c):a.push(c)},open(c){b=c;let d=a;for(let b of(a=[],d))c(b)},close(){b=null},clear(){let b=a;return a=[],b}}}var ej=a.i(647509),ek=a.i(152659);let el="thursday.here.shown",em=a=>(0,X.format)(a,"yyyy-MM-dd"),en=null;var eo=a.i(118082),ep=a.i(158697);async function eq(a,b){let c,d,e,f=b=>({failed:`${a} could not be read: ${(0,w.errorToString)(b)}`});try{c=await fetch(t.queryKey.file(a))}catch(a){return f(a)}if(404===c.status)return{failed:`There is no file at ${a} in the workspace.`};if(403===c.status)return{failed:`${a} is outside the workspace.`};if(!c.ok)return{failed:`${a} could not be read: the file route answered ${c.status}.`};try{d=await c.blob()}catch(a){return f(a)}if(!d.type.startsWith("image/"))return{failed:`${a} is not an image. Read it in the shell instead.`};try{e=await createImageBitmap(d)}catch(b){return{failed:`${a} could not be drawn as a picture: ${(0,w.errorToString)(b)}`}}try{let c=function(a,b){var c,d;let e,f,g=document.createElement("canvas"),h=g.getContext("2d");if(!h)return{failed:"draw"};for(let i of(c=a.width,e=Math.max(c,d=a.height),f=Math.min(e,D.CALL_PICTURE.longestSide),D.CALL_PICTURE.scales.map(a=>{let b=f*a/e;return{width:Math.max(1,Math.round(c*b)),height:Math.max(1,Math.round(d*b))}})))for(let c of(g.width=i.width,g.height=i.height,h.fillStyle="#fff",h.fillRect(0,0,g.width,g.height),h.drawImage(a,0,0,g.width,g.height),D.CALL_PICTURE.qualities)){let a=g.toDataURL("image/jpeg",c);if(a.length<=b)return{url:a}}return{failed:"fit"}}(e,b);if("url"in c)return c;return{failed:"draw"===c.failed?"This browser could not draw the picture.":`${a} would not fit the ${(0,w.formatBytes)(b)} this connection carries, even made smaller.`}}finally{e.close()}}async function er(a,{fact:b,pictures:c,run:d},e,f){try{let f=[];for(let b of c)f.push({path:b,taken:await e(b,a.pictureRoom(b))});for(let{path:c,taken:d}of(a.brief(b),f))"url"in d?a.picture(d.url,c):a.brief(`${c} could not be put before you as a picture: ${d.failed}`);d&&a.run()}finally{f(b)}}let es=(0,ai.createServerReference)("7fc1ed1082d830fb40329cb141e7bf6d68453e0697",ai.callServer,void 0,ai.findSourceMapURL,"openCallAction"),et=(0,ai.createServerReference)("7fa5d25e2f5ee8c6fac0b33c210238c2f7a2acee30",ai.callServer,void 0,ai.findSourceMapURL,"saveThoughtAction"),eu=(0,ai.createServerReference)("7f115af782b3c735780ca4f93d7aa06bcc9948e191",ai.callServer,void 0,ai.findSourceMapURL,"saveTurnsAction"),ev={offer:"the microphone and the offer",globe:"the globe's map",answer:"the server's answer",line:"the line"};function ew(a,b){let c="chatgpt"===a?" on your GPT Subscription":"openai"===a?" on your OpenAI key":"";return b?`Could not start the call${c}`:`The call${c} failed`}class ex extends Error{}let ey=Array(eh.SPECTRUM_BANDS).fill(0),ez=!1;function eA(a){let b=a.replace(/\[[^\]]*\]?|\]/g,"").trim();return/[\p{L}\p{N}]/u.test(b)?b:""}function eB(a,b,c="This call is not being saved"){a.failures>=D.CALL_PAGE.saveFailures||b().then(a=>(0,cE.unwrapResult)(a)).catch(b=>{a.failures+=1,a.failures===D.CALL_PAGE.saveFailures&&cA.toast.add({type:"warning",title:c,description:(0,w.errorToString)(b)})})}var eC=a.i(77453);let eD="(prefers-reduced-motion: reduce)";function eE({turns:a,saying:b}){let[c,e]=(0,s.useState)(""),f=(0,s.useRef)(null),g=a.at(-1);return(0,s.useEffect)(()=>{if(!g||"assistant"!==g.role||b)return;let a=`${g.id}:${g.text.length}`;f.current!==a&&(f.current=a,e(g.text))},[g,b]),(0,K.useAppEvent)({finished:a=>e(`${a.bot} finished: ${a.label}`)}),(0,d.jsx)("div",{role:"status","aria-live":"polite",className:"sr-only",children:c})}var eF=a.i(526496),eG=a.i(935112),eH=a.i(663390);let eI="700 9px ui-monospace, SFMono-Regular, Menlo, monospace",eJ=Math.ceil(13.5);function eK(a){let b=document.createElement("canvas");b.width=eJ*a.length,b.height=eJ;let c=b.getContext("2d");return c?(c.textAlign="center",c.textBaseline="middle",c.font=eI,a.forEach((a,b)=>{c.fillText(a,b*eJ+eJ/2,eJ/2)}),b):null}function eL({status:a}){let b=(0,s.useRef)(null),c=(0,s.useRef)(null),e=(0,s.useRef)(a),[f,g]=(0,s.useState)(!1),h=(0,s.useRef)(null);return(0,s.useEffect)(()=>{"emoji"===(0,eH.faceGlyphs)()&&(h.current=eK(ej.EMOJI_POOL))},[]),(0,s.useEffect)(()=>{let b=e.current;e.current=a,"connecting"!==b||"connecting"===a||"idle"===a||"ending"===a||window.matchMedia("(prefers-reduced-motion: reduce)").matches||g(!0)},[a]),(0,s.useEffect)(()=>{let a=c.current,d=b.current?.getBoundingClientRect();if(!f||!a||!d)return;let e=window.innerWidth,i=window.innerHeight,j=d.left+d.width/2,k=d.top+d.height/2,l=Math.hypot(Math.max(j,e-j),Math.max(k,i-k)),m=Math.ceil(e/11),n=Math.ceil(i/11),o=[];for(let a=0;a<n;a++)for(let b=0;b<m;b++){if((0,ej.hash)(b+53,a+5)>.4)continue;let c=11*b+5.5,d=11*a+5.5,e=Math.atan2(d-k,c-j),f=(0,ej.hash)(b+31,a+17),g=Math.hypot(c-j,d-k)/l*(1+.1*Math.sin(3*e+1.3)+.05*Math.sin(7*e-.7)+(f-.5)*.1);g<.1||o.push({x:c,y:d,dd:g,seed:(0,ej.hash)(b,a),grain:f,speck:(0,ej.hash)(b+7,a+101)})}o.sort((a,b)=>a.dd-b.dd);let p=a=>{let b=0,c=o.length;for(;b<c;){let d=b+c>>1;o[d].dd<a?b=d+1:c=d}return b};a.width=e,a.height=i;let q=a.getContext("2d"),r="letters"===(0,eH.faceGlyphs)(),s=r?null:h.current??eK(ej.EMOJI_POOL);if(!q||!r&&!s)return;r&&(q.textAlign="center",q.textBaseline="middle",q.font=eI,q.fillStyle=getComputedStyle(a).color);let t=ej.LEVELS-1,u=r?ej.CHAR_RATE:ej.EMOJI_CHAR_RATE,v=eJ/2,w=performance.now(),x=0,y=0,z=()=>{let a=(performance.now()-w)/1e3;if(a>1.9736842105263157)return g(!1);if(y=requestAnimationFrame(z),x++%2)return;let b=.95*a;q.clearRect(0,0,e,i);for(let c=p(b-.2-.475);c<o.length;c++){let d=o[c],e=b-d.dd;if(e<-.03)break;let f=(0,ej.smoothstep)(-.03,.02,e)*(1-(0,ej.smoothstep)(.02,.2,e))*(.72+.28*Math.sin(46*d.dd-7*a+6.283*d.seed));if(d.speck<.06){let a=.18+.32*d.grain,b=(e-.2)/.95;f=Math.max(f,(.3+.4*d.grain)*(1-(0,ej.smoothstep)(.4*a,a,b)))}let g=Math.round(f*t);if(g<1)continue;let h=Math.floor(a*u+10*d.seed);if(s){q.globalAlpha=(0,ej.emojiAlpha)(g,t);let a=Math.floor((0,ej.hash)(97*d.seed,h)*ej.EMOJI_POOL.length);q.drawImage(s,a*eJ,0,eJ,eJ,d.x-v,d.y-v,eJ,eJ);continue}q.globalAlpha=ej.ALPHA_TOP*(g/t);let i=ej.RAMP[g];q.fillText(i[Math.floor((0,ej.hash)(131*d.seed,h)*i.length)],d.x,d.y)}q.globalAlpha=1};return y=requestAnimationFrame(z),()=>cancelAnimationFrame(y)},[f]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{ref:b,"aria-hidden":!0,className:"pointer-events-none absolute inset-0"}),f&&(0,eG.createPortal)((0,d.jsx)("canvas",{ref:c,"aria-hidden":!0,className:"pointer-events-none fixed inset-0 z-30 size-full text-foreground"}),document.body)]})}var eM=a.i(445432),eN=a.i(587479),eO=a.i(538254);let eP=["▁▄▇▄","▂▆▆▂","▄▇▄▁","▆▆▂▂","▇▄▁▄","▆▂▂▆","▄▁▄▇","▂▂▆▆"];function eQ({live:a,ringing:b}){let{owed:c}=bB(),d=ck(Object.values(cl()).map(a=>a??null)),e="waiting"===d?null:d;return(0,s.useEffect)(()=>{let d=b?`${D.APP_NAME} is calling`:D.APP_NAME,e=c>0?`(${c}) ${d}`:d;if(!a){document.title=e;return}let f=0;document.title=`${e} ${eP[f]}`;let g=setInterval(()=>{f=(f+1)%eP.length,document.title=`${e} ${eP[f]}`},100);return()=>clearInterval(g)},[a,c,b]),(0,s.useEffect)(()=>{let a=document.head.querySelector("link[data-tab-icon]");a||((a=document.createElement("link")).rel="icon",a.type="image/svg+xml",a.setAttribute("sizes","any"),a.dataset.tabIcon="",document.head.append(a)),a.href=`data:image/svg+xml,${encodeURIComponent(function(a){let{head:b,eyes:c}=(0,eO.markAtRest)(O.THURSDAY_SEED),d=a?`<circle cx="200" cy="200" r="${66}"/>`:"",e=a?`<circle class="${a}" 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="${b}" fill="#fff"/><path d="${c[0]}"/><path d="${c[1]}"/>${d}</mask><path class="ink" d="${b}" mask="url(#m)"/>${e}</svg>`}(e))}`},[e]),null}let eR={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"}]]};eR.node;let eS=(0,h.default)(eR);var eT=a.i(327598);let eU={name:"brush",size:24,node:[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]]};eU.node;let eV=(0,h.default)(eU);var eW=a.i(127774),eX=a.i(676504),eY=a.i(630342),eZ=a.i(546893),e$=a.i(608902);let e_=(0,ai.createServerReference)("7f00f7786d46c0c3794003ea172cbce2485cc9fa12",ai.callServer,void 0,ai.findSourceMapURL,"startThreadAction");var e0=a.i(983874),e1=a.i(866460);let e2={name:"redo-2",size:24,node:[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]};e2.node;let e3=(0,h.default)(e2),e4={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};e4.node;let e5=(0,h.default)(e4);var e6=a.i(704974);let e7=[{label:"Ink",color:null},{label:"Red",color:aQ.MARK_INK.red},{label:"Orange",color:aQ.MARK_INK.orange},{label:"Yellow",color:aQ.MARK_INK.yellow},{label:"Green",color:aQ.MARK_INK.green},{label:"Blue",color:aQ.MARK_INK.blue},{label:"Violet",color:aQ.MARK_INK.violet},{label:"Pink",color:aQ.MARK_INK.pink},{label:"Stone",color:aQ.MARK_INK.stone}];function e8(a,b,c,d,e){for(let f of(a.lineCap="round",a.lineJoin="round",a.lineWidth=.014*b,d)){let[d,...g]=f.points;if(d){for(let[h,i]of(a.strokeStyle=e(f.pen),a.beginPath(),a.moveTo(d[0]*b,d[1]*c),g))a.lineTo(h*b,i*c);g.length||a.lineTo(d[0]*b+.1,d[1]*c),a.stroke()}}}function e9({open:a,onClose:b,onDone:c,action:e}){let f=(0,s.useRef)([]),g=(0,s.useRef)(null),h=(0,s.useRef)([]),i=(0,s.useRef)([]),[j,k]=(0,s.useState)(0),[,l]=(0,s.useState)(0),m=(0,Q.useCommandLabel)("KeyZ"),n=(0,Q.useCommandLabel)("KeyZ",!0),[o,p]=(0,s.useState)(0),[q,r]=(0,s.useState)(null),[t,v]=(0,s.useState)(null),[x,y]=(0,s.useState)(!1),z=(0,bP.useIsDark)();(0,Q.useEscape)(a,b);let A=(0,s.useCallback)(a=>{let[b,c,d]=z?ej.ORB_INK.dark:ej.ORB_INK.light;return e7[a]?.color??`rgb(${b},${c},${d})`},[z]);(0,s.useEffect)(()=>{if(!q)return;let a=new ResizeObserver(([a])=>{let b=a.contentRect.width,c=a.contentRect.height;b>0&&c>0&&v({width:b,height:c})});return a.observe(q),()=>a.disconnect()},[q]),(0,s.useEffect)(()=>{if(!q||!t)return;let a=Math.min(2,window.devicePixelRatio||1);q.width=Math.round(t.width*a),q.height=Math.round(t.height*a);let b=q.getContext("2d");b&&(b.setTransform(a,0,0,a,0,0),e8(b,t.width,t.height,f.current,A))},[q,t,A]);let B=a=>{let b=a.currentTarget.getBoundingClientRect();return[Math.min(1,Math.max(0,(a.clientX-b.left)/b.width)),Math.min(1,Math.max(0,(a.clientY-b.top)/b.height))]},E=a=>{let b=q?.getContext("2d");b&&t&&e8(b,t.width,t.height,[{pen:a.pen,points:a.points.slice(-2)}],A)},F=()=>{k(f.current.length),l(a=>a+1);let a=q?.getContext("2d");q&&a&&t&&(a.clearRect(0,0,q.width,q.height),e8(a,t.width,t.height,f.current,A))},G=()=>{h.current.push([...f.current]),i.current=[],l(a=>a+1)},H=(a,b)=>{let c=a.current.pop();c&&(g.current=null,b.current.push(f.current),f.current=c,F())},I=()=>H(h,i),J=()=>H(i,h),K=async()=>{if(q&&t&&f.current.length){y(!0);try{let{width:a,height:b}=t,d=1,e=1,j=0,k=0;for(let a of f.current)for(let[b,c]of a.points)d=Math.min(d,b),e=Math.min(e,c),j=Math.max(j,b),k=Math.max(k,c);let l=.027*a,m=Math.max(0,d*a-l),n=Math.max(0,e*b-l),o=Math.min(a,j*a+l)-m,p=Math.min(b,k*b+l)-n,r=Math.min(Math.min(2,window.devicePixelRatio||1),D.DRAW_PAD.longestSide/Math.max(o,p)),s=document.createElement("canvas");s.width=Math.max(1,Math.round(o*r)),s.height=Math.max(1,Math.round(p*r));let u=s.getContext("2d");if(!u)throw Error("This browser gave no canvas to keep it on.");u.fillStyle=getComputedStyle(q).backgroundColor,u.fillRect(0,0,s.width,s.height),u.setTransform(r,0,0,r,-m*r,-n*r),e8(u,a,b,f.current,A);let v=await new Promise(a=>s.toBlob(a,"image/png"));if(!v)throw Error("This browser could not keep the drawing.");let w=f.current.length;await c(new File([v],"drawing.png",{type:"image/png"}))&&f.current.length===w&&(f.current=[],g.current=null,h.current=[],i.current=[],F())}catch(a){cA.toast.add({type:"error",title:"The drawing could not be kept.",description:(0,w.errorToString)(a)})}finally{y(!1)}}};return(0,d.jsx)(by.Dialog,{open:a,onOpenChange:a=>!a&&b(),children:(0,d.jsxs)(by.DialogContent,{showCloseButton:!1,onKeyDown:a=>{if(!(a.metaKey||a.ctrlKey)||a.altKey)return;let b=a.key.toLowerCase();"z"===b?(a.preventDefault(),a.shiftKey?J():I()):"y"===b&&a.ctrlKey&&!a.metaKey&&(a.preventDefault(),J())},className:"w-[min(72rem,calc(100vw-2rem),calc((100dvh-7rem)*2))] max-w-none gap-3 p-3 sm:max-w-none",children:[(0,d.jsx)(by.DialogTitle,{className:"sr-only",children:"Drawing pad"}),(0,d.jsx)("canvas",{ref:r,"aria-label":"Drawing pad",className:"block aspect-[2/1] w-full cursor-crosshair touch-none rounded-lg bg-background ring-1 ring-foreground/10",onPointerDown:a=>{a.currentTarget.setPointerCapture(a.pointerId),G();let b={pen:o,points:[B(a)]};g.current=b,f.current.push(b),E(b),k(f.current.length)},onPointerMove:a=>{let b=g.current;if(!b)return;let c=B(a),d=b.points[b.points.length-1];.002>Math.hypot(c[0]-d[0],c[1]-d[1])||(b.points.push(c),E(b))},onPointerUp:()=>{g.current=null},onPointerCancel:()=>{g.current=null}}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 pl-1",children:e7.map((a,b)=>(0,d.jsx)(e6.Swatch,{color:a.color,label:a.label,picked:o===b,onPick:()=>p(b)},a.label))}),(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsx)(C.TooltipTrigger,{render:(0,d.jsx)(u.Button,{variant:"ghost",size:"icon","aria-label":"Undo",disabled:!h.current.length,onClick:I}),children:(0,d.jsx)(e5,{})}),(0,d.jsxs)(C.TooltipContent,{children:["Undo",(0,d.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:m})]})]}),(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsx)(C.TooltipTrigger,{render:(0,d.jsx)(u.Button,{variant:"ghost",size:"icon","aria-label":"Redo",disabled:!i.current.length,onClick:J}),children:(0,d.jsx)(e3,{})}),(0,d.jsxs)(C.TooltipContent,{children:["Redo",(0,d.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:n})]})]}),(0,d.jsx)("span",{"aria-hidden":!0,className:"h-4.5 w-px bg-border"}),(0,d.jsx)(u.Button,{variant:"ghost",disabled:!j,onClick:()=>{G(),f.current=[],g.current=null,F()},children:"Clear"}),(0,d.jsx)(u.Button,{disabled:!j,loading:x,onClick:()=>void K(),children:e})]})]})})}let fa={name:e0.ROOM_THURSDAY,description:"A call in writing — she answers here"},fb=a=>/^@(\S*)$/.exec(a.split(/\s/,1)[0]);function fc({written:a,onCall:b=!1}){let{data:c}=(0,U.useServerRoute)(t.queryKey.bot),e=(0,s.useMemo)(()=>[...a?[fa]:[],...c?.length?c.filter(a=>!a.disabled).map(({name:a,icon:b,description:c})=>({name:a,icon:b,description:c})):[G.DEFAULT_BOT]],[c,a]),[g,h]=(0,s.useState)(!1),[i,j]=(0,s.useState)(!1),[k,l]=(0,s.useState)(!1),[m,n]=(0,s.useState)(!1),[o,q]=(0,s.useState)(""),[r,v]=(0,s.useState)(0),[x,y]=(0,s.useState)(!1),z=(0,s.useRef)(b);z.current=b;let A=(0,e1.useGivenFiles)({onKept:a=>{if(z.current)return V.screenActs.announce({kind:"gave",paths:a}),"she knows it is here"}}),B=(0,s.useRef)(null),C=(0,s.useRef)(null),D=!!a?.on,[E,H]=(0,s.useState)(null);(0,s.useEffect)(()=>{D||H(null)},[D]);let I=e.find(a=>a.name===E)??(a?fa:e[0]),J=I===fa,K=(0,cm.useCallHeld)(),L=(0,s.useCallback)(a=>{K||(h(!0),a&&(q(a=>fb(a)?a:a?`@ ${a}`:"@"),y(!1),v(0)),requestAnimationFrame(()=>{let b=B.current;b?.focus();let c=b?.value.split(/\s/,1)[0].length??0;a&&b?.setSelectionRange(c,c)}))},[K]),M=(0,V.useRoomOpen)(),{take:N}=A,O=(0,s.useCallback)(a=>(V.writeLine.open(),N(a)),[N]);(0,s.useEffect)(()=>V.writeLine.subscribe(L),[L]),(0,s.useEffect)(()=>V.writeLine.onDraw(()=>l(!0)),[]),(0,s.useEffect)(()=>{if("thread"===M)return;let a=a=>{(0,Q.typed)(a,"@")&&(0,Q.windowKey)(a)&&(a.preventDefault(),V.writeLine.choose())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[M]),(0,s.useEffect)(()=>{if(K)return;let a=a=>!!a.dataTransfer?.types.includes("Files"),b=b=>{a(b)&&(b.preventDefault(),n(!0))},c=a=>{null===a.relatedTarget&&n(!1)},d=b=>{if(!a(b))return;b.preventDefault(),n(!1);let c=[...b.dataTransfer?.files??[]];e1.roomDrop.offer(b.target,c)||O(c)};return window.addEventListener("dragover",b),window.addEventListener("dragleave",c),window.addEventListener("drop",d),()=>{window.removeEventListener("dragover",b),window.removeEventListener("dragleave",c),window.removeEventListener("drop",d)}},[O,K]);let[R,S]=(0,an.useServerAction)(e_,{onOk:({id:a})=>{(0,U.revalidate)(t.queryKey.threads),q(""),A.clear(),h(!1),H(null),V.roomOpens.open(a)}}),T=a=>{j(!1),q(a=>fb(a)?a.replace(/^@\S*\s?/,""):a),v(0),B.current?.focus(),H(a.name===fa.name?null:a.name)},W=x?null:fb(o),X=W&&!W[1]?o.replace(/^@\s?/,""):null,Y=null!==X&&!X.trim()&&!A.files.length&&!D,Z=W?e.filter(a=>a.name.toLowerCase().startsWith(W[1].toLowerCase())):e,$=Z.length?r%Z.length:0,[_,aa]=(0,s.useState)(!1),ab=S||_,ac=!!o.trim()&&!W&&!A.arriving&&!ab&&!(J&&!a?.runsOn),ad=()=>{if(!ac)return;let b=A.withPaths(o);J?a&&(aa(!0),a.say(b,A.paths).then(()=>{q(""),A.clear()}).catch(()=>{}).finally(()=>aa(!1))):R(I.name,b)},ae=()=>{if(E)return H(null);D&&a?.end(),h(!1)},af=(0,s.useRef)(b);(0,s.useEffect)(()=>{let a=b&&!af.current;af.current=b,!a||o.trim()||A.files.length||h(!1)},[b,o,A.files.length]);let ag=(g||m||D)&&!M;(0,Q.useEscape)(ag,ae),P(ag,"write");let ah=S||_;(0,s.useEffect)(()=>{ag&&!ah&&B.current?.focus()},[ag,ah]),(0,s.useEffect)(()=>(V.writeLine.shown(ag),()=>V.writeLine.shown(!1)),[ag]);let ai=D&&!!M;(0,s.useEffect)(()=>(V.writeLine.waits(ai),()=>V.writeLine.waits(!1)),[ai]);let aj=ao(),[ak,al]=(0,s.useState)(ag);(0,s.useEffect)(()=>{if(ag)return void al(!0);let a=setTimeout(()=>al(!1),200);return()=>clearTimeout(a)},[ag]);let ap=(0,d.jsx)(e9,{open:k,onClose:()=>l(!1),onDone:async a=>{if(l(!1),!z.current)return(await O([a])).length>0;let b=await A.keepApart(a);return!!b&&(z.current?(V.screenActs.announce({kind:"showed",path:b}),cA.toast.add({type:"success",title:"Shown to her"}),!0):(cA.toast.add({type:"error",title:"The call ended before she saw the drawing."}),!1))},action:b?"Show her":"Add to the message"});return ak?(0,d.jsxs)(d.Fragment,{children:[ap,m&&(0,d.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-0 bg-background/60",children:(0,d.jsx)("div",{className:"absolute inset-3 rounded-3xl border-[1.5px] border-dashed border-foreground/30"})}),(0,d.jsx)("div",{className:"col-start-2 row-start-1 flex min-w-0 items-end justify-center",children:(0,d.jsxs)("div",{className:(0,w.cn)("@container flex w-160 max-w-full flex-col gap-2",ag?"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:[aj.length>0&&(0,d.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,d.jsxs)("p",{className:"px-3 pt-1 pb-1 font-mono text-[10px] tracking-wide text-muted-foreground",children:[aj.length," ",1===aj.length?"needs":"need"," a reply"]}),(0,d.jsx)("div",{className:"max-h-[30vh] overflow-y-auto",children:aj.map(a=>(0,d.jsx)(ax,{thread:a,lines:2,onPick:()=>V.roomOpens.open(a.id)},a.id))})]}),(0,d.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:[(A.files.length>0||m)&&(0,d.jsx)(e1.GivenFiles,{files:A.files,onRemove:A.remove,className:"px-0.5 pt-0.5",children:m&&(0,d.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,d.jsx)(eS,{className:"size-4"}),"Let go — it waits here"]})}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault(),ad()},className:"flex items-end gap-2 @max-md:flex-wrap @max-md:items-center",children:[(0,d.jsxs)(eY.Popover,{open:i||!!W,onOpenChange:j,children:[(0,d.jsxs)(eY.PopoverTrigger,{render:(0,d.jsx)("button",{type:"button","aria-label":`To ${I.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,d.jsx)(fg,{bot:I,size:22}),I.name,(0,d.jsx)(f.ChevronDown,{className:"size-3 text-muted-foreground"})]}),(0,d.jsxs)(eY.PopoverContent,{side:"top",align:"start",sideOffset:14,initialFocus:!W&&void 0,className:"w-90 gap-0 rounded-[18px] p-1.5",children:[(0,d.jsx)("p",{className:"px-2.5 pt-1.5 pb-1 font-mono text-[10px] text-muted-foreground",children:"to"}),Z.map((a,b)=>(0,d.jsxs)("button",{type:"button",onClick:()=>T(a),className:(0,w.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",(W?b===$:a.name===I.name)&&"bg-muted"),children:[(0,d.jsx)(fg,{bot:a,size:24}),(0,d.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,d.jsx)("span",{className:"text-[13.5px] leading-4.5 font-medium",children:a.name}),(0,d.jsx)("span",{className:"truncate text-xs leading-4 text-muted-foreground",children:a.description})]})]},a.name)),0===Z.length&&(0,d.jsx)("p",{className:"px-2.5 py-2 text-[13px] text-muted-foreground",children:"Nobody by that name."})]})]}),(0,d.jsx)(eZ.Textarea,{ref:B,value:o,rows:1,disabled:S||_,onChange:a=>{let b=a.target.value;q(b),v(0),fb(b)||y(!1)},onPaste:a=>{let b=[...a.clipboardData.files];b.length&&(a.preventDefault(),O(b))},onKeyDown:a=>{let b=(0,Q.composing)(a);if("Escape"===a.key&&!b){if(a.preventDefault(),null!==X){if(q(X),!Y)return;H(null),h(!1);return}return W?y(!0):ae()}let c="ArrowDown"===a.key||"ArrowUp"===a.key;if(W&&c&&!b){let b;return a.preventDefault(),b="ArrowDown"===a.key?1:-1,v(a=>Z.length?(a+b+Z.length)%Z.length:0)}let d="Tab"===a.key&&!a.shiftKey;if(W&&d&&!b&&Z[$]){a.preventDefault(),T(Z[$]);return}if("Enter"===a.key&&!a.shiftKey&&!b){if(a.preventDefault(),W){Z[$]&&T(Z[$]);return}ad()}},placeholder:A.files.length?"Say what to do with them":D&&J?"Write back":J?"Write to her instead of calling":`Say the whole job — ${I.name} cannot hear the call`,"aria-label":`Message for ${I.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 @max-md:order-first @max-md:basis-full @max-md:px-2 dark:bg-transparent"}),(0,d.jsx)("input",{ref:C,type:"file",multiple:!0,hidden:!0,onChange:a=>{O([...a.target.files??[]]),a.target.value=""}}),(0,d.jsxs)(eX.DropdownMenu,{children:[(0,d.jsx)(eX.DropdownMenuTrigger,{render:(0,d.jsx)("button",{type:"button","aria-label":"Add a file or a drawing",className:"grid size-9 shrink-0 @max-md:ml-auto 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 data-popup-open:bg-muted data-popup-open:text-foreground"}),children:(0,d.jsx)(eW.Paperclip,{className:"size-4"})}),(0,d.jsxs)(eX.DropdownMenuContent,{side:"top",align:"end",sideOffset:14,className:"w-64 rounded-[18px] p-1.5",children:[(0,d.jsxs)(eX.DropdownMenuItem,{onClick:()=>C.current?.click(),className:"h-11 gap-2.5 rounded-xl px-2.5 text-[13.5px]",children:[(0,d.jsx)(bN.FolderOpen,{}),"A file from this computer"]}),(0,d.jsxs)(eX.DropdownMenuItem,{onClick:()=>l(!0),className:"h-11 gap-2.5 rounded-xl px-2.5 text-[13.5px]",children:[(0,d.jsx)(eV,{}),"Draw something"]})]})]}),(0,d.jsx)("button",{type:"submit","aria-label":"Send",disabled:!ac,className:(0,w.cn)("grid size-9 shrink-0 place-items-center rounded-full outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50",ac?"bg-primary text-primary-foreground hover:bg-primary/85":"bg-muted text-muted-foreground/40"),children:ab?(0,d.jsx)("span",{className:"size-3.5 animate-spin rounded-full border-2 border-current/30 border-t-current"}):(0,d.jsx)(eT.ArrowUp,{className:"size-4"})})]})]}),J&&a?.error&&(a.refused?(0,d.jsxs)("div",{className:"flex flex-col items-center gap-0.5 px-4 text-center",children:[(0,d.jsxs)("p",{className:"text-xs leading-5 text-destructive",children:[(0,F.refusedWords)(a.refused),", so she could not answer."]}),(0,d.jsx)("p",{className:"line-clamp-2 font-mono text-[10.5px] leading-4 text-muted-foreground",children:a.error})]}):(0,d.jsx)("p",{className:"px-4 text-center text-xs leading-5 text-destructive",children:a.error})),J&&a?.error&&(0,d.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[a.refused&&(0,d.jsxs)(u.Button,{type:"button",size:"sm",onClick:()=>(0,am.openSettings)("keys"),children:[(0,d.jsx)(p.Settings2,{}),"Open Settings"]}),(0,d.jsxs)(u.Button,{type:"button",size:"sm",variant:a.refused?"ghost":"brand",disabled:a.busy,onClick:()=>{a.fallback&&cw.useThursdayStore.getState().patch({textModel:a.fallback}),a.again()},children:[(0,d.jsx)(aE.RotateCw,{}),a.fallback?"Send it again on your OpenAI key":"Send it again"]})]}),(0,d.jsx)("p",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1 font-mono text-[10.5px] text-muted-foreground",children:W?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(fh,{keys:["↑↓"],children:"walk"}),(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["Tab","Enter"],children:"take"}),(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["Esc"],children:Y?"close":"close the list"})]}):(0,d.jsxs)(d.Fragment,{children:[J&&!a?.runsOn?(0,d.jsx)(fd,{runsOn:null}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(fh,{keys:["Enter"],children:"send"}),(0,d.jsxs)("span",{className:"contents @max-md:hidden",children:[(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["@"],children:J?"a bot":"pick a bot"})]}),J&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(fe,{}),(0,d.jsx)(fd,{runsOn:a?.runsOn??null})]})]}),(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["Esc"],children:D?J?"to end":"back to her":"close"})]})})]})})]}):ap}function fd({runsOn:a}){let b=F.TEXT_MODEL_PROVIDERS.chatgpt.label,c=(0,d.jsx)(e$.ModelPicker,{compact:!0,provider:a?.provider??null,model:a?.model??"",unset:"pick a model",onChange:a=>cw.useThursdayStore.getState().patch({textModel:a})});return a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"runs on"}),c]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:["Writing to her needs a ",b,", an OpenAI key, or"]}),c,(0,d.jsx)(fe,{}),(0,d.jsx)(ff,{children:"API keys"})]})}let fe=()=>(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"});function ff({children:a}){return(0,d.jsx)("button",{type:"button",onClick:()=>(0,am.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:a})}function fg({bot:a,size:b}){return a===fa?(0,d.jsx)(O.ThursdayMark,{size:b,className:"shrink-0"}):(0,d.jsx)(H.BotMark,{size:b,seed:a.name,color:a.icon?.color,shape:a.icon?.shape,outline:a.icon?.outline,paint:a.icon?.paint,notify:!1,className:"shrink-0"})}function fh({keys:a,children:b}){return(0,d.jsxs)("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[a.map(a=>(0,d.jsx)(fi,{children:a},a)),b]})}function fi({children:a}){return(0,d.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:a})}let fj=(0,r.default)(async()=>{},{loadableGenerated:{modules:[246971]},ssr:!1});function fk({status:a,failed:b=!1,messages:c,tool:e,thinkingSince:f=null,thinkingTitle:g=null,ended:h=null,faceWord:i=null,onTap:j,ringing:k=null,onDecline:l,wakePhrase:m=null,hotkeyLabel:n=null,idleLeft:o=null,since:p=null,getSpectrum:q,getMicSpectrum:r,captionView:t="sides",callable:u=!0,written:v=null}){let[x,y]=(0,s.useState)(!1),z=!u&&"idle"===a,A="connecting"===a||"ending"===a,B=!!v?.on,C="idle"!==a&&!A&&!B,E=c.findLast(a=>"assistant"===a.role)?.text??"",F=R(fo),G="sides"===t&&"idle"!==a&&F,H=ct(),I=!G||null!==H,J=(0,s.useMemo)(()=>(0,eN.turnsOf)(c),[c]),K=(0,eN.useTurnFocus)(J,G),L=J.at(-1)?.role,N=function(a,b){let[c,d]=(0,s.useState)(a),e=(0,s.useRef)(a?[a]:[]),f=(0,s.useRef)(Date.now()),g=(0,s.useRef)(!1),h=(0,s.useRef)(null),i=(0,s.useCallback)(()=>{h.current&&clearTimeout(h.current),h.current=null,(e.current.length>1||g.current)&&e.current.length&&(h.current=setTimeout(()=>{e.current.shift(),f.current=Date.now(),d(e.current[0]??null),i()},Math.max(0,f.current+D.CALL_LINE.dwellMs-Date.now())))},[]);return(0,s.useEffect)(()=>{if(!a){g.current=!0,e.current.length<=1&&(e.current=[],d(null)),i();return}g.current=!1;let b=e.current.findIndex(b=>b.id===a.id);b>=0?(e.current[b]=a,0===b&&d(a)):(e.current=[...e.current.map((a,b)=>0===b?a:{...a,done:!0}),a],1===e.current.length&&(f.current=Date.now(),d(a))),i()},[a,i]),(0,s.useEffect)(()=>{if(!b)return;let a=e.current.at(-1);e.current=a&&!g.current?[a]:[],f.current=Date.now(),d(e.current[0]??null),i()},[b,i]),(0,s.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),c}(e,"speaking"===a),O=function(a,b){let c=null!==a||b,[d,e]=(0,s.useState)([]),[f,g]=(0,s.useState)(c);return(0,s.useEffect)(()=>{e(b=>{let c=b.some(a=>!a.done)?b.map(a=>a.done?a:{...a,done:!0}):b;if(!a)return c;let d=b.findIndex(b=>fA(b)===fA(a));return d>=0?b.map((b,c)=>c===d?a:b):[...c,a].slice(-4)})},[a]),(0,s.useEffect)(()=>{if(c)return void g(!0);let a=setTimeout(()=>{g(!1),e([])},300);return()=>clearTimeout(a)},[c]),{lines:d,on:c,held:f}}(N,null!==f),[P,Q]=(0,s.useState)(!1);(0,s.useEffect)(()=>{"user"!==L?Q(!1):O.on&&Q(!0)},[L,O.on]);let S=function(a,b,c){let[d,e]=(0,s.useState)(fB),f=a.findLast(a=>"assistant"===a.role),g=f?.id??null,h=f?`${f.id}:${f.text.length}`:null,i=!c&&a.at(-1)?.role==="assistant";(0,s.useEffect)(()=>{e(a=>{let c=a;for(let a of b){let b=fA(a),d=c.owner[b];if(void 0===d){let a=b in c.seen?c.seen[b]:h;if(b in c.seen||(c={...c,seen:{...c.seen,[b]:h}}),!g||a===h&&!i)continue;d=g,c={...c,owner:{...c.owner,[b]:d}}}let e=c.turns[d]??[],f=e.findIndex(a=>fA(a)===b);f>=0&&e[f]===a||(c={...c,turns:{...c.turns,[d]:f>=0?e.map((b,c)=>c===f?a:b):[...e,a]}})}return c})},[b,h,g,i]),(0,s.useEffect)(()=>{a.length||e(fB)},[a.length]);let j=(0,s.useMemo)(()=>b.filter(a=>void 0===d.owner[fA(a)]),[b,d.owner]);return{turns:d.turns,pending:j,latest:g}}(J,O.lines,O.on),T="assistant"===L&&"speaking"===a||"user"===L&&"listening"===a&&!B,U=null!==k&&null===k.missedAt,W=function(a){let[b,c]=(0,s.useState)(null);return(0,s.useEffect)(()=>{c(a?{...fD,at:Date.now()}:null)},[a]),b}(U),X=(0,cm.useCallHeld)(),Y=(0,am.useSettingsStore)(a=>a.open),Z=(0,s.useSyncExternalStore)(a=>{let b=window.matchMedia(eD);return b.addEventListener("change",a),()=>b.removeEventListener("change",a)},()=>window.matchMedia(eD).matches,()=>!1),$=(0,M.useCrewAwake)(),_=(0,V.useRoomOffice)(),aa=(0,eC.useAwayAfter)(_,fp),ab="thread"===(0,V.useRoomOpen)(),ac=_&&"idle"!==a&&!B;return(0,s.useEffect)(()=>V.officeCaption.set(ac),[ac]),(0,s.useEffect)(()=>()=>V.officeCaption.set(!1),[]),(0,d.jsxs)("div",{className:"relative flex h-full flex-col",inert:X,children:[(0,d.jsx)(eE,{turns:J,saying:T}),(0,d.jsxs)("div",{className:"absolute top-5 right-5 z-10 flex flex-col items-end gap-3",children:[(0,d.jsx)(fq,{}),(0,d.jsx)(ch,{hidden:X||"idle"!==a||null!==k||B}),(0,d.jsx)(bj,{hidden:"idle"!==a||null!==k||B})]}),ac&&(0,d.jsxs)("p",{className:"absolute top-5 left-6 z-20 line-clamp-2 max-w-[calc(100%-45rem)] animate-in text-[17px] leading-relaxed fade-in duration-500",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:(0,w.cn)("mr-4 inline-block size-2.5 rounded-full bg-brand align-middle","speaking"===a?"animate-pulse motion-reduce:animate-none":"opacity-55")}),E||("connecting"===a?"Calling":"ending"===a?"Hanging up":"On a call")]}),(0,d.jsxs)("div",{inert:_,className:(0,w.cn)("flex min-h-0 flex-1 flex-col items-center justify-center gap-5 pt-[7vh] transition-[opacity,scale] duration-500 ease-out motion-reduce:transition-none",_&&"pointer-events-none scale-[0.97] opacity-0"),children:[(0,d.jsxs)("div",{className:"relative w-[min(20rem,52vw,37.5vh)] [--face-bleed:19.5%]",children:[(0,d.jsxs)("button",{type:"button",disabled:A,onClick:z?()=>y(!0):B&&!u?void 0:j,"aria-label":z?"Add a speech key":C?"End the call":U?"Answer Thursday":"Call Thursday",className:(0,w.cn)("group/face relative block w-full rounded-full outline-none transition-all duration-700 ease-out enabled:active:scale-[0.99] disabled:opacity-70",z&&"opacity-35"),children:[(0,d.jsx)("span",{className:"block",children:(0,d.jsx)(eM.Face,{status:a,failed:b,word:W??i,getSpectrum:q,covered:X||H?.phase==="world"||aa,held:Y||Z&&"idle"===a&&!$,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"})}),(0,d.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full opacity-0 ring-3 ring-ring/50 transition-opacity group-focus-visible/face:opacity-100"})]}),(0,d.jsx)(eL,{status:a}),H?.moment.kind==="here"&&(0,d.jsx)(fj,{scene:H.moment.scene,covered:X||aa,onPhase:a=>cs.tell(H.id,a)},H.id),G&&(0,d.jsx)("div",{className:(0,w.cn)("contents",H&&"*:invisible"),children:(0,d.jsx)(eN.SideCaptions,{turns:J,pinned:K.pinned,live:T,onPick:K.pick,under:O.held&&S.pending.length>0?(0,d.jsx)(fC,{lines:S.pending,shown:O.on}):null,ahead:P&&O.held&&S.pending.length>0,typed:B,workOf:a=>{let b=[...S.turns[a]??[],...a===S.latest&&"assistant"===L?S.pending:[]];return b.length?(0,d.jsx)(fC,{lines:b,shown:!0}):null}})})]}),(0,d.jsxs)("div",{className:"relative flex w-full max-w-3xl flex-col items-center gap-2 px-6 text-center",children:[k&&(0,d.jsx)(fF,{ringing:k,wakePhrase:m,onAnswer:j,onDecline:()=>l?.()}),(0,d.jsxs)("div",{className:(0,w.cn)("contents",k&&"*:invisible"),children:[(0,d.jsx)(fy,{tool:I?N:null,toolUp:null!==N,thinkingSince:f,thinkingTitle:g,micOpen:!B&&("listening"===a||"working"===a||"delegating"===a),getMicSpectrum:r}),(0,d.jsx)(fr,{text:I&&"idle"!==a?E:"",fadeIn:!0,className:"w-full max-w-160 text-center text-base"}),(0,d.jsx)("div",{className:(0,w.cn)("flex flex-col items-center","idle"===a&&"order-first"),children:z?(0,d.jsx)(fQ,{open:x,onOpen:()=>y(!0),onClose:()=>y(!1)}):B?(0,d.jsx)("span",{className:"h-6"}):(0,d.jsx)(fL,{status:a,idleLeft:o,since:p,ended:h,behind:G&&K.back,wakePhrase:m,hotkeyLabel:n})})]})]})]}),(0,d.jsxs)(fl,{children:[(0,d.jsx)("div",{inert:ab,className:(0,w.cn)("contents *:transition-opacity *:duration-300",ab&&"*:pointer-events-none *:opacity-0"),children:(0,d.jsx)(c2.ArtifactView,{talking:"idle"!==a})}),(0,d.jsx)(fc,{written:v,onCall:C}),(0,d.jsx)(a5,{})]})]})}function fl({children:a}){return(0,d.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:a})}let fm=["thursday","memory","bot"];function fn({alert:a}){return a?(0,d.jsx)("span",{"aria-hidden":!0,className:(0,w.cn)("absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2 ring-background","red"===a?"bg-destructive":"bg-waiting")}):null}let fo=1e3,fp=500;function fq(){let a=cl(),b=ck(cb.filter(a=>!fm.includes(a.id)).map(b=>a[b.id]??null));return(0,d.jsxs)(C.TooltipProvider,{children:[(0,d.jsxs)(y,{className:"bg-background/75 backdrop-blur-md",children:[(0,d.jsx)(y,{children:fm.map(b=>{let c=cb.find(a=>a.id===b);return c?(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsxs)(C.TooltipTrigger,{render:(0,d.jsx)(u.Button,{size:"icon",variant:"outline","aria-label":c.label,onClick:()=>(0,am.openSettings)(b)}),children:[(0,d.jsx)(c.icon,{className:"text-muted-foreground"}),(0,d.jsx)(fn,{alert:a[b]??null})]}),(0,d.jsx)(C.TooltipContent,{side:"bottom",children:c.label})]},b):null})}),(0,d.jsx)(y,{children:(0,d.jsxs)(u.Button,{variant:"outline",onClick:()=>(0,am.openSettings)(),className:"gap-1.5 px-2.5 text-[12.5px] font-normal",children:[(0,d.jsx)(p.Settings2,{className:"text-muted-foreground"}),"Settings",(0,d.jsx)(fn,{alert:b})]})})]}),(0,d.jsx)(ce,{})]})}function fr({text:a,lines:b=3,fadeIn:c=!1,className:e}){let h=(0,s.useRef)(null),[i,j]=(0,s.useState)(b),[k,l]=(0,s.useState)(0),[m,n]=(0,s.useState)(a);m!==a&&(n(a),l(0)),(0,s.useEffect)(()=>{let a=h.current;if(!a)return;let b=()=>{let b=Number.parseFloat(getComputedStyle(a).lineHeight);b&&j(Math.max(1,Math.round(a.scrollHeight/b)))};b();let c=new ResizeObserver(b);return c.observe(a),()=>c.disconnect()},[a]);let o=Math.ceil(Math.max(0,i-b)/b),p=Math.max(0,i-b-Math.min(k,o)*b),q=`calc(${b} * 1.625em)`,r=(0,d.jsx)("p",{ref:h,style:{lineHeight:1.625,transform:`translateY(-${1.625*p}em)`},className:"break-keep wrap-anywhere whitespace-pre-line transition-transform duration-200",children:(0,d.jsx)(eF.CaptionWords,{text:a,animate:c})});return(0,d.jsxs)("div",{className:"relative flex w-full justify-center",children:[(0,d.jsx)("div",{style:{height:q},onClick:o>0?()=>l(a=>a>=o?0:a+1):void 0,className:(0,w.cn)("overflow-hidden",o>0&&"cursor-pointer",e),children:r}),o>0&&(0,d.jsxs)("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 flex-col items-center gap-0.5",children:[(0,d.jsx)(fs,{look:g.ChevronUp,label:"Earlier lines",shown:k<o,onPick:()=>l(a=>Math.min(o,a+1))}),(0,d.jsx)(fs,{look:f.ChevronDown,label:"Later lines",shown:k>0,onPick:()=>l(a=>Math.max(0,a-1))})]})]})}function fs({look:a,label:b,shown:c,onPick:e}){return(0,d.jsx)("button",{type:"button","aria-label":b,"aria-hidden":!c,tabIndex:c?void 0:-1,onClick:a=>{a.stopPropagation(),e()},className:(0,w.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",!c&&"invisible"),children:(0,d.jsx)(a,{className:"size-3.5"})})}let ft=[{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 fu({live:a,getMicSpectrum:b}){let c=(0,s.useRef)({}),e=(0,s.useRef)(ft.map(()=>0));return(0,s.useEffect)(()=>{if(!a||!b)return;let d=requestAnimationFrame(function a(){let f=b();ft.forEach((a,b)=>{let d=0;for(let b=a.from;b<a.to;b++)d=Math.max(d,f[b]??0);let g=Math.min(1,(d*a.gain)**.8),h=e.current[b],i=h+(g-h)*(g>h?.6:.16);e.current[b]=i;let j=c.current[a.id];j&&(j.style.height=`${2+12*i}px`)}),d=requestAnimationFrame(a)});return()=>cancelAnimationFrame(d)},[a,b]),(0,d.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-[18px] shrink-0 items-center gap-0.5",children:ft.map(a=>(0,d.jsx)("span",{ref:b=>{c.current[a.id]=b},style:{height:2},className:"w-0.5 rounded-full bg-muted-foreground/70"},a.id))})}function fv({live:a,getMicSpectrum:b}){return(0,d.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] leading-5 text-muted-foreground",children:[(0,d.jsx)(fu,{live:a,getMicSpectrum:b}),"Listening"]})}function fw({tool:a}){let b="relay"===a.kind?j:(0,a8.toolIcon)(a.name),c=a.line??a.name,e=a.line?"min-w-0 truncate text-[13px] leading-5 break-keep":"min-w-0 truncate font-mono text-xs leading-5",f=(0,U.useServerRoute)(t.queryKey.bot).data,g=a.bot?f?.find(b=>b.name===a.bot)??null:null;return(0,d.jsxs)("span",{className:"flex max-w-full items-center gap-1.5",children:[(0,d.jsxs)("span",{className:"relative grid size-[18px] shrink-0 place-items-center",children:[(0,d.jsx)(fx,{tool:a,bot:g,icon:b}),!a.done&&(0,d.jsx)("span",{className:"absolute inset-0 grid animate-ink place-items-center",children:(0,d.jsx)(fx,{tool:a,bot:g,icon:b,running:!0})})]}),a.done&&a.sources?.length?(0,d.jsx)(B.SourceChips,{sources:a.sources,limit:2,className:"flex-nowrap"}):a.done?(0,d.jsx)("span",{className:(0,w.cn)(e,"text-muted-foreground"),children:c}):(0,d.jsx)(A.ShinyText,{text:c,className:e})]})}function fx({tool:a,bot:b,icon:c,running:e}){return a.bot?(0,d.jsx)("span",{className:(0,w.cn)("flex",!e&&!a.done&&"opacity-40"),children:(0,d.jsx)(H.BotMark,{size:16,seed:a.bot,color:b?.icon?.color,shape:b?.icon?.shape,outline:b?.icon?.outline,paint:b?.icon?.paint,notify:!1})}):(0,d.jsx)(c,{className:(0,w.cn)("size-3.5",e?"text-foreground":"text-muted-foreground",!e&&!a.done&&"opacity-40")})}function fy({tool:a,toolUp:b,thinkingSince:c,thinkingTitle:e,micOpen:f,getMicSpectrum:g}){let[h,i]=(0,s.useState)(a);(0,s.useEffect)(()=>{a&&i(a)},[a]);let{thought:j,title:k}=function(a,b){let[c,d]=(0,s.useState)(null!==a),[e,f]=(0,s.useState)(b);return(0,s.useEffect)(()=>{null!==a&&(d(!0),f(b))},[a,b]),{thought:c,title:e}}(c,e),l=null!==a,m=null!==c&&!b,n=f&&!l&&!m,o=a=>f&&(0,d.jsx)(fu,{live:a,getMicSpectrum:g});return(0,d.jsx)("div",{className:"flex h-7 max-w-full items-center justify-center",children:(0,d.jsxs)("div",{className:"grid min-w-0 items-center justify-items-center",children:[h&&(0,d.jsx)(fJ,{at:"col-start-1 row-start-1 max-w-full",shown:l,children:(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[o(l),(0,d.jsx)(fw,{tool:h})]})}),j&&(0,d.jsx)(fJ,{at:"col-start-1 row-start-1 max-w-full",shown:m,children:(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[o(m),(0,d.jsx)(fR,{title:k})]})}),(0,d.jsx)(fJ,{at:"col-start-1 row-start-1",shown:n,children:(0,d.jsx)(fv,{live:n,getMicSpectrum:g})})]})})}let fz=[1,.7,.45],fA=a=>a.id??`${a.kind??"tool"}:${a.name}`,fB={turns:{},owner:{},seen:{}};function fC({lines:a,shown:b}){let c=Math.max(0,a.length-3),e=a.length-c;return(0,d.jsx)("div",{"aria-hidden":!b,className:(0,w.cn)("pointer-events-auto relative w-full transition-opacity duration-300 ease-out",!b&&"pointer-events-none opacity-0"),style:{height:26*e},children:a.map((b,e)=>{let f=e-c;return(0,d.jsx)("div",{style:{transform:`translateY(${26*f}px)`,opacity:f<0?0:fz[a.length-1-e],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,d.jsx)("div",{className:"flex min-w-0 animate-in duration-300 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",children:(0,d.jsx)(fw,{tool:b})})},fA(b))})})}let fD={text:"CALL",hold:1/0},fE="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 fF({ringing:a,wakePhrase:b,onAnswer:c,onDecline:e}){let f=(0,U.useServerRoute)(t.queryKey.bot).data,g=(a,b)=>{let c=f?.find(b=>b.name===a.bot)?.icon;return(0,d.jsx)(H.BotMark,{size:b,seed:a.bot,color:c?.color,shape:c?.shape,outline:c?.outline,paint:c?.paint,notify:!1,className:"shrink-0"})},{first:h,others:i,missedAt:j}=a,[k,l]=(0,N.useAnswerThread)(),[m,n]=(0,s.useState)(null);if(null!==j){let a=[h,...i];return(0,d.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,d.jsxs)("div",{className:"flex w-full max-w-140 flex-col text-left",children:[(0,d.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,d.jsx)(o,{className:"size-3"}),(0,d.jsxs)("span",{children:["Missed · ",(0,d.jsx)(fG,{at:j})]}),(0,d.jsxs)("button",{type:"button",onClick:e,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,d.jsx)("kbd",{className:fE,children:"Esc"}),"clear"]})]}),a.slice(0,3).map(a=>(0,d.jsxs)("div",{className:"flex h-8.5 items-center gap-2.5",children:[g(a,20),(0,d.jsx)("span",{className:"w-32 shrink-0 truncate text-[13.5px]",children:a.label}),(0,d.jsx)("span",{className:"w-14 shrink-0 font-mono text-[10.5px] text-muted-foreground",children:fI[a.kind]}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px] text-muted-foreground",children:(0,w.plainText)(a.text)})]},a.id)),a.length>3&&(0,d.jsxs)("p",{className:"mt-1 font-mono text-[10.5px] text-muted-foreground",children:["+",a.length-3," more in the room"]})]}),(0,d.jsx)(u.Button,{variant:"brand",onClick:c,className:"mt-5 h-12 px-8 text-[15px]",children:"Call back"}),b&&(0,d.jsxs)("span",{className:"mt-3 flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground",children:["or say ",(0,d.jsx)(fH,{phrase:b})]})]})}return(0,d.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,d.jsxs)("span",{className:"flex max-w-full items-center gap-2 text-sm",children:[g(h,18),(0,d.jsx)("span",{children:h.bot}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,d.jsx)("span",{className:"truncate text-muted-foreground",children:h.label})]}),(0,d.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,w.plainText)(h.text)}),h.options.length>0&&(0,d.jsx)("span",{className:"flex max-w-full flex-wrap justify-center gap-1.5",children:h.options.map(a=>(0,d.jsx)(u.Button,{size:"sm",variant:"secondary",loading:m===a,disabled:l,onClick:async()=>{n(a),await k(h,a,h.bot,h.questionId??void 0),n(null)},className:"h-7 max-w-60 rounded-full px-3 text-[12.5px]",children:(0,d.jsx)("span",{className:"truncate",children:a})},a))}),(0,d.jsx)(u.Button,{variant:"brand",onClick:c,className:"mt-3 h-12 px-8 text-[15px]",children:"Answer"}),i.length>0&&(0,d.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:[i.slice(0,2).map(a=>(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[g(a,16),(0,d.jsx)("span",{className:"max-w-44 truncate text-foreground",children:a.label}),fI[a.kind]]},a.id)),i.length>2&&(0,d.jsxs)("span",{children:["+",i.length-2]})]}),(0,d.jsxs)("span",{className:"mt-1 flex items-center gap-3 font-mono text-[11px] text-muted-foreground",children:[b&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",children:["say ",(0,d.jsx)(fH,{phrase:b})," to answer"]}),(0,d.jsxs)("button",{type:"button",onClick:e,className:"flex items-center gap-2 rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,d.jsx)("kbd",{className:fE,children:"Esc"}),"not now"]})]})]})}function fG({at:a}){let[b,c]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{let a=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(a)},[]),b-a<6e4?"just now":(0,e.formatDistanceStrict)(a,b,{addSuffix:!0})}function fH({phrase:a}){return(0,d.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-foreground/80",children:[(0,d.jsx)(k.Mic,{className:"size-3"}),a]})}let fI={question:"asks",done:"finished",stopped:"stopped"};function fJ({at:a,shown:b,children:c}){return(0,d.jsx)("span",{"aria-hidden":!b,className:(0,w.cn)("flex transition-opacity duration-300 ease-out",a,b?"opacity-100":"pointer-events-none opacity-0"),children:c})}let fK={quiet:`${D.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 fL({status:a,idleLeft:b,since:c,ended:e,behind:f,wakePhrase:g,hotkeyLabel:h}){let i,j,k="connecting"===a||"ending"===a,l="idle"!==a&&!k;return k?(j=a,i=(0,d.jsx)(A.ShinyText,{text:"connecting"===a?"Connecting…":"Ending…",className:"text-muted-foreground/70"})):l&&null!==b?(j="quiet",i=`Quiet — ending in ${b}s. Say anything to stay.`):l?(j=f?"behind":"live",i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"Tap Thursday to end"}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),f?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("kbd",{className:fE,children:"↓"}),(0,d.jsx)("span",{children:"back to now"})]}):(0,d.jsx)(fS,{since:c}),(0,d.jsx)(fM,{})]})):e?(j=`ended:${e}`,i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:["Ended — ",fK[e]]}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,d.jsx)("span",{children:"Tap to call again"})]})):g?(j=`wake:${g}`,i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.Letters,{text:"Tap Thursday, or say"}),(0,d.jsx)(fO,{at:500,children:(0,d.jsx)(fH,{phrase:g})}),(0,d.jsx)(fO,{at:fN,children:(0,d.jsx)(fP,{})})]})):h?(j=`key:${h}`,i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.Letters,{text:"Tap Thursday, or press"}),(0,d.jsx)(fO,{at:550,children:(0,d.jsx)("kbd",{className:fE,children:h})}),(0,d.jsx)(fO,{at:fN,children:(0,d.jsx)(fP,{})})]})):(j="tap",i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.Letters,{text:"Tap Thursday to talk"}),(0,d.jsx)(fO,{at:fN,children:(0,d.jsx)(fP,{})})]})),(0,d.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:i},j)}function fM(){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,d.jsx)("button",{type:"button",onClick:()=>V.writeLine.draw(),className:"rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"Draw"})]})}let fN=900;function fO({at:a,children:b}){return(0,d.jsx)("span",{style:{animationDelay:`${a}ms`},className:"flex animate-in items-center gap-1.5 duration-700 fill-mode-backwards fade-in",children:b})}function fP(){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"px-1.5 text-muted-foreground/30",children:"·"}),(0,d.jsx)("span",{className:"text-muted-foreground",children:"@ to write"})]})}function fQ({open:a,onOpen:b,onClose:c}){let{data:e}=(0,U.useServerRoute)(t.queryKey.automaticModel),{data:f}=(0,U.useServerRoute)(t.queryKey.config),g=E.LIVE_LINES.find(a=>(0,ba.isConfigUnreadable)(f,F.TEXT_MODEL_PROVIDERS[a].apiKeyName)),h=(0,a9.useVoiceLine)(),i=h.signedIn&&!h.planCalls;return a?(0,d.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,d.jsxs)("div",{className:"flex h-6 items-center justify-between gap-2 pl-0.5",children:[(0,d.jsx)("span",{className:"text-[13px] font-medium",children:"Give her a voice"}),(0,d.jsx)(u.Button,{type:"button",size:"icon",variant:"ghost","aria-label":"Not now",onClick:c,className:"-my-1 size-6",children:(0,d.jsx)(q.X,{className:"size-3.5"})})]}),(0,d.jsx)(a9.CallLines,{})]}):(0,d.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,d.jsxs)("span",{className:"relative flex size-6 shrink-0 items-center justify-center",children:[(0,d.jsx)(H.BotMark,{size:24,seed:G.DEFAULT_BOT.name,color:G.DEFAULT_BOT.icon?.color,shape:G.DEFAULT_BOT.icon?.shape,outline:G.DEFAULT_BOT.icon?.outline,notify:!1}),(0,d.jsx)(m,{className:"absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full bg-muted text-muted-foreground"})]}),(0,d.jsx)("span",{className:"text-[13px] text-muted-foreground break-keep wrap-anywhere",children:"chatgpt"===g?"The ChatGPT sign-in saved for calls can't be unlocked any more — sign in again.":g?"The key saved for calls can't be unlocked any more — add it again.":i?`Your ${(0,F.planName)(h.plan)?`${(0,F.planName)(h.plan)} `:""}ChatGPT plan has no spoken calls — add an OpenAI key. Bots and writing already run on it.`:e&&!e.ref?"Sign in with ChatGPT and calls and bots run on your plan, or add a key.":"Calls need a GPT Subscription or an OpenAI key. Everything else here already works."}),(0,d.jsx)(u.Button,{size:"sm",variant:"brand",onClick:b,className:"h-7 px-3.5",children:"Set up"})]})}function fR({title:a}){let b=a?`Thinking \xb7 ${a}`:"Thinking";return(0,d.jsx)("span",{className:"flex max-w-full items-center text-[13px] leading-5",children:(0,d.jsx)(A.ShinyText,{text:b,className:"min-w-0 animate-in truncate fade-in duration-300"},b)})}function fS({since:a}){let[b,c]=(0,s.useState)(()=>Date.now());if((0,s.useEffect)(()=>{if(null===a)return;let b=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(b)},[a]),null===a)return null;let e=Math.max(0,Math.floor((b-a)/1e3)),f=String(Math.floor(e/60)).padStart(2,"0"),g=String(e%60).padStart(2,"0");return(0,d.jsxs)("span",{className:"tabular-nums",children:[f,":",g]})}a.s(["Thursday",0,function({ready:b}){let c=function(){let[a,b]=(0,s.useState)(null),c=(0,s.useRef)(a);c.current=a;let d=(0,s.useRef)(new Set),[e]=(0,an.useServerAction)(cO),f=(0,s.useRef)(null),g=(0,s.useRef)([]),[h,i]=(0,s.useState)([]),j=(0,s.useCallback)(a=>{g.current=a,i(a)},[]),k=(0,s.useRef)(new Map),l=(0,s.useRef)(0),[m,n]=(0,s.useState)(null),o=(0,s.useRef)(()=>{}),p=(0,s.useRef)(!1),[q,r]=(0,s.useState)(null),{messages:u,sendMessage:v,setMessages:x,status:y,stop:z,error:A,clearError:B}=(0,cy.useChat)({transport:c$,onFinish:a=>o.current(a),onData:a=>{if(a.type===`data-${cv.TEXT_CALL_REFUSED}`)return r(a.data.provider);a.type!==`data-${cv.TEXT_CALL_MOVED}`||p.current||(p.current=!0,cA.toast.add({type:"warning",title:"Answering on your OpenAI key",description:a.data.why}))}}),C="submitted"===y||"streaming"===y,E=(0,s.useRef)(u);E.current=u;let F=(0,s.useRef)(A);F.current=A;let G=(0,s.useRef)(""),H=(0,s.useCallback)((a,b=[])=>{let d=c.current;if(!d)return;let e=g.current;j([]);let h=crypto.randomUUID();f.current=h,r(null);let i=c_();G.current=JSON.stringify(i??null);let k=[...e.map(c0),...a?[{type:"text",text:a}]:[],...b.map(cv.picturePart)];v(k.length?{parts:k}:void 0,{body:{callId:d.callId,standing:d.standing,runsOn:i,turn:h,where:d.where}})},[v,j]),I=(0,s.useCallback)(()=>{let a=c.current;if(a){for(let a of(c.current=null,b(null),f.current=null,k.current.values()))cF.delete(a.key);k.current.clear(),j([]),l.current=0,p.current=!1,n(null),z(),x([]),B(),cN(a.callId).then(cE.unwrapResult).finally(()=>(0,U.revalidate)(t.queryKey.callHistory(null)))}},[z,x,B,j]),J=(0,s.useRef)(I);J.current=I,(0,s.useEffect)(()=>()=>J.current(),[]);let K=(0,s.useCallback)(a=>{j([...g.current,a]);let b=c.current,d=f.current;b&&d&&cP(b.callId,d,a).then(cE.unwrapResult).catch(()=>{})},[j]);(0,s.useEffect)(()=>V.screenActs.subscribe(a=>{c.current&&K({id:crypto.randomUUID(),text:cM(a),said:!1})}),[K]);let L=(0,s.useCallback)(async(a,g=[])=>{let h=g.filter(cD.isPicture),i=c.current;if(!i){let a=cY();c.current=i={...await e(c_()),at:Date.now(),where:a?.where??null},d.current=cG(O.current??[]),b(i)}if(l.current=0,f.current)return K({id:crypto.randomUUID(),text:a,said:!0,...h.length?{pictures:h}:{}});B(),H(a,h)},[e,K,B,H]),M=(0,s.useCallback)(()=>{let a=E.current,b=a.at(-1);if(c.current&&b){if("assistant"===b.role){let c=G.current!==JSON.stringify(c_()??null)?-1:b.parts.findLastIndex(a=>(0,cz.isToolUIPart)(a)&&!a.providerExecuted&&("output-available"===a.state||"output-error"===a.state));j([...(0,cv.notesIn)([{...b,parts:b.parts.slice(c+1)}]),...g.current]),x(c<0?a.slice(0,-1):[...a.slice(0,-1),{...b,parts:b.parts.slice(0,c+1)}])}B(),H(null)}},[H,x,B,j]),{data:N}=(0,U.useServerRoute)(t.queryKey.threads),O=(0,s.useRef)(N);O.current=N;let P=(0,s.useCallback)(()=>{if(!c.current||!O.current)return;let a=cL(O.current),b=new Set(a.map(a=>a.key)),e=g.current.filter(a=>{let c=k.current.get(a.id);return void 0!==c&&!b.has(c.key)});if(e.length){for(let a of e){let b=k.current.get(a.id);b&&cF.delete(b.key),k.current.delete(a.id)}j(g.current.filter(a=>!e.includes(a)))}for(let b of a){if(cF.has(b.key)||d.current.has(b.key))continue;cF.add(b.key);let a={id:crypto.randomUUID(),text:b.line,said:!1};k.current.set(a.id,{key:b.key,rows:b.relayIds,show:b.show}),f.current&&n(b.show),K(a)}if(f.current||F.current||l.current>=D.TEXT_CALL.autoTurns)return;let h=g.current.filter(a=>k.current.has(a.id)),i=h.length?k.current.get(h[h.length-1].id):null;i&&(l.current+=1,n(i.show),H(null))},[j,K,H]),Q=null!==a;(0,s.useEffect)(()=>{Q&&N&&P()},[Q,N,P]),o.current=({message:a,messages:b,isAbort:d,isError:e,isDisconnect:h})=>{if(d||!c.current)return;f.current=null;let i=new Set((0,cv.notesIn)([a]).map(a=>a.id));if(j(g.current.filter(a=>!i.has(a.id))),e||h)return;let l=new Set((0,cv.notesIn)(b).map(a=>a.id)),m=[];for(let[a,b]of k.current)l.has(a)&&(m.push(...b.rows),k.current.delete(a));if(m.length&&cC(m).then(cE.unwrapResult).catch(a=>cA.toast.add({type:"error",title:"Could not record relay delivery",description:(0,w.errorToString)(a)})),g.current.some(a=>a.said))return H(null);P()},(0,s.useEffect)(()=>{if(C||!m)return;let a=setTimeout(()=>n(null),D.CALL_LINE.lingerMs);return()=>clearTimeout(a)},[C,m]);let R=u.at(-1)?.role==="assistant"?u.at(-1):null,S=R?.parts??[],T=S.at(-1),W=(0,s.useMemo)(()=>{let a=[],b=!1,c=(c,d,e)=>{if(!e)return;let f=b&&"assistant"===d;"assistant"===d&&(b=!1),a.push({id:c,role:d,text:e,...f?{fresh:!0}:{}})};for(let a of u){if("system"===a.role)continue;let d=a.role,e=[],f=0,g=()=>{let b=e.join("\n\n").trim();e=[],c(`${a.id}:${f++}`,d,"assistant"===d?(0,w.captionText)(b):b)};for(let d of a.parts){"text"===d.type&&e.push(d.text);let a=(0,cv.noteOf)(d);a&&(g(),a.said?c(a.id,"user",a.text):b=!0)}g()}let d=new Set((0,cv.notesIn)(u).map(a=>a.id));for(let a of h)a.said&&!d.has(a.id)&&c(a.id,"user",a.text);return a},[u,h]),X=[...S].reverse().find(cz.isToolUIPart),Y=X?.toolCallId??null,Z=X?(0,cz.getToolName)(X):null,$=X?.state==="output-available"||X?.state==="output-error",_=X?.output,aa=(0,s.useMemo)(()=>$&&Z===cB.TOOL_NAMES.web_search?(0,cQ.searchSourcesOf)(JSON.stringify(_??null)):[],[$,Z,_]),ab=_?.action?.query,ac=JSON.stringify({..."string"==typeof ab?{query:ab}:{},...X?.input??{}}),ad=Z?(0,cQ.toolBot)(Z,ac,O.current,void 0===_?void 0:JSON.stringify(_)):null,ae=Z?(0,cQ.toolLine)(Z,ac,ad):null,af=T?.type==="text",ag=(0,s.useMemo)(()=>Y&&Z&&(!af||aa.length)?{id:Y,name:Z,line:ae,bot:ad,done:$,...aa.length?{sources:aa}:{}}:null,[Y,Z,ae,ad,$,aa,af]),[ah,ai]=(0,s.useState)(null),aj=ag?.done&&!ag.sources?ag.id:null;(0,s.useEffect)(()=>{if(!aj)return;let a=setTimeout(()=>ai(aj),D.CALL_LINE.lingerMs);return()=>clearTimeout(a)},[aj]);let ak=ag&&ag.id!==ah?ag:m,al=!!C&&T?.type!=="text"&&(!ag||!!ag.done),[am,ao]=(0,s.useState)(null);(0,s.useEffect)(()=>{ao(al?Date.now():null)},[al]);let ap=[...S].reverse().find(a=>"reasoning"===a.type),aq=al&&ap?.type==="reasoning"&&(0,cQ.reasoningTitle)(ap.text)||null,ar=a?C?T?.type==="text"?"speaking":ag&&!ag.done&&ag.name===cB.TOOL_NAMES.thread_start?"delegating":"working":"listening":"idle";return{on:null!==a,busy:C,status:ar,messages:W,tool:ak,thinkingSince:am,thinkingTitle:aq,since:a?.at??null,error:A?A.message:null,refused:A?q:null,say:L,again:M,end:I}}(),{status:e,failed:f,messages:g,tool:h,thinkingSince:i,thinkingTitle:j,ended:k,faceWord:l,idleLeft:m,since:n,call:o,ringing:p,decline:q,getSpectrum:r,getMicSpectrum:u,wakePhrase:v,hotkey:x}=function(b=!1){let c=(0,s.useRef)(null),{data:d}=(0,U.useServerRoute)(t.queryKey.thursdaySettings),e=(0,s.useRef)(null);e.current=(0,a9.useVoiceLine)(d?.runsOn??null).line;let f=(0,s.useRef)(null),g=(0,s.useRef)(null),[h,i]=(0,s.useState)("idle"),[j,k]=(0,s.useState)(!1),l=(0,s.useRef)(null),m=(0,s.useCallback)(a=>{l.current&&clearTimeout(l.current),l.current=a?setTimeout(()=>k(!1),6e3):null,k(a)},[]),[n,o]=(0,s.useState)([]),[p,q]=(0,s.useState)(null),[r,u]=(0,s.useState)(null),[v,x]=(0,s.useState)(null),[y,z]=(0,s.useState)(null),[A,B]=(0,s.useState)(null),[C,F]=(0,s.useState)(null),[G,H]=(0,s.useState)(null),I=ct(),J=I?.moment.kind==="here"&&null!==I.phase;(0,s.useEffect)(()=>{J&&function(a=new Date){let b=em(a);try{window.localStorage.setItem(el,b)}catch{en=b}}()},[J]),(0,s.useEffect)(()=>{let a,b,c;return b=!1,(c=async()=>{if(clearTimeout(a),"visible"!==document.visibilityState||(a=setTimeout(c,D.HERE.keptMs),await cZ(),b||"visible"!==document.visibilityState))return;let d=cR?cR.at+D.HERE.keptMs-D.HERE.lookMs-Date.now():0;clearTimeout(a),a=setTimeout(c,d>0?d:D.HERE.keptMs)})(),document.addEventListener("visibilitychange",c),window.addEventListener("online",c),()=>{b=!0,clearTimeout(a),document.removeEventListener("visibilitychange",c),window.removeEventListener("online",c)}},[]);let L=(0,s.useRef)(null),M=(0,s.useRef)(null),N=(0,s.useRef)({on:!1,spoke:!1,giveUp:null}),O=(0,s.useRef)(null),P=(0,s.useRef)(0),R=(0,s.useRef)(null),T=(0,s.useRef)(!1),W=(0,s.useRef)(null),X=(0,s.useRef)(null),Y=(0,s.useRef)(null),Z=(0,s.useRef)(cF),$=(0,s.useRef)(new Set),_=(0,s.useRef)(new Set),aa=(0,s.useRef)([]),ab=(0,s.useRef)([]),ac=(0,s.useRef)(0),ad=(0,s.useRef)(null),ae=(0,s.useRef)(0),af=(0,s.useRef)(!1),ag=(0,s.useRef)(!1),ah=(0,s.useRef)(void 0),ai=(0,s.useRef)(null),aj=ai.current??=ei(),ak=(0,s.useRef)(null),al=ak.current??=ei(),am=(0,s.useRef)(!1),an=(0,s.useRef)(!1),ao=(0,s.useRef)(!1),ap=(0,s.useRef)(0),aq=(0,s.useCallback)(a=>{R.current&&clearTimeout(R.current),T.current=!1;let b=(0,cQ.toolBot)(a.name,a.arguments,ah.current);q({id:a.id,name:a.name,line:(0,cQ.toolLine)(a.name,a.arguments,b),bot:b,done:!1})},[]),ar=(0,s.useCallback)((a,b)=>{let c=(0,cQ.toolBot)(a.name,a.arguments,ah.current,b);c&&q(b=>b?.id===a.id&&b.bot!==c?{...b,bot:c,line:(0,cQ.toolLine)(a.name,a.arguments,c)}:b)},[]),as=(0,s.useCallback)(a=>{R.current&&clearTimeout(R.current),T.current=!0,q({...a,done:!1})},[]),at=(0,s.useCallback)(a=>{q(b=>b?.id===a?{...b,done:!0}:b),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>q(a=>a?.done?null:a),D.CALL_LINE.lingerMs)},[]),au=(0,s.useCallback)(()=>{if(N.current.giveUp&&clearTimeout(N.current.giveUp),N.current.spoke){for(let a of aa.current)$.current.delete(a);let a=ab.current;a.length&&cC(a).then(cE.unwrapResult).catch(a=>cA.toast.add({type:"error",title:"Could not record relay delivery",description:(0,w.errorToString)(a)}))}ab.current=[],aa.current=[],N.current={on:!1,spoke:!1,giveUp:null},T.current&&(T.current=!1,q(a=>a?.kind==="relay"?{...a,done:!0}:a),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>q(a=>a?.kind==="relay"?null:a),D.CALL_LINE.relayLingerMs))},[]),av=(0,s.useCallback)(()=>{N.current.giveUp&&clearTimeout(N.current.giveUp),N.current={on:!0,spoke:!1,giveUp:setTimeout(au,D.CALL_RELAY.readMs)}},[au]),aw=(0,s.useCallback)(a=>{L.current=a,B(a),F(null)},[]),ax=(0,s.useCallback)((a,b)=>{let c=()=>{M.current&&clearTimeout(M.current),M.current=null};if(b){c(),null!==L.current&&aw(null);return}if(a){c(),null===L.current&&aw(Date.now());return}null===L.current||M.current||(M.current=setTimeout(()=>{M.current=null,aw(null)},D.CALL_LINE.thinkingTailMs))},[aw]),ay=(0,s.useCallback)(()=>{let a=c.current,b=ah.current;if(!a||!b||N.current.on||ag.current||null!==L.current||ad.current)return;let d=af.current;if(af.current=!1,!d&&Date.now()-ae.current<D.CALL_RELAY.quietMs)return;let e=cL(b).filter(a=>!Z.current.has(a.key)&&!_.current.has(a.key)),f=e[0];if(!f)return;let g=e.filter(a=>a.kind===f.kind).slice(0,D.CALL_RELAY.perTurn),h=g.map(a=>a.line);for(let a of g)Z.current.add(a.key),$.current.add(a.key);f.key.startsWith("done:")&&!cs.current()&&H((0,ek.finished)()),av(),aa.current=g.map(a=>a.key),ab.current=g.flatMap(a=>a.relayIds),as((g.at(-1)??f).show),a.append("commentary",1===h.length?h.join(""):`[${h.length} updates.]
|
|
10
|
+
${d}`)}formatType(a,b,c){let d=d0[a.type]||d1[a.level]||"gray";if(b)return(function(a="bgWhite"){return dv[`bg${a[0].toUpperCase()}${a.slice(1)}`]||dv.bgWhite})(d)(dv.black(` ${a.type.toUpperCase()} `));let e="string"==typeof d4[a.type]?d4[a.type]:a.icon||a.type;return e?(function(a="white"){return dv[a]||dv.white})(d)(e):""}formatLogObj(a,b){let c,[d,...e]=this.formatArgs(a.args,b).split("\n");if("box"===a.type)return function(a,b={}){let c={...b,style:{...dA,...b.style}},d=a.split("\n"),e=[],f=dw(c.style.borderColor),g={..."string"==typeof c.style.borderStyle?dz[c.style.borderStyle]||dz.solid:c.style.borderStyle};if(f)for(let a in g)g[a]=f(g[a]);let h=c.style.padding%2==0?c.style.padding:c.style.padding+1,i=d.length+h,j=Math.max(...d.map(a=>dy(a).length),c.title?dy(c.title).length:0)+h,k=j+h,l=c.style.marginLeft>0?" ".repeat(c.style.marginLeft):"";if(c.style.marginTop>0&&e.push("".repeat(c.style.marginTop)),c.title){let a=f?f(c.title):c.title,b=g.h.repeat(Math.floor((j-dy(c.title).length)/2)),d=g.h.repeat(j-dy(c.title).length-dy(b).length+h);e.push(`${l}${g.tl}${b}${a}${d}${g.tr}`)}else e.push(`${l}${g.tl}${g.h.repeat(k)}${g.tr}`);let m="center"===c.style.valign?Math.floor((i-d.length)/2):"top"===c.style.valign?i-d.length-h:i-d.length;for(let a=0;a<i;a++)if(a<m||a>=m+d.length)e.push(`${l}${g.v}${" ".repeat(k)}${g.v}`);else{let b=d[a-m],c=" ".repeat(h),f=" ".repeat(j-dy(b).length);e.push(`${l}${g.v}${c}${b}${f}${g.v}`)}return e.push(`${l}${g.bl}${g.h.repeat(k)}${g.br}`),c.style.marginBottom>0&&e.push("".repeat(c.style.marginBottom)),e.join("\n")}(d7(d+(e.length>0?"\n"+e.join("\n"):"")),{title:a.title?d7(a.title):void 0,style:a.style});let f=this.formatDate(a.date,b),g=f&&dv.gray(f),h=a.badge??a.level<2,i=this.formatType(a,h,b),j=a.tag?dv.gray(a.tag):"",k=this.filterAndJoin([i,d7(d)]),l=this.filterAndJoin(b.columns?[j,g]:[j]),m=(b.columns||0)-d5(k)-d5(l)-2;if(c=(m>0&&(b.columns||0)>=80?k+" ".repeat(m)+l:(l?`${dv.gray(`[${l}]`)} `:"")+k)+d7(e.length>0?"\n"+e.join("\n"):""),"trace"===a.type){let b=Error("Trace: "+a.message);c+=this.formatStack(b.stack||"",b.message)}return h?"\n"+c+"\n":c}}function d7(a){return a.replace(/`([^`]+)`/gm,(a,b)=>dv.cyan(b)).replace(/\s+_([^_]+)_\s+/gm,(a,b)=>` ${dv.underline(b)} `)}function d8(b={}){let c=dM?4:dN?1:3;return process.env.CONSOLA_LEVEL&&(c=Number.parseInt(process.env.CONSOLA_LEVEL)??c),function(a={}){return new da(a)}({level:c,defaults:{level:c},stdout:process.stdout,stderr:process.stderr,prompt:(...b)=>a.A(715837).then(a=>a.prompt(...b)),reporters:b.reporters||[b.fancy??!(dK||dN)?new d6:new dg],...b})}d8();let d9=d8({level:D.IS_DEV?4:3}),ea=(b=D.APP_NAME,d9.withDefaults({message:(c=`${b}: `,dw("blackBright")(c))}));var eb=a.i(249890);let ec={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},ed=new TextEncoder;async function ee(a){let b=eg(a);try{return await b.connect(),b}catch(a){throw await b.close(),a}}let ef=["response.completed","response.failed","response.incomplete","response.cancelled"],eg=({initialize:a,audio:b,on:c})=>{let d,e,f,g,h,i,j,k,l,m=!1,n=!1,o=!1,p=0,q=0,r="",s=[],t=new Set,u=new Set,v=new Set,x=new Map,y=!1,z=new Map,A=new Map,B=[],C=null,E=-1/0,F=null,G=()=>{clearTimeout(l),!F||F.unmute||o||n||(F.unmute=crypto.randomUUID(),Y.send({type:"session.input_audio.unmute",event_id:F.unmute}))},H=()=>{for(let a of(clearTimeout(j),j=void 0,t))c.turn({...a.turn,fragments:[...a.fragments],done:!0});t.clear()},I=()=>{if(!o){for(let a of(o=!0,clearTimeout(h),clearTimeout(k),clearTimeout(l),R&&clearTimeout(R.timer),R=null,clearInterval(i),H(),C=null,B.splice(0)))a.settle(!1);Y.close(),f?.()}},J=a=>{e?.(Error(a)),I(),m&&!n?c.failed(a):n&&c.warn(a)},K=-1/0,L=()=>{if(o||n)return;let a=performance.now(),d=b.levels?.();d&&d.output>.01&&(E=a);let e={speaking:a-E<300,working:[...x.values()].some(a=>!a.terminal)||A.size>0||a-K<5e3,tools:[...A.values()]},f=JSON.stringify(e);(f!==r||e.speaking||e.working)&&(r=f,c.activity(e))},M=()=>{if(!m||o||n||C||!B.length)return;let[a]=B;C=crypto.randomUUID(),Y.send({type:`session.${a.kind}.append`,event_id:C,delegation_id:null,content:a.chunks[0]}),k=setTimeout(()=>{c.warn("Live did not acknowledge the conversation update; delivery is unknown."),N(!1)},D.LIVE_CALL.appendMs)},N=a=>{clearTimeout(k),C=null;let[b]=B;b&&(a&&b.chunks.shift(),a&&b.chunks.length||(B.shift(),b.settle(a)),M())},O=(a,b)=>{if(!a.delta||void 0===a.start_ms||void 0===a.end_ms)return;let d=a.start_ms,e=a.end_ms,f=s.findLast(a=>a.turn.role===b&&d>=a.turn.seq-D.LIVE_CALL.transcriptGapMs&&d<=a.end+D.LIVE_CALL.transcriptGapMs&&("user"===b||!s.some(b=>"user"===b.turn.role&&b.turn.seq>a.turn.seq&&b.turn.seq<d)));f||(f={turn:{id:`live-${q++}`,role:b,text:"",seq:d,done:!1},end:e,fragments:[]},s.push(f)),f.fragments.push({start:d,end:e,text:a.delta}),f.fragments.sort((a,b)=>a.start-b.start),f.end=Math.max(f.end,e),f.turn.text=f.fragments.map(a=>a.text).join(""),c.turn({...f.turn,done:!1}),t.add(f),j??=setTimeout(H,D.LIVE_CALL.transcriptSaveMs)},P=()=>{K=performance.now(),Y.send({type:"response.create",event_id:crypto.randomUUID()})},Q=(a,b=!1)=>{for(let b of(a.settled=!0,a.held.splice(0)))"fact"in b?W(b.fact):X(b);let c=a.rerun;a.rerun=!1,c&&!b&&P()},R=null,S=()=>{let a=R;if((R=null,a)&&(clearTimeout(a.timer),!o&&!n)){for(let b of a.held)"fact"in b?W(b.fact):X(b);a.rerun&&P()}},T=()=>{let a,b=(a=[...x.values()].at(-1))&&!a.settled&&(!a.terminal||a.calls.size>0)?a:void 0;if(b)return b;let c=performance.now()-K;if(!(c>=5e3))return R??={held:[],rerun:!1,timer:setTimeout(S,5e3-c)}},U=async a=>{if(a.terminal&&!a.continued){if(!a.calls.size)return Q(a);a.continued=!0,await Promise.all(a.calls.values()),n||o||(Q(a,!0),P()),L()}},V=async a=>{a.continued=!0,a.calls.size&&await Promise.all(a.calls.values()),n||o||Q(a),L()},W=a=>Y.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"developer",content:[{type:"input_text",text:a}]}}),X=({image:a,path:b})=>{try{Y.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"user",content:[{type:"input_text",text:`${b}, as an image:`},{type:"input_image",image_url:a}]}})}catch(e){let d=(0,w.errorToString)(e);ea.warn("Live picture not sent",{reason:d,bytes:a.length}),W(`The picture of ${b} did not go through, so nothing on it was seen: ${d}`),c.warn(`${b} did not go through to her: ${d}`)}},Y=function({negotiate:a,audio:b,on:c}){let d,e,f,g=null,h=null,i=null,j=!1,k=!1,l=!1,m=null,n=null,o=!1,p=Promise.resolve(),q=!1,r=a=>{for(let b of a?.getTracks()??[])b.stop()},s=a=>{j||l||(l=!0,k?c.dropped(a):e?.(Error(a)))},t=()=>{!k&&q&&(!m||o)&&(k=!0,d?.())};return{async connect(){let k=new RTCPeerConnection;g=k;let l=k.createDataChannel("oai-events");h=l;let p=new Promise((a,b)=>{d=a,e=b});l.onopen=()=>{q=!0,t()},l.onclose=()=>s("The connection to OpenAI Live closed."),l.onerror=()=>s("The connection to OpenAI Live dropped."),k.onconnectionstatechange=()=>{["failed","closed"].includes(k.connectionState)&&s("Could not reach OpenAI Live.")},p.catch(()=>{}),l.onmessage=({data:a})=>{let b;if(!j&&!m&&"string"==typeof a){try{b=JSON.parse(a)}catch{c.dropped("OpenAI Live sent an unreadable event.");return}c.event(b)}},k.ontrack=a=>{if(j)return;let c=a.streams[0]??new MediaStream([a.track]);b.element.srcObject=c,b.listen(c)};let u=await navigator.mediaDevices.getUserMedia({audio:ec});if(j)throw r(u),Error("The call closed before connecting.");for(let a of(i=u,b.hear?.(u),u.getAudioTracks()))k.addTrack(a,u);await k.setLocalDescription(await k.createOffer()),"complete"!==k.iceGatheringState&&await new Promise((a,b)=>{let c=c=>{clearTimeout(e),k.removeEventListener("icegatheringstatechange",d),f=void 0,c?b(c):a()},d=()=>{"complete"===k.iceGatheringState&&c()},e=setTimeout(()=>c(Error("ICE gathering timed out.")),1e4);f=()=>c(Error("The call closed before connecting.")),k.addEventListener("icegatheringstatechange",d),d()});let v=k.localDescription?.sdp;if(!v||j)throw Error("No live SDP offer is available.");let w=await a(v);if(j)throw Error("The call closed before connecting.");if("string"!=typeof w){let a;m=w.relay,await (a=m,new Promise((b,d)=>{let e=new EventSource(a);n=e,e.onopen=()=>b(),e.onmessage=({data:a})=>{let b;if(!j&&"string"==typeof a){try{b=JSON.parse(a)}catch{c.dropped("The call on the plan sent an unreadable event.");return}c.event(b)}},e.onerror=()=>{e.close(),d(Error("Could not follow the call on the plan.")),s("The line to her on the plan dropped.")}})),o=!0}await k.setRemoteDescription({type:"answer",sdp:"string"==typeof w?w:w.sdp}),t(),await p},send(a){if(!j){if(m){let b=m;p=p.then(async()=>{let c=await fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:[a]})}),d=await c.json().catch(()=>null);if(!c.ok||!(0,cE.isResultOk)(d))throw Error((0,cE.isResultError)(d)&&d.message||`${c.status}`)}).catch(a=>{s(`The call on the plan did not take what was sent: ${a instanceof Error?a.message:String(a)}`)});return}h?.readyState==="open"&&h.send(JSON.stringify(a))}},limit:()=>m?D.PLAN_CALL.pictureBytes:g?.sctp?.maxMessageSize??null,relayed:()=>null!==m,hush(){r(i)},close:()=>{j||(j=!0,e?.(Error("The call closed before connecting.")),f?.(),r(i),i=null,n?.close(),h?.close(),g?.close(),b.element.srcObject=null)}}}({audio:b,negotiate:async b=>{let c=await a(b);if(!("string"==typeof c?c:c.sdp))throw Error("OpenAI Live returned no SDP answer.");return c},on:{event:a=>{if(!o){if(a.event_id){if(u.has(a.event_id))return;u.add(a.event_id)}switch(p=Math.max(p,a.offset_ms??0,a.end_ms??0),a.type){case"session.started":m=!0,d?.(),M();break;case"session.closed":c.finalized?.({reason:a.reason??"closed",seconds:a.usage?.seconds??null}),ea.info("Live session closed",{reason:a.reason,seconds:a.usage?.seconds}),e?.(Error("OpenAI Live closed before startup completed.")),I(),n||c.failed(`The Live call ended (${a.reason??"closed"}).`);break;case"session.input_transcript.delta":O(a,"user");break;case"session.output_transcript.delta":G(),O(a,"assistant");break;case"session.input_audio.unmuted":F&&a.client_event_id===F.unmute&&(F=null);break;case"session.instructions.appended":case"session.commentary.appended":case"session.thinking.appended":C&&a.client_event_id===C&&N(!0);break;case"error":{let b=a.error?.message??"OpenAI Live reported an error.";if(!m){J(b);break}if(F?.unmute&&a.error?.client_event_id===F.unmute){J(`She could not hear the microphone again: ${b}`);break}for(let d of(F&&a.error?.client_event_id===F.mute&&(clearTimeout(l),F=null),c.warn(b),C&&a.error?.client_event_id===C&&N(!1),x.values()))d.terminal||d.calls.size||(d.terminal=!0,d.stale=!0,Q(d));L();break}case"session.delegation.created":K=performance.now();break;case"response.event":{let b=a.event;if(!b||n)break;"response.created"===b.type&&(K=-1/0),"response.created"===b.type&&b.response&&a.delegation_id&&z.set(a.delegation_id,b.response.id);let d=b.response?.id??b.response_id??(a.delegation_id?z.get(a.delegation_id):void 0);if(!d)break;let e=x.get(d);if(!e){let a=[],b=!1;for(let c of x.values())c.settled||c.continued||(c.settled=!0,a.push(...c.held.splice(0)),b||=!!c.rerun);R&&(clearTimeout(R.timer),a.push(...R.held),b||=R.rerun,R=null),e={calls:new Map,held:a,terminal:!1,continued:!1,rerun:b},x.set(d,e)}if(e.stale&&!ef.includes(b.type)&&(e.stale=!1,e.terminal=!1,e.settled=!1),"response.reasoning_summary_text.done"===b.type&&c.reasoning?.({id:`${b.item_id}:${b.summary_index??0}`,text:b.text??"",seq:p}),("response.output_item.added"===b.type||"response.output_item.done"===b.type)&&b.item?.type===eb.LIVE_HOSTED_TOOLS.webSearch.item){let a=b.item,e="response.output_item.done"===b.type;e&&ea.debug("Live web search",a),c.search?.({id:a.id,responseId:d,query:(a.action?.query??a.action?.queries?.join(" · "))?.trim()||null,sources:[...new Set((a.action?.sources??[]).flatMap(a=>a.url?[a.url]:[]))].map(a=>({url:a})),done:e,seq:p})}if("response.output_item.done"===b.type&&b.item?.type==="message"){let a=function(a){let b=new Map;for(let c of a??[])for(let a of c.annotations??[])"url_citation"===a.type&&a.url&&!b.has(a.url)&&b.set(a.url,{url:a.url,...a.title?{title:a.title}:{}});return[...b.values()]}(b.item.content);a.length&&c.cited?.(d,a)}if("response.output_item.done"===b.type&&b.item?.type==="function_call"){let a=b.item;if(v.has(a.call_id))break;if(v.add(a.call_id),"incomplete"===a.status){e.terminal=!0,ea.warn("Live backend call cut off; not run",{responseId:d,name:a.name,arguments:a.arguments.slice(0,200)}),e.calls.size&&!y?(y=!0,U(e)):(y=!1,V(e));break}c.turn({id:a.id,role:"tool",tool:a.name,text:a.arguments,seq:p,done:!0}),H(),A.set(a.call_id,a.name);let f=Promise.resolve().then(()=>c.runTool({id:a.call_id,name:a.name,arguments:a.arguments,item:a.id})).catch(a=>`Error: ${(0,w.errorToString)(a)}`).then(b=>{A.delete(a.call_id),o||n||((a,b)=>{let c=b=>Y.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"function_call_output",call_id:a,output:b}});try{c(b)}catch(d){let a=(0,w.errorToString)(d);ea.warn("Live tool output not sent",{reason:a,chars:b.length});try{c(`Error: the result was too large to return (${b.length.toLocaleString("en")} characters: ${a}). Ask for a smaller part of it.`)}catch(a){ea.warn("Live tool output not answered",{reason:(0,w.errorToString)(a)})}}})(a.call_id,b),L()});e.calls.set(a.call_id,f),U(e)}ef.includes(b.type)&&(e.terminal=!0,e.stale=!1,"response.completed"===b.type?(y=!1,ea.debug("Live backend usage",{responseId:d,usage:b.response?.usage}),U(e)):"response.incomplete"===b.type&&e.calls.size&&!y?(y=!0,ea.warn("Live backend response incomplete; continuing once",{responseId:d}),U(e)):(y=!1,V(e),c.warn(b.response?.error?.message??`The Live backend ${b.type.slice(9)}.`)))}}L()}},dropped:J}});return{async connect(){b.element.muted=!1;let a=new Promise((a,b)=>{d=a,e=b});a.catch(()=>{});let c=setTimeout(()=>J("OpenAI Live did not start in time."),D.LIVE_CALL.startupMs);try{if(await Promise.all([Y.connect(),a]),o)throw Error("The Live call closed during startup.");i=setInterval(L,100)}catch(a){throw I(),a}finally{clearTimeout(c),e=void 0}},close:()=>g||(o?Promise.resolve():(n=!0,H(),m)?(g=new Promise(a=>{f=a}),h=setTimeout(()=>{c.warn("Live disconnected without confirming final session usage."),I()},D.LIVE_CALL.closeMs),b.element.muted=!0,Y.hush(),Y.send({type:"session.close",event_id:crypto.randomUUID()}),g):(I(),Promise.resolve())),append(a,b){let c=function(a){let b=[],c="",d=0,e=a=>{let e=ed.encode(a).length;if(d+e>480&&c&&(b.push(c),c="",d=0),e<=480){c+=a,d+=e;return}for(let e of a){let a=ed.encode(e).length;d+a>480&&(b.push(c),c="",d=0),c+=e,d+=a}};for(let b of a.split(/(?<=\s)/))e(b);return c&&b.push(c),b}(b);return o||n||!c.length?Promise.resolve(!1):new Promise(b=>{B.push({kind:a,chunks:c,settle:b}),M()})},holdInput(a){Y.relayed()||!m||o||n||F||a<=0||(F={mute:crypto.randomUUID(),unmute:null},Y.send({type:"session.input_audio.mute",event_id:F.mute}),l=setTimeout(G,a))},pictureRoom:a=>{let b=Y.limit();return(b&&Number.isFinite(b)&&b>2048?b:65536)-1024-ed.encode(a).length-64},brief(a){let b=a.trim();if(o||n||!b)return;let c=T();c?c.held.push({fact:b}):W(b)},picture(a,b){if(o||n)return;let c=T();c?c.held.push({image:a,path:b}):X({image:a,path:b})},run(){if(o||n)return;let a=T();a?a.rerun=!0:P(),L()}}};var eh=a.i(483253);function ei(){let a=[],b=null;return{send(c){b?b(c):a.push(c)},open(c){b=c;let d=a;for(let b of(a=[],d))c(b)},close(){b=null},clear(){let b=a;return a=[],b}}}var ej=a.i(647509),ek=a.i(152659);let el="thursday.here.shown",em=a=>(0,X.format)(a,"yyyy-MM-dd"),en=null;var eo=a.i(118082),ep=a.i(158697);async function eq(a,b){let c,d,e,f=b=>({failed:`${a} could not be read: ${(0,w.errorToString)(b)}`});try{c=await fetch(t.queryKey.file(a))}catch(a){return f(a)}if(404===c.status)return{failed:`There is no file at ${a} in the workspace.`};if(403===c.status)return{failed:`${a} is outside the workspace.`};if(!c.ok)return{failed:`${a} could not be read: the file route answered ${c.status}.`};try{d=await c.blob()}catch(a){return f(a)}if(!d.type.startsWith("image/"))return{failed:`${a} is not an image. Read it in the shell instead.`};try{e=await createImageBitmap(d)}catch(b){return{failed:`${a} could not be drawn as a picture: ${(0,w.errorToString)(b)}`}}try{let c=function(a,b){var c,d;let e,f,g=document.createElement("canvas"),h=g.getContext("2d");if(!h)return{failed:"draw"};for(let i of(c=a.width,e=Math.max(c,d=a.height),f=Math.min(e,D.CALL_PICTURE.longestSide),D.CALL_PICTURE.scales.map(a=>{let b=f*a/e;return{width:Math.max(1,Math.round(c*b)),height:Math.max(1,Math.round(d*b))}})))for(let c of(g.width=i.width,g.height=i.height,h.fillStyle="#fff",h.fillRect(0,0,g.width,g.height),h.drawImage(a,0,0,g.width,g.height),D.CALL_PICTURE.qualities)){let a=g.toDataURL("image/jpeg",c);if(a.length<=b)return{url:a}}return{failed:"fit"}}(e,b);if("url"in c)return c;return{failed:"draw"===c.failed?"This browser could not draw the picture.":`${a} would not fit the ${(0,w.formatBytes)(b)} this connection carries, even made smaller.`}}finally{e.close()}}async function er(a,{fact:b,pictures:c,run:d},e,f){try{let f=[];for(let b of c)f.push({path:b,taken:await e(b,a.pictureRoom(b))});for(let{path:c,taken:d}of(a.brief(b),f))"url"in d?a.picture(d.url,c):a.brief(`${c} could not be put before you as a picture: ${d.failed}`);d&&a.run()}finally{f(b)}}let es=(0,ai.createServerReference)("7fb6bb4f14ac3e64309c0db50393266303f00b20fb",ai.callServer,void 0,ai.findSourceMapURL,"openCallAction"),et=(0,ai.createServerReference)("7f299603ea8c1c7fb1d874afbe56e183d04e136346",ai.callServer,void 0,ai.findSourceMapURL,"saveThoughtAction"),eu=(0,ai.createServerReference)("7f42bc2e79ad070e82485b63d2217b2596a327a291",ai.callServer,void 0,ai.findSourceMapURL,"saveTurnsAction"),ev={offer:"the microphone and the offer",globe:"the globe's map",answer:"the server's answer",line:"the line"};function ew(a,b){let c="chatgpt"===a?" on your GPT Subscription":"openai"===a?" on your OpenAI key":"";return b?`Could not start the call${c}`:`The call${c} failed`}class ex extends Error{}let ey=Array(eh.SPECTRUM_BANDS).fill(0),ez=!1;function eA(a){let b=a.replace(/\[[^\]]*\]?|\]/g,"").trim();return/[\p{L}\p{N}]/u.test(b)?b:""}function eB(a,b,c="This call is not being saved"){a.failures>=D.CALL_PAGE.saveFailures||b().then(a=>(0,cE.unwrapResult)(a)).catch(b=>{a.failures+=1,a.failures===D.CALL_PAGE.saveFailures&&cA.toast.add({type:"warning",title:c,description:(0,w.errorToString)(b)})})}var eC=a.i(77453);let eD="(prefers-reduced-motion: reduce)";function eE({turns:a,saying:b}){let[c,e]=(0,s.useState)(""),f=(0,s.useRef)(null),g=a.at(-1);return(0,s.useEffect)(()=>{if(!g||"assistant"!==g.role||b)return;let a=`${g.id}:${g.text.length}`;f.current!==a&&(f.current=a,e(g.text))},[g,b]),(0,K.useAppEvent)({finished:a=>e(`${a.bot} finished: ${a.label}`)}),(0,d.jsx)("div",{role:"status","aria-live":"polite",className:"sr-only",children:c})}var eF=a.i(526496),eG=a.i(935112),eH=a.i(663390);let eI="700 9px ui-monospace, SFMono-Regular, Menlo, monospace",eJ=Math.ceil(13.5);function eK(a){let b=document.createElement("canvas");b.width=eJ*a.length,b.height=eJ;let c=b.getContext("2d");return c?(c.textAlign="center",c.textBaseline="middle",c.font=eI,a.forEach((a,b)=>{c.fillText(a,b*eJ+eJ/2,eJ/2)}),b):null}function eL({status:a}){let b=(0,s.useRef)(null),c=(0,s.useRef)(null),e=(0,s.useRef)(a),[f,g]=(0,s.useState)(!1),h=(0,s.useRef)(null);return(0,s.useEffect)(()=>{"emoji"===(0,eH.faceGlyphs)()&&(h.current=eK(ej.EMOJI_POOL))},[]),(0,s.useEffect)(()=>{let b=e.current;e.current=a,"connecting"!==b||"connecting"===a||"idle"===a||"ending"===a||window.matchMedia("(prefers-reduced-motion: reduce)").matches||g(!0)},[a]),(0,s.useEffect)(()=>{let a=c.current,d=b.current?.getBoundingClientRect();if(!f||!a||!d)return;let e=window.innerWidth,i=window.innerHeight,j=d.left+d.width/2,k=d.top+d.height/2,l=Math.hypot(Math.max(j,e-j),Math.max(k,i-k)),m=Math.ceil(e/11),n=Math.ceil(i/11),o=[];for(let a=0;a<n;a++)for(let b=0;b<m;b++){if((0,ej.hash)(b+53,a+5)>.4)continue;let c=11*b+5.5,d=11*a+5.5,e=Math.atan2(d-k,c-j),f=(0,ej.hash)(b+31,a+17),g=Math.hypot(c-j,d-k)/l*(1+.1*Math.sin(3*e+1.3)+.05*Math.sin(7*e-.7)+(f-.5)*.1);g<.1||o.push({x:c,y:d,dd:g,seed:(0,ej.hash)(b,a),grain:f,speck:(0,ej.hash)(b+7,a+101)})}o.sort((a,b)=>a.dd-b.dd);let p=a=>{let b=0,c=o.length;for(;b<c;){let d=b+c>>1;o[d].dd<a?b=d+1:c=d}return b};a.width=e,a.height=i;let q=a.getContext("2d"),r="letters"===(0,eH.faceGlyphs)(),s=r?null:h.current??eK(ej.EMOJI_POOL);if(!q||!r&&!s)return;r&&(q.textAlign="center",q.textBaseline="middle",q.font=eI,q.fillStyle=getComputedStyle(a).color);let t=ej.LEVELS-1,u=r?ej.CHAR_RATE:ej.EMOJI_CHAR_RATE,v=eJ/2,w=performance.now(),x=0,y=0,z=()=>{let a=(performance.now()-w)/1e3;if(a>1.9736842105263157)return g(!1);if(y=requestAnimationFrame(z),x++%2)return;let b=.95*a;q.clearRect(0,0,e,i);for(let c=p(b-.2-.475);c<o.length;c++){let d=o[c],e=b-d.dd;if(e<-.03)break;let f=(0,ej.smoothstep)(-.03,.02,e)*(1-(0,ej.smoothstep)(.02,.2,e))*(.72+.28*Math.sin(46*d.dd-7*a+6.283*d.seed));if(d.speck<.06){let a=.18+.32*d.grain,b=(e-.2)/.95;f=Math.max(f,(.3+.4*d.grain)*(1-(0,ej.smoothstep)(.4*a,a,b)))}let g=Math.round(f*t);if(g<1)continue;let h=Math.floor(a*u+10*d.seed);if(s){q.globalAlpha=(0,ej.emojiAlpha)(g,t);let a=Math.floor((0,ej.hash)(97*d.seed,h)*ej.EMOJI_POOL.length);q.drawImage(s,a*eJ,0,eJ,eJ,d.x-v,d.y-v,eJ,eJ);continue}q.globalAlpha=ej.ALPHA_TOP*(g/t);let i=ej.RAMP[g];q.fillText(i[Math.floor((0,ej.hash)(131*d.seed,h)*i.length)],d.x,d.y)}q.globalAlpha=1};return y=requestAnimationFrame(z),()=>cancelAnimationFrame(y)},[f]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{ref:b,"aria-hidden":!0,className:"pointer-events-none absolute inset-0"}),f&&(0,eG.createPortal)((0,d.jsx)("canvas",{ref:c,"aria-hidden":!0,className:"pointer-events-none fixed inset-0 z-30 size-full text-foreground"}),document.body)]})}var eM=a.i(445432),eN=a.i(587479),eO=a.i(538254);let eP=["▁▄▇▄","▂▆▆▂","▄▇▄▁","▆▆▂▂","▇▄▁▄","▆▂▂▆","▄▁▄▇","▂▂▆▆"];function eQ({live:a,ringing:b}){let{owed:c}=bB(),d=ck(Object.values(cl()).map(a=>a??null)),e="waiting"===d?null:d;return(0,s.useEffect)(()=>{let d=b?`${D.APP_NAME} is calling`:D.APP_NAME,e=c>0?`(${c}) ${d}`:d;if(!a){document.title=e;return}let f=0;document.title=`${e} ${eP[f]}`;let g=setInterval(()=>{f=(f+1)%eP.length,document.title=`${e} ${eP[f]}`},100);return()=>clearInterval(g)},[a,c,b]),(0,s.useEffect)(()=>{let a=document.head.querySelector("link[data-tab-icon]");a||((a=document.createElement("link")).rel="icon",a.type="image/svg+xml",a.setAttribute("sizes","any"),a.dataset.tabIcon="",document.head.append(a)),a.href=`data:image/svg+xml,${encodeURIComponent(function(a){let{head:b,eyes:c}=(0,eO.markAtRest)(O.THURSDAY_SEED),d=a?`<circle cx="200" cy="200" r="${66}"/>`:"",e=a?`<circle class="${a}" 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="${b}" fill="#fff"/><path d="${c[0]}"/><path d="${c[1]}"/>${d}</mask><path class="ink" d="${b}" mask="url(#m)"/>${e}</svg>`}(e))}`},[e]),null}let eR={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"}]]};eR.node;let eS=(0,h.default)(eR);var eT=a.i(327598);let eU={name:"brush",size:24,node:[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]]};eU.node;let eV=(0,h.default)(eU);var eW=a.i(127774),eX=a.i(676504),eY=a.i(630342),eZ=a.i(546893),e$=a.i(608902);let e_=(0,ai.createServerReference)("7f362592b81ee976c7522d8bea4fbc2d025296797c",ai.callServer,void 0,ai.findSourceMapURL,"startThreadAction");var e0=a.i(983874),e1=a.i(866460);let e2={name:"redo-2",size:24,node:[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]};e2.node;let e3=(0,h.default)(e2),e4={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};e4.node;let e5=(0,h.default)(e4);var e6=a.i(704974);let e7=[{label:"Ink",color:null},{label:"Red",color:aQ.MARK_INK.red},{label:"Orange",color:aQ.MARK_INK.orange},{label:"Yellow",color:aQ.MARK_INK.yellow},{label:"Green",color:aQ.MARK_INK.green},{label:"Blue",color:aQ.MARK_INK.blue},{label:"Violet",color:aQ.MARK_INK.violet},{label:"Pink",color:aQ.MARK_INK.pink},{label:"Stone",color:aQ.MARK_INK.stone}];function e8(a,b,c,d,e){for(let f of(a.lineCap="round",a.lineJoin="round",a.lineWidth=.014*b,d)){let[d,...g]=f.points;if(d){for(let[h,i]of(a.strokeStyle=e(f.pen),a.beginPath(),a.moveTo(d[0]*b,d[1]*c),g))a.lineTo(h*b,i*c);g.length||a.lineTo(d[0]*b+.1,d[1]*c),a.stroke()}}}function e9({open:a,onClose:b,onDone:c,action:e}){let f=(0,s.useRef)([]),g=(0,s.useRef)(null),h=(0,s.useRef)([]),i=(0,s.useRef)([]),[j,k]=(0,s.useState)(0),[,l]=(0,s.useState)(0),m=(0,Q.useCommandLabel)("KeyZ"),n=(0,Q.useCommandLabel)("KeyZ",!0),[o,p]=(0,s.useState)(0),[q,r]=(0,s.useState)(null),[t,v]=(0,s.useState)(null),[x,y]=(0,s.useState)(!1),z=(0,bP.useIsDark)();(0,Q.useEscape)(a,b);let A=(0,s.useCallback)(a=>{let[b,c,d]=z?ej.ORB_INK.dark:ej.ORB_INK.light;return e7[a]?.color??`rgb(${b},${c},${d})`},[z]);(0,s.useEffect)(()=>{if(!q)return;let a=new ResizeObserver(([a])=>{let b=a.contentRect.width,c=a.contentRect.height;b>0&&c>0&&v({width:b,height:c})});return a.observe(q),()=>a.disconnect()},[q]),(0,s.useEffect)(()=>{if(!q||!t)return;let a=Math.min(2,window.devicePixelRatio||1);q.width=Math.round(t.width*a),q.height=Math.round(t.height*a);let b=q.getContext("2d");b&&(b.setTransform(a,0,0,a,0,0),e8(b,t.width,t.height,f.current,A))},[q,t,A]);let B=a=>{let b=a.currentTarget.getBoundingClientRect();return[Math.min(1,Math.max(0,(a.clientX-b.left)/b.width)),Math.min(1,Math.max(0,(a.clientY-b.top)/b.height))]},E=a=>{let b=q?.getContext("2d");b&&t&&e8(b,t.width,t.height,[{pen:a.pen,points:a.points.slice(-2)}],A)},F=()=>{k(f.current.length),l(a=>a+1);let a=q?.getContext("2d");q&&a&&t&&(a.clearRect(0,0,q.width,q.height),e8(a,t.width,t.height,f.current,A))},G=()=>{h.current.push([...f.current]),i.current=[],l(a=>a+1)},H=(a,b)=>{let c=a.current.pop();c&&(g.current=null,b.current.push(f.current),f.current=c,F())},I=()=>H(h,i),J=()=>H(i,h),K=async()=>{if(q&&t&&f.current.length){y(!0);try{let{width:a,height:b}=t,d=1,e=1,j=0,k=0;for(let a of f.current)for(let[b,c]of a.points)d=Math.min(d,b),e=Math.min(e,c),j=Math.max(j,b),k=Math.max(k,c);let l=.027*a,m=Math.max(0,d*a-l),n=Math.max(0,e*b-l),o=Math.min(a,j*a+l)-m,p=Math.min(b,k*b+l)-n,r=Math.min(Math.min(2,window.devicePixelRatio||1),D.DRAW_PAD.longestSide/Math.max(o,p)),s=document.createElement("canvas");s.width=Math.max(1,Math.round(o*r)),s.height=Math.max(1,Math.round(p*r));let u=s.getContext("2d");if(!u)throw Error("This browser gave no canvas to keep it on.");u.fillStyle=getComputedStyle(q).backgroundColor,u.fillRect(0,0,s.width,s.height),u.setTransform(r,0,0,r,-m*r,-n*r),e8(u,a,b,f.current,A);let v=await new Promise(a=>s.toBlob(a,"image/png"));if(!v)throw Error("This browser could not keep the drawing.");let w=f.current.length;await c(new File([v],"drawing.png",{type:"image/png"}))&&f.current.length===w&&(f.current=[],g.current=null,h.current=[],i.current=[],F())}catch(a){cA.toast.add({type:"error",title:"The drawing could not be kept.",description:(0,w.errorToString)(a)})}finally{y(!1)}}};return(0,d.jsx)(by.Dialog,{open:a,onOpenChange:a=>!a&&b(),children:(0,d.jsxs)(by.DialogContent,{showCloseButton:!1,onKeyDown:a=>{if(!(a.metaKey||a.ctrlKey)||a.altKey)return;let b=a.key.toLowerCase();"z"===b?(a.preventDefault(),a.shiftKey?J():I()):"y"===b&&a.ctrlKey&&!a.metaKey&&(a.preventDefault(),J())},className:"w-[min(72rem,calc(100vw-2rem),calc((100dvh-7rem)*2))] max-w-none gap-3 p-3 sm:max-w-none",children:[(0,d.jsx)(by.DialogTitle,{className:"sr-only",children:"Drawing pad"}),(0,d.jsx)("canvas",{ref:r,"aria-label":"Drawing pad",className:"block aspect-[2/1] w-full cursor-crosshair touch-none rounded-lg bg-background ring-1 ring-foreground/10",onPointerDown:a=>{a.currentTarget.setPointerCapture(a.pointerId),G();let b={pen:o,points:[B(a)]};g.current=b,f.current.push(b),E(b),k(f.current.length)},onPointerMove:a=>{let b=g.current;if(!b)return;let c=B(a),d=b.points[b.points.length-1];.002>Math.hypot(c[0]-d[0],c[1]-d[1])||(b.points.push(c),E(b))},onPointerUp:()=>{g.current=null},onPointerCancel:()=>{g.current=null}}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 pl-1",children:e7.map((a,b)=>(0,d.jsx)(e6.Swatch,{color:a.color,label:a.label,picked:o===b,onPick:()=>p(b)},a.label))}),(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsx)(C.TooltipTrigger,{render:(0,d.jsx)(u.Button,{variant:"ghost",size:"icon","aria-label":"Undo",disabled:!h.current.length,onClick:I}),children:(0,d.jsx)(e5,{})}),(0,d.jsxs)(C.TooltipContent,{children:["Undo",(0,d.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:m})]})]}),(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsx)(C.TooltipTrigger,{render:(0,d.jsx)(u.Button,{variant:"ghost",size:"icon","aria-label":"Redo",disabled:!i.current.length,onClick:J}),children:(0,d.jsx)(e3,{})}),(0,d.jsxs)(C.TooltipContent,{children:["Redo",(0,d.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:n})]})]}),(0,d.jsx)("span",{"aria-hidden":!0,className:"h-4.5 w-px bg-border"}),(0,d.jsx)(u.Button,{variant:"ghost",disabled:!j,onClick:()=>{G(),f.current=[],g.current=null,F()},children:"Clear"}),(0,d.jsx)(u.Button,{disabled:!j,loading:x,onClick:()=>void K(),children:e})]})]})})}let fa={name:e0.ROOM_THURSDAY,description:"A call in writing — she answers here"},fb=a=>/^@(\S*)$/.exec(a.split(/\s/,1)[0]);function fc({written:a,onCall:b=!1}){let{data:c}=(0,U.useServerRoute)(t.queryKey.bot),e=(0,s.useMemo)(()=>[...a?[fa]:[],...c?.length?c.filter(a=>!a.disabled).map(({name:a,icon:b,description:c})=>({name:a,icon:b,description:c})):[G.DEFAULT_BOT]],[c,a]),[g,h]=(0,s.useState)(!1),[i,j]=(0,s.useState)(!1),[k,l]=(0,s.useState)(!1),[m,n]=(0,s.useState)(!1),[o,q]=(0,s.useState)(""),[r,v]=(0,s.useState)(0),[x,y]=(0,s.useState)(!1),z=(0,s.useRef)(b);z.current=b;let A=(0,e1.useGivenFiles)({onKept:a=>{if(z.current)return V.screenActs.announce({kind:"gave",paths:a}),"she knows it is here"}}),B=(0,s.useRef)(null),C=(0,s.useRef)(null),D=!!a?.on,[E,H]=(0,s.useState)(null);(0,s.useEffect)(()=>{D||H(null)},[D]);let I=e.find(a=>a.name===E)??(a?fa:e[0]),J=I===fa,K=(0,cm.useCallHeld)(),L=(0,s.useCallback)(a=>{K||(h(!0),a&&(q(a=>fb(a)?a:a?`@ ${a}`:"@"),y(!1),v(0)),requestAnimationFrame(()=>{let b=B.current;b?.focus();let c=b?.value.split(/\s/,1)[0].length??0;a&&b?.setSelectionRange(c,c)}))},[K]),M=(0,V.useRoomOpen)(),{take:N}=A,O=(0,s.useCallback)(a=>(V.writeLine.open(),N(a)),[N]);(0,s.useEffect)(()=>V.writeLine.subscribe(L),[L]),(0,s.useEffect)(()=>V.writeLine.onDraw(()=>l(!0)),[]),(0,s.useEffect)(()=>{if("thread"===M)return;let a=a=>{(0,Q.typed)(a,"@")&&(0,Q.windowKey)(a)&&(a.preventDefault(),V.writeLine.choose())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[M]),(0,s.useEffect)(()=>{if(K)return;let a=a=>!!a.dataTransfer?.types.includes("Files"),b=b=>{a(b)&&(b.preventDefault(),n(!0))},c=a=>{null===a.relatedTarget&&n(!1)},d=b=>{if(!a(b))return;b.preventDefault(),n(!1);let c=[...b.dataTransfer?.files??[]];e1.roomDrop.offer(b.target,c)||O(c)};return window.addEventListener("dragover",b),window.addEventListener("dragleave",c),window.addEventListener("drop",d),()=>{window.removeEventListener("dragover",b),window.removeEventListener("dragleave",c),window.removeEventListener("drop",d)}},[O,K]);let[R,S]=(0,an.useServerAction)(e_,{onOk:({id:a})=>{(0,U.revalidate)(t.queryKey.threads),q(""),A.clear(),h(!1),H(null),V.roomOpens.open(a)}}),T=a=>{j(!1),q(a=>fb(a)?a.replace(/^@\S*\s?/,""):a),v(0),B.current?.focus(),H(a.name===fa.name?null:a.name)},W=x?null:fb(o),X=W&&!W[1]?o.replace(/^@\s?/,""):null,Y=null!==X&&!X.trim()&&!A.files.length&&!D,Z=W?e.filter(a=>a.name.toLowerCase().startsWith(W[1].toLowerCase())):e,$=Z.length?r%Z.length:0,[_,aa]=(0,s.useState)(!1),ab=S||_,ac=!!o.trim()&&!W&&!A.arriving&&!ab&&!(J&&!a?.runsOn),ad=()=>{if(!ac)return;let b=A.withPaths(o);J?a&&(aa(!0),a.say(b,A.paths).then(()=>{q(""),A.clear()}).catch(()=>{}).finally(()=>aa(!1))):R(I.name,b)},ae=()=>{if(E)return H(null);D&&a?.end(),h(!1)},af=(0,s.useRef)(b);(0,s.useEffect)(()=>{let a=b&&!af.current;af.current=b,!a||o.trim()||A.files.length||h(!1)},[b,o,A.files.length]);let ag=(g||m||D)&&!M;(0,Q.useEscape)(ag,ae),P(ag,"write");let ah=S||_;(0,s.useEffect)(()=>{ag&&!ah&&B.current?.focus()},[ag,ah]),(0,s.useEffect)(()=>(V.writeLine.shown(ag),()=>V.writeLine.shown(!1)),[ag]);let ai=D&&!!M;(0,s.useEffect)(()=>(V.writeLine.waits(ai),()=>V.writeLine.waits(!1)),[ai]);let aj=ao(),[ak,al]=(0,s.useState)(ag);(0,s.useEffect)(()=>{if(ag)return void al(!0);let a=setTimeout(()=>al(!1),200);return()=>clearTimeout(a)},[ag]);let ap=(0,d.jsx)(e9,{open:k,onClose:()=>l(!1),onDone:async a=>{if(l(!1),!z.current)return(await O([a])).length>0;let b=await A.keepApart(a);return!!b&&(z.current?(V.screenActs.announce({kind:"showed",path:b}),cA.toast.add({type:"success",title:"Shown to her"}),!0):(cA.toast.add({type:"error",title:"The call ended before she saw the drawing."}),!1))},action:b?"Show her":"Add to the message"});return ak?(0,d.jsxs)(d.Fragment,{children:[ap,m&&(0,d.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-0 bg-background/60",children:(0,d.jsx)("div",{className:"absolute inset-3 rounded-3xl border-[1.5px] border-dashed border-foreground/30"})}),(0,d.jsx)("div",{className:"col-start-2 row-start-1 flex min-w-0 items-end justify-center",children:(0,d.jsxs)("div",{className:(0,w.cn)("@container flex w-160 max-w-full flex-col gap-2",ag?"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:[aj.length>0&&(0,d.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,d.jsxs)("p",{className:"px-3 pt-1 pb-1 font-mono text-[10px] tracking-wide text-muted-foreground",children:[aj.length," ",1===aj.length?"needs":"need"," a reply"]}),(0,d.jsx)("div",{className:"max-h-[30vh] overflow-y-auto",children:aj.map(a=>(0,d.jsx)(ax,{thread:a,lines:2,onPick:()=>V.roomOpens.open(a.id)},a.id))})]}),(0,d.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:[(A.files.length>0||m)&&(0,d.jsx)(e1.GivenFiles,{files:A.files,onRemove:A.remove,className:"px-0.5 pt-0.5",children:m&&(0,d.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,d.jsx)(eS,{className:"size-4"}),"Let go — it waits here"]})}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault(),ad()},className:"flex items-end gap-2 @max-md:flex-wrap @max-md:items-center",children:[(0,d.jsxs)(eY.Popover,{open:i||!!W,onOpenChange:j,children:[(0,d.jsxs)(eY.PopoverTrigger,{render:(0,d.jsx)("button",{type:"button","aria-label":`To ${I.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,d.jsx)(fg,{bot:I,size:22}),I.name,(0,d.jsx)(f.ChevronDown,{className:"size-3 text-muted-foreground"})]}),(0,d.jsxs)(eY.PopoverContent,{side:"top",align:"start",sideOffset:14,initialFocus:!W&&void 0,className:"w-90 gap-0 rounded-[18px] p-1.5",children:[(0,d.jsx)("p",{className:"px-2.5 pt-1.5 pb-1 font-mono text-[10px] text-muted-foreground",children:"to"}),Z.map((a,b)=>(0,d.jsxs)("button",{type:"button",onClick:()=>T(a),className:(0,w.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",(W?b===$:a.name===I.name)&&"bg-muted"),children:[(0,d.jsx)(fg,{bot:a,size:24}),(0,d.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,d.jsx)("span",{className:"text-[13.5px] leading-4.5 font-medium",children:a.name}),(0,d.jsx)("span",{className:"truncate text-xs leading-4 text-muted-foreground",children:a.description})]})]},a.name)),0===Z.length&&(0,d.jsx)("p",{className:"px-2.5 py-2 text-[13px] text-muted-foreground",children:"Nobody by that name."})]})]}),(0,d.jsx)(eZ.Textarea,{ref:B,value:o,rows:1,disabled:S||_,onChange:a=>{let b=a.target.value;q(b),v(0),fb(b)||y(!1)},onPaste:a=>{let b=[...a.clipboardData.files];b.length&&(a.preventDefault(),O(b))},onKeyDown:a=>{let b=(0,Q.composing)(a);if("Escape"===a.key&&!b){if(a.preventDefault(),null!==X){if(q(X),!Y)return;H(null),h(!1);return}return W?y(!0):ae()}let c="ArrowDown"===a.key||"ArrowUp"===a.key;if(W&&c&&!b){let b;return a.preventDefault(),b="ArrowDown"===a.key?1:-1,v(a=>Z.length?(a+b+Z.length)%Z.length:0)}let d="Tab"===a.key&&!a.shiftKey;if(W&&d&&!b&&Z[$]){a.preventDefault(),T(Z[$]);return}if("Enter"===a.key&&!a.shiftKey&&!b){if(a.preventDefault(),W){Z[$]&&T(Z[$]);return}ad()}},placeholder:A.files.length?"Say what to do with them":D&&J?"Write back":J?"Write to her instead of calling":`Say the whole job — ${I.name} cannot hear the call`,"aria-label":`Message for ${I.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 @max-md:order-first @max-md:basis-full @max-md:px-2 dark:bg-transparent"}),(0,d.jsx)("input",{ref:C,type:"file",multiple:!0,hidden:!0,onChange:a=>{O([...a.target.files??[]]),a.target.value=""}}),(0,d.jsxs)(eX.DropdownMenu,{children:[(0,d.jsx)(eX.DropdownMenuTrigger,{render:(0,d.jsx)("button",{type:"button","aria-label":"Add a file or a drawing",className:"grid size-9 shrink-0 @max-md:ml-auto 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 data-popup-open:bg-muted data-popup-open:text-foreground"}),children:(0,d.jsx)(eW.Paperclip,{className:"size-4"})}),(0,d.jsxs)(eX.DropdownMenuContent,{side:"top",align:"end",sideOffset:14,className:"w-64 rounded-[18px] p-1.5",children:[(0,d.jsxs)(eX.DropdownMenuItem,{onClick:()=>C.current?.click(),className:"h-11 gap-2.5 rounded-xl px-2.5 text-[13.5px]",children:[(0,d.jsx)(bN.FolderOpen,{}),"A file from this computer"]}),(0,d.jsxs)(eX.DropdownMenuItem,{onClick:()=>l(!0),className:"h-11 gap-2.5 rounded-xl px-2.5 text-[13.5px]",children:[(0,d.jsx)(eV,{}),"Draw something"]})]})]}),(0,d.jsx)("button",{type:"submit","aria-label":"Send",disabled:!ac,className:(0,w.cn)("grid size-9 shrink-0 place-items-center rounded-full outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50",ac?"bg-primary text-primary-foreground hover:bg-primary/85":"bg-muted text-muted-foreground/40"),children:ab?(0,d.jsx)("span",{className:"size-3.5 animate-spin rounded-full border-2 border-current/30 border-t-current"}):(0,d.jsx)(eT.ArrowUp,{className:"size-4"})})]})]}),J&&a?.error&&(a.refused?(0,d.jsxs)("div",{className:"flex flex-col items-center gap-0.5 px-4 text-center",children:[(0,d.jsxs)("p",{className:"text-xs leading-5 text-destructive",children:[(0,F.refusedWords)(a.refused),", so she could not answer."]}),(0,d.jsx)("p",{className:"line-clamp-2 font-mono text-[10.5px] leading-4 text-muted-foreground",children:a.error})]}):(0,d.jsx)("p",{className:"px-4 text-center text-xs leading-5 text-destructive",children:a.error})),J&&a?.error&&(0,d.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[a.refused&&(0,d.jsxs)(u.Button,{type:"button",size:"sm",onClick:()=>(0,am.openSettings)("keys"),children:[(0,d.jsx)(p.Settings2,{}),"Open Settings"]}),(0,d.jsxs)(u.Button,{type:"button",size:"sm",variant:a.refused?"ghost":"brand",disabled:a.busy,onClick:()=>{a.fallback&&cw.useThursdayStore.getState().patch({textModel:a.fallback}),a.again()},children:[(0,d.jsx)(aE.RotateCw,{}),a.fallback?"Send it again on your OpenAI key":"Send it again"]})]}),(0,d.jsx)("p",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1 font-mono text-[10.5px] text-muted-foreground",children:W?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(fh,{keys:["↑↓"],children:"walk"}),(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["Tab","Enter"],children:"take"}),(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["Esc"],children:Y?"close":"close the list"})]}):(0,d.jsxs)(d.Fragment,{children:[J&&!a?.runsOn?(0,d.jsx)(fd,{runsOn:null}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(fh,{keys:["Enter"],children:"send"}),(0,d.jsxs)("span",{className:"contents @max-md:hidden",children:[(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["@"],children:J?"a bot":"pick a bot"})]}),J&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(fe,{}),(0,d.jsx)(fd,{runsOn:a?.runsOn??null})]})]}),(0,d.jsx)(fe,{}),(0,d.jsx)(fh,{keys:["Esc"],children:D?J?"to end":"back to her":"close"})]})})]})})]}):ap}function fd({runsOn:a}){let b=F.TEXT_MODEL_PROVIDERS.chatgpt.label,c=(0,d.jsx)(e$.ModelPicker,{compact:!0,provider:a?.provider??null,model:a?.model??"",unset:"pick a model",onChange:a=>cw.useThursdayStore.getState().patch({textModel:a})});return a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"runs on"}),c]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:["Writing to her needs a ",b,", an OpenAI key, or"]}),c,(0,d.jsx)(fe,{}),(0,d.jsx)(ff,{children:"API keys"})]})}let fe=()=>(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"});function ff({children:a}){return(0,d.jsx)("button",{type:"button",onClick:()=>(0,am.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:a})}function fg({bot:a,size:b}){return a===fa?(0,d.jsx)(O.ThursdayMark,{size:b,className:"shrink-0"}):(0,d.jsx)(H.BotMark,{size:b,seed:a.name,color:a.icon?.color,shape:a.icon?.shape,outline:a.icon?.outline,paint:a.icon?.paint,notify:!1,className:"shrink-0"})}function fh({keys:a,children:b}){return(0,d.jsxs)("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[a.map(a=>(0,d.jsx)(fi,{children:a},a)),b]})}function fi({children:a}){return(0,d.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:a})}let fj=(0,r.default)(async()=>{},{loadableGenerated:{modules:[246971]},ssr:!1});function fk({status:a,failed:b=!1,messages:c,tool:e,thinkingSince:f=null,thinkingTitle:g=null,ended:h=null,faceWord:i=null,onTap:j,ringing:k=null,onDecline:l,wakePhrase:m=null,hotkeyLabel:n=null,idleLeft:o=null,since:p=null,getSpectrum:q,getMicSpectrum:r,captionView:t="sides",callable:u=!0,written:v=null}){let[x,y]=(0,s.useState)(!1),z=!u&&"idle"===a,A="connecting"===a||"ending"===a,B=!!v?.on,C="idle"!==a&&!A&&!B,E=c.findLast(a=>"assistant"===a.role)?.text??"",F=R(fo),G="sides"===t&&"idle"!==a&&F,H=ct(),I=!G||null!==H,J=(0,s.useMemo)(()=>(0,eN.turnsOf)(c),[c]),K=(0,eN.useTurnFocus)(J,G),L=J.at(-1)?.role,N=function(a,b){let[c,d]=(0,s.useState)(a),e=(0,s.useRef)(a?[a]:[]),f=(0,s.useRef)(Date.now()),g=(0,s.useRef)(!1),h=(0,s.useRef)(null),i=(0,s.useCallback)(()=>{h.current&&clearTimeout(h.current),h.current=null,(e.current.length>1||g.current)&&e.current.length&&(h.current=setTimeout(()=>{e.current.shift(),f.current=Date.now(),d(e.current[0]??null),i()},Math.max(0,f.current+D.CALL_LINE.dwellMs-Date.now())))},[]);return(0,s.useEffect)(()=>{if(!a){g.current=!0,e.current.length<=1&&(e.current=[],d(null)),i();return}g.current=!1;let b=e.current.findIndex(b=>b.id===a.id);b>=0?(e.current[b]=a,0===b&&d(a)):(e.current=[...e.current.map((a,b)=>0===b?a:{...a,done:!0}),a],1===e.current.length&&(f.current=Date.now(),d(a))),i()},[a,i]),(0,s.useEffect)(()=>{if(!b)return;let a=e.current.at(-1);e.current=a&&!g.current?[a]:[],f.current=Date.now(),d(e.current[0]??null),i()},[b,i]),(0,s.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),c}(e,"speaking"===a),O=function(a,b){let c=null!==a||b,[d,e]=(0,s.useState)([]),[f,g]=(0,s.useState)(c);return(0,s.useEffect)(()=>{e(b=>{let c=b.some(a=>!a.done)?b.map(a=>a.done?a:{...a,done:!0}):b;if(!a)return c;let d=b.findIndex(b=>fA(b)===fA(a));return d>=0?b.map((b,c)=>c===d?a:b):[...c,a].slice(-4)})},[a]),(0,s.useEffect)(()=>{if(c)return void g(!0);let a=setTimeout(()=>{g(!1),e([])},300);return()=>clearTimeout(a)},[c]),{lines:d,on:c,held:f}}(N,null!==f),[P,Q]=(0,s.useState)(!1);(0,s.useEffect)(()=>{"user"!==L?Q(!1):O.on&&Q(!0)},[L,O.on]);let S=function(a,b,c){let[d,e]=(0,s.useState)(fB),f=a.findLast(a=>"assistant"===a.role),g=f?.id??null,h=f?`${f.id}:${f.text.length}`:null,i=!c&&a.at(-1)?.role==="assistant";(0,s.useEffect)(()=>{e(a=>{let c=a;for(let a of b){let b=fA(a),d=c.owner[b];if(void 0===d){let a=b in c.seen?c.seen[b]:h;if(b in c.seen||(c={...c,seen:{...c.seen,[b]:h}}),!g||a===h&&!i)continue;d=g,c={...c,owner:{...c.owner,[b]:d}}}let e=c.turns[d]??[],f=e.findIndex(a=>fA(a)===b);f>=0&&e[f]===a||(c={...c,turns:{...c.turns,[d]:f>=0?e.map((b,c)=>c===f?a:b):[...e,a]}})}return c})},[b,h,g,i]),(0,s.useEffect)(()=>{a.length||e(fB)},[a.length]);let j=(0,s.useMemo)(()=>b.filter(a=>void 0===d.owner[fA(a)]),[b,d.owner]);return{turns:d.turns,pending:j,latest:g}}(J,O.lines,O.on),T="assistant"===L&&"speaking"===a||"user"===L&&"listening"===a&&!B,U=null!==k&&null===k.missedAt,W=function(a){let[b,c]=(0,s.useState)(null);return(0,s.useEffect)(()=>{c(a?{...fD,at:Date.now()}:null)},[a]),b}(U),X=(0,cm.useCallHeld)(),Y=(0,am.useSettingsStore)(a=>a.open),Z=(0,s.useSyncExternalStore)(a=>{let b=window.matchMedia(eD);return b.addEventListener("change",a),()=>b.removeEventListener("change",a)},()=>window.matchMedia(eD).matches,()=>!1),$=(0,M.useCrewAwake)(),_=(0,V.useRoomOffice)(),aa=(0,eC.useAwayAfter)(_,fp),ab="thread"===(0,V.useRoomOpen)(),ac=_&&"idle"!==a&&!B;return(0,s.useEffect)(()=>V.officeCaption.set(ac),[ac]),(0,s.useEffect)(()=>()=>V.officeCaption.set(!1),[]),(0,d.jsxs)("div",{className:"relative flex h-full flex-col",inert:X,children:[(0,d.jsx)(eE,{turns:J,saying:T}),(0,d.jsxs)("div",{className:"absolute top-5 right-5 z-10 flex flex-col items-end gap-3",children:[(0,d.jsx)(fq,{}),(0,d.jsx)(ch,{hidden:X||"idle"!==a||null!==k||B}),(0,d.jsx)(bj,{hidden:"idle"!==a||null!==k||B})]}),ac&&(0,d.jsxs)("p",{className:"absolute top-5 left-6 z-20 line-clamp-2 max-w-[calc(100%-45rem)] animate-in text-[17px] leading-relaxed fade-in duration-500",children:[(0,d.jsx)("span",{"aria-hidden":!0,className:(0,w.cn)("mr-4 inline-block size-2.5 rounded-full bg-brand align-middle","speaking"===a?"animate-pulse motion-reduce:animate-none":"opacity-55")}),E||("connecting"===a?"Calling":"ending"===a?"Hanging up":"On a call")]}),(0,d.jsxs)("div",{inert:_,className:(0,w.cn)("flex min-h-0 flex-1 flex-col items-center justify-center gap-5 pt-[7vh] transition-[opacity,scale] duration-500 ease-out motion-reduce:transition-none",_&&"pointer-events-none scale-[0.97] opacity-0"),children:[(0,d.jsxs)("div",{className:"relative w-[min(20rem,52vw,37.5vh)] [--face-bleed:19.5%]",children:[(0,d.jsxs)("button",{type:"button",disabled:A,onClick:z?()=>y(!0):B&&!u?void 0:j,"aria-label":z?"Add a speech key":C?"End the call":U?"Answer Thursday":"Call Thursday",className:(0,w.cn)("group/face relative block w-full rounded-full outline-none transition-all duration-700 ease-out enabled:active:scale-[0.99] disabled:opacity-70",z&&"opacity-35"),children:[(0,d.jsx)("span",{className:"block",children:(0,d.jsx)(eM.Face,{status:a,failed:b,word:W??i,getSpectrum:q,covered:X||H?.phase==="world"||aa,held:Y||Z&&"idle"===a&&!$,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"})}),(0,d.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-full opacity-0 ring-3 ring-ring/50 transition-opacity group-focus-visible/face:opacity-100"})]}),(0,d.jsx)(eL,{status:a}),H?.moment.kind==="here"&&(0,d.jsx)(fj,{scene:H.moment.scene,covered:X||aa,onPhase:a=>cs.tell(H.id,a)},H.id),G&&(0,d.jsx)("div",{className:(0,w.cn)("contents",H&&"*:invisible"),children:(0,d.jsx)(eN.SideCaptions,{turns:J,pinned:K.pinned,live:T,onPick:K.pick,under:O.held&&S.pending.length>0?(0,d.jsx)(fC,{lines:S.pending,shown:O.on}):null,ahead:P&&O.held&&S.pending.length>0,typed:B,workOf:a=>{let b=[...S.turns[a]??[],...a===S.latest&&"assistant"===L?S.pending:[]];return b.length?(0,d.jsx)(fC,{lines:b,shown:!0}):null}})})]}),(0,d.jsxs)("div",{className:"relative flex w-full max-w-3xl flex-col items-center gap-2 px-6 text-center",children:[k&&(0,d.jsx)(fF,{ringing:k,wakePhrase:m,onAnswer:j,onDecline:()=>l?.()}),(0,d.jsxs)("div",{className:(0,w.cn)("contents",k&&"*:invisible"),children:[(0,d.jsx)(fy,{tool:I?N:null,toolUp:null!==N,thinkingSince:f,thinkingTitle:g,micOpen:!B&&("listening"===a||"working"===a||"delegating"===a),getMicSpectrum:r}),(0,d.jsx)(fr,{text:I&&"idle"!==a?E:"",fadeIn:!0,className:"w-full max-w-160 text-center text-base"}),(0,d.jsx)("div",{className:(0,w.cn)("flex flex-col items-center","idle"===a&&"order-first"),children:z?(0,d.jsx)(fQ,{open:x,onOpen:()=>y(!0),onClose:()=>y(!1)}):B?(0,d.jsx)("span",{className:"h-6"}):(0,d.jsx)(fL,{status:a,idleLeft:o,since:p,ended:h,behind:G&&K.back,wakePhrase:m,hotkeyLabel:n})})]})]})]}),(0,d.jsxs)(fl,{children:[(0,d.jsx)("div",{inert:ab,className:(0,w.cn)("contents *:transition-opacity *:duration-300",ab&&"*:pointer-events-none *:opacity-0"),children:(0,d.jsx)(c2.ArtifactView,{talking:"idle"!==a})}),(0,d.jsx)(fc,{written:v,onCall:C}),(0,d.jsx)(a5,{})]})]})}function fl({children:a}){return(0,d.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:a})}let fm=["thursday","memory","bot"];function fn({alert:a}){return a?(0,d.jsx)("span",{"aria-hidden":!0,className:(0,w.cn)("absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2 ring-background","red"===a?"bg-destructive":"bg-waiting")}):null}let fo=1e3,fp=500;function fq(){let a=cl(),b=ck(cb.filter(a=>!fm.includes(a.id)).map(b=>a[b.id]??null));return(0,d.jsxs)(C.TooltipProvider,{children:[(0,d.jsxs)(y,{className:"bg-background/75 backdrop-blur-md",children:[(0,d.jsx)(y,{children:fm.map(b=>{let c=cb.find(a=>a.id===b);return c?(0,d.jsxs)(C.Tooltip,{children:[(0,d.jsxs)(C.TooltipTrigger,{render:(0,d.jsx)(u.Button,{size:"icon",variant:"outline","aria-label":c.label,onClick:()=>(0,am.openSettings)(b)}),children:[(0,d.jsx)(c.icon,{className:"text-muted-foreground"}),(0,d.jsx)(fn,{alert:a[b]??null})]}),(0,d.jsx)(C.TooltipContent,{side:"bottom",children:c.label})]},b):null})}),(0,d.jsx)(y,{children:(0,d.jsxs)(u.Button,{variant:"outline",onClick:()=>(0,am.openSettings)(),className:"gap-1.5 px-2.5 text-[12.5px] font-normal",children:[(0,d.jsx)(p.Settings2,{className:"text-muted-foreground"}),"Settings",(0,d.jsx)(fn,{alert:b})]})})]}),(0,d.jsx)(ce,{})]})}function fr({text:a,lines:b=3,fadeIn:c=!1,className:e}){let h=(0,s.useRef)(null),[i,j]=(0,s.useState)(b),[k,l]=(0,s.useState)(0),[m,n]=(0,s.useState)(a);m!==a&&(n(a),l(0)),(0,s.useEffect)(()=>{let a=h.current;if(!a)return;let b=()=>{let b=Number.parseFloat(getComputedStyle(a).lineHeight);b&&j(Math.max(1,Math.round(a.scrollHeight/b)))};b();let c=new ResizeObserver(b);return c.observe(a),()=>c.disconnect()},[a]);let o=Math.ceil(Math.max(0,i-b)/b),p=Math.max(0,i-b-Math.min(k,o)*b),q=`calc(${b} * 1.625em)`,r=(0,d.jsx)("p",{ref:h,style:{lineHeight:1.625,transform:`translateY(-${1.625*p}em)`},className:"break-keep wrap-anywhere whitespace-pre-line transition-transform duration-200",children:(0,d.jsx)(eF.CaptionWords,{text:a,animate:c})});return(0,d.jsxs)("div",{className:"relative flex w-full justify-center",children:[(0,d.jsx)("div",{style:{height:q},onClick:o>0?()=>l(a=>a>=o?0:a+1):void 0,className:(0,w.cn)("overflow-hidden",o>0&&"cursor-pointer",e),children:r}),o>0&&(0,d.jsxs)("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 flex-col items-center gap-0.5",children:[(0,d.jsx)(fs,{look:g.ChevronUp,label:"Earlier lines",shown:k<o,onPick:()=>l(a=>Math.min(o,a+1))}),(0,d.jsx)(fs,{look:f.ChevronDown,label:"Later lines",shown:k>0,onPick:()=>l(a=>Math.max(0,a-1))})]})]})}function fs({look:a,label:b,shown:c,onPick:e}){return(0,d.jsx)("button",{type:"button","aria-label":b,"aria-hidden":!c,tabIndex:c?void 0:-1,onClick:a=>{a.stopPropagation(),e()},className:(0,w.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",!c&&"invisible"),children:(0,d.jsx)(a,{className:"size-3.5"})})}let ft=[{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 fu({live:a,getMicSpectrum:b}){let c=(0,s.useRef)({}),e=(0,s.useRef)(ft.map(()=>0));return(0,s.useEffect)(()=>{if(!a||!b)return;let d=requestAnimationFrame(function a(){let f=b();ft.forEach((a,b)=>{let d=0;for(let b=a.from;b<a.to;b++)d=Math.max(d,f[b]??0);let g=Math.min(1,(d*a.gain)**.8),h=e.current[b],i=h+(g-h)*(g>h?.6:.16);e.current[b]=i;let j=c.current[a.id];j&&(j.style.height=`${2+12*i}px`)}),d=requestAnimationFrame(a)});return()=>cancelAnimationFrame(d)},[a,b]),(0,d.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-[18px] shrink-0 items-center gap-0.5",children:ft.map(a=>(0,d.jsx)("span",{ref:b=>{c.current[a.id]=b},style:{height:2},className:"w-0.5 rounded-full bg-muted-foreground/70"},a.id))})}function fv({live:a,getMicSpectrum:b}){return(0,d.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] leading-5 text-muted-foreground",children:[(0,d.jsx)(fu,{live:a,getMicSpectrum:b}),"Listening"]})}function fw({tool:a}){let b="relay"===a.kind?j:(0,a8.toolIcon)(a.name),c=a.line??a.name,e=a.line?"min-w-0 truncate text-[13px] leading-5 break-keep":"min-w-0 truncate font-mono text-xs leading-5",f=(0,U.useServerRoute)(t.queryKey.bot).data,g=a.bot?f?.find(b=>b.name===a.bot)??null:null;return(0,d.jsxs)("span",{className:"flex max-w-full items-center gap-1.5",children:[(0,d.jsxs)("span",{className:"relative grid size-[18px] shrink-0 place-items-center",children:[(0,d.jsx)(fx,{tool:a,bot:g,icon:b}),!a.done&&(0,d.jsx)("span",{className:"absolute inset-0 grid animate-ink place-items-center",children:(0,d.jsx)(fx,{tool:a,bot:g,icon:b,running:!0})})]}),a.done&&a.sources?.length?(0,d.jsx)(B.SourceChips,{sources:a.sources,limit:2,className:"flex-nowrap"}):a.done?(0,d.jsx)("span",{className:(0,w.cn)(e,"text-muted-foreground"),children:c}):(0,d.jsx)(A.ShinyText,{text:c,className:e})]})}function fx({tool:a,bot:b,icon:c,running:e}){return a.bot?(0,d.jsx)("span",{className:(0,w.cn)("flex",!e&&!a.done&&"opacity-40"),children:(0,d.jsx)(H.BotMark,{size:16,seed:a.bot,color:b?.icon?.color,shape:b?.icon?.shape,outline:b?.icon?.outline,paint:b?.icon?.paint,notify:!1})}):(0,d.jsx)(c,{className:(0,w.cn)("size-3.5",e?"text-foreground":"text-muted-foreground",!e&&!a.done&&"opacity-40")})}function fy({tool:a,toolUp:b,thinkingSince:c,thinkingTitle:e,micOpen:f,getMicSpectrum:g}){let[h,i]=(0,s.useState)(a);(0,s.useEffect)(()=>{a&&i(a)},[a]);let{thought:j,title:k}=function(a,b){let[c,d]=(0,s.useState)(null!==a),[e,f]=(0,s.useState)(b);return(0,s.useEffect)(()=>{null!==a&&(d(!0),f(b))},[a,b]),{thought:c,title:e}}(c,e),l=null!==a,m=null!==c&&!b,n=f&&!l&&!m,o=a=>f&&(0,d.jsx)(fu,{live:a,getMicSpectrum:g});return(0,d.jsx)("div",{className:"flex h-7 max-w-full items-center justify-center",children:(0,d.jsxs)("div",{className:"grid min-w-0 items-center justify-items-center",children:[h&&(0,d.jsx)(fJ,{at:"col-start-1 row-start-1 max-w-full",shown:l,children:(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[o(l),(0,d.jsx)(fw,{tool:h})]})}),j&&(0,d.jsx)(fJ,{at:"col-start-1 row-start-1 max-w-full",shown:m,children:(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[o(m),(0,d.jsx)(fR,{title:k})]})}),(0,d.jsx)(fJ,{at:"col-start-1 row-start-1",shown:n,children:(0,d.jsx)(fv,{live:n,getMicSpectrum:g})})]})})}let fz=[1,.7,.45],fA=a=>a.id??`${a.kind??"tool"}:${a.name}`,fB={turns:{},owner:{},seen:{}};function fC({lines:a,shown:b}){let c=Math.max(0,a.length-3),e=a.length-c;return(0,d.jsx)("div",{"aria-hidden":!b,className:(0,w.cn)("pointer-events-auto relative w-full transition-opacity duration-300 ease-out",!b&&"pointer-events-none opacity-0"),style:{height:26*e},children:a.map((b,e)=>{let f=e-c;return(0,d.jsx)("div",{style:{transform:`translateY(${26*f}px)`,opacity:f<0?0:fz[a.length-1-e],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,d.jsx)("div",{className:"flex min-w-0 animate-in duration-300 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",children:(0,d.jsx)(fw,{tool:b})})},fA(b))})})}let fD={text:"CALL",hold:1/0},fE="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 fF({ringing:a,wakePhrase:b,onAnswer:c,onDecline:e}){let f=(0,U.useServerRoute)(t.queryKey.bot).data,g=(a,b)=>{let c=f?.find(b=>b.name===a.bot)?.icon;return(0,d.jsx)(H.BotMark,{size:b,seed:a.bot,color:c?.color,shape:c?.shape,outline:c?.outline,paint:c?.paint,notify:!1,className:"shrink-0"})},{first:h,others:i,missedAt:j}=a,[k,l]=(0,N.useAnswerThread)(),[m,n]=(0,s.useState)(null);if(null!==j){let a=[h,...i];return(0,d.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,d.jsxs)("div",{className:"flex w-full max-w-140 flex-col text-left",children:[(0,d.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,d.jsx)(o,{className:"size-3"}),(0,d.jsxs)("span",{children:["Missed · ",(0,d.jsx)(fG,{at:j})]}),(0,d.jsxs)("button",{type:"button",onClick:e,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,d.jsx)("kbd",{className:fE,children:"Esc"}),"clear"]})]}),a.slice(0,3).map(a=>(0,d.jsxs)("div",{className:"flex h-8.5 items-center gap-2.5",children:[g(a,20),(0,d.jsx)("span",{className:"w-32 shrink-0 truncate text-[13.5px]",children:a.label}),(0,d.jsx)("span",{className:"w-14 shrink-0 font-mono text-[10.5px] text-muted-foreground",children:fI[a.kind]}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px] text-muted-foreground",children:(0,w.plainText)(a.text)})]},a.id)),a.length>3&&(0,d.jsxs)("p",{className:"mt-1 font-mono text-[10.5px] text-muted-foreground",children:["+",a.length-3," more in the room"]})]}),(0,d.jsx)(u.Button,{variant:"brand",onClick:c,className:"mt-5 h-12 px-8 text-[15px]",children:"Call back"}),b&&(0,d.jsxs)("span",{className:"mt-3 flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground",children:["or say ",(0,d.jsx)(fH,{phrase:b})]})]})}return(0,d.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,d.jsxs)("span",{className:"flex max-w-full items-center gap-2 text-sm",children:[g(h,18),(0,d.jsx)("span",{children:h.bot}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,d.jsx)("span",{className:"truncate text-muted-foreground",children:h.label})]}),(0,d.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,w.plainText)(h.text)}),h.options.length>0&&(0,d.jsx)("span",{className:"flex max-w-full flex-wrap justify-center gap-1.5",children:h.options.map(a=>(0,d.jsx)(u.Button,{size:"sm",variant:"secondary",loading:m===a,disabled:l,onClick:async()=>{n(a),await k(h,a,h.bot,h.questionId??void 0),n(null)},className:"h-7 max-w-60 rounded-full px-3 text-[12.5px]",children:(0,d.jsx)("span",{className:"truncate",children:a})},a))}),(0,d.jsx)(u.Button,{variant:"brand",onClick:c,className:"mt-3 h-12 px-8 text-[15px]",children:"Answer"}),i.length>0&&(0,d.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:[i.slice(0,2).map(a=>(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[g(a,16),(0,d.jsx)("span",{className:"max-w-44 truncate text-foreground",children:a.label}),fI[a.kind]]},a.id)),i.length>2&&(0,d.jsxs)("span",{children:["+",i.length-2]})]}),(0,d.jsxs)("span",{className:"mt-1 flex items-center gap-3 font-mono text-[11px] text-muted-foreground",children:[b&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5",children:["say ",(0,d.jsx)(fH,{phrase:b})," to answer"]}),(0,d.jsxs)("button",{type:"button",onClick:e,className:"flex items-center gap-2 rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,d.jsx)("kbd",{className:fE,children:"Esc"}),"not now"]})]})]})}function fG({at:a}){let[b,c]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{let a=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(a)},[]),b-a<6e4?"just now":(0,e.formatDistanceStrict)(a,b,{addSuffix:!0})}function fH({phrase:a}){return(0,d.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-foreground/80",children:[(0,d.jsx)(k.Mic,{className:"size-3"}),a]})}let fI={question:"asks",done:"finished",stopped:"stopped"};function fJ({at:a,shown:b,children:c}){return(0,d.jsx)("span",{"aria-hidden":!b,className:(0,w.cn)("flex transition-opacity duration-300 ease-out",a,b?"opacity-100":"pointer-events-none opacity-0"),children:c})}let fK={quiet:`${D.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 fL({status:a,idleLeft:b,since:c,ended:e,behind:f,wakePhrase:g,hotkeyLabel:h}){let i,j,k="connecting"===a||"ending"===a,l="idle"!==a&&!k;return k?(j=a,i=(0,d.jsx)(A.ShinyText,{text:"connecting"===a?"Connecting…":"Ending…",className:"text-muted-foreground/70"})):l&&null!==b?(j="quiet",i=`Quiet — ending in ${b}s. Say anything to stay.`):l?(j=f?"behind":"live",i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"Tap Thursday to end"}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),f?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("kbd",{className:fE,children:"↓"}),(0,d.jsx)("span",{children:"back to now"})]}):(0,d.jsx)(fS,{since:c}),(0,d.jsx)(fM,{})]})):e?(j=`ended:${e}`,i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:["Ended — ",fK[e]]}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,d.jsx)("span",{children:"Tap to call again"})]})):g?(j=`wake:${g}`,i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.Letters,{text:"Tap Thursday, or say"}),(0,d.jsx)(fO,{at:500,children:(0,d.jsx)(fH,{phrase:g})}),(0,d.jsx)(fO,{at:fN,children:(0,d.jsx)(fP,{})})]})):h?(j=`key:${h}`,i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.Letters,{text:"Tap Thursday, or press"}),(0,d.jsx)(fO,{at:550,children:(0,d.jsx)("kbd",{className:fE,children:h})}),(0,d.jsx)(fO,{at:fN,children:(0,d.jsx)(fP,{})})]})):(j="tap",i=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.Letters,{text:"Tap Thursday to talk"}),(0,d.jsx)(fO,{at:fN,children:(0,d.jsx)(fP,{})})]})),(0,d.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:i},j)}function fM(){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,d.jsx)("button",{type:"button",onClick:()=>V.writeLine.draw(),className:"rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"Draw"})]})}let fN=900;function fO({at:a,children:b}){return(0,d.jsx)("span",{style:{animationDelay:`${a}ms`},className:"flex animate-in items-center gap-1.5 duration-700 fill-mode-backwards fade-in",children:b})}function fP(){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"px-1.5 text-muted-foreground/30",children:"·"}),(0,d.jsx)("span",{className:"text-muted-foreground",children:"@ to write"})]})}function fQ({open:a,onOpen:b,onClose:c}){let{data:e}=(0,U.useServerRoute)(t.queryKey.automaticModel),{data:f}=(0,U.useServerRoute)(t.queryKey.config),g=E.LIVE_LINES.find(a=>(0,ba.isConfigUnreadable)(f,F.TEXT_MODEL_PROVIDERS[a].apiKeyName)),h=(0,a9.useVoiceLine)(),i=h.signedIn&&!h.planCalls;return a?(0,d.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,d.jsxs)("div",{className:"flex h-6 items-center justify-between gap-2 pl-0.5",children:[(0,d.jsx)("span",{className:"text-[13px] font-medium",children:"Give her a voice"}),(0,d.jsx)(u.Button,{type:"button",size:"icon",variant:"ghost","aria-label":"Not now",onClick:c,className:"-my-1 size-6",children:(0,d.jsx)(q.X,{className:"size-3.5"})})]}),(0,d.jsx)(a9.CallLines,{})]}):(0,d.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,d.jsxs)("span",{className:"relative flex size-6 shrink-0 items-center justify-center",children:[(0,d.jsx)(H.BotMark,{size:24,seed:G.DEFAULT_BOT.name,color:G.DEFAULT_BOT.icon?.color,shape:G.DEFAULT_BOT.icon?.shape,outline:G.DEFAULT_BOT.icon?.outline,notify:!1}),(0,d.jsx)(m,{className:"absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full bg-muted text-muted-foreground"})]}),(0,d.jsx)("span",{className:"text-[13px] text-muted-foreground break-keep wrap-anywhere",children:"chatgpt"===g?"The ChatGPT sign-in saved for calls can't be unlocked any more — sign in again.":g?"The key saved for calls can't be unlocked any more — add it again.":i?`Your ${(0,F.planName)(h.plan)?`${(0,F.planName)(h.plan)} `:""}ChatGPT plan has no spoken calls — add an OpenAI key. Bots and writing already run on it.`:e&&!e.ref?"Sign in with ChatGPT and calls and bots run on your plan, or add a key.":"Calls need a GPT Subscription or an OpenAI key. Everything else here already works."}),(0,d.jsx)(u.Button,{size:"sm",variant:"brand",onClick:b,className:"h-7 px-3.5",children:"Set up"})]})}function fR({title:a}){let b=a?`Thinking \xb7 ${a}`:"Thinking";return(0,d.jsx)("span",{className:"flex max-w-full items-center text-[13px] leading-5",children:(0,d.jsx)(A.ShinyText,{text:b,className:"min-w-0 animate-in truncate fade-in duration-300"},b)})}function fS({since:a}){let[b,c]=(0,s.useState)(()=>Date.now());if((0,s.useEffect)(()=>{if(null===a)return;let b=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(b)},[a]),null===a)return null;let e=Math.max(0,Math.floor((b-a)/1e3)),f=String(Math.floor(e/60)).padStart(2,"0"),g=String(e%60).padStart(2,"0");return(0,d.jsxs)("span",{className:"tabular-nums",children:[f,":",g]})}a.s(["Thursday",0,function({ready:b}){let c=function(){let[a,b]=(0,s.useState)(null),c=(0,s.useRef)(a);c.current=a;let d=(0,s.useRef)(new Set),[e]=(0,an.useServerAction)(cO),f=(0,s.useRef)(null),g=(0,s.useRef)([]),[h,i]=(0,s.useState)([]),j=(0,s.useCallback)(a=>{g.current=a,i(a)},[]),k=(0,s.useRef)(new Map),l=(0,s.useRef)(0),[m,n]=(0,s.useState)(null),o=(0,s.useRef)(()=>{}),p=(0,s.useRef)(!1),[q,r]=(0,s.useState)(null),{messages:u,sendMessage:v,setMessages:x,status:y,stop:z,error:A,clearError:B}=(0,cy.useChat)({transport:c$,onFinish:a=>o.current(a),onData:a=>{if(a.type===`data-${cv.TEXT_CALL_REFUSED}`)return r(a.data.provider);a.type!==`data-${cv.TEXT_CALL_MOVED}`||p.current||(p.current=!0,cA.toast.add({type:"warning",title:"Answering on your OpenAI key",description:a.data.why}))}}),C="submitted"===y||"streaming"===y,E=(0,s.useRef)(u);E.current=u;let F=(0,s.useRef)(A);F.current=A;let G=(0,s.useRef)(""),H=(0,s.useCallback)((a,b=[])=>{let d=c.current;if(!d)return;let e=g.current;j([]);let h=crypto.randomUUID();f.current=h,r(null);let i=c_();G.current=JSON.stringify(i??null);let k=[...e.map(c0),...a?[{type:"text",text:a}]:[],...b.map(cv.picturePart)];v(k.length?{parts:k}:void 0,{body:{callId:d.callId,standing:d.standing,runsOn:i,turn:h,where:d.where}})},[v,j]),I=(0,s.useCallback)(()=>{let a=c.current;if(a){for(let a of(c.current=null,b(null),f.current=null,k.current.values()))cF.delete(a.key);k.current.clear(),j([]),l.current=0,p.current=!1,n(null),z(),x([]),B(),cN(a.callId).then(cE.unwrapResult).finally(()=>(0,U.revalidate)(t.queryKey.callHistory(null)))}},[z,x,B,j]),J=(0,s.useRef)(I);J.current=I,(0,s.useEffect)(()=>()=>J.current(),[]);let K=(0,s.useCallback)(a=>{j([...g.current,a]);let b=c.current,d=f.current;b&&d&&cP(b.callId,d,a).then(cE.unwrapResult).catch(()=>{})},[j]);(0,s.useEffect)(()=>V.screenActs.subscribe(a=>{c.current&&K({id:crypto.randomUUID(),text:cM(a),said:!1})}),[K]);let L=(0,s.useCallback)(async(a,g=[])=>{let h=g.filter(cD.isPicture),i=c.current;if(!i){let a=cY();c.current=i={...await e(c_()),at:Date.now(),where:a?.where??null},d.current=cG(O.current??[]),b(i)}if(l.current=0,f.current)return K({id:crypto.randomUUID(),text:a,said:!0,...h.length?{pictures:h}:{}});B(),H(a,h)},[e,K,B,H]),M=(0,s.useCallback)(()=>{let a=E.current,b=a.at(-1);if(c.current&&b){if("assistant"===b.role){let c=G.current!==JSON.stringify(c_()??null)?-1:b.parts.findLastIndex(a=>(0,cz.isToolUIPart)(a)&&!a.providerExecuted&&("output-available"===a.state||"output-error"===a.state));j([...(0,cv.notesIn)([{...b,parts:b.parts.slice(c+1)}]),...g.current]),x(c<0?a.slice(0,-1):[...a.slice(0,-1),{...b,parts:b.parts.slice(0,c+1)}])}B(),H(null)}},[H,x,B,j]),{data:N}=(0,U.useServerRoute)(t.queryKey.threads),O=(0,s.useRef)(N);O.current=N;let P=(0,s.useCallback)(()=>{if(!c.current||!O.current)return;let a=cL(O.current),b=new Set(a.map(a=>a.key)),e=g.current.filter(a=>{let c=k.current.get(a.id);return void 0!==c&&!b.has(c.key)});if(e.length){for(let a of e){let b=k.current.get(a.id);b&&cF.delete(b.key),k.current.delete(a.id)}j(g.current.filter(a=>!e.includes(a)))}for(let b of a){if(cF.has(b.key)||d.current.has(b.key))continue;cF.add(b.key);let a={id:crypto.randomUUID(),text:b.line,said:!1};k.current.set(a.id,{key:b.key,rows:b.relayIds,show:b.show}),f.current&&n(b.show),K(a)}if(f.current||F.current||l.current>=D.TEXT_CALL.autoTurns)return;let h=g.current.filter(a=>k.current.has(a.id)),i=h.length?k.current.get(h[h.length-1].id):null;i&&(l.current+=1,n(i.show),H(null))},[j,K,H]),Q=null!==a;(0,s.useEffect)(()=>{Q&&N&&P()},[Q,N,P]),o.current=({message:a,messages:b,isAbort:d,isError:e,isDisconnect:h})=>{if(d||!c.current)return;f.current=null;let i=new Set((0,cv.notesIn)([a]).map(a=>a.id));if(j(g.current.filter(a=>!i.has(a.id))),e||h)return;let l=new Set((0,cv.notesIn)(b).map(a=>a.id)),m=[];for(let[a,b]of k.current)l.has(a)&&(m.push(...b.rows),k.current.delete(a));if(m.length&&cC(m).then(cE.unwrapResult).catch(a=>cA.toast.add({type:"error",title:"Could not record relay delivery",description:(0,w.errorToString)(a)})),g.current.some(a=>a.said))return H(null);P()},(0,s.useEffect)(()=>{if(C||!m)return;let a=setTimeout(()=>n(null),D.CALL_LINE.lingerMs);return()=>clearTimeout(a)},[C,m]);let R=u.at(-1)?.role==="assistant"?u.at(-1):null,S=R?.parts??[],T=S.at(-1),W=(0,s.useMemo)(()=>{let a=[],b=!1,c=(c,d,e)=>{if(!e)return;let f=b&&"assistant"===d;"assistant"===d&&(b=!1),a.push({id:c,role:d,text:e,...f?{fresh:!0}:{}})};for(let a of u){if("system"===a.role)continue;let d=a.role,e=[],f=0,g=()=>{let b=e.join("\n\n").trim();e=[],c(`${a.id}:${f++}`,d,"assistant"===d?(0,w.captionText)(b):b)};for(let d of a.parts){"text"===d.type&&e.push(d.text);let a=(0,cv.noteOf)(d);a&&(g(),a.said?c(a.id,"user",a.text):b=!0)}g()}let d=new Set((0,cv.notesIn)(u).map(a=>a.id));for(let a of h)a.said&&!d.has(a.id)&&c(a.id,"user",a.text);return a},[u,h]),X=[...S].reverse().find(cz.isToolUIPart),Y=X?.toolCallId??null,Z=X?(0,cz.getToolName)(X):null,$=X?.state==="output-available"||X?.state==="output-error",_=X?.output,aa=(0,s.useMemo)(()=>$&&Z===cB.TOOL_NAMES.web_search?(0,cQ.searchSourcesOf)(JSON.stringify(_??null)):[],[$,Z,_]),ab=_?.action?.query,ac=JSON.stringify({..."string"==typeof ab?{query:ab}:{},...X?.input??{}}),ad=Z?(0,cQ.toolBot)(Z,ac,O.current,void 0===_?void 0:JSON.stringify(_)):null,ae=Z?(0,cQ.toolLine)(Z,ac,ad):null,af=T?.type==="text",ag=(0,s.useMemo)(()=>Y&&Z&&(!af||aa.length)?{id:Y,name:Z,line:ae,bot:ad,done:$,...aa.length?{sources:aa}:{}}:null,[Y,Z,ae,ad,$,aa,af]),[ah,ai]=(0,s.useState)(null),aj=ag?.done&&!ag.sources?ag.id:null;(0,s.useEffect)(()=>{if(!aj)return;let a=setTimeout(()=>ai(aj),D.CALL_LINE.lingerMs);return()=>clearTimeout(a)},[aj]);let ak=ag&&ag.id!==ah?ag:m,al=!!C&&T?.type!=="text"&&(!ag||!!ag.done),[am,ao]=(0,s.useState)(null);(0,s.useEffect)(()=>{ao(al?Date.now():null)},[al]);let ap=[...S].reverse().find(a=>"reasoning"===a.type),aq=al&&ap?.type==="reasoning"&&(0,cQ.reasoningTitle)(ap.text)||null,ar=a?C?T?.type==="text"?"speaking":ag&&!ag.done&&ag.name===cB.TOOL_NAMES.thread_start?"delegating":"working":"listening":"idle";return{on:null!==a,busy:C,status:ar,messages:W,tool:ak,thinkingSince:am,thinkingTitle:aq,since:a?.at??null,error:A?A.message:null,refused:A?q:null,say:L,again:M,end:I}}(),{status:e,failed:f,messages:g,tool:h,thinkingSince:i,thinkingTitle:j,ended:k,faceWord:l,idleLeft:m,since:n,call:o,ringing:p,decline:q,getSpectrum:r,getMicSpectrum:u,wakePhrase:v,hotkey:x}=function(b=!1){let c=(0,s.useRef)(null),{data:d}=(0,U.useServerRoute)(t.queryKey.thursdaySettings),e=(0,s.useRef)(null);e.current=(0,a9.useVoiceLine)(d?.runsOn??null).line;let f=(0,s.useRef)(null),g=(0,s.useRef)(null),[h,i]=(0,s.useState)("idle"),[j,k]=(0,s.useState)(!1),l=(0,s.useRef)(null),m=(0,s.useCallback)(a=>{l.current&&clearTimeout(l.current),l.current=a?setTimeout(()=>k(!1),6e3):null,k(a)},[]),[n,o]=(0,s.useState)([]),[p,q]=(0,s.useState)(null),[r,u]=(0,s.useState)(null),[v,x]=(0,s.useState)(null),[y,z]=(0,s.useState)(null),[A,B]=(0,s.useState)(null),[C,F]=(0,s.useState)(null),[G,H]=(0,s.useState)(null),I=ct(),J=I?.moment.kind==="here"&&null!==I.phase;(0,s.useEffect)(()=>{J&&function(a=new Date){let b=em(a);try{window.localStorage.setItem(el,b)}catch{en=b}}()},[J]),(0,s.useEffect)(()=>{let a,b,c;return b=!1,(c=async()=>{if(clearTimeout(a),"visible"!==document.visibilityState||(a=setTimeout(c,D.HERE.keptMs),await cZ(),b||"visible"!==document.visibilityState))return;let d=cR?cR.at+D.HERE.keptMs-D.HERE.lookMs-Date.now():0;clearTimeout(a),a=setTimeout(c,d>0?d:D.HERE.keptMs)})(),document.addEventListener("visibilitychange",c),window.addEventListener("online",c),()=>{b=!0,clearTimeout(a),document.removeEventListener("visibilitychange",c),window.removeEventListener("online",c)}},[]);let L=(0,s.useRef)(null),M=(0,s.useRef)(null),N=(0,s.useRef)({on:!1,spoke:!1,giveUp:null}),O=(0,s.useRef)(null),P=(0,s.useRef)(0),R=(0,s.useRef)(null),T=(0,s.useRef)(!1),W=(0,s.useRef)(null),X=(0,s.useRef)(null),Y=(0,s.useRef)(null),Z=(0,s.useRef)(cF),$=(0,s.useRef)(new Set),_=(0,s.useRef)(new Set),aa=(0,s.useRef)([]),ab=(0,s.useRef)([]),ac=(0,s.useRef)(0),ad=(0,s.useRef)(null),ae=(0,s.useRef)(0),af=(0,s.useRef)(!1),ag=(0,s.useRef)(!1),ah=(0,s.useRef)(void 0),ai=(0,s.useRef)(null),aj=ai.current??=ei(),ak=(0,s.useRef)(null),al=ak.current??=ei(),am=(0,s.useRef)(!1),an=(0,s.useRef)(!1),ao=(0,s.useRef)(!1),ap=(0,s.useRef)(0),aq=(0,s.useCallback)(a=>{R.current&&clearTimeout(R.current),T.current=!1;let b=(0,cQ.toolBot)(a.name,a.arguments,ah.current);q({id:a.id,name:a.name,line:(0,cQ.toolLine)(a.name,a.arguments,b),bot:b,done:!1})},[]),ar=(0,s.useCallback)((a,b)=>{let c=(0,cQ.toolBot)(a.name,a.arguments,ah.current,b);c&&q(b=>b?.id===a.id&&b.bot!==c?{...b,bot:c,line:(0,cQ.toolLine)(a.name,a.arguments,c)}:b)},[]),as=(0,s.useCallback)(a=>{R.current&&clearTimeout(R.current),T.current=!0,q({...a,done:!1})},[]),at=(0,s.useCallback)(a=>{q(b=>b?.id===a?{...b,done:!0}:b),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>q(a=>a?.done?null:a),D.CALL_LINE.lingerMs)},[]),au=(0,s.useCallback)(()=>{if(N.current.giveUp&&clearTimeout(N.current.giveUp),N.current.spoke){for(let a of aa.current)$.current.delete(a);let a=ab.current;a.length&&cC(a).then(cE.unwrapResult).catch(a=>cA.toast.add({type:"error",title:"Could not record relay delivery",description:(0,w.errorToString)(a)}))}ab.current=[],aa.current=[],N.current={on:!1,spoke:!1,giveUp:null},T.current&&(T.current=!1,q(a=>a?.kind==="relay"?{...a,done:!0}:a),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>q(a=>a?.kind==="relay"?null:a),D.CALL_LINE.relayLingerMs))},[]),av=(0,s.useCallback)(()=>{N.current.giveUp&&clearTimeout(N.current.giveUp),N.current={on:!0,spoke:!1,giveUp:setTimeout(au,D.CALL_RELAY.readMs)}},[au]),aw=(0,s.useCallback)(a=>{L.current=a,B(a),F(null)},[]),ax=(0,s.useCallback)((a,b)=>{let c=()=>{M.current&&clearTimeout(M.current),M.current=null};if(b){c(),null!==L.current&&aw(null);return}if(a){c(),null===L.current&&aw(Date.now());return}null===L.current||M.current||(M.current=setTimeout(()=>{M.current=null,aw(null)},D.CALL_LINE.thinkingTailMs))},[aw]),ay=(0,s.useCallback)(()=>{let a=c.current,b=ah.current;if(!a||!b||N.current.on||ag.current||null!==L.current||ad.current)return;let d=af.current;if(af.current=!1,!d&&Date.now()-ae.current<D.CALL_RELAY.quietMs)return;let e=cL(b).filter(a=>!Z.current.has(a.key)&&!_.current.has(a.key)),f=e[0];if(!f)return;let g=e.filter(a=>a.kind===f.kind).slice(0,D.CALL_RELAY.perTurn),h=g.map(a=>a.line);for(let a of g)Z.current.add(a.key),$.current.add(a.key);f.key.startsWith("done:")&&!cs.current()&&H((0,ek.finished)()),av(),aa.current=g.map(a=>a.key),ab.current=g.flatMap(a=>a.relayIds),as((g.at(-1)??f).show),a.append("commentary",1===h.length?h.join(""):`[${h.length} updates.]
|
|
11
11
|
|
|
12
|
-
${h.join("\n\n")}`).then(a=>{a||(ab.current=[],au())})},[av,au,as]),az=(0,s.useRef)(h);(0,s.useEffect)(()=>{az.current=h},[h]);let aA=(0,s.useRef)("listening"),aB=(0,s.useRef)(null),aC=(0,s.useCallback)(()=>{aB.current&&clearTimeout(aB.current),aB.current=null},[]),aD=(0,s.useCallback)(a=>{az.current=a,i(a)},[]),aE=(0,s.useCallback)(a=>{aA.current=a;let b=az.current;if("speaking"===a){aC(),aD(a);return}let c="working"===a||"delegating"===a;if(c&&("working"===b||"delegating"===b)){aC(),aD(a);return}c||"listening"!==b?aB.current||(aB.current=setTimeout(()=>{aB.current=null,aD(aA.current)},c?800:600)):aC()},[aC,aD]),aF="idle"!==h&&"connecting"!==h&&"ending"!==h,{data:aG}=(0,U.useServerRoute)(t.queryKey.threads,{refreshInterval:D.INBOX_POLL_MS}),aH=(0,s.useRef)(!1);(0,K.useAppEvent)({hello:()=>{if(!aH.current){aH.current=!0;return}(0,U.revalidateAll)()},threads:()=>void(0,U.revalidate)(t.queryKey.threads),routines:()=>void(0,U.revalidate)(t.queryKey.routines),memory:()=>void(0,U.revalidate)(t.queryKey.memory),mcp:()=>{(0,U.revalidate)(t.queryKey.mcp),(0,U.revalidate)(t.queryKey.mcpTools)},config:()=>{(0,U.revalidate)(t.queryKey.config),(0,U.revalidate)(t.queryKey.llmModel)}});let{data:aI}=(0,U.useServerRoute)(t.queryKey.bot);(0,s.useEffect)(()=>{aG&&V.botThreads.sync(aG,aI)},[aG,aI]),(0,s.useEffect)(()=>{ah.current=aG},[aG]);let aJ=function({threads:a,resting:b,writing:c}){let d=(0,s.useRef)(Date.now()),[e,f]=(0,s.useState)([]),[g,h]=(0,s.useState)(null),i=e.length>0,j=(0,cw.useThursdayStore)(a=>a.callBack),k=(0,V.useRoomThread)(),l=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{let b=k&&a?.find(a=>a.id===k);b&&l.current.set(b.id,(0,S.toDate)(b.updatedAt).getTime())},[k,a]),(0,s.useEffect)(()=>{if(!a)return;let e=new Set(a.filter(a=>{let b,c;return b=a,"off"!==(c=j)&&!b.seen&&(b.room.questions.length>0||"any"===c&&"running"!==b.status)}).map(a=>a.id));if(f(a=>a.every(a=>e.has(a))?a:a.filter(a=>e.has(a))),!b||c||k)return;let g=d.current,i=a.filter(a=>e.has(a.id)&&(0,S.toDate)(a.updatedAt).getTime()>Math.max(g,l.current.get(a.id)??0));i.length&&(d.current=Math.max(...i.map(a=>(0,S.toDate)(a.updatedAt).getTime())),h(null),f(a=>[...a,...i.map(a=>a.id).filter(b=>!a.includes(b))]))},[a,j,b,c,k]),(0,s.useEffect)(()=>{c?(f([]),h(null)):d.current=Date.now()},[c]);let m=(0,s.useCallback)(()=>{f([]),h(null)},[]);(0,Q.useEscape)(i,m),(0,s.useEffect)(()=>{if(!i||null!==g)return;let a=setTimeout(()=>h(Date.now()),D.CALL_BACK.ringMs);return()=>clearTimeout(a)},[i,g]),(0,s.useEffect)(()=>{if(i&&null===g){let a;return(a=new Audio("/sounds/ring.ogg")).play().catch(()=>{}),()=>a.pause()}},[i,g]);let n=(0,s.useMemo)(()=>{let[b,...c]=e.flatMap(b=>{let c=a?.find(a=>a.id===b);if(!c)return[];let d=c.room.questions[0];return[{id:c.id,bot:d?.bot??c.bot,kind:d?"question":"done"===c.status?"done":"stopped",label:c.label,text:d?.text??c.outcome??c.ask?.question??c.label,options:d?.options??[],questionId:d?.id??null}]});return b?{first:b,others:c,missedAt:g}:null},[e,a,g]);(0,s.useEffect)(()=>{V.ringingThreads.set(e)},[e]);let o=(0,s.useCallback)(()=>{f([]),h(null)},[]);return{ringing:n,isRinging:i,ringingFor:e,answered:o,unanswered:(0,s.useCallback)(a=>{a.length&&(f(b=>[...a,...b.filter(b=>!a.includes(b))]),h(Date.now()))},[]),settle:(0,s.useCallback)(()=>{d.current=Date.now()},[]),decline:m}}({threads:aG,resting:"idle"===h,writing:b}),{answered:aK,unanswered:aL,settle:aM}=aJ;(0,s.useEffect)(()=>V.screenActs.subscribe(a=>{if(!am.current)return;let b=cM(a);"gave"===a.kind?al.send({fact:b,pictures:a.paths.filter(cD.isPicture)}):"showed"===a.kind?al.send({fact:b,pictures:[a.path],run:!0}):aj.send(b)}),[aj,al]);let aN=(0,s.useCallback)(async(a=null)=>{if(ao.current)return;ao.current=!0,ad.current&&clearInterval(ad.current),ad.current=null,ap.current+=1;let b=c.current,d=X.current;for(let a of(c.current=null,X.current=null,am.current=!1,an.current=!1,cs.clear(),af.current=!1,$.current))Z.current.delete(a);$.current.clear(),aj.close(),aj.clear(),al.close(),al.clear(),W.current?.abort(),W.current=null,N.current.spoke=!1,au(),R.current&&clearTimeout(R.current),aC(),aM(),x(null),u(null),i(b?"ending":"idle"),b&&H((0,ek.goodbye)()),o([]),q(null),aw(null),M.current&&clearTimeout(M.current),M.current=null,T.current=!1,await b?.close(),Y.current?.(),Y.current=null;let e=O.current;O.current=null,ao.current=!1,i("idle"),b&&z(a),d&&cN(d,e),b&&g.current&&(g.current.currentTime=0,g.current.play().catch(()=>{}))},[aj,al,aC,au,aw]);(0,s.useEffect)(()=>{let a=()=>{let a=X.current;a&&navigator.sendBeacon(t.queryKey.callEnd,a)};return window.addEventListener("pagehide",a),()=>window.removeEventListener("pagehide",a)},[]),(0,s.useEffect)(()=>()=>{ap.current+=1,Y.current?.(),Y.current=null,c.current?.close(),c.current=null;let a=X.current;for(let b of(X.current=null,am.current=!1,an.current=!1,a&&cN(a),$.current))Z.current.delete(b);$.current.clear(),W.current?.abort(),W.current=null,R.current&&clearTimeout(R.current),aB.current&&clearTimeout(aB.current),N.current.giveUp&&clearTimeout(N.current.giveUp),M.current&&clearTimeout(M.current),l.current&&clearTimeout(l.current),ad.current&&clearInterval(ad.current),cs.clear()},[]);let aO=(0,s.useCallback)(()=>{if(ad.current)return;let a=Date.now();ad.current=setInterval(()=>{let b=Date.now();((ac.current>a-D.CALL_END.unsaidMs?b-Math.max(ac.current,a)>=D.CALL_END.quietMs:b-a>=D.CALL_END.unsaidMs)||b-a>=D.CALL_END.maxMs)&&aN("hungUp")},100)},[aN]);(0,s.useEffect)(()=>{if(!aF)return;P.current=Date.now();let a=setInterval(()=>{if(!c.current)return;let a=D.CALL_IDLE.hangUpMs-(Date.now()-P.current);x(a<=D.CALL_IDLE.warnMs?Math.max(0,Math.ceil(a/1e3)):null),a<=0&&!N.current.on&&aN("quiet")},1e3);return()=>clearInterval(a)},[aF,aN]),(0,s.useEffect)(()=>{if(!aF)return;let a=setInterval(ay,1e3);return()=>clearInterval(a)},[aF,ay]);let aP=(0,s.useCallback)(async()=>{let b,d,j=aJ.isRinging,k=aJ.ringingFor;if(an.current||ao.current)return;if(am.current||"idle"!==h)return aN();aK(),(0,c2.askToNotify)(),i("connecting"),z(null),m(!1),an.current=!0,am.current=!0,O.current=null,aj.clear(),al.clear(),ap.current+=1;let l=ap.current,n=()=>am.current&&ap.current===l,p={server:!1},r=e.current,s=(b=performance.now(),d={},{at(a){let c=performance.now();d[a]=c-b,performance.measure(`call ${a}`,{start:b,end:c})},say(){let a=Object.entries(ev).flatMap(([a,b])=>{let c=d[a];return void 0===c?[]:[`${b} at ${Math.round(c)} ms`]});console.debug(`The call opened: ${a.join(", ")}.`)}});try{f.current??=(0,eh.createAudioTap)(),function(a){if("suspended"!==a.state||ez)return;ez=!0;let b=()=>{ez=!1,window.removeEventListener("pointerdown",b),window.removeEventListener("keydown",b),a.resume().catch(()=>{})};window.addEventListener("pointerdown",b),window.addEventListener("keydown",b),cA.toast.add({type:"warning",title:"Tap anywhere to hear her",description:"This call opened on its own, so the browser is holding the audio."})}(f.current.open().context);let b=new Audio("/sounds/start_voice.ogg");g.current??=new Audio("/sounds/end_voice.ogg");let d=cY(),e=d?.where.weather,h=e&&!j&&function(a=new Date){let b=em(a);if(en===b)return!1;try{return window.localStorage.getItem(el)!==b}catch{return!0}}()&&"visible"===document.visibilityState&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches?Promise.race([Promise.all([(0,eo.loadWorld)(),a.A(372511)]).then(()=>!0,a=>(console.warn(`No globe on this call: ${(0,w.errorToString)(a)}`),!1)),new Promise(a=>setTimeout(()=>a(!1),D.HERE.waitMs))]):null,i=await (!("locks"in navigator)?Promise.resolve(()=>{}):new Promise(a=>{navigator.locks.request("thursday-spoken-call",{ifAvailable:!0},b=>b?new Promise(b=>a(()=>b())):void a(null))}));if(!i)throw new ex("A call is already on in another tab of this app. Hang up there, or go on there.");Y.current=i;let k=new AbortController;W.current=k;let l={failures:0},t={failures:0},v={callId:"",opening:null,here:null,standing:null,opened:{webSearch:E.LIVE_DEFAULTS.webSearch,readSkills:E.LIVE_DEFAULTS.readSkills}},x=new Map,y=new Map,z=null,A=a=>{let b={query:a.query,sources:a.sources};return eB(l,()=>eu(v.callId,[{id:a.row,role:"tool",tool:cB.TOOL_NAMES.web_search,text:JSON.stringify(b),seq:Math.max(0,Math.round(a.seq)),fragments:null}])),!!a.sources.length&&z===a.id&&(R.current&&clearTimeout(R.current),q(c=>c&&c.id!==a.id?c:{id:a.id,name:cB.TOOL_NAMES.web_search,line:(0,cQ.toolLine)(cB.TOOL_NAMES.web_search,JSON.stringify(b)),done:!0,bot:null,sources:a.sources}),!0)},B=await ee({initialize:async a=>{s.at("offer");let b=!!(h&&await h&&"visible"===document.visibilityState);h&&s.at("globe"),p.server=!0;let c=(0,cE.unwrapResult)(await es(a,j,d?.where??null,b));if(s.at("answer"),!n())throw cN(c.callId),Error("The call closed during startup.");return X.current=c.callId,v.callId=c.callId,v.opening=c.opening,v.here=c.here&&d&&e?{...d.position,code:d.country,weather:e}:null,v.standing=c.standing,v.opened=c.opened,c.relay?{sdp:c.sdp,relay:c.relay}:c.sdp},audio:f.current,on:{runTool:async a=>{if(a.name===cB.TOOL_NAMES.end_call)return aO(),"Ending the call.";if(a.name===cB.TOOL_NAMES.emote){if(cs.current())return"Nothing was shown: their screen is showing where they are for a few seconds more.";let{word:b,reply:c}=function(a){let b="";try{let c=JSON.parse(a);c&&"object"==typeof c&&"text"in c&&(b=String(c.text??"").trim())}catch{b=""}let c=Array.from(b).length;if(!c)return{word:null,reply:"Nothing was shown: text is empty."};if(c>ej.FACE_WORD_MAX)return{word:null,reply:`Too long: ${c} characters, ${ej.FACE_WORD_MAX} at most. Nothing was shown.`};let d=(0,ej.undrawable)(b);return d?{word:null,reply:`Cannot draw "${d}"; use only the characters \`text\` lists. Nothing was shown.`}:{word:b.toUpperCase(),reply:"Shown."}}(a.arguments);return b&&H({text:b,at:Date.now()}),c}aq(a);let b=a.name===cB.TOOL_NAMES.web_search;b&&(z=a.id);let c=!1;try{let d=await c1(v.callId,a,v.opened,k.signal);ar(a,d);let e=a.name===cB.TOOL_NAMES.thread_start?function(a){try{let{threadId:b,bot:c,label:d}=JSON.parse(a);return"string"==typeof b&&"string"==typeof c&&"string"==typeof d?{bot:c,label:d}:null}catch{return null}}(d):null;return e&&aj.send((({bot:a,label:b})=>`${a} took "${b}" and is working on it now.`)(e)),b&&(c=A({id:a.id,row:a.item??a.id,query:(0,cQ.searchQueryOf)(a.arguments),sources:(0,cQ.searchSourcesOf)(d),seq:0})),d}finally{c||at(a.id)}},search:a=>{if(!a.done){z=a.id,aq({id:a.id,name:cB.TOOL_NAMES.web_search,arguments:JSON.stringify({query:a.query})});return}let b={id:a.id,row:a.id,query:a.query,sources:a.sources,seq:a.seq};y.set(a.responseId,b),A(b)||at(b.id)},cited:(a,b)=>{let c=y.get(a);if(!c)return;let d=new Set(c.sources.map(a=>a.url));c.sources=[...c.sources.map(a=>b.find(b=>b.url===a.url)??a),...b.filter(a=>!d.has(a.url))],A(c)},reasoning:a=>{let b=(0,cQ.reasoningTitle)(a.text);b&&F(b),eB(t,()=>et(v.callId,{...a,seq:Math.max(0,Math.round(a.seq))}),"The backend's thinking is not being saved")},turn:a=>{let b="tool"===a.role?"":eA(a.text),c=!!b&&b!==eA(x.get(a.id)?.text??"");if(c&&(ae.current=Date.now()),c&&"user"===a.role&&(P.current=Date.now(),z)){let a=z;z=null,q(b=>b?.id===a?null:b)}"tool"!==a.role&&X.current===v.callId&&(x.set(a.id,{seq:a.seq,id:a.id,role:a.role,text:a.text}),o([...x.values()].sort((a,b)=>a.seq-b.seq).slice(-D.CALL_PAGE.scrollback))),a.done&&eB(l,()=>eu(v.callId,[{id:a.id,role:a.role,tool:a.tool,text:a.text,seq:Math.max(0,Math.round(a.seq)),fragments:a.fragments??null}]))},activity:a=>{var b;aE((b=a).speaking?"speaking":b.working||b.tools.length?b.tools.includes(cB.TOOL_NAMES.thread_start)?"delegating":"working":"listening");let c=a.working||a.tools.length>0;ag.current=c,ax(c,a.speaking),a.speaking&&(ac.current=Date.now()),(a.speaking&&!N.current.on||a.working||a.tools.length)&&(P.current=Date.now()),N.current.on&&(a.speaking?N.current.spoke=!0:N.current.spoke&&au())},finalized:a=>{O.current=a},warn:a=>cA.toast.add({type:"warning",title:"Call warning",description:a}),failed:a=>{let b=O.current?.reason;if("expired"===b||"remote_hangup"===b)return void aN("expired"===b?"expired":"closed");if("content"===b){cA.toast.add({type:"warning",title:"Live ended the call",description:"Its safety filter stopped the conversation."}),aN("closed");return}cA.toast.add({type:"error",title:ew(r,!1),description:a}),m(!0),aN(O.current?"closed":"dropped")}}});if(!n())return void await B.close();s.at("line"),s.say(),c.current=B,an.current=!1,af.current=j,_.current=j?new Set:cG(ah.current??[]);let C=a=>void B.append("thinking",a);aj.open(C),al.open(a=>void er(B,a,eq,C).catch(a=>cA.toast.add({type:"error",title:"What you put down did not reach the backend",description:(0,w.errorToString)(a)}))),ae.current=Date.now(),v.here&&cs.show({kind:"here",scene:v.here}),v.opening&&(av(),B.holdInput(D.LIVE_CALL.openingHoldMs),B.append("instructions",v.opening).then(a=>{a||au()})),v.standing&&B.brief(v.standing),aD("listening"),u(Date.now()),b.play().catch(()=>{})}catch(a){if(Y.current?.(),Y.current=null,n()&&a instanceof ex)cA.toast.add({type:"warning",title:"One call at a time",description:a.message});else if(n()){let b;cA.toast.add({type:"error",description:("refused"===(b=(0,ep.micProblem)(a))?"This page is not allowed the microphone. The icon at the left of the address bar opens the site's settings: set Microphone to Allow, then call her again.":"missing"===b?"No microphone was found. Plug one in or switch it on, then call her again.":"busy"===b?"The microphone would not start. Another app may be using it: close that app, then call her again.":null)??(0,w.errorToString)(a),title:p.server?ew(r,!0):"Could not start the call"}),m(!0),j&&aL(k)}if(ap.current!==l)return;X.current&&cN(X.current),X.current=null,an.current=!1,am.current=!1,W.current=null,aj.clear(),al.clear(),i("idle")}},[h,aN,aq,ar,at,aE,aD,aj,al,av,au,ax,m,aO,aJ.isRinging,aJ.ringingFor,aK,aL]);(0,s.useEffect)(()=>{if(!y)return;let a=setTimeout(()=>z(null),D.CALL_ENDED_MS);return()=>clearTimeout(a)},[y]);let aQ=(0,s.useCallback)(()=>f.current?.read()??ey,[]),aR=(0,s.useCallback)(()=>f.current?.readMic()??ey,[]),aS=(0,cw.useThursdayStore)(a=>a.wake),[aT,aU]=(0,s.useState)(!1);(0,s.useEffect)(()=>aU(!1),[aS.enabled,aS.phrase]);let aV=(0,cm.useCallHeld)();(0,s.useEffect)(()=>cm.callSignal.onPlace(()=>void aP()),[aP]),function({enabled:a,onWake:b,phrases:c,onError:d}){let e=(0,s.useRef)({onWake:b,onError:d,phrases:c});e.current={onWake:b,onError:d,phrases:c},(0,s.useEffect)(()=>{if(!a)return;let b=window,c=b.SpeechRecognition??b.webkitSpeechRecognition;if(!c)return void e.current.onError?.("This browser cannot listen for a wake word");let d=new c,f=!0,g=!0,h=null,i=300;d.lang="en-US",d.continuous=!0,d.interimResults=!0,d.maxAlternatives=3;let j=()=>{if(f){g=!0;try{d.start()}catch{}}};return d.onresult=({resultIndex:a,results:b})=>{if(!f||!g)return;i=300;let{phrases:c,onWake:h}=e.current,j=c.map(c4).filter(a=>a.length);for(let c=a;c<b.length;c++){let a=b[c];for(let b=0;b<a.length;b++){let c=a[b].transcript,e=c4(c);if(j.some(a=>(function(a,b,c){for(let d=0;d<a.length;d++)if(function a(b,c,d,e,f){if(e===d.length)return!0;if(c>=b.length)return!1;let g=d[e],h=Math.max(1,Math.round(g.length*f));return!!(c5(b[c],g,h)&&a(b,c+1,d,e+1,f))||c+1<b.length&&c5(b[c]+b[c+1],g,h)&&a(b,c+2,d,e+1,f)}(a,d,b,0,c))return!0;return!1})(e,a,D.WAKE_TOLERANCE))){g=!1,d.abort(),h(c.trim());return}}}},d.onerror=({error:a})=>{let b=c3[a];b?(f=!1,e.current.onError?.(b)):"network"===a&&(i=Math.min(2*i,1e4))},d.onend=()=>{f&&(h=setTimeout(j,i))},j(),()=>{f=!1,h&&clearTimeout(h),d.onresult=null,d.onerror=null,d.onend=null,d.abort()}},[a])}({enabled:"idle"===h&&aS.enabled&&!aT&&!aV,phrases:[aS.phrase],onWake:()=>void aP(),onError:a=>{aU(!0),cA.toast.add({type:"error",title:"Wake word off",description:a})}});let aW=(0,cw.useThursdayStore)(a=>a.hotkey),aX="connecting"===h||"ending"===h;return(0,Q.useHotkey)({enabled:aW.enabled&&!aX&&!aV,combo:aW.enabled&&(0,Q.isCombo)(aW.combo)?aW.combo:null,onPress:()=>void aP()}),{status:h,failed:j,messages:n,tool:p,ended:y,thinkingSince:A,thinkingTitle:C,faceWord:G,idleLeft:v,since:r,call:aP,ringing:aJ.ringing,decline:aJ.decline,getSpectrum:aQ,getMicSpectrum:aR,wakePhrase:aS.enabled&&!aT?aS.phrase:null,hotkey:aW.enabled&&(0,Q.isCombo)(aW.combo)?aW.combo:null}}(c.on),y=(0,Q.useHotkeyLabel)(x),z=(0,cw.useThursdayStore)(a=>a.captionView),{data:A}=(0,U.useServerRoute)(t.queryKey.config),B=(0,a9.useVoiceLine)(),C=B.known?null!==B.line:b,G="idle"!==e,H=c.end;(0,s.useEffect)(()=>{G&&c.on&&H()},[G,c.on,H]);let I=c.on&&!G,J=(0,cw.useThursdayStore)(a=>a.textModel),{settings:L}=(0,cx.useLiveSettings)(),M=L?.backendModel??E.LIVE_DEFAULTS.backendModel,N=(0,s.useMemo)(()=>{let a=a=>(0,ba.isConfigSet)(A,a),b=(0,cv.textCallRunsOn)(a),d=J&&a(F.TEXT_MODEL_PROVIDERS[J.provider].apiKeyName)?J:b?{provider:b,model:M}:null;return{on:I,busy:c.busy,error:c.error,refused:c.refused,say:c.say,again:c.again,end:c.end,runsOn:d,fallback:d?.provider!=="openai"&&a(F.TEXT_MODEL_PROVIDERS.openai.apiKeyName)?{provider:"openai",model:M}:null}},[I,c.busy,c.error,c.refused,c.say,c.again,c.end,A,J,M]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(eQ,{live:"idle"!==e,ringing:null!==p}),(0,d.jsx)(fk,{status:I?c.status:e,failed:I?null!==c.error:f,messages:I?c.messages:g,tool:I?c.tool:h,thinkingSince:I?c.thinkingSince:i,thinkingTitle:I?c.thinkingTitle:j,ended:k,faceWord:l,onTap:o,ringing:C?p:null,onDecline:q,wakePhrase:v,hotkeyLabel:y,idleLeft:m,since:n,getSpectrum:I?cu.silentVoice:r,getMicSpectrum:u,captionView:z,callable:C,written:G?null:N})]})}],137079)},113608,540990,511576,36304,444324,650485,645323,152659,158697,77453,526496,587479,a=>{"use strict";var b=a.i(164831);let c={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};c.node;let d=(0,b.default)(c);a.s(["ChevronUp",0,d],113608);let e={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"}]]};e.node;let f=(0,b.default)(e);a.s(["Mic",0,f],540990);var g=a.i(187924),h=a.i(572131);let i=new Intl.Segmenter(void 0,{granularity:"grapheme"});function j({text:a,wraps:b=[]}){let c=(0,h.useMemo)(()=>Array.from(i.segment(a),a=>a.segment),[a]),d=(0,h.useRef)([]),e=0;for(;e<c.length&&c[e]===d.current[e];)e++;(0,h.useEffect)(()=>{d.current=c},[c]);let f=a=>(0,g.jsx)(k,{wait:25*Math.max(0,a-e),children:c[a]},`${c[a]}${a}`),l=[];for(let a=0;a<c.length;){let d=b.find(b=>b.from===a&&b.to>a);if(!d){l.push(f(a)),a+=1;continue}let e=Math.min(d.to,c.length),i=[];for(let b=a;b<e;b++)i.push(f(b));l.push((0,g.jsx)(h.Fragment,{children:d.render(i)},`wrap${a}`)),a=e}return(0,g.jsx)("span",{children:l})}function k({wait:a,children:b}){let[c]=(0,h.useState)(a);return(0,g.jsx)("span",{style:{animationDelay:`${c}ms`},className:"animate-letter motion-reduce:animate-none",children:b})}a.s(["Letters",0,j],511576);var l=a.i(287702);let m={wave:740,done:740,ask:820,took:740,give:900,take:520,stop:1150,read:560},n={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"}},o={key:0,body:"",shape:"animate-crew-breath",turn:"",delayMs:0};function p(){let[a,b]=(0,h.useState)(!0);return(0,h.useEffect)(()=>{let a=setTimeout(()=>b(!1),l.CREW_REST.awakeMs),c=()=>{"visible"===document.visibilityState&&(clearTimeout(a),b(!0),a=setTimeout(()=>b(!1),l.CREW_REST.awakeMs))};return window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),()=>{clearTimeout(a),window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c)}},[]),a}a.s(["motionOf",0,function(a,b){if(!a)return{...o,delayMs:-370*b};let c=n[a.gesture];return{key:a.id,body:c.body??"",shape:c.shape??"animate-crew-breath",turn:c.turn??"",delayMs:"wave"===a.gesture?70*b:0}},"useCrewAwake",0,p,"useCrewGestures",0,function(){let[a,b]=(0,h.useState)(new Map),c=(0,h.useRef)(new Map),d=(0,h.useRef)(0);return(0,h.useEffect)(()=>{let a=c.current;return()=>{for(let b of a.values())clearTimeout(b);a.clear()}},[]),[a,(0,h.useCallback)(a=>{a.length&&b(e=>{let f=new Map(e);for(let{bot:e,gesture:g}of a){d.current+=1,f.set(e,{gesture:g,id:d.current});let a=c.current.get(e);a&&clearTimeout(a),c.current.set(e,setTimeout(()=>{c.current.delete(e),b(a=>{let b=new Map(a);return b.delete(e),b})},m[g]+1400*("wave"===g)))}return f})},[])]}],36304);let q=!1,r=new Set,s=new Set;a.s(["callSignal",0,{hold(a){if(a!==q)for(let b of(q=a,r))b()},place(){for(let a of s)a()},onPlace:a=>(s.add(a),()=>{s.delete(a)})},"useCallHeld",0,function(){return(0,h.useSyncExternalStore)(a=>(r.add(a),()=>r.delete(a)),()=>q,()=>!1)}],444324);var t=a.i(483253);a.s(["silentVoice",0,function(){let a=performance.now()/1e3;return Array.from({length:t.SPECTRUM_BANDS},(b,c)=>.18+.16*Math.sin(a*(5+.9*c)+1.7*c)**2)}],650485);var u=a.i(474215),v=a.i(986368),w=a.i(767561),x=a.i(340695),y=a.i(864037),z=a.i(785395),A=a.i(411509),B=a.i(321799),C=a.i(913834),D=a.i(135432),E=a.i(38793),F=a.i(559553),G=a.i(199169),H=a.i(576271),I=a.i(759497),J=a.i(497895),K=a.i(369768);let L={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},M="thursday.corner-dismissed";function N(){try{let a=JSON.parse(window.localStorage.getItem(M)??"[]");return Array.isArray(a)?a:[]}catch{return[]}}function O(a){try{let b=[...a,...N().filter(b=>!a.includes(b))].slice(0,50);window.localStorage.setItem(M,JSON.stringify(b))}catch{}}function P(a){return{threadId:a.id,label:a.label,bot:a.bot.name,words:(0,J.plainText)(a.outcome??"").slice(0,l.FINISHED_NOTICE.words),paths:(0,F.leadFirst)((0,F.pathsIn)(a.outcome??"")),unchecked:!0}}function Q({row:a,children:b}){let c=a.unchecked&&a.paths.length>0,{data:d}=(0,I.useServerRoute)(c?w.queryKey.workspaceFiles(a.paths):null);if(!c)return b(a);if(!d)return null;let e=new Set(d.map(a=>a.path));return b({...a,paths:(0,F.leadFirst)(a.paths.filter(a=>e.has(a)))})}function R({talking:a}){let[b,c]=(0,h.useState)([]),[d,e]=(0,h.useState)(!1);(0,h.useEffect)(()=>{a||e(!1)},[a]);let{data:f}=(0,I.useServerRoute)(w.queryKey.bot),i=(0,D.useBotThreads)(),j=(0,K.useOpenFile)();(0,h.useEffect)(()=>D.fileOpens.subscribe(a=>{j(a)}),[j]),(0,v.useAppEvent)({showFile:a=>j(a.paths[0],a.paths.filter(a=>"image"===(0,F.viewKindOf)(a)),!0),finished:a=>{!function(a,b,c){if(!("u"<typeof Notification)&&"granted"===Notification.permission&&!("visible"===document.visibilityState&&document.hasFocus()))try{let d=new Notification(b,{body:c,tag:a,icon:"/icon.svg"});d.onclick=()=>{window.focus(),d.close()}}catch{}}(a.threadId,a.label,a.words),c(b=>[{threadId:a.threadId,label:a.label,bot:a.bot,words:a.words,paths:a.paths},...b.filter(b=>b.threadId!==a.threadId)].slice(0,l.FINISHED_NOTICE.rows))}});let k=(0,h.useRef)(new Set);(0,h.useEffect)(()=>{if(!D.botThreads.primed())return;for(let a of i)("done"===a.status||"cancelled"===a.status)&&k.current.add(a.id);let a=new Set(N()),b=i.filter(b=>(0,A.isUnread)(b)&&!a.has(b.id)).sort((a,b)=>(0,G.toDate)(b.updatedAt).getTime()-(0,G.toDate)(a.updatedAt).getTime()),d=new Set(b.map(a=>a.id));c(a=>{let c=a.filter(a=>!k.current.has(a.threadId)||d.has(a.threadId)),e=[...b.filter(a=>!c.some(b=>b.threadId===a.id)).map(P),...c].slice(0,l.FINISHED_NOTICE.rows);return e.length===a.length&&e.every((b,c)=>b.threadId===a[c].threadId)?a:e})},[i]);let m=a=>{O([a]),c(b=>b.filter(b=>b.threadId!==a))};if(!b.length)return null;let n=b.slice(0,l.FINISHED_NOTICE.shown),o=b.slice(l.FINISHED_NOTICE.shown),p=a&&o.length>0&&!d,q=a=>{O(a),c(b=>b.filter(b=>!a.includes(b.threadId))),(0,z.markSeenAction)(a).then(H.unwrapResult).then(()=>(0,I.revalidate)(w.queryKey.threads)).catch(b=>y.toast.add({type:"error",title:a.length>1?"Could not mark the threads as read":"Could not mark the thread as read",description:(0,J.errorToString)(b)}))};return(0,g.jsx)("div",{className:"pointer-events-none relative col-start-1 row-start-2 w-82 max-w-full",children:(0,g.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:[n.map(a=>(0,g.jsx)(Q,{row:a,children:a=>(0,g.jsx)(U,{row:a,bot:f?.find(b=>b.name===a.bot),onOpen:b=>{b?(j(b,a.paths.filter(a=>"image"===(0,F.viewKindOf)(a)),!1,a.threadId),q([a.threadId])):(D.roomOpens.open(a.threadId),m(a.threadId))},onClose:()=>m(a.threadId)})},a.threadId)),p&&(0,g.jsx)(S,{rows:o,bots:f,onOpen:()=>e(!0)}),(p?[]:o).map(a=>(0,g.jsx)(Q,{row:a,children:a=>(0,g.jsx)(T,{row:a,bot:f?.find(b=>b.name===a.bot),onOpen:()=>{D.roomOpens.open(a.threadId),m(a.threadId)},onClose:()=>m(a.threadId)})},a.threadId)),b.length>1&&!p&&(0,g.jsxs)("p",{className:"flex shrink-0 items-center gap-2 px-1.5 font-mono text-[10px] text-muted-foreground",children:[(0,g.jsxs)("span",{children:[b.length," new"]}),(0,g.jsx)("span",{className:"flex-1"}),(0,g.jsx)("button",{type:"button",onClick:()=>q(b.map(a=>a.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 S({rows:a,bots:b,onOpen:c}){let e=[...new Set(a.map(a=>a.bot))].slice(0,3);return(0,g.jsxs)("button",{type:"button",onClick:c,className:"flex shrink-0 animate-in items-center gap-2 rounded-2xl bg-background py-1.5 pr-2.5 pl-2.5 text-left shadow-black/8 shadow-md ring-1 ring-border outline-none fade-in duration-300 hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,g.jsx)("span",{className:"flex shrink-0",children:e.map((a,c)=>{let d=b?.find(b=>b.name===a);return(0,g.jsx)(C.BotMark,{size:18,seed:a,color:d?.icon?.color,shape:d?.icon?.shape,outline:d?.icon?.outline,paint:d?.icon?.paint,notify:!1,resting:!0,className:(0,J.cn)("shrink-0",c>0&&"-ml-1.5")},a)})}),(0,g.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] leading-5",children:[a.length," more finished"]}),(0,g.jsx)(d,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}function T({row:a,bot:b,onOpen:c,onClose:d}){let e=a.paths.length-3,f=p();return(0,g.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,g.jsxs)("button",{type:"button",onClick:c,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,g.jsx)(C.BotMark,{size:18,seed:a.bot,color:b?.icon?.color,shape:b?.icon?.shape,outline:b?.icon?.outline,paint:b?.icon?.paint,notify:!1,resting:!f,className:"shrink-0"}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] leading-5",children:a.label}),a.paths.length>0&&(0,g.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[a.paths.slice(0,3).map(a=>(0,g.jsx)(E.FileThumb,{path:a,glyph:"size-2.5",className:"size-5 rounded-[6px] ring-1 ring-border"},a)),e>0&&(0,g.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e]})]})]}),(0,g.jsx)(x.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:d,className:"shrink-0 text-muted-foreground",children:(0,g.jsx)(u.X,{})})]})}function U({row:a,bot:b,onOpen:c,onClose:d}){let e,f=(e=a.paths.length)<=2?2:3===e?3:4,h=a.paths.slice(0,f),i=a.paths.length-h.length,j=p();return(0,g.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,g.jsx)(C.BotMark,{size:32,seed:a.bot,color:b?.icon?.color,shape:b?.icon?.shape,outline:b?.icon?.outline,paint:b?.icon?.paint,notify:!1,resting:!j,className:"shrink-0"}),(0,g.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[(0,g.jsxs)("div",{className:"flex items-start gap-1",children:[(0,g.jsxs)("button",{type:"button",onClick:()=>c(a.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,g.jsxs)("span",{className:"flex min-h-8 flex-col justify-center",children:[(0,g.jsx)("span",{className:"truncate font-medium text-[14px] leading-5 tracking-[-0.15px]",children:a.label}),(0,g.jsx)("span",{className:"truncate font-mono text-[10px] leading-[13px] text-muted-foreground",children:a.bot})]}),a.words&&(0,g.jsx)("span",{className:"line-clamp-2 break-keep wrap-anywhere text-[12.5px] leading-normal text-muted-foreground",children:(0,B.shortenPaths)(a.words)})]}),(0,g.jsx)(x.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:d,className:"shrink-0 text-muted-foreground",children:(0,g.jsx)(u.X,{})})]}),h.length>0&&(0,g.jsx)("div",{className:(0,J.cn)("grid gap-1.5 pt-0.5",L[f]),children:h.map((a,b)=>(0,g.jsxs)("button",{type:"button",title:a.split("/").pop(),onClick:()=>c(a),className:"relative rounded-[10px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,g.jsx)(E.FileThumb,{path:a,glyph:2===f?"size-6":"size-4",className:"aspect-square w-full rounded-[10px] ring-1 ring-border"}),i>0&&b===h.length-1&&(0,g.jsxs)("span",{className:"absolute inset-0 grid place-items-center rounded-[10px] bg-black/45 font-medium text-[14px] text-white",children:["+",i]})]},a))})]})]})}a.s(["ArtifactView",0,function({talking:a=!1}){return(0,g.jsx)(K.FileViewer,{children:(0,g.jsx)(R,{talking:a})})},"FinishedCard",0,U,"askToNotify",0,function(){"u"<typeof Notification||"default"===Notification.permission&&Notification.requestPermission().catch(()=>void 0)}],645323);let V=["NIGHT","G'NIGHT","NITE","SLEEP ♥","ZZZ","BYE"],W=[[22,V],[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,V]],X=(a,b)=>({text:a,at:Date.now(),hold:b});a.s(["awake",0,()=>X("HI",1.6),"finished",0,()=>X("OK",1),"goodbye",0,function(a=new Date){let b,c=a.getHours();return X((b=W.find(([a])=>c>=a)?.[1]??["BYE"])[Math.floor(Math.random()*b.length)],1.6)}],152659),a.s(["micProblem",0,function(a){let b=a instanceof DOMException?a.name:"";return"NotAllowedError"===b?"refused":"NotFoundError"===b?"missing":"NotReadableError"===b?"busy":null}],158697),a.s(["useAwayAfter",0,function(a,b){let[c,d]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{if(!a)return void d(!1);let c=setTimeout(()=>d(!0),b);return()=>clearTimeout(c)},[a,b]),a&&c}],77453);var Y=a.i(160161),Z=a.i(313237);let $=new Intl.Segmenter(void 0,{granularity:"grapheme"}),_=a=>Array.from($.segment(a)).length;function aa({text:a,animate:b}){let{shown:c,links:d}=(0,h.useMemo)(()=>{let b=[],c="",d=0;for(let e of a.matchAll(J.MARKDOWN_LINK)){let f=_(c+=a.slice(d,e.index));c+=e[1],b.push({from:f,to:_(c),href:e[2]}),d=e.index+e[0].length}return{shown:c+a.slice(d),links:b}},[a]);if(b)return(0,g.jsx)(j,{text:c,wraps:d.map(a=>({from:a.from,to:a.to,render:b=>(0,g.jsx)(ac,{href:a.href,children:b})}))});let e=Array.from($.segment(c),a=>a.segment),f=[],i=0;for(let a of d)f.push(e.slice(i,a.from).join("")),f.push((0,g.jsx)(ac,{href:a.href,children:e.slice(a.from,a.to).join("")},a.from)),i=a.to;return f.push(e.slice(i).join("")),(0,g.jsx)(g.Fragment,{children:f})}let ab="pointer-events-auto underline decoration-current/35 underline-offset-4 transition-colors hover:decoration-current";function ac({href:a,children:b}){let[c]=(0,Z.useServerAction)(Y.openFileAction);if(/^https?:\/\//i.test(a))return(0,g.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:ab,onClick:a=>a.stopPropagation(),children:b});let d=(0,F.workspaceRelative)(a);return d?(0,g.jsx)("a",{href:w.queryKey.fileView(d),className:ab,onClick:b=>{b.preventDefault(),b.stopPropagation();let d=(0,K.fileTarget)(a);"os"===d.how?c(a):D.fileOpens.open(d.path)||window.open(w.queryKey.fileView(d.path),"_blank")},children:b}):b}a.s(["CaptionWords",0,aa],526496);var ad=a.i(332033);let ae={assistant:null,user:null},af="(under)";function ag({role:a,turns:b,pinned:c,saying:d,onPick:e,under:f,ahead:i,workOf:j,whole:k}){let l="user"===a,[m,n]=(0,h.useState)({}),o=(0,h.useRef)(null);(0,h.useEffect)(()=>()=>o.current?.disconnect(),[]);let p=(0,h.useCallback)(a=>{if(a)return o.current??=new ResizeObserver(a=>{n(b=>{let c=b;for(let d of a){let a=d.target,e=a.dataset.turn;e&&b[e]!==a.offsetHeight&&(c===b&&(c={...b}),c[e]=a.offsetHeight)}return c})}),o.current.observe(a),()=>o.current?.unobserve(a)},[]),q=b.length-1,r=null===c&&(i||!b.length)?b.length:Math.min(c??q,q),s=(0,h.useRef)(null);if((0,h.useEffect)(()=>{let a=s.current;a&&(a.scrollTop=a.scrollHeight)},[b[r]?.text]),!b.length&&!f)return null;let t=a=>1150/(1150+700*Math.abs(a-r)),u=a=>a===r?1:.78,v=a=>(m[b[a].id]??28.475)*t(a)*u(a),w=r===b.length?f:j?.(b[r].id)??null,x=Array(b.length+1).fill(0);x[r]=-28.475/2;for(let a=r-1;a>=0;a--)x[a]=x[a+1]-49-v(a);let y=w&&r<b.length?(m[af]??0)+8:0;for(let a=r+1;a<b.length;a++)x[a]=x[a-1]+v(a-1)+49+(a-1===r?y:0);let z=w?r===b.length?x[r]:x[r]+(m[b[r].id]??28.475)+8:null;return(0,g.jsxs)("div",{className:(0,J.cn)("pointer-events-none absolute h-0 w-[min(21.25rem,24vw)]",l?"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:[b.map((a,c)=>{let f=Math.abs(c-r),h=c<r?r-c<=2:c-r<=2,i=c===r,j=h?i?1:.56*.6**(f-1):0,m=h&&!i,n=14*f*(l?-1:1)/t(c),o=x[c]/t(c);return(0,g.jsx)("div",{ref:p,"data-turn":a.id,"aria-hidden":!h,onClick:m?()=>e(c):void 0,style:{transform:`translate(${n.toFixed(1)}px, ${o.toFixed(1)}px) translateZ(${-700*f}px) scale(${u(c)})`,"--ink":j,"--lift":Math.max(j,.9)},className:(0,J.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",k&&c===b.length-1&&"animate-in fade-in duration-200 motion-reduce:animate-none",l?"left-0 origin-top-left":"right-0 origin-top-right",!h&&"invisible",m&&"pointer-events-auto cursor-pointer",i&&"pointer-events-auto"),children:(0,g.jsxs)("p",{ref:i?s:void 0,className:(0,J.cn)("break-keep wrap-anywhere text-pretty whitespace-pre-line opacity-(--ink) transition-opacity duration-[520ms] motion-reduce:transition-none",!i&&"line-clamp-4",i&&"overflow-y-auto overscroll-contain scrollbar-none",m&&"group-hover/turn:opacity-(--lift)"),style:i?{maxHeight:284.75}:void 0,children:[i&&(0,g.jsx)("span",{className:(0,J.cn)("mr-4 inline-block size-2.5 rounded-full align-middle",a.id===d?"animate-pulse motion-reduce:animate-none":"opacity-55",l?"bg-foreground":"bg-brand")}),(0,g.jsx)(aa,{text:a.text,animate:c===b.length-1&&!k})]})},a.id)}),w&&(0,g.jsx)("div",{ref:p,"data-turn":af,style:{transform:`translateY(${(z??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:w})]})}a.s(["SideCaptions",0,function({turns:a,pinned:b,live:c,onPick:d,under:e=null,ahead:f=!1,workOf:h,typed:i=!1}){let j=a.at(-1);return(0,g.jsx)(g.Fragment,{children:["assistant","user"].map(k=>(0,g.jsx)(ag,{role:k,turns:a.filter(a=>a.role===k),pinned:b[k],saying:c?j?.id:void 0,onPick:a=>d(k,a),under:"assistant"===k?e:null,ahead:"assistant"===k&&f,workOf:"assistant"===k?h:void 0,whole:i&&"user"===k},k))})},"turnsOf",0,function(a){let b=[];for(let c of a){let a=b.at(-1);a?.role!==c.role||c.fresh?b.push({id:c.id,role:c.role,text:c.text}):a.text=`${a.text} ${c.text}`}return b},"useTurnFocus",0,function(a,b){let[c,d]=(0,h.useState)(ae);return(0,h.useEffect)(()=>{b||d(ae)},[b]),(0,h.useEffect)(()=>{if(!b)return;let a=a=>{"ArrowDown"!==a.key||a.altKey||a.ctrlKey||a.metaKey||a.shiftKey||(0,ad.windowKey)(a)&&(a.preventDefault(),d(ae))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[b]),{pinned:c,pick:(0,h.useCallback)((b,c)=>{let e=a.filter(a=>a.role===b).length-1;d(a=>({...a,[b]:c>=e?null:c}))},[a]),back:null!==c.assistant||null!==c.user}}],587479)},222099,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={getRedirectError:function(){return i},getRedirectStatusCodeFromError:function(){return n},getRedirectTypeFromError:function(){return m},getURLFromRedirectError:function(){return l},permanentRedirect:function(){return k},redirect:function(){return j}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(615128),g=a.r(111026),h=a.r(869789);function i(a,b,c=f.RedirectStatusCode.TemporaryRedirect){let d=Object.defineProperty(Error(g.REDIRECT_ERROR_CODE),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return d.digest=`${g.REDIRECT_ERROR_CODE};${b};${a};${c};`,d}function j(a,b){throw i(a,b??=h.actionAsyncStorage?.getStore()?.isAction?"push":"replace",f.RedirectStatusCode.TemporaryRedirect)}function k(a,b="replace"){throw i(a,b,f.RedirectStatusCode.PermanentRedirect)}function l(a){return(0,g.isRedirectError)(a)?a.digest.split(";").slice(2,-2).join(";"):null}function m(a){if(!(0,g.isRedirectError)(a))throw Object.defineProperty(Error("Not a redirect error"),"__NEXT_ERROR_CODE",{value:"E260",enumerable:!1,configurable:!0});return a.digest.split(";",2)[1]}function n(a){if(!(0,g.isRedirectError)(a))throw Object.defineProperty(Error("Not a redirect error"),"__NEXT_ERROR_CODE",{value:"E260",enumerable:!1,configurable:!0});return Number(a.digest.split(";").at(-2))}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},8535,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={HTTPAccessErrorStatus:function(){return f},HTTP_ERROR_FALLBACK_ERROR_CODE:function(){return h},getAccessFallbackErrorTypeByStatus:function(){return k},getAccessFallbackHTTPStatus:function(){return j},isHTTPAccessFallbackError:function(){return i}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f={NOT_FOUND:404,FORBIDDEN:403,UNAUTHORIZED:401},g=new Set(Object.values(f)),h="NEXT_HTTP_ERROR_FALLBACK";function i(a){if("object"!=typeof a||null===a||!("digest"in a)||"string"!=typeof a.digest)return!1;let[b,c]=a.digest.split(";");return b===h&&g.has(Number(c))}function j(a){return Number(a.digest.split(";")[1])}function k(a){switch(a){case 401:return"unauthorized";case 403:return"forbidden";case 404:return"not-found";default:return}}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},228102,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"notFound",{enumerable:!0,get:function(){return f}});let d=a.r(8535),e=`${d.HTTP_ERROR_FALLBACK_ERROR_CODE};404`;function f(){let a=Object.defineProperty(Error(e),"__NEXT_ERROR_CODE",{value:"E1041",enumerable:!1,configurable:!0});throw a.digest=e,a}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},364177,(a,b,c)=>{"use strict";function d(){throw Object.defineProperty(Error("`forbidden()` is experimental and only allowed to be enabled when `experimental.authInterrupts` is enabled."),"__NEXT_ERROR_CODE",{value:"E488",enumerable:!1,configurable:!0})}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"forbidden",{enumerable:!0,get:function(){return d}}),a.r(8535).HTTP_ERROR_FALLBACK_ERROR_CODE,("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},688213,(a,b,c)=>{"use strict";function d(){throw Object.defineProperty(Error("`unauthorized()` is experimental and only allowed to be used when `experimental.authInterrupts` is enabled."),"__NEXT_ERROR_CODE",{value:"E411",enumerable:!1,configurable:!0})}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"unauthorized",{enumerable:!0,get:function(){return d}}),a.r(8535).HTTP_ERROR_FALLBACK_ERROR_CODE,("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},731101,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"isPostpone",{enumerable:!0,get:function(){return e}});let d=Symbol.for("react.postpone");function e(a){return"object"==typeof a&&null!==a&&a.$$typeof===d}},477747,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"isNextRouterError",{enumerable:!0,get:function(){return f}});let d=a.r(8535),e=a.r(111026);function f(a){return(0,e.isRedirectError)(a)||(0,d.isHTTPAccessFallbackError)(a)}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},247083,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"unstable_rethrow",{enumerable:!0,get:function(){return function a(b){if((0,g.isNextRouterError)(b)||(0,f.isBailoutToCSRError)(b)||(0,i.isDynamicServerError)(b)||(0,h.isDynamicPostpone)(b)||(0,e.isPostpone)(b)||(0,d.isHangingPromiseRejectionError)(b)||(0,h.isPrerenderInterruptedError)(b))throw b;b instanceof Error&&"cause"in b&&a(b.cause)}}});let d=a.r(935710),e=a.r(731101),f=a.r(441997),g=a.r(477747),h=a.r(154110),i=a.r(903326);("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},521066,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={ReadonlyURLSearchParams:function(){return f.ReadonlyURLSearchParams},RedirectType:function(){return m},forbidden:function(){return i.forbidden},notFound:function(){return h.notFound},permanentRedirect:function(){return g.permanentRedirect},redirect:function(){return g.redirect},unauthorized:function(){return j.unauthorized},unstable_isUnrecognizedActionError:function(){return l},unstable_rethrow:function(){return k.unstable_rethrow}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(475718),g=a.r(222099),h=a.r(228102),i=a.r(364177),j=a.r(688213),k=a.r(247083);function l(){throw Object.defineProperty(Error("`unstable_isUnrecognizedActionError` can only be used on the client."),"__NEXT_ERROR_CODE",{value:"E776",enumerable:!1,configurable:!0})}let m={push:"push",replace:"replace"};("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},874137,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={ReadonlyURLSearchParams:function(){return h.ReadonlyURLSearchParams},RedirectType:function(){return m.RedirectType},ServerInsertedHTMLContext:function(){return k.ServerInsertedHTMLContext},forbidden:function(){return m.forbidden},notFound:function(){return m.notFound},permanentRedirect:function(){return m.permanentRedirect},redirect:function(){return m.redirect},unauthorized:function(){return m.unauthorized},unstable_isUnrecognizedActionError:function(){return l.unstable_isUnrecognizedActionError},unstable_rethrow:function(){return m.unstable_rethrow},useParams:function(){return t},usePathname:function(){return r},useRouter:function(){return s},useSearchParams:function(){return q},useSelectedLayoutSegment:function(){return v},useSelectedLayoutSegments:function(){return u},useServerInsertedHTML:function(){return k.useServerInsertedHTML}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(346058)._(a.r(572131)),g=a.r(909270),h=a.r(736313),i=a.r(739118),j=a.r(549842),k=a.r(818341),l=a.r(857997),m=a.r(521066),{instrumentParamsForClientValidation:n,instrumentSearchParamsForClientValidation:o,expectCompleteParamsInClientValidation:p}={};function q(){j.useDynamicSearchParams?.("useSearchParams()");let a=(0,f.useContext)(h.SearchParamsContext);return(0,f.useMemo)(()=>a?new h.ReadonlyURLSearchParams(a):null,[a])}function r(){return j.useDynamicRouteParams?.("usePathname()"),(0,f.useContext)(h.PathnameContext)}function s(){let a=(0,f.useContext)(g.AppRouterContext);if(null===a)throw Object.defineProperty(Error("invariant expected app router to be mounted"),"__NEXT_ERROR_CODE",{value:"E238",enumerable:!1,configurable:!0});let b=(0,f.useContext)(g.LayoutRouterContext),c=b?.parentCacheNode.bfcacheId??0;return(0,f.useMemo)(()=>({back:a.back,forward:a.forward,refresh:a.refresh,hmrRefresh:a.hmrRefresh,push:a.push,replace:a.replace,prefetch:a.prefetch,experimental_gesturePush:a.experimental_gesturePush,bfcacheId:"_b_"+c+"_"}),[a,c])}function t(){return j.useDynamicRouteParams?.("useParams()"),(0,f.useContext)(h.PathParamsContext)}function u(a="children"){j.useDynamicRouteParams?.("useSelectedLayoutSegments()");let b=(0,f.useContext)(g.LayoutRouterContext);return b?(0,i.getSelectedLayoutSegmentPath)(b.parentTree,a):null}function v(a="children"){j.useDynamicRouteParams?.("useSelectedLayoutSegment()"),(0,f.useContext)(h.NavigationPromisesContext);let b=u(a);return(0,i.computeSelectedLayoutSegment)(b,a)}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},50944,(a,b,c)=>{b.exports=a.r(874137)},857997,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={UnrecognizedActionError:function(){return f},unstable_isUnrecognizedActionError:function(){return g}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});class f extends Error{constructor(...a){super(...a),this.name="UnrecognizedActionError"}}function g(a){return!!(a&&"object"==typeof a&&a instanceof f)}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},475718,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"ReadonlyURLSearchParams",{enumerable:!0,get:function(){return e}});class d extends Error{constructor(){super("Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams"),Object.defineProperty(this,"__NEXT_ERROR_CODE",{value:"E1174",enumerable:!1,configurable:!0})}}class e extends URLSearchParams{append(){throw new d}delete(){throw new d}set(){throw new d}sort(){throw new d}}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},615128,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"RedirectStatusCode",{enumerable:!0,get:function(){return e}});var d,e=((d={})[d.SeeOther=303]="SeeOther",d[d.TemporaryRedirect=307]="TemporaryRedirect",d[d.PermanentRedirect=308]="PermanentRedirect",d);("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},111026,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={REDIRECT_ERROR_CODE:function(){return g},isRedirectError:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(615128),g="NEXT_REDIRECT";function h(a){if("object"!=typeof a||null===a||!("digest"in a)||"string"!=typeof a.digest)return!1;let b=a.digest.split(";"),[c,d]=b,e=b.slice(2,-2).join(";"),h=Number(b.at(-2));return c===g&&("replace"===d||"push"===d)&&"string"==typeof e&&!isNaN(h)&&h in f.RedirectStatusCode}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},308117,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={createDynamicBodyError:function(){return g},createDynamicBodyErrorInNavigation:function(){return j},createDynamicMetadataError:function(){return n},createDynamicOrRuntimeBodyError:function(){return k},createDynamicOrRuntimeMetadataError:function(){return s},createDynamicOrRuntimeViewportError:function(){return r},createDynamicViewportError:function(){return q},createLinkBodyErrorInNavigation:function(){return i},createLinkMetadataError:function(){return l},createLinkViewportError:function(){return o},createRuntimeBodyError:function(){return f},createRuntimeBodyErrorInNavigation:function(){return h},createRuntimeMetadataError:function(){return m},createRuntimeViewportError:function(){return p},logBuildDebugHint:function(){return t}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(a){return Object.defineProperty(Error(`Route "${a}": Next.js encountered runtime data during prerendering.
|
|
12
|
+
${h.join("\n\n")}`).then(a=>{a||(ab.current=[],au())})},[av,au,as]),az=(0,s.useRef)(h);(0,s.useEffect)(()=>{az.current=h},[h]);let aA=(0,s.useRef)("listening"),aB=(0,s.useRef)(null),aC=(0,s.useCallback)(()=>{aB.current&&clearTimeout(aB.current),aB.current=null},[]),aD=(0,s.useCallback)(a=>{az.current=a,i(a)},[]),aE=(0,s.useCallback)(a=>{aA.current=a;let b=az.current;if("speaking"===a){aC(),aD(a);return}let c="working"===a||"delegating"===a;if(c&&("working"===b||"delegating"===b)){aC(),aD(a);return}c||"listening"!==b?aB.current||(aB.current=setTimeout(()=>{aB.current=null,aD(aA.current)},c?800:600)):aC()},[aC,aD]),aF="idle"!==h&&"connecting"!==h&&"ending"!==h,{data:aG}=(0,U.useServerRoute)(t.queryKey.threads,{refreshInterval:D.INBOX_POLL_MS}),aH=(0,s.useRef)(!1);(0,K.useAppEvent)({hello:()=>{if(!aH.current){aH.current=!0;return}(0,U.revalidateAll)()},threads:()=>void(0,U.revalidate)(t.queryKey.threads),routines:()=>void(0,U.revalidate)(t.queryKey.routines),memory:()=>void(0,U.revalidate)(t.queryKey.memory),mcp:()=>{(0,U.revalidate)(t.queryKey.mcp),(0,U.revalidate)(t.queryKey.mcpTools)},config:()=>{(0,U.revalidate)(t.queryKey.config),(0,U.revalidate)(t.queryKey.llmModel)}});let{data:aI}=(0,U.useServerRoute)(t.queryKey.bot);(0,s.useEffect)(()=>{aG&&V.botThreads.sync(aG,aI)},[aG,aI]),(0,s.useEffect)(()=>{ah.current=aG},[aG]);let aJ=function({threads:a,resting:b,writing:c}){let d=(0,s.useRef)(Date.now()),[e,f]=(0,s.useState)([]),[g,h]=(0,s.useState)(null),i=e.length>0,j=(0,cw.useThursdayStore)(a=>a.callBack),k=(0,V.useRoomThread)(),l=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{let b=k&&a?.find(a=>a.id===k);b&&l.current.set(b.id,(0,S.toDate)(b.updatedAt).getTime())},[k,a]),(0,s.useEffect)(()=>{if(!a)return;let e=new Set(a.filter(a=>{let b,c;return b=a,"off"!==(c=j)&&!b.seen&&(b.room.questions.length>0||"any"===c&&"running"!==b.status)}).map(a=>a.id));if(f(a=>a.every(a=>e.has(a))?a:a.filter(a=>e.has(a))),!b||c||k)return;let g=d.current,i=a.filter(a=>e.has(a.id)&&(0,S.toDate)(a.updatedAt).getTime()>Math.max(g,l.current.get(a.id)??0));i.length&&(d.current=Math.max(...i.map(a=>(0,S.toDate)(a.updatedAt).getTime())),h(null),f(a=>[...a,...i.map(a=>a.id).filter(b=>!a.includes(b))]))},[a,j,b,c,k]),(0,s.useEffect)(()=>{c?(f([]),h(null)):d.current=Date.now()},[c]);let m=(0,s.useCallback)(()=>{f([]),h(null)},[]);(0,Q.useEscape)(i,m),(0,s.useEffect)(()=>{if(!i||null!==g)return;let a=setTimeout(()=>h(Date.now()),D.CALL_BACK.ringMs);return()=>clearTimeout(a)},[i,g]),(0,s.useEffect)(()=>{if(i&&null===g){let a;return(a=new Audio("/sounds/ring.ogg")).play().catch(()=>{}),()=>a.pause()}},[i,g]);let n=(0,s.useMemo)(()=>{let[b,...c]=e.flatMap(b=>{let c=a?.find(a=>a.id===b);if(!c)return[];let d=c.room.questions[0];return[{id:c.id,bot:d?.bot??c.bot,kind:d?"question":"done"===c.status?"done":"stopped",label:c.label,text:d?.text??c.outcome??c.ask?.question??c.label,options:d?.options??[],questionId:d?.id??null}]});return b?{first:b,others:c,missedAt:g}:null},[e,a,g]);(0,s.useEffect)(()=>{V.ringingThreads.set(e)},[e]);let o=(0,s.useCallback)(()=>{f([]),h(null)},[]);return{ringing:n,isRinging:i,ringingFor:e,answered:o,unanswered:(0,s.useCallback)(a=>{a.length&&(f(b=>[...a,...b.filter(b=>!a.includes(b))]),h(Date.now()))},[]),settle:(0,s.useCallback)(()=>{d.current=Date.now()},[]),decline:m}}({threads:aG,resting:"idle"===h,writing:b}),{answered:aK,unanswered:aL,settle:aM}=aJ;(0,s.useEffect)(()=>V.screenActs.subscribe(a=>{if(!am.current)return;let b=cM(a);"gave"===a.kind?al.send({fact:b,pictures:a.paths.filter(cD.isPicture)}):"showed"===a.kind?al.send({fact:b,pictures:[a.path],run:!0}):aj.send(b)}),[aj,al]);let aN=(0,s.useCallback)(async(a=null)=>{if(ao.current)return;ao.current=!0,ad.current&&clearInterval(ad.current),ad.current=null,ap.current+=1;let b=c.current,d=X.current;for(let a of(c.current=null,X.current=null,am.current=!1,an.current=!1,cs.clear(),af.current=!1,$.current))Z.current.delete(a);$.current.clear(),aj.close(),aj.clear(),al.close(),al.clear(),W.current?.abort(),W.current=null,N.current.spoke=!1,au(),R.current&&clearTimeout(R.current),aC(),aM(),x(null),u(null),i(b?"ending":"idle"),b&&H((0,ek.goodbye)()),o([]),q(null),aw(null),M.current&&clearTimeout(M.current),M.current=null,T.current=!1,await b?.close(),Y.current?.(),Y.current=null;let e=O.current;O.current=null,ao.current=!1,i("idle"),b&&z(a),d&&cN(d,e),b&&g.current&&(g.current.currentTime=0,g.current.play().catch(()=>{}))},[aj,al,aC,au,aw]);(0,s.useEffect)(()=>{let a=()=>{let a=X.current;a&&navigator.sendBeacon(t.queryKey.callEnd,a)};return window.addEventListener("pagehide",a),()=>window.removeEventListener("pagehide",a)},[]),(0,s.useEffect)(()=>()=>{ap.current+=1,Y.current?.(),Y.current=null,c.current?.close(),c.current=null;let a=X.current;for(let b of(X.current=null,am.current=!1,an.current=!1,a&&cN(a),$.current))Z.current.delete(b);$.current.clear(),W.current?.abort(),W.current=null,R.current&&clearTimeout(R.current),aB.current&&clearTimeout(aB.current),N.current.giveUp&&clearTimeout(N.current.giveUp),M.current&&clearTimeout(M.current),l.current&&clearTimeout(l.current),ad.current&&clearInterval(ad.current),cs.clear()},[]);let aO=(0,s.useCallback)(()=>{if(ad.current)return;let a=Date.now();ad.current=setInterval(()=>{let b=Date.now();((ac.current>a-D.CALL_END.unsaidMs?b-Math.max(ac.current,a)>=D.CALL_END.quietMs:b-a>=D.CALL_END.unsaidMs)||b-a>=D.CALL_END.maxMs)&&aN("hungUp")},100)},[aN]);(0,s.useEffect)(()=>{if(!aF)return;P.current=Date.now();let a=setInterval(()=>{if(!c.current)return;let a=D.CALL_IDLE.hangUpMs-(Date.now()-P.current);x(a<=D.CALL_IDLE.warnMs?Math.max(0,Math.ceil(a/1e3)):null),a<=0&&!N.current.on&&aN("quiet")},1e3);return()=>clearInterval(a)},[aF,aN]),(0,s.useEffect)(()=>{if(!aF)return;let a=setInterval(ay,1e3);return()=>clearInterval(a)},[aF,ay]);let aP=(0,s.useCallback)(async()=>{let b,d,j=aJ.isRinging,k=aJ.ringingFor;if(an.current||ao.current)return;if(am.current||"idle"!==h)return aN();aK(),(0,c2.askToNotify)(),i("connecting"),z(null),m(!1),an.current=!0,am.current=!0,O.current=null,aj.clear(),al.clear(),ap.current+=1;let l=ap.current,n=()=>am.current&&ap.current===l,p={server:!1},r=e.current,s=(b=performance.now(),d={},{at(a){let c=performance.now();d[a]=c-b,performance.measure(`call ${a}`,{start:b,end:c})},say(){let a=Object.entries(ev).flatMap(([a,b])=>{let c=d[a];return void 0===c?[]:[`${b} at ${Math.round(c)} ms`]});console.debug(`The call opened: ${a.join(", ")}.`)}});try{f.current??=(0,eh.createAudioTap)(),function(a){if("suspended"!==a.state||ez)return;ez=!0;let b=()=>{ez=!1,window.removeEventListener("pointerdown",b),window.removeEventListener("keydown",b),a.resume().catch(()=>{})};window.addEventListener("pointerdown",b),window.addEventListener("keydown",b),cA.toast.add({type:"warning",title:"Tap anywhere to hear her",description:"This call opened on its own, so the browser is holding the audio."})}(f.current.open().context);let b=new Audio("/sounds/start_voice.ogg");g.current??=new Audio("/sounds/end_voice.ogg");let d=cY(),e=d?.where.weather,h=e&&!j&&function(a=new Date){let b=em(a);if(en===b)return!1;try{return window.localStorage.getItem(el)!==b}catch{return!0}}()&&"visible"===document.visibilityState&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches?Promise.race([Promise.all([(0,eo.loadWorld)(),a.A(372511)]).then(()=>!0,a=>(console.warn(`No globe on this call: ${(0,w.errorToString)(a)}`),!1)),new Promise(a=>setTimeout(()=>a(!1),D.HERE.waitMs))]):null,i=await (!("locks"in navigator)?Promise.resolve(()=>{}):new Promise(a=>{navigator.locks.request("thursday-spoken-call",{ifAvailable:!0},b=>b?new Promise(b=>a(()=>b())):void a(null))}));if(!i)throw new ex("A call is already on in another tab of this app. Hang up there, or go on there.");Y.current=i;let k=new AbortController;W.current=k;let l={failures:0},t={failures:0},v={callId:"",opening:null,here:null,standing:null,opened:{webSearch:E.LIVE_DEFAULTS.webSearch,readSkills:E.LIVE_DEFAULTS.readSkills}},x=new Map,y=new Map,z=null,A=a=>{let b={query:a.query,sources:a.sources};return eB(l,()=>eu(v.callId,[{id:a.row,role:"tool",tool:cB.TOOL_NAMES.web_search,text:JSON.stringify(b),seq:Math.max(0,Math.round(a.seq)),fragments:null}])),!!a.sources.length&&z===a.id&&(R.current&&clearTimeout(R.current),q(c=>c&&c.id!==a.id?c:{id:a.id,name:cB.TOOL_NAMES.web_search,line:(0,cQ.toolLine)(cB.TOOL_NAMES.web_search,JSON.stringify(b)),done:!0,bot:null,sources:a.sources}),!0)},B=await ee({initialize:async a=>{s.at("offer");let b=!!(h&&await h&&"visible"===document.visibilityState);h&&s.at("globe"),p.server=!0;let c=(0,cE.unwrapResult)(await es(a,j,d?.where??null,b));if(s.at("answer"),!n())throw cN(c.callId),Error("The call closed during startup.");return X.current=c.callId,v.callId=c.callId,v.opening=c.opening,v.here=c.here&&d&&e?{...d.position,code:d.country,weather:e}:null,v.standing=c.standing,v.opened=c.opened,c.relay?{sdp:c.sdp,relay:c.relay}:c.sdp},audio:f.current,on:{runTool:async a=>{if(a.name===cB.TOOL_NAMES.end_call)return aO(),"Ending the call.";if(a.name===cB.TOOL_NAMES.emote){if(cs.current())return"Nothing was shown: their screen is showing where they are for a few seconds more.";let{word:b,reply:c}=function(a){let b="";try{let c=JSON.parse(a);c&&"object"==typeof c&&"text"in c&&(b=String(c.text??"").trim())}catch{b=""}let c=Array.from(b).length;if(!c)return{word:null,reply:"Nothing was shown: text is empty."};if(c>ej.FACE_WORD_MAX)return{word:null,reply:`Too long: ${c} characters, ${ej.FACE_WORD_MAX} at most. Nothing was shown.`};let d=(0,ej.undrawable)(b);return d?{word:null,reply:`Cannot draw "${d}"; use only the characters \`text\` lists. Nothing was shown.`}:{word:b.toUpperCase(),reply:"Shown."}}(a.arguments);return b&&H({text:b,at:Date.now()}),c}aq(a);let b=a.name===cB.TOOL_NAMES.web_search;b&&(z=a.id);let c=!1;try{let d=await c1(v.callId,a,v.opened,k.signal);ar(a,d);let e=a.name===cB.TOOL_NAMES.thread_start?function(a){try{let{threadId:b,bot:c,label:d}=JSON.parse(a);return"string"==typeof b&&"string"==typeof c&&"string"==typeof d?{bot:c,label:d}:null}catch{return null}}(d):null;return e&&aj.send((({bot:a,label:b})=>`${a} took "${b}" and is working on it now.`)(e)),b&&(c=A({id:a.id,row:a.item??a.id,query:(0,cQ.searchQueryOf)(a.arguments),sources:(0,cQ.searchSourcesOf)(d),seq:0})),d}finally{c||at(a.id)}},search:a=>{if(!a.done){z=a.id,aq({id:a.id,name:cB.TOOL_NAMES.web_search,arguments:JSON.stringify({query:a.query})});return}let b={id:a.id,row:a.id,query:a.query,sources:a.sources,seq:a.seq};y.set(a.responseId,b),A(b)||at(b.id)},cited:(a,b)=>{let c=y.get(a);if(!c)return;let d=new Set(c.sources.map(a=>a.url));c.sources=[...c.sources.map(a=>b.find(b=>b.url===a.url)??a),...b.filter(a=>!d.has(a.url))],A(c)},reasoning:a=>{let b=(0,cQ.reasoningTitle)(a.text);b&&F(b),eB(t,()=>et(v.callId,{...a,seq:Math.max(0,Math.round(a.seq))}),"The backend's thinking is not being saved")},turn:a=>{let b="tool"===a.role?"":eA(a.text),c=!!b&&b!==eA(x.get(a.id)?.text??"");if(c&&(ae.current=Date.now()),c&&"user"===a.role&&(P.current=Date.now(),z)){let a=z;z=null,q(b=>b?.id===a?null:b)}"tool"!==a.role&&X.current===v.callId&&(x.set(a.id,{seq:a.seq,id:a.id,role:a.role,text:a.text}),o([...x.values()].sort((a,b)=>a.seq-b.seq).slice(-D.CALL_PAGE.scrollback))),a.done&&eB(l,()=>eu(v.callId,[{id:a.id,role:a.role,tool:a.tool,text:a.text,seq:Math.max(0,Math.round(a.seq)),fragments:a.fragments??null}]))},activity:a=>{var b;aE((b=a).speaking?"speaking":b.working||b.tools.length?b.tools.includes(cB.TOOL_NAMES.thread_start)?"delegating":"working":"listening");let c=a.working||a.tools.length>0;ag.current=c,ax(c,a.speaking),a.speaking&&(ac.current=Date.now()),(a.speaking&&!N.current.on||a.working||a.tools.length)&&(P.current=Date.now()),N.current.on&&(a.speaking?N.current.spoke=!0:N.current.spoke&&au())},finalized:a=>{O.current=a},warn:a=>cA.toast.add({type:"warning",title:"Call warning",description:a}),failed:a=>{let b=O.current?.reason;if("expired"===b||"remote_hangup"===b)return void aN("expired"===b?"expired":"closed");if("content"===b){cA.toast.add({type:"warning",title:"Live ended the call",description:"Its safety filter stopped the conversation."}),aN("closed");return}cA.toast.add({type:"error",title:ew(r,!1),description:a}),m(!0),aN(O.current?"closed":"dropped")}}});if(!n())return void await B.close();s.at("line"),s.say(),c.current=B,an.current=!1,af.current=j,_.current=j?new Set:cG(ah.current??[]);let C=a=>void B.append("thinking",a);aj.open(C),al.open(a=>void er(B,a,eq,C).catch(a=>cA.toast.add({type:"error",title:"What you put down did not reach the backend",description:(0,w.errorToString)(a)}))),ae.current=Date.now(),v.here&&cs.show({kind:"here",scene:v.here}),v.opening&&(av(),B.holdInput(D.LIVE_CALL.openingHoldMs),B.append("instructions",v.opening).then(a=>{a||au()})),v.standing&&B.brief(v.standing),aD("listening"),u(Date.now()),b.play().catch(()=>{})}catch(a){if(Y.current?.(),Y.current=null,n()&&a instanceof ex)cA.toast.add({type:"warning",title:"One call at a time",description:a.message});else if(n()){let b;cA.toast.add({type:"error",description:("refused"===(b=(0,ep.micProblem)(a))?"This page is not allowed the microphone. The icon at the left of the address bar opens the site's settings: set Microphone to Allow, then call her again.":"missing"===b?"No microphone was found. Plug one in or switch it on, then call her again.":"busy"===b?"The microphone would not start. Another app may be using it: close that app, then call her again.":null)??(0,w.errorToString)(a),title:p.server?ew(r,!0):"Could not start the call"}),m(!0),j&&aL(k)}if(ap.current!==l)return;X.current&&cN(X.current),X.current=null,an.current=!1,am.current=!1,W.current=null,aj.clear(),al.clear(),i("idle")}},[h,aN,aq,ar,at,aE,aD,aj,al,av,au,ax,m,aO,aJ.isRinging,aJ.ringingFor,aK,aL]);(0,s.useEffect)(()=>{if(!y)return;let a=setTimeout(()=>z(null),D.CALL_ENDED_MS);return()=>clearTimeout(a)},[y]);let aQ=(0,s.useCallback)(()=>f.current?.read()??ey,[]),aR=(0,s.useCallback)(()=>f.current?.readMic()??ey,[]),aS=(0,cw.useThursdayStore)(a=>a.wake),[aT,aU]=(0,s.useState)(!1);(0,s.useEffect)(()=>aU(!1),[aS.enabled,aS.phrase]);let aV=(0,cm.useCallHeld)();(0,s.useEffect)(()=>cm.callSignal.onPlace(()=>void aP()),[aP]),function({enabled:a,onWake:b,phrases:c,onError:d}){let e=(0,s.useRef)({onWake:b,onError:d,phrases:c});e.current={onWake:b,onError:d,phrases:c},(0,s.useEffect)(()=>{if(!a)return;let b=window,c=b.SpeechRecognition??b.webkitSpeechRecognition;if(!c)return void e.current.onError?.("This browser cannot listen for a wake word");let d=new c,f=!0,g=!0,h=null,i=300;d.lang="en-US",d.continuous=!0,d.interimResults=!0,d.maxAlternatives=3;let j=()=>{if(f){g=!0;try{d.start()}catch{}}};return d.onresult=({resultIndex:a,results:b})=>{if(!f||!g)return;i=300;let{phrases:c,onWake:h}=e.current,j=c.map(c4).filter(a=>a.length);for(let c=a;c<b.length;c++){let a=b[c];for(let b=0;b<a.length;b++){let c=a[b].transcript,e=c4(c);if(j.some(a=>(function(a,b,c){for(let d=0;d<a.length;d++)if(function a(b,c,d,e,f){if(e===d.length)return!0;if(c>=b.length)return!1;let g=d[e],h=Math.max(1,Math.round(g.length*f));return!!(c5(b[c],g,h)&&a(b,c+1,d,e+1,f))||c+1<b.length&&c5(b[c]+b[c+1],g,h)&&a(b,c+2,d,e+1,f)}(a,d,b,0,c))return!0;return!1})(e,a,D.WAKE_TOLERANCE))){g=!1,d.abort(),h(c.trim());return}}}},d.onerror=({error:a})=>{let b=c3[a];b?(f=!1,e.current.onError?.(b)):"network"===a&&(i=Math.min(2*i,1e4))},d.onend=()=>{f&&(h=setTimeout(j,i))},j(),()=>{f=!1,h&&clearTimeout(h),d.onresult=null,d.onerror=null,d.onend=null,d.abort()}},[a])}({enabled:"idle"===h&&aS.enabled&&!aT&&!aV,phrases:[aS.phrase],onWake:()=>void aP(),onError:a=>{aU(!0),cA.toast.add({type:"error",title:"Wake word off",description:a})}});let aW=(0,cw.useThursdayStore)(a=>a.hotkey),aX="connecting"===h||"ending"===h;return(0,Q.useHotkey)({enabled:aW.enabled&&!aX&&!aV,combo:aW.enabled&&(0,Q.isCombo)(aW.combo)?aW.combo:null,onPress:()=>void aP()}),{status:h,failed:j,messages:n,tool:p,ended:y,thinkingSince:A,thinkingTitle:C,faceWord:G,idleLeft:v,since:r,call:aP,ringing:aJ.ringing,decline:aJ.decline,getSpectrum:aQ,getMicSpectrum:aR,wakePhrase:aS.enabled&&!aT?aS.phrase:null,hotkey:aW.enabled&&(0,Q.isCombo)(aW.combo)?aW.combo:null}}(c.on),y=(0,Q.useHotkeyLabel)(x),z=(0,cw.useThursdayStore)(a=>a.captionView),{data:A}=(0,U.useServerRoute)(t.queryKey.config),B=(0,a9.useVoiceLine)(),C=B.known?null!==B.line:b,G="idle"!==e,H=c.end;(0,s.useEffect)(()=>{G&&c.on&&H()},[G,c.on,H]);let I=c.on&&!G,J=(0,cw.useThursdayStore)(a=>a.textModel),{settings:L}=(0,cx.useLiveSettings)(),M=L?.backendModel??E.LIVE_DEFAULTS.backendModel,N=(0,s.useMemo)(()=>{let a=a=>(0,ba.isConfigSet)(A,a),b=(0,cv.textCallRunsOn)(a),d=J&&a(F.TEXT_MODEL_PROVIDERS[J.provider].apiKeyName)?J:b?{provider:b,model:M}:null;return{on:I,busy:c.busy,error:c.error,refused:c.refused,say:c.say,again:c.again,end:c.end,runsOn:d,fallback:d?.provider!=="openai"&&a(F.TEXT_MODEL_PROVIDERS.openai.apiKeyName)?{provider:"openai",model:M}:null}},[I,c.busy,c.error,c.refused,c.say,c.again,c.end,A,J,M]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(eQ,{live:"idle"!==e,ringing:null!==p}),(0,d.jsx)(fk,{status:I?c.status:e,failed:I?null!==c.error:f,messages:I?c.messages:g,tool:I?c.tool:h,thinkingSince:I?c.thinkingSince:i,thinkingTitle:I?c.thinkingTitle:j,ended:k,faceWord:l,onTap:o,ringing:C?p:null,onDecline:q,wakePhrase:v,hotkeyLabel:y,idleLeft:m,since:n,getSpectrum:I?cu.silentVoice:r,getMicSpectrum:u,captionView:z,callable:C,written:G?null:N})]})}],137079)},113608,540990,511576,36304,444324,650485,645323,152659,158697,77453,526496,587479,a=>{"use strict";var b=a.i(164831);let c={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};c.node;let d=(0,b.default)(c);a.s(["ChevronUp",0,d],113608);let e={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"}]]};e.node;let f=(0,b.default)(e);a.s(["Mic",0,f],540990);var g=a.i(187924),h=a.i(572131);let i=new Intl.Segmenter(void 0,{granularity:"grapheme"});function j({text:a,wraps:b=[]}){let c=(0,h.useMemo)(()=>Array.from(i.segment(a),a=>a.segment),[a]),d=(0,h.useRef)([]),e=0;for(;e<c.length&&c[e]===d.current[e];)e++;(0,h.useEffect)(()=>{d.current=c},[c]);let f=a=>(0,g.jsx)(k,{wait:25*Math.max(0,a-e),children:c[a]},`${c[a]}${a}`),l=[];for(let a=0;a<c.length;){let d=b.find(b=>b.from===a&&b.to>a);if(!d){l.push(f(a)),a+=1;continue}let e=Math.min(d.to,c.length),i=[];for(let b=a;b<e;b++)i.push(f(b));l.push((0,g.jsx)(h.Fragment,{children:d.render(i)},`wrap${a}`)),a=e}return(0,g.jsx)("span",{children:l})}function k({wait:a,children:b}){let[c]=(0,h.useState)(a);return(0,g.jsx)("span",{style:{animationDelay:`${c}ms`},className:"animate-letter motion-reduce:animate-none",children:b})}a.s(["Letters",0,j],511576);var l=a.i(287702);let m={wave:740,done:740,ask:820,took:740,give:900,take:520,stop:1150,read:560},n={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"}},o={key:0,body:"",shape:"animate-crew-breath",turn:"",delayMs:0};function p(){let[a,b]=(0,h.useState)(!0);return(0,h.useEffect)(()=>{let a=setTimeout(()=>b(!1),l.CREW_REST.awakeMs),c=()=>{"visible"===document.visibilityState&&(clearTimeout(a),b(!0),a=setTimeout(()=>b(!1),l.CREW_REST.awakeMs))};return window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),()=>{clearTimeout(a),window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c)}},[]),a}a.s(["motionOf",0,function(a,b){if(!a)return{...o,delayMs:-370*b};let c=n[a.gesture];return{key:a.id,body:c.body??"",shape:c.shape??"animate-crew-breath",turn:c.turn??"",delayMs:"wave"===a.gesture?70*b:0}},"useCrewAwake",0,p,"useCrewGestures",0,function(){let[a,b]=(0,h.useState)(new Map),c=(0,h.useRef)(new Map),d=(0,h.useRef)(0);return(0,h.useEffect)(()=>{let a=c.current;return()=>{for(let b of a.values())clearTimeout(b);a.clear()}},[]),[a,(0,h.useCallback)(a=>{a.length&&b(e=>{let f=new Map(e);for(let{bot:e,gesture:g}of a){d.current+=1,f.set(e,{gesture:g,id:d.current});let a=c.current.get(e);a&&clearTimeout(a),c.current.set(e,setTimeout(()=>{c.current.delete(e),b(a=>{let b=new Map(a);return b.delete(e),b})},m[g]+1400*("wave"===g)))}return f})},[])]}],36304);let q=!1,r=new Set,s=new Set;a.s(["callSignal",0,{hold(a){if(a!==q)for(let b of(q=a,r))b()},place(){for(let a of s)a()},onPlace:a=>(s.add(a),()=>{s.delete(a)})},"useCallHeld",0,function(){return(0,h.useSyncExternalStore)(a=>(r.add(a),()=>r.delete(a)),()=>q,()=>!1)}],444324);var t=a.i(483253);a.s(["silentVoice",0,function(){let a=performance.now()/1e3;return Array.from({length:t.SPECTRUM_BANDS},(b,c)=>.18+.16*Math.sin(a*(5+.9*c)+1.7*c)**2)}],650485);var u=a.i(474215),v=a.i(986368),w=a.i(767561),x=a.i(340695),y=a.i(864037),z=a.i(278210),A=a.i(411509),B=a.i(321799),C=a.i(913834),D=a.i(135432),E=a.i(38793),F=a.i(559553),G=a.i(199169),H=a.i(576271),I=a.i(759497),J=a.i(497895),K=a.i(369768);let L={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},M="thursday.corner-dismissed";function N(){try{let a=JSON.parse(window.localStorage.getItem(M)??"[]");return Array.isArray(a)?a:[]}catch{return[]}}function O(a){try{let b=[...a,...N().filter(b=>!a.includes(b))].slice(0,50);window.localStorage.setItem(M,JSON.stringify(b))}catch{}}function P(a){return{threadId:a.id,label:a.label,bot:a.bot.name,words:(0,J.plainText)(a.outcome??"").slice(0,l.FINISHED_NOTICE.words),paths:(0,F.leadFirst)((0,F.pathsIn)(a.outcome??"")),unchecked:!0}}function Q({row:a,children:b}){let c=a.unchecked&&a.paths.length>0,{data:d}=(0,I.useServerRoute)(c?w.queryKey.workspaceFiles(a.paths):null);if(!c)return b(a);if(!d)return null;let e=new Set(d.map(a=>a.path));return b({...a,paths:(0,F.leadFirst)(a.paths.filter(a=>e.has(a)))})}function R({talking:a}){let[b,c]=(0,h.useState)([]),[d,e]=(0,h.useState)(!1);(0,h.useEffect)(()=>{a||e(!1)},[a]);let{data:f}=(0,I.useServerRoute)(w.queryKey.bot),i=(0,D.useBotThreads)(),j=(0,K.useOpenFile)();(0,h.useEffect)(()=>D.fileOpens.subscribe(a=>{j(a)}),[j]),(0,v.useAppEvent)({showFile:a=>j(a.paths[0],a.paths.filter(a=>"image"===(0,F.viewKindOf)(a)),!0),finished:a=>{!function(a,b,c){if(!("u"<typeof Notification)&&"granted"===Notification.permission&&!("visible"===document.visibilityState&&document.hasFocus()))try{let d=new Notification(b,{body:c,tag:a,icon:"/icon.svg"});d.onclick=()=>{window.focus(),d.close()}}catch{}}(a.threadId,a.label,a.words),c(b=>[{threadId:a.threadId,label:a.label,bot:a.bot,words:a.words,paths:a.paths},...b.filter(b=>b.threadId!==a.threadId)].slice(0,l.FINISHED_NOTICE.rows))}});let k=(0,h.useRef)(new Set);(0,h.useEffect)(()=>{if(!D.botThreads.primed())return;for(let a of i)("done"===a.status||"cancelled"===a.status)&&k.current.add(a.id);let a=new Set(N()),b=i.filter(b=>(0,A.isUnread)(b)&&!a.has(b.id)).sort((a,b)=>(0,G.toDate)(b.updatedAt).getTime()-(0,G.toDate)(a.updatedAt).getTime()),d=new Set(b.map(a=>a.id));c(a=>{let c=a.filter(a=>!k.current.has(a.threadId)||d.has(a.threadId)),e=[...b.filter(a=>!c.some(b=>b.threadId===a.id)).map(P),...c].slice(0,l.FINISHED_NOTICE.rows);return e.length===a.length&&e.every((b,c)=>b.threadId===a[c].threadId)?a:e})},[i]);let m=a=>{O([a]),c(b=>b.filter(b=>b.threadId!==a))};if(!b.length)return null;let n=b.slice(0,l.FINISHED_NOTICE.shown),o=b.slice(l.FINISHED_NOTICE.shown),p=a&&o.length>0&&!d,q=a=>{O(a),c(b=>b.filter(b=>!a.includes(b.threadId))),(0,z.markSeenAction)(a).then(H.unwrapResult).then(()=>(0,I.revalidate)(w.queryKey.threads)).catch(b=>y.toast.add({type:"error",title:a.length>1?"Could not mark the threads as read":"Could not mark the thread as read",description:(0,J.errorToString)(b)}))};return(0,g.jsx)("div",{className:"pointer-events-none relative col-start-1 row-start-2 w-82 max-w-full",children:(0,g.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:[n.map(a=>(0,g.jsx)(Q,{row:a,children:a=>(0,g.jsx)(U,{row:a,bot:f?.find(b=>b.name===a.bot),onOpen:b=>{b?(j(b,a.paths.filter(a=>"image"===(0,F.viewKindOf)(a)),!1,a.threadId),q([a.threadId])):(D.roomOpens.open(a.threadId),m(a.threadId))},onClose:()=>m(a.threadId)})},a.threadId)),p&&(0,g.jsx)(S,{rows:o,bots:f,onOpen:()=>e(!0)}),(p?[]:o).map(a=>(0,g.jsx)(Q,{row:a,children:a=>(0,g.jsx)(T,{row:a,bot:f?.find(b=>b.name===a.bot),onOpen:()=>{D.roomOpens.open(a.threadId),m(a.threadId)},onClose:()=>m(a.threadId)})},a.threadId)),b.length>1&&!p&&(0,g.jsxs)("p",{className:"flex shrink-0 items-center gap-2 px-1.5 font-mono text-[10px] text-muted-foreground",children:[(0,g.jsxs)("span",{children:[b.length," new"]}),(0,g.jsx)("span",{className:"flex-1"}),(0,g.jsx)("button",{type:"button",onClick:()=>q(b.map(a=>a.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 S({rows:a,bots:b,onOpen:c}){let e=[...new Set(a.map(a=>a.bot))].slice(0,3);return(0,g.jsxs)("button",{type:"button",onClick:c,className:"flex shrink-0 animate-in items-center gap-2 rounded-2xl bg-background py-1.5 pr-2.5 pl-2.5 text-left shadow-black/8 shadow-md ring-1 ring-border outline-none fade-in duration-300 hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,g.jsx)("span",{className:"flex shrink-0",children:e.map((a,c)=>{let d=b?.find(b=>b.name===a);return(0,g.jsx)(C.BotMark,{size:18,seed:a,color:d?.icon?.color,shape:d?.icon?.shape,outline:d?.icon?.outline,paint:d?.icon?.paint,notify:!1,resting:!0,className:(0,J.cn)("shrink-0",c>0&&"-ml-1.5")},a)})}),(0,g.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] leading-5",children:[a.length," more finished"]}),(0,g.jsx)(d,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}function T({row:a,bot:b,onOpen:c,onClose:d}){let e=a.paths.length-3,f=p();return(0,g.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,g.jsxs)("button",{type:"button",onClick:c,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,g.jsx)(C.BotMark,{size:18,seed:a.bot,color:b?.icon?.color,shape:b?.icon?.shape,outline:b?.icon?.outline,paint:b?.icon?.paint,notify:!1,resting:!f,className:"shrink-0"}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] leading-5",children:a.label}),a.paths.length>0&&(0,g.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[a.paths.slice(0,3).map(a=>(0,g.jsx)(E.FileThumb,{path:a,glyph:"size-2.5",className:"size-5 rounded-[6px] ring-1 ring-border"},a)),e>0&&(0,g.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e]})]})]}),(0,g.jsx)(x.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:d,className:"shrink-0 text-muted-foreground",children:(0,g.jsx)(u.X,{})})]})}function U({row:a,bot:b,onOpen:c,onClose:d}){let e,f=(e=a.paths.length)<=2?2:3===e?3:4,h=a.paths.slice(0,f),i=a.paths.length-h.length,j=p();return(0,g.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,g.jsx)(C.BotMark,{size:32,seed:a.bot,color:b?.icon?.color,shape:b?.icon?.shape,outline:b?.icon?.outline,paint:b?.icon?.paint,notify:!1,resting:!j,className:"shrink-0"}),(0,g.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[(0,g.jsxs)("div",{className:"flex items-start gap-1",children:[(0,g.jsxs)("button",{type:"button",onClick:()=>c(a.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,g.jsxs)("span",{className:"flex min-h-8 flex-col justify-center",children:[(0,g.jsx)("span",{className:"truncate font-medium text-[14px] leading-5 tracking-[-0.15px]",children:a.label}),(0,g.jsx)("span",{className:"truncate font-mono text-[10px] leading-[13px] text-muted-foreground",children:a.bot})]}),a.words&&(0,g.jsx)("span",{className:"line-clamp-2 break-keep wrap-anywhere text-[12.5px] leading-normal text-muted-foreground",children:(0,B.shortenPaths)(a.words)})]}),(0,g.jsx)(x.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:d,className:"shrink-0 text-muted-foreground",children:(0,g.jsx)(u.X,{})})]}),h.length>0&&(0,g.jsx)("div",{className:(0,J.cn)("grid gap-1.5 pt-0.5",L[f]),children:h.map((a,b)=>(0,g.jsxs)("button",{type:"button",title:a.split("/").pop(),onClick:()=>c(a),className:"relative rounded-[10px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,g.jsx)(E.FileThumb,{path:a,glyph:2===f?"size-6":"size-4",className:"aspect-square w-full rounded-[10px] ring-1 ring-border"}),i>0&&b===h.length-1&&(0,g.jsxs)("span",{className:"absolute inset-0 grid place-items-center rounded-[10px] bg-black/45 font-medium text-[14px] text-white",children:["+",i]})]},a))})]})]})}a.s(["ArtifactView",0,function({talking:a=!1}){return(0,g.jsx)(K.FileViewer,{children:(0,g.jsx)(R,{talking:a})})},"FinishedCard",0,U,"askToNotify",0,function(){"u"<typeof Notification||"default"===Notification.permission&&Notification.requestPermission().catch(()=>void 0)}],645323);let V=["NIGHT","G'NIGHT","NITE","SLEEP ♥","ZZZ","BYE"],W=[[22,V],[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,V]],X=(a,b)=>({text:a,at:Date.now(),hold:b});a.s(["awake",0,()=>X("HI",1.6),"finished",0,()=>X("OK",1),"goodbye",0,function(a=new Date){let b,c=a.getHours();return X((b=W.find(([a])=>c>=a)?.[1]??["BYE"])[Math.floor(Math.random()*b.length)],1.6)}],152659),a.s(["micProblem",0,function(a){let b=a instanceof DOMException?a.name:"";return"NotAllowedError"===b?"refused":"NotFoundError"===b?"missing":"NotReadableError"===b?"busy":null}],158697),a.s(["useAwayAfter",0,function(a,b){let[c,d]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{if(!a)return void d(!1);let c=setTimeout(()=>d(!0),b);return()=>clearTimeout(c)},[a,b]),a&&c}],77453);var Y=a.i(774387),Z=a.i(313237);let $=new Intl.Segmenter(void 0,{granularity:"grapheme"}),_=a=>Array.from($.segment(a)).length;function aa({text:a,animate:b}){let{shown:c,links:d}=(0,h.useMemo)(()=>{let b=[],c="",d=0;for(let e of a.matchAll(J.MARKDOWN_LINK)){let f=_(c+=a.slice(d,e.index));c+=e[1],b.push({from:f,to:_(c),href:e[2]}),d=e.index+e[0].length}return{shown:c+a.slice(d),links:b}},[a]);if(b)return(0,g.jsx)(j,{text:c,wraps:d.map(a=>({from:a.from,to:a.to,render:b=>(0,g.jsx)(ac,{href:a.href,children:b})}))});let e=Array.from($.segment(c),a=>a.segment),f=[],i=0;for(let a of d)f.push(e.slice(i,a.from).join("")),f.push((0,g.jsx)(ac,{href:a.href,children:e.slice(a.from,a.to).join("")},a.from)),i=a.to;return f.push(e.slice(i).join("")),(0,g.jsx)(g.Fragment,{children:f})}let ab="pointer-events-auto underline decoration-current/35 underline-offset-4 transition-colors hover:decoration-current";function ac({href:a,children:b}){let[c]=(0,Z.useServerAction)(Y.openFileAction);if(/^https?:\/\//i.test(a))return(0,g.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:ab,onClick:a=>a.stopPropagation(),children:b});let d=(0,F.workspaceRelative)(a);return d?(0,g.jsx)("a",{href:w.queryKey.fileView(d),className:ab,onClick:b=>{b.preventDefault(),b.stopPropagation();let d=(0,K.fileTarget)(a);"os"===d.how?c(a):D.fileOpens.open(d.path)||window.open(w.queryKey.fileView(d.path),"_blank")},children:b}):b}a.s(["CaptionWords",0,aa],526496);var ad=a.i(332033);let ae={assistant:null,user:null},af="(under)";function ag({role:a,turns:b,pinned:c,saying:d,onPick:e,under:f,ahead:i,workOf:j,whole:k}){let l="user"===a,[m,n]=(0,h.useState)({}),o=(0,h.useRef)(null);(0,h.useEffect)(()=>()=>o.current?.disconnect(),[]);let p=(0,h.useCallback)(a=>{if(a)return o.current??=new ResizeObserver(a=>{n(b=>{let c=b;for(let d of a){let a=d.target,e=a.dataset.turn;e&&b[e]!==a.offsetHeight&&(c===b&&(c={...b}),c[e]=a.offsetHeight)}return c})}),o.current.observe(a),()=>o.current?.unobserve(a)},[]),q=b.length-1,r=null===c&&(i||!b.length)?b.length:Math.min(c??q,q),s=(0,h.useRef)(null);if((0,h.useEffect)(()=>{let a=s.current;a&&(a.scrollTop=a.scrollHeight)},[b[r]?.text]),!b.length&&!f)return null;let t=a=>1150/(1150+700*Math.abs(a-r)),u=a=>a===r?1:.78,v=a=>(m[b[a].id]??28.475)*t(a)*u(a),w=r===b.length?f:j?.(b[r].id)??null,x=Array(b.length+1).fill(0);x[r]=-28.475/2;for(let a=r-1;a>=0;a--)x[a]=x[a+1]-49-v(a);let y=w&&r<b.length?(m[af]??0)+8:0;for(let a=r+1;a<b.length;a++)x[a]=x[a-1]+v(a-1)+49+(a-1===r?y:0);let z=w?r===b.length?x[r]:x[r]+(m[b[r].id]??28.475)+8:null;return(0,g.jsxs)("div",{className:(0,J.cn)("pointer-events-none absolute h-0 w-[min(21.25rem,24vw)]",l?"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:[b.map((a,c)=>{let f=Math.abs(c-r),h=c<r?r-c<=2:c-r<=2,i=c===r,j=h?i?1:.56*.6**(f-1):0,m=h&&!i,n=14*f*(l?-1:1)/t(c),o=x[c]/t(c);return(0,g.jsx)("div",{ref:p,"data-turn":a.id,"aria-hidden":!h,onClick:m?()=>e(c):void 0,style:{transform:`translate(${n.toFixed(1)}px, ${o.toFixed(1)}px) translateZ(${-700*f}px) scale(${u(c)})`,"--ink":j,"--lift":Math.max(j,.9)},className:(0,J.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",k&&c===b.length-1&&"animate-in fade-in duration-200 motion-reduce:animate-none",l?"left-0 origin-top-left":"right-0 origin-top-right",!h&&"invisible",m&&"pointer-events-auto cursor-pointer",i&&"pointer-events-auto"),children:(0,g.jsxs)("p",{ref:i?s:void 0,className:(0,J.cn)("break-keep wrap-anywhere text-pretty whitespace-pre-line opacity-(--ink) transition-opacity duration-[520ms] motion-reduce:transition-none",!i&&"line-clamp-4",i&&"overflow-y-auto overscroll-contain scrollbar-none",m&&"group-hover/turn:opacity-(--lift)"),style:i?{maxHeight:284.75}:void 0,children:[i&&(0,g.jsx)("span",{className:(0,J.cn)("mr-4 inline-block size-2.5 rounded-full align-middle",a.id===d?"animate-pulse motion-reduce:animate-none":"opacity-55",l?"bg-foreground":"bg-brand")}),(0,g.jsx)(aa,{text:a.text,animate:c===b.length-1&&!k})]})},a.id)}),w&&(0,g.jsx)("div",{ref:p,"data-turn":af,style:{transform:`translateY(${(z??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:w})]})}a.s(["SideCaptions",0,function({turns:a,pinned:b,live:c,onPick:d,under:e=null,ahead:f=!1,workOf:h,typed:i=!1}){let j=a.at(-1);return(0,g.jsx)(g.Fragment,{children:["assistant","user"].map(k=>(0,g.jsx)(ag,{role:k,turns:a.filter(a=>a.role===k),pinned:b[k],saying:c?j?.id:void 0,onPick:a=>d(k,a),under:"assistant"===k?e:null,ahead:"assistant"===k&&f,workOf:"assistant"===k?h:void 0,whole:i&&"user"===k},k))})},"turnsOf",0,function(a){let b=[];for(let c of a){let a=b.at(-1);a?.role!==c.role||c.fresh?b.push({id:c.id,role:c.role,text:c.text}):a.text=`${a.text} ${c.text}`}return b},"useTurnFocus",0,function(a,b){let[c,d]=(0,h.useState)(ae);return(0,h.useEffect)(()=>{b||d(ae)},[b]),(0,h.useEffect)(()=>{if(!b)return;let a=a=>{"ArrowDown"!==a.key||a.altKey||a.ctrlKey||a.metaKey||a.shiftKey||(0,ad.windowKey)(a)&&(a.preventDefault(),d(ae))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[b]),{pinned:c,pick:(0,h.useCallback)((b,c)=>{let e=a.filter(a=>a.role===b).length-1;d(a=>({...a,[b]:c>=e?null:c}))},[a]),back:null!==c.assistant||null!==c.user}}],587479)},222099,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={getRedirectError:function(){return i},getRedirectStatusCodeFromError:function(){return n},getRedirectTypeFromError:function(){return m},getURLFromRedirectError:function(){return l},permanentRedirect:function(){return k},redirect:function(){return j}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(615128),g=a.r(111026),h=a.r(869789);function i(a,b,c=f.RedirectStatusCode.TemporaryRedirect){let d=Object.defineProperty(Error(g.REDIRECT_ERROR_CODE),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return d.digest=`${g.REDIRECT_ERROR_CODE};${b};${a};${c};`,d}function j(a,b){throw i(a,b??=h.actionAsyncStorage?.getStore()?.isAction?"push":"replace",f.RedirectStatusCode.TemporaryRedirect)}function k(a,b="replace"){throw i(a,b,f.RedirectStatusCode.PermanentRedirect)}function l(a){return(0,g.isRedirectError)(a)?a.digest.split(";").slice(2,-2).join(";"):null}function m(a){if(!(0,g.isRedirectError)(a))throw Object.defineProperty(Error("Not a redirect error"),"__NEXT_ERROR_CODE",{value:"E260",enumerable:!1,configurable:!0});return a.digest.split(";",2)[1]}function n(a){if(!(0,g.isRedirectError)(a))throw Object.defineProperty(Error("Not a redirect error"),"__NEXT_ERROR_CODE",{value:"E260",enumerable:!1,configurable:!0});return Number(a.digest.split(";").at(-2))}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},8535,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={HTTPAccessErrorStatus:function(){return f},HTTP_ERROR_FALLBACK_ERROR_CODE:function(){return h},getAccessFallbackErrorTypeByStatus:function(){return k},getAccessFallbackHTTPStatus:function(){return j},isHTTPAccessFallbackError:function(){return i}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f={NOT_FOUND:404,FORBIDDEN:403,UNAUTHORIZED:401},g=new Set(Object.values(f)),h="NEXT_HTTP_ERROR_FALLBACK";function i(a){if("object"!=typeof a||null===a||!("digest"in a)||"string"!=typeof a.digest)return!1;let[b,c]=a.digest.split(";");return b===h&&g.has(Number(c))}function j(a){return Number(a.digest.split(";")[1])}function k(a){switch(a){case 401:return"unauthorized";case 403:return"forbidden";case 404:return"not-found";default:return}}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},228102,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"notFound",{enumerable:!0,get:function(){return f}});let d=a.r(8535),e=`${d.HTTP_ERROR_FALLBACK_ERROR_CODE};404`;function f(){let a=Object.defineProperty(Error(e),"__NEXT_ERROR_CODE",{value:"E1041",enumerable:!1,configurable:!0});throw a.digest=e,a}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},364177,(a,b,c)=>{"use strict";function d(){throw Object.defineProperty(Error("`forbidden()` is experimental and only allowed to be enabled when `experimental.authInterrupts` is enabled."),"__NEXT_ERROR_CODE",{value:"E488",enumerable:!1,configurable:!0})}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"forbidden",{enumerable:!0,get:function(){return d}}),a.r(8535).HTTP_ERROR_FALLBACK_ERROR_CODE,("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},688213,(a,b,c)=>{"use strict";function d(){throw Object.defineProperty(Error("`unauthorized()` is experimental and only allowed to be used when `experimental.authInterrupts` is enabled."),"__NEXT_ERROR_CODE",{value:"E411",enumerable:!1,configurable:!0})}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"unauthorized",{enumerable:!0,get:function(){return d}}),a.r(8535).HTTP_ERROR_FALLBACK_ERROR_CODE,("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},731101,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"isPostpone",{enumerable:!0,get:function(){return e}});let d=Symbol.for("react.postpone");function e(a){return"object"==typeof a&&null!==a&&a.$$typeof===d}},477747,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"isNextRouterError",{enumerable:!0,get:function(){return f}});let d=a.r(8535),e=a.r(111026);function f(a){return(0,e.isRedirectError)(a)||(0,d.isHTTPAccessFallbackError)(a)}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},247083,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"unstable_rethrow",{enumerable:!0,get:function(){return function a(b){if((0,g.isNextRouterError)(b)||(0,f.isBailoutToCSRError)(b)||(0,i.isDynamicServerError)(b)||(0,h.isDynamicPostpone)(b)||(0,e.isPostpone)(b)||(0,d.isHangingPromiseRejectionError)(b)||(0,h.isPrerenderInterruptedError)(b))throw b;b instanceof Error&&"cause"in b&&a(b.cause)}}});let d=a.r(935710),e=a.r(731101),f=a.r(441997),g=a.r(477747),h=a.r(154110),i=a.r(903326);("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},521066,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={ReadonlyURLSearchParams:function(){return f.ReadonlyURLSearchParams},RedirectType:function(){return m},forbidden:function(){return i.forbidden},notFound:function(){return h.notFound},permanentRedirect:function(){return g.permanentRedirect},redirect:function(){return g.redirect},unauthorized:function(){return j.unauthorized},unstable_isUnrecognizedActionError:function(){return l},unstable_rethrow:function(){return k.unstable_rethrow}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(475718),g=a.r(222099),h=a.r(228102),i=a.r(364177),j=a.r(688213),k=a.r(247083);function l(){throw Object.defineProperty(Error("`unstable_isUnrecognizedActionError` can only be used on the client."),"__NEXT_ERROR_CODE",{value:"E776",enumerable:!1,configurable:!0})}let m={push:"push",replace:"replace"};("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},874137,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={ReadonlyURLSearchParams:function(){return h.ReadonlyURLSearchParams},RedirectType:function(){return m.RedirectType},ServerInsertedHTMLContext:function(){return k.ServerInsertedHTMLContext},forbidden:function(){return m.forbidden},notFound:function(){return m.notFound},permanentRedirect:function(){return m.permanentRedirect},redirect:function(){return m.redirect},unauthorized:function(){return m.unauthorized},unstable_isUnrecognizedActionError:function(){return l.unstable_isUnrecognizedActionError},unstable_rethrow:function(){return m.unstable_rethrow},useParams:function(){return t},usePathname:function(){return r},useRouter:function(){return s},useSearchParams:function(){return q},useSelectedLayoutSegment:function(){return v},useSelectedLayoutSegments:function(){return u},useServerInsertedHTML:function(){return k.useServerInsertedHTML}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(346058)._(a.r(572131)),g=a.r(909270),h=a.r(736313),i=a.r(739118),j=a.r(549842),k=a.r(818341),l=a.r(857997),m=a.r(521066),{instrumentParamsForClientValidation:n,instrumentSearchParamsForClientValidation:o,expectCompleteParamsInClientValidation:p}={};function q(){j.useDynamicSearchParams?.("useSearchParams()");let a=(0,f.useContext)(h.SearchParamsContext);return(0,f.useMemo)(()=>a?new h.ReadonlyURLSearchParams(a):null,[a])}function r(){return j.useDynamicRouteParams?.("usePathname()"),(0,f.useContext)(h.PathnameContext)}function s(){let a=(0,f.useContext)(g.AppRouterContext);if(null===a)throw Object.defineProperty(Error("invariant expected app router to be mounted"),"__NEXT_ERROR_CODE",{value:"E238",enumerable:!1,configurable:!0});let b=(0,f.useContext)(g.LayoutRouterContext),c=b?.parentCacheNode.bfcacheId??0;return(0,f.useMemo)(()=>({back:a.back,forward:a.forward,refresh:a.refresh,hmrRefresh:a.hmrRefresh,push:a.push,replace:a.replace,prefetch:a.prefetch,experimental_gesturePush:a.experimental_gesturePush,bfcacheId:"_b_"+c+"_"}),[a,c])}function t(){return j.useDynamicRouteParams?.("useParams()"),(0,f.useContext)(h.PathParamsContext)}function u(a="children"){j.useDynamicRouteParams?.("useSelectedLayoutSegments()");let b=(0,f.useContext)(g.LayoutRouterContext);return b?(0,i.getSelectedLayoutSegmentPath)(b.parentTree,a):null}function v(a="children"){j.useDynamicRouteParams?.("useSelectedLayoutSegment()"),(0,f.useContext)(h.NavigationPromisesContext);let b=u(a);return(0,i.computeSelectedLayoutSegment)(b,a)}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},50944,(a,b,c)=>{b.exports=a.r(874137)},857997,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={UnrecognizedActionError:function(){return f},unstable_isUnrecognizedActionError:function(){return g}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});class f extends Error{constructor(...a){super(...a),this.name="UnrecognizedActionError"}}function g(a){return!!(a&&"object"==typeof a&&a instanceof f)}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},475718,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"ReadonlyURLSearchParams",{enumerable:!0,get:function(){return e}});class d extends Error{constructor(){super("Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams"),Object.defineProperty(this,"__NEXT_ERROR_CODE",{value:"E1174",enumerable:!1,configurable:!0})}}class e extends URLSearchParams{append(){throw new d}delete(){throw new d}set(){throw new d}sort(){throw new d}}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},615128,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"RedirectStatusCode",{enumerable:!0,get:function(){return e}});var d,e=((d={})[d.SeeOther=303]="SeeOther",d[d.TemporaryRedirect=307]="TemporaryRedirect",d[d.PermanentRedirect=308]="PermanentRedirect",d);("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},111026,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={REDIRECT_ERROR_CODE:function(){return g},isRedirectError:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(615128),g="NEXT_REDIRECT";function h(a){if("object"!=typeof a||null===a||!("digest"in a)||"string"!=typeof a.digest)return!1;let b=a.digest.split(";"),[c,d]=b,e=b.slice(2,-2).join(";"),h=Number(b.at(-2));return c===g&&("replace"===d||"push"===d)&&"string"==typeof e&&!isNaN(h)&&h in f.RedirectStatusCode}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},308117,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={createDynamicBodyError:function(){return g},createDynamicBodyErrorInNavigation:function(){return j},createDynamicMetadataError:function(){return n},createDynamicOrRuntimeBodyError:function(){return k},createDynamicOrRuntimeMetadataError:function(){return s},createDynamicOrRuntimeViewportError:function(){return r},createDynamicViewportError:function(){return q},createLinkBodyErrorInNavigation:function(){return i},createLinkMetadataError:function(){return l},createLinkViewportError:function(){return o},createRuntimeBodyError:function(){return f},createRuntimeBodyErrorInNavigation:function(){return h},createRuntimeMetadataError:function(){return m},createRuntimeViewportError:function(){return p},logBuildDebugHint:function(){return t}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(a){return Object.defineProperty(Error(`Route "${a}": Next.js encountered runtime data during prerendering.
|
|
13
13
|
|
|
14
14
|
\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.
|
|
15
15
|
|