thursday-agent 0.4.0 → 0.6.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/app-path-routes-manifest.json +3 -2
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.json +8 -1
- package/.next/routes-manifest.json +18 -6
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- 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/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +13 -13
- package/.next/server/app/_not-found.segments/_full.segment.rsc +13 -13
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +12 -12
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/artifact/route.js +10 -6
- package/.next/server/app/api/artifact/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/memory/files/route.js +6 -5
- package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/memory/route.js +8 -8
- package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/route.js +8 -8
- package/.next/server/app/api/bot/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/[id]/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/bot/thread/[id]/route.js +15 -0
- package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/bot/thread/[id]/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/bot/thread/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/bot/thread/route.js +15 -0
- package/.next/server/app/api/bot/thread/route.js.nft.json +1 -0
- package/.next/server/app/api/bot/thread/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/config/route.js +7 -7
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/events/route.js +3 -3
- package/.next/server/app/api/events/route.js.nft.json +1 -1
- package/.next/server/app/api/file/[...path]/route.js +5 -5
- package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/catalog/route.js +8 -8
- package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/credits/route.js +8 -8
- package/.next/server/app/api/llm-model/credits/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/route.js +8 -8
- package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/subscription/route.js +8 -8
- package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/[name]/route.js +6 -6
- package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/oauth/callback/route.js +4 -4
- package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/route.js +6 -6
- package/.next/server/app/api/mcp/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/tools/route.js +6 -6
- package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
- package/.next/server/app/api/memory/edit/route.js +13 -13
- package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
- package/.next/server/app/api/memory/route.js +7 -6
- package/.next/server/app/api/memory/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/[source]/[name]/route.js +6 -6
- package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route.js +6 -6
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/route.js +10 -11
- package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/skills/route.js +10 -11
- package/.next/server/app/api/thursday/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/tool-call/route.js +15 -15
- package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/missing/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/workspace/missing/route/build-manifest.json +12 -0
- package/.next/server/app/api/workspace/missing/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/workspace/missing/route.js +12 -0
- package/.next/server/app/api/workspace/missing/route.js.map +5 -0
- package/.next/server/app/api/workspace/missing/route.js.nft.json +1 -0
- package/.next/server/app/api/workspace/missing/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/workspace/route.js +5 -4
- package/.next/server/app/api/workspace/route.js.nft.json +1 -1
- package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +1 -1
- package/.next/server/app/artifact/[...path]/page.js +4 -3
- 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/favicon.ico/route.js.nft.json +1 -1
- package/.next/server/app/page/server-reference-manifest.json +67 -45
- package/.next/server/app/page.js +10 -9
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +3 -2
- package/.next/server/chunks/[root-of-the-server]__02846fb._.js +8 -0
- package/.next/server/chunks/[root-of-the-server]__049f521._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__05luceg._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__06--3q3._.js +8 -0
- package/.next/server/chunks/[root-of-the-server]__07bnah_._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__08eae20._.js +8 -0
- package/.next/server/chunks/[root-of-the-server]__0_ue8oe._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0c9fgca._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__0g-ueei._.js +8 -0
- package/.next/server/chunks/[root-of-the-server]__0h_x6q6._.js +5 -0
- package/.next/server/chunks/{[root-of-the-server]__0pa2n68._.js → [root-of-the-server]__0kxrvxf._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__0q0vvt2._.js → [root-of-the-server]__0ov3iir._.js} +2 -2
- package/.next/server/chunks/[root-of-the-server]__0qwtlmx._.js +8 -0
- package/.next/server/chunks/[root-of-the-server]__0sm5xvm._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0ye3da2._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0zp35ul._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__144u9d_._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__18-2tsq._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__1e-ci13._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1e2365e._.js +8 -0
- package/.next/server/chunks/[root-of-the-server]__1fix932._.js +8 -0
- package/.next/server/chunks/{[root-of-the-server]__0ce8nf8._.js → [root-of-the-server]__1g3t7vn._.js} +3 -3
- package/.next/server/chunks/[root-of-the-server]__1kp-83u._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__1kv8p3e._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__1orn-5b._.js +2 -3
- package/.next/server/chunks/_02szwk8._.js +5 -0
- package/.next/server/chunks/_05h2cii._.js +1 -1
- package/.next/server/chunks/_06c9kie._.js +216 -0
- package/.next/server/chunks/{_1x6kd1r._.js → _07y2gj-._.js} +1 -1
- package/.next/server/chunks/_0a43a-0._.js +3 -0
- package/.next/server/chunks/_0bujjey._.js +5 -0
- package/.next/server/chunks/_0c9j6rb._.js +1 -1
- package/.next/server/chunks/_0dkd549._.js +3 -0
- package/.next/server/chunks/_0ej1kvv._.js +3 -0
- package/.next/server/chunks/_0f6ts7z._.js +3 -0
- package/.next/server/chunks/_0gm9hyv._.js +55 -0
- package/.next/server/chunks/_0i55en5._.js +25 -0
- package/.next/server/chunks/_0k50n27._.js +18 -0
- package/.next/server/chunks/_0khihjk._.js +3 -3
- package/.next/server/chunks/_0n74zsf._.js +5 -5
- package/.next/server/chunks/_0nvm9ef._.js +3 -0
- package/.next/server/chunks/_0p56fn0._.js +3 -0
- package/.next/server/chunks/_0recufk._.js +1 -1
- package/.next/server/chunks/_0xbkz10._.js +3 -0
- package/.next/server/chunks/_10tkr26._.js +3 -0
- package/.next/server/chunks/{_0ioz3nd._.js → _11u2kp7._.js} +1 -1
- package/.next/server/chunks/_11ujpya._.js +3 -0
- package/.next/server/chunks/_127nx_p._.js +5 -0
- package/.next/server/chunks/_17l5ygt._.js +1 -1
- package/.next/server/chunks/_19uauj6._.js +3 -0
- package/.next/server/chunks/_1_5mnq4._.js +5 -5
- package/.next/server/chunks/_1abl6t9._.js +55 -0
- package/.next/server/chunks/_1d0j961._.js +3 -3
- package/.next/server/chunks/_1dbixxz._.js +3 -0
- package/.next/server/chunks/_1dc_d1q._.js +98 -0
- package/.next/server/chunks/_1drgfx4._.js +5 -5
- package/.next/server/chunks/_1e48czp._.js +3 -3
- package/.next/server/chunks/_1f31u5x._.js +5 -0
- package/.next/server/chunks/_1kg70wc._.js +3 -3
- package/.next/server/chunks/_1klbcft._.js +5 -0
- package/.next/server/chunks/_1krd9rf._.js +4 -1
- package/.next/server/chunks/_1kwmzab._.js +3 -0
- package/.next/server/chunks/{_1pf4qe-._.js → _1oxj9fa._.js} +1 -1
- package/.next/server/chunks/{_1f46eie._.js → _1pcmdbb._.js} +1 -1
- package/.next/server/chunks/_1qgix-j._.js +3 -0
- package/.next/server/chunks/{lib_logger_ts_1exwjut._.js → _1rpchta._.js} +5 -5
- package/.next/server/chunks/_1vsej-s._.js +5 -0
- package/.next/server/chunks/_1yx0p_s._.js +5 -0
- package/.next/server/chunks/{_0rnf-6n._.js → _20fsr_z._.js} +6 -6
- package/.next/server/chunks/_2128hkj._.js +5 -0
- package/.next/server/chunks/_next-internal_server_app_api_bot_thread_[id]_route_actions_1fstjn2.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_bot_thread_route_actions_003ccso.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_workspace_missing_route_actions_1fidi6p.js +3 -0
- package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
- package/.next/server/chunks/features_0-cnt0l._.js +4 -0
- package/.next/server/chunks/features_0hdaci0._.js +4 -0
- package/.next/server/chunks/features_1e39j7-._.js +8 -0
- package/.next/server/chunks/features_bot_bot_query_ts_12mgkl2._.js +1 -1
- package/.next/server/chunks/features_memory_1uqvksn._.js +1 -1
- package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0r28-sm._.js → node_modules_consola_dist_chunks_prompt_mjs_0a7-pbw._.js} +1 -1
- package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0v_7drq._.js → node_modules_consola_dist_chunks_prompt_mjs_0gzvgfv._.js} +1 -1
- package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0i7cvml._.js → node_modules_consola_dist_chunks_prompt_mjs_107pxfn._.js} +1 -1
- package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0icqaqw._.js → node_modules_consola_dist_chunks_prompt_mjs_15hbel8._.js} +1 -1
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_18i-23e._.js +3 -0
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1bewgf3._.js +3 -0
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1kipdeo._.js +3 -0
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1nlww1m._.js +3 -0
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1q77nfx._.js +3 -0
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1xqdzx_._.js +3 -0
- package/.next/server/chunks/{node_modules_zod_v4_1801ax7._.js → node_modules_zod_v4_0lkux5-._.js} +2 -2
- package/.next/server/chunks/{node_modules_zod_v4_1cha_bw._.js → node_modules_zod_v4_1jmr9cq._.js} +2 -2
- package/.next/server/chunks/{node_modules_zod_v4_0ubdflj._.js → node_modules_zod_v4_1yrxmek._.js} +2 -2
- package/.next/server/chunks/node_modules_zod_v4_classic_errors_0tp0y-q.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__09q9med._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0bxsfyn._.js +101 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0lyi8i2._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__16jc196._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__172cq4x._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__18dthbp._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__18e68w8._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1fll8dc._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1mzi-ju._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1nygfik._.js +5 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1sdphb0._.js +8 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1waa3rc._.js +100 -0
- package/.next/server/chunks/ssr/_00rehl_._.js +3 -0
- package/.next/server/chunks/ssr/{_1lz_cq2._.js → _02oc_h5._.js} +76 -89
- package/.next/server/chunks/ssr/_03_928f._.js +3 -0
- package/.next/server/chunks/ssr/_05yghx6._.js +3 -0
- package/.next/server/chunks/ssr/_08c4z-9._.js +3 -0
- package/.next/server/chunks/ssr/_0_qfdlw._.js +4 -0
- package/.next/server/chunks/ssr/_0c9e5w6._.js +9 -0
- package/.next/server/chunks/ssr/{_0s99bgb._.js → _0dh2e1j._.js} +9 -3
- package/.next/server/chunks/ssr/_0dr-ddg._.js +3 -0
- package/.next/server/chunks/ssr/_0eaog6_._.js +3 -0
- package/.next/server/chunks/ssr/_0evkpto._.js +3 -0
- package/.next/server/chunks/ssr/_0g_rlog._.js +3 -0
- package/.next/server/chunks/ssr/_0geg212._.js +3 -0
- package/.next/server/chunks/ssr/{_1gd8q8l._.js → _0hxt2ul._.js} +2 -2
- package/.next/server/chunks/ssr/_0i_6q1w._.js +2 -2
- package/.next/server/chunks/ssr/_0lu1n_x._.js +1 -1
- package/.next/server/chunks/ssr/{_15j2_8f._.js → _0wzaht-._.js} +2 -2
- package/.next/server/chunks/ssr/_0z-g0uy._.js +3 -0
- package/.next/server/chunks/ssr/_123ttsf._.js +3 -0
- package/.next/server/chunks/ssr/_123y-ah._.js +3 -0
- package/.next/server/chunks/ssr/_12w42gi._.js +3 -0
- package/.next/server/chunks/ssr/_161kqav._.js +3 -0
- package/.next/server/chunks/ssr/{_0ap2fzn._.js → _16c6_xm._.js} +2 -2
- package/.next/server/chunks/ssr/_18opah7._.js +3 -0
- package/.next/server/chunks/ssr/_18xqmny._.js +3 -0
- package/.next/server/chunks/ssr/_1_krfph._.js +3 -0
- package/.next/server/chunks/ssr/{_1-_etts._.js → _1anqots._.js} +2 -2
- package/.next/server/chunks/ssr/_1ey7qn-._.js +70 -0
- package/.next/server/chunks/ssr/_1g9vs7q._.js +3 -0
- package/.next/server/chunks/ssr/_1jmz33w._.js +3 -0
- package/.next/server/chunks/ssr/{_0n3toaw._.js → _1k0spz7._.js} +2 -2
- package/.next/server/chunks/ssr/_1rgtxhr._.js +5 -0
- package/.next/server/chunks/ssr/_1slp25y._.js +3 -0
- package/.next/server/chunks/ssr/{_1fojd41._.js → _1x9pskj._.js} +3 -3
- package/.next/server/chunks/ssr/_1y6b5mr._.js +101 -0
- package/.next/server/chunks/ssr/_1ztk7p6._.js +7 -0
- package/.next/server/chunks/ssr/components_ui_tabs_tsx_0ej40b4._.js +3 -0
- package/.next/server/chunks/ssr/features_bot_thread_query_ts_023eklt._.js +4 -0
- 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/{_1-teee5._.js → lib_logger_ts_0-olsze._.js} +2 -7
- package/.next/server/chunks/ssr/{node_modules_0cxaxk9._.js → node_modules_00_51_v._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_04jf_m8._.js → node_modules_022sipm._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0g7fzk3._.js → node_modules_0332gw4._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1cx_ql6._.js → node_modules_04vxchl._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1vh5ntv._.js → node_modules_0746rzi._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0yugy6m._.js → node_modules_0d5uzof._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_09q35v_._.js → node_modules_0exkwcm._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_08dhkiq._.js → node_modules_0fr-ml8._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_14q6g4n._.js → node_modules_0mxvg8h._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0arus10._.js → node_modules_0qapgjr._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1eg7m6c._.js → node_modules_0qbfyjh._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1cz2hle._.js → node_modules_0t-9nup._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_17bwo43._.js → node_modules_0tusx4d._.js} +3 -3
- package/.next/server/chunks/ssr/{node_modules_1efrqxi._.js → node_modules_0vsxbzp._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0_-_a--._.js → node_modules_0vv0-fg._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1gdh31p._.js → node_modules_0wsvp00._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1hpopmo._.js → node_modules_1-urho9._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1_pc9kq._.js → node_modules_16pi_dd._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_00etblx._.js → node_modules_1d53yiq._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1aaxuef._.js → node_modules_1g1eihe._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_198nmll._.js → node_modules_1gpednh._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0pvd7q-._.js → node_modules_1gu1pph._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0b__sgl._.js → node_modules_1he1w8_._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1qpjvy5._.js → node_modules_1lnjapm._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0940ns5._.js → node_modules_1lynj9m._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0x3-ply._.js → node_modules_1seuurl._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_14om4ar._.js → node_modules_1u6w1pb._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0had7xd._.js → node_modules_1xn6saw._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1b748ic._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_067_exa._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1z4hm5e._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0nrrdaq._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_@vercel_oidc_dist_06mk8id._.js → node_modules_@vercel_oidc_dist_21a5haa._.js} +1 -1
- package/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_trash_mjs_0px2gzr._.js +3 -0
- 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 +68 -46
- package/.next/static/chunks/0dr16v67vj4n7.js +2 -0
- package/.next/static/chunks/0g4b348l0pve7.js +1 -0
- package/.next/static/chunks/0joan-69kbspd.js +1 -0
- package/.next/static/chunks/0vlgzqo9ka90v.js +1 -0
- package/.next/static/chunks/0zrupxgci5gqc.js +1 -0
- package/.next/static/chunks/10k2xvap03z20.css +1 -0
- package/.next/static/chunks/18mkhstgiqcbt.js +1 -0
- package/.next/static/chunks/{15m575979un5f.js → 1i-u2wzub_to1.js} +2 -2
- package/.next/static/chunks/1kp5nfp06nj9h.js +5 -0
- package/.next/static/chunks/1ohslk4568tm3.js +1 -0
- package/.next/static/chunks/1sbmwswc9k2-1.js +1 -0
- package/.next/static/chunks/1t9qms5pwwa3n.js +1 -0
- package/.next/static/chunks/1vj_5bnbxx84e.js +1 -0
- package/.next/static/chunks/1vqezbhjm3goq.js +1 -0
- package/.next/static/chunks/{3akmqm77muj4-.js → 1wlo979mx-y3w.js} +1 -1
- package/.next/static/chunks/26ql4y-43xwhp.js +1 -0
- package/.next/static/chunks/{0fl3gwe4-l6tz.js → 2_pnccjp6j1ca.js} +1 -1
- package/.next/static/chunks/2a51-ywz9b2a3.js +1 -0
- package/.next/static/chunks/2fvdgxih7x7hr.js +1 -0
- package/.next/static/chunks/2jlz8zp4jax_m.js +18 -0
- package/.next/static/chunks/2nvepds1fu2ux.js +1 -0
- package/.next/static/chunks/3addj3i4-izma.js +1 -0
- package/.next/static/chunks/3bfwpww3m3x4u.js +1 -0
- package/.next/static/chunks/3gfh7nxwusbt0.js +1 -0
- package/.next/static/chunks/3gwa44cvz4qoi.js +1 -0
- package/.next/static/chunks/{38gweqdo4jpfj.js → 3izg0a3k87q1-.js} +5 -5
- package/.next/static/chunks/3zk6q3-3f9swq.js +99 -0
- package/.next/static/chunks/3zkg5iup3v4a2.js +12 -0
- package/.next/static/chunks/405m0bqtoihev.js +1 -0
- package/.next/static/chunks/42wcg3wfg_m_p.js +1 -0
- package/README.md +27 -216
- package/app/api/events/app-event.ts +6 -4
- package/app/api/query-key.ts +25 -16
- package/bin/database.mjs +37 -0
- package/bin/thursday.mjs +44 -28
- package/components/ui/custom-icon.tsx +0 -60
- package/components/ui/radio-group.tsx +37 -0
- package/components/ui/shiny-text.tsx +33 -6
- package/database/migrations/{20260910173049_numerous_spirit → 20260916145701_clever_multiple_man}/migration.sql +80 -24
- package/database/migrations/{20260910173049_numerous_spirit → 20260916145701_clever_multiple_man}/snapshot.json +689 -110
- package/database/migrations/20260916160713_thread_cancelled/migration.sql +2 -0
- package/database/migrations/{20260911030320_opposite_jack_power → 20260916160713_thread_cancelled}/snapshot.json +706 -84
- package/docs/how-it-works.md +39 -36
- package/docs/images/keeps-going.png +0 -0
- package/docs/images/two-minds.png +0 -0
- package/docs/live-calls.md +231 -0
- package/docs/thread-rooms.md +71 -0
- package/features/ai/chatgpt.ts +1 -2
- package/features/ai/live.schema.ts +128 -0
- package/features/ai/load-tools.ts +148 -77
- package/features/ai/model.schema.ts +2 -120
- package/features/ai/model.ts +52 -88
- package/features/ai/prompts/bot.prompt.ts +91 -214
- package/features/ai/prompts/live.prompt.ts +265 -0
- package/features/ai/prompts/prompt-helper.ts +91 -32
- package/features/ai/prompts/thursday.prompt.ts +125 -172
- package/features/ai/tools/bot.tool.ts +38 -145
- package/features/ai/tools/call.tool.ts +1 -1
- package/features/ai/tools/connected.ts +5 -3
- package/features/ai/tools/mcp.tool.ts +7 -4
- package/features/ai/tools/memory.tool.ts +35 -31
- package/features/ai/tools/skills.tool.ts +36 -14
- package/features/ai/tools/studio.tool.ts +26 -21
- package/features/ai/tools/tool-name.ts +2 -5
- package/features/ai/tools/workspace.tool.ts +33 -10
- package/features/artifact/artifact.action.ts +2 -2
- package/features/artifact/artifact.query.ts +112 -61
- package/features/artifact/artifact.schema.ts +8 -6
- package/features/artifact/components/artifact-setting.tsx +83 -33
- package/features/bot/bot.action.ts +43 -36
- package/features/bot/bot.memory.ts +137 -20
- package/features/bot/bot.query.ts +28 -11
- package/features/bot/bot.run.ts +299 -636
- package/features/bot/bot.runner.ts +468 -844
- package/features/bot/bot.schema.ts +93 -82
- package/features/bot/bot.seed.ts +141 -64
- package/features/bot/components/bot-mark.tsx +324 -232
- package/features/bot/components/bot-room.tsx +1613 -697
- package/features/bot/components/bot-roster.tsx +8 -13
- package/features/bot/components/bot-setting.tsx +58 -42
- package/features/bot/components/bot-tool.tsx +55 -87
- package/features/bot/components/mark-palette.tsx +35 -32
- package/features/bot/components/path-chips.tsx +33 -3
- package/features/bot/components/thread-badge.tsx +34 -0
- package/features/bot/components/thread-reply.tsx +639 -0
- package/features/bot/components/thread-setting.tsx +674 -0
- package/features/bot/mark.const.ts +79 -31
- package/features/bot/room.query.ts +889 -0
- package/features/bot/room.schema.ts +64 -0
- package/features/bot/seed-bots.ts +2 -1
- package/features/bot/thread.query.ts +971 -0
- package/features/bot/thread.store.ts +587 -0
- package/features/config/components/voice-key.tsx +113 -88
- package/features/config/config.const.ts +5 -9
- package/features/connectors/mcp.schema.ts +0 -2
- package/features/intro/components/intro.tsx +169 -139
- package/features/memory/components/memory-setting.tsx +2 -7
- package/features/memory/memory.schema.ts +14 -23
- package/features/settings/components/setting-ui.tsx +0 -44
- package/features/settings/components/settings.tsx +12 -12
- package/features/settings/settings.alert.ts +3 -3
- package/features/settings/settings.store.ts +1 -1
- package/features/skills/skills.schema.ts +0 -2
- package/features/thursday/components/ascii-field.tsx +24 -44
- package/features/thursday/components/ascii-orb.tsx +359 -358
- package/features/thursday/components/call-log.tsx +46 -44
- package/features/thursday/components/face.tsx +35 -10
- package/features/thursday/components/tab-state.tsx +3 -3
- package/features/thursday/components/thursday-mark.tsx +1 -0
- package/features/thursday/components/thursday-setting.tsx +631 -332
- package/features/thursday/components/thursday.tsx +106 -41
- package/features/thursday/components/voice-picker.tsx +255 -0
- package/features/thursday/thursday.action.ts +94 -68
- package/features/thursday/thursday.query.ts +49 -30
- package/features/thursday/thursday.schema.ts +27 -30
- package/features/thursday/thursday.store.ts +11 -7
- package/features/thursday/tool-call.ts +3 -3
- package/features/thursday/tool-line.ts +5 -3
- package/features/thursday/use-thursday.ts +725 -450
- package/features/workspace/workspace.query.ts +17 -0
- package/features/workspace/workspace.ts +103 -50
- package/lib/live/live.schema.ts +47 -0
- package/lib/live/live.server.ts +155 -0
- package/lib/live/live.session.ts +574 -0
- package/lib/{realtime/realtime.tap.ts → live/live.tap.ts} +41 -12
- package/lib/live/live.transport.ts +152 -0
- package/lib/protocol/use-server-pages.ts +9 -5
- package/lib/utils.ts +21 -20
- package/package.json +2 -2
- package/public/voices/alloy.ogg +0 -0
- package/public/voices/ash.ogg +0 -0
- package/public/voices/ballad.ogg +0 -0
- package/public/voices/beacon.ogg +0 -0
- package/public/voices/bossa.ogg +0 -0
- package/public/voices/cedar.ogg +0 -0
- package/public/voices/cinder.ogg +0 -0
- package/public/voices/coral.ogg +0 -0
- package/public/voices/delta.ogg +0 -0
- package/public/voices/echo.ogg +0 -0
- package/public/voices/gleam.ogg +0 -0
- package/public/voices/marin.ogg +0 -0
- package/public/voices/meridian.ogg +0 -0
- package/public/voices/quartz.ogg +0 -0
- package/public/voices/ripple.ogg +0 -0
- package/public/voices/sage.ogg +0 -0
- package/public/voices/shimmer.ogg +0 -0
- package/public/voices/stone.ogg +0 -0
- package/public/voices/tempo.ogg +0 -0
- package/public/voices/verse.ogg +0 -0
- package/public/voices/vesper.ogg +0 -0
- package/public/voices/willow.ogg +0 -0
- package/scripts/artifact-paths.test.mts +25 -0
- package/scripts/bot-context.test.mts +1408 -0
- package/scripts/live-history.test.mts +115 -0
- package/scripts/live-session.test.mts +948 -0
- package/server.js +1 -1
- package/skills/browser/SKILL.md +17 -6
- package/skills/computer/SKILL.md +1 -1
- package/skills/find-skills/SKILL.md +3 -8
- package/skills/interactive-page/SKILL.md +12 -7
- package/skills/interactive-page/references/diagram.md +89 -0
- package/skills/interactive-page/scripts/archify/LICENSE +22 -0
- package/skills/interactive-page/scripts/archify/README.md +25 -0
- package/skills/interactive-page/scripts/archify/assets/JetBrainsMono-OFL.txt +93 -0
- package/skills/interactive-page/scripts/archify/assets/template.html +14934 -0
- package/skills/interactive-page/scripts/archify/bin/archify.mjs +2126 -0
- package/skills/interactive-page/scripts/archify/bin/open-artifact.mjs +86 -0
- package/skills/interactive-page/scripts/archify/bin/preview.mjs +653 -0
- package/skills/interactive-page/scripts/archify/bin/visual-check.mjs +829 -0
- package/skills/interactive-page/scripts/archify/delta/architecture-delta.mjs +1223 -0
- package/skills/interactive-page/scripts/archify/examples/agent-run.lifecycle.json +60 -0
- package/skills/interactive-page/scripts/archify/examples/agent-tool-call.workflow.json +94 -0
- package/skills/interactive-page/scripts/archify/examples/async-job-roundtrip.sequence.json +61 -0
- package/skills/interactive-page/scripts/archify/examples/cache-miss-request.sequence.json +82 -0
- package/skills/interactive-page/scripts/archify/examples/checkout-platform.base.architecture.json +31 -0
- package/skills/interactive-page/scripts/archify/examples/checkout-platform.head.architecture.json +31 -0
- package/skills/interactive-page/scripts/archify/examples/deployment-release.lifecycle.json +49 -0
- package/skills/interactive-page/scripts/archify/examples/event-stream.dataflow.json +57 -0
- package/skills/interactive-page/scripts/archify/examples/incident-response.workflow.json +64 -0
- package/skills/interactive-page/scripts/archify/examples/product-analytics.dataflow.json +76 -0
- package/skills/interactive-page/scripts/archify/examples/production-deployment.architecture.json +71 -0
- package/skills/interactive-page/scripts/archify/examples/release-delivery.workflow.json +62 -0
- package/skills/interactive-page/scripts/archify/examples/web-app.architecture.json +46 -0
- package/skills/interactive-page/scripts/archify/migrations/workflow-v2.mjs +279 -0
- package/skills/interactive-page/scripts/archify/recipes/scenarios.mjs +284 -0
- package/skills/interactive-page/scripts/archify/references/authoring-contract.md +243 -0
- package/skills/interactive-page/scripts/archify/references/delivery-contract.md +120 -0
- package/skills/interactive-page/scripts/archify/references/viewer-runtime.md +45 -0
- package/skills/interactive-page/scripts/archify/renderers/architecture/grid.mjs +62 -0
- package/skills/interactive-page/scripts/archify/renderers/architecture/render-architecture.mjs +1078 -0
- package/skills/interactive-page/scripts/archify/renderers/dataflow/README.md +104 -0
- package/skills/interactive-page/scripts/archify/renderers/dataflow/render-dataflow.mjs +483 -0
- package/skills/interactive-page/scripts/archify/renderers/lifecycle/README.md +115 -0
- package/skills/interactive-page/scripts/archify/renderers/lifecycle/render-lifecycle.mjs +561 -0
- package/skills/interactive-page/scripts/archify/renderers/sequence/README.md +114 -0
- package/skills/interactive-page/scripts/archify/renderers/sequence/render-sequence.mjs +464 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/brand-marks.mjs +563 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/cli.mjs +218 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/desktop-readability.mjs +26 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/diagnostics.mjs +127 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/engineering-profiles.mjs +157 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/generated-brand-marks.mjs +3 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/generated-validators.mjs +13 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/geometry.mjs +1423 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/i18n.mjs +595 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/layout-report.mjs +40 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/legend.mjs +217 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/output-path.mjs +340 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/repository-evidence.mjs +238 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/repository-location.mjs +58 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/text-fit.mjs +49 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/utils.mjs +232 -0
- package/skills/interactive-page/scripts/archify/renderers/shared/validator.mjs +86 -0
- package/skills/interactive-page/scripts/archify/renderers/workflow/README.md +223 -0
- package/skills/interactive-page/scripts/archify/renderers/workflow/render-workflow.mjs +35 -0
- package/skills/interactive-page/scripts/archify/renderers/workflow/workflow-compiler.mjs +4400 -0
- package/skills/interactive-page/scripts/archify/renderers/workflow/workflow-migration-geometry.mjs +144 -0
- package/skills/interactive-page/scripts/archify/schemas/README.md +211 -0
- package/skills/interactive-page/scripts/archify/schemas/architecture.schema.json +178 -0
- package/skills/interactive-page/scripts/archify/schemas/common.schema.json +115 -0
- package/skills/interactive-page/scripts/archify/schemas/dataflow.schema.json +243 -0
- package/skills/interactive-page/scripts/archify/schemas/lifecycle.schema.json +266 -0
- package/skills/interactive-page/scripts/archify/schemas/sequence.schema.json +223 -0
- package/skills/interactive-page/scripts/archify/schemas/workflow.schema.json +428 -0
- package/skills/interactive-page/scripts/archify/scripts/check-render-output.mjs +916 -0
- package/skills/interactive-page/scripts/archify/scripts/render-examples.mjs +26 -0
- package/skills/interactive-page/scripts/bundle-artifact.sh +9 -8
- package/skills/skill-creator/SKILL.md +4 -5
- package/.next/server/app/api/bot/task/[id]/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/bot/task/[id]/route.js +0 -16
- package/.next/server/app/api/bot/task/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/bot/task/[id]/route_client-reference-manifest.js +0 -3
- package/.next/server/app/api/bot/task/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/bot/task/route.js +0 -16
- package/.next/server/app/api/bot/task/route.js.nft.json +0 -1
- package/.next/server/app/api/bot/task/route_client-reference-manifest.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__01dkp4a._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__02va5wz._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__02xjoto._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__04q--0f._.js +0 -8
- package/.next/server/chunks/[root-of-the-server]__0bl-e63._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0ffbg85._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0jq4ohy._.js +0 -8
- package/.next/server/chunks/[root-of-the-server]__0ls6_8y._.js +0 -8
- package/.next/server/chunks/[root-of-the-server]__0ncs9uu._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1-ga0kh._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__11n256_._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__12cabg9._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1339jnv._.js +0 -8
- package/.next/server/chunks/[root-of-the-server]__18_teo8._.js +0 -8
- package/.next/server/chunks/[root-of-the-server]__1_04mcf._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__1anc1p9._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1ccon1w._.js +0 -10
- package/.next/server/chunks/[root-of-the-server]__1fizn31._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1llj3-b._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1p8m3f4._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1wa1k7r._.js +0 -8
- package/.next/server/chunks/_0-73of8._.js +0 -55
- package/.next/server/chunks/_0-fjql4._.js +0 -26
- package/.next/server/chunks/_00xh_q0._.js +0 -25
- package/.next/server/chunks/_03a0897._.js +0 -3
- package/.next/server/chunks/_051qh8u._.js +0 -3
- package/.next/server/chunks/_05sovvj._.js +0 -3
- package/.next/server/chunks/_0fzqt2y._.js +0 -134
- package/.next/server/chunks/_0mecv0f._.js +0 -26
- package/.next/server/chunks/_0mh8j4m._.js +0 -3
- package/.next/server/chunks/_0obojvv._.js +0 -3
- package/.next/server/chunks/_0sb7tlz._.js +0 -3
- package/.next/server/chunks/_0sbynis._.js +0 -3
- package/.next/server/chunks/_0u10wmw._.js +0 -55
- package/.next/server/chunks/_0u4aiy2._.js +0 -3
- package/.next/server/chunks/_0wp4le3._.js +0 -3
- package/.next/server/chunks/_0y5fg-x._.js +0 -3
- package/.next/server/chunks/_1230wbx._.js +0 -10
- package/.next/server/chunks/_12nheja._.js +0 -3
- package/.next/server/chunks/_13510xh._.js +0 -3
- package/.next/server/chunks/_15hq89o._.js +0 -3
- package/.next/server/chunks/_18-1wcc._.js +0 -55
- package/.next/server/chunks/_1_9mjx-._.js +0 -3
- package/.next/server/chunks/_1c78vw5._.js +0 -229
- package/.next/server/chunks/_1h5_8sk._.js +0 -3
- package/.next/server/chunks/_1hdnxb7._.js +0 -3
- package/.next/server/chunks/_1j8k_j5._.js +0 -3
- package/.next/server/chunks/_1nula3v._.js +0 -3
- package/.next/server/chunks/_1php4eq._.js +0 -3
- package/.next/server/chunks/_1yuv4vp._.js +0 -3
- package/.next/server/chunks/_1zjrdag._.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_bot_task_[id]_route_actions_1_k_8u3.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_bot_task_route_actions_0xln6ra.js +0 -3
- package/.next/server/chunks/features_0rpfxbk._.js +0 -3
- package/.next/server/chunks/features_1qf3cei._.js +0 -3
- package/.next/server/chunks/features_bot_0zt92oh._.js +0 -3
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1xoq2rl._.js +0 -3
- package/.next/server/chunks/ssr/[externals]__0dizgek._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__092knlj._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0mz33a7._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0s9dq5u._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0s9l2sv._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0vnmv-s._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0xsog8n._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__10-dz5o._.js +0 -61
- package/.next/server/chunks/ssr/[root-of-the-server]__1gtlw6v._.js +0 -43
- package/.next/server/chunks/ssr/[root-of-the-server]__1ox7hbk._.js +0 -4
- package/.next/server/chunks/ssr/[root-of-the-server]__202p40z._.js +0 -3
- package/.next/server/chunks/ssr/_001_ms1._.js +0 -28
- package/.next/server/chunks/ssr/_01n3o0m._.js +0 -3
- package/.next/server/chunks/ssr/_0fz4mf_._.js +0 -3
- package/.next/server/chunks/ssr/_0gb4gmf._.js +0 -3
- package/.next/server/chunks/ssr/_0h42fze._.js +0 -3
- package/.next/server/chunks/ssr/_0h7zdni._.js +0 -3
- package/.next/server/chunks/ssr/_0ilna52._.js +0 -42
- package/.next/server/chunks/ssr/_0q0zan6._.js +0 -70
- package/.next/server/chunks/ssr/_0zcjrbg._.js +0 -3
- package/.next/server/chunks/ssr/_0zhoc3r._.js +0 -3
- package/.next/server/chunks/ssr/_13fke0x._.js +0 -3
- package/.next/server/chunks/ssr/_18cymkq._.js +0 -3
- package/.next/server/chunks/ssr/_1b2mjwr._.js +0 -3
- package/.next/server/chunks/ssr/_1f-dg-6._.js +0 -3
- package/.next/server/chunks/ssr/_1h0rw11._.js +0 -3
- package/.next/server/chunks/ssr/_1jhd09t._.js +0 -3
- package/.next/server/chunks/ssr/_1nnsk7z._.js +0 -3
- package/.next/server/chunks/ssr/_1ov37if._.js +0 -3
- package/.next/server/chunks/ssr/_1sji22n._.js +0 -3
- package/.next/server/chunks/ssr/_1vi_uo7._.js +0 -3
- package/.next/server/chunks/ssr/_1vyd1ji._.js +0 -3
- package/.next/server/chunks/ssr/_1xx4zlb._.js +0 -3
- package/.next/server/chunks/ssr/components_ui_1y1l7yj._.js +0 -3
- package/.next/server/chunks/ssr/features_bot_1s_-2vj._.js +0 -3
- package/.next/server/chunks/ssr/lib_realtime_12wg_dd._.js +0 -27
- package/.next/server/chunks/ssr/lib_realtime_15h_v1v._.js +0 -27
- package/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_0npjf8-._.js +0 -3
- package/.next/static/chunks/00rd4-v8r7axp.js +0 -1
- package/.next/static/chunks/08qe4as2q428z.js +0 -3
- package/.next/static/chunks/0gnqdjn2lvdad.js +0 -2
- package/.next/static/chunks/0hwap1-p0m5sa.js +0 -1
- package/.next/static/chunks/0r5qcctujhxli.js +0 -1
- package/.next/static/chunks/0w52rrrmuj9r9.js +0 -1
- package/.next/static/chunks/0wcprt5ot5she.js +0 -1
- package/.next/static/chunks/10teww7wt-f6h.js +0 -1
- package/.next/static/chunks/17p6tk6k88dq6.js +0 -1
- package/.next/static/chunks/18a96rkhi4_yd.js +0 -1
- package/.next/static/chunks/1dkjg87pxk0n9.js +0 -28
- package/.next/static/chunks/1jd09sxcjddu1.js +0 -1
- package/.next/static/chunks/1w73ece_6bheu.js +0 -18
- package/.next/static/chunks/214ya3n5gxeih.js +0 -1
- package/.next/static/chunks/22_zkas21rpna.js +0 -1
- package/.next/static/chunks/2fh4-3z_q8b_w.js +0 -1
- package/.next/static/chunks/2h0sd2vumhb15.js +0 -1
- package/.next/static/chunks/2t4vhi3m8ahya.js +0 -1
- package/.next/static/chunks/2tigdtz3dpcy8.js +0 -1
- package/.next/static/chunks/2u7xt6mxg44lf.js +0 -1
- package/.next/static/chunks/3786h5vayt80-.js +0 -28
- package/.next/static/chunks/39j0fvpybzabl.js +0 -40
- package/.next/static/chunks/3cq5g494yuke8.css +0 -1
- package/.next/static/chunks/3hibbjnt85-k6.js +0 -1
- package/.next/static/chunks/3woj-xd7ki5_i.js +0 -1
- package/.next/static/chunks/3xk7yqgomx7yq.js +0 -1
- package/.next/static/chunks/3zmcsnuo25zvq.js +0 -1
- package/database/migrations/20260911030320_opposite_jack_power/migration.sql +0 -1
- package/docs/images/task-thread.png +0 -0
- package/features/bot/components/task-badge.tsx +0 -42
- package/features/bot/components/task-reply.tsx +0 -328
- package/features/bot/components/task-setting.tsx +0 -524
- package/features/bot/task.query.ts +0 -976
- package/features/bot/task.store.ts +0 -489
- package/lib/realtime/client-secret.ts +0 -86
- package/lib/realtime/open-session.ts +0 -31
- package/lib/realtime/openai.ts +0 -35
- package/lib/realtime/realtime.audio.ts +0 -196
- package/lib/realtime/realtime.driver.ts +0 -489
- package/lib/realtime/realtime.protocol.ts +0 -393
- package/lib/realtime/realtime.schema.ts +0 -37
- package/lib/realtime/realtime.session.ts +0 -106
- package/lib/realtime/realtime.transport.ts +0 -384
- package/lib/realtime/xai.ts +0 -39
- /package/.next/server/app/api/bot/{task → thread}/[id]/route/build-manifest.json +0 -0
- /package/.next/server/app/api/bot/{task → thread}/[id]/route/server-reference-manifest.json +0 -0
- /package/.next/server/app/api/bot/{task → thread}/[id]/route.js.map +0 -0
- /package/.next/server/app/api/bot/{task → thread}/route/build-manifest.json +0 -0
- /package/.next/server/app/api/bot/{task → thread}/route/server-reference-manifest.json +0 -0
- /package/.next/server/app/api/bot/{task → thread}/route.js.map +0 -0
- /package/.next/static/{kaTO0UHqF1bMnWgCDik2f → 0qzGoKn2wTERVZtblX1tp}/_buildManifest.js +0 -0
- /package/.next/static/{kaTO0UHqF1bMnWgCDik2f → 0qzGoKn2wTERVZtblX1tp}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{kaTO0UHqF1bMnWgCDik2f → 0qzGoKn2wTERVZtblX1tp}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports=[159479,e=>e.a(async(t,n)=>{try{var a=e.i(847841),i=e.i(983477),r=e.i(687388),o=e.i(54282),s=e.i(316172),l=e.i(349047),c=e.i(926435),u=e.i(770639),h=e.i(489956),d=e.i(41181),m=e.i(353885),f=e.i(123203),w=e.i(944971),p=e.i(636882),g=e.i(22676),y=e.i(786025),b=e.i(704161),S=e.i(640911),T=e.i(53748),O=e.i(388439),v=e.i(41444),k=t([c,u,h,g]);async function M(t){let{listThreadOverview:n}=await e.A(866938),a=await n();if(!a.length)return"No jobs have been handed over yet.";let i=a.map(e=>`"${e.label}" (${e.bot}, ${e.status})`).join(", ");return`There is no job called "${t}". The latest are: ${i}. Call again with one of those names.`}async function $(e,t){let n=[];for(let[e,i]of Object.entries(t)){let t=await (0,a.asSchema)(i.inputSchema).jsonSchema,r="string"==typeof i.description?i.description:"";n.push({name:e,tokens:(0,O.estimateTokens)(r)+(0,O.estimateTokens)(JSON.stringify(t))})}n.sort((e,t)=>t.tokens-e.tokens);let i=n.reduce((e,t)=>e+t.tokens,0);S.logger.debug(`${e} tools ${i} tokens over ${n.length} — ${n.map(e=>`${e.name} ${e.tokens}`).join(", ")}`)}async function E(e){let t=await _(e);return r.IS_DEV&&await $(e.target,t),t}async function _(t){if("memory-edit"===t.target){let e=(0,u.createMemoryTools)("user",null,{countReads:!1});return{[m.TOOL_NAMES.memory_recall]:e[m.TOOL_NAMES.memory_recall],[m.TOOL_NAMES.memory_remember]:e[m.TOOL_NAMES.memory_remember],[m.TOOL_NAMES.memory_forget]:e[m.TOOL_NAMES.memory_forget]}}let{[m.TOOL_NAMES.memory_conversation]:n,...S}=(0,u.createMemoryTools)("call","thursday"===t.target?t.callId??null:null),O={[m.TOOL_NAMES.memory_conversation]:n},k=await (0,y.openWorkspace)();if("thursday"===t.target){var $;let n=await (0,g.readCallSkillsOn)()?(0,d.createSkillTools)({sandbox:k,skills:await (0,p.loadSkills)(k)}):{};return{...S,...O,...n,...(0,f.createWorkspaceTools)(k,{write:!1,timeoutMs:r.CALL_EXEC_TIMEOUT_MS}),...($=t.callId,{[m.TOOL_NAMES.delegate]:(0,a.tool)({description:s.delegateSpec.description,inputSchema:s.delegateSpec.parameters,execute:async({bot:t,request:n,label:a})=>{let{findJobBot:i,listJobBots:r}=await e.A(814317),o=await i(t);if(!o||o.disabled){let e=(await r()).map(e=>e.name);return`There is no bot called "${t}". The bots are: ${e.join(", ")}. Nothing was handed over — call again with one of those.`}let{startThread:s}=await e.A(994193);return{threadId:await s({bot:o.name,request:n,label:a,callId:$,from:"thursday"}),note:`${o.name} has "${a}". Its updates reach the conversation on their own. Anything further about this work — an answer, a correction, the next step once it finishes — is \`${m.TOOL_NAMES.thread}\` with "${a}".`}}}),[m.TOOL_NAMES.thread]:(0,a.tool)({description:s.threadSpec.description,inputSchema:s.threadSpec.parameters,execute:async({action:t,thread:n,answer:a,recipient:r,replyTo:s})=>{let l,{listThreadOverview:c,resolveThread:u}=await e.A(866938);if("status"===t){let t=a?.trim()?{note:"The text in `answer` was not passed on — `status` only reads. Send it again as `answer` if the bot is meant to hear it."}:{},r={now:(0,o.clockNow)()};if(n){let a=await u(n);if(!a)return await M(n);let{findThreadView:o}=await e.A(866938),s=(await o(a.id))?.room;return{...r,...t,label:a.label,id:a.id,bot:a.bot,participants:s?.participants??[],questions:s?.questions??[],status:a.status,since:(0,i.formatDistanceToNowStrict)((0,b.toDate)(a.updatedAt),{addSuffix:!0}),outcome:a.outcome,..."waiting"===a.status&&a.pending?.options.length?{options:a.pending.options}:{}}}let s=await c();return{...r,...t,threads:s.map(e=>({id:e.id,label:e.label,bot:e.bot,status:e.status,participants:e.room.participants,questions:e.room.questions.map(e=>({...e,text:(0,v.clip)(e.text,200)})),since:(0,i.formatDistanceToNowStrict)((0,b.toDate)(e.updatedAt),{addSuffix:!0}),...e.ask?{asking:e.ask.question,options:e.ask.options}:{},..."running"===e.status?{now:(0,w.threadActivity)(e.lines)}:{},...e.outcome&&"waiting"!==e.status?{outcome:(0,v.clip)(e.outcome,200)}:{}}))}}let{listInboxThreads:h,markSeen:d}=await e.A(866938),f=!n&&("answer"===t||"open"===t),p=f?await h():[],g="answer"===t?p.filter(e=>e.room.questions.length):[];if(g.length>1)return`Questions are waiting in more than one job: ${g.map(e=>`"${e.label}" (${e.room.questions.map(e=>e.bot).join(", ")})`).join(", ")}. Name the job.`;let y=n?await u(n):"answer"===t?g[0]??null:f?p[0]??null:null;if(!y)return n?await M(n):"answer"===t?`No question is waiting. Name the job this is for; \`${m.TOOL_NAMES.thread}\` \`status\` lists them.`:f?"No job has moved yet — say which one, or check `status` first.":"Say which job — by its label. Call `status` with no job named to see them.";if("open"===t){if(!(f?p:await h()).some(e=>e.id===y.id))return`"${y.label}" is older than the call screen keeps; it is under Settings › Threads.`;let{appEvents:t}=await e.A(522275);return t.emit({type:"showThread",threadId:y.id}),{label:y.label,open:!0}}if("seen"===t)return await d([y.id]),{label:y.label,seen:!0};let{answerThread:S,cancelThread:O}=await e.A(994193);if("cancel"===t)return await O(y.id),{label:y.label,status:"cancelled"};if(!a?.trim())return"Say what to pass on.";try{l=await S(y.id,a.trim(),"thursday",r??void 0,s??void 0)}catch(e){if((0,T.isPublicError)(e))return e.message;throw e}return l?.answered?{label:y.label,answered:l.answered,note:`${l.answered.bot} has the answer to its question and goes on from it.`}:{label:y.label,bot:l?.to??y.bot,status:"running",note:"running"===y.status?"The bot reads it before its next step.":"The bot picks the job back up from there."}}})}),...l.CALL_TOOLS}}let E=await (0,p.loadSkills)(k);return{[m.TOOL_NAMES.memory_recall]:S[m.TOOL_NAMES.memory_recall],...O,...await (0,h.createSearchTool)(t.model,k),...(0,f.createWorkspaceTools)(k,{write:!0,env:{...(0,y.jobShellEnv)(t.session),...(0,y.botShellEnv)(t.bot)},guide:!0,bot:t.bot}),...await (0,c.createMcpTools)(t.bot,k),...(0,d.createSkillTools)({sandbox:k,skills:E})}}[c,u,h,g]=k.then?(await k)():k,e.s(["loadTools",0,E]),n()}catch(e){n(e)}},!1),54282,e=>{"use strict";var t=e.i(343747),n=e.i(983477),a=e.i(687388),i=e.i(353885),r=e.i(704161),o=e.i(640911),s=e.i(388439);let l=(e=new Date)=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} ${Intl.DateTimeFormat().resolvedOptions().timeZone}`;i.STUDIO_TOOLS.generate_image,i.STUDIO_TOOLS.generate_speech,i.STUDIO_TOOLS.transcribe,i.STUDIO_TOOLS.generate_video,e.s(["callStamp",0,e=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} (${(0,n.formatDistanceToNowStrict)(e,{addSuffix:!0})})`,"clockNow",0,l,"conversationLines",0,e=>e.map(e=>"tool"===e.role?`you → ${e.tool??"tool"}`:`${"user"===e.role?"user":"you"}: ${e.text}`).join("\n"),"logPromptSize",0,function(e,t){let n=(0,s.sectionTokens)(t),i=n.reduce((e,t)=>e+t.tokens,0);o.logger.debug(`${e} prompt ${i} tokens — ${n.map(e=>`${e.name} ${e.tokens}`).join(", ")}`);let r=n[0];i>a.PROMPT_BUDGET&&r&&o.logger.warn(`${e} prompt is ${i} tokens, over ${a.PROMPT_BUDGET}: ${r.name} carries ${r.tokens} of it. Every call and every job pays this.`)},"mcpToolLines",0,function(e){let t=new Map;for(let n of e){let e=t.get(n.server);e?e.push(n.name):t.set(n.server,[n.name])}return[...t].map(([e,t])=>`- **${e}**: ${t.join(", ")}`).join("\n")},"noteLines",0,function(e,t=!1){return e.length?e.map(e=>{var n;let a,i=e.aliases?.length?` ${e.aliases.map(e=>`"${e}"`).join(" ")}`:"",o=t?` \xb7 ${n=e.lastSeenAt,(a=Math.floor((Date.now()-(0,r.toDate)(n).getTime())/864e5))>=365?`${Math.floor(a/365)}y`:a>=30?`${Math.floor(a/30)}mo`:`${Math.max(a,0)}d`}`:"";return`- ${e.path} — ${e.description?.trim()} (${e.factCount})${i}${o}`}).join("\n"):"(nothing saved yet)"},"nowLine",0,(e=new Date)=>`**Now**: ${l(e)}`,"saidStamp",0,e=>(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm"),"skillLines",0,(e,t={})=>e.map(e=>{var n;let i,r;return`- **${e.name}**: ${t.short?(n=e.description,i=a.PROMPT_LINE.skill,(r=n.trim().split(/(?<=[.。])\s|\n/)[0].trim()).length>i?`${r.slice(0,i).trim()}…`:r):e.description}`}).join("\n")])},316172,e=>{"use strict";var t=e.i(907855),n=e.i(687388),a=e.i(353885),i=e.i(944971),r=e.i(889034);let o={name:a.TOOL_NAMES.delegate,description:"Hand a job to a bot. Returns a receipt at once; the job runs in the background and its updates reach the conversation on their own.",parameters:t.object({bot:t.string().describe("A name from the bot list."),request:t.string().describe("The whole job. The bot cannot hear the call, so everything it needs goes here — names, paths, what the user actually asked for — in their own language and their own words: it is the only language the bot has, and whatever it writes comes back to them. **Their request, never your reading of it**: a condition, a caution or a smaller goal they did not say is how a job comes back as the wrong thing. When their words leave a real choice open, ask them on the call and put the answer here."),label:t.string().describe("Two or three words naming the job, in the user's language. Used on screen and said out loud.")})},s={description:"Send a message to a participant or Thursday and receive a delivery receipt immediately. Mark a question for Thursday to request user input; ordinary messages to Thursday are notifications and need no answer.",parameters:r.RoomMessageSchema.extend({kind:r.RoomMessageSchema.shape.kind.describe("Use question only when Thursday must obtain an answer from the user: it ends your turn, and you continue when the answer arrives. Use message for bot collaboration, progress updates and reports."),options:r.RoomMessageSchema.shape.options.describe("With a question, offer concise answer choices when useful. Omit for an open-ended question; the user can always type their own answer."),to:t.string().trim().min(1).describe("Choose a bot from the roster, or Thursday to reach the user."),text:t.string().trim().min(1).describe("Write the message and include the context the recipient needs."),replyTo:t.string().nullish().describe("Use an incoming message ID to send an explicit reply; omit to start a new exchange. Your ordinary final text already replies to your current correspondent.")})},l={name:a.TOOL_NAMES.thread,description:`List up to ${n.THREAD_STATUS_LIMIT} jobs, prioritizing running and waiting work before recent endings; inspect one job, answer it, cancel it, open it on the user's screen, or mark it seen — the same as the user opening it, which takes it off the work waiting on them.`,parameters:t.object({action:t.enum(["status","answer","cancel","open","seen"]),recipient:t.string().nullish().describe("With answer, name the participant to receive it. Words to a participant waiting on its question answer that question; omit to reach the only open question, or the coordinator when none is open."),replyTo:t.string().nullish().describe("With answer, use the message ID of the question being answered when several questions are open."),thread:t.string().nullish().describe(`Identify the job by label or ID. With status, omit or use null to list up to ${n.THREAD_STATUS_LIMIT} jobs, prioritizing open work and filling remaining places with recent endings; name one to read its full result and pending questions. With open, omit to show the job that moved last. With answer, omit only to answer the one question waiting.`),answer:t.string().nullish().describe(`With \`answer\`: what to tell the bot — the answer to its question, a course correction for a job still running, or what to do next on one that finished. \`${i.THREAD_CONTINUE}\` carries on a job that stopped before finishing, from where it was.`)})};e.s(["delegateSpec",0,o,"sendMessageSpec",0,s,"threadSpec",0,l])},349047,e=>{"use strict";var t=e.i(847841),n=e.i(907855),a=e.i(353885);let i={name:a.TOOL_NAMES.end_call,description:`End the call.
|
|
2
|
+
|
|
3
|
+
The line stays open until this runs, and drops once the goodbye being said is over.`,parameters:n.object({})},r=(0,t.tool)({description:i.description,inputSchema:i.parameters}),o={[a.TOOL_NAMES.end_call]:r};e.s(["CALL_TOOLS",0,o])},926435,e=>e.a(async(t,n)=>{try{var a=e.i(847841),i=e.i(907855),r=e.i(353885),o=e.i(148831),s=e.i(786025),l=e.i(660948),c=t([o,l]);[o,l]=c.then?(await c)():c;let d={[r.TOOL_NAMES.tool_search]:{name:r.TOOL_NAMES.tool_search,description:`Return the description and exact inputSchema of tools on a connected server, so they can be called with \`${r.TOOL_NAMES.tool_call}\`.`,parameters:i.object({server:i.string().describe("A server name, exactly as the Connected tools section writes it."),tools:i.string().array().describe("Tool names listed under that server. Only the ones you may actually call — schemas are large, and at most 8 come back.")})},[r.TOOL_NAMES.tool_call]:{name:r.TOOL_NAMES.tool_call,description:`Run one tool whose definition came back from \`${r.TOOL_NAMES.tool_search}\`.`,parameters:i.object({server:i.string().describe("The server the tool lives on."),tool:i.string().describe("Its name, as search returned it."),args:i.record(i.string(),i.unknown()).nullish().describe("Arguments matching the inputSchema search returned — do not guess. Null when it takes none."),description:i.string().nullish().describe("One short line for the user: what this call is for. Shown on their screen while it runs.")})}},m=(e,t)=>`${e.replace(/[^a-zA-Z0-9]+/g,"_")}__${t.replace(/[^a-zA-Z0-9_-]+/g,"_")}`.slice(0,64);async function u(e,t){let[n,i]=await Promise.all([(0,l.listConnectedToolNames)(),(0,o.findPinnedTools)(e)]),r={},c=(0,s.botArtifacts)(e);for(let e of i){let n=m(e.server,e.name);r[n]||(r[n]=(0,a.tool)({description:e.description??`${e.name} on the ${e.server} server.`,inputSchema:(0,a.jsonSchema)(e.inputSchema??{type:"object",properties:{}}),execute:(n,{abortSignal:a})=>(0,l.callConnectedTool)(t,e.server,e.name,n??void 0,{artifacts:c,abortSignal:a})}))}return n.length>i.length&&Object.assign(r,f(t,c)),r}async function h(e){let t=(await (0,l.listConnectedToolNames)(e)).map(e=>e.name);if(t.length)return`Tools on "${e}": ${t.join(", ")}.`;let n=await (0,l.listConnectedServerNames)();return n.length?`There is no server called "${e}". Connected: ${n.join(", ")}.`:"Nothing is connected."}let f=(e,t)=>({[r.TOOL_NAMES.tool_search]:(0,a.tool)({description:d[r.TOOL_NAMES.tool_search].description,inputSchema:d[r.TOOL_NAMES.tool_search].parameters,execute:async({server:e,tools:t})=>{let n=[...new Set(t.map(e=>e.trim()).filter(Boolean))],a=n.slice(0,8),i=await (0,l.findConnectedSchemas)(e.trim(),a);if(!i.length)return{tools:[],note:await h(e)};let r=a.filter(e=>!i.some(t=>t.name===e)),o=n.slice(8),s=[r.length?`Not on "${e}": ${r.join(", ")}.`:"",o.length?`Only 8 at a time — ask again for: ${o.join(", ")}.`:""].filter(Boolean);return{tools:i,...s.length?{note:s.join(" ")}:{}}}}),[r.TOOL_NAMES.tool_call]:(0,a.tool)({description:d[r.TOOL_NAMES.tool_call].description,inputSchema:d[r.TOOL_NAMES.tool_call].parameters,execute:async({server:n,tool:a,args:i},{abortSignal:r})=>(await (0,l.listConnectedToolNames)(n.trim())).some(e=>e.name===a.trim())?(0,l.callConnectedTool)(e,n.trim(),a.trim(),i??void 0,{artifacts:t,abortSignal:r}):{status:"error",text:await h(n)}})});e.s(["createMcpTools",0,u]),n()}catch(e){n(e)}},!1),770639,e=>e.a(async(t,n)=>{try{var a=e.i(847841),i=e.i(907855),r=e.i(687388),o=e.i(54282),s=e.i(353885),l=e.i(619898),c=e.i(453569),u=e.i(22676),h=t([l,u]);[l,u]=h.then?(await h)():h;let d=c.MEMORY_PATHS.map(e=>e.path.endsWith("/")?`${e.path}<name>`:e.path).join(", "),m=e=>({...e,facts:e.facts.map(({saidAt:e,...t})=>e?{...t,said:(0,o.saidStamp)(e)}:t),factCount:e.facts.length}),f=e=>"user"===e?"Typed on the screen — there is no conversation behind it.":"bot"===e?"Saved by a bot during a job — there is no conversation behind it.":"The conversation it was saved in is not kept.",w=e=>e>r.MEMORY_LIMITS.factsPerNote?` This note now holds ${e} facts, past the ${r.MEMORY_LIMITS.factsPerNote} one note holds well. Ask the user which of it is no longer true and delete what they name.`:"";e.s(["createMemoryTools",0,(e,t=null,{countReads:n=!0}={})=>({[s.TOOL_NAMES.memory_recall]:(0,a.tool)({description:"Open one note from the listing, whole.",inputSchema:i.object({path:i.string().describe("Exactly as the listing writes it — the path, or one of the names in quotes after it.")}),execute:async({path:e})=>{let{notes:t}=await (0,l.readNotes)([e],{touch:n}),a=t[0];if(!a)return{note:`Nothing on the listing called ${e.trim()}.`};let i=w(a.facts.length);return i?{...m(a),note:i.trim()}:m(a)}}),[s.TOOL_NAMES.memory_remember]:(0,a.tool)({description:"Write to one note: facts, and the line the listing shows for it. The path is the key — a path not on the listing is created (with at least one fact), one that is gets amended.",inputSchema:i.object({path:i.string().describe("The group this note is found by — the person, project or topic its facts are about. Exactly as the listing writes it, or a new path following the same convention. A fact goes under the one note it is about; other notes name it rather than repeat it."),facts:i.object({text:i.string().describe('One statement that stands on its own later — a date as a date, never "next week".'),replaces:i.number().int().nullish().describe(`The id of the fact this replaces — from this note as handed back here or by \`${s.TOOL_NAMES.memory_recall}\`. Null if this is new. A fact that stopped being true is replaced rather than deleted, and so is a note saying the same thing twice: replacing keeps what changed on the record, deleting does not.`),alwaysLoad:i.boolean().nullish().describe(`True carries this line into every call's instructions without opening its note — for what every call needs before any note is opened: what to call them, their language and register. At most ${r.MEMORY_LIMITS.carried}. Null leaves it; false makes a carried line an ordinary fact.`)}).array().nullish().describe("What to write under this note. Send everything that came up at once: one call is one pause in the conversation, three calls are three. Null when only naming it."),description:i.string().nullish().describe(`One line saying what this note holds, so the listing alone tells which facts are inside. Give it for a new note, and again with new facts: rewritten from the current line and the new facts together, so it covers the whole note rather than only what was added. Null leaves it; ${c.MEMORY_ALWAYS_LISTED.join(", ")} keep their own line.`),aliases:i.string().array().nullish().describe('What the user calls this note out loud, in the language they say it — the words they would use to ask for it, not the facts inside. A note at people/partner might be "my partner" and their first name. Replaces the set it has, so send the whole set. Null leaves it.')}),execute:async n=>{let a=n.path.trim(),i=await (0,l.resolveNotePath)(a),o=n.aliases??null,s=i??a,u=(0,c.isAlwaysListed)(s)?(0,c.appNoteLine)(s):n.description?.trim()||null,h=n.facts??[];if(!h.length&&!u&&!o)return{note:"Nothing to write: send facts, a line, names, or any of them."};if(!i&&!(0,c.isMemoryPath)(a))return{note:`Nothing was saved: "${a}" is not a path this listing can carry. Write it again under one of ${d}.`};if(!i&&!h.length)return{note:`Nothing on the listing called ${a}. A note comes into being with a fact — send at least one.`};let f=await (0,l.writeNotes)([{path:s,description:u,aliases:o,facts:h}],e,t),p=f.unnamed.length?` ${f.unnamed[0]} is new and has no line yet — the listing shows its first fact instead. Call again with \`description\` (one line about what it is) and \`aliases\` (the names they say for it).`:"",g=f.notLoaded.length?` All ${r.MEMORY_LIMITS.carried} carried lines are taken, so ${f.notLoaded.map(e=>`"${e}"`).join(", ")} saved as an ordinary fact. Say which carried line you would drop for it and let them choose.`:"",y=m(f.notes[0]),b=i&&h.length&&!u?` Its line still reads "${y.description}"; if that no longer says what the note holds, send \`description\`.`:"";return{...y,note:`Saved. The listing in your instructions is from when this session opened and will not show this until the next one — the note below is current.${p}${g}${b}${w(y.factCount)}`}}}),[s.TOOL_NAMES.memory_conversation]:(0,a.tool)({description:"Open the conversation a fact was saved in, whole: what each side said, and which tools were used.",inputSchema:i.object({factId:i.number().int().describe("The id that came with the fact when its note was opened."),page:i.number().int().min(1).nullish().describe(`${r.MEMORY_CONVERSATION_PAGE} turns a page, oldest first. Null for the first.`)}),execute:async({factId:e,page:n})=>{let a=await (0,l.findFactCall)(e);if(!a)return{note:`No fact with id ${e}.`};if(!a.callId)return{note:f(a.source)};if(a.callId===t)return{note:"Said in this call — it is the conversation you are in."};let i=n??1,s=await (0,u.readCallConversation)(a.callId,i,r.MEMORY_CONVERSATION_PAGE);if(!s)return{note:f(a.source)};let c=Math.max(1,Math.ceil(s.total/r.MEMORY_CONVERSATION_PAGE));return i>c?{note:`That conversation has ${c} page${c>1?"s":""}.`}:{when:(0,o.callStamp)(s.startedAt),page:i,pages:c,conversation:(0,o.conversationLines)(s.turns)}}}),[s.TOOL_NAMES.memory_forget]:(0,a.tool)({description:"Delete facts for good.",inputSchema:i.object({factIds:i.number().int().array().min(1).describe("The ids that came with the facts when their notes were opened — every one to delete, in one call.")}),execute:async({factIds:e})=>{let t=[],n=[],a=new Set;for(let i of new Set(e)){let e=await (0,l.forgetFactById)(i);if(!e){t.push(i);continue}e.noteGone?(a.delete(e.path),n.push(e.path)):a.add(e.path)}if(!n.length&&!a.size)return{note:`No fact with id ${t.join(", ")}. Nothing was deleted.`};let i=["Deleted for good. The listing in your instructions is from when this session opened and still shows it that way until the next one.",1===n.length?`That was the last fact under ${n[0]}, so the note went with it.`:n.length?`That was the last of ${n.join(", ")}, so those notes went with them.`:"",t.length?`No fact with id ${t.join(", ")}, so those were skipped.`:""].filter(Boolean).join(" ");if(!a.size)return{note:i};let{notes:r}=await (0,l.readNotes)([...a],{touch:!1});return{notes:r.map(m),note:i}}})})]),n()}catch(e){n(e)}},!1),489956,e=>e.a(async(t,n)=>{try{var a=e.i(68356),i=e.i(847841),r=e.i(105249),o=e.i(687388),s=e.i(353885),l=e.i(279041),c=e.i(340698),u=e.i(41444),h=t([c]);[c]=h.then?(await h)():h;let f=`Answer the question from the web. Lead with the answer, then
|
|
4
|
+
what supports it. Say plainly what you could not find or confirm — do not fill
|
|
5
|
+
the gap with a guess. Every number carries the date you saw it. Be brief: this
|
|
6
|
+
is read by another model, not by a person.`,w=r.default.string().describe("What you want to know, as one full question. Put the place and the time in when they matter — the searcher sees nothing but this line.");async function d(e,t,n){let a=await fetch("https://api.exa.ai/search",{method:"POST",signal:n,headers:{"content-type":"application/json","x-api-key":e},body:JSON.stringify({query:t,type:"auto",numResults:o.SEARCH.sources,contents:{text:{maxCharacters:o.SEARCH.excerptChars},livecrawl:"fallback",livecrawlTimeout:5e3}})});if(!a.ok)return`Exa answered ${a.status}: ${(0,u.clip)((await a.text()).trim(),200)}`;let i=(await a.json()).results??[];return i.length?i.map(e=>{let t=[e.title?.trim(),e.url?.trim()].filter(Boolean).join(" — "),n=e.publishedDate?.slice(0,10);return[n?`${t} \xb7 ${n}`:t,e.text?.trim()].filter(Boolean).join("\n")}).join("\n\n"):"Nothing came back for that. Try other words, or open a page in the browser."}async function m(e,t,n){let{text:i,sources:r}=await (0,a.generateText)({model:e.model,tools:e.tools,system:f,prompt:t,abortSignal:n}),s=[...new Set(r.flatMap(e=>"url"===e.sourceType?[e.title?`${e.title} — ${e.url}`:e.url]:[]))].slice(0,o.SEARCH.sources);return[i.trim(),s.length?`Sources:
|
|
7
|
+
${s.join("\n")}`:""].filter(Boolean).join("\n\n")}let p=async(e,t)=>{let n=await (0,c.readConfig)(l.EXA_API_KEY),a=e?.searchTools?{model:e.model,tools:e.searchTools}:null,h=n?(e,t)=>d(n,e,t):a?(e,t)=>m(a,e,t):null;return h?{[s.TOOL_NAMES.web_search]:(0,i.tool)({description:"Search the web and get back what the pages say, with their links. For a fact, a price, a date, what a page says. Not for a page that has to be clicked, filled, or signed into — that is the browser.",inputSchema:r.default.object({query:w}),execute:async({query:e},{abortSignal:n})=>{let a=AbortSignal.timeout(o.SEARCH.timeoutMs),i=n?AbortSignal.any([n,a]):a,r=await h(e,i).catch(e=>{if(n?.aborted)throw e;return a.aborted?`The search did not come back in ${o.SEARCH.timeoutMs/1e3}s. Ask something narrower, or open the page in the browser.`:`Search failed: ${(0,u.errorToString)(e)}. The browser is the other way in.`});return t.fold(r,"web-search")}})}:{}};e.s(["createSearchTool",0,p]),n()}catch(e){n(e)}},!1),41181,e=>{"use strict";var t=e.i(847841),n=e.i(105249),a=e.i(353885),i=e.i(636882),r=e.i(696968);e.s(["createSkillTools",0,({skills:e,sandbox:o})=>({[a.TOOL_NAMES.load_skill]:(0,t.tool)({description:"Load one skill: its instructions, and the files that ship with it.",inputSchema:n.default.object({name:n.default.string().describe("Exact name from the Skills list, or of a skill installed during this job. Do not guess names.")}),execute:async({name:t},{messages:n})=>{let s=e=>e.find(e=>e.name.toLowerCase()===t.toLowerCase()),l=s(e)?e:await (0,i.loadSkills)(o),c=s(l);if(!c)return{error:`No skill named '${t}'.`,available:l.map(e=>e.name)};let u=`${c.path}/SKILL.md`;if(n.some(e=>Array.isArray(e.content)&&e.content.some(e=>{if("tool-result"!==e.type||e.toolName!==a.TOOL_NAMES.load_skill||"json"!==e.output.type)return!1;let t=e.output.value;return t?.skillDirectory===c.path&&"string"==typeof t.content})))return{skillDirectory:c.path,note:`Use the full '${c.name}' instructions already in your conversation. To check for changes on disk, read ${u} with the shell.`};let h=await o.readFile(u,"utf-8"),{body:d}=(0,r.splitFrontmatter)(h),m=await o.glob("**/*",{path:c.path,limit:50});return{skillDirectory:c.path,files:m,content:d}}})})])},741376,e=>e.a(async(t,n)=>{try{var a=e.i(912714),i=e.i(750227),r=e.i(68356),o=e.i(343747),s=e.i(105249),l=e.i(386075),c=e.i(353885),u=e.i(640911),h=e.i(41444),d=t([l]);function m(e){return{...e,execute:(t,n)=>{let a=e.inputSchema.safeParse(t);if(!a.success)throw Error(s.default.prettifyError(a.error));return e.execute(a.data,n)}}}function f(e,t){let n=e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,40),a=(0,o.format)(new Date,"yyyyMMdd-HHmmss");return`${a}${n?`-${n}`:""}.${t}`}async function w(e,t,n,a){let i=`${t}/${n}`;return await e.exec(`mkdir -p ${t}`),await e.writeFile(i,Buffer.from(a)),i}[l]=d.then?(await d)():d;let y=e=>`${e}
|
|
8
|
+
Saved. Give the user this path — the file opens from the thread row. Do not describe it back to them; they can open it.`,b=(e,t)=>e?.split("/")[1]?.split(";")[0]||t,S=["1:1","16:9","9:16","4:3","3:4"],T=async()=>{let e=await (0,l.resolveMediaRef)("image");if(!e)return null;let t=(0,l.buildImageModel)(e.ref,e.apiKey);return m({name:c.STUDIO_TOOLS.generate_image,description:"Draw an image and save it as a file in the workspace. What comes back is its path.",inputSchema:s.default.object({prompt:s.default.string().describe("What to draw, described: subject, style, mood, what is in frame. The image model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:s.default.enum(S).nullish().describe("Aspect ratio. Null for square.")}),execute:async({prompt:e,aspectRatio:n},{sandbox:a,artifacts:i,abortSignal:o})=>{let{image:s}=await (0,r.generateImage)({model:t,prompt:e,aspectRatio:n??"1:1",abortSignal:o}),l=await w(a,i,f(e,b(s.mediaType,"png")),s.uint8Array);return y(l)}})},O=async()=>{let e=await (0,l.resolveMediaRef)("speech");if(!e)return null;let t=(0,l.buildSpeechModel)(e.ref,e.apiKey);return m({name:c.STUDIO_TOOLS.generate_speech,description:"Read text aloud into an audio file in the workspace — something the user listens to or sends, not Thursday's voice. What comes back is its path.",inputSchema:s.default.object({text:s.default.string().min(1).max(4e3).describe("The words to read, up to 4000 characters. Longer pieces are read in parts, one call each."),voice:s.default.string().nullish().describe("A voice name the provider knows. Null for its default."),instructions:s.default.string().nullish().describe('How to read it — "slowly", "warm", "like a news anchor". Null for plain.')}),execute:async({text:e,voice:n,instructions:a},{sandbox:i,artifacts:o,abortSignal:s})=>{let{audio:l}=await (0,r.generateSpeech)({model:t,text:e,voice:n??void 0,instructions:a??void 0,outputFormat:"mp3",abortSignal:s}),c=await w(i,o,f(e.slice(0,60),l.format||"mp3"),l.uint8Array);return y(c)}})},v=async()=>{let e=await (0,l.resolveMediaRef)("transcription");if(!e)return null;let t=(0,l.buildTranscriptionModel)(e.ref,e.apiKey);return m({name:c.STUDIO_TOOLS.transcribe,description:"Turn an audio file — a recording, a voice memo, a meeting — into text. The transcript is saved as a file in the workspace; what comes back is its path and the text.",inputSchema:s.default.object({path:s.default.string().min(1).describe("The audio file: a path relative to the workspace, or an absolute one anywhere on this machine.")}),execute:async({path:e},{sandbox:n,artifacts:o,abortSignal:s})=>{let l=await (0,a.readFile)(n.resolve(e)),c=await (0,r.transcribe)({model:t,audio:l,abortSignal:s}),u=c.segments.length?`
|
|
9
|
+
|
|
10
|
+
## Timeline
|
|
11
|
+
|
|
12
|
+
${c.segments.map(e=>{var t;let n,a;return`- ${t=e.startSecond,n=Math.floor(t/60),a=Math.floor(t%60),`${n}:${String(a).padStart(2,"0")}`} ${e.text.trim()}`}).join("\n")}`:"",h=(0,i.basename)(e,(0,i.extname)(e)),d=await w(n,o,f(h,"md"),Buffer.from(`# ${h}
|
|
13
|
+
|
|
14
|
+
${c.text.trim()}${u}
|
|
15
|
+
`));return`${d}
|
|
16
|
+
|
|
17
|
+
${await n.fold(c.text,"transcript")}`}})},k=async()=>{let e=await (0,l.resolveMediaRef)("video");if(!e)return null;let t=(0,l.buildVideoModel)(e.ref,e.apiKey);return m({name:c.STUDIO_TOOLS.generate_video,description:"Make a short video and save it as a file in the workspace. Takes minutes. What comes back is its path.",inputSchema:s.default.object({prompt:s.default.string().describe("What happens: the scene, the motion, the camera, the mood. The video model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:s.default.enum(["16:9","9:16"]).nullish().describe("Aspect ratio. Null for 16:9."),seconds:s.default.number().int().min(2).max(10).nullish().describe("Length in seconds, 2 to 10. Null for the provider's default.")}),execute:async({prompt:e,aspectRatio:n,seconds:a},{sandbox:i,artifacts:o,abortSignal:s})=>{let{video:l}=await (0,r.experimental_generateVideo)({model:t,prompt:e,aspectRatio:n??"16:9",duration:a??void 0,abortSignal:s}),c=await w(i,o,f(e,b(l.mediaType,"mp4")),l.uint8Array);return y(c)}})};async function p(){return(await Promise.all([g(T),g(O),g(v),g(k)])).filter(e=>null!==e)}async function g(e){try{return await e()}catch(e){return u.logger.warn(`studio: a tool could not be built — ${(0,h.errorToString)(e)}`),null}}e.s(["loadStudio",0,p]),n()}catch(e){n(e)}},!1),660948,e=>e.a(async(t,n)=>{try{var a=e.i(105249),i=e.i(687388),r=e.i(105303),o=e.i(148831),s=e.i(41444),l=e.i(741376),c=t([r,o,l]);async function u(e){let[t,n]=await Promise.all([!e||e===i.STUDIO_SERVER?(0,l.loadStudio)():[],e===i.STUDIO_SERVER?[]:(0,o.listToolNames)(e)]);return[...t.map(e=>({server:i.STUDIO_SERVER,name:e.name})),...n]}[r,o,l]=c.then?(await c)():c;let w=async()=>{let[e,t]=await Promise.all([(0,l.loadStudio)(),(0,o.listServerNames)()]);return[...e.length?[i.STUDIO_SERVER]:[],...t.map(e=>e.name)]};async function h(e,t){if(e===i.STUDIO_SERVER){let e=new Set(t);return(await (0,l.loadStudio)()).filter(t=>e.has(t.name)).map(e=>({name:e.name,description:e.description,inputSchema:a.default.toJSONSchema(e.inputSchema)}))}return(await (0,o.findToolSchemas)(e,t)).map(e=>({name:e.name,description:e.description??null,inputSchema:e.inputSchema??null}))}async function d(e,t,n,a,{artifacts:o,abortSignal:l}){let c=AbortSignal.timeout(i.CONNECTED_TOOL_TIMEOUT_MS),u=l?AbortSignal.any([l,c]):c;try{let r=t===i.STUDIO_SERVER?await m(e,n,a,o,u):await f(t,n,a,u);if("string"!=typeof r)return r;return{status:"ok",text:await e.fold(r,`${t}-${n}`)}}catch(e){if(e instanceof r.McpAuthRequiredError)return{status:"auth_required",server:t,authorizationUrl:e.authorizationUrl};if(c.aborted&&!l?.aborted)return{status:"error",text:`${n} on ${t} gave no answer in ${i.CONNECTED_TOOL_TIMEOUT_MS/6e4} minutes and was given up on.`};return{status:"error",text:(0,s.errorToString)(e)}}}async function m(e,t,n,a,r){let o=(await (0,l.loadStudio)()).find(e=>e.name===t);if(!o)throw Error(`"${t}" is not in the ${i.STUDIO_SERVER} right now — the key that runs it is gone.`);return o.execute(n??{},{sandbox:e,artifacts:a,abortSignal:r})}async function f(e,t,n,a){let i=function(e){let t=e??{},n=!0===t.isError;if(!Array.isArray(t.content)){let e=void 0===t.toolResult?"":"string"==typeof t.toolResult?t.toolResult:JSON.stringify(t.toolResult);return{status:n?"error":"ok",text:e||p(n)}}let a=t.content.map(e=>"text"===e.type&&"string"==typeof e.text?e.text:`[${e.type}${e.mimeType?` ${e.mimeType}`:""} — not shown]`).join("\n").trim();return{status:n?"error":"ok",text:a||p(n)}}(await r.mcpManager.callTool(e,t,n,a));return"ok"===i.status?i.text:i}let p=e=>e?"The tool failed without a message.":"Done.";e.s(["callConnectedTool",0,d,"findConnectedSchemas",0,h,"listConnectedServerNames",0,w,"listConnectedToolNames",0,u]),n()}catch(e){n(e)}},!1),123203,e=>{"use strict";var t=e.i(750227),n=e.i(847841),a=e.i(105249),i=e.i(687388),r=e.i(353885),o=e.i(393189),s=e.i(786025);let l=`## The shell here
|
|
18
|
+
|
|
19
|
+
Every command is a new shell: \`cd\`, exported variables and an activated venv are gone by the next one — chain what depends on the last step into a single command.
|
|
20
|
+
|
|
21
|
+
Nothing is watching it. A command that stops to ask never gets an answer and is killed after ${i.EXEC_TIMEOUT_MS/1e3}s, so pass the flag that skips the question (\`-y\`, \`--yes\`, \`--no-input\`), and send anything genuinely long to the background with its output redirected to a file.
|
|
22
|
+
|
|
23
|
+
Keys are not in the environment: every variable named like a key, a token or a secret is removed before the shell starts. An empty one is not an unset one — say which it was, and ask for what a command needs.`;e.s(["createWorkspaceTools",0,(e,i)=>{let c=!0===i.guide,u=async e=>{let t=i.bot;if(!t)return{result:await e(),memory:null};let n=await (0,o.holdBotMemory)(t);return{result:await e(),memory:await (0,o.keepBotMemory)(t,n)}},h=(0,n.tool)({description:"Run a bash command.",inputSchema:a.default.object({command:a.default.string(),description:a.default.string().nullish().describe("One short line for the user: what this command does and why. Shown on their screen while it runs — not a restatement of the command.")}),execute:async({command:t},{abortSignal:n})=>{let{result:a,memory:r}=await u(()=>e.exec(t,{signal:n,env:i.env,timeoutMs:i.timeoutMs})),o=r?{...a,memory:r}:a;return c?(c=!1,{...o,guide:l}):o}});if(!i.write)return{[r.TOOL_NAMES.bash]:h};let d=(0,n.tool)({description:"Write a whole file — what was there is gone. Parent directories are created.",inputSchema:a.default.object({path:a.default.string().describe("Relative to the working directory — under one of its folders — or absolute"),content:a.default.string(),description:a.default.string().nullish().describe("One short line for the user: what this file is. Shown on their screen next to the path.")}),execute:async({path:n,content:a})=>{let r,o=e.resolve(n),l=(0,s.writeRefusal)(o,i.bot);if(l)return l;let{memory:c}=await u(()=>e.writeFile(n,a));return c??`Wrote ${(r=(0,t.relative)(e.cwd,o))&&!r.startsWith("..")?r:o} (${a.split("\n").length} lines)`}});return{[r.TOOL_NAMES.bash]:h,[r.TOOL_NAMES.write_file]:d}}])},636882,e=>{"use strict";var t=e.i(750227),n=e.i(687388),a=e.i(640911),i=e.i(41444),r=e.i(696968);let o=[(0,t.join)(n.APP_DIR,n.PATHS.skills.default),(0,t.join)(n.DATA_DIR,n.PATHS.skills.custom)];async function s(e,t){let n=[],o=new Set;for(let s of t){let t;try{t=await e.readdir(s,{withFileTypes:!0})}catch{continue}for(let l of t){let t,c;if(!l.isDirectory())continue;let u=`${s}/${l.name}`,h=`${u}/SKILL.md`;try{t=await e.readFile(h,"utf-8")}catch{continue}try{c=(0,r.parseFrontmatter)(t)}catch(e){a.logger.warn(`skill ${u}: SKILL.md front matter did not load — ${(0,i.errorToString)(e)}`);continue}!o.has(c.name)&&(o.add(c.name),c.disabled||n.push({name:c.name,description:c.description,path:u}))}}return n}e.s(["loadSkills",0,e=>s(e,o)])},388439,e=>{"use strict";let t=/[\u1100-\u11ff\u3040-\u30ff\u3130-\u318f\u4e00-\u9fff\uac00-\ud7af]/;function n(e){let n=0,a=0;for(let i of e)t.test(i)?n+=1:a+=1;return Math.ceil(n/1.3+a/4)}e.s(["estimateTokens",0,n,"sectionTokens",0,function(e){return e.split(/\n(?=## )/).map(e=>({name:e.startsWith("## ")?e.slice(3,e.indexOf("\n")):"identity",tokens:n(e)})).sort((e,t)=>t.tokens-e.tokens)}])},343747,e=>{"use strict";var t=e.i(881237),n=e.i(662001),a=e.i(89929),i=e.i(277988),r=e.i(438220),o=e.i(609730);function s(e,t){let n=(0,o.toDate)(e,t?.in);return n.setHours(0,0,0,0),n}function l(e,t){let a=(0,n.getDefaultOptions)(),i=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,r=(0,o.toDate)(e,t?.in),s=r.getDay();return r.setDate(r.getDate()-(7*(s<i)+s-i)),r.setHours(0,0,0,0),r}function c(e,t){return l(e,{...t,weekStartsOn:1})}var u=e.i(874321);function h(e,t){let n=(0,o.toDate)(e,t?.in),a=n.getFullYear(),i=(0,u.constructFrom)(n,0);i.setFullYear(a+1,0,4),i.setHours(0,0,0,0);let r=c(i),s=(0,u.constructFrom)(n,0);s.setFullYear(a,0,4),s.setHours(0,0,0,0);let l=c(s);return n.getTime()>=r.getTime()?a+1:n.getTime()>=l.getTime()?a:a-1}function d(e,t){let a=(0,o.toDate)(e,t?.in),i=a.getFullYear(),r=(0,n.getDefaultOptions)(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,c=(0,u.constructFrom)(t?.in||e,0);c.setFullYear(i+1,0,s),c.setHours(0,0,0,0);let h=l(c,t),d=(0,u.constructFrom)(t?.in||e,0);d.setFullYear(i,0,s),d.setHours(0,0,0,0);let m=l(d,t);return+a>=+h?i+1:+a>=+m?i:i-1}function m(e,t){let n=Math.abs(e).toString().padStart(t,"0");return(e<0?"-":"")+n}let f={y(e,t){let n=e.getFullYear(),a=n>0?n:1-n;return m("yy"===t?a%100:a,t.length)},M(e,t){let n=e.getMonth();return"M"===t?String(n+1):m(n+1,2)},d:(e,t)=>m(e.getDate(),t.length),a(e,t){let n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return"am"===n?"a.m.":"p.m."}},h:(e,t)=>m(e.getHours()%12||12,t.length),H:(e,t)=>m(e.getHours(),t.length),m:(e,t)=>m(e.getMinutes(),t.length),s:(e,t)=>m(e.getSeconds(),t.length),S(e,t){let n=t.length;return m(Math.trunc(e.getMilliseconds()*Math.pow(10,n-3)),t.length)}},w={G:function(e,t,n){let a=+(e.getFullYear()>0);switch(t){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});default:return n.era(a,{width:"wide"})}},y:function(e,t,n){if("yo"===t){let t=e.getFullYear();return n.ordinalNumber(t>0?t:1-t,{unit:"year"})}return f.y(e,t)},Y:function(e,t,n,a){let i=d(e,a),r=i>0?i:1-i;return"YY"===t?m(r%100,2):"Yo"===t?n.ordinalNumber(r,{unit:"year"}):m(r,t.length)},R:function(e,t){return m(h(e),t.length)},u:function(e,t){return m(e.getFullYear(),t.length)},Q:function(e,t,n){let a=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return m(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(e,t,n){let a=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return m(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(e,t,n){let a=e.getMonth();switch(t){case"M":case"MM":return f.M(e,t);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(e,t,n){let a=e.getMonth();switch(t){case"L":return String(a+1);case"LL":return m(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(e,t,a,i){let s,c,h,f,w,p=Math.round((l(s=(0,o.toDate)(e,i?.in),i)-(c=(0,n.getDefaultOptions)(),h=i?.firstWeekContainsDate??i?.locale?.options?.firstWeekContainsDate??c.firstWeekContainsDate??c.locale?.options?.firstWeekContainsDate??1,f=d(s,i),(w=(0,u.constructFrom)(i?.in||s,0)).setFullYear(f,0,h),w.setHours(0,0,0,0),l(w,i)))/r.millisecondsInWeek)+1;return"wo"===t?a.ordinalNumber(p,{unit:"week"}):m(p,t.length)},I:function(e,t,n){let a,i,s,l=Math.round((c(a=(0,o.toDate)(e,void 0))-(i=h(a,void 0),(s=(0,u.constructFrom)(a,0)).setFullYear(i,0,4),s.setHours(0,0,0,0),c(s)))/r.millisecondsInWeek)+1;return"Io"===t?n.ordinalNumber(l,{unit:"week"}):m(l,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getDate(),{unit:"date"}):f.d(e,t)},D:function(e,t,n){let l,c,u=function(e,t){let[n,o]=(0,i.normalizeDates)(void 0,e,t),l=s(n),c=s(o);return Math.round((l-(0,a.getTimezoneOffsetInMilliseconds)(l)-(c-(0,a.getTimezoneOffsetInMilliseconds)(c)))/r.millisecondsInDay)}(l=(0,o.toDate)(e,void 0),((c=(0,o.toDate)(l,void 0)).setFullYear(c.getFullYear(),0,1),c.setHours(0,0,0,0),c))+1;return"Do"===t?n.ordinalNumber(u,{unit:"dayOfYear"}):m(u,t.length)},E:function(e,t,n){let a=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(e,t,n,a){let i=e.getDay(),r=(i-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(r);case"ee":return m(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,a){let i=e.getDay(),r=(i-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(r);case"cc":return m(r,t.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){let a=e.getDay(),i=0===a?7:a;switch(t){case"i":return String(i);case"ii":return m(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(e,t,n){let a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){let a,i=e.getHours();switch(a=12===i?"noon":0===i?"midnight":i/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){let a,i=e.getHours();switch(a=i>=17?"evening":i>=12?"afternoon":i>=4?"morning":"night",t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return f.h(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getHours(),{unit:"hour"}):f.H(e,t)},K:function(e,t,n){let a=e.getHours()%12;return"Ko"===t?n.ordinalNumber(a,{unit:"hour"}):m(a,t.length)},k:function(e,t,n){let a=e.getHours();return(0===a&&(a=24),"ko"===t)?n.ordinalNumber(a,{unit:"hour"}):m(a,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):f.m(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getSeconds(),{unit:"second"}):f.s(e,t)},S:function(e,t){return f.S(e,t)},X:function(e,t,n){let a=e.getTimezoneOffset();if(0===a)return"Z";switch(t){case"X":return g(a);case"XXXX":case"XX":return y(a);default:return y(a,":")}},x:function(e,t,n){let a=e.getTimezoneOffset();switch(t){case"x":return g(a);case"xxxx":case"xx":return y(a);default:return y(a,":")}},O:function(e,t,n){let a=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+p(a,":");default:return"GMT"+y(a,":")}},z:function(e,t,n){let a=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+p(a,":");default:return"GMT"+y(a,":")}},t:function(e,t,n){return m(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return m(+e,t.length)}};function p(e,t=""){let n=e>0?"-":"+",a=Math.abs(e),i=Math.trunc(a/60),r=a%60;return 0===r?n+String(i):n+String(i)+t+m(r,2)}function g(e,t){return e%60==0?(e>0?"-":"+")+m(Math.abs(e)/60,2):y(e,t)}function y(e,t=""){let n=Math.abs(e);return(e>0?"-":"+")+m(Math.trunc(n/60),2)+t+m(n%60,2)}let b=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},S=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},T={p:S,P:(e,t)=>{let n,a=e.match(/(P+)(p+)?/)||[],i=a[1],r=a[2];if(!r)return b(e,t);switch(i){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",b(i,t)).replace("{{time}}",S(r,t))}},O=/^D+$/,v=/^Y+$/,k=["D","DD","YY","YYYY"],M=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,E=/^'([^]*?)'?$/,_=/''/g,N=/[a-zA-Z]/;e.s(["format",0,function(e,a,i){let r=(0,n.getDefaultOptions)(),s=i?.locale??r.locale??t.defaultLocale,l=i?.firstWeekContainsDate??i?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,c=i?.weekStartsOn??i?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,u=(0,o.toDate)(e,i?.in);if(!(u instanceof Date||"object"==typeof u&&"[object Date]"===Object.prototype.toString.call(u))&&"number"!=typeof u||isNaN(+(0,o.toDate)(u)))throw RangeError("Invalid time value");let h=a.match($).map(e=>{let t=e[0];return"p"===t||"P"===t?(0,T[t])(e,s.formatLong):e}).join("").match(M).map(e=>{if("''"===e)return{isToken:!1,value:"'"};let t=e[0];if("'"===t){var n;let t;return{isToken:!1,value:(t=(n=e).match(E))?t[1].replace(_,"'"):n}}if(w[t])return{isToken:!0,value:e};if(t.match(N))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});s.localize.preprocessor&&(h=s.localize.preprocessor(u,h));let d={firstWeekContainsDate:l,weekStartsOn:c,locale:s};return h.map(t=>{if(!t.isToken)return t.value;let n=t.value;return(!i?.useAdditionalWeekYearTokens&&v.test(n)||!i?.useAdditionalDayOfYearTokens&&O.test(n))&&function(e,t,n){var a,i,r;let o,s=(a=e,i=t,r=n,o="Y"===a[0]?"years":"days of the month",`Use \`${a.toLowerCase()}\` instead of \`${a}\` (in \`${i}\`) for formatting ${o} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`);if(console.warn(s),k.includes(e))throw RangeError(s)}(n,a,String(e)),(0,w[n[0]])(u,n,s.localize,d)}).join("")}],343747)}];
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=_0i55en5._.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports=[876393,e=>e.a(async(t,i)=>{try{let h,d;var s,r=e.i(902157),n=e.i(750227),l=e.i(418520),a=e.i(429330),o=e.i(333925),u=e.i(64774),c=t([l,a]);[l,a]=c.then?(await c)():c;let f=o.DB_FILE_NAME.replace(/^file:/,"");(0,r.mkdirSync)((0,n.dirname)(f),{recursive:!0});let m=globalThis.__dbClient??=(s=((h=(0,l.createClient)({url:o.DB_FILE_NAME,timeout:5e3})).execute("PRAGMA journal_mode = WAL"),h),d=(0,u.PromiseChain)(),{...s,execute:(...e)=>d(()=>s.execute(...e)),batch:(...e)=>d(()=>s.batch(...e)),executeMultiple:(...e)=>d(()=>s.executeMultiple(...e)),migrate:(...e)=>d(()=>s.migrate(...e)),async transaction(...e){let t,i=await new Promise(e=>{let t,i=new Promise(e=>{t=e});d(async()=>{e(t),await i})});try{t=await s.transaction(...e)}catch(e){throw i(),e}let r=!1,n=()=>{r||(r=!0,i())};return{execute:(...e)=>t.execute(...e),batch:(...e)=>t.batch(...e),executeMultiple:(...e)=>t.executeMultiple(...e),get closed(){return t.closed},commit:()=>t.commit().finally(n),rollback:()=>t.rollback().finally(n),close:()=>{try{t.close()}finally{n()}}}}}),p=(0,a.drizzle)({client:m});e.s(["database",0,p]),i()}catch(e){i(e)}},!1),64774,e=>{"use strict";function t(e,t){let i=e.replace(/\s+/g," ").trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i}e.s(["PromiseChain",0,()=>{let e=Promise.resolve();return t=>{let i=e.then(()=>t());return e=i.catch(()=>{}),i}},"clip",0,t,"errorToString",0,function(e){if(e instanceof Error)return e.message;if("object"!=typeof e||null===e)return String(e);let{message:i,error:s}=e;if("string"==typeof i&&i)return i;if("string"==typeof s&&s)return s;let r=s?.message;if("string"==typeof r&&r)return r;try{return t(JSON.stringify(e),300)}catch{return`${e.constructor?.name??"Object"} thrown without a message`}}])},925369,e=>{"use strict";var t=e.i(539774),i=e.i(533102),s=class{static [t.entityKind]="ConsoleLogWriter";write(e){console.log(e)}},r=class{static [t.entityKind]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new s}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}},n=class{static [t.entityKind]="NoopLogger";logQuery(){}},l=e.i(284346),a=class{static [t.entityKind]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}},o=i,u=class e extends o.SQL{static [t.entityKind]="SQLiteCountBuilder";dialect;session;static buildCount(e,t,i){let s=o.sql`select count(*) from ${e}${o.sql` where ${t}`.if(t)}`;return i?o.sql`(${s})`:s}constructor(t){super(e.buildCount(t.source,t.filters,!0).queryChunks),this.countConfig=t,this.dialect=t.dialect,this.session=t.session,this.mapWith(e=>"number"==typeof e?e:Number(e??0))}executableSql;build(){if(!this.executableSql){let{source:t,filters:i}=this.countConfig;this.executableSql=e.buildCount(t,i)}return this.dialect.sqlToQuery(this.executableSql)}},c=class extends u{static [t.entityKind]="SQLiteAsyncCountBuilder";constructor(e){super(e)}executeRaw(e){return this.session.prepareQuery(this.build(),"arrays",!1,"all",e=>{let t=e[0]?.[0];return"number"==typeof t?t:t?Number(t):0}).execute(e)}async execute(e){return await this.executeRaw(e)}};(0,l.applyMixins)(c,[a]);var h=class extends c{static [t.entityKind]="SQLiteSyncCountBuilder";sync(e){return this.executeRaw(e).sync()}},d=class{static [t.entityKind]="SQLiteRelationalQueryBuilderV2";constructor(e,t,i,s,r,n,l,a=f){this.mode=e,this.schema=t,this.table=i,this.tableConfig=s,this.dialect=r,this.session=n,this.forbidJsonb=l,this.builder=a}findMany(e){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,e??!0,"many",this.forbidJsonb)}findFirst(e){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,e??!0,"first",this.forbidJsonb)}},f=class{static [t.entityKind]="SQLiteRelationalQueryV2";mode;table;resultKind;constructor(e,t,i,s,r,n,l,a,o){this.schema=t,this.tableConfig=s,this.dialect=r,this.session=n,this.config=l,this.forbidJsonb=o,this.resultKind=e,this.mode=a,this.table=i}getSQL(){return this._getQuery().sql}_getQuery(){let e=this.forbidJsonb?i.sql`json`:i.sql`jsonb`;return this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,jsonb:e})}_toSQL(){let e=this._getQuery();return{query:e,builtQuery:this.dialect.sqlToQuery(e.sql)}}toSQL(){return this._toSQL().builtQuery}},m=class extends f{static [t.entityKind]="SQLiteAsyncRelationalQueryV2";_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL(),s=this.dialect.mapperGenerators.relationalRows({isFirst:"first"===this.mode,parseJson:!0,parseJsonIfString:!1,rootJsonMappers:!1,selection:t.selection,arrayModeRoot:!0});return this.session.prepareQuery(i,"arrays",e,"all",s)}prepare(){return this._prepare(!0)}async execute(e){return this._prepare().execute(e)}},p=class extends m{static [t.entityKind]="SQLiteSyncRelationalQueryV2";sync(e){return this._prepare().execute(e).sync()}};(0,l.applyMixins)(m,[a]);var y=e.i(155464),g=e.i(763369),b=e.i(731902),q=e.i(767874),$=e.i(725490),S=class{static [t.entityKind]="ColumnTableAliasProxyHandler";constructor(e,t){this.table=e,this.ignoreColumnAlias=t}get(e,t){return"table"===t?this.table:("isAlias"!==t||!this.ignoreColumnAlias)&&e[t]}},w=class{static [t.entityKind]="ViewSelectionAliasProxyHandler";constructor(e,t,i){this.view=e,this.selection=t,this.ignoreColumnAlias=i}get(e,s){let r=e[s];return(0,t.is)(r,g.Column)?new Proxy(r,new S(this.view,this.ignoreColumnAlias)):(0,t.is)(r,y.Subquery)||(0,t.is)(r,i.SQL)||(0,t.is)(r,i.SQL.Aliased)||(0,i.isSQLWrapper)(r)||"object"!=typeof r||null===r?r:new Proxy(r,this)}},v=class{static [t.entityKind]="TableAliasProxyHandler";constructor(e,t,i){this.alias=e,this.replaceOriginalName=t,this.ignoreColumnAlias=i}get(e,s){if(s===$.Table.Symbol.IsAlias)return!0;if(s===$.Table.Symbol.Name||this.replaceOriginalName&&s===$.Table.Symbol.OriginalName)return this.alias;if(s===b.ViewBaseConfig)return{...e[b.ViewBaseConfig],name:this.alias,isAlias:!0,selectedFields:new Proxy(e[b.ViewBaseConfig].selectedFields,new w(new Proxy(e,this),e[b.ViewBaseConfig].selectedFields,this.ignoreColumnAlias))};if(s===$.Table.Symbol.Columns){let s=e[$.Table.Symbol.Columns];if(!s)return s;if((0,t.is)(e,i.View))return new Proxy(e[$.Table.Symbol.Columns],new w(new Proxy(e,this),e[$.Table.Symbol.Columns],this.ignoreColumnAlias));let r={};return Object.keys(s).map(t=>{r[t]=new Proxy(s[t],new S(new Proxy(e,this),this.ignoreColumnAlias))}),r}let r=e[s];return(0,t.is)(r,g.Column)?new Proxy(r,new S(new Proxy(e,this),this.ignoreColumnAlias)):r}},Q=class{static [t.entityKind]="ColumnAliasProxyHandler";constructor(e){this.alias=e}get(e,t){return"isAlias"===t||("name"===t?this.alias:"keyAsName"!==t&&(t===q.OriginalColumn?()=>e:e[t]))}};function L(e,t){return new Proxy(e,new v(t,!1,!1))}function C(e){return e[q.OriginalColumn]()}t.entityKind,g.Column.prototype.as=function(e){return new Proxy(this,new Q(e))};var T=class e{static [t.entityKind]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(s,r){if("_"===r)return{...s._,selectedFields:new Proxy(s._.selectedFields,this)};if(r===b.ViewBaseConfig)return{...s[b.ViewBaseConfig],selectedFields:new Proxy(s[b.ViewBaseConfig].selectedFields,this)};if("symbol"==typeof r)return s[r];let n=((0,t.is)(s,y.Subquery)?s._.selectedFields:(0,t.is)(s,i.View)?s[b.ViewBaseConfig].selectedFields:s)[r];if((0,t.is)(n,i.SQL.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!n.isSelectionField)return n.sql;let e=n.clone();return e.isSelectionField=!0,e.origin=this.config.alias,e}if((0,t.is)(n,i.SQL)){if("sql"===this.config.sqlBehavior)return n;throw Error(`You tried to reference "${r}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return(0,t.is)(n,g.Column)?this.config.alias?new Proxy(n,new S(new Proxy(n.table,new v(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):n:"object"!=typeof n||null===n?n:new Proxy(n,new e(this.config))}},N=e.i(97141);function x(e){return(0,t.is)(e,N.SQLiteTable)?[`${e[$.Table.Symbol.BaseName]}`]:(0,t.is)(e,y.Subquery)?e._.usedTables??[]:(0,t.is)(e,i.SQL)?e.usedTables??[]:[]}t.entityKind,t.entityKind,e.i(502765),e.i(117381),e.i(173431),e.i(282276);var A=class{static [t.entityKind]="SQLiteDelete";config;constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s}}where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[$.Table.Symbol.Columns],new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[N.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,l.orderSelectedFields)(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},j=class extends A{static [t.entityKind]="SQLiteAsyncDelete";_prepare(e=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",e,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"delete",tables:x(this.config.table)})}prepare(){return this._prepare(!0)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}};(0,l.applyMixins)(j,[a]);var B=i,_=class extends B.View{static [t.entityKind]="SQLiteViewBase"},O=class{static [t.entityKind]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},F=class{static [t.entityKind]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e,t=D){this.builder=t,this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let s,r=!!this.fields;return s=this.fields?this.fields:(0,t.is)(e,y.Subquery)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):(0,t.is)(e,_)?e[b.ViewBaseConfig].selectedFields:(0,t.is)(e,i.SQL)?{}:(0,l.getTableColumns)(e),new this.builder({table:e,fields:s,isPartialSelect:r,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},D=class extends O{static [t.entityKind]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:r,withList:n,distinct:a}){for(const o of(super(),this.config={withList:n,table:e,fields:{...t},distinct:a,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=r,this._={selectedFields:t,config:this.config},this.tableName=(0,l.getTableLikeName)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},x(e)))this.usedTables.add(o)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(s,r)=>{let n=this.tableName,a=(0,l.getTableLikeName)(s);for(let e of x(s))this.usedTables.add(e);if("string"==typeof a&&this.config.joins?.some(e=>e.alias===a))throw Error(`Alias "${a}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof n&&(this.config.fields={[n]:this.config.fields}),"string"==typeof a&&!(0,t.is)(s,i.SQL))){let e=(0,t.is)(s,y.Subquery)?s._.selectedFields:(0,t.is)(s,i.View)?s[b.ViewBaseConfig].selectedFields:s[$.Table.Symbol.Columns];this.config.fields[a]=e}if("function"==typeof r&&(r=r(new Proxy(this.config.fields,new T({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:r,table:s,joinType:e,alias:a}),"string"==typeof a)switch(e){case"left":this.joinsNotNullableMap[a]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[a]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let s="function"==typeof i?i(P()):i;if(!(0,l.haveSameKeys)(this.getSelectedFields(),s.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new T({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new T({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enabled:!0,autoInvalidate:!0}:!1===e?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...e},this}getSQL(){return this.config.fieldsFlat=(0,l.orderSelectedFields)(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(e){let t=[];if(t.push(...x(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...x(e.table));return new Proxy(new y.Subquery(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new T({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new T({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function K(e,t){return(i,s,...r)=>{let n=[s,...r].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!(0,l.haveSameKeys)(i.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return i.addSetOperators(n)}}let P=()=>({union:k,unionAll:E,intersect:V,except:I}),k=K("union",!1),E=K("union",!0),V=K("intersect",!1),I=K("except",!1);var J=class extends Error{static [t.entityKind]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}},M=class e extends Error{static [t.entityKind]="DrizzleQueryError";constructor(t,i,s){super(`Failed query: ${t}
|
|
2
|
+
params: ${i}`),this.query=t,this.params=i,this.cause=s,this.name="DrizzleQueryError",Error.captureStackTrace(this,e),s&&(this.cause=s)}},z=class extends J{static [t.entityKind]="TransactionRollbackError";constructor(){super({message:"Rollback"}),this.name="TransactionRollbackError"}},U=e.i(336763),R=e.i(396918),W=class{static [t.entityKind]="RelationV2";fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[];constructor(e,t){this.targetTableName=t,this.targetTable=e}},H=class extends W{static [t.entityKind]="OneV2";relationType="one";optional;constructor(e,t,i,s){super(t,i),this.alias=s?.alias,this.where=s?.where,s?.from&&(this.sourceColumns=(Array.isArray(s.from)?s.from:[s.from]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.sourceColumnTableNames.push(t._.tableName),t._.column))),s?.to&&(this.targetColumns=(Array.isArray(s.to)?s.to:[s.to]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.targetColumnTableNames.push(t._.tableName),t._.column))),this.throughTable&&(this.through={source:(Array.isArray(s?.from)?s.from:s?.from?[s.from]:[]).map(e=>e._.through),target:(Array.isArray(s?.to)?s.to:s?.to?[s.to]:[]).map(e=>e._.through)}),this.optional=s?.optional??!0}},G=(t.entityKind,class{static [t.entityKind]="AggregatedField";table;onTable(e){return this.table=e,this}});t.entityKind;let Y={and:U.and,between:U.between,eq:U.eq,exists:U.exists,gt:U.gt,gte:U.gte,ilike:U.ilike,inArray:U.inArray,arrayContains:U.arrayContains,arrayContained:U.arrayContained,arrayOverlaps:U.arrayOverlaps,isNull:U.isNull,isNotNull:U.isNotNull,like:U.like,lt:U.lt,lte:U.lte,ne:U.ne,not:U.not,notBetween:U.notBetween,notExists:U.notExists,notLike:U.notLike,notIlike:U.notIlike,notInArray:U.notInArray,or:U.or,sql:i.sql},Z={sql:i.sql,asc:R.asc,desc:R.desc};function X(e,s,r,n=!1,l=!1,a=!0){let o=s?1:e.length,u=r.map(({field:e,codec:s,arrayDimensions:r})=>{let n;return(n=(0,t.is)(e,g.Column)?e:(0,t.is)(e,i.SQL)?e.decoder:(0,t.is)(e,i.SQL.Aliased)?e.sql.decoder:(0,t.is)(e,$.Table)||(0,t.is)(e,i.View)?i.noopDecoder:e.getSQL().decoder,a&&e.mapFromJsonValue)?t=>e.mapFromJsonValue(t):n.mapFromDriverValue.isNoop?s?e=>s(e,r):void 0:s?e=>n.mapFromDriverValue(s(e,r)):e=>n.mapFromDriverValue(e)});for(let t=0;t<o;++t){let i=s?e:e[t];for(let e=0;e<r.length;++e){let t=r[e];if(t.selection){if(null===i[t.key])continue;if(n){if(i[t.key]=JSON.parse(i[t.key]),null===i[t.key])continue}else l&&"string"==typeof i[t.key]&&(i[t.key]=JSON.parse(i[t.key]));if(t.isArray){X(i[t.key],!1,t.selection,!1,l);continue}X(i[t.key],!0,t.selection,!1,l);continue}if(null===i[t.key])continue;let s=u[e];s&&(i[t.key]=s(i[t.key]))}}return e}function ee({selection:e,isFirst:s,parseJson:r,parseJsonIfString:n,rootJsonMappers:l,arrayModeRoot:a}){return o=>s&&!o[0]?o[0]:a?function(e,s,r,n=!1,l=!1){let a=s?1:e.length,o=r.map(({field:e,codec:s,arrayDimensions:r})=>{let n;return(n=(0,t.is)(e,g.Column)?e:(0,t.is)(e,i.SQL)?e.decoder:(0,t.is)(e,i.SQL.Aliased)?e.sql.decoder:(0,t.is)(e,$.Table)||(0,t.is)(e,i.View)?i.noopDecoder:e.getSQL().decoder).mapFromDriverValue.isNoop?s?e=>s(e,r):void 0:s?e=>n.mapFromDriverValue(s(e,r)):e=>n.mapFromDriverValue(e)}),u=Array.from({length:a});for(let t=0;t<a;++t){let i=s?e:e[t],a={};for(let e=0;e<r.length;++e){let t=r[e],s=i[e];if(t.selection){if(null===s){a[t.key]=null;continue}if(n){if(null===(s=JSON.parse(s))){a[t.key]=null;continue}}else l&&"string"==typeof s&&(s=JSON.parse(s));t.isArray?X(s,!1,t.selection,!1,l):X(s,!0,t.selection,!1,l),a[t.key]=s;continue}if(null===s){a[t.key]=null;continue}let u=o[e];a[t.key]=u?u(s):s}u[t]=a}return s?u[0]:u}(s?o[0]:o,s,e,r,n):X(s?o[0]:o,s,e,r,n,l)}function et({selection:e,isFirst:s,parseJson:r,parseJsonIfString:n,rootJsonMappers:a,arrayModeRoot:o}){let u=[],c=function e(s,r,n,l,a,o,u,c,h){let d=[],f=[],m=!1,p=s.map(()=>`c${c.n++}`),y=s.map((e,t)=>h?p[t]:`${JSON.stringify(e.key)}: ${p[t]}`);for(let[b,{field:q,key:S,codec:w,isArray:v,selection:Q,arrayDimensions:L}]of(d.push(h?`let [ ${y.join(", ")} ] = ${r};`:`let { ${y.join(", ")} } = ${r};`),s.entries())){let s=`${n}[${b}]`,r=JSON.stringify(S),h=p[b];if(Q){l?(d.push(`if (${h} !== null) ${h} = JSON.parse(${h});`),m=!0):a&&(d.push(`if (typeof ${h} === 'string') ${h} = JSON.parse(${h});`),m=!0);let t=`s${c.n++}`,i=u.length;if(u.push(`const { selection: ${t} } = ${s};`),v){let s=`j${c.n++}`,r=e(Q,`${h}[${s}]`,t,!1,a,!0,u,c,!1);if(r.hasWork){for(let e of(m=!0,d.push(`if (${h} !== null) {`),d.push(` for (let ${s} = 0; ${s} < ${h}.length; ++${s}) {`),r.bodyStmts))d.push(` ${e}`);d.push(` ${h}[${s}] = ${r.literal};`),d.push(" }"),d.push("}")}else u.splice(i,1)}else{let s=e(Q,h,t,!1,a,!0,u,c,!1);if(s.hasWork){for(let e of(m=!0,d.push(`if (${h} !== null) {`),s.bodyStmts))d.push(` ${e}`);d.push(` ${h} = ${s.literal};`),d.push("}")}else u.splice(i,1)}f.push(`${r}: ${h}`);continue}let y="",C="",T=!1;if((0,t.is)(q,g.Column)){if(o&&q.mapFromJsonValue){T=!0;let e=c.n++;C=`field: dec${e}`,y=`dec${e}.mapFromJsonValue`}else if(!q.mapFromDriverValue.isNoop){let e=c.n++;C=`field: dec${e}`,y=`dec${e}.mapFromDriverValue`}}else if((0,t.is)(q,i.SQL)){if(o&&q.decoder.mapFromJsonValue){T=!0;let e=c.n++;C=`field: { decoder: dec${e} }`,y=`dec${e}.mapFromJsonValue`}else if(!q.decoder.mapFromDriverValue.isNoop){let e=c.n++;C=`field: { decoder: dec${e} }`,y=`dec${e}.mapFromDriverValue`}}else if((0,t.is)(q,i.SQL.Aliased)){if(o&&q.sql.decoder.mapFromJsonValue){T=!0;let e=c.n++;C=`field: { sql: { decoder: dec${e} } }`,y=`dec${e}.mapFromJsonValue`}else if(!q.sql.decoder.mapFromDriverValue.isNoop){let e=c.n++;C=`field: { sql: { decoder: dec${e} } }`,y=`dec${e}.mapFromDriverValue`}}else if((0,t.is)(q,$.Table)||(0,t.is)(q,i.View));else{let e=q.getSQL();if(o&&e.decoder.mapFromJsonValue){T=!0;let e=c.n++;u.push(`const dec${e} = ${s}.field.getSQL().decoder;`),y=`dec${e}.mapFromJsonValue`}else if(!e.decoder.mapFromDriverValue.isNoop){let e=c.n++;u.push(`const dec${e} = ${s}.field.getSQL().decoder;`),y=`dec${e}.mapFromDriverValue`}}let N="";if(!T&&w&&(N=`codec${c.n++}`),C||N){let e=[];C&&e.push(C),N&&e.push(`codec: ${N}`),u.push(`const { ${e.join(", ")} } = ${s};`)}if(y||N){m=!0;let e=h;N&&(e=`${N}(${e}, ${L})`),y&&(e=`${y}(${e})`),f.push(`${r}: ${h} === null ? null : ${e}`)}else f.push(`${r}: ${h}`)}return{bodyStmts:d,literal:`{ ${f.join(", ")} }`,hasWork:m}}(e,"row","selection",r,n,!o&&a,u,{n:0},!!o),h=[];for(let e of(h.push(` "use strict";
|
|
3
|
+
const { selection } = this;`),u))h.push(` ${e}`);if(o)if(s){for(let e of(h.push(" const row = rows[0];"),h.push(" if (!row) return undefined;"),c.bodyStmts))h.push(` ${e}`);h.push(` return ${c.literal};`)}else{for(let e of(h.push(" const { length } = rows;"),h.push(" const mapped = Array.from({ length });"),h.push(" for (let i = 0; i < length; ++i) {"),h.push(" const row = rows[i];"),c.bodyStmts))h.push(` ${e}`);h.push(` mapped[i] = ${c.literal};`),h.push(" }"),h.push(" return mapped;")}else if(c.hasWork)if(s){for(let e of(h.push(" const row = rows[0];"),h.push(" if (!row) return undefined;"),c.bodyStmts))h.push(` ${e}`);h.push(` rows[0] = ${c.literal};`),h.push(" return rows[0];")}else{for(let e of(h.push(" for (let i = 0; i < rows.length; ++i) {"),h.push(" const row = rows[i];"),c.bodyStmts))h.push(` ${e}`);h.push(` rows[i] = ${c.literal};`),h.push(" }"),h.push(" return rows;")}else h.push(s?" return rows[0];":" return rows;");h.push(" //# sourceURL=drizzle:jit-relational-query-mapper");let d=h.join("\n");return Object.assign(new l.FnConstructor("rows",d).bind({selection:e}),{body:`function jitRqbMapper (rows) {
|
|
4
|
+
${d}
|
|
5
|
+
}`})}function ei(e,s){let r=e[$.TableColumns][s];return r?(0,t.is)(r,g.Column)?r:(0,t.is)(r,i.SQL.Aliased)?i.sql`${e}.${i.sql.identifier(r.fieldAlias)}`:i.sql`${e}.${i.sql.identifier(s)}`:i.sql`${e}.${i.sql.identifier(s)}`}function es(e,s,r={},n={},l=0){let a=Object.entries(s);if(!a.length)return;let o=[];for(let[s,u]of a)if(void 0!==u)switch(s){case"RAW":{let t="function"==typeof u?u(e,Y):u.getSQL();o.push(t);continue}case"OR":if(!u?.length)continue;o.push((0,U.or)(...u.map(t=>es(e,t,r,n,l))));continue;case"AND":if(!u?.length)continue;o.push((0,U.and)(...u.map(t=>es(e,t,r,n,l))));continue;case"NOT":{if(void 0===u)continue;let t=es(e,u,r,n,l);if(!t)continue;o.push((0,U.not)(t));continue}default:{if(e[$.TableColumns][s]){let r=function e(s,r){if("object"!=typeof r||(0,t.is)(r,i.Placeholder))return(0,U.eq)(s,r);let n=Object.entries(r);if(!n.length)return;let l=[];for(let[t,i]of n)if(void 0!==i)switch(t){case"NOT":{let t=e(s,i);if(!t)continue;l.push((0,U.not)(t));continue}case"OR":if(!i.length)continue;l.push((0,U.or)(...i.map(t=>e(s,t))));continue;case"AND":if(!i.length)continue;l.push((0,U.and)(...i.map(t=>e(s,t))));continue;case"isNotNull":case"isNull":if(!i)continue;l.push(Y[t](s));continue;case"in":l.push(Y.inArray(s,i));continue;case"notIn":l.push(Y.notInArray(s,i));continue;default:l.push(Y[t](s,i));continue}if(l.length)return(0,U.and)(...l)}(ei(e,s),u);r&&o.push(r);continue}let a=r[s];if(!a)throw new J({message:`Unknown relational filter field: "${s}"`});let c=L(a.targetTable,`f${l}`),h=a.throughTable?L(a.throughTable,`ft${l}`):void 0,d=n[a.targetTableName],{filter:f,joinCondition:m}=er(a,e,c,h),p=(0,U.and)(f,"boolean"==typeof u?void 0:es(c,u,d.relations,n,l+1)),y=h?i.sql`(select * from ${en(c)} inner join ${en(h)} on ${m}${i.sql` where ${p}`.if(p)} limit 1)`:i.sql`(select * from ${en(c)}${i.sql` where ${p}`.if(p)} limit 1)`;p&&o.push((u?U.exists:U.notExists)(y))}}return(0,U.and)(...o)}function er(e,s,r,n){if(e.through){let l=e.sourceColumns.map((r,l)=>{let a=e.through.source[l];return(0,U.eq)(i.sql`${s}.${i.sql.identifier(r.name)}`,i.sql`${n}.${i.sql.identifier((0,t.is)(a._.column,g.Column)?a._.column.name:a._.key)}`)}),a=e.targetColumns.map((s,l)=>{let a=e.through.target[l];return(0,U.eq)(i.sql`${n}.${i.sql.identifier((0,t.is)(a._.column,g.Column)?a._.column.name:a._.key)}`,i.sql`${r}.${i.sql.identifier(s.name)}`)});return{filter:(0,U.and)(e.where?es(e.isReversed?s:r,e.where):void 0,...l),joinCondition:(0,U.and)(...a)}}return{filter:(0,U.and)(...e.sourceColumns.map((t,n)=>{let l=e.targetColumns[n];return(0,U.eq)(i.sql`${s}.${i.sql.identifier(t.name)}`,i.sql`${r}.${i.sql.identifier(l.name)}`)}),e.where?es(e.isReversed?s:r,e.where):void 0)}}function en(e){return i.sql`${e[$.IsAlias]?i.sql`${i.sql`${i.sql.identifier(e[$.TableSchema]??"")}.`.if(e[$.TableSchema])}${i.sql.identifier(e[$.OriginalName])} as ${e}`:e}`}t.entityKind,t.entityKind,t.entityKind,t.entityKind;var el=e.i(827194),ea=class{static [t.entityKind]="SQLiteDialect";mapperGenerators;constructor(e){this.mapperGenerators=e?.useJitMappers?{rows:l.makeJitQueryMapper,relationalRows:et}:{rows:l.makeDefaultQueryMapper,relationalRows:ee}}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[i.sql`with `];for(let[s,r]of e.entries())t.push(i.sql`${i.sql.identifier(r._.alias)} as (${r._.sql})`),s<e.length-1&&t.push(i.sql`, `);return t.push(i.sql` `),i.sql.join(t)}buildDeleteQuery({table:e,where:t,returning:s,withList:r,limit:n,orderBy:l}){let a=this.buildWithCTE(r),o=s?i.sql` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0;return i.sql`${a}delete from ${e}${t?i.sql` where ${t}`:void 0}${o}${this.buildOrderBy(l)}${this.buildLimit(n)}`}buildUpdateSet(e,s){let r=e[$.Table.Symbol.Columns],n=Object.keys(r).filter(e=>void 0!==s[e]||r[e]?.onUpdateFn!==void 0),l=n.length;return i.sql.join(n.flatMap((e,n)=>{let a=r[e],o=a.onUpdateFn?.(),u=s[e]??((0,t.is)(o,i.SQL)?o:i.sql.param(o,a)),c=i.sql`${i.sql.identifier(a.name)} = ${u}`;return n<l-1?[c,i.sql.raw(", ")]:[c]}))}buildUpdateQuery({table:e,set:t,where:s,returning:r,withList:n,joins:l,from:a,limit:o,orderBy:u}){let c=this.buildWithCTE(n),h=this.buildUpdateSet(e,t),d=a&&i.sql.join([i.sql.raw(" from "),this.buildFromTable(a)]),f=this.buildJoins(l),m=r?i.sql` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0;return i.sql`${c}update ${e} set ${h}${d}${f}${s?i.sql` where ${s}`:void 0}${m}${this.buildOrderBy(u)}${this.buildLimit(o)}`}buildSelection(e,{isSingleTable:s=!1}={}){let r=e.length,n=e.flatMap(({field:e},n)=>{let l=[];if((0,t.is)(e,i.SQL.Aliased))if(e.isSelectionField)s||void 0===e.origin||l.push(i.sql.identifier(e.origin),i.sql.raw(".")),l.push(i.sql.identifier(e.fieldAlias));else{let r=e.sql;if(s){let e=new i.SQL(r.queryChunks.map(e=>(0,t.is)(e,g.Column)?i.sql.identifier(e.name):e));l.push(r.shouldInlineParams?e.inlineParams():e)}else l.push(r);l.push(i.sql` as ${i.sql.identifier(e.fieldAlias)}`)}else if((0,t.is)(e,i.SQL))if(s){let s=new i.SQL(e.queryChunks.map(e=>(0,t.is)(e,g.Column)?i.sql.identifier(e.name):e));l.push(e.shouldInlineParams?s.inlineParams():s)}else l.push(e);else(0,t.is)(e,g.Column)?"SQLiteNumericBigInt"===e.columnType||"SQLiteNumeric"===e.columnType?s?l.push(e.isAlias?i.sql`cast(${i.sql.identifier(C(e).name)} as text) as ${e}`:i.sql`cast(${i.sql.identifier(e.name)} as text)`):l.push(e.isAlias?i.sql`cast(${C(e)} as text) as ${e}`:i.sql`cast(${e} as text)`):s?l.push(e.isAlias?i.sql`${i.sql.identifier(C(e).name)} as ${e}`:i.sql.identifier(e.name)):l.push(e.isAlias?i.sql`${C(e)} as ${e}`:e):(0,t.is)(e,y.Subquery)&&(e._.isWith?l.push(e):l.push(i.sql`(${e._.sql}) ${i.sql.identifier(e._.alias)}`));return n<r-1&&l.push(i.sql`, `),l});return i.sql.join(n)}buildJoins(e){if(!e||0===e.length)return;let s=[];if(e)for(let[r,n]of e.entries()){0===r&&s.push(i.sql` `);let l=n.table,a=n.on?i.sql` on ${n.on}`:void 0;if((0,t.is)(l,N.SQLiteTable)){let e=l[N.SQLiteTable.Symbol.Name],t=l[N.SQLiteTable.Symbol.Schema],r=l[N.SQLiteTable.Symbol.OriginalName],o=e===r?void 0:n.alias;s.push(i.sql`${i.sql.raw(n.joinType)} join ${t?i.sql`${i.sql.identifier(t)}.`:void 0}${i.sql.identifier(r)}${o&&i.sql` ${i.sql.identifier(o)}`}${a}`)}else s.push(i.sql`${i.sql.raw(n.joinType)} join ${l}${a}`);r<e.length-1&&s.push(i.sql` `)}return i.sql.join(s)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?i.sql` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[s,r]of e.entries())t.push(r),s<e.length-1&&t.push(i.sql`, `);return t.length>0?i.sql` order by ${i.sql.join(t)}`:void 0}buildFromTable(e){if((0,t.is)(e,$.Table)&&e[$.Table.Symbol.IsAlias])return i.sql`${i.sql`${i.sql.identifier(e[$.Table.Symbol.Schema]??"")}.`.if(e[$.Table.Symbol.Schema])}${i.sql.identifier(e[$.Table.Symbol.OriginalName])} ${i.sql.identifier(e[$.Table.Symbol.Name])}`;if((0,t.is)(e,i.View)&&e[b.ViewBaseConfig].isAlias){let t=i.sql`${i.sql.identifier(e[b.ViewBaseConfig].originalName)}`;return e[b.ViewBaseConfig].schema&&(t=i.sql`${i.sql.identifier(e[b.ViewBaseConfig].schema)}.${t}`),i.sql`${t} ${i.sql.identifier(e[b.ViewBaseConfig].name)}`}return e}buildSelectQuery({withList:e,fields:s,fieldsFlat:r,where:n,having:a,table:o,joins:u,orderBy:c,groupBy:h,limit:d,offset:f,distinct:m,setOperators:p}){let q=r??(0,l.orderSelectedFields)(s);for(let e of q){let s;if((0,t.is)(e.field,g.Column)&&(0,$.getTableName)(e.field.table)!==((0,t.is)(o,y.Subquery)?o._.alias:(0,t.is)(o,_)?o[b.ViewBaseConfig].name:(0,t.is)(o,i.SQL)?void 0:(0,$.getTableName)(o))&&(s=e.field.table,!u?.some(({alias:e})=>e===(s[$.Table.Symbol.IsAlias]?(0,$.getTableName)(s):s[$.Table.Symbol.BaseName])))){let t=(0,$.getTableName)(e.field.table);throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let S=!u||0===u.length,w=this.buildWithCTE(e),v=m?i.sql` distinct`:void 0,Q=this.buildSelection(q,{isSingleTable:S}),L=this.buildFromTable(o),C=this.buildJoins(u),T=n?i.sql` where ${n}`:void 0,N=a?i.sql` having ${a}`:void 0,x=[];if(h)for(let[e,t]of h.entries())x.push(t),e<h.length-1&&x.push(i.sql`, `);let A=i.sql`${w}select${v} ${Q} from ${L}${C}${T}${x.length>0?i.sql` group by ${i.sql.join(x)}`:void 0}${N}${this.buildOrderBy(c)}${this.buildLimit(d)}${f?i.sql` offset ${f}`:void 0}`;return p.length>0?this.buildSetOperations(A,p):A}buildSetOperations(e,t){let[i,...s]=t;if(!i)throw Error("Cannot pass undefined values to any set operator");return 0===s.length?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:s,isAll:r,rightSelect:n,limit:l,orderBy:a,offset:o}}){let u,c=i.sql`${e.getSQL()} `,h=i.sql`${n.getSQL()}`;if(a&&a.length>0){let e=[];for(let s of a)if((0,t.is)(s,el.SQLiteColumn))e.push(i.sql.identifier(s.name));else if((0,t.is)(s,i.SQL)){for(let e=0;e<s.queryChunks.length;e++){let r=s.queryChunks[e];(0,t.is)(r,el.SQLiteColumn)&&(s.queryChunks[e]=i.sql.identifier(r.name))}e.push(i.sql`${s}`)}else e.push(i.sql`${s}`);u=i.sql` order by ${i.sql.join(e,i.sql`, `)}`}let d="object"==typeof l||"number"==typeof l&&l>=0?i.sql` limit ${l}`:void 0,f=i.sql.raw(`${s} ${r?"all ":""}`),m=o?i.sql` offset ${o}`:void 0;return i.sql`${c}${f}${h}${u}${d}${m}`}buildInsertQuery({table:e,values:s,onConflict:r,returning:n,withList:l,select:a}){let o=[],u=e[$.Table.Symbol.Columns],c=Object.entries(u),h=a&&!(0,t.is)(s,i.SQL)?Object.keys(s.getSelectedFields()).map(e=>[e,u[e]]):c.filter(([e,t])=>!t.shouldDisableInsert()),d=h.map(([,e])=>i.sql.identifier(e.name));if(a)(0,t.is)(s,i.SQL)?o.push(s):o.push(s.getSQL());else for(let[e,r]of(o.push(i.sql.raw("values ")),s.entries())){let n=[];for(let[e,s]of h){let l=r[e];if(void 0===l||(0,t.is)(l,i.Param)&&void 0===l.value){let e;if(null!==s.default&&void 0!==s.default)e=(0,t.is)(s.default,i.SQL)?s.default:i.sql.param(s.default,s);else if(void 0!==s.defaultFn){let r=s.defaultFn();e=(0,t.is)(r,i.SQL)?r:i.sql.param(r,s)}else if(s.default||void 0===s.onUpdateFn)e=i.sql`null`;else{let r=s.onUpdateFn();e=(0,t.is)(r,i.SQL)?r:i.sql.param(r,s)}n.push(e)}else n.push(l)}o.push(n),e<s.length-1&&o.push(i.sql`, `)}let f=this.buildWithCTE(l),m=i.sql.join(o),p=n?i.sql` returning ${this.buildSelection(n,{isSingleTable:!0})}`:void 0;return i.sql`${f}insert into ${e} ${d} ${m}${r?.length?i.sql.join(r):void 0}${p}`}sqlToQuery(e,t){return e.toQuery({escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}nestedSelectionerror(){throw new J({message:"Views with nested selections are not supported by the relational query builder"})}buildRqbColumn(e,s,r,n){if((0,t.is)(s,g.Column)){let t=i.sql`${e}.${i.sql.identifier(s.name)}`;switch(s.columnType){case"SQLiteBigInt":case"SQLiteBlobJson":case"SQLiteBlobBuffer":if(!n)return i.sql`${t} as ${i.sql.identifier(r)}`;return i.sql`hex(${t}) as ${i.sql.identifier(r)}`;case"SQLiteNumeric":case"SQLiteNumericNumber":case"SQLiteNumericBigInt":return i.sql`cast(${t} as text) as ${i.sql.identifier(r)}`;case"SQLiteCustomColumn":if(!n)return i.sql`${t} as ${i.sql.identifier(r)}`;return i.sql`${s.jsonSelectIdentifier(t,i.sql)} as ${i.sql.identifier(r)}`;default:return i.sql`${t} as ${i.sql.identifier(r)}`}}return i.sql`${e}.${(0,t.is)(s,i.SQL.Aliased)?i.sql.identifier(s.fieldAlias):(0,i.isSQLWrapper)(s)?i.sql.identifier(r):this.nestedSelectionerror()} as ${i.sql.identifier(r)}`}unwrapAllColumns=(e,t,s)=>i.sql.join(Object.entries(e[$.TableColumns]).map(([i,r])=>(t.push({key:i,field:r}),this.buildRqbColumn(e,r,i,s))),i.sql`, `);getSelectedTableColumns=(e,t)=>{let i,s=[],r=e[$.TableColumns];for(let[e,n]of Object.entries(t))if(void 0!==n&&(i=i||n,n)){let t=r[e];s.push({column:t,tsName:e})}if(!1===i)for(let[e,i]of Object.entries(r))!1!==t[e]&&s.push({column:i,tsName:e});return s};buildColumns=(e,t,s,r)=>r?.columns?(()=>{let n=[];for(let{column:i,tsName:l}of this.getSelectedTableColumns(e,r?.columns))n.push(this.buildRqbColumn(e,i,l,s)),t.push({key:l,field:i});return n.length?i.sql.join(n,i.sql`, `):void 0})():this.unwrapAllColumns(e,t,s);buildRelationalQuery({schema:e,table:s,tableConfig:r,queryConfig:n,relationWhere:l,mode:a,isNested:o,errorPath:u,depth:c,throughJoin:h,jsonb:d}){let f=[],m=!0===n?void 0:n,p=u??"",y=c??0;y||(s=L(s,`d${y}`));let b="first"===a?1:m?.limit,q=m?.offset,$=this.buildColumns(s,f,!!o,m),S=m?.where&&l?(0,U.and)(es(s,m.where,r.relations,e),l):m?.where?es(s,m.where,r.relations,e):l,w=m?.orderBy?function(e,s){if("function"==typeof s){let r=s(e,Z);return(0,t.is)(r,i.SQL)?r:Array.isArray(r)?r.length?i.sql.join(r.map(e=>(0,t.is)(e,i.SQL)?e:(0,R.asc)(e)),i.sql`, `):void 0:(0,t.is)(r,g.Column)?(0,R.asc)(r):void 0}let r=Object.entries(s).filter(([e,t])=>t);if(r.length)return i.sql.join(r.map(([t,i])=>("asc"===i?R.asc:R.desc)(ei(e,t))),i.sql`, `)}(s,m.orderBy):void 0,v=m?.extras?function(e,t){let s=[],r=[];for(let[n,l]of Object.entries(t)){if(!l)continue;let t=("function"==typeof l?l(e,{sql:Y.sql}):l).getSQL(),a,o=a?i.sql`${(void 0).apply(a,"cast",i.sql`(${t})`)} as ${i.sql.identifier(n)}`:i.sql`(${t}) as ${i.sql.identifier(n)}`;o.decoder=t.decoder,s.push(o),r.push(a?{key:n,field:o,codec:(void 0).get(a,"normalize"),arrayDimensions:a.dimensions}:{key:n,field:o})}return{sql:s.length?i.sql.join(s,i.sql`, `):void 0,selection:r}}(s,m.extras):void 0;v&&f.push(...v.selection);let Q=m?(()=>{let{with:n}=m;if(!n)return;let l=Object.entries(n).filter(([e,t])=>t);if(l.length)return i.sql.join(l.map(([n,l])=>{let a=r.relations[n],u=(0,t.is)(a,H),c=L(a.targetTable,`d${y+1}`),h=a.throughTable?L(a.throughTable,`tr${y}`):void 0,{filter:m,joinCondition:g}=er(a,s,c,h),b=h?i.sql` inner join ${en(h)} on ${g}`:void 0,q=this.buildRelationalQuery({table:c,mode:u?"first":"many",schema:e,queryConfig:l,tableConfig:e[a.targetTableName],relationWhere:m,isNested:!0,errorPath:`${p.length?`${p}.`:""}${n}`,depth:y+1,throughJoin:b,jsonb:d});f.push({field:c,key:n,selection:q.selection,isArray:!u,isOptional:(a.optional??!1)||!0!==l&&!!l.where});let $=i.sql.join(q.selection.map(e=>i.sql`${i.sql.raw(this.escapeString(e.key))}, ${e.selection?i.sql`${d}(${i.sql.identifier(e.key)})`:i.sql.identifier(e.key)}`),i.sql`, `),S=o?d:i.sql`json`;return u?i.sql`(select ${S}_object(${$}) as ${i.sql.identifier("r")} from (${q.sql}) as ${i.sql.identifier("t")}) as ${i.sql.identifier(n)}`:i.sql`coalesce((select ${S}_group_array(json_object(${$})) as ${i.sql.identifier("r")} from (${q.sql}) as ${i.sql.identifier("t")}), ${d}_array()) as ${i.sql.identifier(n)}`}),i.sql`, `)})():void 0,C=[$,v?.sql,Q].filter(e=>void 0!==e);if(!C.length)throw new J({message:`No fields selected for table "${r.name}"${p?` ("${p}")`:""}`});return{sql:i.sql`select ${i.sql.join(C,i.sql`, `)} from ${en(s)}${h}${i.sql` where ${S}`.if(S)}${i.sql` order by ${w}`.if(w)}${i.sql` limit ${b}`.if(void 0!==b)}${i.sql` offset ${q}`.if(void 0!==q)}`,selection:f}}},eo=class{static [t.entityKind]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=(0,t.is)(e,ea)?e:void 0,this.dialectConfig=(0,t.is)(e,ea)?void 0:e}$with=(e,t)=>{let i=this;return{as:s=>("function"==typeof s&&(s=s(i)),new Proxy(new y.WithSubquery(s.getSQL(),t??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),e,!0),new T({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};with(...e){let t=this;return{select:function(i){return new F({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(i){return new F({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}}}select(e){return new F({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new F({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||(this.dialect=new ea(this.dialectConfig)),this.dialect}},eu=class{static [t.entityKind]="SQLiteInsertBuilder";constructor(e,t,i,s,r=ec){this.table=e,this.session=t,this.dialect=i,this.withList=s,this.builder=r}values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let s=e.map(e=>{let s={},r=this.table[$.Table.Symbol.Columns];for(let n of Object.keys(e)){let l=e[n];s[n]=(0,t.is)(l,i.SQL)?l:new i.Param(l,r[n])}return s});return new this.builder(this.table,s,this.session,this.dialect,this.withList)}select(e){let s="function"==typeof e?e(new eo):e;if(!(0,t.is)(s,i.SQL)){let e=Object.keys(this.table[$.Table.Symbol.Columns]);for(let t of Object.keys(s._.selectedFields))if(!e.includes(t))throw Error(`Insert select error: column "${t}" does not exist in table "${this.table[$.Table.Symbol.Name]}"`)}return new this.builder(this.table,s,this.session,this.dialect,this.withList,!0)}},ec=class{static [t.entityKind]="SQLiteInsert";config;constructor(e,t,i,s,r,n){this.session=i,this.dialect=s,this.config={table:e,values:t,withList:r,select:n}}returning(e=this.config.table[N.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,l.orderSelectedFields)(e),this}onConflictDoNothing(e={}){if(this.config.onConflict||(this.config.onConflict=[]),void 0===e.target)this.config.onConflict.push(i.sql` on conflict do nothing`);else{let t=Array.isArray(e.target)?i.sql`${e.target}`:i.sql`${[e.target]}`,s=e.where?i.sql` where ${e.where}`:i.sql``;this.config.onConflict.push(i.sql` on conflict ${t} do nothing${s}`)}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');this.config.onConflict||(this.config.onConflict=[]);let t=e.where?i.sql` where ${e.where}`:void 0,s=e.targetWhere?i.sql` where ${e.targetWhere}`:void 0,r=e.setWhere?i.sql` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?i.sql`${e.target}`:i.sql`${[e.target]}`,a=this.dialect.buildUpdateSet(this.config.table,(0,l.mapUpdateSet)(this.config.table,e.set));return this.config.onConflict.push(i.sql` on conflict ${n}${s} do update set ${a}${t}${r}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},eh=class extends ec{static [t.entityKind]="SQLiteAsyncInsert";_prepare(e=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",e,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"insert",tables:x(this.config.table)})}prepare(){return this._prepare(!0)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this._prepare().execute()}};(0,l.applyMixins)(eh,[a]);var ed=class{static [t.entityKind]="SQLiteRaw";constructor(e,t,i){this.prepared=e,this.sql=t,this.query=i}getSQL(){return this.sql}getQuery(){return this.query}_prepare(){return this.prepared}},ef=class extends ed{static [t.entityKind]="SQLiteAsyncRaw";constructor(e,t,i){super(e,t,i)}execute(e){return this.prepared.execute(e)}};(0,l.applyMixins)(ef,[a]);var em=class extends D{static [t.entityKind]="SQLiteAsyncSelect";_prepare(e=!1){let t=this.dialect.sqlToQuery(this.getSQL()),i=this.config.fieldsFlat,s=this.dialect.mapperGenerators.rows(i,this.joinsNotNullableMap);return this.session.prepareQuery(t,"arrays",e,"all",s,{type:"select",tables:[...this.usedTables]},this.cacheConfig)}prepare(){return this._prepare(!0)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this._prepare().execute()}};(0,l.applyMixins)(em,[a]);var ep=class{static [t.entityKind]="SQLiteUpdateBuilder";constructor(e,t,i,s,r=ey){this.table=e,this.session=t,this.dialect=i,this.withList=s,this.builder=r}set(e){return new this.builder(this.table,(0,l.mapUpdateSet)(this.table,e),this.session,this.dialect,this.withList)}},ey=class{static [t.entityKind]="SQLiteUpdate";config;constructor(e,t,i,s,r){this.session=i,this.dialect=s,this.config={set:t,table:e,withList:r,joins:[]}}from(e){return this.config.from=e,this}createJoin(e){return(i,s)=>{let r=(0,l.getTableLikeName)(i);if("string"==typeof r&&this.config.joins.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if("function"==typeof s){let e=this.config.from?(0,t.is)(i,N.SQLiteTable)?i[$.Table.Symbol.Columns]:(0,t.is)(i,y.Subquery)?i._.selectedFields:(0,t.is)(i,_)?i[b.ViewBaseConfig].selectedFields:void 0:void 0;s=s(new Proxy(this.config.table[$.Table.Symbol.Columns],new T({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new T({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:s,table:i,joinType:e,alias:r}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[$.Table.Symbol.Columns],new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[N.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,l.orderSelectedFields)(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},eg=class extends ey{static [t.entityKind]="SQLiteAsyncUpdate";_prepare(e=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",e,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"update",tables:x(this.config.table)})}prepare(){return this._prepare(!0)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}};(0,l.applyMixins)(eg,[a]);var eb=class{static [t.entityKind]="BaseSQLiteDatabase";query;constructor(e,t,i,s,r){for(const[n,l]of(this.resultKind=e,this.dialect=t,this.session=i,this.forbidJsonb=r,this._={relations:s,session:i,resultKind:e},this.query={},Object.entries(s)))this.query[n]=new d(e,s,s[l.name].table,l,t,i,r,"sync"===e?p:m);this.$cache={invalidate:async e=>{}}}$with=(e,t)=>{let i=this;return{as:s=>("function"==typeof s&&(s=s(new eo(i.dialect))),new Proxy(new y.WithSubquery(s.getSQL(),t??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),e,!0),new T({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}};$count(e,t){return"async"===this.resultKind?new c({source:e,filters:t,session:this.session,dialect:this.dialect}):new h({source:e,filters:t,session:this.session,dialect:this.dialect})}with(...e){let t=this;return{select:function(i){return new F({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e},em)},selectDistinct:function(i){return new F({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0},em)},update:function(i){return new ep(i,t.session,t.dialect,e,eg)},insert:function(i){return new eu(i,t.session,t.dialect,e,eh)},delete:function(i){return new j(i,t.session,t.dialect,e)}}}select(e){return new F({fields:e??void 0,session:this.session,dialect:this.dialect},em)}selectDistinct(e){return new F({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0},em)}update(e){return new ep(e,this.session,this.dialect,void 0,eg)}$cache;insert(e){return new eu(e,this.session,this.dialect,void 0,eh)}delete(e){return new j(e,this.session,this.dialect)}run(e){let t="string"==typeof e?i.sql.raw(e):e.getSQL(),s=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(s,"raw",!1,"run");return"async"===this.resultKind?new ef(r,t,s):this.session.run(t)}all(e){let t="string"==typeof e?i.sql.raw(e):e.getSQL(),s=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(s,"objects",!1,"all");return"async"===this.resultKind?new ef(r,t,s):this.session.objects(t)}get(e){let t="string"==typeof e?i.sql.raw(e):e.getSQL(),s=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(s,"objects",!1,"get");return"async"===this.resultKind?new ef(r,t,s):this.session.object(t)}values(e){let t="string"==typeof e?i.sql.raw(e):e.getSQL(),s=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(s,"objects",!1,"values");return"async"===this.resultKind?new ef(r,t,s):this.session.arrays(t)}transaction(e,t){return this.session.transaction(e,t)}};e.i(663114),e.i(171652);var eq=class{static [t.entityKind]="Cache"},e$=class extends eq{static [t.entityKind]="NoopCache";strategy(){return"all"}async get(e){}async put(e,t,i,s){}async onMutate(e){}};let eS=async(e,t,i,s)=>{if(!i)return{type:"skip"};let{type:r,tables:n}=i;return("insert"===r||"update"===r||"delete"===r)&&n.length>0?{type:"invalidate",tables:n}:s&&s.enabled&&"select"===r?{type:"try",key:s.tag??await ew(e,t),isTag:void 0!==s.tag,autoInvalidate:s.autoInvalidate,tables:i.tables,config:s.config}:{type:"skip"}};async function ew(e,t){let i=`${e}-${JSON.stringify(t,(e,t)=>"bigint"==typeof t?`${t}n`:t)}`,s=new TextEncoder().encode(i);return[...new Uint8Array(await crypto.subtle.digest("SHA-256",s))].map(e=>e.toString(16).padStart(2,"0")).join("")}var ev=class{static [t.entityKind]="SQLiteBasePreparedQuery";mapper;executeMethod;constructor(e,t,i,s){this.query=t,this.mode=s,this.mapper=i,this.executeMethod=e}getQuery(){return this.query}},eQ=class{static [t.entityKind]="SQLiteSession";constructor(e){this.dialect=e}},eL=class extends a{static [t.entityKind]="ExecuteResultSync";constructor(e){super(),this.resultCb=e}async execute(){return this.resultCb()}sync(){return this.resultCb()}},eC=class extends ev{static [t.entityKind]="SQLiteAsyncPreparedQuery";fastPath;constructor(e,i="all",s,r,n,l,a,o,u,c){super(i,r,n,l),this.resultKind=e,this.executors=s,this.logger=a,this.cache=o,this.queryMetadata=u,this.cacheConfig=c,o&&"all"===o.strategy()&&void 0===c&&(this.cacheConfig={enabled:!0,autoInvalidate:!0}),this.cacheConfig?.enabled||(this.cacheConfig=void 0),this.fastPath=void 0===c&&(void 0===o||(0,t.is)(o,e$))}async queryWithCache(e,i,s,r){let n=void 0===this.cache||(0,t.is)(this.cache,e$)?{type:"skip"}:await eS(e,i,this.queryMetadata,this.cacheConfig);if("skip"===n.type)return r().catch(t=>{throw new M(e,i,t)});let a=this.cache;if("invalidate"===n.type)return Promise.all([r(),a.onMutate({tables:n.tables})]).then(e=>e[0]).catch(t=>{throw new M(e,i,t)});if("try"===n.type){let{tables:t,key:l,isTag:o,autoInvalidate:u,config:c}=n,h=`${s}_${l}`,d=await a.get(h,t,o,u);if(void 0===d){let s=await r().catch(t=>{throw new M(e,i,t)});return await a.put(h,s,u?t:[],o,c),s}return d}(0,l.assertUnreachable)(n)}run(e={}){let{query:t,logger:s,executors:r,fastPath:n,resultKind:l}=this,a=t._sql?t._sql.join(" "):t.sql,o=0===t.params.length?t.params:(0,i.fillPlaceholders)(t.params,e);if(s.logQuery(a,o),"sync"===l)try{return r.run(o)}catch(e){throw new M(a,o,e)}return n?r.run(o).catch(e=>{throw new M(a,o,e)}):this.queryWithCache(a,o,"run",()=>r.run(o))}all(e={}){let{query:t,logger:s,executors:r,mapper:n,fastPath:l,resultKind:a}=this,o=t._sql?t._sql.join(" "):t.sql,u=0===t.params.length?t.params:(0,i.fillPlaceholders)(t.params,e);if(s.logQuery(o,u),"sync"===a){let e;try{e=r.all(u)}catch(e){throw new M(o,u,e)}return n?n(e):e}let c=l?r.all(u).catch(e=>{throw new M(o,u,e)}):this.queryWithCache(o,u,"all",()=>r.all(u));return n?c.then(e=>n(e)):c}get(e={}){let{query:t,logger:s,executors:r,mapper:n,fastPath:l,resultKind:a}=this,o=t._sql?t._sql.join(" "):t.sql,u=0===t.params.length?t.params:(0,i.fillPlaceholders)(t.params,e);if(s.logQuery(o,u),"sync"===a){let e;try{e=r.get(u)}catch(e){throw new M(o,u,e)}return e?n?n([e])[0]:e:void 0}let c=l?r.get(u).catch(e=>{throw new M(o,u,e)}):this.queryWithCache(o,u,"get",()=>r.get(u));return n?c.then(e=>e?n([e])[0]:void 0):c.then(e=>e||void 0)}values(e={}){let{query:t,logger:s,executors:r,fastPath:n,resultKind:l}=this,a=t._sql?t._sql.join(" "):t.sql,o=0===t.params.length?t.params:(0,i.fillPlaceholders)(t.params,e);if(s.logQuery(a,o),"sync"===l)try{return r.values(o)}catch(e){throw new M(a,o,e)}return n?r.values(o).catch(e=>{throw new M(a,o,e)}):this.queryWithCache(a,o,"values",()=>r.values(o))}execute(e){return"async"===this.resultKind?this[this.executeMethod](e):new eL(()=>this[this.executeMethod](e))}},eT=class extends eQ{static [t.entityKind]="SQLiteAsyncSession";constructor(e,t){super(e),this.resultKind=t}run(e){return this.prepareQuery(this.dialect.sqlToQuery(e),"raw",!1).run()}objects(e){return this.prepareQuery(this.dialect.sqlToQuery(e),"objects",!1).all()}object(e){return this.prepareQuery(this.dialect.sqlToQuery(e),"objects",!1).get()}arrays(e){return this.prepareQuery(this.dialect.sqlToQuery(e),"arrays",!1).all()}array(e){return this.prepareQuery(this.dialect.sqlToQuery(e),"arrays",!1).get()}},eN=class extends eb{static [t.entityKind]="SQLiteAsyncTransaction";constructor(e,t,i,s,r=0,n){super(e,t,i,s,n),this.nestedIndex=r}rollback(){throw new z}},ex=class e extends eT{static [t.entityKind]="LibSQLSession";logger;cache;constructor(e,t,i,s,r){super(t,"async"),this.client=e,this.relations=i,this.options=s,this.tx=r,this.logger=s.logger??new n,this.cache=s.cache??new e$}prepareQuery(e,t,i,s,r,n,l){let a=this.tx??this.client;return new eC("async",s,{all:i=>a.execute({sql:e.sql,args:i}).then(({rows:e})=>"arrays"===t?e.map(ej):e.map(eB)),get:i=>a.execute({sql:e.sql,args:i}).then(({rows:e})=>e[0]?"arrays"===t?ej(e[0]):eB(e[0]):void 0),run:t=>a.execute({sql:e.sql,args:t}),values:t=>a.execute({sql:e.sql,args:t}).then(({rows:e})=>e.map(ej))},e,r,t,this.logger,this.cache,n,l)}async batch(e,t){let i=[],s=[];for(let t of e){let e=t._prepare(),r=e.getQuery();i.push(e),s.push({sql:r.sql,args:r.params})}return(await (t?this.client.migrate(s):(this.tx??this.client).batch(s))).map((e,t)=>{let{executeMethod:s,mapper:r,mode:n}=i[t];if("run"===s)return e;if("values"===s)return e.rows;if("get"===s){let t=e.rows[0];if(!t)return;let i="arrays"===n?ej(t):eB(t);return r?r([i])[0]:i}let{rows:l}=e,a="arrays"===n?l.map(ej):l.map(eB);return r?r(a):a})}async migrate(e){return this.batch(e,!0)}async transaction(t,i){let s=await this.client.transaction(),r=new e(this.client,this.dialect,this.relations,this.options,s),n=new eA("async",this.dialect,r,this.relations);try{let e=await t(n);return await s.commit(),e}catch(e){throw await s.rollback(),e}}},eA=class e extends eN{static [t.entityKind]="LibSQLTransaction";async transaction(t){let s=`sp${this.nestedIndex}`,r=new e("async",this.dialect,this.session,this._.relations,this.nestedIndex+1);await this.session.run(i.sql.raw(`savepoint ${s}`));try{let e=await t(r);return await this.session.run(i.sql.raw(`release savepoint ${s}`)),e}catch(e){throw await this.session.run(i.sql.raw(`rollback to savepoint ${s}`)),e}}};function ej(e){return Array.prototype.slice.call(e)}function eB(e){return Object.keys(e).reduce((t,i)=>(Object.prototype.propertyIsEnumerable.call(e,i)&&(t[i]=e[i]),t),{})}var e_=class extends eb{static [t.entityKind]="LibSQLDatabase";async batch(e){return this.session.batch(e)}};e.s(["LibSQLDatabase",0,e_,"construct",0,function(e,t={}){let i,s=new ea({useJitMappers:(0,l.jitCompatCheck)(t.jit)});!0===t.logger?i=new r:!1!==t.logger&&(i=t.logger);let n=t.relations??{},a=new e_("async",s,new ex(e,s,n,{logger:i,cache:t.cache},void 0),n);return a.$client=e,a.$cache=t.cache,a.$cache&&(a.$cache.invalidate=t.cache?.onMutate),a}],925369)},429330,e=>e.a(async(t,i)=>{try{var s=e.i(925369),r=e.i(418520),n=t([r]);function l(...e){if("string"==typeof e[0])return(0,s.construct)((0,r.createClient)({url:e[0]}),e[1]);let{connection:t,client:i,...n}=e[0];return i?(0,s.construct)(i,n):(0,s.construct)("string"==typeof t?(0,r.createClient)({url:t}):(0,r.createClient)(t),n)}[r]=n.then?(await n)():n,(l||(l={})).mock=function(e){return(0,s.construct)({},e)},e.s(["drizzle",0,l]),i()}catch(e){i(e)}},!1),663114,171652,e=>{"use strict";e.s(["formatToMillis",0,function(e){return Date.UTC(parseInt(e.slice(0,4),10),parseInt(e.slice(4,6),10)-1,parseInt(e.slice(6,8),10),parseInt(e.slice(8,10),10),parseInt(e.slice(10,12),10),parseInt(e.slice(12,14),10))},"getMigrationsToRun",0,function(e){let{localMigrations:t,dbMigrations:i}=e,s=new Set(i.map(e=>e.name).filter(e=>null!==e));return t.filter(e=>!e.name||!s.has(e.name))}],663114);let t=e=>+!!e.includes("name");var i=e.i(533102);let s={0:(e,t,s)=>{let r=i.sql`${i.sql.identifier(e)}`,n=t.objects(i.sql`SELECT id, hash, created_at FROM ${r} ORDER BY id ASC`);s.sort((e,t)=>e.folderMillis!==t.folderMillis?e.folderMillis-t.folderMillis:(e.name??"").localeCompare(t.name??""));let l=new Map,a=new Map;for(let e of s)l.has(e.folderMillis)||l.set(e.folderMillis,[]),l.get(e.folderMillis).push(e),a.set(e.hash,e);let o=[],u=[];for(let e of n){let t,i=String(e.created_at),s=Number(i.substring(0,i.length-3)+"000"),r=l.get(s),n=null;r&&1===r.length?(t=r[0],n="millis"):r&&r.length>1?(t=r.find(t=>t.hash&&e.hash&&t.hash===e.hash))&&(n="hash"):(t=a.get(e.hash))&&(n="hash"),t?o.push({id:e.id,name:t.name,hash:e.hash,created_at:i,matchedBy:e.id?"id":n}):u.push(e)}if(u.length>0)throw Error(`While upgrading your database migrations table we found ${u.length} (${u.map(e=>`[id: ${e.id}, created_at: ${e.created_at}]`).join(", ")}) migrations in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`);t.transaction(e=>{for(let t of(e.run(i.sql`ALTER TABLE ${r} ADD COLUMN ${i.sql.identifier("name")} text`),e.run(i.sql`ALTER TABLE ${r} ADD COLUMN ${i.sql.identifier("applied_at")} TEXT`),o)){let s=i.sql`UPDATE ${r} SET ${i.sql.identifier("name")} = ${t.name}, ${i.sql.identifier("applied_at")} = NULL WHERE`;t.id?s.append(i.sql` ${i.sql.identifier("id")} = ${t.id}`):"millis"===t.matchedBy?s.append(i.sql` ${i.sql.identifier("created_at")} = ${t.created_at}`):s.append(i.sql` ${i.sql.identifier("hash")} = ${t.hash}`),e.run(s)}})}};async function r(e,s,r){if(0===(await s.session.objects(i.sql`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ${e}`)).length)return{newDb:!0};let l=t((await s.session.objects(i.sql`SELECT name as column_name FROM pragma_table_info(${e})`)).map(e=>e.column_name));for(let t=l;t<1;t++){let i=n[t];if(!i)throw Error(`No upgrade path from migration table version ${t} to ${t+1}`);await i(e,s,r)}return{newDb:!1}}let n={0:async(e,t,s)=>{let r=i.sql`${i.sql.identifier(e)}`,n=await t.session.objects(i.sql`SELECT id, hash, created_at FROM ${r} ORDER BY id ASC`);s.sort((e,t)=>e.folderMillis!==t.folderMillis?e.folderMillis-t.folderMillis:(e.name??"").localeCompare(t.name??""));let l=new Map,a=new Map;for(let e of s)l.has(e.folderMillis)||l.set(e.folderMillis,[]),l.get(e.folderMillis).push(e),a.set(e.hash,e);let o=[],u=[];for(let e of n){let t,i=String(e.created_at),s=Number(i.substring(0,i.length-3)+"000"),r=l.get(s),n=null;r&&1===r.length?(t=r[0],n="millis"):r&&r.length>1?(t=r.find(t=>t.hash&&e.hash&&t.hash===e.hash))&&(n="hash"):(t=a.get(e.hash))&&(n="hash"),t?o.push({id:e.id,name:t.name,hash:e.hash,created_at:i,matchedBy:e.id?"id":n}):u.push(e)}if(u.length>0)throw Error(`While upgrading your database migrations table we found ${u.length} (${u.map(e=>`[id: ${e.id}, created_at: ${e.created_at}]`).join(", ")}) migrations in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`);let c=[i.sql`ALTER TABLE ${r} ADD COLUMN ${i.sql.identifier("name")} text`,i.sql`ALTER TABLE ${r} ADD COLUMN ${i.sql.identifier("applied_at")} TEXT`];for(let e of o){let t=i.sql`UPDATE ${r} SET ${i.sql.identifier("name")} = ${e.name}, ${i.sql.identifier("applied_at")} = NULL WHERE`;e.id?t.append(i.sql` ${i.sql.identifier("id")} = ${e.id}`):"millis"===e.matchedBy?t.append(i.sql` ${i.sql.identifier("created_at")} = ${e.created_at}`):t.append(i.sql` ${i.sql.identifier("hash")} = ${e.hash}`),c.push(t)}await t.transaction(async e=>{for(let t of c)await e.run(t)})}};e.s(["upgradeAsyncIfNeeded",0,r,"upgradeSyncIfNeeded",0,function(e,r,n){if(0===r.objects(i.sql`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ${e}`).length)return{newDb:!0};let l=t(r.objects(i.sql`SELECT name as column_name FROM pragma_table_info(${e})`).map(e=>e.column_name));for(let t=l;t<1;t++){let i=s[t];if(!i)throw Error(`No upgrade path from migration table version ${t} to ${t+1}`);i(e,r,n)}return{newDb:!1}}],171652)},336763,e=>{"use strict";var t=e.i(533102),i=e.i(539774),s=e.i(725490),r=e.i(763369);function n(e,n){return!(0,t.isDriverValueEncoder)(n)||(0,t.isSQLWrapper)(e)||(0,i.is)(e,t.Param)||(0,i.is)(e,t.Placeholder)||(0,i.is)(e,r.Column)||(0,i.is)(e,s.Table)||(0,i.is)(e,t.View)?e:new t.Param(e,n)}e.s(["and",0,function(...e){let i=e.filter(e=>void 0!==e);if(0!==i.length)return new t.SQL(1===i.length?i:[new t.StringChunk("("),t.sql.join(i.map(e=>t.sql`(${e})`),new t.StringChunk(" and ")),new t.StringChunk(")")])},"arrayContained",0,function(e,i){if(Array.isArray(i)){if(0===i.length)throw Error("arrayContained requires at least one value");let s=n(i,e);return t.sql`${e} <@ ${t.sql`${Array.isArray(s)?new t.Param(s):s}`}`}return t.sql`${e} <@ ${n(i,e)}`},"arrayContains",0,function(e,i){if(Array.isArray(i)){if(0===i.length)throw Error("arrayContains requires at least one value");let s=n(i,e);return t.sql`${e} @> ${t.sql`${Array.isArray(s)?new t.Param(s):s}`}`}return t.sql`${e} @> ${n(i,e)}`},"arrayOverlaps",0,function(e,i){if(Array.isArray(i)){if(0===i.length)throw Error("arrayOverlaps requires at least one value");let s=n(i,e);return t.sql`${e} && ${t.sql`${Array.isArray(s)?new t.Param(s):s}`}`}return t.sql`${e} && ${n(i,e)}`},"between",0,function(e,i,s){return t.sql`${e} between ${n(i,e)} and ${n(s,e)}`},"eq",0,(e,i)=>t.sql`${e} = ${n(i,e)}`,"exists",0,function(e){return t.sql`exists ${e}`},"gt",0,(e,i)=>t.sql`${e} > ${n(i,e)}`,"gte",0,(e,i)=>t.sql`${e} >= ${n(i,e)}`,"ilike",0,function(e,i){return t.sql`${e} ilike ${i}`},"inArray",0,function(e,i){return Array.isArray(i)?0===i.length?t.sql`false`:t.sql`${e} in ${i.map(t=>n(t,e))}`:t.sql`${e} in ${n(i,e)}`},"isNotNull",0,function(e){return t.sql`(${e} is not null)`},"isNull",0,function(e){return t.sql`(${e} is null)`},"like",0,function(e,i){return t.sql`${e} like ${i}`},"lt",0,(e,i)=>t.sql`${e} < ${n(i,e)}`,"lte",0,(e,i)=>t.sql`${e} <= ${n(i,e)}`,"ne",0,(e,i)=>t.sql`${e} <> ${n(i,e)}`,"not",0,function(e){return(0,i.is)(e,t.SQL)?t.sql`not (${e})`:t.sql`not ${e}`},"notBetween",0,function(e,i,s){return t.sql`${e} not between ${n(i,e)} and ${n(s,e)}`},"notExists",0,function(e){return t.sql`not exists ${e}`},"notIlike",0,function(e,i){return t.sql`${e} not ilike ${i}`},"notInArray",0,function(e,i){return Array.isArray(i)?0===i.length?t.sql`true`:t.sql`${e} not in ${i.map(t=>n(t,e))}`:t.sql`${e} not in ${n(i,e)}`},"notLike",0,function(e,i){return t.sql`${e} not like ${i}`},"or",0,function(...e){let i=e.filter(e=>void 0!==e);if(0!==i.length)return new t.SQL(1===i.length?i:[new t.StringChunk("("),t.sql.join(i.map(e=>t.sql`(${e})`),new t.StringChunk(" or ")),new t.StringChunk(")")])}])},396918,e=>{"use strict";var t=e.i(533102);e.s(["asc",0,function(e){return t.sql`${e} asc`},"desc",0,function(e){return t.sql`${e} desc`}])},533102,539774,767874,763369,76519,725490,155464,731902,e=>{"use strict";let t=Symbol.for("drizzle:entityKind");function i(e,i){if(!e||"object"!=typeof e)return!1;if(e instanceof i)return!0;if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Class "${i.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let s=Object.getPrototypeOf(e)?.constructor;if(s)for(;s;){if(t in s&&s[t]===i[t])return!0;s=Object.getPrototypeOf(s)}return!1}Symbol.for("drizzle:hasOwnEntityKind"),e.s(["entityKind",0,t,"is",0,i],539774);let s=Symbol.for("drizzle:OriginalColumn");e.s(["OriginalColumn",0,s],767874);let r=e=>e;r.isNoop=!0;var n,l=class{static [t]="Column";codec;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;length;isLengthExact;isAlias;config;table;onInit(){}constructor(e,t){this.config=t,this.onInit(),this.table=e,this.name=t.name,this.isAlias=!1,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity,this.length=t.length,this.isLengthExact=t.isLengthExact}mapFromDriverValue=r;mapToDriverValue=r;postBuild(){return this}shouldDisableInsert(){return void 0!==this.config.generated&&"byDefault"!==this.config.generated.type}[s](){return this}};e.s(["Column",0,l],763369);let a=Symbol.for("drizzle:Name");e.s(["TableName",0,a],76519);let o=Symbol.for("drizzle:Schema"),u=Symbol.for("drizzle:Columns"),c=Symbol.for("drizzle:ExtraConfigColumns"),h=Symbol.for("drizzle:OriginalName"),d=Symbol.for("drizzle:BaseName"),f=Symbol.for("drizzle:IsAlias"),m=Symbol.for("drizzle:ExtraConfigBuilder"),p=Symbol.for("drizzle:IsDrizzleTable");var y=class{static [t]="Table";static Symbol={Name:a,Schema:o,OriginalName:h,Columns:u,ExtraConfigColumns:c,BaseName:d,IsAlias:f,ExtraConfigBuilder:m};[a];[h];[o];[u];[c];[d];[f]=!1;[p]=!0;[m]=void 0;constructor(e,t,i){this[a]=this[h]=e,this[o]=t,this[d]=i}};e.s(["IsAlias",0,f,"OriginalName",0,h,"Table",0,y,"TableColumns",0,u,"TableSchema",0,o,"getTableName",0,function(e){return e[a]}],725490);var g=class{static [t]="Subquery";constructor(e,t,i,s=!1,r=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:i,isWith:s,usedTables:r}}},b=class extends g{static [t]="WithSubquery"};e.s(["Subquery",0,g,"WithSubquery",0,b],155464);let q=Symbol.for("drizzle:ViewBaseConfig");function $(e){return null!=e&&"function"==typeof e.getSQL}e.s(["ViewBaseConfig",0,q],731902);var S=class{static [t]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new w([this])}},w=class e{static [t]="SQL";decoder=Q;shouldInlineParams=!1;usedTables=[];constructor(e){for(const t of(this.queryChunks=e,e))if(i(t,y)){const e=t[y.Symbol.Schema];this.usedTables.push(void 0===e?t[y.Symbol.Name]:e+"."+t[y.Symbol.Name])}}append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return(t=>{let i=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":i.sql,"drizzle.query.params":JSON.stringify(i.params)}),i})()}buildQueryFromSourceParams(t,s){let r=Object.assign({},s,{inlineParams:s.inlineParams||this.shouldInlineParams,paramStartIndex:s.paramStartIndex||{value:0}}),{escapeName:n,escapeParam:a,codecs:o,inlineParams:u,paramStartIndex:c,invokeSource:h}=r,d=t.map(t=>{if(i(t,S))return{sql:t.value.join(""),params:[]};if(i(t,v))return{sql:n(t.value),params:[]};if(void 0===t)return{sql:"",params:[]};if(Array.isArray(t)){let e=[new S("(")];for(let[i,s]of t.entries())e.push(s),i<t.length-1&&e.push(new S(", "));return e.push(new S(")")),this.buildQueryFromSourceParams(e,r)}if(i(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:u||t.shouldInlineParams});if(i(t,y)){let e=t[y.Symbol.Schema],i=t[y.Symbol.Name];return"mssql-view-with-schemabinding"===h?{sql:(void 0===e?n("dbo"):n(e))+"."+n(i),params:[]}:{sql:void 0===e||t[f]?n(i):n(e)+"."+n(i),params:[]}}if(i(t,l)){let e=t.name;if("indexes"===s.invokeSource)return{sql:n(e),params:[]};let i="mssql-check"===h?void 0:t.table[y.Symbol.Schema];return{sql:t.isAlias?n(t.name):t.table[f]||void 0===i?n(t.table[y.Symbol.Name])+"."+n(e):n(i)+"."+n(t.table[y.Symbol.Name])+"."+n(e),params:[]}}if(i(t,j)){let e=t[q].schema,i=t[q].name;return{sql:void 0===e||t[q].isAlias?n(i):n(e)+"."+n(i),params:[]}}if(i(t,C)){let s;if(i(t.value,e))return this.buildQueryFromSourceParams([t.value],r);let n=o&&i(t.encoder,l);if(i(t.value,x)){let e=a(c.value++,t);return t.codec=n?e=>o.apply(t.encoder,"normalizeParam",e):void 0,{sql:n?o.apply(t.encoder,"castParam",e):e,params:[t]}}if(null===t.value)s=t.value;else{if(i(s=t.encoder.mapToDriverValue.isNoop?t.value:t.encoder.mapToDriverValue(t.value),e))return this.buildQueryFromSourceParams([s],r);n&&(s=o.apply(t.encoder,"normalizeParam",s))}if(u)return{sql:this.mapInlineParam(s,r),params:[]};let h=a(c.value++,s);return{sql:n?o.apply(t.encoder,"castParam",h):h,params:[s]}}return i(t,x)?{sql:a(c.value++,t),params:[t]}:i(t,e.Aliased)&&void 0!==t.fieldAlias?{sql:(void 0!==t.origin?n(t.origin)+".":"")+n(t.fieldAlias),params:[]}:i(t,g)?t._.isWith?{sql:n(t._.alias),params:[]}:this.buildQueryFromSourceParams([new S("("),t._.sql,new S(") "),new v(t._.alias)],r):"function"==typeof t&&"enumName"in t?"schema"in t&&t.schema?{sql:n(t.schema)+"."+n(t.enumName),params:[]}:{sql:n(t.enumName),params:[]}:$(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new S("("),t.getSQL(),new S(")")],r):u?{sql:this.mapInlineParam(t,r),params:[]}:{sql:a(c.value++,t),params:[t]}});if(s.tagged){let e={sql:"",params:[]},t=[];for(let i of d)t.push(i.sql),e.params.push(...i.params);return e._sql=Object.assign(t,{raw:t}),e}let m={sql:"",params:[]};for(let e of d)m.sql+=e.sql,m.params.push(...e.params);return m}mapInlineParam(e,{escapeString:t}){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return e.toString();if("string"==typeof e)return t(e);if("object"==typeof e){let i=e.toString();return"[object Object]"===i?t(JSON.stringify(e)):t(i)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(t){return void 0===t?this:new e.Aliased(this,t)}mapWith(e){return this.decoder="function"==typeof e?{mapFromDriverValue:e}:e,this}nullable(){return this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},v=class{static [t]="Name";brand;constructor(e){this.value=e}getSQL(){return new w([this])}};let Q={mapFromDriverValue:e=>e};Q.mapFromDriverValue.isNoop=!0;let L={mapToDriverValue:e=>e};L.mapToDriverValue.isNoop=!0;var C=class{static [t]="Param";brand;constructor(e,t=L,i){this.value=e,this.encoder=t,this.codec=i}getSQL(){return new w([this])}};function T(e,...t){let i=[];for(let[s,r]of((t.length>0||e.length>0&&""!==e[0])&&i.push(new S(e[0])),t.entries()))i.push(r,new S(e[s+1]));return new w(i)}function N(e){let t=N.encodeInput(e);return t.length?`/*${t}*/`:""}(n=T||(T={})).empty=function(){return new w([])},n.fromList=function(e){return new w(e)},n.raw=function(e){return new w([new S(e)])},n.join=function(e,t){let i=[];for(let[s,r]of e.entries())s>0&&void 0!==t&&i.push(t),i.push(r);return new w(i)},n.identifier=function(e){return new v(e)},n.placeholder=function(e){return new x(e)},n.param=function(e,t){return new C(e,t)},n.comment=function(e){let t=N(e);if(t.length)return T.raw(t)},function(e){function t(e){if("string"==typeof e)return e.length?s(e):e;let t=[];for(let[s,r]of Object.entries(e)){if(null==r||""===r)continue;let e=i(s),n=i(String(r));t.push(`${e}='${n}'`)}return t.length?t.sort().join(","):""}function i(e){return encodeURIComponent(e).replace(/'/g,"\\'")}function s(e){return e.replace(/\/\*/g,"/ *").replace(/\*\//g,"* /")}e.merge=function(e,i){let s;if("object"==typeof e&&"object"==typeof i)s=t({...e,...i});else if(e&&i)s=[t(e),t(i)].filter(e=>e.length).join(",");else if(i)s=t(i);else{if(!e)return"";s=t(e)}return s.length?`/*${s}*/`:""},e.encodeInput=t,e.sanitizeObjectElement=i,e.sanitizeStringInput=s}(N||(N={})),(w||(w={})).Aliased=class e{static [t]="SQL.Aliased";isSelectionField=!1;origin;constructor(e,t){this.sql=e,this.fieldAlias=t}getSQL(){return this.sql}clone(){return new e(this.sql,this.fieldAlias)}};var x=class{static [t]="Placeholder";constructor(e){this.name=e}getSQL(){return new w([this])}};let A=Symbol.for("drizzle:IsDrizzleView");var j=class{static [t]="View";[q];[A]=!0;get[a](){return this[q].name}get[o](){return this[q].schema}get[f](){return this[q].isAlias}get[h](){return this[q].originalName}get[u](){return this[q].selectedFields}constructor({name:e,schema:t,selectedFields:i,query:s}){this[q]={name:e,originalName:e,schema:t,selectedFields:i,query:s,isExisting:!s,isAlias:!1}}};l.prototype.getSQL=function(){return new w([this])},g.prototype.getSQL=function(){return new w([this])},e.s(["Param",0,C,"Placeholder",0,x,"SQL",0,w,"StringChunk",0,S,"View",0,j,"fillPlaceholders",0,function(e,t){return e.map(e=>{if(i(e,x)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(i(e,C)&&i(e.value,x)){if(!(e.value.name in t))throw Error(`No value for placeholder "${e.value.name}" was provided`);let i=t[e.value.name];if(null===i)return i;let s=e.encoder.mapToDriverValue.isNoop?i:e.encoder.mapToDriverValue(i);return e.codec?e.codec(s):s}return e})},"isDriverValueEncoder",0,function(e){return"object"==typeof e&&null!==e&&"mapToDriverValue"in e&&"function"==typeof e.mapToDriverValue},"isSQLWrapper",0,$,"noopDecoder",0,Q,"sql",0,T],533102)},284346,502765,827194,581731,651840,97141,117381,173431,282276,e=>{"use strict";var t,i=e.i(539774),s=e.i(763369),r=e.i(725490),n=e.i(533102),l=e.i(155464),a=e.i(731902);let o=Object.getPrototypeOf(()=>null).constructor;function u(e){let t=e.getSQL();if((0,i.is)(t.decoder,s.Column))return t.decoder}function c(e,t){return{name:"string"==typeof e&&e.length>0?e:"",config:"object"==typeof e?e:t}}let h="u"<typeof TextDecoder?null:new TextDecoder;e.s(["FnConstructor",0,o,"applyMixins",0,function(e,t){for(let i of t)for(let t of Object.getOwnPropertyNames(i.prototype))"constructor"!==t&&Object.defineProperty(e.prototype,t,Object.getOwnPropertyDescriptor(i.prototype,t)||Object.create(null))},"assertUnreachable",0,function(e){throw Error("Didn't expect to get here")},"getColumnFromDecoder",0,u,"getColumnNameAndConfig",0,c,"getTableColumns",0,function(e){return e[r.Table.Symbol.Columns]},"getTableLikeName",0,function(e){return(0,i.is)(e,l.Subquery)?e._.alias:(0,i.is)(e,n.View)?e[a.ViewBaseConfig].name:(0,i.is)(e,n.SQL)?void 0:e[r.Table.Symbol.IsAlias]?e[r.Table.Symbol.Name]:e[r.Table.Symbol.BaseName]},"haveSameKeys",0,function(e,t){let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let[e,t]of i.entries())if(t!==s[e])return!1;return!0},"jitCompatCheck",0,function(e){if(!e)return!1;try{let e=new o("input",'"use strict"; return input;')(!0);return!0!==e&&(console.warn("Unable to use jit mappers due to incompatibility: corrupted jit function output.\nFalling back to premade mappers.\nError details:"),console.error(`Expected to receive \`true\`, got: ${e}`)),!0}catch(e){return console.warn("Unable to use jit mappers due to incompatibility.\nFalling back to premade mappers.\nError details:"),console.error(e),!1}},"makeDefaultQueryMapper",0,function(e,t){let a=e.map(({field:e,codec:a,arrayDimensions:o,path:u})=>{let c,h;if((0,i.is)(e,s.Column)){if(h=e,t&&2===u.length){let t=u[0];c=(i,s)=>{t in i?"string"==typeof i[t]&&i[t]!==(0,r.getTableName)(e.table)&&(i[t]=!1):i[t]=null===s&&(0,r.getTableName)(e.table)}}}else h=(0,i.is)(e,n.SQL)?e.decoder:(0,i.is)(e,l.Subquery)?e._.sql.decoder:e.sql.decoder;return[h.mapFromDriverValue.isNoop?a?e=>a(e,o):void 0:a?e=>h.mapFromDriverValue(a(e,o)):e=>h.mapFromDriverValue(e),c]});return i=>i.map(i=>{let s={},r=e.reduce((e,{path:t},r)=>{let n=e;for(let[e,l]of t.entries())if(e<t.length-1)l in n||(n[l]={}),n=n[l];else{let[e,t]=a[r],o=i[r],u=n[l]=null===o?null:e?e(o):o;t?.(s,u)}return e},{});if(t&&Object.keys(s).length>0)for(let[e,i]of Object.entries(s))"string"!=typeof i||t[i]||(r[e]=null);return r})},"makeJitQueryMapper",0,function(e,t){let a=` "use strict";
|
|
6
|
+
const { columns } = this;
|
|
7
|
+
const { length } = rows;
|
|
8
|
+
const mapped = Array.from({ length });
|
|
9
|
+
${function(e,t={}){let a=[],o=[];o.push(`const [ ${e.map((e,t)=>`c${t}`).join(", ")} ] = rows[i];`);let u={},c={},h=Array.from({length:e.length});for(let o=0;o<e.length;++o){let d,f,m,{field:p,path:y,codec:g,arrayDimensions:b}=e[o],q=!1;(0,i.is)(p,s.Column)?(q=!0,d=p,m=`field: decoder${o}`):(0,i.is)(p,n.SQL)?(d=p.decoder,m=`field: { decoder: decoder${o} }`):(0,i.is)(p,l.Subquery)?(d=p._.sql.decoder,m=`field: { _: { sql: { decoder: decoder${o} } } }`):(d=p.sql.decoder,m=`field: { sql: { decoder: decoder${o} } }`),f=`decoder${o}.mapFromDriverValue`,d.mapFromDriverValue.isNoop&&(f=""),f?a.push(`const { ${m}${g?`, codec: codec${o}`:""} } = columns[${o}];`):g&&a.push(`const { codec: codec${o} } = columns[${o}];`);let $=`c${o}`,S=$;if(g&&(S=`codec${o}(${S}, ${b})`),f&&(S=`${f}(${S})`),h[o]=$===S?`${$}`:`${$} === null ? ${$} : ${S}`,2!==y.length||!q)continue;void 0===c[y[0]]?c[y[0]]=[`c${o}`]:c[y[0]]?.push(`c${o}`);let[w]=y,v=(0,r.getTableName)(p.table);u[w]=!t[v]&&("string"==typeof u[w]?u[w]===v&&v:v)}o.push("mapped[i] = {");let d=[];for(let t=0;t<e.length;++t){let{path:i}=e[t],s=i.map(e=>JSON.stringify(e)),r=h[t],n=i.slice(0,-1),l=0;for(;l<d.length&&l<n.length&&d[l]===n[l];)l++;for(let e=d.length-1;e>=l;--e)o.push(`${" ".repeat(e+1)}},`);for(let e=l;e<n.length;++e)o.push(`${" ".repeat(e+1)}${s[e]}: ${0===e&&1===n.length&&"string"==typeof u[i[0]]?`${c[i[0]]?.map(e=>`${e} === null`).join(" && ")} ? null : {`:"{"}`);d=n,o.push(`${" ".repeat(i.length)}${s[i.length-1]}: ${r},`)}for(let e=d.length-1;e>=0;--e)o.push(`${" ".repeat(e+1)}},`);return o.push("};"),`${a.length?`${a.join("\n ")}
|
|
10
|
+
`:""}for (let i = 0; i < length; ++i) {
|
|
11
|
+
${o.join("\n ")}
|
|
12
|
+
}`}(e,t)}
|
|
13
|
+
return mapped;
|
|
14
|
+
//# sourceURL=drizzle:jit-query-mapper`;return Object.assign(new o("rows",a).bind({columns:e}),{body:`function jitQueryMapper (rows) {
|
|
15
|
+
${a}
|
|
16
|
+
}`})},"mapUpdateSet",0,function(e,t){let l=Object.entries(t).filter(([,e])=>void 0!==e).map(([t,l])=>(0,i.is)(l,n.SQL)||(0,i.is)(l,s.Column)?[t,l]:[t,new n.Param(l,e[r.Table.Symbol.Columns][t])]);if(0===l.length)throw Error("No values to set");return Object.fromEntries(l)},"orderSelectedFields",0,function e(t,a,o){return Object.entries(t).reduce((t,[c,h])=>{if("string"!=typeof c)return t;let d=a?[...a,c]:[c];if((0,i.is)(h,s.Column))t.push({path:d,field:h,codec:o?.get(h,"normalize"),arrayDimensions:h.dimensions,column:h});else if((0,i.is)(h,n.SQL)||(0,i.is)(h,n.SQL.Aliased)){let e=u(h);t.push(e?{path:d,field:h,codec:o?.get(e,"normalize"),arrayDimensions:e.dimensions,column:e}:{path:d,field:h})}else if((0,i.is)(h,l.Subquery)){let e,r,l=Object.values(h._.selectedFields)[0];(0,i.is)(l,s.Column)?(e=l,r=l):(0,i.is)(l,n.SQL)?(e=u(l),r=l.decoder):(e=u(l),r=l.sql.decoder),r&&(h._.sql.decoder=r),t.push(e?{path:d,field:h,codec:o?.get(e,"normalize"),arrayDimensions:e.dimensions,column:e}:{path:d,field:h})}else(0,i.is)(h,r.Table)?t.push(...e(h[r.Table.Symbol.Columns],d,o)):t.push(...e(h,d,o));return t},[])},"textDecoder",0,h],284346);var d=s,f=class{static [i.entityKind]="ColumnBuilder";config;constructor(e,t,i){this.config={name:e,keyAsName:""===e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:i,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e,t){""===this.config.name&&(this.config.name=t(e))}},m=e.i(76519),p=class{static [i.entityKind]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:i,foreignColumns:s}=e();return{name:t,columns:i,foreignTable:s[0].table,foreignColumns:s}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new y(e,this)}},y=class{static [i.entityKind]="SQLiteForeignKey";reference;onUpdate;onDelete;constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(e=>e.name),r=i.map(e=>e.name),n=[this.table[m.TableName],...s,i[0].table[m.TableName],...r];return e??`${n.join("_")}_fk`}isNameExplicit(){return!!this.reference().name}};e.s(["ForeignKeyBuilder",0,p],502765);var g=class extends f{static [i.entityKind]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:s})=>{let r;return r=new p(()=>({columns:[e],foreignColumns:[i()]})),s.onUpdate&&r.onUpdate(s.onUpdate),s.onDelete&&r.onDelete(s.onDelete),r.build(t)})}},b=class extends d.Column{static [i.entityKind]="SQLiteColumn";table;constructor(e,t){super(e,t),this.table=e}};function q(e){let t="";for(let i=0;i<e.length;i+=2)t+=String.fromCodePoint(Number.parseInt(e.slice(i,i+2),16));return t}e.s(["SQLiteColumn",0,b,"SQLiteColumnBuilder",0,g],827194);var $=class extends g{static [i.entityKind]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint int64","SQLiteBigInt")}build(e){return new S(e,this.config)}},S=class extends b{static [i.entityKind]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue=e=>"string"==typeof e?BigInt(q(e)):"u">typeof Buffer&&Buffer.from?BigInt((Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e)).toString("utf8")):BigInt(h.decode(e));mapToDriverValue=e=>Buffer.from(e.toString())},w=class extends g{static [i.entityKind]="SQLiteBlobJsonBuilder";constructor(e){super(e,"object json","SQLiteBlobJson")}build(e){return new v(e,this.config)}},v=class extends b{static [i.entityKind]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue=e=>"string"==typeof e?JSON.parse(q(e)):"u">typeof Buffer&&Buffer.from?JSON.parse((Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e)).toString("utf8")):JSON.parse(h.decode(e));mapToDriverValue=e=>Buffer.from(JSON.stringify(e))},Q=class extends g{static [i.entityKind]="SQLiteBlobBufferBuilder";constructor(e){super(e,"object buffer","SQLiteBlobBuffer")}build(e){return new L(e,this.config)}},L=class extends b{static [i.entityKind]="SQLiteBlobBuffer";mapFromDriverValue=e=>Buffer.isBuffer(e)?e:"string"==typeof e?Buffer.from(e,"hex"):Buffer.from(e);getSQLType(){return"blob"}};function C(e,t){let{name:i,config:s}=c(e,t);return s?.mode==="bigint"?new $(i):s?.mode==="buffer"?new Q(i):new w(i)}var T=class extends g{static [i.entityKind]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new N(e,this.config)}},N=class extends b{static [i.entityKind]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;mapJson;forJsonSelect;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver,this.mapJson=t.customTypeParams.fromJson,this.forJsonSelect=t.customTypeParams.forJsonSelect}getSQLType(){return this.sqlName}mapFromDriverValue=e=>"function"==typeof this.mapFrom?this.mapFrom(e):e;mapFromJsonValue(e){return"function"==typeof this.mapJson?this.mapJson(e):this.mapFromDriverValue(e)}jsonSelectIdentifier(e,t){if("function"==typeof this.forJsonSelect)return this.forJsonSelect(e,t);let i=this.getSQLType().toLowerCase(),s=i.indexOf("(");switch(s+1?i.slice(0,s):i){case"numeric":case"decimal":case"bigint":return t`cast(${e} as text)`;case"blob":return t`hex(${e})`;default:return e}}mapToDriverValue=e=>"function"==typeof this.mapTo?this.mapTo(e):e};function x(e){return(t,i)=>{let{name:s,config:r}=c(t,i);return new T(s,r,e)}}var A=class extends g{static [i.entityKind]="SQLiteBaseIntegerBuilder";constructor(e,t,i){super(e,t,i),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},j=class extends b{static [i.entityKind]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}},B=class extends A{static [i.entityKind]="SQLiteIntegerBuilder";constructor(e){super(e,"number int53","SQLiteInteger")}build(e){return new _(e,this.config)}},_=class extends j{static [i.entityKind]="SQLiteInteger"},O=class extends A{static [i.entityKind]="SQLiteTimestampBuilder";constructor(e,t){super(e,"object date","SQLiteTimestamp"),this.config.mode=t}defaultNow(){return this.default(n.sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new F(e,this.config)}},F=class extends j{static [i.entityKind]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue=e=>new Date("string"==typeof e?e.replaceAll('"',""):"timestamp"===this.config.mode?1e3*e:e);mapToDriverValue=e=>{if("number"==typeof e)return e;let t=e.getTime();return"timestamp"===this.config.mode?Math.floor(t/1e3):t}},D=class extends A{static [i.entityKind]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t}build(e){return new K(e,this.config)}},K=class extends j{static [i.entityKind]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue=e=>1===Number(e);mapToDriverValue=e=>+!!e};function P(e,t){let{name:i,config:s}=c(e,t);return s?.mode==="timestamp"||s?.mode==="timestamp_ms"?new O(i,s.mode):s?.mode==="boolean"?new D(i,s.mode):new B(i)}e.s(["int",0,P,"integer",0,P],581731);var k=class extends g{static [i.entityKind]="SQLiteNumericBuilder";constructor(e){super(e,"string numeric","SQLiteNumeric")}build(e){return new E(e,this.config)}},E=class extends b{static [i.entityKind]="SQLiteNumeric";mapFromDriverValue=e=>"string"==typeof e?e:String(e);getSQLType(){return"numeric"}},V=class extends g{static [i.entityKind]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new I(e,this.config)}},I=class extends b{static [i.entityKind]="SQLiteNumericNumber";mapFromDriverValue=e=>"number"==typeof e?e:Number(e);mapToDriverValue=String;getSQLType(){return"numeric"}},J=class extends g{static [i.entityKind]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint int64","SQLiteNumericBigInt")}build(e){return new M(e,this.config)}},M=class extends b{static [i.entityKind]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}};function z(e,t){let{name:i,config:s}=c(e,t),r=s?.mode;return"number"===r?new V(i):"bigint"===r?new J(i):new k(i)}var U=class extends g{static [i.entityKind]="SQLiteRealBuilder";constructor(e){super(e,"number double","SQLiteReal")}build(e){return new R(e,this.config)}},R=class extends b{static [i.entityKind]="SQLiteReal";getSQLType(){return"real"}};function W(e){return new U(e??"")}var H=class extends g{static [i.entityKind]="SQLiteTextBuilder";constructor(e,t){super(e,t.enum?.length?"string enum":"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new G(e,this.config)}},G=class extends b{static [i.entityKind]="SQLiteText";enumValues=this.config.enumValues;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}},Y=class extends g{static [i.entityKind]="SQLiteTextJsonBuilder";constructor(e){super(e,"object json","SQLiteTextJson")}build(e){return new Z(e,this.config)}},Z=class extends b{static [i.entityKind]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue=e=>JSON.parse(e);mapToDriverValue=e=>JSON.stringify(e)};function X(e,t={}){let{name:i,config:s}=c(e,t);return"json"===s.mode?new Y(i):new H(i,s)}e.s(["text",0,X],651840);var ee=r;function et(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function ei(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,i)=>e+(0===i?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}let es=Symbol.for("drizzle:SQLiteInlineForeignKeys");var er=class extends ee.Table{static [i.entityKind]="SQLiteTable";static Symbol=Object.assign({},ee.Table.Symbol,{InlineForeignKeys:es});[ee.Table.Symbol.Columns];[es]=[];[ee.Table.Symbol.ExtraConfigBuilder]=void 0};let en=(t=void 0,(e,i,s)=>(function(e,t,i,s,r,n=e){let l="snake_case"===r?et:"camelCase"===r?ei:e=>e,a=new er(e,s,n),o=Object.fromEntries(Object.entries("function"==typeof t?t({blob:C,customType:x,integer:P,numeric:z,real:W,text:X}):t).map(([e,t])=>{t.setName(e,l);let i=t.build(a).postBuild();return a[es].push(...t.buildForeignKeys(i,a)),[e,i]})),u=Object.assign(a,o);return u[ee.Table.Symbol.Columns]=o,u[ee.Table.Symbol.ExtraConfigColumns]=o,i&&(u[er.Symbol.ExtraConfigBuilder]=i),u})(e,i,s,void 0,t));e.s(["SQLiteTable",0,er,"sqliteTable",0,en],97141);var el=class{static [i.entityKind]="SQLiteIndexBuilderOn";constructor(e,t){this.name=e,this.unique=t}on(...e){return new ea(this.name,e,this.unique)}},ea=class{static [i.entityKind]="SQLiteIndexBuilder";config;constructor(e,t,i){this.config={name:e,columns:t,unique:i,where:void 0}}where(e){return this.config.where=e,this}build(e){return new eo(this.config,e)}},eo=class{static [i.entityKind]="SQLiteIndex";config;isNameExplicit;constructor(e,t){this.config={...e,table:t},this.isNameExplicit=!!e.name}};e.s(["IndexBuilder",0,ea,"index",0,function(e){return new el(e,!1)},"uniqueIndex",0,function(e){return new el(e,!0)}],117381);var eu=class{static [i.entityKind]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new ec(e,this.columns,this.name)}},ec=class{static [i.entityKind]="SQLitePrimaryKey";columns;name;isNameExplicit;constructor(e,t,i){this.table=e,this.columns=t,this.name=i,this.isNameExplicit=!!i}getName(){return this.name??`${this.table[er.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}};e.s(["PrimaryKeyBuilder",0,eu,"primaryKey",0,function(...e){return e[0].columns?new eu(e[0].columns,e[0].name):new eu(e)}],173431);var eh=class{static [i.entityKind]="SQLiteUniqueConstraintBuilder";columns;constructor(e,t){this.name=t,this.columns=e}build(e){return new ef(e,this.columns,this.name)}},ed=class{static [i.entityKind]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new eh(e,this.name)}},ef=class{static [i.entityKind]="SQLiteUniqueConstraint";columns;name;isNameExplicit;constructor(e,t,i){this.table=e,this.columns=t,this.isNameExplicit=!!i,this.name=i??function(e,t){return`${e[m.TableName]}_${t.join("_")}_unique`}(this.table,this.columns.map(e=>e.name))}getName(){return this.name}};e.s(["UniqueConstraintBuilder",0,eh,"unique",0,function(e){return new ed(e)}],282276)}];
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=_0k50n27._.js.map
|