@lyhue1991/pi-web 0.8.6
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 -0
- package/.next/app-path-routes-manifest.json +46 -0
- package/.next/build-manifest.json +20 -0
- package/.next/diagnostics/build-diagnostics.json +6 -0
- package/.next/diagnostics/framework.json +1 -0
- package/.next/export-marker.json +6 -0
- package/.next/images-manifest.json +68 -0
- package/.next/next-minimal-server.js.nft.json +1 -0
- package/.next/next-server.js.nft.json +1 -0
- package/.next/package.json +1 -0
- package/.next/prerender-manifest.json +143 -0
- package/.next/react-loadable-manifest.json +2258 -0
- package/.next/required-server-files.js +349 -0
- package/.next/required-server-files.json +349 -0
- package/.next/routes-manifest.json +372 -0
- package/.next/server/app/_global-error/page.js +32 -0
- package/.next/server/app/_global-error/page.js.nft.json +1 -0
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_global-error.html +1 -0
- package/.next/server/app/_global-error.meta +16 -0
- package/.next/server/app/_global-error.rsc +14 -0
- package/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
- package/.next/server/app/_not-found/page.js +2 -0
- package/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_not-found.html +1 -0
- package/.next/server/app/_not-found.meta +16 -0
- package/.next/server/app/_not-found.rsc +20 -0
- package/.next/server/app/_not-found.segments/_full.segment.rsc +20 -0
- package/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
- package/.next/server/app/_not-found.segments/_index.segment.rsc +7 -0
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +5 -0
- package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -0
- package/.next/server/app/api/agent/[id]/bash-output/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/[id]/bash-output/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/[id]/events/route.js +3 -0
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/[id]/route.js +1 -0
- package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/new/route.js +1 -0
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/new/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/running/events/route.js +3 -0
- package/.next/server/app/api/agent/running/events/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/running/events/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/running/route.js +1 -0
- package/.next/server/app/api/agent/running/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/running/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/all-providers/route.js +1 -0
- package/.next/server/app/api/auth/all-providers/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/all-providers/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/login/[provider]/route.js +3 -0
- package/.next/server/app/api/auth/login/[provider]/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/login/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/providers/route.js +1 -0
- package/.next/server/app/api/auth/providers/route.js.nft.json +1 -0
- package/.next/server/app/api/auth/providers/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/cwd/browse/route.js +1 -0
- package/.next/server/app/api/cwd/browse/route.js.nft.json +1 -0
- package/.next/server/app/api/cwd/browse/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/cwd/validate/route.js +1 -0
- package/.next/server/app/api/cwd/validate/route.js.nft.json +1 -0
- package/.next/server/app/api/cwd/validate/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/default-cwd/route.js +1 -0
- package/.next/server/app/api/default-cwd/route.js.nft.json +1 -0
- package/.next/server/app/api/default-cwd/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/file-index/route.js +1 -0
- package/.next/server/app/api/file-index/route.js.nft.json +1 -0
- package/.next/server/app/api/file-index/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/files/[...path]/route.js +49 -0
- package/.next/server/app/api/files/[...path]/route.js.nft.json +1 -0
- package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/git/diff/route.js +6 -0
- package/.next/server/app/api/git/diff/route.js.nft.json +1 -0
- package/.next/server/app/api/git/diff/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/git/status/route.js +6 -0
- package/.next/server/app/api/git/status/route.js.nft.json +1 -0
- package/.next/server/app/api/git/status/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/home/route.js +1 -0
- package/.next/server/app/api/home/route.js.nft.json +1 -0
- package/.next/server/app/api/home/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models/route.js +1 -0
- package/.next/server/app/api/models/route.js.nft.json +1 -0
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/catalog/route.js +1 -0
- package/.next/server/app/api/models-config/catalog/route.js.nft.json +1 -0
- package/.next/server/app/api/models-config/catalog/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/discover/route.js +1 -0
- package/.next/server/app/api/models-config/discover/route.js.nft.json +1 -0
- package/.next/server/app/api/models-config/discover/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/route.js +1 -0
- package/.next/server/app/api/models-config/route.js.nft.json +1 -0
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/test/route.js +1 -0
- package/.next/server/app/api/models-config/test/route.js.nft.json +1 -0
- package/.next/server/app/api/models-config/test/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/plugins/route.js +1 -0
- package/.next/server/app/api/plugins/route.js.nft.json +1 -0
- package/.next/server/app/api/plugins/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/project-trust/route.js +1 -0
- package/.next/server/app/api/project-trust/route.js.nft.json +1 -0
- package/.next/server/app/api/project-trust/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +10 -0
- package/.next/server/app/api/sessions/[id]/auto-name/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/auto-name/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/export/route.js +54 -0
- package/.next/server/app/api/sessions/[id]/export/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/export/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/state/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/state/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/route.js +1 -0
- package/.next/server/app/api/sessions/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/check/route.js +1 -0
- package/.next/server/app/api/skills/check/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/check/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/install/route.js +1 -0
- package/.next/server/app/api/skills/install/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/route.js +6 -0
- package/.next/server/app/api/skills/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/search/route.js +1 -0
- package/.next/server/app/api/skills/search/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/update/route.js +1 -0
- package/.next/server/app/api/skills/update/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/update/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/worktrees/route.js +1 -0
- package/.next/server/app/api/worktrees/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -0
- package/.next/server/app/favicon.ico/route.js +1 -0
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -0
- package/.next/server/app/favicon.ico.body +0 -0
- package/.next/server/app/favicon.ico.meta +1 -0
- package/.next/server/app/index.html +1 -0
- package/.next/server/app/index.meta +14 -0
- package/.next/server/app/index.rsc +21 -0
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +8 -0
- package/.next/server/app/index.segments/_full.segment.rsc +21 -0
- package/.next/server/app/index.segments/_head.segment.rsc +6 -0
- package/.next/server/app/index.segments/_index.segment.rsc +7 -0
- package/.next/server/app/index.segments/_tree.segment.rsc +6 -0
- package/.next/server/app/manifest.webmanifest/route.js +16 -0
- package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -0
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -0
- package/.next/server/app/manifest.webmanifest.body +1 -0
- package/.next/server/app/manifest.webmanifest.meta +1 -0
- package/.next/server/app/page.js +73 -0
- package/.next/server/app/page.js.nft.json +1 -0
- package/.next/server/app/page_client-reference-manifest.js +1 -0
- package/.next/server/app-paths-manifest.json +46 -0
- package/.next/server/chunks/1030.js +1 -0
- package/.next/server/chunks/1048.js +1 -0
- package/.next/server/chunks/1198.js +5 -0
- package/.next/server/chunks/123.js +79 -0
- package/.next/server/chunks/1309.js +14 -0
- package/.next/server/chunks/165.js +1 -0
- package/.next/server/chunks/1813.js +1 -0
- package/.next/server/chunks/2055.js +1 -0
- package/.next/server/chunks/2325.js +80 -0
- package/.next/server/chunks/2349.js +1 -0
- package/.next/server/chunks/258.js +1 -0
- package/.next/server/chunks/2715.js +1 -0
- package/.next/server/chunks/2778.js +1 -0
- package/.next/server/chunks/2943.js +1 -0
- package/.next/server/chunks/3000.js +4 -0
- package/.next/server/chunks/3052.js +1 -0
- package/.next/server/chunks/3054.js +148 -0
- package/.next/server/chunks/3181.js +1 -0
- package/.next/server/chunks/319.js +45 -0
- package/.next/server/chunks/3379.js +1 -0
- package/.next/server/chunks/3397.js +29 -0
- package/.next/server/chunks/358.js +19 -0
- package/.next/server/chunks/3672.js +1 -0
- package/.next/server/chunks/3818.js +1 -0
- package/.next/server/chunks/4120.js +148 -0
- package/.next/server/chunks/4266.js +1 -0
- package/.next/server/chunks/4365.js +43 -0
- package/.next/server/chunks/4407.js +23 -0
- package/.next/server/chunks/4741.js +20 -0
- package/.next/server/chunks/4768.js +80 -0
- package/.next/server/chunks/4893.js +1 -0
- package/.next/server/chunks/5409.js +1 -0
- package/.next/server/chunks/5414.js +1 -0
- package/.next/server/chunks/5460.js +255 -0
- package/.next/server/chunks/5582.js +3 -0
- package/.next/server/chunks/5737.js +24 -0
- package/.next/server/chunks/5773.js +104 -0
- package/.next/server/chunks/5985.js +24 -0
- package/.next/server/chunks/6073.js +64 -0
- package/.next/server/chunks/6346.js +1 -0
- package/.next/server/chunks/6429.js +1 -0
- package/.next/server/chunks/6900.js +90 -0
- package/.next/server/chunks/6953.js +1 -0
- package/.next/server/chunks/7058.js +166 -0
- package/.next/server/chunks/7162.js +287 -0
- package/.next/server/chunks/7287.js +141 -0
- package/.next/server/chunks/7307.js +1 -0
- package/.next/server/chunks/7424.js +4 -0
- package/.next/server/chunks/7635.js +1 -0
- package/.next/server/chunks/7702.js +93 -0
- package/.next/server/chunks/7960.js +1 -0
- package/.next/server/chunks/812.js +226 -0
- package/.next/server/chunks/8276.js +1 -0
- package/.next/server/chunks/8360.js +36 -0
- package/.next/server/chunks/8361.js +1 -0
- package/.next/server/chunks/8430.js +1 -0
- package/.next/server/chunks/8469.js +9 -0
- package/.next/server/chunks/8490.js +1 -0
- package/.next/server/chunks/8704.js +115 -0
- package/.next/server/chunks/9703.js +215 -0
- package/.next/server/chunks/974.js +1 -0
- package/.next/server/chunks/9963.js +1 -0
- package/.next/server/chunks/static/media/macos-trash.6c01a2a6 +0 -0
- package/.next/server/chunks/static/media/windows-trash.2b7fe177.exe +0 -0
- package/.next/server/functions-config-manifest.json +19 -0
- package/.next/server/instrumentation.js +1 -0
- package/.next/server/instrumentation.js.nft.json +1 -0
- package/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/.next/server/middleware.js +18 -0
- package/.next/server/middleware.js.nft.json +1 -0
- package/.next/server/next-font-manifest.js +1 -0
- package/.next/server/next-font-manifest.json +1 -0
- package/.next/server/pages/404.html +1 -0
- package/.next/server/pages/500.html +1 -0
- package/.next/server/pages-manifest.json +4 -0
- package/.next/server/prefetch-hints.json +1 -0
- package/.next/server/server-reference-manifest.js +1 -0
- package/.next/server/server-reference-manifest.json +1 -0
- package/.next/server/webpack-runtime.js +1 -0
- package/.next/static/JpAkqjRvCHtp3M_ChE6_B/_buildManifest.js +1 -0
- package/.next/static/JpAkqjRvCHtp3M_ChE6_B/_ssgManifest.js +1 -0
- package/.next/static/chunks/122.eef9274869d2a305.js +287 -0
- package/.next/static/chunks/1407.28a7fb037c2b2f35.js +43 -0
- package/.next/static/chunks/164.ab76942aa0c3ec72.js +1 -0
- package/.next/static/chunks/1744.78ed01e4e93054c1.js +93 -0
- package/.next/static/chunks/1812.9d1e5ae0d68e6c24.js +76 -0
- package/.next/static/chunks/1921.2c58179657f0a6da.js +90 -0
- package/.next/static/chunks/1978.260c2b48f817965f.js +1 -0
- package/.next/static/chunks/2082.1535d602444ae4c1.js +1 -0
- package/.next/static/chunks/288.d969aeba2ab92928.js +1 -0
- package/.next/static/chunks/318.3fee3527eeabc956.js +4 -0
- package/.next/static/chunks/330.f851561e21edfbbb.js +19 -0
- package/.next/static/chunks/348d3b01.d472dd6bc52ab90c.js +148 -0
- package/.next/static/chunks/3762.d5c709991fc322ef.js +148 -0
- package/.next/static/chunks/3794-1b03b52e3112452e.js +32 -0
- package/.next/static/chunks/3916.0ba385e8bbb9cc14.js +1 -0
- package/.next/static/chunks/4021.cdd3c8f1def79a10.js +1 -0
- package/.next/static/chunks/4178.0212bbaaa6124460.js +115 -0
- package/.next/static/chunks/4389.18c637d4861a0624.js +215 -0
- package/.next/static/chunks/4823.276e9524d3742f1c.js +141 -0
- package/.next/static/chunks/4829.cf1d50e43e6d9db5.js +1 -0
- package/.next/static/chunks/4bd1b696-e356ca5ba0218e27.js +1 -0
- package/.next/static/chunks/5019.b5a1a2b8daf17525.js +1 -0
- package/.next/static/chunks/5326.69460442bdcd6cd3.js +1 -0
- package/.next/static/chunks/5336.d3fa82872c826f30.js +79 -0
- package/.next/static/chunks/5590.ef62922166d308b4.js +1 -0
- package/.next/static/chunks/5627.62050808924cacee.js +23 -0
- package/.next/static/chunks/5690.9d6eb1edb1399995.js +1 -0
- package/.next/static/chunks/58bb9007.3ddd5d34c5f548be.js +80 -0
- package/.next/static/chunks/6071.e9deb627fefd3a20.js +104 -0
- package/.next/static/chunks/6600.583c88eef37aa524.js +1 -0
- package/.next/static/chunks/6710.5b0cfa12a8f68eb9.js +36 -0
- package/.next/static/chunks/744.e67714b764b7bed0.js +166 -0
- package/.next/static/chunks/7478.c2572eb272c8f7ac.js +80 -0
- package/.next/static/chunks/75.70c23d2729f4ae2c.js +9 -0
- package/.next/static/chunks/7563.d8fbeed6a250a962.js +64 -0
- package/.next/static/chunks/7704.a79a089b1c6a8099.js +5 -0
- package/.next/static/chunks/7874.8db6929b94cdf697.js +1 -0
- package/.next/static/chunks/7948.aca281219bad1ab4.js +1 -0
- package/.next/static/chunks/8311-95813758da2b283c.js +1 -0
- package/.next/static/chunks/8538.9462238529bbdc80.js +226 -0
- package/.next/static/chunks/8568.f85d8b36fc9a9037.js +1 -0
- package/.next/static/chunks/8603.7619d9ceac35ae03.js +1 -0
- package/.next/static/chunks/8783.8586d8ca9ef1dce8.js +24 -0
- package/.next/static/chunks/8863.bd7e87f75e046db5.js +1 -0
- package/.next/static/chunks/8889.1ed3f1aa3ac49dd9.js +29 -0
- package/.next/static/chunks/895.a198d303969f1c01.js +24 -0
- package/.next/static/chunks/90542734.b75ad0df50bf68f5.js +1 -0
- package/.next/static/chunks/9242.a1894a4c754b979d.js +1 -0
- package/.next/static/chunks/9471.a7e240888c3a75bc.js +1 -0
- package/.next/static/chunks/9500.1488aec06ee78127.js +1 -0
- package/.next/static/chunks/9529.438891449b77abc7.js +1 -0
- package/.next/static/chunks/9633.155548b5fca6e580.js +1 -0
- package/.next/static/chunks/9779.673004a62d70e36a.js +1 -0
- package/.next/static/chunks/app/_global-error/page-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/_not-found/page-ccc1f1aeb5ecc593.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/agent/running/events/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/agent/running/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/auth/all-providers/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/cwd/browse/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/cwd/validate/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/file-index/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/git/diff/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/git/status/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/home/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/models/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/models-config/catalog/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/models-config/discover/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/models-config/test/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/plugins/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/project-trust/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/export/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/state/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/skills/check/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/skills/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/skills/update/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/layout-ca97634a96114a03.js +1 -0
- package/.next/static/chunks/app/manifest.webmanifest/route-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/app/page-4be55877df86a39c.js +72 -0
- package/.next/static/chunks/c9a5f755.309e1bea31640a4c.js +119 -0
- package/.next/static/chunks/d3ac728e-7964f816a1ca64e5.js +1 -0
- package/.next/static/chunks/f2098590.3d4ddddc296bb3a1.js +62 -0
- package/.next/static/chunks/framework-711ef29bc66f648c.js +1 -0
- package/.next/static/chunks/main-a787264d62ebe041.js +5 -0
- package/.next/static/chunks/main-app-44b3ecb27de577ad.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-0ed2693ee1341146.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-35860f4efe0047e5.js +1 -0
- package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/.next/static/chunks/webpack-35ab8665f48061d4.js +1 -0
- package/.next/static/css/03c139a692325b4b.css +1 -0
- package/.next/static/css/121a2cf33104c046.css +1 -0
- package/.next/static/css/88714c00e109ce28.css +1 -0
- package/.next/static/media/15605e25b523335c-s.woff2 +0 -0
- package/.next/static/media/1a3dce5cfb5f7760-s.woff2 +0 -0
- package/.next/static/media/1cdd02902f937a18-s.woff2 +0 -0
- package/.next/static/media/4c4b3b30b6bcb2be-s.woff2 +0 -0
- package/.next/static/media/641a7b8a5800ee0e-s.woff2 +0 -0
- package/.next/static/media/7deddc85b7ffd1dc-s.p.woff2 +0 -0
- package/.next/static/media/KaTeX_AMS-Regular.1608a09b.woff +0 -0
- package/.next/static/media/KaTeX_AMS-Regular.4aafdb68.ttf +0 -0
- package/.next/static/media/KaTeX_AMS-Regular.a79f1c31.woff2 +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Bold.b6770918.woff +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Bold.cce5b8ec.ttf +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Bold.ec17d132.woff2 +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Regular.07ef19e7.ttf +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Regular.55fac258.woff2 +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Regular.dad44a7f.woff +0 -0
- package/.next/static/media/KaTeX_Fraktur-Bold.9f256b85.woff +0 -0
- package/.next/static/media/KaTeX_Fraktur-Bold.b18f59e1.ttf +0 -0
- package/.next/static/media/KaTeX_Fraktur-Bold.d42a5579.woff2 +0 -0
- package/.next/static/media/KaTeX_Fraktur-Regular.7c187121.woff +0 -0
- package/.next/static/media/KaTeX_Fraktur-Regular.d3c882a6.woff2 +0 -0
- package/.next/static/media/KaTeX_Fraktur-Regular.ed38e79f.ttf +0 -0
- package/.next/static/media/KaTeX_Main-Bold.b74a1a8b.ttf +0 -0
- package/.next/static/media/KaTeX_Main-Bold.c3fb5ac2.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-Bold.d181c465.woff +0 -0
- package/.next/static/media/KaTeX_Main-BoldItalic.6f2bb1df.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-BoldItalic.70d8b0a5.ttf +0 -0
- package/.next/static/media/KaTeX_Main-BoldItalic.e3f82f9d.woff +0 -0
- package/.next/static/media/KaTeX_Main-Italic.47373d1e.ttf +0 -0
- package/.next/static/media/KaTeX_Main-Italic.8916142b.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-Italic.9024d815.woff +0 -0
- package/.next/static/media/KaTeX_Main-Regular.0462f03b.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-Regular.7f51fe03.woff +0 -0
- package/.next/static/media/KaTeX_Main-Regular.b7f8fe9b.ttf +0 -0
- package/.next/static/media/KaTeX_Math-BoldItalic.572d331f.woff2 +0 -0
- package/.next/static/media/KaTeX_Math-BoldItalic.a879cf83.ttf +0 -0
- package/.next/static/media/KaTeX_Math-BoldItalic.f1035d8d.woff +0 -0
- package/.next/static/media/KaTeX_Math-Italic.5295ba48.woff +0 -0
- package/.next/static/media/KaTeX_Math-Italic.939bc644.ttf +0 -0
- package/.next/static/media/KaTeX_Math-Italic.f28c23ac.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Bold.8c5b5494.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Bold.94e1e8dc.ttf +0 -0
- package/.next/static/media/KaTeX_SansSerif-Bold.bf59d231.woff +0 -0
- package/.next/static/media/KaTeX_SansSerif-Italic.3b1e59b3.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Italic.7c9bc82b.woff +0 -0
- package/.next/static/media/KaTeX_SansSerif-Italic.b4c20c84.ttf +0 -0
- package/.next/static/media/KaTeX_SansSerif-Regular.74048478.woff +0 -0
- package/.next/static/media/KaTeX_SansSerif-Regular.ba21ed5f.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Regular.d4d7ba48.ttf +0 -0
- package/.next/static/media/KaTeX_Script-Regular.03e9641d.woff2 +0 -0
- package/.next/static/media/KaTeX_Script-Regular.07505710.woff +0 -0
- package/.next/static/media/KaTeX_Script-Regular.fe9cbbe1.ttf +0 -0
- package/.next/static/media/KaTeX_Size1-Regular.e1e279cb.woff +0 -0
- package/.next/static/media/KaTeX_Size1-Regular.eae34984.woff2 +0 -0
- package/.next/static/media/KaTeX_Size1-Regular.fabc004a.ttf +0 -0
- package/.next/static/media/KaTeX_Size2-Regular.57727022.woff +0 -0
- package/.next/static/media/KaTeX_Size2-Regular.5916a24f.woff2 +0 -0
- package/.next/static/media/KaTeX_Size2-Regular.d6b476ec.ttf +0 -0
- package/.next/static/media/KaTeX_Size3-Regular.9acaf01c.woff +0 -0
- package/.next/static/media/KaTeX_Size3-Regular.a144ef58.ttf +0 -0
- package/.next/static/media/KaTeX_Size3-Regular.b4230e7e.woff2 +0 -0
- package/.next/static/media/KaTeX_Size4-Regular.10d95fd3.woff2 +0 -0
- package/.next/static/media/KaTeX_Size4-Regular.7a996c9d.woff +0 -0
- package/.next/static/media/KaTeX_Size4-Regular.fbccdabe.ttf +0 -0
- package/.next/static/media/KaTeX_Typewriter-Regular.6258592b.woff +0 -0
- package/.next/static/media/KaTeX_Typewriter-Regular.a8709e36.woff2 +0 -0
- package/.next/static/media/KaTeX_Typewriter-Regular.d97aaf4a.ttf +0 -0
- package/.next/static/media/ec14413c594b3356-s.p.woff2 +0 -0
- package/.next/trace +37 -0
- package/.next/trace-build +1 -0
- package/.next/types/app/api/agent/[id]/bash-output/route.ts +351 -0
- package/.next/types/app/api/agent/[id]/events/route.ts +351 -0
- package/.next/types/app/api/agent/[id]/route.ts +351 -0
- package/.next/types/app/api/agent/new/route.ts +351 -0
- package/.next/types/app/api/agent/running/events/route.ts +351 -0
- package/.next/types/app/api/agent/running/route.ts +351 -0
- package/.next/types/app/api/auth/all-providers/route.ts +351 -0
- package/.next/types/app/api/auth/api-key/[provider]/route.ts +351 -0
- package/.next/types/app/api/auth/login/[provider]/route.ts +351 -0
- package/.next/types/app/api/auth/logout/[provider]/route.ts +351 -0
- package/.next/types/app/api/auth/providers/route.ts +351 -0
- package/.next/types/app/api/cwd/browse/route.ts +351 -0
- package/.next/types/app/api/cwd/validate/route.ts +351 -0
- package/.next/types/app/api/default-cwd/route.ts +351 -0
- package/.next/types/app/api/file-index/route.ts +351 -0
- package/.next/types/app/api/files/[...path]/route.ts +351 -0
- package/.next/types/app/api/git/diff/route.ts +351 -0
- package/.next/types/app/api/git/status/route.ts +351 -0
- package/.next/types/app/api/home/route.ts +351 -0
- package/.next/types/app/api/models/route.ts +351 -0
- package/.next/types/app/api/models-config/catalog/route.ts +351 -0
- package/.next/types/app/api/models-config/discover/route.ts +351 -0
- package/.next/types/app/api/models-config/route.ts +351 -0
- package/.next/types/app/api/models-config/test/route.ts +351 -0
- package/.next/types/app/api/plugins/route.ts +351 -0
- package/.next/types/app/api/project-trust/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/auto-name/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/context/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/entries/[entryId]/thinking/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/export/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/route.ts +351 -0
- package/.next/types/app/api/sessions/[id]/state/route.ts +351 -0
- package/.next/types/app/api/sessions/route.ts +351 -0
- package/.next/types/app/api/skills/check/route.ts +351 -0
- package/.next/types/app/api/skills/install/route.ts +351 -0
- package/.next/types/app/api/skills/route.ts +351 -0
- package/.next/types/app/api/skills/search/route.ts +351 -0
- package/.next/types/app/api/skills/update/route.ts +351 -0
- package/.next/types/app/api/worktrees/route.ts +351 -0
- package/.next/types/app/layout.ts +87 -0
- package/.next/types/app/page.ts +87 -0
- package/.next/types/cache-life.d.ts +145 -0
- package/.next/types/package.json +1 -0
- package/.next/types/routes.d.ts +111 -0
- package/.next/types/validator.ts +421 -0
- package/LICENSE +21 -0
- package/README.ja.md +150 -0
- package/README.md +155 -0
- package/README.ru.md +155 -0
- package/README.zh-CN.md +151 -0
- package/bin/node-version.js +35 -0
- package/bin/pi-web-options.js +30 -0
- package/bin/pi-web.js +96 -0
- package/next.config.ts +50 -0
- package/package.json +79 -0
- package/public/icons/apple-touch-icon.png +0 -0
- package/public/icons/icon-192.png +0 -0
- package/public/icons/icon-512.png +0 -0
- package/public/offline.html +83 -0
- package/public/sw.js +76 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{14755:(e,t,n)=>{"use strict";n.d(t,{getPresetFromTools:()=>s,xG:()=>a});let r=[],i=["read","bash","edit","write"],o=["bash","read","edit","write","grep","find","ls"],l=new Set(o);function s(e){let t=e.filter(e=>e.active);if(0===t.length)return"none";let n=t.map(e=>e.name).filter(e=>l.has(e)).sort().join(",");return n===[...i].sort().join(",")?"default":n===[...o].sort().join(",")?"full":"default"}function a(e){return"none"===e?[...r]:"full"===e?[...o]:[...i]}},18382:(e,t,n)=>{"use strict";n.d(t,{AppShell:()=>iu});var r=n(95155),i=n(12115),o=n(73321);let l=null;var s=n(39247),a=n(47650);async function d(e){let t=e?`?path=${encodeURIComponent(e)}`:"",n=await fetch(`/api/cwd/browse${t}`),r=await n.json();if(!n.ok||r.error)throw Error(r.error??`HTTP ${n.status}`);return r}function c(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M1.5 3h4l1.5 2h7.5v7.5h-13z"})})}function u(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,r.jsx)("path",{d:"M2 9h12"}),(0,r.jsx)("circle",{cx:"11.5",cy:"11",r:"0.6",fill:"currentColor",stroke:"none"})]})}function p({onCancel:e,onSelect:t,busy:n=!1,error:o}){let{t:l}=(0,s.s)(),[h,g]=(0,i.useState)(null),[x,f]=(0,i.useState)(""),[m,v]=(0,i.useState)(null),[y,b]=(0,i.useState)(""),[k,w]=(0,i.useState)([]),[j,S]=(0,i.useState)(null),[C,T]=(0,i.useState)(null),[M,R]=(0,i.useState)(!0),I=(0,i.useCallback)(async e=>{R(!0),T(null);try{let t=await d(e),n=t.path??e??"/";f(n),v(t.parentPath??null),b(n),w(t.directories??[]),S(t.drives??null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{R(!1)}},[]);(0,i.useEffect)(()=>{g(document.body),I()},[I]);let L=y.trim()!==x,W=!!x&&!L&&!n,z=!!m||/^[a-zA-Z]:[\\/]?$/.test(x);return h?(0,a.createPortal)((0,r.jsx)("div",{className:"directory-picker-backdrop",role:"dialog","aria-modal":"true","aria-label":l("directoryPicker.selectDirectory"),onClick:t=>{t.target!==t.currentTarget||n||e()},onKeyDown:t=>{"Escape"!==t.key||n||e()},style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.35)"},children:(0,r.jsxs)("div",{className:"directory-picker-panel",style:{width:520,maxWidth:"calc(100vw - 16px)",height:"min(620px, calc(100dvh - 16px))",maxHeight:"calc(100dvh - 16px)",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 8px 32px rgba(0,0,0,0.18)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,padding:"12px 18px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{minWidth:0,flex:1},children:(0,r.jsx)("div",{style:{color:"var(--text)",fontWeight:700,fontSize:15},children:l("directoryPicker.selectDirectory")})}),(0,r.jsx)("button",{type:"button",onClick:e,disabled:n,title:l("i18n.close"),"aria-label":l("i18n.close"),style:{padding:"2px 6px",border:0,background:"none",color:"var(--text-muted)",fontSize:20,lineHeight:1,cursor:n?"default":"pointer",opacity:n?.5:1},children:"\xd7"})]}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=y.trim();t&&I(t)},style:{display:"flex",alignItems:"center",gap:8,flexShrink:0,padding:"10px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("button",{className:"directory-picker-back",type:"button",onClick:()=>void I(m??void 0),disabled:M||!z,title:l("directoryPicker.goToParent"),"aria-label":l("directoryPicker.goToParent"),style:{width:36,height:36,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-hover)",color:"var(--text-muted)",cursor:z?"pointer":"default",opacity:z?1:.45},children:(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"m18 15-6-6-6 6"})})}),(0,r.jsx)("label",{htmlFor:"directory-path",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:l("directoryPicker.directoryPath")}),(0,r.jsx)("input",{className:"directory-picker-path",id:"directory-path",type:"text",value:y,placeholder:"/path/to/project or ~/project",autoFocus:!0,autoComplete:"off",spellCheck:!1,onChange:e=>{b(e.target.value),T(null)},style:{minWidth:0,flex:1,height:36,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,outline:"none",background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:12}}),(0,r.jsx)("button",{className:"directory-picker-action",type:"submit",disabled:M||!y.trim(),title:l("directoryPicker.goToDirectory"),style:{minWidth:58,height:36,padding:"0 12px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-hover)",color:"var(--text-muted)",cursor:M||!y.trim()?"default":"pointer",opacity:M||!y.trim()?.6:1},children:l("directoryPicker.go")})]}),(0,r.jsxs)("div",{className:"directory-picker-list",style:{flex:1,minHeight:0,overflow:"auto",padding:"8px 10px"},children:[M?(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.loadingDirectories")}):null!==j?(0,r.jsx)(r.Fragment,{children:j.length>0?j.map(e=>(0,r.jsxs)("button",{className:"directory-picker-entry",type:"button",onClick:()=>void I(e.path),title:e.path,style:{width:"100%",minHeight:34,display:"flex",alignItems:"center",gap:7,padding:"6px 8px",border:0,borderRadius:5,background:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)",fontSize:11},children:[(0,r.jsx)(u,{}),(0,r.jsx)("span",{children:e.name})]},e.path)):(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.noDrives")})}):k.length>0?k.map(e=>(0,r.jsxs)("button",{className:"directory-picker-entry",type:"button",onClick:()=>void I(e.path),title:e.path,style:{width:"100%",minHeight:30,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:0,borderRadius:5,background:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)",fontSize:11},children:[(0,r.jsx)(c,{}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.path)):(0,r.jsx)("div",{style:{padding:8,color:"var(--text-dim)",fontSize:11},children:l("directoryPicker.noSubdirectories")}),(C||o)&&(0,r.jsx)("div",{style:{padding:"8px",color:"#dc2626",fontSize:11},children:C??o})]}),(0,r.jsxs)("div",{className:"directory-picker-footer",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:10,flexShrink:0,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{className:"directory-picker-action",type:"button",onClick:e,disabled:n,style:{padding:"6px 14px",border:"1px solid var(--border)",borderRadius:6,background:"none",color:"var(--text-muted)",cursor:n?"default":"pointer",fontSize:13},children:l("i18n.cancel")}),(0,r.jsx)("button",{className:"directory-picker-action",type:"button",onClick:()=>t(x),disabled:!W,title:l(L?"directoryPicker.openBeforeSelecting":"directoryPicker.selectCurrentDirectory"),style:{padding:"6px 16px",border:0,borderRadius:6,background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,opacity:W?1:.6,cursor:W?"pointer":"default"},children:l(n?"i18n.checking":"directoryPicker.selectThisFolder")})]})]})}),h):null}let h="var(--text-dim)";function g({size:e=14,open:t=!1}){return t?(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,r.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:h}),(0,r.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:h,strokeWidth:"1",fill:h,fillOpacity:"0.12"})]}):(0,r.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:(0,r.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:h,strokeWidth:"1",fill:h,fillOpacity:"0.1"})})}function x({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",children:[(0,r.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:h,strokeWidth:"1",fill:h,fillOpacity:"0.08"}),(0,r.jsx)("path",{d:"M10 2v3h3",stroke:h,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function f({label:e,size:t=14}){let n=t/14;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:3.4*n,fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:h,letterSpacing:"0",children:e})]})}function m({size:e=14}){return(0,r.jsx)(f,{label:"TS",size:e})}function v({size:e=14}){return(0,r.jsx)(f,{label:"TSX",size:e})}function y({size:e=14}){return(0,r.jsx)(f,{label:"JS",size:e})}function b({size:e=14}){return(0,r.jsx)(f,{label:"JSX",size:e})}function k({size:e=14}){return(0,r.jsx)(f,{label:"PY",size:e})}function w({size:e=14}){return(0,r.jsx)(f,{label:"{}",size:e})}function j({size:e=14}){return(0,r.jsx)(f,{label:"CSS",size:e})}function S({size:e=14}){return(0,r.jsx)(f,{label:"SC",size:e})}function C({size:e=14}){return(0,r.jsx)(f,{label:"HTM",size:e})}function T({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:h,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,r.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:h,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function M({size:e=14}){return(0,r.jsx)(f,{label:"YML",size:e})}function R({size:e=14}){return(0,r.jsx)(f,{label:"TOM",size:e})}function I({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:h,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,r.jsx)("path",{d:"M7.5 10.5h2.5",stroke:h,strokeWidth:"0.95",strokeLinecap:"round"})]})}function L({size:e=14}){return(0,r.jsx)(f,{label:"RS",size:e})}function W({size:e=14}){return(0,r.jsx)(f,{label:"GO",size:e})}function z({size:e=14}){return(0,r.jsx)(f,{label:"SQL",size:e})}function E({size:e=14}){return(0,r.jsx)(f,{label:"GQL",size:e})}function P({size:e=14}){return(0,r.jsx)(f,{label:"TF",size:e})}function $({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:h,strokeWidth:"0.8"}),(0,r.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:h,strokeWidth:"0.8"}),(0,r.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:h,strokeWidth:"0.8"})]})}function F({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("circle",{cx:"5.5",cy:"8.5",r:"1.5",stroke:h,strokeWidth:"0.9"}),(0,r.jsx)("path",{d:"M7 8.5h2.5M8.5 8.5v1.5",stroke:h,strokeWidth:"0.9",strokeLinecap:"round"})]})}function D({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("circle",{cx:"5",cy:"6.5",r:"1",stroke:h,strokeWidth:"0.85"}),(0,r.jsx)("circle",{cx:"9",cy:"6.5",r:"1",stroke:h,strokeWidth:"0.85"}),(0,r.jsx)("circle",{cx:"5",cy:"10",r:"1",stroke:h,strokeWidth:"0.85"}),(0,r.jsx)("path",{d:"M5 7.5V9",stroke:h,strokeWidth:"0.85",strokeLinecap:"round"}),(0,r.jsx)("path",{d:"M9 7.5v.5a2 2 0 0 1-2 2H6",stroke:h,strokeWidth:"0.85",strokeLinecap:"round",fill:"none"})]})}function N({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("rect",{x:"4.5",y:"8.5",width:"5",height:"3",rx:"0.6",stroke:h,strokeWidth:"0.9"}),(0,r.jsx)("path",{d:"M5.5 8.5V7.5a1.5 1.5 0 0 1 3 0v1",stroke:h,strokeWidth:"0.9",strokeLinecap:"round",fill:"none"})]})}function A({size:e=14}){return(0,r.jsx)(f,{label:"DOC",size:e})}function B({size:e=14}){return(0,r.jsx)(f,{label:"PDF",size:e})}function H({size:e=14}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",children:[(0,r.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:h,strokeWidth:"0.9",fill:h,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.5 1v3h3",stroke:h,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,r.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:h,strokeWidth:"0.9"}),(0,r.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:h,strokeWidth:"0.8",strokeLinecap:"round"})]})}function O(e,t=14){let n=e.toLowerCase(),i=n.split(".").pop()??"";if("dockerfile"===n||n.startsWith("dockerfile."))return(0,r.jsx)($,{size:t});if(".env"===n||n.startsWith(".env."))return(0,r.jsx)(F,{size:t});if(".gitignore"===n||".gitattributes"===n||".gitmodules"===n)return(0,r.jsx)(D,{size:t});if("package-lock.json"===n||"yarn.lock"===n||"bun.lock"===n||"pnpm-lock.yaml"===n||"cargo.lock"===n)return(0,r.jsx)(N,{size:t});if(n.endsWith(".config.ts")||n.endsWith(".config.js")||n.endsWith(".config.mjs")||n.endsWith(".config.cjs")||[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(n))return(0,r.jsx)(H,{size:t});switch(i){case"ts":return(0,r.jsx)(m,{size:t});case"tsx":return(0,r.jsx)(v,{size:t});case"js":case"mjs":case"cjs":return(0,r.jsx)(y,{size:t});case"jsx":return(0,r.jsx)(b,{size:t});case"py":return(0,r.jsx)(k,{size:t});case"json":case"jsonl":return(0,r.jsx)(w,{size:t});case"css":case"less":return(0,r.jsx)(j,{size:t});case"scss":return(0,r.jsx)(S,{size:t});case"html":case"htm":return(0,r.jsx)(C,{size:t});case"md":case"mdx":return(0,r.jsx)(T,{size:t});case"yaml":case"yml":return(0,r.jsx)(M,{size:t});case"toml":return(0,r.jsx)(R,{size:t});case"sh":case"bash":case"zsh":case"fish":return(0,r.jsx)(I,{size:t});case"rs":return(0,r.jsx)(L,{size:t});case"go":return(0,r.jsx)(W,{size:t});case"sql":return(0,r.jsx)(z,{size:t});case"graphql":case"gql":return(0,r.jsx)(E,{size:t});case"tf":case"hcl":return(0,r.jsx)(P,{size:t});case"docx":return(0,r.jsx)(A,{size:t});case"pdf":return(0,r.jsx)(B,{size:t});case"lock":return(0,r.jsx)(N,{size:t});default:return(0,r.jsx)(x,{size:t})}}function U({initialValue:e,selectNameWithoutExtension:t=!0,onCommit:n,onCancel:o,invalid:l=!1}){let[s,a]=(0,i.useState)(e),d=(0,i.useRef)(null),c=(0,i.useRef)(!1);(0,i.useEffect)(()=>{let n=d.current;if(n)if(n.focus(),t){let t=e.lastIndexOf(".");t<=0?n.select():n.setSelectionRange(0,t)}else n.select()},[e,t]);let u=e=>{c.current||(c.current=!0,e())};return(0,r.jsx)("input",{ref:d,type:"text",value:s,spellCheck:!1,autoComplete:"off",onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>u(()=>n(s)),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),e.stopPropagation(),u(()=>n(s))):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),u(()=>o()))},style:{flex:1,minWidth:0,height:20,fontSize:12,color:"var(--text)",background:l?"color-mix(in srgb, #ef4444 12%, var(--bg))":"var(--bg)",border:`1px solid ${l?"#ef4444":"var(--accent)"}`,borderRadius:4,padding:"0 4px",outline:"none",fontFamily:"var(--font-mono)"}})}function _({x:e,y:t,items:n,onClose:o}){let l=(0,i.useRef)(null),[s,a]=(0,i.useState)({x:e,y:t});return(0,i.useLayoutEffect)(()=>{let n=l.current;if(!n)return;let r=n.getBoundingClientRect(),i=e,o=t;e+r.width>window.innerWidth-4&&(i=Math.max(4,window.innerWidth-r.width-4)),t+r.height>window.innerHeight-4&&(o=Math.max(4,window.innerHeight-r.height-4)),a({x:i,y:o})},[e,t]),(0,i.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&o()},t=e=>{"Escape"===e.key&&o()},n=()=>o();return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),window.addEventListener("scroll",n,!0),window.addEventListener("resize",o),window.addEventListener("blur",o),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t),window.removeEventListener("scroll",n,!0),window.removeEventListener("resize",o),window.removeEventListener("blur",o)}},[o]),(0,r.jsx)("div",{ref:l,role:"menu",style:{position:"fixed",left:s.x,top:s.y,zIndex:1200,minWidth:168,maxWidth:240,padding:4,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",boxShadow:"0 8px 24px rgba(0,0,0,0.22)"},children:n.map(e=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)("button",{type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{e.disabled||(e.onClick(),o())},style:{display:"flex",alignItems:"center",width:"100%",padding:"5px 10px",border:"none",borderRadius:4,background:"transparent",color:e.disabled?"var(--text-dim)":e.danger?"#f87171":"var(--text)",cursor:e.disabled?"default":"pointer",fontSize:12,textAlign:"left",whiteSpace:"nowrap"},onMouseEnter:t=>{e.disabled||(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:e.label}),e.separatorAfter&&(0,r.jsx)("div",{style:{height:1,margin:"4px 0",background:"var(--border)"}})]},e.key))})}function V(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function q(e){return V(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function K(e){let t=V(e).replace(/\/+$/,"");return t.split("/").pop()??t}function J(e){let t=V(e).replace(/\/+$/,""),n=t.lastIndexOf("/");return n<0?"":0===n?"/":2===n&&/^[a-zA-Z]:\//.test(t)?t.slice(0,3):t.slice(0,n)}function Y(e,t){if(!t)return e;let n=V(e),r=V(t).replace(/\/$/,"");return n.startsWith(r+"/")?n.slice(r.length+1):e}function Z(e,t){return`${V(e).replace(/\/$/,"")}/${t}`}async function G(e){let t=q(e),n=await fetch(`/api/files/${t}?type=list`);if(!n.ok){let e=`Failed to load files (HTTP ${n.status})`;try{let t=await n.json();t.error&&(e=t.error)}catch{}throw Error(e)}return((await n.json()).entries??[]).map(t=>({name:t.name,fullPath:Z(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}async function X(e){let t=new URLSearchParams({cwd:e}),n=await fetch(`/api/git/status?${t.toString()}`);if(!n.ok)throw Error(`Failed to load Git status (HTTP ${n.status})`);return n.json()}async function Q(e,t){let n=await fetch(`/api/files/${q(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:t})});if(!n.ok){let e=await n.json().catch(()=>({})),t=Error(e.error??`HTTP ${n.status}`);throw t.exists=e.exists,t}}async function ee(e){let t=await fetch(`/api/files/${q(e)}`,{method:"DELETE"});if(!t.ok)throw Error((await t.json().catch(()=>({}))).error??`HTTP ${t.status}`)}async function et(e,t,n){let r=await fetch(`/api/files/${q(e)}?type=create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,isDir:n})});if(!r.ok){let e=await r.json().catch(()=>({})),t=Error(e.error??`HTTP ${r.status}`);throw t.exists=e.exists,t}}function en(e){return!!e&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\")&&!e.includes("\0")}let er={modified:"files.modified",added:"files.added",deleted:"files.deleted",renamed:"files.renamed",untracked:"files.untracked",conflict:"files.conflict"},ei={modified:"#d6a84b",added:"#4ade80",deleted:"#f87171",renamed:"#60a5fa",untracked:"#4ade80",conflict:"#f87171"};function eo({status:e,t}){return(0,r.jsx)("span",{title:t(er[e.status]),"aria-label":t(er[e.status]),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",color:ei[e.status],fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600},children:e.code})}function el({size:e=11}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,r.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]})}function es({onClick:e,title:t}){return(0,r.jsx)("button",{type:"button",onClick:e,title:t,"aria-label":t,style:{width:24,height:24,padding:0,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"none",borderRadius:4,background:"none",color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"m6 6 12 12"}),(0,r.jsx)("path",{d:"m18 6-12 12"})]})})}function ea({depth:e,isDir:t,onCommit:n,onCancel:i}){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*e,paddingRight:8,height:24},children:[t?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:t?(0,r.jsx)(g,{size:14,open:!1}):O("new.txt",14)}),(0,r.jsx)(U,{initialValue:"",selectNameWithoutExtension:!1,onCommit:n,onCancel:i})]})}function ed({name:e,isDir:t,busy:n,error:i,onCancel:o,onConfirm:l,t:s}){return(0,r.jsx)("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0,0,0,0.4)"},onClick:e=>{n||e.target!==e.currentTarget||o()},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"file-delete-title",style:{width:400,maxWidth:"100%",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-panel)",boxShadow:"0 12px 36px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:12,padding:"18px 18px 14px"},children:[(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#ef4444",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,marginTop:1},children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{id:"file-delete-title",style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:s("files.moveToTrash")}),(0,r.jsx)("div",{style:{marginTop:7,fontSize:12,lineHeight:1.6,color:"var(--text-muted)"},children:s(t?"files.deleteFolderWarning":"files.deleteFileWarning",{name:e})}),i&&(0,r.jsx)("div",{role:"alert",style:{marginTop:10,color:"#f87171",fontSize:12,lineHeight:1.5,overflowWrap:"anywhere"},children:i})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:o,disabled:n,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:n?"not-allowed":"pointer",fontSize:12},children:s("files.cancel")}),(0,r.jsx)("button",{type:"button",onClick:l,disabled:n,autoFocus:!0,style:{height:32,padding:"0 12px",border:"1px solid #ef4444",borderRadius:5,background:"transparent",color:"#ef4444",cursor:n?"wait":"pointer",opacity:n?.7:1,fontSize:12,fontWeight:600},children:s(n?"files.deleting":"files.moveToTrash")})]})]})})}function ec({node:e,depth:t,cwd:n,onOpenFile:o,onAtMention:l,expandedPaths:s,onToggleExpanded:a,refreshToken:d,highlightedPaths:c,gitStatusByPath:u,changedDirectoryPaths:p,t:h,onContextMenu:x,editing:f,onRenameCommit:m,onCreateCommit:v,onCancelEdit:y,onDragStartNode:b,onDropOnNode:k,getDraggedPath:w}){let j=s.has(e.fullPath),S=c.has(e.fullPath),C=V(e.fullPath),T=u.get(C),M=e.isDir&&(void 0!==T||p.has(C)),[R,I]=(0,i.useState)(e.children??[]),[L,W]=(0,i.useState)(e.loaded??!1),[z,E]=(0,i.useState)(!1),[P,$]=(0,i.useState)(!1),[F,D]=(0,i.useState)(!1),N=f?.kind==="rename"&&f.fullPath===e.fullPath,A=f&&("newfile"===f.kind||"newdir"===f.kind)&&f.parentPath===e.fullPath?f:null,B=(0,i.useCallback)(()=>{if(!e.isDir)return!1;let t=w();if(!t)return!1;let n=V(t).replace(/\/$/,"");return!(C===n||C.startsWith(`${n}/`))},[e.isDir,C,w]),H=(0,i.useCallback)(async(t=!1)=>{if(!L||t){E(!0);try{let t=await G(e.fullPath);I(t),W(!0)}catch{}finally{E(!1)}}},[L,e.fullPath]);(0,i.useEffect)(()=>{j&&L&&H(!0)},[d]);let _=(0,i.useCallback)(()=>{if(e.isDir){let t=!j;a(e.fullPath,t),t&&!L&&H()}else o(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,L,j,H,o,a]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{onClick:_,onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),x(e,t)},draggable:!N,onDragStart:t=>b(e,t),onDragOver:e=>{B()&&(e.preventDefault(),e.dataTransfer.dropEffect="move",D(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||D(!1)},onDrop:t=>{B()&&(t.preventDefault(),t.stopPropagation(),D(!1),k(e,t))},style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*t,paddingRight:8,height:24,cursor:N?"default":"pointer",background:F?"var(--bg-selected)":P?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none",outline:F?"1px solid var(--accent)":"none"},children:[e.isDir&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:j?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!e.isDir&&(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:e.isDir?(0,r.jsx)(g,{size:14,open:j}):O(e.name,14)}),N?(0,r.jsx)(U,{initialValue:e.name,selectNameWithoutExtension:!0,onCommit:t=>m(e,t),onCancel:y}):(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:e.fullPath,children:e.name}),S&&(0,r.jsx)("span",{title:h("files.newlyUploaded"),"aria-label":h("files.newlyUploaded"),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#3b82f6"}})}),!P&&!e.isDir&&T&&(0,r.jsx)(eo,{status:T,t:h}),!P&&M&&(0,r.jsx)("span",{title:h("files.containsChangedFiles"),"aria-label":h("files.containsChangedFiles"),style:{width:14,height:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"#d6a84b"}})}),z&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,r.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),l&&P&&!N&&(0,r.jsxs)("button",{onClick:t=>{t.stopPropagation(),l(Y(e.fullPath,n),e.isDir)},title:h("files.insertPath"),style:{position:"absolute",right:e.isDir?4:28,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(el,{}),h("files.mention")]}),P&&!e.isDir&&!N&&(0,r.jsx)("a",{href:`/api/files/${q(e.fullPath)}?type=download`,download:!0,onClick:e=>e.stopPropagation(),title:h("files.download"),style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 5px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap",textDecoration:"none"},children:(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]}),e.isDir&&j&&(0,r.jsxs)("div",{children:[A&&(0,r.jsx)(ea,{depth:t+1,isDir:"newdir"===A.kind,onCommit:t=>v(e.fullPath,t,"newdir"===A.kind),onCancel:y}),R.map(e=>(0,r.jsx)(ec,{node:e,depth:t+1,cwd:n,onOpenFile:o,onAtMention:l,expandedPaths:s,onToggleExpanded:a,refreshToken:d,highlightedPaths:c,gitStatusByPath:u,changedDirectoryPaths:p,t:h,onContextMenu:x,editing:f,onRenameCommit:m,onCreateCommit:v,onCancelEdit:y,onDragStartNode:b,onDropOnNode:k,getDraggedPath:w},e.fullPath)),0===R.length&&L&&!A&&(0,r.jsx)("div",{style:{paddingLeft:8+(t+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function eu({status:e,cwd:t,onOpenFile:n,t:o}){let[l,s]=(0,i.useState)(!1),a=K(e.filePath),d=Y(e.filePath,t);return(0,r.jsxs)("div",{onClick:()=>n(e.filePath,a,{modeHint:"diff"}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:e.filePath,style:{display:"flex",alignItems:"center",gap:6,paddingLeft:10,paddingRight:8,height:24,cursor:"pointer",background:l?"var(--bg-hover)":"transparent",borderRadius:4,userSelect:"none"},children:[(0,r.jsx)(eo,{status:e,t:o}),(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center",opacity:.85},children:O(a,13)}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:d})]})}let ep=(0,i.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:n,onAtMention:o,onAtMentions:l,onUploadBusyChange:a,changesCollapsed:d,onChangesCountChange:c},u){let{t:p}=(0,s.s)(),[h,g]=(0,i.useState)([]),[x,f]=(0,i.useState)(!0),[m,v]=(0,i.useState)(null),[y,b]=(0,i.useState)(new Set),[k,w]=(0,i.useState)(0),[j,S]=(0,i.useState)(new Set),[C,T]=(0,i.useState)([]),[M,R]=(0,i.useState)({additions:0,deletions:0}),[I,L]=(0,i.useState)("idle"),[W,z]=(0,i.useState)(0),[E,P]=(0,i.useState)(null),[$,F]=(0,i.useState)(null),[D,N]=(0,i.useState)(null),A=(0,i.useRef)(null),B=(0,i.useRef)(null),H=`${n??0}:${k}`,O="idle"!==I,[U,er]=(0,i.useState)(null),[eo,ep]=(0,i.useState)(null),[eh,eg]=(0,i.useState)(null),[ex,ef]=(0,i.useState)(null),[em,ev]=(0,i.useState)(null),ey=(0,i.useRef)(null),eb=(0,i.useMemo)(()=>new Map(C.map(e=>[V(e.filePath),e])),[C]),ek=(0,i.useMemo)(()=>{let t=new Set,n=V(e).replace(/\/$/,"");for(let e of C){let r=J(V(e.filePath));for(;(r===n||r.startsWith(`${n}/`))&&(t.add(r),r!==n);){let e=J(r);if(e===r)break;r=e}}return t},[e,C]),ew=(0,i.useCallback)((e,t)=>{b(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),ej=(0,i.useCallback)(()=>w(e=>e+1),[]),eS=(0,i.useCallback)((e,t)=>{b(n=>{let r=new Set;for(let i of n)i===e?r.add(t):i.startsWith(`${e}/`)?r.add(t+i.slice(e.length)):r.add(i);return r})},[]),eC=(0,i.useCallback)(e=>{b(t=>{let n=new Set;for(let r of t)r===e||r.startsWith(`${e}/`)||n.add(r);return n})},[]),eT=(0,i.useCallback)(()=>ep(null),[]),eM=(0,i.useCallback)(e=>{ep({kind:"rename",parentPath:J(e.fullPath),fullPath:e.fullPath})},[]),eR=(0,i.useCallback)((t,n)=>{t!==e&&ew(t,!0),ep({kind:n?"newdir":"newfile",parentPath:t})},[e,ew]),eI=(0,i.useCallback)(e=>{eg({node:e,busy:!1,error:null})},[]),eL=(0,i.useCallback)((e,t,n)=>{ef(e.exists?p(t):e.message||p(n))},[p]),eW=(0,i.useCallback)(async(e,t)=>{ep(null);let n=t.trim();if(!n||n===e.name)return;if(!en(n))return void ef(p("files.invalidName"));let r=Z(J(e.fullPath),n);try{await Q(e.fullPath,r),e.isDir&&eS(e.fullPath,r),ej()}catch(e){eL(e,"files.nameExists","files.renameError")}},[p,eS,ej,eL]),ez=(0,i.useCallback)(async(e,t,n)=>{let r=t.trim();if(!r)return void ep(null);if(!en(r)){ef(p("files.invalidName")),ep(null);return}try{await et(e,r,n),ep(null),S(new Set([Z(e,r)])),ej()}catch(e){eL(e,"files.nameExists","files.createError"),ep(null)}},[p,ej,eL]),eE=(0,i.useCallback)(async()=>{if(!eh)return;let e=eh.node;eg(e=>e?{...e,busy:!0,error:null}:e);try{await ee(e.fullPath),eC(e.fullPath),eg(null),ej()}catch(t){let e=t instanceof Error?t.message:String(t);eg(t=>t?{...t,busy:!1,error:e}:t)}},[eh,eC,ej]),eP=(0,i.useCallback)(()=>{eh?.busy||eg(null)},[eh]),e$=(0,i.useCallback)(async t=>{let n=Y(t.fullPath,e);try{await navigator.clipboard.writeText(n),ev(p("files.pathCopied"))}catch{ef(p("files.copyFailed"))}},[e,p]),eF=(0,i.useCallback)((e,t)=>{ey.current=e.fullPath,t.dataTransfer.setData("application/x-pi-file-path",e.fullPath),t.dataTransfer.effectAllowed="move"},[]),eD=(0,i.useCallback)(async e=>{let t=ey.current;if(ey.current=null,!t)return;let n=Z(e.fullPath,K(t));if(n!==t)try{await Q(t,n),eS(t,n),ej()}catch(e){eL(e,"files.nameExists","files.moveError")}},[eS,ej,eL]),eN=(0,i.useCallback)(()=>ey.current,[]),eA=(0,i.useCallback)((e,t)=>{er({x:t.clientX,y:t.clientY,node:e})},[]),eB=(0,i.useCallback)(e=>{e.preventDefault(),er({x:e.clientX,y:e.clientY,node:null})},[]);(0,i.useEffect)(()=>{if(!em)return;let e=setTimeout(()=>ev(null),1500);return()=>clearTimeout(e)},[em]);let eH=(0,i.useCallback)(t=>{let n=t.uploaded??[];F({uploaded:n,skipped:t.skipped??[],errors:t.errors??[]}),n.length>0&&(S(new Set(n.map(t=>Z(e,t)))),w(e=>e+1))},[e]),eO=(0,i.useCallback)(async(t,n)=>{N(null),P(null),z(0),L("uploading");try{let{status:r,data:i}=await new Promise((r,i)=>{let o=new FormData;t.forEach(e=>o.append("files",e,e.name));let l=new XMLHttpRequest;l.open("POST",`/api/files/${q(e)}?type=upload&conflict=${n}`),l.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&z(Math.round(e.loaded/e.total*100))},l.onerror=()=>i(Error("Network error while uploading files")),l.onabort=()=>i(Error("Upload cancelled")),l.onload=()=>{let e={};try{e=JSON.parse(l.responseText)}catch{l.responseText&&(e.error=l.responseText)}r({status:l.status,data:e})},l.send(o)});if(409===r&&i.conflicts?.length)return void N({files:t,conflicts:i.conflicts,nonReplaceable:i.nonReplaceable??[]});if(r<200||r>=300)throw Error(i.error??`Upload failed (HTTP ${r})`);z(100),eH(i)}catch(e){P(e instanceof Error?e.message:String(e))}finally{L("idle")}},[eH,e]),eU=(0,i.useCallback)(async t=>{if(0!==t.length&&!O){F(null),S(new Set),N(null),P(null),z(0),L("checking");try{let n=await fetch(`/api/files/${q(e)}?type=upload-check`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileNames:t.map(e=>e.name)})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??`Upload check failed (HTTP ${n.status})`);if(r.conflicts?.length)return void N({files:t,conflicts:r.conflicts,nonReplaceable:r.nonReplaceable??[]});await eO(t,"error")}catch(e){P(e instanceof Error?e.message:String(e))}finally{L("idle")}}},[e,eO,O]),e_=(0,i.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value="",eU(t)},[eU]);(0,i.useImperativeHandle)(u,()=>({openUploadPicker(){O||B.current?.click()}}),[O]),(0,i.useEffect)(()=>{a?.(O)},[a,O]),(0,i.useEffect)(()=>()=>a?.(!1),[a]),(0,i.useEffect)(()=>{let t=A.current!==e;A.current=e,t&&(b(new Set),S(new Set),F(null),N(null),P(null),er(null),ep(null),eg(null),ef(null),ev(null)),f(t),v(null);let n=!1;return G(e).then(e=>{n||g(e)}).catch(e=>{n||v(e instanceof Error?e.message:String(e))}).finally(()=>{n||f(!1)}),()=>{n=!0}},[e,n,k]),(0,i.useEffect)(()=>{let t=!1;return X(e).then(e=>{t||(T(e.isGitRepository?e.files:[]),R(e.isGitRepository?{additions:e.additions,deletions:e.deletions}:{additions:0,deletions:0}))}).catch(()=>{t||(T([]),R({additions:0,deletions:0}))}),()=>{t=!0}},[e,n,k]),(0,i.useEffect)(()=>{c?.(C.length)},[C,c]);let eV=O||null!==D||null!==E||null!==$,eq=(0,i.useCallback)(()=>{$&&0!==$.uploaded.length&&l?.($.uploaded.map(t=>Y(Z(e,t),e)))},[e,l,$]),eK=(0,i.useCallback)(t=>{let n=[];return t?(n.push({key:"rename",label:p("files.rename"),onClick:()=>eM(t)}),n.push({key:"delete",label:p("files.moveToTrash"),onClick:()=>eI(t),danger:!0,separatorAfter:!0}),t.isDir&&(n.push({key:"newfile",label:p("files.newFile"),onClick:()=>eR(t.fullPath,!1)}),n.push({key:"newfolder",label:p("files.newFolder"),onClick:()=>eR(t.fullPath,!0),separatorAfter:!0})),t.isDir||n.push({key:"download",label:p("files.download"),onClick:()=>window.open(`/api/files/${q(t.fullPath)}?type=download`,"_blank")}),n.push({key:"copyPath",label:p("files.copyPath"),onClick:()=>void e$(t)})):(n.push({key:"newfile",label:p("files.newFile"),onClick:()=>eR(e,!1)}),n.push({key:"newfolder",label:p("files.newFolder"),onClick:()=>eR(e,!0)})),n},[p,eM,eI,eR,e$,e]),eJ=eo&&("newfile"===eo.kind||"newdir"===eo.kind)&&eo.parentPath===e?eo:null;return(0,r.jsxs)("div",{style:{minHeight:"100%"},children:[(0,r.jsx)("input",{ref:B,type:"file",multiple:!0,hidden:!0,onChange:e_}),eV&&(0,r.jsxs)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:[O&&(0,r.jsxs)("div",{role:"status","aria-live":"polite","aria-label":"checking"===I?p("files.checking"):p("files.uploading",{progress:W}),children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:14,color:"var(--text-muted)"},children:["checking"===I?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-5.7-8.4"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 16V4"}),(0,r.jsx)("path",{d:"m7 9 5-5 5 5"}),(0,r.jsx)("path",{d:"M5 20h14"})]}),"uploading"===I&&(0,r.jsxs)("span",{style:{fontSize:10},children:[W,"%"]})]}),"uploading"===I&&(0,r.jsx)("div",{style:{height:3,marginTop:4,overflow:"hidden",borderRadius:2,background:"var(--border)"},children:(0,r.jsx)("div",{style:{width:`${W}%`,height:"100%",background:"var(--text-muted)",transition:"width 120ms ease"}})})]}),D&&(0,r.jsxs)("div",{role:"alert",style:{padding:7,border:"1px solid color-mix(in srgb, #f59e0b 55%, var(--border))",borderRadius:4,background:"color-mix(in srgb, #f59e0b 9%, var(--bg-panel))"},children:[(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.35,overflowWrap:"anywhere"},children:p("files.conflictSummary",{count:D.conflicts.length,countSuffix:1===D.conflicts.length?"":"s",files:D.conflicts.join(", ")})}),D.nonReplaceable.length>0&&(0,r.jsx)("div",{style:{marginTop:3,fontSize:10,color:"#f59e0b",lineHeight:1.35,overflowWrap:"anywhere"},children:p("files.cannotReplace",{files:D.nonReplaceable.join(", ")})}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:7},children:[(0,r.jsx)("button",{type:"button",onClick:()=>void eO(D.files,"overwrite"),style:{height:22,padding:"0 7px",border:"1px solid #ef4444",borderRadius:4,background:"transparent",color:"#ef4444",cursor:"pointer",fontSize:10},children:p("files.replace")}),(0,r.jsx)("button",{type:"button",onClick:()=>void eO(D.files,"skip"),style:{height:22,padding:"0 7px",border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",fontSize:10},children:p("files.skipExisting")}),(0,r.jsx)("button",{type:"button",onClick:()=>N(null),style:{height:22,padding:"0 7px",border:"none",borderRadius:4,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:10},children:p("files.cancel")})]})]}),E&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:E}),(0,r.jsx)(es,{onClick:()=>P(null),title:p("files.dismissError")})]}),$&&(0,r.jsxs)("div",{"aria-live":"polite",children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:22,fontSize:11},children:[(0,r.jsxs)("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8},children:[$.uploaded.length>0&&(0,r.jsxs)("span",{title:`${$.uploaded.length} uploaded`,"aria-label":`${$.uploaded.length} uploaded`,style:{display:"flex",alignItems:"center",gap:3,color:"#22c55e"},children:[(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"m5 12 4 4L19 6"})}),(0,r.jsx)("span",{children:$.uploaded.length})]}),$.skipped.length>0&&(0,r.jsxs)("span",{title:`${$.skipped.length} skipped`,"aria-label":`${$.skipped.length} skipped`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--text-dim)"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M8 12h8"})]}),(0,r.jsx)("span",{children:$.skipped.length})]}),$.errors.length>0&&(0,r.jsxs)("span",{title:`${$.errors.length} failed`,"aria-label":`${$.errors.length} failed`,style:{display:"flex",alignItems:"center",gap:3,color:"#f87171"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 3 2.5 20h19L12 3Z"}),(0,r.jsx)("path",{d:"M12 9v4"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsx)("span",{children:$.errors.length})]})]}),$.uploaded.length>0&&l&&(0,r.jsxs)("button",{type:"button",onClick:eq,title:1===$.uploaded.length?p("files.addUploadedFile"):p("files.addAllUploadedFiles"),"aria-label":1===$.uploaded.length?p("files.addUploadedFile"):p("files.addAllUploadedFiles"),style:{height:22,padding:"0 7px",display:"flex",alignItems:"center",justifyContent:"center",gap:4,flexShrink:0,border:"1px solid var(--border)",borderRadius:4,background:"var(--bg-panel)",color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(el,{}),p("files.mention")]}),(0,r.jsx)(es,{onClick:()=>F(null),title:p("files.dismissUploadResults")})]}),$.errors.map(e=>(0,r.jsxs)("div",{title:e.error,style:{display:"flex",alignItems:"center",gap:4,marginTop:3,minWidth:0,fontSize:10,color:"#f87171"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 8v5"}),(0,r.jsx)("path",{d:"M12 17h.01"})]}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.name))]})]}),(ex||em)&&(0,r.jsxs)("div",{style:{padding:"4px 8px",borderBottom:"1px solid var(--border)"},children:[ex&&(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,lineHeight:1.35,color:"#f87171"},children:[(0,r.jsx)("span",{style:{minWidth:0,flex:1,overflowWrap:"anywhere"},children:ex}),(0,r.jsx)(es,{onClick:()=>ef(null),title:p("files.dismissError")})]}),em&&(0,r.jsx)("div",{role:"status",style:{fontSize:11,color:"var(--text-muted)"},children:em})]}),!d&&C.length>0&&(0,r.jsxs)("div",{style:{padding:"0 4px 2px"},children:[(0,r.jsxs)("div",{"aria-label":p("files.changeStats",{count:C.length,additions:M.additions,deletions:M.deletions}),style:{display:"flex",alignItems:"center",gap:6,height:24,padding:"0 10px",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)"},children:p("files.changedCount",{count:C.length})}),(0,r.jsxs)("span",{style:{color:ei.added,fontFamily:"var(--font-mono)"},children:["+",M.additions]}),(0,r.jsxs)("span",{style:{color:ei.deleted,fontFamily:"var(--font-mono)"},children:["-",M.deletions]})]}),C.map(n=>(0,r.jsx)(eu,{status:n,cwd:e,onOpenFile:t,t:p},n.filePath))]}),(d||0===C.length)&&(0,r.jsxs)("div",{style:{padding:"2px 4px"},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),eB(e)},children:[x?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."}):m?(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:m}):(0,r.jsxs)(r.Fragment,{children:[eJ&&(0,r.jsx)(ea,{depth:0,isDir:"newdir"===eJ.kind,onCommit:t=>void ez(e,t,"newdir"===eJ.kind),onCancel:eT}),h.map(n=>(0,r.jsx)(ec,{node:n,depth:0,cwd:e,onOpenFile:t,onAtMention:o,expandedPaths:y,onToggleExpanded:ew,refreshToken:H,highlightedPaths:j,gitStatusByPath:eb,changedDirectoryPaths:ek,t:p,onContextMenu:eA,editing:eo,onRenameCommit:eW,onCreateCommit:ez,onCancelEdit:eT,onDragStartNode:eF,onDropOnNode:e=>void eD(e),getDraggedPath:eN},n.fullPath))]}),!x&&!m&&0===h.length&&(0,r.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:p("files.noFiles")})]}),U&&(0,r.jsx)(_,{x:U.x,y:U.y,items:eK(U.node),onClose:()=>er(null)}),eh&&(0,r.jsx)(ed,{name:eh.node.name,isDir:eh.node.isDir,busy:eh.busy,error:eh.error,onCancel:eP,onConfirm:()=>void eE(),t:p})]})});function eh({onClick:e,title:t,disabled:n,skipHover:i,color:o,background:l="none",marginRight:s,ariaPressed:a,children:d}){return(0,r.jsx)("button",{onClick:e,disabled:n,title:t,"aria-label":t,"aria-pressed":a,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,padding:0,marginRight:s,background:l,border:"none",color:o,cursor:n?"default":"pointer",borderRadius:5,flexShrink:0,opacity:n?.6:1,transition:"color 0.3s, background 0.3s"},onMouseEnter:e=>{n||i||(e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||i||(e.currentTarget.style.color=o,e.currentTarget.style.background=l)},children:d})}let eg="pi-web:unread-session-ids";function ex(e){let t=new Map;for(let n of e){let e=n.projectRoot??n.cwd;if(!e)continue;let r=t.get(e);(!r||n.modified>r)&&t.set(e,n.modified)}return[...t.entries()].sort((e,t)=>t[1].localeCompare(e[1])).map(([e])=>e)}function ef(e,t){return t&&e.startsWith(t)?"~"+e.slice(t.length):e}function em({text:e,style:t}){return(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",minWidth:0,lineHeight:1.35,direction:"rtl",textAlign:"left",...t},children:(0,r.jsx)("span",{style:{unicodeBidi:"plaintext"},children:e})})}function ev({open:e,children:t,style:n}){let[o,l]=(0,i.useState)(e),[s,a]=(0,i.useState)(e);return((0,i.useEffect)(()=>{let t,n;return e?(l(!0),a(!1),t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>a(!0))})):(a(!1),n=setTimeout(()=>l(!1),140)),()=>{void 0!==t&&window.cancelAnimationFrame(t),n&&clearTimeout(n)}},[e]),o)?(0,r.jsx)("div",{style:{...n,opacity:+!!s,transform:s?"translateY(0) scale(1)":"translateY(-8px) scale(0.96)",transformOrigin:"top center",transition:"opacity 140ms ease, transform 140ms ease",pointerEvents:e?"auto":"none"},children:t}):null}let ey="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";function eb(){let[e,t]=(0,i.useState)(!1),[n,o]=(0,i.useState)(!1),l=(0,i.useRef)(null),s=function(e,t){let[n,r]=(0,i.useState)(e),o=(0,i.useRef)(null),l=(0,i.useRef)(0);return(0,i.useEffect)(()=>{if(!t)return void r(e);l.current=0;let n=4*e.length,i=()=>{l.current+=1;let t=Math.floor(l.current/n*e.length);r(e.split("").map((e,n)=>" "===e?" ":n<t?e:ey[Math.floor(Math.random()*ey.length)]).join("")),l.current<n?o.current=requestAnimationFrame(i):r(e)};return o.current=requestAnimationFrame(i),()=>{o.current&&cancelAnimationFrame(o.current)}},[e,t]),n}(e?"0.8.6p0.83.0":"Pi Web",n),a=(0,i.useCallback)(e=>{t(e),o(!0),setTimeout(()=>o(!1),(e?6:8)*4*(1e3/60)+100)},[]),d=(0,i.useCallback)(()=>{l.current&&clearTimeout(l.current);let t=!e;a(t),t&&(l.current=setTimeout(()=>a(!1),3e3))},[e,a]);return(0,i.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),(0,r.jsx)("button",{onClick:d,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:e?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"6ch"},children:s})}function ek({selectedSessionId:e,onSelectSession:t,onNewSession:n,initialSessionId:o,skipInitialProjectSelection:l,onInitialRestoreDone:a,refreshKey:d,onSessionDeleted:c,selectedCwd:u,onCwdChange:h,onOpenFile:g,explorerRefreshKey:x,onExplorerRefresh:f,onAtMention:m,onAtMentions:v}){let{t:y}=(0,s.s)(),[b,k]=(0,i.useState)([]),[w,j]=(0,i.useState)(!0),[S,C]=(0,i.useState)(null),[T,M]=(0,i.useState)(null),[R,I]=(0,i.useState)(""),[L,W]=(0,i.useState)(!1),[z,E]=(0,i.useState)(""),[P,$]=(0,i.useState)(""),[F,D]=(0,i.useState)(!1),[N,A]=(0,i.useState)(""),[B,H]=(0,i.useState)(null),[O,U]=(0,i.useState)(!1),_=(0,i.useRef)(null),[V,q]=(0,i.useState)(null),[K,J]=(0,i.useState)(!1),[Y,Z]=(0,i.useState)(!1),[G,X]=(0,i.useState)(""),[Q,ee]=(0,i.useState)(null),[et,en]=(0,i.useState)(!1),[er,ei]=(0,i.useState)(null),[eo,el]=(0,i.useState)(null),es=(0,i.useRef)(null),ea=(0,i.useRef)(null),[ed,ec]=(0,i.useState)(!0),[eu,ey]=(0,i.useState)(0),[ej,eS]=(0,i.useState)(!1),[eC,eT]=(0,i.useState)(0),[eM,eR]=(0,i.useState)(!0),[eI,eL]=(0,i.useState)(!1),[eW,ez]=(0,i.useState)(!1),[eE,eP]=(0,i.useState)(()=>new Set),[e$,eF]=(0,i.useState)(()=>(function(){try{let e=window.localStorage.getItem(eg);if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>"string"==typeof e));return new Set}catch{return new Set}})()),eD=(0,i.useRef)(new Set),eN=(0,i.useRef)(!1),eA=(0,i.useRef)(null),eB=(0,i.useRef)(null),eH=(0,i.useRef)(null),eO=(0,i.useCallback)(async(e=!1)=>{try{e&&j(!0);let t=await fetch("/api/sessions");if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();k(n.sessions),eN.current||eP(new Set(n.runningSessionIds??[]));let r=new Set(n.sessions.map(e=>e.id));eF(e=>{if(0===e.size)return e;let t=new Set([...e].filter(e=>r.has(e)));return t.size===e.size?e:t}),C(null),e||(eL(!0),eA.current&&clearTimeout(eA.current),eA.current=setTimeout(()=>eL(!1),2e3))}catch(e){C(String(e))}finally{e&&j(!1)}},[]),eU=(0,i.useRef)(!1);(0,i.useEffect)(()=>{let e=!eU.current;eU.current=!0,eO(e)},[eO,d]),(0,i.useEffect)(()=>{try{0===e$.size?window.localStorage.removeItem(eg):window.localStorage.setItem(eg,JSON.stringify([...e$]))}catch{}},[e$]),(0,i.useEffect)(()=>{let e=!1,t=null,n=null,r=()=>{t&&clearTimeout(t),t=null},i=async()=>{if(e||"visible"!==document.visibilityState)return;let o=new AbortController;n?.abort(),n=o;try{let t=await fetch("/api/agent/running",{cache:"no-store",signal:o.signal});if(!t.ok)return;let r=await t.json();if(e||n!==o)return;eN.current=!0,eP(new Set(r.runningSessionIds??[]))}catch{}finally{n===o&&(n=null),r(),e||"visible"!==document.visibilityState||(t=setTimeout(()=>void i(),2500))}},o=()=>{"visible"===document.visibilityState?i():(r(),n?.abort(),n=null)};return i(),document.addEventListener("visibilitychange",o),()=>{e=!0,r(),n?.abort(),document.removeEventListener("visibilitychange",o)}},[]),(0,i.useEffect)(()=>{let t=[...eD.current].filter(t=>!eE.has(t)&&t!==e),n=[...eE];(t.length>0||n.length>0)&&eF(e=>{let r=new Set(e);return n.forEach(e=>r.delete(e)),t.forEach(e=>r.add(e)),r}),t.length>0&&eO(!1),eD.current=eE},[eE,e,eO]),(0,i.useEffect)(()=>{e&&eF(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[e]),(0,i.useEffect)(()=>{void 0!==x&&ey(e=>e+1)},[x]),(0,i.useEffect)(()=>{fetch("/api/home").then(e=>e.json()).then(e=>{e.home&&I(e.home)}).catch(()=>{})},[]);let e_=(0,i.useRef)(!1),eV=(0,i.useCallback)(e=>{if(!e)return null;if(V&&V.forCwd===e||V?.worktrees.some(t=>t.path===e))return V.projectRoot;let t=b.find(t=>t.cwd===e);return t?.projectRoot??e},[V,b]),eq=(0,i.useRef)(null);(0,i.useEffect)(()=>{eq.current!==T&&(eq.current=T,h?.(T,eV(T)))},[T,h,eV]);let eK=(0,i.useRef)(null);(0,i.useEffect)(()=>{u&&u!==eK.current&&(eK.current=u,M(u))},[u]);let[eJ,eY]=(0,i.useState)(0);(0,i.useLayoutEffect)(()=>{if(!T){q(null),el(null);return}let e=!1;return el(T),fetch(`/api/worktrees?cwd=${encodeURIComponent(T)}`).then(e=>e.json()).then(t=>{if(!e){if(el(null),t.error||!t.projectRoot)return void q(null);q({forCwd:T,projectRoot:t.projectRoot,isGit:t.isGit??!1,isTopLevel:t.isTopLevel??!1,worktrees:t.worktrees??[]})}}).catch(()=>{e||(el(null),q(null))}),()=>{e=!0}},[T,eJ,d]),(0,i.useEffect)(()=>{if(0!==b.length&&!l&&null===T){if(o&&!e_.current){e_.current=!0;let e=b.find(e=>e.id===o);if(e){M(e.cwd),t(e,!0);return}a?.()}let e=ex(b);e.length>0&&M(e[0])}},[b,T,o,l,t,a]);let eZ=(0,i.useCallback)(async e=>{let t=(e??N).trim();if(t&&!O){U(!0),H(null);try{let e=await fetch("/api/cwd/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t})}),n=await e.json().catch(()=>({}));if(!e.ok||n.error)return void H(n.error??`HTTP ${e.status}`);M(n.cwd??t),D(!1),A(""),W(!1)}catch(e){H(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[N,O]),eG=(0,i.useCallback)(()=>{D(!0),H(null),W(!1)},[]),eX=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/default-cwd",{method:"POST"}),t=await e.json();t.cwd&&(M(t.cwd),D(!1),A(""),H(null),W(!1))}catch{}},[]),eQ=(0,i.useCallback)(async()=>{let e=G.trim();if(e&&!et&&V){en(!0),ee(null);try{let t=await fetch("/api/worktrees",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:V.projectRoot,branch:e})}),n=await t.json().catch(()=>({}));if(!t.ok||n.error||!n.path)return void ee(n.error??`HTTP ${t.status}`);Z(!1),X(""),J(!1),q(t=>t?{...t,forCwd:n.path,worktrees:[...t.worktrees,{path:n.path,branch:e,isMain:!1}]}:t),M(n.path),eY(e=>e+1)}catch(e){ee(e instanceof Error?e.message:String(e))}finally{en(!1)}}},[G,et,V]),e0=(0,i.useCallback)(async(e,t)=>{if(V&&!et){en(!0),ee(null);try{let n=await fetch("/api/worktrees",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:V.projectRoot,path:e,force:t})}),r=await n.json().catch(()=>({}));if(!n.ok){if(r.dirty&&!t)return void ei(e);ee(r.error??`HTTP ${n.status}`);return}ei(null),T===e&&M(V.projectRoot),eY(e=>e+1)}catch(e){ee(e instanceof Error?e.message:String(e))}finally{en(!1)}}},[V,et,T]);(0,i.useEffect)(()=>{let e=e=>{_.current&&!_.current.contains(e.target)&&(W(!1),E("")),es.current&&!es.current.contains(e.target)&&(J(!1),Z(!1),X(""),ee(null),ei(null),$(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let e1=(0,i.useCallback)(e=>{e.cwd&&M(e.cwd),t(e)},[t]),e2=(0,i.useCallback)(()=>{if(!T)return;let e="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;n?.(e,T)},[T,n]),e8=ex(b),e4=e8.length>8,e5=z.trim()?e8.filter(e=>e.toLowerCase().includes(z.trim().toLowerCase())):e8,e6=eV(T),e3=e6?b.filter(e=>(e.projectRoot??e.cwd)===e6):b,e9=!!(V?.isGit&&V.isTopLevel&&T&&e6===V.projectRoot),e7=T&&V&&e6===V.projectRoot&&!e9?V.isGit?{label:y("sidebar.openRepoRoot"),title:y("sidebar.openRepoRootTitle")}:{label:y("sidebar.gitRepoRootOnly"),title:y("sidebar.gitRepoRootOnlyTitle")}:null,te=!!(T&&eo===T),tt=e7??(te&&!e9?{label:y("sidebar.worktrees"),title:y("sidebar.checkingWorktrees")}:null),tn=function(e){let t=new Map;for(let n of e)t.set(n.id,{session:n,children:[]});let n=new Map;for(let t of e)t.parentSessionId&&n.set(t.id,t.parentSessionId);let r=[];for(let e of t.values()){let i=function(e){let r=n.get(e),i=new Set;for(;r&&!i.has(r);){if(i.add(r),t.has(r))return r;r=n.get(r)}return null}(e.session.id);i?t.get(i).children.push(e):r.push(e)}let i=e=>{e.sort((e,t)=>t.session.modified.localeCompare(e.session.modified)),e.forEach(e=>i(e.children))};return i(r),r}(e3);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[F&&(0,r.jsx)(p,{busy:O,error:B,onCancel:()=>{D(!1),H(null)},onSelect:e=>void eZ(e)}),(0,r.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[(0,r.jsx)(eb,{}),(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsxs)("button",{onClick:e2,disabled:!T,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:T?"var(--text-muted)":"var(--text-dim)",cursor:T?"pointer":"not-allowed",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:T?y("sidebar.newSessionTitle",{path:T}):y("sidebar.selectProject"),onMouseEnter:e=>{T&&(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=T?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,r.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),y("sidebar.new")]}),(0,r.jsx)("button",{onClick:()=>eO(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",background:eI?"rgba(74,222,128,0.18)":"var(--bg-hover)",border:`1px solid ${eI?"rgba(74,222,128,0.4)":"var(--border)"}`,color:eI?"#4ade80":"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.3s, color 0.3s, border-color 0.3s"},onMouseEnter:e=>{eI||(e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)")},onMouseLeave:e=>{eI||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)")},title:y("sidebar.refresh"),children:eI?(0,r.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]})})]})]}),(0,r.jsxs)("div",{ref:_,style:{position:"relative"},children:[(0,r.jsx)("button",{onClick:()=>W(e=>!e),title:e6??T??"",style:{width:"100%",display:"flex",alignItems:"center",padding:"6px 10px",background:T?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:T?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left",transition:"border-color 0.15s, background 0.15s"},children:T?(0,r.jsx)(em,{text:ef(e6??T,R),style:{flex:1,fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text)"}}):(0,r.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)"},children:o&&!e_.current?"":y("sidebar.selectProject")})}),(0,r.jsxs)(ev,{open:L,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[e4&&(0,r.jsx)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{value:z,onChange:e=>E(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(E(""),W(!1))},placeholder:y("sidebar.filterProjects"),autoFocus:!0,style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}})}),(0,r.jsxs)("div",{style:{maxHeight:"min(50vh, 380px)",overflowY:"auto"},children:[e5.map(e=>(0,r.jsxs)("button",{onClick:()=>{M(e),E(""),D(!1),A(""),H(null),W(!1)},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"var(--bg)",border:"none",borderBottom:"1px solid var(--border)",color:e===e6?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:[e===e6&&(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}),e!==e6&&(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)(em,{text:ef(e,R),style:{flex:1}})]},e)),0===e5.length&&z.trim()&&(0,r.jsx)("div",{style:{padding:"8px 10px",fontSize:11,color:"var(--text-dim)"},children:y("sidebar.noMatchingProjects")})]}),!F&&(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),eX()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",borderTop:e5.length>0?"1px solid var(--border)":"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2H4L5 3.5H8.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7A.5.5 0 0 1 1 8V3Z"})}),(0,r.jsx)("span",{children:y("sidebar.useDefaultDirectory")})]}),(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),eG()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,r.jsx)("span",{children:y("sidebar.customPath")})]})]})]}),e9&&(()=>{if(!V)return null;let e=V.worktrees.find(e=>e.path===T)??V.worktrees.find(e=>e.isMain),t=V.worktrees.length>=8,n=t&&P.trim()?V.worktrees.filter(e=>(e.branch??ef(e.path,R)).toLowerCase().includes(P.trim().toLowerCase())):V.worktrees;return(0,r.jsxs)("div",{ref:es,style:{position:"relative",marginTop:6},children:[(0,r.jsxs)("button",{onClick:()=>J(e=>!e),title:e?y("sidebar.switchWorktreeTitle",{path:e.path}):y("sidebar.switchWorktree"),style:{width:"100%",height:29,boxSizing:"border-box",display:"flex",alignItems:"center",gap:6,padding:"0 10px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,cursor:"pointer",fontSize:11,lineHeight:1.35,color:"var(--text-muted)",textAlign:"left"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:e&&!e.isMain?"var(--accent)":"var(--text-dim)"},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)(em,{text:e?e.branch??ef(e.path,R):"…",style:{flex:1,fontFamily:"var(--font-mono)",color:"var(--text)"}}),e?.isMain&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:y("sidebar.main")}),V.worktrees.length>1&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:V.worktrees.length}),(0,r.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),(0,r.jsxs)(ev,{open:K,style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[t&&(0,r.jsx)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("input",{value:P,onChange:e=>$(e.target.value),onKeyDown:e=>{"Escape"===e.key&&($(""),J(!1))},placeholder:y("sidebar.filterWorktrees"),autoFocus:!0,style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}})}),(0,r.jsxs)("div",{style:{maxHeight:"min(40vh, 300px)",overflowY:"auto"},children:[n.map(e=>{let t=e.path===T||e.isMain&&!V.worktrees.some(e=>e.path===T);return er===e.path?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"rgba(239,68,68,0.06)"},children:[(0,r.jsx)("span",{style:{flex:1,fontSize:11,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y("sidebar.forceRemoveCheckout")}),(0,r.jsx)("button",{onClick:()=>void e0(e.path,!0),disabled:et,style:{padding:"3px 9px",background:"#ef4444",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",flexShrink:0},children:y("sidebar.force")}),(0,r.jsx)("button",{onClick:()=>ei(null),style:{padding:"3px 9px",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer",flexShrink:0},children:y("sidebar.cancel")})]},e.path):(0,r.jsxs)("div",{className:"wt-row",style:{display:"flex",alignItems:"center",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("button",{onClick:()=>{M(e.path),J(!1),ee(null),$("")},title:e.path,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:7,padding:"8px 10px",background:"var(--bg)",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11,fontFamily:"var(--font-mono)"},children:[t?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)(em,{text:e.branch??ef(e.path,R),style:{flex:1}}),e.isMain&&(0,r.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10},children:y("sidebar.main")})]}),!e.isMain&&(0,r.jsx)("button",{onClick:()=>void e0(e.path,!1),disabled:et,title:y("sidebar.removeWorktreeTitle",{path:e.path}),style:{display:"flex",alignItems:"center",justifyContent:"center",width:34,height:28,padding:0,marginRight:4,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",borderRadius:5,flexShrink:0,transition:"color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="#ef4444",e.currentTarget.style.background="rgba(239,68,68,0.08)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]},e.path)}),t&&0===n.length&&P.trim()&&(0,r.jsx)("div",{style:{padding:"8px 10px",fontSize:11,color:"var(--text-dim)"},children:y("sidebar.noMatchingWorktrees")})]}),Y?(0,r.jsxs)("div",{style:{padding:"6px 8px"},children:[(0,r.jsx)("input",{ref:ea,value:G,onChange:e=>{X(e.target.value),ee(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eQ()),"Escape"===e.key&&(Z(!1),X(""),ee(null))},placeholder:y("sidebar.branchName"),style:{width:"100%",fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,marginTop:5},children:[(0,r.jsx)("button",{onClick:()=>void eQ(),disabled:et||!G.trim(),style:{flex:1,padding:"4px 0",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",fontSize:11,fontWeight:600,cursor:et||!G.trim()?"not-allowed":"pointer",opacity:et||!G.trim()?.65:1},children:et?y("sidebar.creating"):y("sidebar.create")}),(0,r.jsx)("button",{onClick:()=>{Z(!1),X(""),ee(null)},style:{flex:1,padding:"4px 0",background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:y("sidebar.cancel")})]})]}):(0,r.jsxs)("button",{onClick:e=>{e.stopPropagation(),Z(!0),ee(null),setTimeout(()=>ea.current?.focus(),0)},title:y("sidebar.createWorktreeTitle"),style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),(0,r.jsx)("span",{children:y("sidebar.newWorktree")})]}),Q&&(0,r.jsx)("div",{style:{padding:"5px 10px 8px",color:"#dc2626",fontSize:11,lineHeight:1.35,overflowWrap:"anywhere"},children:Q})]})]})})(),tt&&(0,r.jsxs)("button",{type:"button","aria-disabled":"true",tabIndex:-1,title:tt.title,style:{width:"100%",height:29,boxSizing:"border-box",marginTop:6,display:"flex",alignItems:"center",gap:6,padding:"0 10px",border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-hover)",color:"var(--text-dim)",fontSize:11,lineHeight:1.35,whiteSpace:"nowrap",textAlign:"left",cursor:"default",opacity:.82},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:tt.label})]})]}),(0,r.jsxs)("div",{style:{flex:ed&&(u||T)?"1 1 0":"1 1 auto",overflowY:"auto",padding:"0",minHeight:80},children:[w&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:y("sidebar.loading")}),S&&(0,r.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:S}),!w&&!S&&0===e3.length&&(0,r.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:y("sidebar.noSessions")}),tn.map(t=>(0,r.jsx)(ew,{node:t,selectedSessionId:e,runningSessionIds:eE,unreadSessionIds:e$,onSelectSession:e1,onRenamed:eO,onSessionDeleted:e=>{c?.(e),eO()},depth:0},t.session.id))]}),(u||T)&&(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:ed?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0},children:[(0,r.jsxs)("button",{onClick:()=>ec(e=>!e),style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,r.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:ed?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,r.jsx)("polyline",{points:"3 2 7 5 3 8"})}),y("files.explorer")]}),ed&&eC>0&&(0,r.jsx)(eh,{onClick:()=>eR(e=>!e),title:y("sidebar.changedFiles",{count:eC}),ariaPressed:!eM,color:eM?"var(--text-dim)":"var(--accent)",background:eM?"none":"var(--bg-selected)",children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M3 12h6"}),(0,r.jsx)("path",{d:"M15 12h6"})]})}),ed&&(0,r.jsx)(eh,{onClick:()=>eH.current?.openUploadPicker(),disabled:ej,title:y("sidebar.uploadFilesTitle"),color:"var(--text-dim)",children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M12 3v12"})]})}),(0,r.jsx)(eh,{onClick:()=>{f?f():ey(e=>e+1),ez(!0),eB.current&&clearTimeout(eB.current),eB.current=setTimeout(()=>ez(!1),2e3)},title:y("sidebar.refreshExplorer"),skipHover:eW,color:eW?"#4ade80":"var(--text-dim)",background:eW?"rgba(74,222,128,0.18)":"none",marginRight:6,children:eW?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]})})]}),ed&&(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,r.jsx)(ep,{ref:eH,cwd:T??u,onOpenFile:g??(()=>{}),refreshKey:eu,onAtMention:m,onAtMentions:v,onUploadBusyChange:eS,changesCollapsed:eM,onChangesCountChange:eT})})]})]})}function ew({node:e,selectedSessionId:t,runningSessionIds:n,unreadSessionIds:o,onSelectSession:l,onRenamed:s,onSessionDeleted:a,depth:d}){let[c,u]=(0,i.useState)(!1),p=e.children.length>0;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{position:"relative"},children:[d>0&&(0,r.jsx)("div",{style:{position:"absolute",left:12*d+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,r.jsx)(eC,{session:e.session,isSelected:e.session.id===t,isRunning:n.has(e.session.id),isUnread:o.has(e.session.id),onClick:()=>l(e.session),onRenamed:s,onDeleted:e=>a?.(e),depth:d,hasChildren:p,collapsed:c,onToggleCollapse:()=>u(e=>!e)})]}),p&&!c&&(0,r.jsx)("div",{children:e.children.map(e=>(0,r.jsx)(ew,{node:e,selectedSessionId:t,runningSessionIds:n,unreadSessionIds:o,onSelectSession:l,onRenamed:s,onSessionDeleted:a,depth:d+1},e.session.id))})]})}function ej(){let{t:e}=(0,s.s)();return(0,r.jsx)("span",{title:e("sidebar.agentRunning"),"aria-label":e("sidebar.agentRunning"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"var(--accent)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",style:{display:"block"},children:(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-3.8-7.4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"}),(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.9s",repeatCount:"indefinite"})]})})})}function eS(){let{t:e}=(0,s.s)();return(0,r.jsx)("span",{title:e("sidebar.newActivity"),"aria-label":e("sidebar.newSessionActivity"),style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#0891b2"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",style:{display:"block"},children:[(0,r.jsx)("circle",{cx:"7",cy:"7",r:"2.5",fill:"currentColor"}),(0,r.jsxs)("circle",{cx:"7",cy:"7",r:"3",stroke:"currentColor",strokeWidth:"1.4",opacity:"0.32",children:[(0,r.jsx)("animate",{attributeName:"r",values:"3;6;3",dur:"1.6s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.32;0;0.32",dur:"1.6s",repeatCount:"indefinite"})]})]})})}function eC({session:e,isSelected:t,isRunning:n,isUnread:o,onClick:l,onRenamed:a,onDeleted:d,depth:c=0,hasChildren:u=!1,collapsed:p=!1,onToggleCollapse:h}){let g,x,f,m,v,{t:y}=(0,s.s)(),[b,k]=(0,i.useState)(!1),[w,j]=(0,i.useState)(!1),[S,C]=(0,i.useState)(""),[T,M]=(0,i.useState)(!1),[R,I]=(0,i.useState)(!1),L=(0,i.useRef)(null),W=e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12),z=(0,i.useCallback)(t=>{t.stopPropagation(),C(e.name??""),j(!0),setTimeout(()=>L.current?.select(),0)},[e.name]),E=(0,i.useCallback)(async()=>{let t=S.trim();if(j(!1),t!==(e.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})}),a?.()}catch{}},[S,e.id,e.name,a]),P=(0,i.useCallback)(async()=>{M(!1),I(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:"DELETE"}),d?.(e.id)}catch{I(!1)}},[e.id,d]),$=(0,i.useCallback)(e=>{e.stopPropagation(),e.shiftKey?P():M(!0)},[P]),F=(0,i.useCallback)(e=>{e.stopPropagation(),P()},[P]),D=(0,i.useCallback)(e=>{e.stopPropagation(),M(!1)},[]);return(0,r.jsx)("div",{onClick:T||w?void 0:l,onMouseEnter:()=>k(!0),onMouseLeave:()=>{k(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:c>0?12*c+14:14,paddingRight:8,cursor:T||w?"default":"pointer",background:T?"rgba(239,68,68,0.06)":t?"var(--bg-selected)":b?"var(--bg-hover)":"transparent",borderLeft:T?"2px solid #ef4444":t?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:R?.5:1,gap:6,overflow:"hidden"},children:T?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y("sidebar.deleteSession",{title:W.slice(0,22)+(W.length>22?"…":"")})}),(0,r.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,r.jsxs)("button",{onClick:F,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),y("sidebar.delete")]}),(0,r.jsx)("button",{onClick:D,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:y("sidebar.cancel")})]})]}):w?(0,r.jsx)("input",{ref:L,value:S,onChange:e=>C(e.target.value),onBlur:E,onKeyDown:e=>{"Enter"===e.key&&E(),"Escape"===e.key&&j(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,r.jsxs)(r.Fragment,{children:[c>0&&(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0,fontSize:12,fontWeight:t?500:400,lineHeight:1.4,color:"var(--text)"},title:W,children:(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:W})}),(0,r.jsxs)("div",{style:{marginTop:2,display:"flex",alignItems:"center",gap:8,color:"var(--text-dim)",fontSize:11,minWidth:0},children:[n?(0,r.jsx)(ej,{}):o?(0,r.jsx)(eS,{}):(0,r.jsx)("span",{title:e.modified,children:(g=new Date(e.modified),f=Math.floor((x=new Date().getTime()-g.getTime())/6e4),m=Math.floor(x/36e5),v=Math.floor(x/864e5),f<1?"just now":f<60?`${f}m ago`:m<24?`${m}h ago`:v<7?`${v}d ago`:g.toLocaleDateString())}),(0,r.jsx)("span",{children:y("sidebar.messagesCount",{count:e.messageCount})}),e.worktreeBranch&&(0,r.jsxs)("span",{title:`Worktree: ${e.cwd}`,style:{display:"flex",alignItems:"center",gap:3,color:"var(--accent)",minWidth:0,overflow:"hidden"},children:[(0,r.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.worktreeBranch})]})]})]}),u&&(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),h?.()},title:p?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:p?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),b&&(0,r.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,r.jsx)("button",{onClick:z,title:y("sidebar.rename"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)",e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,r.jsx)("button",{onClick:$,title:y("sidebar.deleteWithShiftClick"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.08)",e.currentTarget.style.color="#ef4444",e.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)",e.currentTarget.style.borderColor="var(--border)"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let eT=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g,eM=/^\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/,eR=/\x1B\[([0-9;]*)m/g,eI=/\x1B_pi:c\x07/g,eL=["#1f2937","#dc2626","#16a34a","#d97706","#2563eb","#9333ea","#0891b2","#6b7280"],eW=["#9ca3af","#ef4444","#22c55e","#f59e0b","#3b82f6","#a855f7","#06b6d4","#e5e7eb"];function ez(e){return e.replace(eI,"").replace(eT,"")}function eE(e){let t=[],n=0;for(;n<e.length;){if(27===e.charCodeAt(n)){let t=e.slice(n).match(eM);if(t){n+=t[0].length;continue}}let r=e.codePointAt(n);if(void 0===r)break;let i=String.fromCodePoint(r);t.push({start:n,end:n+i.length,char:i}),n+=i.length}return t}function eP(e,t){let n=eE(e)[t];return n?e.slice(0,n.start)+e.slice(n.end):e}function e$(e){return eE(e)[0]?.char}function eF(e){let t,n=[],r={},i=0;for(eR.lastIndex=0;null!==(t=eR.exec(e));)t.index>i&&n.push({text:e.slice(i,t.index),style:r}),r=function(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(0===r)for(let e of Object.keys(n))delete n[e];else if(1===r)n.fontWeight=700;else if(2===r)n.opacity=.65;else if(3===r)n.fontStyle="italic";else if(4===r)n.textDecoration="underline";else if(22===r)delete n.fontWeight,delete n.opacity;else if(23===r)delete n.fontStyle;else if(24===r)delete n.textDecoration;else if(39===r)delete n.color;else if(49===r)delete n.backgroundColor;else if(r>=30&&r<=37)n.color=eL[r-30];else if(r>=90&&r<=97)n.color=eW[r-90];else if(r>=40&&r<=47)n.backgroundColor=eL[r-40];else if(r>=100&&r<=107)n.backgroundColor=eW[r-100];else if((38===r||48===r)&&2===t[e+1]){let[i,o,l]=[t[e+2],t[e+3],t[e+4]];[i,o,l].every(e=>"number"==typeof e&&Number.isFinite(e))&&(38===r?n.color=`rgb(${i}, ${o}, ${l})`:n.backgroundColor=`rgb(${i}, ${o}, ${l})`),e+=4}else if((38===r||48===r)&&5===t[e+1]){let i=function(e){if(e>=0&&e<8)return eL[e];if(e>=8&&e<16)return eW[e-8];if(e>=16&&e<=231){let t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),i=e=>0===e?0:55+40*e;return`rgb(${i(n)}, ${i(r)}, ${i(t%6)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}(t[e+2]);i&&(38===r?n.color=i:n.backgroundColor=i),e+=2}}return n}(r,t[1]?t[1].split(";").map(e=>Number(e||"0")):[0]),i=t.index+t[0].length;return i<e.length&&n.push({text:e.slice(i),style:r}),n}let eD={ArrowUp:"\x1b[A",ArrowDown:"\x1b[B",ArrowRight:"\x1b[C",ArrowLeft:"\x1b[D",Home:"\x1b[H",End:"\x1b[F",Insert:"\x1b[2~",Delete:"\x1b[3~",PageUp:"\x1b[5~",PageDown:"\x1b[6~",Escape:"\x1b",Backspace:""},eN={ArrowLeft:"\x1bb",ArrowRight:"\x1bf",ArrowUp:"\x1bp",ArrowDown:"\x1bn"};function eA(e,t={}){return"thinking"===e.type&&!e.deferred&&!t.isStreaming&&""===e.thinking.trim()}function eB(e,t={}){return(e.content??[]).filter(e=>!eA(e,t))}function eH(e,t={}){return t.isStreaming||"error"!==e.stopReason?null:e.errorMessage?.trim()||"Unknown provider error"}function eO(e,t={}){let n=eB(e,t),r=n.findLastIndex(e=>"text"!==e.type&&"image"!==e.type);return -1===r?{answerBlocks:n,processBlocks:[]}:{answerBlocks:n.slice(r+1),processBlocks:n.slice(0,r+1)}}function eU(e){return e.filter(e=>"toolCall"===e.type).length}var e_=n(32316);function eV(e){try{return decodeURIComponent(e)}catch{return e}}function eq(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}function eK(e){let t=eq(e),n=/^[a-zA-Z]:\//.test(t),r=t.startsWith("//"),i=t.startsWith("/")&&!n&&!r,o=[];for(let e of t.split("/"))if(e&&"."!==e){if(".."===e){o.length>0&&".."!==o[o.length-1]?o.pop():i||n||r||o.push(e);continue}o.push(e)}let l=o.join("/");return n?l:r?`//${l}`:i?`/${l}`:l}function eJ(e,t,n=t){let r,i,o,l,s;if(!e)return null;let a=e.split("#",1)[0].split("?",1)[0].trim();if(!a)return null;let d=null,c=null,u=eV(a),p=u.startsWith("\\\\"),h=eq(u),g=h.toLowerCase();if(g.startsWith("/api/")||g.startsWith("/_next/")||!p&&h.startsWith("//")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/i.test(h)&&!g.startsWith("file:")&&!/^[a-zA-Z]:\//.test(h))return null;if(g.startsWith("file:")?c=(d=function(e){try{let t=new URL(e);if("file:"!==t.protocol)return null;let n=eV(t.pathname);if(t.hostname)return`//${t.hostname}${n.startsWith("/")?n:`/${n}`}`;if(/^\/[a-zA-Z]:\//.test(n))return n.slice(1);return n}catch{return null}}(h))?"absolute":null:/^[a-zA-Z]:\//.test(h)||h.startsWith("/")?(d=h,c="absolute"):t&&!(h.startsWith("#")||h.startsWith("?"))&&(h.startsWith("./")||h.startsWith("../")||h.includes("/")||/(^|\/)\.?[^/]+\.[^/.]+$/.test(h))&&(d=`${eq(t).replace(/\/+$/,"")}/${h}`,c="relative"),!d)return null;let x=eK(d).replace(/:\d+(?::\d+)?$/,"");return"relative"===c&&n&&(r=eK(x).replace(/\/+$/,""),i=eK(n).replace(/\/+$/,""),l=(o=/^[a-zA-Z]:\//.test(r)||/^[a-zA-Z]:\//.test(i))?r.toLowerCase():r,!(l===(s=o?i.toLowerCase():i)||l.startsWith(`${s}/`)))?null:x}var eY=n(88374),eZ=n(5924),eG=n(94764),eX=n(63835),eQ=n(84678),e0=n(98164);let e1={...eG.j,attributes:{...eG.j.attributes,code:[["className",/^language-./,"math-inline","math-display"]]},strip:[...eG.j.strip||[],"iframe","object","style","form"]};function e2(e){let t=e.includes("\r\n")?"\r\n":"\n",n=e.split(/\r?\n/),r=[],i=null,o=0,l=null;for(let e=0;e<n.length;e++){var s;let t=n[e];if(l){r.push(t),RegExp(`</${l}\\s*>`,"i").test(t)&&(l=null);continue}let a=t.match(/^ {0,3}(`{3,}|~{3,})/);if(a){let e=a[1][0],n=a[1].length;i?e===i.marker&&n>=i.size&&(i=null):i={marker:e,size:n},o=0,r.push(t);continue}if(i){r.push(t);continue}let d=t.match(/<(code|pre|script|style)\b/i);if(d){let e=d[1].toLowerCase(),n=t.slice((d.index??0)+d[0].length);RegExp(`</${e}\\s*>`,"i").test(n)||(l=e),o=0,r.push(t);continue}if(/^(?: {4}|\t)/.test(t)||""===t.trim()){o=0,r.push(t);continue}if(o||t.includes("`")){o=function(e,t){let n=t;for(let t=0;t<e.length;){if("`"!==e[t]){t++;continue}let r=t+1;for(;"`"===e[r];)r++;let i=r-t;0===n?n=i:i===n&&(n=0),t=r}return n}(t,o),r.push(t);continue}let c=t.match(/^([ ]{0,3})\\\[[ \t]*(.+?)[ \t]*\\\][ \t]*$/);if(c){let e=c[2].trim();if(e){r.push(`${c[1]}$$`,e,`${c[1]}$$`);continue}}let u=t.match(/^([ ]{0,3})\\\[[ \t]*$/);if(u){let t=function(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(/^ {0,3}\\\][ \t]*$/.test(t))return n;if(/^ {0,3}(`{3,}|~{3,})/.test(t)||/^ {0,3}\\\[[ \t]*$/.test(t)||/<(code|pre|script|style)\b/i.test(t))break}return -1}(n,e+1);if(-1!==t){r.push(`${u[1]}$$`,...n.slice(e+1,t),`${u[1]}$$`),e=t;continue}}let p=t.match(/^([ \t]{0,3})\$\$(.+)\$\$[ \t]*$/);if(p){let e=p[2].trim();if(e){r.push(`${p[1]}$$`,e,`${p[1]}$$`);continue}}r.push((s=t,/^\s{0,3}\[[^\]]+\]:/.test(s)||/]\s*\(/.test(s)||/<(?:!--|\/?[A-Za-z][^>]*>)/.test(s)||/\b(?:https?|file|mailto):/i.test(s)||/\b[A-Za-z]:\\/.test(s)?s:s.replace(/(?<!\\)\\\(([^`\r\n$]+?)(?<!\\)\\\)/g,(e,t)=>t.trim()?`$${t}$`:e)))}return r.join(t)}let e8=[eQ.A,e0.A],e4=[eQ.A,e0.A],e5=[eZ.A,[eX.A,e1],[eY.A,{throwOnError:!1,strict:!1}]],e6=[eZ.A,[eX.A,e1],[eY.A,{throwOnError:!1,strict:!1}]];var e3=n(65063),e9=n(7644);let e7=new Set;function te(e){return e7.add(e),()=>{e7.delete(e)}}function tt(){return"u"<typeof document?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function tn(){return"light"}function tr(){let e=(0,i.useSyncExternalStore)(te,tt,tn);return{theme:e,toggleTheme:(0,i.useCallback)(e=>{let t="dark"===tt()?"light":"dark",n=()=>{"dark"===t?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark");try{localStorage.setItem("pi-theme",t)}catch{}e7.forEach(e=>e())},r=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||r)return void n();let i=e?.x??window.innerWidth/2,o=e?.y??window.innerHeight/2,l=Math.hypot(Math.max(i,window.innerWidth-i),Math.max(o,window.innerHeight-o));document.startViewTransition(n).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${i}px ${o}px)`,`circle(${l}px at ${i}px ${o}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]),isDark:"dark"===e}}function ti(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}function to({code:e,isStreaming:t,defaultPreview:o=!1}){let{isDark:l}=tr(),{t:a}=(0,s.s)(),[d,c]=(0,i.useState)(o),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(!1),x=`${l?"dark":"light"}
|
|
2
|
+
${e}`,f=d&&!t;(0,i.useEffect)(()=>{if(!f)return;let t=!1;return p({key:x,status:"loading"}),(async()=>{let{default:r}=await Promise.all([n.e(5958),n.e(3716),n.e(1812)]).then(n.bind(n,28776));if(r.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:l?"dark":"default"}),!await r.parse(e,{suppressErrors:!0}))throw Error("Invalid Mermaid diagram");let i="u">typeof crypto&&"randomUUID"in crypto?`mermaid-${crypto.randomUUID()}`:`mermaid-${Date.now()}-${Math.random().toString(36).slice(2)}`,o=await r.render(i,e);t||p({key:x,status:"ready",svg:o.svg})})().catch(()=>{t||p({key:x,status:"error"})}),()=>{t=!0}},[e,x,l,f]);let m=(0,r.jsx)("button",{type:"button",onClick:()=>c(e=>!e),disabled:t,title:a(t?"i18n.previewAfterStreaming":f?"i18n.showMermaidSource":"i18n.previewMermaid"),className:["markdown-code-action",f?"is-active":""].filter(Boolean).join(" "),children:a(f?"i18n.source":"i18n.preview")});if(!f)return(0,r.jsx)(ts,{code:e,lang:"mermaid",headerAction:m});let v=u?.key===x&&"error"===u.status?(0,r.jsx)("div",{className:"mermaid-block mermaid-block-error",children:a("i18n.invalidMermaid")}):u?.key!==x||"ready"!==u.status?(0,r.jsx)("div",{className:"mermaid-block mermaid-block-loading","aria-label":a("i18n.renderingMermaid")}):(0,r.jsxs)(r.Fragment,{children:[!h&&(0,r.jsx)("button",{type:"button",className:"mermaid-block mermaid-preview-button",title:a("i18n.openMermaidViewer"),"aria-label":a("i18n.openMermaidViewer"),onClick:()=>g(!0),dangerouslySetInnerHTML:{__html:u.svg}}),h&&(0,r.jsx)(tl,{svg:u.svg,onClose:()=>g(!1)})]});return(0,r.jsxs)("div",{className:"markdown-code-block",children:[(0,r.jsxs)("div",{className:"markdown-code-header",children:[(0,r.jsx)("span",{className:"markdown-code-lang",children:"mermaid"}),m]}),v]})}function tl({svg:e,onClose:t}){let{t:n}=(0,s.s)(),o=(0,i.useRef)(null),[l,a]=(0,i.useState)(1);return(0,i.useEffect)(()=>{let e=o.current;if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow="hidden",e.showModal(),()=>{document.body.style.overflow=t,e.open&&e.close()}},[]),(0,r.jsx)("dialog",{ref:o,className:"mermaid-zoom-dialog","aria-label":n("i18n.mermaidViewer"),onCancel:e=>{e.preventDefault(),t()},onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),t())},children:(0,r.jsxs)("div",{className:"mermaid-zoom-layout",children:[(0,r.jsxs)("div",{className:"mermaid-zoom-toolbar",children:[(0,r.jsx)("span",{className:"mermaid-zoom-title",children:n("i18n.mermaidDiagram")}),(0,r.jsxs)("div",{className:"mermaid-zoom-actions",children:[(0,r.jsxs)("div",{className:"mermaid-zoom-stepper",children:[(0,r.jsx)("button",{type:"button",onClick:()=>a(e=>Math.max(.5,e-.25)),disabled:l<=.5,title:n("i18n.zoomOut"),"aria-label":n("i18n.zoomOut"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M5 12h14"})})}),(0,r.jsxs)("span",{className:"mermaid-zoom-value",children:[Math.round(100*l),"%"]}),(0,r.jsx)("button",{type:"button",onClick:()=>a(e=>Math.min(3,e+.25)),disabled:l>=3,title:n("i18n.zoomIn"),"aria-label":n("i18n.zoomIn"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})})})]}),(0,r.jsx)("button",{type:"button",className:"mermaid-zoom-icon-button",onClick:()=>a(1),title:n("i18n.fitToWidth"),"aria-label":n("i18n.fitToWidth"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M8 3H3v5M16 3h5v5M8 21H3v-5M16 21h5v-5"})})}),(0,r.jsx)("button",{type:"button",className:"mermaid-zoom-icon-button",onClick:t,title:n("i18n.close"),"aria-label":n("i18n.close"),children:(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})]})]}),(0,r.jsx)("div",{className:"mermaid-zoom-viewport",onClick:e=>{e.target===e.currentTarget&&t()},children:(0,r.jsx)("div",{className:"mermaid-zoom-canvas",style:{width:`${100*l}%`},dangerouslySetInnerHTML:{__html:e}})})]})})}function ts({code:e,lang:t,headerAction:n}){let{isDark:o}=tr(),{t:l}=(0,s.s)(),[a,d]=(0,i.useState)(!1);return(0,r.jsxs)("div",{className:"markdown-code-block",children:[(0,r.jsxs)("div",{className:"markdown-code-header",children:[(0,r.jsx)("span",{className:"markdown-code-lang",children:t||"text"}),(0,r.jsxs)("div",{className:"markdown-code-actions",children:[n,(0,r.jsx)("button",{onClick:()=>{ti(e).then(()=>{d(!0),setTimeout(()=>d(!1),1500)})},className:"markdown-code-action",children:l(a?"i18n.copied":"i18n.copy")})]})]}),(0,r.jsx)(e3.A,{language:t||"text",style:o?e9.xJ:e9.vs,showLineNumbers:!0,lineNumberStyle:{color:"var(--text-dim)",fontStyle:"normal"},customStyle:{margin:0,padding:"11px 13px",fontSize:12.5,lineHeight:1.62,borderRadius:0,background:"color-mix(in srgb, var(--bg) 92%, var(--bg-panel))"},codeTagProps:{style:{fontFamily:"var(--font-mono)"}},children:e})]})}function ta({children:e,className:t,isStreaming:n,cwd:o,onOpenFile:l}){let s=(0,i.useMemo)(()=>e2(e),[e]),a=(0,i.useMemo)(()=>({code({className:e,children:t,...i}){let o=e?.replace("language-","").toLowerCase()??"",l=String(t);return e?.includes("language-")||l.includes("\n")?"mermaid"===o?(0,r.jsx)(to,{code:l.replace(/\n$/,""),isStreaming:n}):(0,r.jsx)(ts,{code:l.replace(/\n$/,""),lang:o}):(0,r.jsx)("code",{className:"markdown-inline-code",...i,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),a({href:e,children:t,...n}){delete n.node;let i=l?eJ(e,o):null;return i&&l?(0,r.jsx)("a",{href:e,...n,onClick:e=>{if(e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.currentTarget.getAttribute("target");t&&"_self"!==t||(e.preventDefault(),l(i))},children:t}):(0,r.jsx)("a",{href:e,...n,target:"_blank",rel:"noopener noreferrer",children:t})},img({src:e,alt:t,...n}){delete n.node;let i="string"==typeof e?eJ(e,o):null,l=i?`/api/files/${q(i)}?type=read`:e;return(0,r.jsx)("img",{src:l,alt:t??"",loading:"lazy",...n})},table:({children:e})=>(0,r.jsx)("div",{className:"markdown-table-wrap",children:(0,r.jsx)("table",{children:e})})}),[o,n,l]);return(0,r.jsx)("div",{className:["markdown-body",t].filter(Boolean).join(" "),children:(0,r.jsx)(e_.oz,{remarkPlugins:e8,rehypePlugins:e5,components:a,children:s})})}let td=/<(read-files|modified-files)>\s*([\s\S]*?)\s*<\/\1>/g,tc=/(?:\r?\n){2,}((?:[ \t]*<(?:read-files|modified-files)>[ \t]*\r?\n[\s\S]*?\r?\n[ \t]*<\/(?:read-files|modified-files)>[ \t]*(?:\r?\n)?)+)\s*$/;function tu(e){let t,n=[],r=null,i=0,o=0,l=[],s=[],a=()=>({lineNo:null,text:"",type:"empty"}),d=()=>{if(!r){l=[],s=[];return}let e=Math.max(l.length,s.length);for(let t=0;t<e;t++){let e=l[t]?{lineNo:l[t].lineNo,text:l[t].text,type:"removed"}:a(),n=s[t]?{lineNo:s[t].lineNo,text:s[t].text,type:"added"}:a();r.rows.push({type:"line",left:e,right:n})}l=[],s=[]};for(let a of e.split(/\r?\n/)){if(a.startsWith("--- ")){d(),t=tp(a.slice(4));continue}if(a.startsWith("+++ ")){d(),r={oldPath:t,newPath:tp(a.slice(4)),rows:[]},n.push(r);continue}let e=a.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(e){r||(r={rows:[]},n.push(r)),d(),i=Number(e[1]),o=Number(e[2]),r.rows.push({type:"hunk",text:a});continue}if(!r)continue;if(a.startsWith("\\ ")){d(),r.rows.push({type:"hunk",text:a});continue}let c=a[0],u=a.slice(1);" "===c?(d(),r.rows.push({type:"line",left:{lineNo:i++,text:u,type:"context"},right:{lineNo:o++,text:u,type:"context"}})):"-"===c?l.push({lineNo:i++,text:u}):"+"===c?s.push({lineNo:o++,text:u}):""!==a&&(d(),r.rows.push({type:"hunk",text:a}))}d();let c=n.filter(e=>e.rows.some(e=>"line"===e.type));return c.length>0?c:null}function tp(e){return e.split(" ")[0].trim()}let th=new Map;function tg(e){if(!e)return null;let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(r)return i;let o=t.toLocaleDateString([],{month:"short",day:"numeric",year:t.getFullYear()!==n.getFullYear()?"numeric":void 0});return`${o} ${i}`}let tx=(0,i.memo)(function({message:e,isStreaming:t,toolResults:n,modelNames:i,cwd:o,onOpenFile:l,entryId:s,onFork:a,forking:d,onNavigate:c,prevAssistantEntryId:u,onEditContent:p,showTimestamp:h,prevTimestamp:g,sessionId:x}){return"user"===e.role?(0,r.jsx)(tf,{message:e,cwd:o,onOpenFile:l,entryId:s,onFork:a,forking:d,onNavigate:c,prevAssistantEntryId:u,onEditContent:p}):"assistant"===e.role?(0,r.jsx)(tm,{message:e,isStreaming:t,toolResults:n,modelNames:i,cwd:o,onOpenFile:l,showTimestamp:h,prevTimestamp:g,sessionId:x,entryId:s}):"toolResult"===e.role?null:"custom"===e.role?"compaction"===e.customType?(0,r.jsx)(tR,{message:e}):(0,r.jsx)(tW,{message:e,cwd:o,onOpenFile:l}):"bashExecution"===e.role?(0,r.jsx)(tE,{message:e,sessionId:x}):null},(e,t)=>e.message===t.message&&e.isStreaming===t.isStreaming&&function(e,t,n){if(t===n||"assistant"!==e.role)return!0;for(let r of e.content??[])if("toolCall"===r.type&&t?.get(r.toolCallId)!==n?.get(r.toolCallId))return!1;return!0}(e.message,e.toolResults,t.toolResults)&&e.modelNames===t.modelNames&&e.cwd===t.cwd&&e.onOpenFile===t.onOpenFile&&e.entryId===t.entryId&&e.onFork===t.onFork&&e.forking===t.forking&&e.onNavigate===t.onNavigate&&e.prevAssistantEntryId===t.prevAssistantEntryId&&e.onEditContent===t.onEditContent&&e.showTimestamp===t.showTimestamp&&e.prevTimestamp===t.prevTimestamp&&e.sessionId===t.sessionId);function tf({message:e,cwd:t,onOpenFile:n,entryId:o,onFork:l,forking:a,onNavigate:d,prevAssistantEntryId:c,onEditContent:u}){let{t:p}=(0,s.s)(),[h,g]=(0,i.useState)(!1),[x,f]=(0,i.useState)(!1),m="string"==typeof e.content?e.content:e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),v="string"==typeof e.content?[]:e.content.filter(e=>"image"===e.type),y=tg(e.timestamp),b=!!o&&!!l,k=!!c&&!!d;return(0,r.jsxs)("div",{style:{marginBottom:16,display:"flex",flexDirection:"column",alignItems:"flex-end"},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,maxWidth:"85%"},children:(0,r.jsxs)("div",{style:{flex:1,minWidth:0,background:"var(--user-bg)",border:"1px solid rgba(59,130,246,0.2)",borderRadius:12,padding:"8px 12px",fontSize:14,lineHeight:1.6,color:"var(--text)",wordBreak:"break-word"},children:[v.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8*!!m},children:v.map((e,t)=>{let n=e.source?"base64"===e.source.type?`data:${e.source.media_type};base64,${e.source.data}`:e.source.url??"":e.data?`data:${e.mimeType};base64,${e.data}`:"";return(0,r.jsx)("img",{src:n,alt:"",style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid rgba(59,130,246,0.15)"}},t)})}),m&&(0,r.jsx)(ta,{className:"markdown-user-message",cwd:t,onOpenFile:n,children:m})]})}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:6,marginTop:3},children:[(0,r.jsx)("div",{style:{display:"flex",gap:3,opacity:+!!h,pointerEvents:h?"auto":"none",transition:"opacity 0.12s"},children:(0,r.jsxs)("button",{onClick:()=>{ti(m).then(()=>{f(!0),setTimeout(()=>f(!1),1500)})},title:p("i18n.copyMessage"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:x?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{x||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{x||(e.currentTarget.style.color="var(--text-dim)")},children:[x?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),p(x?"i18n.copied":"i18n.copy")]})}),(b||k)&&(0,r.jsxs)("div",{style:{display:"flex",gap:3,opacity:h||a?1:0,pointerEvents:h||a?"auto":"none",transition:"opacity 0.12s"},children:[k&&(0,r.jsxs)("button",{onClick:()=>{d(c),u?.(m)},title:p("i18n.editFromHereTitle"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"15 10 20 15 15 20"}),(0,r.jsx)("path",{d:"M4 4v7a4 4 0 0 0 4 4h12"})]}),p("i18n.editFromHere")]}),b&&(0,r.jsxs)("button",{onClick:()=>{l(o)},disabled:a,title:p(a?"i18n.creatingSession":"i18n.newSessionTitle"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:a?"var(--accent)":"var(--text-dim)",cursor:a?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s"},onMouseEnter:e=>{a||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{a||(e.currentTarget.style.color="var(--text-dim)")},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),p(a?"i18n.creating":"i18n.newSession")]})]}),y&&(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)"},children:y})]})]})}function tm({message:e,isStreaming:t,toolResults:n,modelNames:o,cwd:l,onOpenFile:a,showTimestamp:d,prevTimestamp:c,sessionId:u,entryId:p}){var h;let g,{t:x}=(0,s.s)(),f=d?tg(e.timestamp):null,m=(e.content??[]).map((e,t)=>({block:e,originalIndex:t})).filter(({block:e})=>!eA(e,{isStreaming:t})),v=m.map(({block:e})=>e),y=eH(e,{isStreaming:t}),[b,k]=(0,i.useState)(!1),[w,j]=(0,i.useState)(!1),S=(0,i.useRef)(null),[C,T]=(0,i.useState)(null),M=(0,i.useRef)(m);M.current=m;let R=(0,i.useRef)(new Map),[I,L]=(0,i.useState)(new Map),W=(0,i.useMemo)(()=>{if(!e.timestamp||!c)return;let t=Math.round((e.timestamp-c)/1e3);return t>0?t:void 0},[e.timestamp,c]),z=(0,i.useMemo)(()=>{let t=new Map;if(!n||!e.timestamp)return t;for(let[r,i]of n)if(i.timestamp&&e.timestamp){let n=Math.round((i.timestamp-e.timestamp)/1e3);n>0&&t.set(r,n)}return t},[n,e.timestamp]),E=v.filter(e=>"text"===e.type).map(e=>e.text).join("\n");return((0,i.useEffect)(()=>{if(!t){let e=new Date().getTime();L(t=>{let n=new Map(t);for(let[t,r]of R.current)n.has(t)||n.set(t,Math.round((e-r)/1e3));return n}),S.current=null,T(null);return}let e=setInterval(()=>{let e=M.current,t=e.map(({block:e})=>e),n=Date.now();e.forEach(({originalIndex:e})=>{R.current.has(e)||R.current.set(e,n)}),L(t=>{let r=!1,i=new Map(t);for(let t=0;t<e.length-1;t++){let o=e[t].originalIndex,l=e[t+1].originalIndex;if(!i.has(o)&&R.current.has(o)){let e=R.current.get(o),t=R.current.get(l)??n;i.set(o,Math.round((t-e)/1e3)),r=!0}}return r?i:t});let r=0;for(let e of t)"text"===e.type?r+=e.text?.length??0:"thinking"===e.type?r+=e.thinking?.length??0:"toolCall"===e.type&&(r+=JSON.stringify(e.input??{}).length);if(0===r)return;null===S.current&&(S.current=n);let i=(n-S.current)/1e3;i>.5&&T(r/4/i)},300);return()=>clearInterval(e)},[t]),0!==v.length||t||y)?(0,r.jsxs)("div",{style:{marginBottom:16},onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:[(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:4,display:"flex",alignItems:"center",gap:6},children:[e.provider&&(0,r.jsx)("span",{children:o?.[`${e.provider}:${e.model}`]??o?.[e.model]??e.model}),t&&(()=>{let e,t=0;for(let e of v)"text"===e.type?t+=e.text?.length??0:"thinking"===e.type?t+=e.thinking?.length??0:"toolCall"===e.type&&(t+=JSON.stringify(e.input??{}).length);let n=Math.round(t/4);return(0,r.jsx)(r.Fragment,{children:n>0&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--text)"},title:x("i18n.estimatedTokens"),children:[(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:2,fontSize:11,fontWeight:400},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,r.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),n]}),null!==C&&(e=C>=50?"#53b3cb":C>=30?"#9bc53d":C>=15?"#f9c22e":"#e01a4f",(0,r.jsxs)("span",{style:{marginLeft:6,padding:"1px 6px",borderRadius:4,background:e,color:"#fff",fontSize:11,fontWeight:400},children:[C.toFixed(1)," t/s"]}))]})})})()]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:m.map(({block:e,originalIndex:i})=>(0,r.jsx)(tv,{block:e,toolResults:n,isStreaming:t,streamingDuration:I.get(i)??("thinking"===e.type?W:void 0),toolCallDurations:z,cwd:l,onOpenFile:a,sessionId:u,entryId:p,blockIndex:i},`${p??"stream"}-${i}`))}),y&&(0,r.jsxs)("div",{role:"alert",style:{marginTop:8*(v.length>0),padding:"7px 10px",border:"1px solid rgba(239,68,68,0.3)",borderRadius:6,background:"rgba(239,68,68,0.07)",color:"#ef4444",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:["Error: ",y]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[e.usage&&!t&&(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:(h=e.usage,g=[],h.input&&g.push(`${h.input.toLocaleString()} in`),h.output&&g.push(`${h.output.toLocaleString()} out`),h.cacheRead&&g.push(`${h.cacheRead.toLocaleString()} cache R`),h.cacheWrite&&g.push(`${h.cacheWrite.toLocaleString()} cache W`),h.cost?.total&&g.push(`$${h.cost.total.toFixed(4)}`),g.join(" \xb7 "))}),E&&!t&&(0,r.jsxs)("button",{onClick:()=>{ti(E).then(()=>{j(!0),setTimeout(()=>j(!1),1500)})},title:x("i18n.copyMessage"),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:w?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",opacity:+!!b,pointerEvents:b?"auto":"none",transition:"opacity 0.12s, color 0.12s"},onMouseEnter:e=>{w||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{w||(e.currentTarget.style.color="var(--text-dim)")},children:[w?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),w?x("i18n.copied"):x("i18n.copy")]}),f&&!t&&(0,r.jsx)("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:"auto"},children:f})]})]}):null}function tv({block:e,toolResults:t,isStreaming:n,streamingDuration:i,toolCallDurations:o,cwd:l,onOpenFile:s,sessionId:a,entryId:d,blockIndex:c}){if("text"===e.type)return(0,r.jsx)(ty,{block:e,isStreaming:n,cwd:l,onOpenFile:s});if("thinking"===e.type)return(0,r.jsx)(tb,{block:e,duration:i,sessionId:a,entryId:d,blockIndex:c});if("toolCall"===e.type){let n=t?.get(e.toolCallId),i=o?.get(e.toolCallId);return(0,r.jsx)(tk,{block:e,result:n,duration:i})}return null}function ty({block:e,isStreaming:t,cwd:n,onOpenFile:i}){return(0,r.jsx)(ta,{isStreaming:t,cwd:n,onOpenFile:i,children:e.text})}function tb({block:e,duration:t,sessionId:n,entryId:o,blockIndex:l}){let{t:a}=(0,s.s)(),[d,c]=(0,i.useState)(!1),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(!1),[x,f]=(0,i.useState)(null),m=async()=>{let t=!d;if(c(t),t&&e.deferred&&null===u){if(!n||!o)return void f(a("i18n.thinkingUnavailable"));g(!0),f(null);try{p(await function(e,t,n){let r=`${e}:${t}:${n}`,i=th.get(r);if(i)return th.delete(r),th.set(r,i),i;let o=fetch(`/api/sessions/${encodeURIComponent(e)}/entries/${encodeURIComponent(t)}/thinking?blockIndex=${n}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if("string"!=typeof t.thinking)throw Error("Invalid thinking response");return t.thinking}).catch(e=>{throw th.delete(r),e});if(th.set(r,o),th.size>100){let e=th.keys().next().value;e&&th.delete(e)}return o}(n,o,l))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}};return(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",fontSize:13},children:[(0,r.jsxs)("button",{onClick:()=>void m(),style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 10px",background:"var(--bg-panel)",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left"},children:[(0,r.jsx)("span",{children:a("i18n.thinking")}),void 0!==t&&(0,r.jsxs)("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-dim)",fontVariantNumeric:"tabular-nums"},children:[t,"s"]})]}),d&&(0,r.jsx)("div",{style:{padding:"8px 10px",color:x?"#f87171":"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",background:"var(--bg-panel)",borderTop:"1px solid var(--border)"},children:h?a("i18n.loadingThinking"):x??(e.deferred?u:e.thinking)})]})}function tk({block:e,result:t,duration:n}){let o,[l,s]=(0,i.useState)(!1),a=JSON.stringify(e.input,null,2),d="edit"===(o=e.toolName.toLowerCase())||o.startsWith("edit_")||o.endsWith(".edit")||o.endsWith("_edit")||o.includes("str_replace")||o.includes("replace_editor"),c=t&&!t.isError?function(e){var t;let n=e.details;if(!("object"==typeof(t=n)&&null!==t&&!Array.isArray(t)))return null;let r="string"==typeof n.patch?n.patch:null;if(r)return{text:r};let i="string"==typeof n.diff?n.diff:null;return i?{text:i}:null}(t):null,u=t?t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):null,p=null!==u&&("(no output)"===u.trim()||""===u.trim()),h=t?.isError??!1;return(0,r.jsxs)("div",{style:{borderRadius:7,overflow:"hidden",fontSize:12,border:h?"1px solid rgba(248,113,113,0.45)":"1px solid rgba(34,197,94,0.25)",background:h?"rgba(248,113,113,0.05)":"rgba(34,197,94,0.04)"},children:[(0,r.jsxs)("button",{onClick:()=>s(e=>!e),style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",minWidth:0},children:[(0,r.jsx)("span",{style:{color:h?"#f87171":"#16a34a",fontFamily:"var(--font-mono)",fontWeight:600,fontSize:11,flexShrink:0},children:e.toolName}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:function(e){let t=e.input;if(!t||"object"!=typeof t)return"";let n=Object.keys(t);return 0===n.length?"":"command"in t?String(t.command).slice(0,120):"path"in t?String(t.path).slice(0,120):"file_path"in t?String(t.file_path).slice(0,120):"pattern"in t?String(t.pattern).slice(0,120):"query"in t?String(t.query).slice(0,120):String(t[n[0]]).slice(0,120)}(e)}),void 0!==n&&(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-dim)",flexShrink:0,fontVariantNumeric:"tabular-nums"},children:[n,"s"]}),(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:l?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),l&&!d&&(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,overflow:"auto",background:"var(--bg-subtle)",borderTop:h?"1px solid rgba(248,113,113,0.25)":"1px solid rgba(34,197,94,0.2)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:a}),l&&t&&(c?(0,r.jsx)(tw,{diff:c}):(0,r.jsx)(tM,{text:u??"",isEmpty:p,isError:h}))]})}function tw({diff:e}){return(0,r.jsx)("div",{style:{borderTop:"1px solid rgba(34,197,94,0.15)",background:"var(--bg)"},children:(0,r.jsx)(tj,{text:e.text})})}function tj({text:e}){let{t}=(0,s.s)(),n=(0,i.useMemo)(()=>tu(e),[e]);if(!n)return(0,r.jsx)(tT,{text:e});let o=n.length>1;return(0,r.jsx)("div",{style:{maxHeight:560,overflowY:"auto",overflowX:"hidden",background:"var(--bg)"},children:n.map((e,n)=>(0,r.jsxs)("div",{style:{minWidth:0,borderTop:0===n?"none":"1px solid var(--border)",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55},children:[o&&(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",position:"sticky",top:0,zIndex:1,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)(tS,{title:e.oldPath||t("i18n.before"),side:"left"}),(0,r.jsx)(tS,{title:e.newPath||t("i18n.after"),side:"right"})]}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)"},children:e.rows.map((e,t)=>"hunk"===e.type?null:(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)(tC,{cell:e.left,side:"left"}),(0,r.jsx)(tC,{cell:e.right,side:"right"})]},t))})]},n))})}function tS({title:e,side:t}){return(0,r.jsx)("div",{title:e,style:{padding:"5px 10px",color:"var(--text-dim)",borderRight:"left"===t?"1px solid var(--border)":"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})}function tC({cell:e,side:t}){let n="added"===e.type?"rgba(34,197,94,0.12)":"removed"===e.type?"rgba(248,113,113,0.13)":"empty"===e.type?"var(--bg-subtle)":"transparent",i="added"===e.type?"+":"removed"===e.type?"-":" ",o="added"===e.type?"#22c55e":"removed"===e.type?"#f87171":"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",minWidth:0,background:n,borderRight:"left"===t?"1px solid var(--border)":"none"},children:[(0,r.jsx)("span",{style:{width:42,padding:"0 6px",textAlign:"right",color:"var(--text-dim)",userSelect:"none",background:"var(--bg-panel)",borderRight:"1px solid var(--border)",flexShrink:0},children:e.lineNo??""}),(0,r.jsx)("span",{style:{width:18,padding:"0 5px",color:o,userSelect:"none",fontWeight:"context"===e.type||"empty"===e.type?400:700,flexShrink:0},children:i}),(0,r.jsx)("span",{style:{flex:1,minWidth:0,padding:"0 10px 0 0",color:"empty"===e.type?"var(--text-dim)":"var(--text)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:e.text||"\xa0"})]})}function tT({text:e}){let t=e.split(/\r?\n/);return(0,r.jsx)("div",{style:{maxHeight:520,overflowY:"auto",overflowX:"hidden",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,minWidth:0},children:t.map((e,t)=>{let n=e.startsWith("@@")?"hunk":e.startsWith("+")&&!e.startsWith("+++")?"added":e.startsWith("-")&&!e.startsWith("---")?"removed":"context";return(0,r.jsxs)("div",{style:{display:"flex",background:"added"===n?"rgba(34,197,94,0.12)":"removed"===n?"rgba(248,113,113,0.13)":"hunk"===n?"rgba(96,165,250,0.12)":"transparent",borderLeft:"added"===n?"3px solid #22c55e":"removed"===n?"3px solid #f87171":"hunk"===n?"3px solid var(--accent)":"3px solid transparent"},children:[(0,r.jsx)("span",{style:{width:48,padding:"0 8px",color:"var(--text-dim)",background:"var(--bg-panel)",borderRight:"1px solid var(--border)",textAlign:"right",userSelect:"none",flexShrink:0},children:t+1}),(0,r.jsx)("span",{style:{padding:"0 10px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",color:"added"===n?"#22c55e":"removed"===n?"#f87171":"hunk"===n?"var(--accent)":"var(--text)"},children:e||"\xa0"})]},t)})})}function tM({text:e,isEmpty:t,isError:n}){let{t:i}=(0,s.s)();return(0,r.jsx)("div",{style:{borderTop:`1px solid ${n?"rgba(248,113,113,0.3)":"rgba(34,197,94,0.15)"}`,background:n?"rgba(248,113,113,0.04)":"var(--bg-subtle)"},children:(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",color:n?"#f87171":t?"var(--text-dim)":"var(--text-muted)",fontSize:12,lineHeight:1.5,overflow:"auto",maxHeight:400,background:"var(--bg)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontStyle:t?"italic":"normal",opacity:t?.6:1},children:t?i("i18n.noOutput"):e})})}function tR({message:e}){let{t}=(0,s.s)(),n=tz(e.content),o=(0,i.useMemo)(()=>{let e,t,r,i,o;return e=[],t=[],r=n.match(tc),i=r?.[1]??"",o=r?.index===void 0?n:n.slice(0,r.index),i.replace(td,(n,r,i)=>{let o=i.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return"read-files"===r?e.push(...o):t.push(...o),""}),{body:o.trim(),readFiles:e,modifiedFiles:t}},[n]),l=tg(e.timestamp);return(0,r.jsx)("div",{style:{marginBottom:16},children:(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:650},children:"compaction"}),l&&(0,r.jsx)("span",{style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10},children:l})]}),(0,r.jsxs)("div",{style:{padding:"11px 13px 12px"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:15,fontWeight:700,lineHeight:1.35},children:t("i18n.conversationCompacted")}),(0,r.jsx)("div",{style:{marginTop:3,marginBottom:10,color:"var(--text)",fontSize:14,lineHeight:1.5},children:t("i18n.compactionDescription")}),o.body?(0,r.jsx)(ta,{className:"markdown-compaction-message",children:o.body}):(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:12},children:t("i18n.noSummary")}),(0,r.jsx)(tI,{readFiles:o.readFiles,modifiedFiles:o.modifiedFiles})]})]})})}function tI({readFiles:e,modifiedFiles:t}){let{t:n}=(0,s.s)();if(0===e.length+t.length)return null;let i=[];return e.length>0&&i.push(`${e.length} read`),t.length>0&&i.push(`${t.length} modified`),(0,r.jsxs)("details",{className:"compaction-file-details",children:[(0,r.jsx)("summary",{children:n("i18n.fileContext",{details:i.join(", ")})}),t.length>0&&(0,r.jsx)(tL,{title:n("i18n.modifiedFiles"),files:t}),e.length>0&&(0,r.jsx)(tL,{title:n("i18n.readFiles"),files:e})]})}function tL({title:e,files:t}){return(0,r.jsxs)("div",{className:"compaction-file-section",children:[(0,r.jsx)("div",{className:"compaction-file-title",children:e}),(0,r.jsx)("ul",{className:"compaction-file-list",children:t.map(e=>(0,r.jsx)("li",{children:e},e))})]})}function tW({message:e,cwd:t,onOpenFile:n}){var o;let l,{t:a}=(0,s.s)(),d=!1===e.display,[c,u]=(0,i.useState)(!d),[p,h]=(0,i.useState)(!1),[g,x]=(0,i.useState)(!1),f=tz(e.content),m="string"==typeof(o=e.content)?[]:o.filter(e=>"image"===e.type),v=void 0!==e.details,y=v?function(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}(e.details):"",b=e.customType||"extension",k=tg(e.timestamp);return(0,r.jsx)("div",{style:{marginBottom:16},children:(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:d?"var(--bg-subtle)":"var(--bg)",opacity:d&&!c?.82:1},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",fontSize:12},children:[(0,r.jsx)("span",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:11,fontWeight:650},children:b}),d&&(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:a("i18n.hiddenExtensionMessage")}),k&&(0,r.jsx)("span",{style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10},children:k})]}),c?(0,r.jsxs)("div",{style:{padding:"6px 9px"},children:[m.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8*!!f},children:m.map((e,t)=>{var n;let i=(n=e).source?"base64"===n.source.type?`data:${n.source.media_type};base64,${n.source.data}`:n.source.url??"":n.data?`data:${n.mimeType};base64,${n.data}`:"";return i?(0,r.jsx)("img",{src:i,alt:"",style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid var(--border)"}},t):null})}),f?(0,r.jsx)(ta,{className:"markdown-custom-message",cwd:t,onOpenFile:n,children:f}):(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:12},children:a("i18n.noMessage")})]}):(0,r.jsx)("button",{onClick:()=>u(!0),style:{display:"block",width:"100%",padding:"8px 10px",border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",fontSize:12,textAlign:"left"},children:f?(l=f.replace(/\s+/g," ").trim())?l.length>140?`${l.slice(0,140)}...`:l:"Show extension message":a("i18n.showExtensionMessage")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 9px",borderTop:"1px solid var(--border)",background:"var(--bg-subtle)"},children:[f||y?(0,r.jsx)("button",{onClick:()=>{ti(f||y).then(()=>{x(!0),setTimeout(()=>x(!1),1500)})},style:{padding:"3px 7px",border:"none",background:"none",color:g?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11},children:a(g?"i18n.copied":"i18n.copy")}):null,(v||d)&&(0,r.jsx)("button",{onClick:()=>{d?u(e=>!e):h(e=>!e)},style:{marginLeft:"auto",padding:"3px 7px",border:"none",background:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:11},children:a(d?c?"i18n.collapse":"i18n.expand":p?"i18n.hideDetails":"i18n.showDetails")})]}),v&&(d&&c||!d&&p)&&(0,r.jsx)("pre",{style:{margin:0,padding:"9px 10px",borderTop:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:360,overflow:"auto",fontFamily:"var(--font-mono)"},children:y})]})})}function tz(e){return"string"==typeof e?e:e.filter(e=>"text"===e.type).map(e=>e.text).join("\n")}function tE({message:e,sessionId:t}){let[n,o]=(0,i.useState)(null),[l,s]=(0,i.useState)(!1),[a,d]=(0,i.useState)(null),c=!e.output&&void 0===e.exitCode&&!e.cancelled,u=e.cancelled||void 0!==e.exitCode&&0!==e.exitCode,p=t&&e.fullOutputPath?`/api/agent/${encodeURIComponent(t)}/bash-output?path=${encodeURIComponent(e.fullOutputPath)}`:null,h=e.truncated&&p&&null===n,g=n??e.output;async function x(){if(p){s(!0),d(null);try{let e=await fetch(p),t=await e.json();t.success?o(t.data?.output??""):d(t.error??"failed")}catch(e){d(String(e))}finally{s(!1)}}}let f=e.excludeFromContext?"bash (local)":"bash",m={type:"toolCall",toolCallId:`bash-${e.timestamp??""}`,toolName:f,input:{command:e.command}},v=c?void 0:{role:"toolResult",toolCallId:m.toolCallId,toolName:f,content:g?[{type:"text",text:g}]:[],isError:u,timestamp:e.timestamp};return(0,r.jsxs)("div",{style:{margin:"6px 0"},children:[(0,r.jsx)(tk,{block:m,result:v}),e.truncated&&p&&(0,r.jsxs)("div",{style:{padding:"4px 10px",fontSize:11,marginTop:-1},children:[h&&(0,r.jsx)("button",{onClick:x,disabled:l,style:{background:"none",border:"none",color:"var(--accent)",cursor:l?"default":"pointer",fontSize:11,padding:0,textDecoration:"underline"},children:l?"loading…":"view full output"}),(0,r.jsx)("a",{href:`${p}&download=1`,style:{marginLeft:10*!!h,color:"var(--accent)",fontSize:11,textDecoration:"underline"},children:"download full output"}),a&&(0,r.jsxs)("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:["(",a,")"]})]})]})}let tP=new Map;function t$(e){return{value:e.value,images:e.images.map(e=>({...e}))}}function tF(e){let t=tP.get(e);return t?t$(t):null}function tD(e,t){t.value||0!==t.images.length?tP.set(e,t$(t)):tP.delete(e)}function tN(e){if(!e||"object"!=typeof e||"string"!=typeof e.data||"string"!=typeof e.mimeType||!e.mimeType.startsWith("image/"))return!1;let t=function(e){if(!e||e.length%4!=0)return null;let t=e.endsWith("==")?2:+!!e.endsWith("="),n=e.length-t;for(let t=0;t<n;t+=1){var r;if(!((r=e.charCodeAt(t))>=65&&r<=90||r>=97&&r<=122||r>=48&&r<=57||43===r||47===r))return null}for(let t=n;t<e.length;t+=1)if("="!==e[t])return null;return e.length/4*3-t}(e.data);return null!==t&&t<=0xa00000}function tA(e){let t=/(?:^|\s)@"([^"\n]*)$/.exec(e);if(t)return{start:e.length-(t[1].length+2),query:t[1],quoted:!0};let n=/(?:^|\s)@([^\s"]*)$/.exec(e);return n?{start:e.length-(n[1].length+1),query:n[1],quoted:!1}:null}function tB(e){let t=0;for(let n=0;n<e.length;n++)"/"===e[n]&&t++;return t}function tH(e,t){if(!e)return!0;let n=0;for(let r=0;r<t.length&&n<e.length;r++)t[r]===e[n]&&n++;return n===e.length}function tO(e,t){let n=t?`${e}/`:e;return n.includes(" ")?`@"${n}" `:`@${n} `}let tU="(max-width: 640px)";function t_(e){if(!window.matchMedia)return()=>{};let t=window.matchMedia(tU);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function tV(){return!!window.matchMedia&&window.matchMedia(tU).matches}function tq(){return!1}function tK(){return(0,i.useSyncExternalStore)(t_,tV,tq)}let tJ=["off","default","full"],tY={off:"none",default:"default",full:"full"},tZ=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function tG(e,t){return tZ.compare(e.name||e.modelId,t.name||t.modelId)||tZ.compare(e.provider,t.provider)||tZ.compare(e.modelId,t.modelId)}let tX=["auto","off","minimal","low","medium","high","xhigh","max"],tQ={auto:"chat.thinkingUseDefault",off:"chat.thinkingOff",minimal:"chat.thinkingMinimal",low:"chat.thinkingLow",medium:"chat.thinkingMedium",high:"chat.thinkingHigh",xhigh:"chat.thinkingXhigh",max:"chat.thinkingMax"};function t0(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:e.toLocaleString()}let t1=[{name:"compact",description:"chat.commandCompact",source:"builtin"},{name:"reload",description:"chat.commandReload",source:"builtin"},{name:"name",description:"chat.commandName",source:"builtin"},{name:"session",description:"chat.commandSession",source:"builtin"},{name:"copy",description:"chat.commandCopy",source:"builtin"}],t2=["builtin","extension","prompt","skill"],t8={builtin:"chat.builtIn",extension:"chat.extensions",prompt:"chat.prompts",skill:"chat.skills"},t4={builtin:0,extension:1,prompt:2,skill:3};function t5(e,t,n){let r=e.name.toLowerCase(),i=t6(e,n).toLowerCase();return r===t?0:r.startsWith(t)?1:r.includes(t)?2:i.includes(t)?3:4}function t6(e,t){return"builtin"===e.source?t(e.description):e.description??""}function t3(e,t){return"skill"===e.source&&!!e.name.startsWith("skill:")&&!0===t[e.name.slice(6)]}function t9(e){return{data:e.data,mimeType:e.mimeType}}function t7(e){return{...e,previewUrl:`data:${e.mimeType};base64,${e.data}`}}function ne(e){return(e??[]).filter(tN).slice(0,10).map(t7)}function nt(e){e.previewUrl.startsWith("blob:")&&URL.revokeObjectURL(e.previewUrl)}function nn({kind:e,text:t}){return(0,r.jsxs)("div",{title:t,style:{display:"flex",alignItems:"center",gap:8,padding:"3px 10px",fontSize:12,color:"var(--text-muted)",minWidth:0},children:[(0,r.jsx)("span",{style:{flexShrink:0,fontSize:10,fontFamily:"var(--font-mono)",padding:"1px 7px",borderRadius:999,border:`1px solid ${"steer"===e?"color-mix(in srgb, var(--accent) 45%, transparent)":"var(--border)"}`,color:"steer"===e?"var(--accent)":"var(--text-dim)"},children:e}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})}function nr({tone:e,title:t,body:n}){let i="error"===e?"239,68,68":"234,179,8";return(0,r.jsxs)("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:8,maxHeight:120,marginBottom:8,padding:"7px 10px",overflowY:"auto",border:`1px solid rgba(${i},0.3)`,borderRadius:6,background:`rgba(${i},0.07)`,color:`rgb(${i})`,fontSize:11,lineHeight:1.45},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:1},"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M10.3 2.9 1.8 17a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 2.9a2 2 0 0 0-3.4 0Z"}),(0,r.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontWeight:600},children:t}),(0,r.jsx)("div",{style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:n})]})]})}function ni({error:e}){return e?(0,r.jsx)(nr,{tone:"error",title:"Model error",body:e}):null}function no({warnings:e}){return e&&0!==e.length?(0,r.jsx)(nr,{tone:"warning",title:e.length>1?"Model scope warnings":"Model scope warning",body:e.join("\n")}):null}let nl=(0,i.forwardRef)(function({onSend:e,onAbort:t,onSteer:n,onFollowUp:o,isStreaming:l,model:a,isAutoModelSelection:d,modelNames:c,modelList:u,modelError:p,modelScopeWarnings:h,onModelChange:x,onCompact:f,onAbortCompaction:m,isCompacting:v,compactError:y,compactResult:b,toolPreset:k,onToolPresetChange:w,thinkingLevel:j,onThinkingLevelChange:S,availableThinkingLevels:C,thinkingLevelMap:T,retryInfo:M,queuedMessages:R,inputHistory:I=[],onRecallQueue:L,slashCommands:W,slashCommandsLoading:z,onLoadSlashCommands:E,onBuiltinCommand:P,soundEnabled:$,onSoundToggle:F,onAudioUnlock:D,onPromptWithStreamingBehavior:N,draftKey:A,cwd:B},H){let U,_,V,q,K,J,Y,Z,G,X,Q,{t:ee}=(0,s.s)(),et=tK(),[en,er]=(0,i.useState)(()=>A?tF(A)?.value??"":""),[ei,eo]=(0,i.useState)(!1),[el,es]=(0,i.useState)(null),[ea,ed]=(0,i.useState)(""),[ec,eu]=(0,i.useState)(!1),[ep,eh]=(0,i.useState)(!1),[eg,ex]=(0,i.useState)(!1),[ef,em]=(0,i.useState)(()=>A?ne(tF(A)?.images):[]),ev=en.trimStart(),ey=0===ef.length&&ev.startsWith("!"),eb=ey&&ev.startsWith("!!"),[ek,ew]=(0,i.useState)(!1),[ej,eS]=(0,i.useState)(0),[eC,eT]=(0,i.useState)(null),[eM,eR]=(0,i.useState)(!1),[eI,eL]=(0,i.useState)(0),[eW,ez]=(0,i.useState)(!1),[eE,eP]=(0,i.useState)(0),[e$,eF]=(0,i.useState)(null),[eD,eN]=(0,i.useState)(!1),[eA,eB]=(0,i.useState)(null),[eH,eO]=(0,i.useState)(null),eU=B&&eH?.cwd===B?eH.values:{},e_=(0,i.useRef)(null),eV=(0,i.useRef)(null),eq=(0,i.useRef)(null),eK=(0,i.useRef)(null),eJ=(0,i.useRef)(null),eY=(0,i.useRef)(null),eZ=(0,i.useRef)(null),eG=(0,i.useRef)(null),eX=(0,i.useRef)(!1),eQ=(0,i.useRef)(0),e0=(0,i.useRef)(!1),e1=(0,i.useRef)([]),e2=(0,i.useRef)([]),e8=(0,i.useRef)([]),e4=(0,i.useRef)(null),e5=(0,i.useRef)(null),e6=(0,i.useRef)(A),e3=(0,i.useRef)(en),e9=(0,i.useRef)(ef),e7=(0,i.useRef)(0);e3.current=en,e9.current=ef,(0,i.useImperativeHandle)(H,()=>({insertIfEmpty(e){let t=e_.current;(t?t.value:en).trim()||(er(e),eT(null),requestAnimationFrame(()=>{t&&(t.focus(),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`)}))},prependText(e){if(!e.trim())return;let t=e_.current,n=[e,t?t.value:en].filter(e=>e.trim()).join("\n\n");er(n),eT(null),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(n.length,n.length),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`)})},insertText(e){let t=e_.current;if(!t)return void er(t=>t+(t?" ":"")+e);let n=t.selectionStart??t.value.length,r=t.selectionEnd??t.value.length,i=t.value.slice(0,n),o=t.value.slice(r),l=i.length>0&&!i.endsWith(" ")?" ":"";er(i+l+e+o),eT(null),requestAnimationFrame(()=>{if(!t)return;let r=n+l.length+e.length;t.setSelectionRange(r,r),t.focus(),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`})},addImages(e){te(e)}}));let te=(0,i.useCallback)(async e=>{if(l)return;let t=Math.max(0,10-e9.current.length-e7.current),n=e.filter(e=>e.type.startsWith("image/")&&e.size<=0xa00000).slice(0,t);if(n.length){e7.current+=n.length;try{let e=await Promise.all(n.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=r.result.split(",")[1];t({data:n,mimeType:e.type,previewUrl:URL.createObjectURL(e)})},r.onerror=n,r.readAsDataURL(e)})));em(t=>{let n=e.slice(0,Math.max(0,10-t.length));return e.slice(n.length).forEach(nt),[...t,...n]})}finally{e7.current-=n.length}}},[l]),tt=(0,i.useCallback)(e=>{em(t=>{let n=[...t],[r]=n.splice(e,1);return r&&nt(r),n})},[]),tn=(0,i.useCallback)(()=>{em(e=>(e.forEach(nt),[]))},[]),tr=(0,i.useCallback)(()=>{var e;er(""),eT(null),ez(!1),A&&tP.delete(A),e6.current&&e6.current!==A&&(e=e6.current,tP.delete(e)),tn(),e_.current&&(e_.current.style.height="auto")},[tn,A]);(0,i.useEffect)(()=>{A&&e6.current===A&&tD(A,{value:en,images:ef.map(t9)})},[ef,A,en]),(0,i.useEffect)(()=>{let e=e6.current;if(e===A)return;e&&tD(e,{value:e3.current,images:e9.current.map(t9)});let t=A?tF(A):null;e6.current=A,er(t?.value??""),eT(null),ez(!1),em(e=>(e.forEach(nt),ne(t?.images)))},[A]),(0,i.useEffect)(()=>{let e=e_.current;e&&(e.style.height="auto",en&&(e.style.height=`${Math.min(e.scrollHeight,200)}px`))},[en]),(0,i.useEffect)(()=>()=>{e9.current.forEach(nt)},[]);let ti=(0,i.useCallback)(async()=>{let t=en.trim();if((t||ef.length)&&!l){if(D?.(),!ef.length&&t.startsWith("/")&&P){let e=await P(t);if(e.handled){e.error||tr();return}}e(t,ef.length?ef:void 0),tr()}},[en,ef,l,P,e,tr,D]),to=en.startsWith("/")&&!/\s/.test(en.slice(1))?en.slice(1).toLowerCase():null,tl=null===to?[]:[...l?[]:t1,...W??[]].filter(e=>{let t=e.name.toLowerCase(),n=t6(e,ee).toLowerCase();return t.includes(to)||n.includes(to)}).sort((e,t)=>{let n=t5(e,to,ee)-t5(t,to,ee);return 0!==n?n:t4[e.source]-t4[t.source]||tZ.compare(e.name,t.name)}),{commands:ts,groups:ta}=(U=0,{commands:(_=t2.map(e=>{let t=tl.filter(t=>t.source===e),n="skill"===e?[...t.filter(e=>!t3(e,eU)),...t.filter(e=>t3(e,eU))]:t;return{source:e,items:n.map(e=>({command:e,index:U++}))}}).filter(e=>e.items.length>0)).flatMap(e=>e.items.map(({command:e})=>e)),groups:_}),td=1===tl.length?ee(to?"chat.match":"chat.command"):ee(to?"chat.matches":"chat.commands",{count:tl.length}),tc=!!en.trim()&&0===ef.length,tu=(0,i.useCallback)((e,t)=>{if(!B)return void eT(null);let n=t??e.length;eT(tA(e.slice(0,n)))},[B]),tp=eC?.query??null,th=i.useMemo(()=>null!==tp&&e$&&e$.cwd===B?function(e,t,n=20){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[];for(let t of e){let e=function(e,t){let n=e.path.toLowerCase(),r=0;if(t.includes("/"))n===t?r=100:n.startsWith(t)?r=80:n.includes(t)?r=50:tH(t,n)&&(r=10);else{let e=n.lastIndexOf("/"),i=-1===e?n:n.slice(e+1);i===t?r=100:i.startsWith(t)?r=80:i.includes(t)?r=50:n.includes(t)?r=30:tH(t,n)&&(r=10)}return e.isDir&&r>0&&(r+=10),r}(t,r);e>0&&i.push({entry:t,score:e})}return i.sort((e,t)=>t.score-e.score||tB(e.entry.path)-tB(t.entry.path)||e.entry.path.localeCompare(t.entry.path)),i.slice(0,n).map(e=>e.entry)}(e$.entries,tp):[],[tp,e$,B]),tg=!!(tp&&e$?.truncated&&e$.cwd===B);(0,i.useEffect)(()=>{if(!tg||!B||!tp)return;let e=setTimeout(()=>{fetch(`/api/file-index?cwd=${encodeURIComponent(B)}&q=${encodeURIComponent(tp)}`).then(e=>{if(!e.ok)throw Error(`file search failed: ${e.status}`);return e.json()}).then(e=>eB({cwd:B,query:tp,matches:e.matches??[]})).catch(()=>{})},150);return()=>clearTimeout(e)},[tg,tp,B]);let tx=tg&&null!==eA&&eA.cwd===B&&eA.query===tp,tf=tx?eA.matches:th,tm=null===eC?null:`${eC.start}:${+!!eC.quoted}:${eC.query}`;(0,i.useEffect)(()=>{if(null===tm){eR(!1),eL(0);return}eR(!0),eL(0)},[tm]);let tv=null!==eC;(0,i.useEffect)(()=>{if(!tv||!B)return;let e=e4.current;e&&e.cwd===B&&Date.now()-e.fetchedAt<1e4||e5.current===B||(e5.current=B,eN(!0),fetch(`/api/file-index?cwd=${encodeURIComponent(B)}`).then(e=>{if(!e.ok)throw Error(`file index failed: ${e.status}`);return e.json()}).then(e=>{eF({cwd:B,entries:function(e){let t=new Set;for(let n of e){let e=n.indexOf("/");for(;-1!==e;)t.add(n.slice(0,e)),e=n.indexOf("/",e+1)}let n=[];for(let e of t)n.push({path:e,isDir:!0});for(let t of e)t&&n.push({path:t,isDir:!1});return n.sort((e,t)=>tB(e.path)-tB(t.path)||e.path.localeCompare(t.path)),n}(e.files??[]),truncated:!!e.truncated}),e4.current={cwd:B,fetchedAt:Date.now()}}).catch(()=>{e4.current=null}).finally(()=>{e5.current=null,eN(!1)}))},[tv,B]);let ty=(0,i.useCallback)(e=>{if(!eC)return;let t=e_.current,n=t?.selectionStart??en.length,r=en.slice(0,eC.start),i=en.slice(n);eC.quoted&&i.startsWith('"')&&(i=i.slice(1));let o=function(e,t,n=!1){let r=t?`${e}/`:e,i=n||r.includes(" ");if(t){let e=i?`@"${r}"`:`@${r}`;return{text:e,cursorOffset:i?e.length-1:e.length}}let o=i?`@"${r}" `:`@${r} `;return{text:o,cursorOffset:o.length}}(e.path,e.isDir,eC.quoted),l=r+o.text+i,s=r.length+o.cursorOffset;er(l),eT(tA(l.slice(0,s))),requestAnimationFrame(()=>{let e=e_.current;e&&(e.focus(),e.setSelectionRange(s,s),e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)})},[eC,en]);(0,i.useEffect)(()=>{eI>=tf.length&&eL(Math.max(0,tf.length-1))},[tf.length,eI]),(0,i.useEffect)(()=>{e2.current.length=tf.length},[tf.length]),(0,i.useEffect)(()=>{eM&&e2.current[eI]?.scrollIntoView({block:"nearest",inline:"nearest"})},[eI,eM]),(0,i.useEffect)(()=>{eE>=I.length&&eP(Math.max(0,I.length-1))},[I.length,eE]),(0,i.useEffect)(()=>{e8.current.length=I.length},[I.length]),(0,i.useEffect)(()=>{eW&&e8.current[eE]?.scrollIntoView({block:"nearest",inline:"nearest"})},[eE,eW]);let tb=(0,i.useCallback)(e=>{er(e),ez(!1),eP(0),eT(null),requestAnimationFrame(()=>{let t=e_.current;t&&(t.focus(),t.setSelectionRange(e.length,e.length),t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`)})},[]),tk=(0,i.useCallback)(e=>{let t=`/${e.name} `;er(t),ew(!1),eS(0),requestAnimationFrame(()=>{let e=e_.current;e&&(e.focus(),e.setSelectionRange(t.length,t.length),e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)})},[]),tw=(0,i.useCallback)(e=>{let t=en.trim();if((t||ef.length)&&!ef.length){if(D?.(),t.startsWith("/")&&N){N(t,"steer"===e?"steer":"followUp",ef.length?ef:void 0),tr();return}"steer"===e&&n?n(t,ef.length?ef:void 0):"followup"===e&&o&&o(t,ef.length?ef:void 0),tr()}},[en,ef,N,n,o,tr,D]),tj=(0,i.useCallback)(e=>{let t=ts.length-1;if(t<0)return 0;if("left"===e)return Math.max(0,ej-1);if("right"===e)return Math.min(t,ej+1);let n=e1.current[ej];if(!n)return"down"===e?Math.min(t,ej+1):Math.max(0,ej-1);let r=n.getBoundingClientRect(),i=r.left+r.width/2,o=r.top+r.height/2,l=-1,s=1/0;for(let n=0;n<=t;n+=1){if(n===ej)continue;let t=e1.current[n];if(!t)continue;let r=t.getBoundingClientRect(),a=r.top+r.height/2-o;if("down"===e?a<=4:a>=-4)continue;let d=1e3*Math.abs(a)+Math.abs(r.left+r.width/2-i);d<s&&(l=n,s=d)}return l>=0?l:"down"===e?Math.min(t,ej+1):Math.max(0,ej-1)},[ts.length,ej]),tS=(0,i.useCallback)(e=>{let r=e.nativeEvent,i=Date.now()-eQ.current<100,s=eX.current||r.isComposing||229===r.keyCode;if("Enter"===e.key&&!e.shiftKey&&(s||i)){i&&e.preventDefault();return}if(eW&&!s){if("ArrowDown"===e.key){e.preventDefault(),eP(e=>Math.min(Math.max(0,I.length-1),e+1));return}if("ArrowUp"===e.key){e.preventDefault(),eP(e=>Math.max(0,e-1));return}if("Escape"===e.key){e.preventDefault(),ez(!1);return}if(("Tab"===e.key||"Enter"===e.key&&!e.shiftKey)&&I[eE]){e.preventDefault(),tb(I[eE]);return}}if(ek&&null!==to){if("ArrowDown"===e.key){e.preventDefault(),eS(tj("down"));return}if("ArrowUp"===e.key){e.preventDefault(),eS(tj("up"));return}if("ArrowRight"===e.key){e.preventDefault(),eS(tj("right"));return}if("ArrowLeft"===e.key){e.preventDefault(),eS(tj("left"));return}if("Escape"===e.key){e.preventDefault(),ew(!1);return}if(("Tab"===e.key||"Enter"===e.key&&!e.shiftKey)&&ts[ej]){e.preventDefault(),tk(ts[ej]);return}}if(eM&&null!==eC&&!s){if("ArrowDown"===e.key){e.preventDefault(),eL(e=>Math.min(Math.max(0,tf.length-1),e+1));return}if("ArrowUp"===e.key){e.preventDefault(),eL(e=>Math.max(0,e-1));return}if("Escape"===e.key){e.preventDefault(),eR(!1);return}if(("Tab"===e.key||"Enter"===e.key&&!e.shiftKey)&&tf[eI]){e.preventDefault(),ty(tf[eI]);return}}if("ArrowUp"===e.key&&!s&&!l&&I.length>0&&0===en.trim().length){e.preventDefault(),ew(!1),eR(!1),eP(I.length-1),ez(!0);return}if("Escape"===e.key&&!s&&l&&t){e.preventDefault(),t();return}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),l&&(n||o)?tw(n?"steer":"followup"):ti())},[l,n,o,t,ek,to,ts,ej,tk,tw,ti,tj,eM,eC,tf,eI,ty,eW,I,eE,tb,en]),tC=(0,i.useCallback)(()=>{let e=e_.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),tT=(0,i.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.type.startsWith("image/"));t.length&&(e.preventDefault(),te(t.map(e=>e.getAsFile()).filter(e=>null!==e)))},[te]);(0,i.useEffect)(()=>{if(null===to){ew(!1),eS(0),e0.current=!1;return}ew(!0),eS(0),!e0.current&&E&&(e0.current=!0,Promise.resolve(E()).catch(()=>{e0.current=!1}))},[to,E]),(0,i.useEffect)(()=>{if(!ek||!B)return;let e=!1;return eO({cwd:B,values:{}}),fetch(`/api/skills?cwd=${encodeURIComponent(B)}`).then(e=>{if(!e.ok)throw Error(`skills fetch failed: ${e.status}`);return e.json()}).then(t=>{if(e)return;let n={};for(let e of t.skills??[])n[e.name]=e.disableModelInvocation;eO({cwd:B,values:n})}).catch(()=>{e||eO({cwd:B,values:{}})}),()=>{e=!0}},[ek,B]),(0,i.useEffect)(()=>{ej>=ts.length&&eS(Math.max(0,ts.length-1))},[ts.length,ej]),(0,i.useEffect)(()=>{e1.current.length=ts.length},[ts.length]),(0,i.useEffect)(()=>{ek&&e1.current[ej]?.scrollIntoView({block:"nearest",inline:"nearest"})},[ej,ek]);let tM=u&&u.length>0?u.map(e=>({provider:e.provider,modelId:e.id,name:e.name})).sort(tG):Object.entries(c??{}).map(([e,t])=>({provider:a?.provider??"unknown",modelId:e,name:t})).sort(tG),tR=(V=ea.trim().toLocaleLowerCase())?tM.filter(e=>`${e.name} ${e.modelId}`.toLocaleLowerCase().includes(V)):tM,tI=tM.length>8,tL=[];for(let e of tR){let t=tL.find(t=>t.provider===e.provider);t?t.options.push(e):tL.push({provider:e.provider,options:[e]})}let tW=a?tM.find(e=>e.modelId===a.modelId&&e.provider===a.provider)?.name??a.modelId:null,tz=b?Math.max(0,b.tokensBefore-b.estimatedTokensAfter):0,tE=b?`${b.reason&&"manual"!==b.reason?`${b.reason[0].toUpperCase()}${b.reason.slice(1)} `:ee("chat.compacted")} ${t0(b.tokensBefore)} -> ${t0(b.estimatedTokensAfter)} tokens (${ee("chat.tokensSaved",{saved:t0(tz)})})`:null,t$="auto"!==(q=j??"auto")&&T?T[q]??q:q,tN=Object.entries(tY).find(([,e])=>e===(k??"default"))?.[0]??"default";return(0,i.useEffect)(()=>{let e=e=>{eV.current&&!eV.current.contains(e.target)&&eq.current&&!eq.current.contains(e.target)&&(eo(!1),ed("")),eK.current&&!eK.current.contains(e.target)&&eu(!1),eJ.current&&!eJ.current.contains(e.target)&&eh(!1),eY.current&&!eY.current.contains(e.target)&&ex(!1),!eZ.current||eZ.current.contains(e.target)||e_.current?.contains(e.target)||ez(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,i.useEffect)(()=>{et||ex(!1)},[et]),(0,r.jsxs)("div",{style:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:et?16:52},children:[(0,r.jsx)("input",{ref:eG,type:"file",accept:"image/*",multiple:!0,disabled:l,style:{display:"none"},onChange:e=>{te(Array.from(e.target.files??[])),e.target.value=""}}),(0,r.jsxs)("div",{style:{maxWidth:820,margin:"0 auto"},children:[(0,r.jsx)(ni,{error:p}),(0,r.jsx)(no,{warnings:h}),(R?.steering.length??0)+(R?.followUp.length??0)>0&&(0,r.jsxs)("div",{style:{marginBottom:8,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",padding:"5px 0"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"2px 8px 4px 10px"},children:[(0,r.jsx)("span",{style:{fontSize:10,fontFamily:"var(--font-mono)",color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4},children:ee("chat.queued",{count:(R?.steering.length??0)+(R?.followUp.length??0)})}),L&&(0,r.jsxs)("button",{onClick:L,title:ee("chat.recallTitle"),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 12px",fontSize:12,color:"var(--text)",background:"transparent",border:"1px solid var(--border)",borderRadius:7,cursor:"pointer",transition:"background 0.12s, border-color 0.12s",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.borderColor="color-mix(in srgb, var(--accent) 45%, var(--border))"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor="var(--border)"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"9 14 4 9 9 4"}),(0,r.jsx)("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),ee("chat.recall")]})]}),R?.steering.map((e,t)=>(0,r.jsx)(nn,{kind:"steer",text:e},`steer-${t}`)),R?.followUp.map((e,t)=>(0,r.jsx)(nn,{kind:"follow-up",text:e},`followup-${t}`))]}),M&&(0,r.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"})]}),ee("chat.retrying",{attempt:M.attempt,max:M.maxAttempts}),M.errorMessage&&(0,r.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",M.errorMessage]})]}),tE&&(0,r.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(16,185,129,0.08)",border:"1px solid rgba(16,185,129,0.24)",borderRadius:6,fontSize:12,color:"rgba(5,150,105,0.95)",display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),tE]}),y&&(0,r.jsx)("div",{role:"alert",style:{marginBottom:8,padding:"7px 10px",background:"rgba(239,68,68,0.07)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:6,color:"#ef4444",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:y}),ef.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:6,marginBottom:6,flexWrap:"wrap"},children:ef.map((e,t)=>(0,r.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,r.jsx)("img",{src:e.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:"1px solid var(--border)",display:"block"}}),(0,r.jsx)("button",{onClick:()=>tt(t),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,r.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},t))}),(0,r.jsxs)("div",{style:{position:"relative",minWidth:0},children:[eW&&I.length>0&&(0,r.jsxs)("div",{ref:eZ,style:{position:"absolute",left:0,right:0,bottom:"calc(100% + 8px)",zIndex:120,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -6px 20px rgba(0,0,0,0.12)",overflow:"hidden",maxHeight:"min(44vh, 360px)"},children:[(0,r.jsx)("div",{title:"Input history",style:{height:30,padding:"0 10px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",color:"var(--text-dim)"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),(0,r.jsx)("path",{d:"M3 4v5h5"}),(0,r.jsx)("path",{d:"M12 7v5l3 2"})]})}),(0,r.jsx)("div",{style:{maxHeight:"calc(min(44vh, 360px) - 31px)",overflowY:"auto",padding:4},children:I.map((e,t)=>{let n=t===eE;return(0,r.jsxs)("button",{ref:e=>{e8.current[t]=e},type:"button",onMouseDown:t=>{t.preventDefault(),tb(e)},onMouseEnter:()=>eP(t),style:{width:"100%",display:"flex",alignItems:"flex-start",gap:8,padding:"7px 8px",border:"none",borderRadius:6,background:n?"var(--bg-selected)":"none",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:12.5,lineHeight:1.45},children:[(0,r.jsx)("span",{style:{flexShrink:0,fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)",paddingTop:1},children:t+1}),(0,r.jsx)("span",{style:{minWidth:0,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden",overflowWrap:"anywhere"},children:e})]},`${t}:${e}`)})})]}),ek&&null!==to&&(0,r.jsxs)("div",{style:{position:"absolute",left:0,right:0,bottom:"calc(100% + 8px)",zIndex:120,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -6px 20px rgba(0,0,0,0.12)",overflow:"hidden",maxHeight:"min(56vh, 460px)"},children:[(0,r.jsxs)("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:11,color:"var(--text-dim)"},children:[(0,r.jsx)("span",{children:z?ee("chat.loadingCommands"):ee("chat.slashCommands",{label:td})}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},children:ee("chat.tabEnter")})]}),(0,r.jsx)("div",{style:{maxHeight:"calc(min(56vh, 460px) - 34px)",overflowY:"auto",padding:10},children:z||0!==tl.length?ta.map(e=>(0,r.jsxs)("section",{style:{marginBottom:12},children:[(0,r.jsxs)("div",{style:{position:"sticky",top:-10,zIndex:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"4px 0 6px",background:"var(--bg)",color:"var(--text-dim)",fontSize:10,fontWeight:600,textTransform:"uppercase"},children:[(0,r.jsx)("span",{children:ee(t8[e.source])}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontWeight:500},children:e.items.length})]}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:8},children:e.items.map(({command:e,index:t})=>{let n=t===ej,i=t3(e,eU);return(0,r.jsxs)("button",{ref:e=>{e1.current[t]=e},type:"button",onMouseDown:t=>{t.preventDefault(),tk(e)},onMouseEnter:()=>eS(t),style:{width:"100%",minWidth:0,minHeight:58,display:"flex",flexDirection:"column",gap:4,justifyContent:"center",padding:"9px 10px",border:`1px solid ${n?"var(--accent)":"var(--border)"}`,borderRadius:7,background:n?"var(--bg-selected)":"var(--bg-panel)",color:"var(--text)",cursor:"pointer",textAlign:"left",boxShadow:n?"0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent)":"none"},children:[(0,r.jsxs)("span",{style:{fontSize:13,fontFamily:"var(--font-mono)",overflowWrap:"anywhere",wordBreak:"break-word",color:i?"var(--text-dim)":void 0},children:["/",e.name,i&&(0,r.jsx)("span",{style:{marginLeft:6,padding:"0 4px",border:"1px solid var(--border)",borderRadius:3,fontSize:9,color:"var(--text-dim)",whiteSpace:"nowrap"},children:ee("chat.dormant")})]}),e.description&&(0,r.jsx)("span",{style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden",fontSize:11,lineHeight:1.35,color:"var(--text-dim)"},children:t6(e,ee)})]},`${e.source}:${e.name}`)})})]},e.source)):(0,r.jsx)("div",{style:{padding:"2px 2px 4px",fontSize:12,color:"var(--text-dim)"},children:ee("chat.noCommands")})})]}),eM&&null!==eC&&(K=eD&&(!e$||e$.cwd!==B),J=1===tf.length?ee("chat.match"):ee("chat.matches",{count:tf.length}),Y=e$?.truncated&&!tx?eC.query?ee("chat.searchingAll"):ee("chat.indexTruncated"):"",(0,r.jsxs)("div",{style:{position:"absolute",left:0,right:0,bottom:"calc(100% + 8px)",zIndex:120,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -6px 20px rgba(0,0,0,0.12)",overflow:"hidden",maxHeight:"min(48vh, 400px)"},children:[(0,r.jsxs)("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:11,color:"var(--text-dim)"},children:[(0,r.jsx)("span",{children:K?ee("chat.loadingFiles"):ee("chat.files",{label:J,hint:Y})}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},children:ee("chat.tabEnter")})]}),(0,r.jsx)("div",{style:{maxHeight:"calc(min(48vh, 400px) - 34px)",overflowY:"auto",padding:4},children:K||0!==tf.length?tf.map((e,t)=>{let n=t===eI,i=e.path.split("/").pop()??e.path,o=e.path.slice(0,e.path.length-i.length);return(0,r.jsxs)("button",{ref:e=>{e2.current[t]=e},type:"button",onMouseDown:t=>{t.preventDefault(),ty(e)},onMouseEnter:()=>eL(t),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"none",borderRadius:6,background:n?"var(--bg-selected)":"none",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:12.5,fontFamily:"var(--font-mono)"},children:[(0,r.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:e.isDir?(0,r.jsx)(g,{size:14}):O(i,14)}),(0,r.jsxs)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o&&(0,r.jsx)("span",{style:{color:"var(--text-dim)"},children:o}),i,e.isDir&&(0,r.jsx)("span",{style:{color:"var(--text-dim)"},children:"/"})]})]},`${e.isDir?"d":"f"}:${e.path}`)}):(0,r.jsx)("div",{style:{padding:"6px 8px",fontSize:12,color:"var(--text-dim)"},children:tg&&!tx?ee("chat.searching"):ee("chat.noMatchingFiles")})})]})),(0,r.jsxs)("div",{style:{minWidth:0,display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:`1px solid ${ey?"var(--tool-bg)":l&&(n||o)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:14,padding:"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,r.jsx)("textarea",{ref:e_,value:en,onChange:e=>{er(e.target.value),ez(!1),tu(e.target.value,e.target.selectionStart)},onSelect:e=>{let t=e.currentTarget;tu(t.value,t.selectionStart)},onKeyDown:tS,onCompositionStart:()=>{eX.current=!0},onCompositionEnd:e=>{eX.current=!1,eQ.current=Date.now();let t=e.currentTarget;tu(t.value,t.selectionStart)},onInput:tC,onPaste:tT,placeholder:l&&(n||o)?ee("chat.steerPlaceholder"):l?ee("chat.agentPlaceholder"):ee("chat.messagePlaceholder"),rows:1,style:{flex:1,minWidth:0,width:"100%",background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto"}}),l?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,alignSelf:"flex-end"},children:[n&&(0,r.jsxs)("button",{onClick:()=>tw("steer"),disabled:!tc,title:ef.length?"Image attachments cannot be queued while the agent is running":"Interrupt the current run and inject this message now",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:tc?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:tc?"rgba(180,130,0,1)":"var(--text-dim)",cursor:tc?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,r.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),ee("chat.steer")]}),o&&(0,r.jsxs)("button",{onClick:()=>tw("followup"),disabled:!tc,title:ef.length?"Image attachments cannot be queued while the agent is running":"Queue this message after the agent finishes",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:tc?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:tc?"rgba(99,102,241,1)":"var(--text-dim)",cursor:tc?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,r.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,r.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),ee("chat.followUp")]})]}):(0,r.jsxs)("button",{onClick:ti,disabled:!en.trim()&&!ef.length,style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:en.trim()||ef.length?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:en.trim()||ef.length?"#fff":"var(--text-dim)",cursor:en.trim()||ef.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:en.trim()||ef.length?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,r.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),ee("chat.send")]})]})]}),ey&&(0,r.jsxs)("div",{className:"text-xs px-2 py-1",style:{color:eb?"var(--text-muted)":"var(--accent)",marginTop:4},children:[ee("chat.shell")," \xb7 ",eb?ee("chat.outputLocal"):ee("chat.outputModel")]}),(0,r.jsxs)("div",{style:{marginTop:8,display:et?"grid":"flex",gridTemplateColumns:et?"minmax(0, 1fr) auto":void 0,alignItems:"center",gap:6},children:[(0,r.jsxs)("div",{style:{flex:et?"1 1 auto":"0 0 auto",minWidth:0,display:"flex",alignItems:"center",gap:2},children:[(0,r.jsx)("button",{onClick:()=>eG.current?.click(),disabled:l,title:ee("chat.attachImage"),style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:ef.length?"var(--accent)":"var(--text-muted)",cursor:l?"not-allowed":"pointer",opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color=ef.length?"var(--accent)":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=ef.length?"var(--accent)":"var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,r.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(tM.length>0||tW||p)&&x&&(0,r.jsxs)("div",{ref:eV,style:{position:"relative",flex:et?"1 1 auto":void 0,minWidth:0},children:[(0,r.jsxs)("button",{onClick:e=>{let t=e.currentTarget.getBoundingClientRect();es({top:t.top,left:t.left,width:t.width}),eo(e=>(e&&ed(""),!e))},disabled:l,style:{display:"flex",alignItems:"center",gap:6,justifyContent:et?"flex-start":void 0,padding:et?"8px 10px":"8px 12px",height:32,width:et?"100%":void 0,maxWidth:et?"100%":220,overflow:"hidden",background:ei?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=ei?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},title:tM.length>0?"Change model":"No available models",children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,r.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,r.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,r.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,r.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,r.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,r.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,r.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:tW??(tM.length>0?"Select model":"No models")})]}),ei&&el&&(G=(Z=window.visualViewport?.height??window.innerHeight)-el.top+6,X=Math.max(120,Math.min(el.top-8,.6*Z)),Q=et?{left:8,right:8,maxWidth:"calc(100vw - 16px)"}:{left:el.left,width:"max-content",minWidth:el.width},(0,r.jsxs)("div",{ref:eq,style:{position:"fixed",bottom:G,...Q,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",maxHeight:X,display:"flex",flexDirection:"column"},children:[tI&&(0,r.jsx)("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border)",flexShrink:0},children:(0,r.jsx)("input",{value:ea,onChange:e=>ed(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(ed(""),eo(!1))},placeholder:ee("chat.filterModels"),"aria-label":ee("chat.filterModels"),autoFocus:!0,autoComplete:"off",spellCheck:!1,style:{width:"100%",minWidth:220*!et,fontSize:11,fontFamily:"var(--font-mono)",padding:"5px 8px",border:"1px solid var(--border)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",boxSizing:"border-box"}})}),(0,r.jsx)("div",{style:{minHeight:0,overflowY:"auto"},children:0===tL.length?(0,r.jsx)("div",{style:{padding:"8px 12px",color:"var(--text-dim)",fontSize:12,whiteSpace:"nowrap"},children:ea.trim()?ee("chat.noMatchingModels"):"No available models"}):tL.map((e,t)=>(0,r.jsxs)("div",{children:[tL.length>1&&(0,r.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:t>0?"1px solid var(--border)":"none"},children:e.provider}),e.options.map(e=>{let t=e.modelId===a?.modelId&&e.provider===a?.provider;return(0,r.jsxs)("button",{onClick:()=>{eo(!1),ed(""),(!t||d)&&x(e.provider,e.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:t?"var(--bg-selected)":"none",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:t?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[t?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),e.name]},`${e.provider}:${e.modelId}`)})]},e.provider))})]}))]})]}),!et&&(0,r.jsx)("div",{style:{flex:1}}),(0,r.jsxs)("div",{ref:eY,style:{flex:"0 0 auto",display:"flex",alignItems:"center",justifyContent:"flex-end",position:"relative",marginLeft:et?0:"auto"},children:[et&&(0,r.jsx)("button",{type:"button",title:eg?void 0:ee("chat.moreControls"),"aria-label":ee("chat.moreControls"),"aria-expanded":eg,"aria-hidden":eg||void 0,tabIndex:eg?-1:void 0,onClick:()=>{eo(!1),ed(""),ex(!0)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:32,padding:"8px 10px",background:"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:eg?"default":"pointer",fontSize:12,fontWeight:500,visibility:eg?"hidden":"visible",pointerEvents:eg?"none":"auto",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{eg||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{eg||(e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)")},children:ee("chat.moreControls")}),(0,r.jsxs)("div",{style:{display:et?eg?"flex":"none":"flex",alignItems:"center",gap:et?1:2,...et?{position:"absolute",right:0,bottom:0,zIndex:60,padding:1,width:"max-content",maxWidth:"calc(100vw - 32px)",flexWrap:"nowrap",justifyContent:"flex-end",border:"1px solid color-mix(in srgb, var(--border) 72%, transparent)",borderRadius:10,background:"color-mix(in srgb, var(--bg-panel) 92%, var(--bg))",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",backdropFilter:"blur(10px)"}:null},children:[!l&&S&&(0,r.jsxs)("div",{ref:eJ,style:{position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>!l&&eh(e=>!e),disabled:l,title:ee("chat.changeReasoning",{level:t$}),"aria-label":ee("chat.changeReasoningLabel"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:et?"0 6px":"8px 12px",width:et?"auto":void 0,height:32,background:ep?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=ep?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,r.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,r.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(!et||eg)&&(0,r.jsx)("span",{style:{whiteSpace:"nowrap"},children:t$})]}),ep&&(0,r.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:180},children:tX.filter(e=>!C||"auto"===e||C.includes(e)).map(e=>{let t=(j??"auto")===e,n=ee(tQ[e]),i="auto"!==e&&T?T[e]:void 0,o=null!=i&&i!==e?i:e,l=null!=i&&i!==e;return(0,r.jsxs)("button",{onClick:()=>{eh(!1),t||S(e)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:t?"var(--bg-selected)":"none",border:"none",color:t?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:t?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[t?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsxs)("span",{style:{flex:1},children:[o,l&&(0,r.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",e,")"]})]}),(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:n})]},e)})})]}),!l&&w&&(0,r.jsxs)("div",{ref:eK,style:{position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>!l&&eu(e=>!e),disabled:l,title:ee("chat.changeToolPreset")+`: ${tN}`,"aria-label":ee("chat.changeToolPreset"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:et?"0 6px":"8px 12px",width:et?"auto":void 0,height:32,background:ec?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:l?"not-allowed":"pointer",fontSize:12,opacity:l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=ec?"var(--bg-hover)":"none",e.currentTarget.style.color="var(--text-muted)"},children:[(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(!et||eg)&&(0,r.jsx)("span",{style:{whiteSpace:"nowrap"},children:tN})]}),ec&&(0,r.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:120},children:tJ.map(e=>{let t=tY[e],n=(k??"default")===t,i="off"===e?ee("chat.noTools"):"default"===e?ee("chat.builtInTools",{count:4}):ee("chat.allBuiltInTools");return(0,r.jsxs)("button",{onClick:()=>{eu(!1),n||w(t)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:n?"var(--bg-selected)":"none",border:"none",color:n?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:n?600:400,whiteSpace:"nowrap"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="none")},children:[n?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,r.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,r.jsx)("span",{style:{width:10,flexShrink:0}}),(0,r.jsx)("span",{style:{flex:1},children:e}),(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:i})]},e)})})]}),!l&&f&&(0,r.jsx)("div",{children:(0,r.jsx)("button",{onClick:v?m:f,disabled:l&&!v,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:et?"0 6px":"8px 12px",width:et?"auto":void 0,height:32,background:v?"rgba(239,68,68,0.08)":"none",border:"none",borderRadius:9,color:v?"#ef4444":"var(--text-muted)",cursor:l&&!v?"not-allowed":"pointer",fontSize:12,opacity:l&&!v?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{(!l||v)&&(e.currentTarget.style.background=v?"rgba(239,68,68,0.16)":"var(--bg-hover)",e.currentTarget.style.color=v?"#ef4444":"var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background=v?"rgba(239,68,68,0.08)":"none",e.currentTarget.style.color=v?"#ef4444":"var(--text-muted)"},title:v?ee("chat.stopCompaction"):ee("chat.compactContext"),"aria-label":v?ee("chat.stopCompaction"):ee("chat.compactContext"),children:v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,r.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}),(!et||eg)&&(0,r.jsx)("span",{style:{whiteSpace:"nowrap"},children:ee("chat.compacting")})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,r.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,r.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,r.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),(!et||eg)&&(0,r.jsx)("span",{style:{whiteSpace:"nowrap"},children:ee("chat.compact")})]})})}),l&&(0,r.jsxs)("button",{onClick:t,title:ee("chat.stopAgent"),style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:32,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:9,color:"#ef4444",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,r.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),ee("chat.stop")]}),void 0!==F&&(0,r.jsx)("button",{onClick:F,title:$?ee("chat.disableSound"):ee("chat.enableSound"),"aria-label":$?ee("chat.disableSound"):ee("chat.enableSound"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:$?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:$?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)",e.currentTarget.style.opacity="1"},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color=$?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.opacity=$?"1":"0.55"},children:$?(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,r.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,r.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,r.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,r.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})}),et&&eg&&(0,r.jsx)("button",{type:"button",title:ee("chat.collapseControls"),"aria-label":ee("chat.collapseControls"),"aria-expanded":!0,onClick:()=>{eu(!1),eh(!1),ex(!1)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:32,padding:0,marginLeft:0,background:"var(--bg-hover)",border:"none",borderLeft:"1px solid color-mix(in srgb, var(--border) 72%, transparent)",borderRadius:"0 9px 9px 0",color:"var(--text)",cursor:"pointer",transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-selected)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-hover)"},children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})]})]})});var ns=n(88576),na=n.n(ns);function nd({level:e,children:t,headingIndex:n,onClick:i}){return(0,r.jsx)("button",{type:"button",className:na().heading,"data-level":e,"data-preview-heading-index":n??void 0,disabled:null===n||!i,onClick:e=>{e.stopPropagation(),null!==n&&i?.(n)},children:t})}let nc=[...e4??[],function(){return e=>{if(!Array.isArray(e.children))return;let t=e.children.filter(e=>"heading"===e.type&&"number"==typeof e.depth&&e.depth<=3);if(t.length>0){t.forEach((e,t)=>{e.data={...e.data,hProperties:{...e.data?.hProperties,"data-preview-heading-index":t}}}),e.children=t;return}let n=e.children.find(e=>"paragraph"===e.type);e.children=n?[n]:[]}}];function nu(e){let t=e?.properties,n=t?.dataPreviewHeadingIndex??t?.["data-preview-heading-index"];return"number"==typeof n?n:"string"==typeof n&&/^\d+$/.test(n)?Number(n):null}let np=(0,i.memo)(function({markdown:e,onHeadingClick:t,onAnswerClick:n}){return e?(0,r.jsx)("div",{className:na().outline,children:(0,r.jsx)(e_.oz,{remarkPlugins:nc,components:{h1:({children:e,node:n})=>(0,r.jsx)(nd,{level:1,headingIndex:nu(n),onClick:t,children:e}),h2:({children:e,node:n})=>(0,r.jsx)(nd,{level:2,headingIndex:nu(n),onClick:t,children:e}),h3:({children:e,node:n})=>(0,r.jsx)(nd,{level:3,headingIndex:nu(n),onClick:t,children:e}),h4:()=>null,h5:()=>null,h6:()=>null,p:({children:e})=>(0,r.jsx)("button",{type:"button",className:na().paragraph,onClick:n,children:e}),blockquote:()=>null,ul:()=>null,ol:()=>null,pre:()=>null,table:()=>null,hr:()=>null,a:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),code:({children:e})=>(0,r.jsx)(r.Fragment,{children:e})},children:e})}):null});function nh({messages:e,streamingMessage:t,scrollContainer:n,messageRefs:o,onRevealHistory:l}){let[s,a]=(0,i.useState)(!1),[d,c]=(0,i.useState)([]),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(600),[x,f]=(0,i.useState)(!1),[m,v]=(0,i.useState)(null),y=(0,i.useRef)(!1),b=(0,i.useRef)(null),k=(0,i.useRef)([]),w=(0,i.useRef)({nodes:[],gap:50,fillsHeight:!1}),j=(0,i.useRef)(null),S=(0,i.useRef)(new Map),C=(0,i.useRef)(null),T=(0,i.useRef)(null),M=(0,i.useRef)(null),R=(0,i.useMemo)(()=>t?[...e,t]:e,[e,t]),I=(0,i.useRef)(R);I.current=R;let L=(0,i.useMemo)(()=>(function(e,t){if(0===e.length)return{nodes:[],gap:50,fillsHeight:!1};let n=Math.max(1,t),r=Math.max(0,n-24);if(1===e.length)return{nodes:[{...e[0],topRatio:12/n}],gap:50,fillsHeight:!1};let i=r/(e.length-1),o=Math.min(50,i);return{nodes:e.map((e,t)=>({...e,topRatio:(12+t*o)/n})),gap:o,fillsHeight:i<=50}})(d,h),[d,h]),{nodes:W,gap:z}=L;w.current=L;let E=(0,i.useCallback)(e=>{T.current={index:e,until:Date.now()+1600},p(e)},[]),P=(0,i.useCallback)((e,t)=>{let n=T.current;if(n&&Date.now()<n.until)return void p(n.index);T.current=null;let r=t.filter(e=>null!==e.targetTurn.scrollTop);if(0===r.length)return void p(null);let i=e.scrollTop+.3*e.clientHeight;p(r.reduce((e,t)=>Math.abs((t.targetTurn.scrollTop??0)-i)<Math.abs((e.targetTurn.scrollTop??0)-i)?t:e,r[0]).index)},[]),$=(0,i.useCallback)(()=>{let e=n.current;if(!e)return;let t=e.scrollHeight-e.clientHeight,r=k.current;a(t>20),P(e,r)},[n,P]),F=(0,i.useRef)(null),D=(0,i.useCallback)(()=>{F.current||(F.current=setTimeout(()=>{F.current=null;let e=n.current,t=b.current;if(!e||!t)return;let r=o.current,i=e.getBoundingClientRect(),l=[],s=0,d=null;for(let t of I.current){if("user"!==t.role&&"assistant"!==t.role)continue;let n=r?.[s];if(s++,"user"===t.role){d=null;let r=n?.getBoundingClientRect();d={userMessage:t,assistantPreviews:[],scrollTop:r?r.top-i.top+e.scrollTop:null},l.push(d);continue}if(!d)continue;let o=function(e){if("assistant"!==e.role)return"";let{answerBlocks:t}=eO(e);return t.filter(e=>"text"===e.type).map(e=>e.text).join("\n\n").trim()}(t);o&&d.assistantPreviews.push({markdown:o,element:n})}let u=l.map((e,t)=>({topRatio:0,targetTurn:e,index:t}));g(t.clientHeight),k.current=u,c(u),a(e.scrollHeight-e.clientHeight>20),P(e,u);let p=M.current,h=p?u[p.nodeIndex]:null;if(p&&h){let t=void 0===p.assistantIndex?null:h.targetTurn.assistantPreviews[p.assistantIndex],n=h.targetTurn.scrollTop;if("assistant"===p.target){let r=t?.element?.getBoundingClientRect();n=r?r.top-i.top+e.scrollTop:null}else if("heading"===p.target){let r=void 0===p.headingIndex?null:t?.element?.querySelectorAll("h1, h2, h3").item(p.headingIndex),o=r?.getBoundingClientRect();n=o?o.top-i.top+e.scrollTop:null}if(null===n)return;M.current=null,E(h.index);let r=.3*e.clientHeight;e.scrollTo({top:Math.max(0,n-r),behavior:"smooth"})}},150))},[E,o,n,P]);(0,i.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener("scroll",$,{passive:!0}),()=>e.removeEventListener("scroll",$)},[n,$]),(0,i.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{D(),$()},r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),t(),()=>{r.disconnect(),F.current&&(clearTimeout(F.current),F.current=null)}},[D,n,$]),(0,i.useEffect)(()=>{let e=setTimeout(()=>{D(),$()},50);return()=>clearTimeout(e)},[e.length,D,$]);let N=(0,i.useCallback)((e,t)=>{let r=n.current;if(!r)return;if(E(e.index),null===e.targetTurn.scrollTop){M.current={nodeIndex:e.index,target:"user"},l();return}let i=Math.max(0,e.targetTurn.scrollTop-.3*r.clientHeight);r.scrollTo({top:i,behavior:t})},[E,l,n]),A=(0,i.useCallback)((e,t)=>{let r=n.current;if(!r)return;let i=e.targetTurn.assistantPreviews[t]?.element;if(!i){M.current={nodeIndex:e.index,target:"assistant",assistantIndex:t},l();return}let o=r.getBoundingClientRect(),s=i.getBoundingClientRect().top-o.top+r.scrollTop-.3*r.clientHeight;E(e.index),r.scrollTo({top:Math.max(0,s),behavior:"smooth"})},[E,l,n]),B=(0,i.useCallback)(e=>{let{nodes:t,gap:n,fillsHeight:r}=w.current,i=b.current?.clientHeight??0;if(0===t.length||i<=0)return null;let o=Math.max(0,Math.min(i,e*i)),l=t[0].topRatio*i,s=n>0?Math.round((o-l)/n):0,a=Math.max(0,Math.min(t.length-1,s)),d=t[a];if(!r&&Math.abs(o-d.topRatio*i)>Math.max(10,n/2))return null;return d},[]),H=(0,i.useCallback)((e,t,r)=>{let i=n.current;if(!i)return;let o=e.targetTurn.assistantPreviews[t]?.element;if(!o){M.current={nodeIndex:e.index,target:"heading",assistantIndex:t,headingIndex:r},l();return}let s=o.querySelectorAll("h1, h2, h3").item(r);if(!s)return;let a=i.getBoundingClientRect(),d=s.getBoundingClientRect().top-a.top+i.scrollTop-.3*i.clientHeight;E(e.index),i.scrollTo({top:Math.max(0,d),behavior:"smooth"})},[E,l,n]),O=(0,i.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),U=(0,i.useCallback)(()=>{O(),f(!0)},[O]),_=(0,i.useCallback)(()=>{O(),C.current=setTimeout(()=>{C.current=null,f(!1),v(null)},250)},[O]);(0,i.useEffect)(()=>()=>O(),[O]);let V=(0,i.useCallback)(e=>{if(!s)return;y.current=!0,U();let t=e.currentTarget.getBoundingClientRect();v(Math.max(0,Math.min(1,(e.clientY-t.top)/t.height)));let n=(e,n)=>{let r=B(Math.max(0,Math.min(1,(e-t.top)/t.height)));r&&N(r,n)};n(e.clientY,"smooth");let r=e=>{y.current&&n(e.clientY,"auto")},i=()=>{y.current=!1,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",i)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",i)},[B,N,U,s]),q=null===m?null:B(m),K=q?.index??null;if((0,i.useEffect)(()=>{if(!x||null===K)return;let e=j.current,t=S.current.get(K);if(!e||!t)return;let n=t.offsetTop-(e.clientHeight-t.offsetHeight)/2;e.scrollTop=Math.max(0,n)},[d,x,K]),!s)return null;let J=Math.max(1,(W.length>0?W[W.length-1].topRatio*h:12)-12);return(0,r.jsxs)("div",{ref:b,onMouseDown:V,onMouseEnter:U,onMouseLeave:_,onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();v((e.clientY-t.top)/t.height)},style:{width:36,flexShrink:0,position:"relative",cursor:"pointer",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,r.jsx)("div",{style:{position:"absolute",left:"50%",top:12,height:J,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),W.map(e=>{let t=x&&q?.index===e.index,n=u===e.index;return(0,r.jsx)("div",{"data-minimap-node-index":e.index,"data-minimap-node-active":n?"":void 0,style:{position:"absolute",top:`${100*e.topRatio}%`,transform:"translateY(-50%)",left:0,right:0,height:Math.max(1,z),display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",zIndex:2},children:(0,r.jsx)("div",{style:{width:8,height:8,borderRadius:2,background:n?"rgba(128,128,128,0.42)":"rgba(128,128,128,0.16)",border:`1.5px solid ${n?"rgba(128,128,128,0.95)":"rgba(128,128,128,0.58)"}`,boxShadow:n?"0 0 0 2px var(--bg-panel)":"none",transition:"transform 0.1s, background 0.1s",transform:t?"scale(1.25)":"scale(1)"}})},e.index)}),x&&d.length>0&&(0,r.jsx)("div",{ref:j,className:na().preview,"data-minimap-preview-box":"",onMouseEnter:U,onMouseDown:e=>e.stopPropagation(),onMouseMove:e=>e.stopPropagation(),children:d.map(e=>{var t;let n=K===e.index;return(0,r.jsxs)("div",{ref:t=>{t?S.current.set(e.index,t):S.current.delete(e.index)},className:na().turn,"data-minimap-preview-index":e.index,"data-located":n?"true":void 0,children:[(0,r.jsx)("span",{className:na().number,"aria-hidden":"true",children:String(e.index+1).padStart(2,"0")}),(0,r.jsxs)("div",{className:na().content,children:[(0,r.jsx)("button",{type:"button",className:na().user,"data-minimap-preview-user":e.index,onClick:()=>{N(e,"smooth")},children:(0,r.jsx)("span",{className:na().userText,children:"string"==typeof(t=e.targetTurn.userMessage).content?t.content.trim():t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n").trim()})}),e.targetTurn.assistantPreviews.map((t,n)=>(0,r.jsxs)("div",{className:na().assistant,children:[(0,r.jsx)("button",{type:"button",className:na().assistantJump,"data-minimap-preview-assistant":`${e.index}-${n}`,onClick:()=>A(e,n),"aria-label":"Locate assistant message",title:"Locate assistant message",children:"A"}),(0,r.jsx)(np,{markdown:t.markdown,onAnswerClick:()=>A(e,n),onHeadingClick:t=>H(e,n,t)})]},n))]})]},e.index)})})]})}function ng({statuses:e}){if(0===e.length)return null;let t=[...e].sort((e,t)=>e.key.localeCompare(t.key)).map(({text:e})=>e.replace(/[\r\n\t]/g," ").replace(/ +/g," ").trim()).join(" "),n=ez(t);return(0,r.jsx)("div",{role:"status","aria-label":n,title:n,style:{display:"flex",alignItems:"center",flexShrink:0,minWidth:0,height:36,padding:"0 12px",borderTop:"1px solid var(--border)",background:"transparent"},children:(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontSize:11,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:eF(t).map((e,t)=>(0,r.jsx)("span",{style:e.style,children:e.text},t))})})}function nx(e){if("assistant"!==e.role)return e;let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>("object"!=typeof e||null===e||Array.isArray(e)||"toolCall"!==e.type?null:{type:"toolCall",toolCallId:"string"==typeof e.toolCallId?e.toolCallId:"string"==typeof e.id?e.id:"",toolName:"string"==typeof e.toolName?e.toolName:"string"==typeof e.name?e.name:"",input:"object"!=typeof e.input||null===e.input||Array.isArray(e.input)?"object"!=typeof e.arguments||null===e.arguments||Array.isArray(e.arguments)?{}:e.arguments:e.input})??e);return{...e,content:n}}async function nf(e,t){let n=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok||r.error)throw Error(r.error??`HTTP ${n.status}`);return r.data}var nm=n(14755);function nv(e,t){switch(t.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:t.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return e}}function ny(e){return{steering:e?.steering??[],followUp:e?.followUp??[]}}let nb=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," ","Space","Spacebar"]);class nk extends Error{constructor(e){super("timeout"===e?"Timed out connecting to the agent event stream. Please try again.":"Failed to connect to the agent event stream. Please try again."),this.status=e,this.name="EventStreamConnectionError"}}function nw(e){return new Promise(t=>setTimeout(t,e))}function nj(e){let t=e.findIndex(e=>!e.exiting);return -1===t?e:e.map((e,n)=>n===t?{...e,exiting:!0}:e)}function nS(e,t){switch(t.type){case"add":if(e.visible.some(e=>e.exiting)||e.visible.length>=5)return{visible:e.visible.some(e=>e.exiting)?e.visible:nj(e.visible),pending:[...e.pending,t.notice]};return{...e,visible:[...e.visible,t.notice]};case"mark_oldest_exiting":return{...e,visible:nj(e.visible)};case"remove":return function(e,t){let n=e,r=t;for(;r.length>0&&n.length<5;){let[e,...t]=r;n=[...n,e],r=t}return r.length>0&&!n.some(e=>e.exiting)&&(n=nj(n)),{visible:n,pending:r}}(e.visible.filter(e=>e.id!==t.id),e.pending);default:return e}}function nC(e){if(!e||"object"!=typeof e||"image"!==e.type)return"";let t=e.source;return t&&"object"==typeof t?["url"===t.type?"url":"base64","string"==typeof t.media_type?t.media_type:"","string"==typeof t.data?t.data:"","string"==typeof t.url?t.url:""].join(":"):["base64","string"==typeof e.mimeType?e.mimeType:"","string"==typeof e.data?e.data:"",""].join(":")}function nT(e){let t,n=e.content;return"string"==typeof n?JSON.stringify({text:n,images:[]}):Array.isArray(n)?JSON.stringify({text:"string"==typeof(t=e.content)?t:Array.isArray(t)?t.map(e=>e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text?e.text:"").filter(Boolean).join("\n"):"",images:n.map(nC).filter(Boolean)}):JSON.stringify({text:"",images:[]})}function nM(e,t){return e&&"object"==typeof e?"number"!=typeof e.tokensBefore||"number"!=typeof e.estimatedTokensAfter?null:{reason:t,tokensBefore:e.tokensBefore,estimatedTokensAfter:e.estimatedTokensAfter}:null}function nR(e){return"user"===e.role||"custom"===e.role&&"compaction"===e.customType}function nI(e,t,n={}){let r={...e,content:t};return n.omitUsage&&(r.usage=void 0),r}function nL({messageCount:e,toolCallCount:t,children:n,t:o}){let[l,s]=(0,i.useState)(!1),a=[o("chat.processDetails"),`${e} ${o(1===e?"chat.message":"chat.messages")}`];return t>0&&a.push(`${t} ${o(1===t?"chat.toolCall":"chat.toolCalls")}`),(0,r.jsxs)("div",{style:{marginBottom:14},children:[(0,r.jsxs)("button",{type:"button","aria-expanded":l,onClick:()=>s(e=>!e),style:{display:"flex",alignItems:"center",gap:8,width:"auto",minHeight:24,padding:"2px 0",border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left"},title:o(l?"chat.collapseProcess":"chat.expandProcess"),children:[(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:l?"rotate(90deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("polyline",{points:"4 2.5 7.5 6 4 9.5"})}),(0,r.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.join(" \xb7 ")})]}),l&&(0,r.jsx)("div",{style:{marginTop:8},children:n})]})}function nW({session:e,newSessionCwd:t,onAgentEnd:o,onSessionCreated:a,onSessionForked:d,modelsRefreshKey:c,chatInputRef:u,onBranchDataChange:p,onSystemPromptChange:h,onSessionStatsChange:g,onSessionStatsPanelOpen:x,onContextUsageChange:f,onOpenFile:m}){var v;let y,{t:b}=(0,s.s)(),{soundEnabled:k,onSoundToggle:w,playDoneSound:j,unlockAudio:S}=function(){let[e,t]=(0,i.useState)(()=>{let e=localStorage.getItem("pi-sound-enabled");return null===e||"true"===e}),n=(0,i.useRef)(e);(0,i.useEffect)(()=>{n.current=e},[e]);let r=(0,i.useRef)(null),o=(0,i.useCallback)(()=>{if(r.current&&"closed"!==r.current.state)return r.current;try{r.current=new AudioContext}catch{return null}return r.current},[]),l=(0,i.useCallback)((e=!1)=>{if(!e&&!n.current)return;let t=o();t&&"suspended"===t.state&&t.resume().catch(()=>{})},[o]);return{soundEnabled:e,onSoundToggle:(0,i.useCallback)(()=>{let e=!n.current;e&&l(!0),n.current=e,localStorage.setItem("pi-sound-enabled",String(e)),t(e)},[l]),playDoneSound:(0,i.useCallback)(()=>{if(!n.current)return;let e=o();if(!e)return;let t=()=>{try{let t;t=e.currentTime,[523.25,659.25].forEach((n,r)=>{let i=e.createOscillator(),o=e.createGain();i.connect(o),o.connect(e.destination),i.type="sine",i.frequency.value=n;let l=t+.18*r;o.gain.setValueAtTime(0,l),o.gain.linearRampToValueAtTime(.18,l+.02),o.gain.exponentialRampToValueAtTime(.001,l+.45),i.start(l),i.stop(l+.45)})}catch{}};"suspended"===e.state?e.resume().then(t).catch(()=>{}):t()},[o]),unlockAudio:l,soundEnabledRef:n}}(),C=tK(),T=(0,i.useRef)(j);T.current=j;let M=(0,i.useRef)(k);M.current=k;let R=(0,i.useRef)(null),I=(0,i.useCallback)(()=>{M.current&&T.current(),o?.()},[o]),L=(0,i.useCallback)(e=>{u?.current?.insertIfEmpty(e)},[u]),{loading:W,error:z,messages:E,entryIds:P,streamState:$,agentRunning:F,bashRunning:D,pendingBash:N,modelNames:A,modelList:B,modelError:H,modelScopeWarnings:O,modelThinkingLevels:U,modelThinkingLevelMaps:_,toolPreset:V,thinkingLevel:q,retryInfo:K,contextUsage:J,forkingEntryId:Y,isCompacting:Z,compactError:G,compactResult:X,displayModel:Q,sessionStats:ee,slashCommands:et,slashCommandsLoading:en,queuedMessages:er,notices:ei,extensionDialog:eo,extensionCustomUi:el,extensionStatuses:es,extensionWidgets:ea,respondToExtensionUi:ed,sendExtensionCustomInput:ec,isAutoModelSelection:eu,agentPhase:ep,isNew:eh,sessionIdRef:eg,messagesEndRef:ex,scrollContainerRef:ef,lastUserMsgRef:em,handleSend:ev,handleAbort:ey,handleFork:eb,handleNavigate:ek,handleModelChange:ew,handleCompact:ej,handleSteer:eS,handleFollowUp:eC,handlePromptWithStreamingBehavior:eT,handleAbortCompaction:eM,handleRecallQueue:eR,handleBuiltinSlashCommand:eI,handleToolPresetChange:eL,handleThinkingLevelChange:eW,loadSlashCommands:ez}=function(e){let{session:t,newSessionCwd:r,onAgentEnd:o,onSessionCreated:l,onSessionForked:s,modelsRefreshKey:a,onBranchDataChange:d,onSystemPromptChange:c,onSessionStatsPanelOpen:u}=e,p=null===t&&null!==r,[h,g]=(0,i.useState)(null),[x,f]=(0,i.useState)(!p),[m,v]=(0,i.useState)(null),[y,b]=(0,i.useState)(null),[k,w]=(0,i.useState)([]),[j,S]=(0,i.useState)([]),[C,T]=(0,i.useReducer)(nv,{isStreaming:!1,streamingMessage:null}),[M,R]=(0,i.useState)(!1),[I,L]=(0,i.useState)(!1),[W,z]=(0,i.useState)(null),[E,P]=(0,i.useState)({}),[$,F]=(0,i.useState)([]),[D,N]=(0,i.useState)(null),[A,B]=(0,i.useState)([]),[H,O]=(0,i.useState)({}),[U,_]=(0,i.useState)({}),[V,q]=(0,i.useState)(null),[K,J]=(0,i.useState)(null),[Y,Z]=(0,i.useState)("default"),[G,X]=(0,i.useState)("auto"),[Q,ee]=(0,i.useState)(null),[et,en]=(0,i.useState)(null),[er,ei]=(0,i.useState)(null),[eo,el]=(0,i.useState)(null),[es,ea]=(0,i.useState)(null),[ed,ec]=(0,i.useState)(null),[eu,ep]=(0,i.useState)(!1),[eh,eg]=(0,i.useState)(null),[ex,ef]=(0,i.useState)(null),[em,ev]=(0,i.useState)(null),[ey,eb]=(0,i.useState)([]),[ek,ew]=(0,i.useState)(!1),[ej,eS]=(0,i.useReducer)(nS,{visible:[],pending:[]}),[eC,eT]=(0,i.useState)(null),[eM,eR]=(0,i.useState)(null),[eI,eL]=(0,i.useState)(null),[eW,ez]=(0,i.useState)([]),[eE,eP]=(0,i.useState)([]),[e$,eF]=(0,i.useState)({steering:[],followUp:[]}),eD=(0,i.useRef)(null),eN=(0,i.useRef)(null),eA=(0,i.useRef)(null),eB=(0,i.useRef)(null),eH=(0,i.useRef)(0),eO=(0,i.useRef)(!1),eU=(0,i.useRef)(t?.id??null),e_=(0,i.useRef)(!1),eV=(0,i.useRef)(!1),eq=(0,i.useRef)(!1),eK=(0,i.useRef)(-1),eJ=(0,i.useRef)(!1),eY=(0,i.useRef)(0),eZ=(0,i.useRef)(null),eG=(0,i.useRef)(!1),eX=(0,i.useRef)(null),eQ=(0,i.useRef)(!1),e0=(0,i.useRef)(!0),e1=(0,i.useRef)(void 0),e2=(0,i.useRef)(0),e8=(0,i.useRef)(0),e4=(0,i.useRef)(null),e5=(0,i.useRef)(null),e6=(0,i.useRef)(null),e3=(0,i.useRef)(!1),e9=(0,i.useRef)(null),e7=(0,i.useRef)(null),te=(0,i.useRef)(0),tt=(0,i.useRef)(null),tn=e.setToolPreset??Z,tr=es??h?.context.model??ed??null,ti=p?V??K:tr,to=(0,i.useMemo)(()=>{if(eC)return eC;let e={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},n=0,r=0,i=0,o=0,l=0;for(let t of k){if("user"===t.role&&(r+=1),"toolResult"===t.role&&(o+=1),"assistant"!==t.role)continue;i+=1;let s=t.usage;l+=t.content.filter(e=>"toolCall"===e.type).length,s&&(e.input+=s.input??0,e.output+=s.output??0,e.cacheRead+=s.cacheRead??0,e.cacheWrite+=s.cacheWrite??0,n+=s.cost?.total??0)}return(e.total=e.input+e.output+e.cacheRead+e.cacheWrite,0===e.total&&0===k.length)?null:{sessionFile:h?.filePath||void 0,sessionId:eU.current??t?.id??"",sessionName:t?.name,userMessages:r,assistantMessages:i,toolCalls:l,toolResults:o,totalMessages:k.length,tokens:e,cost:n,...et?{contextUsage:et}:{}}},[k,eC,et,h?.filePath,t?.id,t?.name]),tl=(0,i.useCallback)(async(e,t=!1,n=!1)=>{let r=!1;try{t&&f(!0);let i=new URLSearchParams({deferThinking:"1",deferMedia:"1"}),o=await fetch(`/api/sessions/${encodeURIComponent(e)}?${i}`);if(404===o.status)return t&&(g(null),b(null),w([]),v(null)),null;if(!o.ok)throw Error(`HTTP ${o.status}`);let l=await o.json();if(eU.current!==e||(g(l),b(l.leafId),w(l.context.messages),S(l.context.entryIds??[]),ea(null),v(null),l.context.thinkingLevel&&"off"!==l.context.thinkingLevel&&X(l.context.thinkingLevel),r=!0,t&&f(!1),!n))return null;try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(eU.current!==e)return null;let r=n.state;return r?(void 0!==r.contextUsage&&en(r.contextUsage??null),void 0!==r.systemPrompt&&ei(r.systemPrompt??null),void 0!==r.thinkingLevel&&X(r.thinkingLevel??"auto"),void 0!==r.extensionStatuses&&ez(r.extensionStatuses??[]),void 0!==r.extensionWidgets&&eP(r.extensionWidgets??[]),void 0!==r.queuedMessages&&eF(ny(r.queuedMessages))):n.running||eF({steering:[],followUp:[]}),n}catch(e){return console.error("Failed to load agent state:",e),null}}catch(e){return v(String(e)),null}finally{t&&!r&&f(!1)}},[]),ts=(0,i.useCallback)(async(e,t)=>{try{let n=new URLSearchParams({deferThinking:"1",deferMedia:"1"});t&&n.set("leafId",t);let r=`/api/sessions/${encodeURIComponent(e)}/context?${n}`,i=await fetch(r);if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();w(o.context.messages),S(o.context.entryIds??[])}catch(e){console.error("Failed to load context:",e)}},[]),ta=(0,i.useCallback)(async e=>{try{let t=await nf(e,{type:"get_tools"});if(t){let{getPresetFromTools:e}=await Promise.resolve().then(n.bind(n,14755));tn(e(t))}}catch(e){console.error("Failed to load tools:",e)}},[tn]),td=(0,i.useCallback)((e=0,t="(no messages)")=>{let n=eU.current;p&&r&&n&&!e3.current&&(e3.current=!0,l?.({id:n,path:"",cwd:r,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:e,firstMessage:t}))},[p,r,l]),tc=(0,i.useCallback)(async()=>{if(eU.current||!p||!r)return eU.current;if(e6.current)return e6.current;let e=(async()=>{let e=e9.current,t=e7.current;e&&ec(e);let n=(0,nm.xG)(Y),i=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:r,type:"ensure_session",toolNames:n,...e?{provider:e.provider,modelId:e.modelId}:{},...t?{thinkingLevel:t}:{}})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json(),l=o.sessionId;return eU.current=l,o.model&&e9.current===e&&(ec(o.model),e||J(o.model)),o.thinkingLevel&&e7.current===t&&X(o.thinkingLevel),l})();e6.current=e;try{return await e}finally{e6.current=null}},[p,r,Y]),tu=(0,i.useCallback)(async()=>{let e=eU.current??await tc();if(!e)return eb([]),[];ew(!0);try{let t=await nf(e,{type:"get_commands"}),n=t?.commands??[];return eb(n),n}catch(e){return console.error("Failed to load slash commands:",e),eb([]),[]}finally{ew(!1)}},[tc]),tp=(0,i.useCallback)(()=>{eH.current+=1,eO.current=!1,eB.current&&(clearTimeout(eB.current),eB.current=null)},[]),th=(0,i.useCallback)(()=>{eD.current?.close(),eD.current=null,eN.current=null,eA.current=null},[]),tg=(0,i.useCallback)(e=>{th();let t=new EventSource(`/api/agent/${encodeURIComponent(e)}/events`);eD.current=t,eN.current=e;let n=new Promise(n=>{let r=!1,i=e=>{r||(r=!0,clearTimeout(o),eA.current?.source===t&&(eA.current.pending=!1),n({status:e,source:t}))},o=setTimeout(()=>i("timeout"),5e3);t.onmessage=e=>{try{let t=JSON.parse(e.data);"connected"===t.type&&i("connected"),eZ.current?.(t)}catch{}},t.onerror=()=>{if(t.readyState===EventSource.CLOSED&&(i("closed"),eD.current===t&&(e_.current||eO.current))){eD.current=null,eN.current=null,eA.current=null;let t=eH.current;setTimeout(()=>{t===eH.current&&!eD.current&&(e_.current||eO.current)&&tg(e)},1e3)}}});return eA.current={source:t,promise:n,pending:!0},n},[th]),tx=(0,i.useCallback)(async e=>{let t=eD.current;if(t&&eN.current===e){if(t.readyState===EventSource.OPEN)return;let e=eA.current;if(e?.source===t&&e.pending&&(await e.promise,eD.current===t&&t.readyState===EventSource.OPEN))return}let n=await tg(e);if("connected"!==n.status&&n.source.readyState!==EventSource.OPEN)throw eD.current===n.source&&(eD.current=null),eN.current===e&&(eN.current=null),eA.current?.source===n.source&&(eA.current=null),n.source.close(),new nk(n.status)},[tg]),tf=(0,i.useCallback)(async(e,t)=>{let n=eU.current;if(eR(t=>t?.id===e.id?null:t),n)try{await nf(n,{type:"extension_ui_response",id:e.id,...t})}catch(e){console.error("Failed to send extension UI response:",e)}},[]),tm=(0,i.useCallback)(async(e,t)=>{let n=eU.current;if(n)try{await nf(n,{type:"extension_ui_input",id:e.id,data:t})}catch(e){console.error("Failed to send extension custom UI input:",e)}},[]),tv=(0,i.useCallback)(e=>{let t=e.message.trim();t&&eS({type:"add",notice:{id:e.id??("u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`),message:t,type:e.type??"info"}})},[]),ty=(0,i.useCallback)(t=>{switch(t.method){case"select":case"confirm":case"input":case"editor":eR(t);break;case"notify":tv({id:t.id,message:t.message,type:t.notifyType??"info"});break;case"setStatus":ez(e=>{let n=e.filter(e=>e.key!==t.statusKey);return void 0!==t.statusText?[...n,{key:t.statusKey,text:t.statusText}]:n});break;case"setWidget":eP(e=>{let n=e.filter(e=>e.key!==t.widgetKey);return t.widgetLines?[...n,{key:t.widgetKey,lines:t.widgetLines,placement:t.widgetPlacement??"aboveEditor"}]:n});break;case"setTitle":t.title&&(document.title=t.title);break;case"set_editor_text":e.chatInputRef?.current?.insertText(t.text);break;case"custom":eL(e=>t.closed?e?.id===t.id?null:e:t)}},[tv,e.chatInputRef]),tb=(0,i.useCallback)(()=>{let e=e_.current;return e_.current=!1,R(!1),ev(null),ee(null),T({type:"end"}),e},[]),tk=(0,i.useCallback)(e=>eK.current!==e&&(eK.current=e,o?.(),!0),[o]),tw=(0,i.useCallback)(e=>{tp(),eO.current=!0;let t=eH.current,n=async()=>{if(t===eH.current&&eU.current===e&&eO.current)try{let r=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();if(t!==eH.current||eU.current!==e||!eO.current)return;let o=i.state;if(i.running&&o&&(o.isStreaming||o.isPromptRunning)){eO.current=!1,eB.current=null,eV.current=!!o?.isStreaming,eq.current=!!o?.isPromptRunning,e_.current=!0,R(!0),ev(o?.isStreaming?{kind:"waiting_model"}:{kind:"running_command"});return}if(i.running&&o?.isCompacting){ep(!0),eB.current=setTimeout(()=>void n(),600);return}eO.current=!1,eB.current=null,th()}catch{if(t!==eH.current||eU.current!==e||!eO.current)return;eB.current=setTimeout(()=>void n(),600)}};eB.current=setTimeout(()=>void n(),3e4)},[tp,th]),tj=(0,i.useCallback)(async(e=eU.current,t=te.current)=>{if(te.current===t)try{e&&await tl(e)}finally{if(te.current!==t)return;let n=eq.current,r=eV.current;eq.current=!1,eV.current=!1,tt.current=null;let i=tb();n?tk(t):r&&i&&o?.(),e&&tw(e)}},[tl,tk,o,tw,tb]),tS=(0,i.useCallback)(async(e,t)=>{await nw(800);let n=Date.now();for(;e_.current&&Date.now()-n<2e4;){if(void 0!==t&&te.current!==t)return;try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(n.ok){let r=await n.json(),i=r.state;if(!r.running||!i||!i.isStreaming&&!i.isPromptRunning)return void await tj(e,t)}}catch{}await nw(600)}},[tj]),tC=(0,i.useCallback)(async e=>{let t=eY.current+1;for(eY.current=t;eJ.current&&eY.current===t&&eU.current===e;){await nw(1e3);try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!n.ok)continue;let r=await n.json();if(r.state?.isBashRunning)continue;if(await tl(e),eY.current!==t||eU.current!==e)return;eJ.current=!1,L(!1),z(null);return}catch{}}},[tl]),tT=(0,i.useCallback)(async e=>{if(!e_.current)return;let t=te.current;try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!n.ok)return;let r=await n.json();if(te.current!==t)return;let i=r.state;if(ep(i?.isCompacting??!1),eF(ny(i?.queuedMessages)),r.running&&i&&(i.isStreaming||i.isPromptRunning||i.isCompacting)||!e_.current)return;i&&(void 0!==i.contextUsage&&en(i.contextUsage??null),void 0!==i.systemPrompt&&ei(i.systemPrompt??null),void 0!==i.extensionStatuses&&ez(i.extensionStatuses??[]),void 0!==i.extensionWidgets&&eP(i.extensionWidgets??[])),await tj(e,t)}catch{}},[tj]);(0,i.useEffect)(()=>{if(!M)return;let e=()=>{let e=eU.current;e&&tT(e)},t=()=>{"visible"===document.visibilityState&&e()},n=setInterval(e,15e3);return document.addEventListener("visibilitychange",t),window.addEventListener("online",e),()=>{clearInterval(n),document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e)}},[M,tT]),(0,i.useEffect)(()=>{e_.current=M},[M]),eZ.current=(0,i.useCallback)(e=>{switch(e.type){case"agent_start":tp(),eV.current=!0,e_.current=!0,R(!0),ev({kind:"waiting_model"}),T({type:"start"});break;case"agent_end":if(!e_.current)break;ev(null),ee(null),T({type:"end"}),eU.current&&(tl(eU.current),fetch(`/api/agent/${encodeURIComponent(eU.current)}`).then(e=>e.json()).then(e=>{e.state?.contextUsage!==void 0&&en(e.state.contextUsage??null),e.state?.systemPrompt!==void 0&&ei(e.state.systemPrompt??null),e.state?.extensionStatuses!==void 0&&ez(e.state.extensionStatuses??[]),e.state?.extensionWidgets!==void 0&&eP(e.state.extensionWidgets??[]),eF(ny(e.state?.queuedMessages))}).catch(()=>{}));break;case"agent_settled":{let e=eV.current;if(eV.current=!1,!e||eq.current)break;let t=eU.current,n=tb();ep(!1),t&&(tl(t),tw(t)),n&&o?.();break}case"prompt_done":{let e=te.current,t=eq.current;eq.current=!1,tt.current=null;let n=tk(e);if(!t&&!n)break;let r=eU.current;r&&tl(r),!eV.current&&(tb(),r&&tw(r))}break;case"prompt_error":tv({type:"error",message:e.errorMessage??"Command failed"});break;case"extension_error":tv({type:"error",message:e.error??"Extension command failed"});break;case"message_start":case"message_update":{if(!e_.current)break;let t=e.message;if(t?.role==="user")break;t&&T({type:"update",message:nx(t)}),ev(null);break}case"message_end":{if(!e_.current)break;let t=e.message;if(t&&"user"===t.role){let e=nx(t),n=nT(e),r=tt.current;tt.current=null,w(t=>{let i=t[t.length-1];return r&&i?.role==="user"&&nT(i)===r?r===n?t:[...t.slice(0,-1),e]:[...t,e]})}else t&&w(e=>[...e,nx(t)]);T({type:"reset"}),ev({kind:"waiting_model"});break}case"tool_execution_start":{let t=e.toolCallId,n=e.toolName;ev(e=>{let r=e?.kind==="running_tools"?[...e.tools]:[];return r.some(e=>e.id===t)||r.push({id:t,name:n}),{kind:"running_tools",tools:r}});break}case"tool_execution_end":{let t=e.toolCallId;ev(e=>{if(e?.kind!=="running_tools")return e;let n=e.tools.filter(e=>e.id!==t);return 0===n.length?{kind:"waiting_model"}:{kind:"running_tools",tools:n}});break}case"queue_update":eF({steering:[...e.steering??[]],followUp:[...e.followUp??[]]});break;case"auto_retry_start":ee({attempt:e.attempt,maxAttempts:e.maxAttempts,errorMessage:e.errorMessage});break;case"auto_retry_end":ee(null);break;case"auto_compaction_start":case"compaction_start":ep(!0),eg(null),ef(null);break;case"auto_compaction_end":case"compaction_end":ep(!1),e.errorMessage?(eg(e.errorMessage),ef(null)):!e.aborted&&(ef(nM(e.result,e.reason??"auto")),eU.current&&tl(eU.current));break;case"extension_ui_request":ty(e)}},[tv,tp,ty,tl,tk,o,tw,tb]);let tM=(0,i.useCallback)(async(n,i)=>{let o=n.trim();if(!o&&!i?.length||e_.current||eJ.current)return;let l=!i?.length&&o.startsWith("/");if(!i?.length&&o.startsWith("!")){let e=o.startsWith("!!"),t=(e?o.slice(2):o.slice(1)).trim();if(!t)return;await e1.current?.(t,e);return}let s=te.current+1;tp(),eq.current=!0;let a=i?.map(e=>({type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}})),d={role:"user",content:a?.length?[...n.trim()?[{type:"text",text:n}]:[],...a]:n,timestamp:Date.now()};w(e=>[...e,d]),tt.current=nT(d),te.current=s,e_.current=!0,R(!0),ev(l?{kind:"running_command"}:{kind:"waiting_model"}),T({type:"start"}),eQ.current=!0,e0.current=!0;let c=i?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType})),u=null,h=!1;try{if(p&&r){let e=eU.current??await e6.current,t=e??await tc();t&&(u=t,V&&(ec(V),e&&await nf(t,{type:"set_model",provider:V.provider,modelId:V.modelId})),await tx(t),h=!0,await nf(t,{type:"prompt",message:n,...c?.length?{images:c}:{}}),td(1,n))}else t&&(u=t.id,await tx(t.id),h=!0,await nf(t.id,{type:"prompt",message:n,...c?.length?{images:c}:{}}));l&&u&&tS(u,s)}catch(t){if(console.error("Failed to send message:",t),h&&u)return void tS(u,s);if(eq.current=!1,e_.current=!1,th(),t instanceof nk){let r=tt.current;r&&w(e=>{let t=e[e.length-1];return t?.role==="user"&&nT(t)===r?e.slice(0,-1):e}),tv({type:"error",message:t.message}),n&&e.chatInputRef?.current?.insertIfEmpty(n)}tt.current=null,R(!1),ev(null),T({type:"end"})}},[p,r,V,t,tc,tx,td,tS,tv,tp,th,e.chatInputRef]);e1.current=(0,i.useCallback)(async(n,r)=>{if(e_.current||eJ.current)return;let i=`${r?"!!":"!"}${n}`;eJ.current=!0,z({command:n,excludeFromContext:r}),L(!0);try{let e=eU.current??t?.id??await tc();if(!e)throw Error("Unable to create a session for the shell command");await nf(e,{type:"bash",command:n,excludeFromContext:r}),await tl(e),td(1,i)}catch(t){console.error("Failed to execute shell command:",t),tv({type:"error",message:t instanceof Error?t.message:String(t)}),e.chatInputRef?.current?.insertIfEmpty(i)}finally{eJ.current=!1,z(null),L(!1)}},[tv,tc,tl,e.chatInputRef,td,t]);let tR=(0,i.useCallback)(async()=>{let e=eU.current;if(e){if(eJ.current){try{await nf(e,{type:"abort_bash"})}catch(e){console.error("Failed to abort bash:",e)}return}try{await nf(e,{type:"abort"})}catch(e){console.error("Failed to abort:",e)}}},[]),tI=(0,i.useCallback)(async e=>{if(eJ.current)return;let t=eU.current;if(t){el(e);try{let{cancelled:n,newSessionId:r}=await nf(t,{type:"fork",entryId:e})??{};!n&&r&&s?.(r)}catch(e){console.error("Fork failed:",e)}finally{el(null)}}},[s]),tL=(0,i.useCallback)(async e=>{if(eJ.current)return;let t=eU.current;t&&(nf(t,{type:"navigate_tree",targetId:e}).catch(()=>{}),b(e),await ts(t,e))},[ts]),tW=(0,i.useCallback)(async e=>{if(eJ.current)return;b(e);let t=eU.current;t&&(await ts(t,e),e&&nf(t,{type:"navigate_tree",targetId:e}).catch(()=>{}))},[ts]),tz=(0,i.useCallback)(async(e,t)=>{if(p){let n={provider:e,modelId:t};e9.current=n,q(n),ec(n);let r=eU.current??await e6.current;if(!r)return;try{await nf(r,{type:"set_model",provider:e,modelId:t})}catch(e){console.error("Failed to set model:",e)}return}let n=eU.current;if(n)try{await nf(n,{type:"set_model",provider:e,modelId:t}),ea({provider:e,modelId:t})}catch(e){console.error("Failed to set model:",e)}},[p,q]),tE=(0,i.useCallback)(async()=>{let e=eU.current;if(e&&!eu){ep(!0),eg(null),ef(null);try{let t=await nf(e,{type:"compact"});ef(nM(t,"manual")),await tl(e,!0)}catch(e){eg(e instanceof Error?e.message:String(e)),ef(null)}finally{ep(!1)}}},[eu,tl]),tP=(0,i.useCallback)(async e=>{let n=r??t?.cwd??"",i=n?`/api/models?cwd=${encodeURIComponent(n)}`:"/api/models",o=await fetch(i,e?{signal:e}:void 0);if(!o.ok)throw Error(`HTTP ${o.status}`);let l=await o.json();P(l.models),N(l.modelError??null),B(l.modelScopeWarnings??[]),O(l.thinkingLevels??{}),_(l.thinkingLevelMaps??{});let s=l.modelList??[];if(F(s),p&&!eU.current){let e=(l.defaultModel?s.find(e=>e.id===l.defaultModel?.modelId&&e.provider===l.defaultModel?.provider):void 0)??s[0];J(e?{provider:e.provider,modelId:e.id}:null);let t=e&&l.thinkingLevelPins?.[`${e.provider}/${e.id}`];null===e7.current&&X(t??"auto")}},[p,r,t?.cwd]),t$=(0,i.useCallback)(async e=>{if(!e.startsWith("/"))return{handled:!1};let t=e.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(!t)return{handled:!1};let[,n,r=""]=t,i=r.trim(),o=eU.current??await tc(),l=e=>(e.handled&&(e.error?tv({type:"error",message:e.error}):"openSessionStats"!==e.action&&tv({type:"success",message:e.message??"Command completed"})),e);try{switch(n){case"compact":{if(!o||eu)return l({handled:!0,error:"No active session to compact"});ep(!0),eg(null),ef(null);let e=await nf(o,{type:"compact",...i?{customInstructions:i}:{}});return ef(nM(e,"manual")),await tl(o,!0)&&td(),l({handled:!0,message:"Compacted context"})}case"reload":if(!o)return l({handled:!0,error:"No active session to reload"});return await nf(o,{type:"reload"}),await Promise.all([tl(o,!1,!0),ta(o),tu(),tP()]),l({handled:!0,message:"Reloaded session resources"});case"name":if(!o)return l({handled:!0,error:"No active session to name"});if(!i)return l({handled:!0,error:"Usage: /name <name>"});return await nf(o,{type:"set_session_name",name:i}),await tl(o)&&td(),l({handled:!0,message:`Session renamed to ${i}`});case"session":{if(!o)return l({handled:!0,error:"No active session"});let e=await nf(o,{type:"get_session_stats"});return e&&eT(e),u?.(),l({handled:!0,action:"openSessionStats"})}case"copy":{if(!o)return l({handled:!0,error:"No active session"});let e=await nf(o,{type:"get_last_assistant_text"}),t=e?.text??"";if(!t)return l({handled:!0,error:"No assistant message to copy"});return await navigator.clipboard.writeText(t),l({handled:!0,message:"Copied last assistant message"})}default:return{handled:!1}}}catch(e){return l({handled:!0,error:e instanceof Error?e.message:String(e)})}finally{"compact"===n&&ep(!1)}},[tv,tc,eu,tP,tl,tu,ta,td,u]),tF=(0,i.useCallback)(async(e,t)=>{let n=eU.current;if(!n)return;let r=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{await nf(n,{type:"steer",message:e,...r?.length?{images:r}:{}})}catch(e){console.error("Failed to steer:",e)}},[]),tD=(0,i.useCallback)(async(e,t,n)=>{let r=eU.current;if(!r)return;let i=n?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{await nf(r,{type:"prompt",message:e,streamingBehavior:t,...i?.length?{images:i}:{}})}catch(e){console.error("Failed to queue prompt:",e)}},[]),tN=(0,i.useCallback)(async(e,t)=>{let n=eU.current;if(!n)return;let r=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType}));try{await nf(n,{type:"follow_up",message:e,...r?.length?{images:r}:{}})}catch(e){console.error("Failed to follow up:",e)}},[]),tA=(0,i.useCallback)(async()=>{let e=eU.current;if(e)try{await nf(e,{type:"abort_compaction"})}catch(e){console.error("Failed to abort compaction:",e)}},[]),tB=(0,i.useCallback)(async()=>{let t=eU.current;if(t)try{let n=await nf(t,{type:"clear_queue"});eF({steering:[],followUp:[]});let r=[...n?.steering??[],...n?.followUp??[]];r.length>0&&e.chatInputRef?.current?.prependText(r.join("\n\n"))}catch(e){console.error("Failed to recall queued messages:",e),tv({type:"error",message:"Failed to recall queued messages"})}},[e.chatInputRef,tv]),tH=(0,i.useCallback)(async e=>{if(X(e),p&&!eU.current&&(e7.current="auto"===e?null:e),"auto"===e)return;let t=eU.current??await e6.current;if(t)try{await nf(t,{type:"set_thinking_level",level:e})}catch(e){console.error("Failed to set thinking level:",e)}},[p]),tO=(0,i.useCallback)(async e=>{let t=(0,nm.xG)(e);tn(e);let n=eU.current??await e6.current;if(n)try{await nf(n,{type:"set_tools",toolNames:t})}catch(e){console.error("Failed to set tools:",e)}},[tn]),tU=(0,i.useCallback)((e="smooth")=>{e8.current=Date.now()+700,e4.current?.scrollIntoView({behavior:e})},[]),t_=(0,i.useCallback)(()=>{let e=e5.current,t=eX.current;if(!e||!t)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e8.current=Date.now()+700,e.scrollTo({top:n-16,behavior:"smooth"})},[]),tV=(0,i.useCallback)(e=>{e instanceof KeyboardEvent&&(!nb.has(e.key)||e.target instanceof Element&&e.target.closest("input, textarea, [contenteditable='true']"))||(e2.current=Date.now()+1200)},[]),tq=(0,i.useCallback)(()=>{!e_.current||Date.now()<e8.current||Date.now()>e2.current||(e0.current=!1)},[]);return(0,i.useEffect)(()=>(t&&(eU.current=t.id,tl(t.id,!0,!0).then(e=>{e?.running&&(ta(t.id),(e.state?.isStreaming||e.state?.isPromptRunning)&&(eV.current=!!e.state.isStreaming,eq.current=!!e.state.isPromptRunning,e_.current=!0,R(!0),ev(e.state.isStreaming?{kind:"waiting_model"}:{kind:"running_command"}),T({type:"start"}),tg(t.id),!e.state.isStreaming&&e.state.isPromptRunning&&tS(t.id)),e.state?.isBashRunning&&(eJ.current=!0,L(!0),tC(t.id))),e?.state&&(void 0!==e.state.isCompacting&&ep(e.state.isCompacting),void 0!==e.state.contextUsage&&en(e.state.contextUsage??null),void 0!==e.state.systemPrompt&&ei(e.state.systemPrompt??null),void 0!==e.state.thinkingLevel&&X(e.state.thinkingLevel??"auto"),void 0!==e.state.extensionStatuses&&ez(e.state.extensionStatuses??[]),void 0!==e.state.extensionWidgets&&eP(e.state.extensionWidgets??[]),void 0!==e.state.queuedMessages&&eF(ny(e.state.queuedMessages)))})),()=>{eY.current+=1,tp(),th()}),[]),(0,i.useEffect)(()=>{c?.(er)},[er,c]),(0,i.useEffect)(()=>{d&&d(h?.tree??[],y,tW)},[h?.tree,y,tW,d]),(0,i.useEffect)(()=>(window.addEventListener("keydown",tV),window.addEventListener("pointerdown",tV,{passive:!0}),()=>{window.removeEventListener("keydown",tV),window.removeEventListener("pointerdown",tV)}),[tV]),(0,i.useEffect)(()=>{let e=e5.current;if(e)return e.addEventListener("wheel",tV,{passive:!0}),e.addEventListener("touchstart",tV,{passive:!0}),e.addEventListener("scroll",tq,{passive:!0}),()=>{e.removeEventListener("wheel",tV),e.removeEventListener("touchstart",tV),e.removeEventListener("scroll",tq)}},[k.length,x,tq,tV]),(0,i.useEffect)(()=>{k.length>0&&(eQ.current?(eQ.current=!1,eG.current=!0,t_()):eG.current?!e_.current&&e0.current&&tU("smooth"):(eG.current=!0,tU("instant")))},[k.length,M,tU,t_]),(0,i.useEffect)(()=>{let e=new AbortController;return tP(e.signal).catch(e=>{if(e instanceof DOMException&&"AbortError"===e.name)return}),()=>e.abort()},[tP,a]),(0,i.useEffect)(()=>{if(!ex)return;let e=setTimeout(()=>ef(null),6e3);return()=>clearTimeout(e)},[ex]),(0,i.useEffect)(()=>{if(0===ej.visible.length)return;let e=ej.visible.find(e=>e.exiting);if(e){let t=setTimeout(()=>{eS({type:"remove",id:e.id})},180);return()=>clearTimeout(t)}if(!ej.visible[0])return;let t=setTimeout(()=>{eS({type:"mark_oldest_exiting"})},5e3);return()=>clearTimeout(t)},[ej.visible]),(0,i.useEffect)(()=>{eT(null)},[k.length,et?.tokens,et?.percent,et?.contextWindow]),{data:h,loading:x,error:m,activeLeafId:y,messages:k,entryIds:j,streamState:C,agentRunning:M,modelNames:E,modelList:$,modelError:D,modelScopeWarnings:A,modelThinkingLevels:H,modelThinkingLevelMaps:U,newSessionModel:V,toolPreset:Y,thinkingLevel:G,retryInfo:Q,contextUsage:et,systemPrompt:er,forkingEntryId:eo,isCompacting:eu,compactError:eh,compactResult:ex,currentModel:tr,displayModel:ti,sessionStats:to,slashCommands:ey,slashCommandsLoading:ek,queuedMessages:e$,notices:ej.visible,extensionDialog:eM,extensionCustomUi:eI,extensionStatuses:eW,extensionWidgets:eE,respondToExtensionUi:tf,sendExtensionCustomInput:tm,isAutoModelSelection:p&&null===V,agentPhase:em,isNew:p,sessionIdRef:eU,eventSourceRef:eD,messagesEndRef:e4,scrollContainerRef:e5,lastUserMsgRef:eX,pendingScrollToUserRef:eQ,initialScrollDoneRef:eG,handleSend:tM,handleAbort:tR,handleFork:tI,handleNavigate:tL,handleModelChange:tz,handleCompact:tE,handleSteer:tF,handleFollowUp:tN,handlePromptWithStreamingBehavior:tD,handleAbortCompaction:tA,handleRecallQueue:tB,handleBuiltinSlashCommand:t$,handleToolPresetChange:tO,handleThinkingLevelChange:tH,loadTools:ta,loadSlashCommands:tu,setActiveLeafId:b,setData:g,setMessages:w,dispatch:T,setAgentRunning:R,setForkingEntryId:el,bashRunning:I,pendingBash:W,handleAgentEventRef:eZ}}({session:e,newSessionCwd:t,onAgentEnd:I,onSessionCreated:a,onSessionForked:d,modelsRefreshKey:c,chatInputRef:u,onBranchDataChange:p,onSystemPromptChange:h,onSessionStatsPanelOpen:x}),eE=F||D;(0,i.useEffect)(()=>{eo&&R.current!==eo.id&&(R.current=eo.id,T.current())},[eo]),(0,i.useEffect)(()=>{l=eE?ey:null},[eE,ey]);let[eP,e$]=(0,i.useState)(50),eF=(0,i.useRef)(null),eD=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=eF.current,t=ef.current;if(!e||!t)return;let n=new IntersectionObserver(e=>{e[0]?.isIntersecting&&(eD.current=t.scrollHeight-t.scrollTop,e$(e=>(function(e,t=50){return e+t})(e)))},{root:t,threshold:0});return n.observe(e),()=>n.disconnect()},[eP,E.length,ef]),(0,i.useEffect)(()=>{if(null==eD.current)return;let e=ef.current;if(e){var t;t=e.scrollHeight,e.scrollTop=Math.max(0,t-eD.current),eD.current=null}},[eP,ef]);let eN=ee?[ee.sessionId,ee.sessionFile??"",ee.sessionName??"",ee.userMessages,ee.assistantMessages,ee.toolCalls,ee.toolResults,ee.totalMessages,ee.tokens.input,ee.tokens.output,ee.tokens.cacheRead,ee.tokens.cacheWrite,ee.tokens.total,ee.cost??0].join("|"):null,eA=(0,i.useRef)(ee);eA.current=ee,(0,i.useEffect)(()=>{g?.(eA.current)},[eN,g]),(0,i.useEffect)(()=>()=>{g?.(null)},[g]);let e_=J?`${J.percent??"null"}|${J.contextWindow}|${J.tokens??"null"}`:null,eV=(0,i.useRef)(J);eV.current=J,(0,i.useEffect)(()=>{f?.(eV.current)},[e_,f]),(0,i.useEffect)(()=>()=>{f?.(null)},[f]);let{isDragOver:eq,handleDragEnter:eK,handleDragOver:eJ,handleDragLeave:eY,handleDrop:eZ}=function(e){let[t,n]=(0,i.useState)(!1),r=(0,i.useRef)(0),o=(0,i.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith("image/"))&&(e.preventDefault(),r.current+=1,n(!0))},[]),l=(0,i.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith("image/"))&&e.preventDefault()},[]);return{isDragOver:t,handleDragEnter:o,handleDragOver:l,handleDragLeave:(0,i.useCallback)(()=>{r.current-=1,r.current<=0&&(r.current=0,n(!1))},[]),handleDrop:(0,i.useCallback)(t=>{t.preventDefault(),r.current=0,n(!1),e(Array.from(t.dataTransfer.files))},[e])}}((0,i.useCallback)(e=>{eE||u?.current?.addImages(e)},[eE,u])),eG=E.filter(e=>"user"===e.role||"assistant"===e.role),eX=(0,i.useMemo)(()=>{let e=new Set,t=[];for(let n=E.length-1;n>=0;n-=1){let r=function(e){if("user"!==e.role)return null;if("string"==typeof e.content){let t=e.content.trim();return t.length>0?t:null}let t=e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n").trim();return t.length>0?t:null}(E[n]);if(!(!r||e.has(r))&&(e.add(r),t.push(r),t.length>=50))break}return t.reverse()},[E]),eQ=(v=eG.length,(y=(0,i.useRef)([])).current=Array(v).fill(null).map((e,t)=>y.current[t]??null),y),e0=(0,i.useCallback)(()=>{e$(e=>Math.max(e,2*E.length))},[E.length]),e1=eh&&0===E.length&&!$.isStreaming&&!eE,e2=e?.cwd??t??void 0,e8=Q?U[`${Q.provider}:${Q.modelId}`]??null:null,e4=Q?_[`${Q.provider}:${Q.modelId}`]??null:null,e5=(0,r.jsx)(nl,{ref:u,onSend:ev,onAbort:ey,onSteer:F?eS:void 0,onFollowUp:F?eC:void 0,onPromptWithStreamingBehavior:F?eT:void 0,isStreaming:eE,model:Q,isAutoModelSelection:eu,modelNames:A,modelList:B,modelError:H,modelScopeWarnings:O,onModelChange:ew,onCompact:e||eh?ej:void 0,onAbortCompaction:eM,isCompacting:Z,compactError:G,compactResult:X,toolPreset:V,onToolPresetChange:e||eh?eL:void 0,thinkingLevel:q,onThinkingLevelChange:e||eh?eW:void 0,availableThinkingLevels:e8,thinkingLevelMap:e4,retryInfo:K,queuedMessages:er,inputHistory:eX,onRecallQueue:eR,slashCommands:et,slashCommandsLoading:en,onLoadSlashCommands:ez,onBuiltinCommand:eI,soundEnabled:k,onSoundToggle:w,onAudioUnlock:S,draftKey:e?.id??(t?`new:${t}`:void 0),cwd:e?.cwd??t}),e6=ea.filter(e=>"belowEditor"!==e.placement),e3=ea.filter(e=>"belowEditor"===e.placement);return W?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-text-muted",children:b("chat.loadingSession")}):z?(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-red-400",children:z}):(0,r.jsxs)("div",{className:"relative flex h-full min-w-0 flex-col overflow-hidden",style:{paddingBottom:"env(safe-area-inset-bottom)"},onDragEnter:eK,onDragOver:eJ,onDragLeave:eY,onDrop:eZ,children:[eq&&!eE&&(0,r.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[rgba(37,99,235,0.06)] backdrop-blur-[1px]",children:[(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[0,.8,1.6].map(e=>(0,r.jsx)("div",{className:"absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[rgba(37,99,235,0.5)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]",style:{transformOrigin:"center",animationDelay:`${e}s`}},e))}),(0,r.jsxs)("svg",{width:"280",height:"280",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"drop-shadow-[0_6px_18px_rgba(37,99,235,0.18)]",children:[(0,r.jsx)("rect",{x:"28",y:"44",width:"84",height:"60",rx:"8",fill:"rgba(37,99,235,0.08)",stroke:"rgba(37,99,235,0.50)",strokeWidth:"1.8"}),(0,r.jsx)("path",{d:"M36 100 L54 72 L68 88 L80 74 L104 100Z",fill:"rgba(37,99,235,0.16)",stroke:"rgba(37,99,235,0.40)",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,r.jsx)("circle",{cx:"96",cy:"58",r:"8",fill:"rgba(37,99,235,0.22)",stroke:"rgba(37,99,235,0.55)",strokeWidth:"1.6"}),(0,r.jsxs)("g",{stroke:"rgba(37,99,235,0.45)",strokeWidth:"1.4",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"96",y1:"46",x2:"96",y2:"43"}),(0,r.jsx)("line",{x1:"96",y1:"70",x2:"96",y2:"73"}),(0,r.jsx)("line",{x1:"84",y1:"58",x2:"81",y2:"58"}),(0,r.jsx)("line",{x1:"108",y1:"58",x2:"111",y2:"58"}),(0,r.jsx)("line",{x1:"87.5",y1:"49.5",x2:"85.4",y2:"47.4"}),(0,r.jsx)("line",{x1:"104.5",y1:"66.5",x2:"106.6",y2:"68.6"}),(0,r.jsx)("line",{x1:"104.5",y1:"49.5",x2:"106.6",y2:"47.4"}),(0,r.jsx)("line",{x1:"87.5",y1:"66.5",x2:"85.4",y2:"68.6"})]})]})]}),eo&&(0,r.jsx)(nP,{request:eo,onRespond:ed}),el&&(0,r.jsx)(n$,{request:el,onInput:ec}),e1?(0,r.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-8",children:(0,r.jsxs)("div",{className:"w-full max-w-[820px]",children:[(0,r.jsxs)("div",{className:"mb-3",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginLeft:16,marginRight:52,fontFamily:"var(--font-mono)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0,flex:1,lineHeight:1.4,overflow:"hidden"},children:[(0,r.jsx)("span",{style:{fontSize:28,fontWeight:700,letterSpacing:0,color:"var(--text)",flexShrink:0,whiteSpace:"nowrap"},children:"π"}),(0,r.jsx)("span",{style:{fontSize:22,color:"var(--text)",fontWeight:700,letterSpacing:0,flexShrink:0,whiteSpace:"nowrap"},children:"Pi Web"})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:[(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["web ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.8.6"]})]}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["pi ",(0,r.jsxs)("span",{style:{color:"var(--text)"},children:["v","0.83.0"]})]})]})]}),(0,r.jsx)(nE,{notices:ei,align:"right"}),e5]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative flex min-w-0 flex-1 overflow-hidden",children:[(0,r.jsx)("div",{style:{position:"absolute",top:12,left:0,right:36*!C,zIndex:40,padding:"0 16px",pointerEvents:"none"},children:(0,r.jsx)("div",{style:{maxWidth:820,margin:"0 auto"},children:(0,r.jsx)(nE,{notices:ei,floating:!0,align:"right"})})}),(0,r.jsx)("div",{ref:ef,className:"min-w-0 flex-1 overflow-x-hidden overflow-y-auto pt-4 [scrollbar-width:none]",children:(0,r.jsx)("div",{style:{minWidth:0,padding:"0 16px"},children:(0,r.jsxs)("div",{style:{width:"100%",minWidth:0,maxWidth:820,margin:"0 auto"},children:[(0,r.jsx)(nz,{widgets:e6}),(()=>{var t;let n,i,o=new Map;for(let e of E)"toolResult"===e.role&&o.set(e.toolCallId,e);let l=-1;for(let e=E.length-1;e>=0;e--)if("user"===E[e].role){l=e;break}let s=-1;for(let e=E.length-1;e>=0;e--)if(nR(E[e])){s=e;break}let a=new Map,d=0;E.forEach((e,t)=>{("user"===e.role||"assistant"===e.role)&&a.set(t,d++)});let c=(t,n={})=>{let i=n.messageOverride??E[t],s="user"===i.role&&t>0&&"assistant"===E[t-1].role?P[t-1]:void 0,d="user"===i.role||"assistant"===i.role,c=a.get(t),u=n.keyPrefix??"message",p=!1;if("assistant"===i.role){p=!0;for(let e=t+1;e<E.length;e++){let t=E[e].role;if("user"===t)break;if("assistant"===t){p=!1;break}}p&&$.isStreaming&&t===E.length-1&&(p=!1)}void 0!==n.showTimestamp&&(p=n.showTimestamp);let h=(0,r.jsx)(tx,{message:i,toolResults:o,modelNames:A,cwd:e2,onOpenFile:m,entryId:P[t],onFork:eE||eh||0===t&&"user"===i.role?void 0:eb,forking:Y===P[t],onNavigate:eE?void 0:ek,prevAssistantEntryId:eE?void 0:s,onEditContent:L,showTimestamp:p,prevTimestamp:t>0?E[t-1].timestamp:void 0,sessionId:e?.id??eg.current??void 0},`${u}-view-${t}`);return d&&!1!==n.attachRef&&void 0!==c?(0,r.jsx)("div",{ref:e=>{eQ.current[c]=e,t===l&&(em.current=e)},children:h},`${u}-${t}`):h},u=[];for(let e=0;e<E.length;){if(!nR(E[e])){u.push(c(e)),e+=1;continue}let t=e,n=t+1;for(;n<E.length&&!nR(E[n]);)n+=1;let i=function(e,t,n){for(let i=n-1;i>t;i--){var r;if("assistant"===(r=e[i]).role&&eO(r).answerBlocks.some(e=>"image"===e.type||"text"===e.type&&e.text.trim().length>0))return i}for(let r=n-1;r>t;r--)if(e[r]?.role==="assistant")return r;return -1}(E,t,n);if(-1===i||(eE||$.isStreaming)&&n===E.length&&t===s){for(let e=t;e<n;e++)u.push(c(e));e=n;continue}u.push(c(t));let o=[];for(let e=t+1;e<i;e++)o.push(e);let l=o.filter(e=>{var t;return"assistant"===(t=E[e]).role?eB(t).length>0:"custom"===t.role}),d=E[i],p=eO(d),h=p.processBlocks.length>0?nI(d,p.processBlocks,{omitUsage:!0}):null,g=p.answerBlocks.length>0||eH(d)?nI(d,p.answerBlocks):null,x=l.length+ +!!h;if(x>0){let e=l.map(e=>a.get(e)).find(e=>"number"==typeof e)??(g?void 0:a.get(i)),n=(0,r.jsxs)(nL,{messageCount:x,t:b,toolCallCount:function(e,t){let n=0;for(let r of t){let t=e[r];t?.role==="assistant"&&(n+=eU(eB(t)))}return n}(E,l)+eU(p.processBlocks),children:[l.map(e=>c(e,{attachRef:!1,keyPrefix:"process"})),h&&c(i,{attachRef:!1,keyPrefix:"process-final",messageOverride:h,showTimestamp:!1})]});u.push((0,r.jsx)("div",{ref:void 0===e?void 0:t=>{eQ.current[e]=t},children:n},`process-group-${t}-${i}`))}g&&u.push(c(i,{messageOverride:g}));for(let e=i+1;e<n;e++)u.push(c(e));e=n}let{startIndex:p,hasMore:h}=(n=Math.min(Math.max(eP,0),Math.max(t=u.length,0)),{startIndex:i=Math.max(0,t-n),hasMore:i>0});return(0,r.jsxs)(r.Fragment,{children:[h&&(0,r.jsx)("div",{ref:eF,className:"py-3 text-center text-xs text-text-muted",children:b("chat.loadEarlier",{count:p})}),u.slice(p)]})})(),$.isStreaming&&$.streamingMessage&&(0,r.jsx)(tx,{message:$.streamingMessage,isStreaming:!0,modelNames:A,cwd:e2,onOpenFile:m}),F&&!$.streamingMessage&&ep&&(0,r.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,r.jsx)("span",{className:"animate-[pulse_1.5s_infinite]",children:function(e,t){if(e?.kind==="running_tools"){let n=e.tools.map(e=>e.name);return 0===n.length?t("chat.runningTool"):1===n.length?t("chat.runningNamedTool",{name:n[0]}):n.length<=3?t("chat.runningTools",{names:n.join(", ")}):t("chat.runningToolsMore",{names:n.slice(0,2).join(", "),count:n.length-2})}return e?.kind==="waiting_model"?t("chat.waitingModel"):e?.kind==="running_command"?t("chat.runningCommand"):null}(ep,b)})}),D&&!N&&(0,r.jsx)("div",{className:"py-2 text-[13px] text-text-muted",children:(0,r.jsx)("span",{className:"animate-[pulse_1.5s_infinite]",children:b("chat.runningCommand")})}),N&&(0,r.jsx)(tx,{message:{role:"bashExecution",command:N.command,output:"",excludeFromContext:N.excludeFromContext},sessionId:e?.id??eg.current??void 0}),F&&(0,r.jsx)("div",{style:{height:ef.current?ef.current.clientHeight:"80vh"}}),(0,r.jsx)("div",{ref:ex})]})})}),C?null:(0,r.jsx)(nh,{messages:E,streamingMessage:$.streamingMessage,scrollContainer:ef,messageRefs:eQ,onRevealHistory:e0})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{style:{padding:"0 16px",paddingRight:C?16:52},children:(0,r.jsx)("div",{style:{maxWidth:820,margin:"0 auto"},children:(0,r.jsx)(nz,{widgets:e3})})}),e5,(0,r.jsx)(ng,{statuses:es})]})]})]})}function nz({widgets:e}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:10},children:e.map(e=>(0,r.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-panel)",overflow:"hidden"},children:[(0,r.jsx)("div",{style:{padding:"5px 9px",borderBottom:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)"},children:e.key}),(0,r.jsx)("pre",{style:{margin:0,padding:"8px 9px",color:"var(--text-muted)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)"},children:e.lines.join("\n")})]},e.key))})}function nE({notices:e,floating:t=!1,align:n="left"}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"right"===n?"flex-end":"stretch",marginBottom:10*!t},children:e.map((n,i)=>{let o="error"===n.type?"#ef4444":"warning"===n.type?"#d97706":"success"===n.type?"#10b981":"var(--accent)";return(0,r.jsxs)("div",{className:"notice-shelf-item",style:{display:"flex",alignItems:"center",gap:10,minHeight:60,height:60,maxHeight:60,marginBottom:6*(i!==e.length-1),overflow:"hidden",borderRadius:14,border:"1px solid color-mix(in srgb, var(--border) 70%, transparent)",background:"var(--bg)",color:"var(--text-muted)",width:"fit-content",maxWidth:"min(100%, 620px)",boxShadow:t?"0 1px 2px rgba(15,23,42,0.05), 0 10px 28px -14px rgba(15,23,42,0.24)":"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",fontSize:18,lineHeight:1.45,transformOrigin:"top center",animation:n.exiting?"notice-shelf-out 0.18s ease-in forwards":"notice-shelf-in 0.18s ease-out both",padding:"0 12px"},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:o,flexShrink:0}}),(0,r.jsx)("span",{style:{padding:"14px 0",minWidth:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.message})]},n.id)})})}function nP({request:e,onRespond:t}){let{t:n}=(0,s.s)(),[o,l]=(0,i.useState)("editor"===e.method?e.prefill??"":"");(0,i.useEffect)(()=>{l("editor"===e.method?e.prefill??"":"")},[e]);let a=()=>{"confirm"===e.method?t(e,{confirmed:!0}):t(e,{value:o})};return(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:90,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(0,0,0,0.18)"},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true",style:{width:"min(560px, 100%)",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"12px 14px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:650},children:e.title}),(0,r.jsx)("div",{style:{marginTop:3,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)"},children:n("chat.extensionRequest")})]}),(0,r.jsxs)("div",{style:{padding:14},children:["confirm"===e.method&&(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontSize:13,lineHeight:1.6,whiteSpace:"pre-wrap"},children:e.message}),"select"===e.method&&(0,r.jsx)("div",{style:{display:"grid",gap:8},children:e.options.map(n=>(0,r.jsx)("button",{onClick:()=>t(e,{value:n}),style:{width:"100%",padding:"9px 10px",borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:13},children:n},n))}),"input"===e.method&&(0,r.jsx)("input",{autoFocus:!0,value:o,placeholder:e.placeholder,onChange:e=>l(e.target.value),onKeyDown:n=>{"Enter"===n.key&&a(),"Escape"===n.key&&t(e,{cancelled:!0})},style:{width:"100%",padding:"9px 10px",borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",outline:"none",fontSize:13}}),"editor"===e.method&&(0,r.jsx)("textarea",{autoFocus:!0,value:o,onChange:e=>l(e.target.value),onKeyDown:n=>{"Escape"===n.key&&t(e,{cancelled:!0}),(n.metaKey||n.ctrlKey)&&"Enter"===n.key&&a()},style:{width:"100%",minHeight:220,padding:10,borderRadius:7,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text)",outline:"none",resize:"vertical",fontSize:13,lineHeight:1.55,fontFamily:"var(--font-mono)"}})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 14px",borderTop:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,r.jsx)("button",{onClick:()=>t(e,{cancelled:!0}),style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",cursor:"pointer"},children:n("chat.cancel")}),"confirm"===e.method?(0,r.jsx)("button",{onClick:a,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--accent)",background:"var(--accent)",color:"#fff",cursor:"pointer"},children:n("chat.confirm")}):"select"!==e.method?(0,r.jsx)("button",{onClick:a,style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--accent)",background:"var(--accent)",color:"#fff",cursor:"pointer"},children:n("chat.submit")}):null]})]})})}function n$({request:e,onInput:t}){let{t:n}=(0,s.s)(),o=(0,i.useRef)(null),l=(0,i.useRef)(!1),a=function(e){let t=/^[┌├└╭╰][─┬┴┼]+[┐┤┘╮╯]$/,n=[];for(let r of e){let e=r.replace(eI,""),i=ez(e).trimEnd();if(t.test(i))continue;let o=e,l=e$(o);("│"===l||"┃"===l)&&" "===e$(o=eP(o,0))&&(o=eP(o,0));let s=function(e){let t=eE(e);for(let e=t.length-1;e>=0;e--)if(""!==t[e].char.trim())return e;return -1}(o),a=s>=0?eE(o)[s]?.char:void 0;("│"===a||"┃"===a)&&(o=eP(o,s)),n.push(function(e){let t=e;for(;;){let e=eE(t),n=e[e.length-1];if(!n||""!==n.char.trim())return t;t=t.slice(0,n.start)+t.slice(n.end)}}(o))}for(;n.length>0&&""===ez(n[0]).trim();)n.shift();for(;n.length>0&&""===ez(n[n.length-1]).trim();)n.pop();return n.length?n:e}(e.lines);return(0,i.useEffect)(()=>{o.current?.focus()},[e.id]),(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:95,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(0,0,0,0.18)"},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true",onClick:e=>{e.target.closest("button")||o.current?.focus()},style:{position:"relative",width:"min(920px, 100%)",maxHeight:"min(760px, calc(100vh - 40px))",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg)",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",overflow:"hidden",outline:"none"},children:[(0,r.jsx)("textarea",{ref:o,"aria-label":n("chat.extensionInput"),autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,onKeyDown:n=>{if(l.current||n.nativeEvent.isComposing)return;let r=function(e){if(e.metaKey||e.ctrlKey&&!e.altKey&&"v"===e.key.toLowerCase())return null;if(e.ctrlKey&&!e.altKey){let t=function(e){if(1!==e.length)return null;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(31&t):"?"===e?"":null}(e.key);if(t)return t}if(e.altKey&&!e.ctrlKey){if("Backspace"===e.key)return"\x1b\x7f";let t=eN[e.key];if(t)return t;if(1===e.key.length)return`\x1b${e.key}`}return"Enter"===e.key?e.shiftKey?"\n":"\r":"Tab"===e.key?e.shiftKey?"\x1b[Z":" ":eD[e.key]??null}(n);r&&(n.preventDefault(),n.stopPropagation(),t(e,r))},onInput:n=>{if(l.current||n.nativeEvent.isComposing)return;let r=n.currentTarget.value;n.currentTarget.value="",r&&t(e,r)},onCompositionStart:()=>{l.current=!0},onCompositionEnd:n=>{l.current=!1;let r=n.currentTarget;queueMicrotask(()=>{let n=r.value;r.value="",n&&t(e,n)})},onPaste:n=>{n.preventDefault();let r=n.clipboardData.getData("text");r&&t(e,`\x1b[200~${r}\x1b[201~`)},style:{position:"absolute",width:1,height:1,padding:0,border:0,opacity:0,pointerEvents:"none"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("div",{style:{color:"var(--text)",fontSize:13,fontWeight:650},children:n("chat.extensionPanel")}),(0,r.jsx)("button",{onClick:()=>t(e,"\x03"),style:{padding:"5px 9px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:n("chat.close")})]}),(0,r.jsx)("pre",{style:{margin:0,padding:14,maxHeight:"calc(min(760px, 100vh - 40px) - 48px)",overflow:"auto",background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.45,whiteSpace:"pre"},children:(a.length?a:[""]).map((e,t,n)=>{var o;return(0,r.jsxs)(i.Fragment,{children:[(o=`line-${t}`,eF(e).map((e,t)=>Object.keys(e.style).length>0?(0,r.jsx)("span",{style:e.style,children:e.text},`${o}-${t}`):e.text)),t<n.length-1?"\n":null]},t)})})]})})}var nF=n(50640);let nD={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},nN={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm",webm:"audio/webm"};function nA(e){return(e.replace(/\\/g,"/").split("/").pop()??"").toLowerCase().split(".").pop()??""}let nB={source:"Source",preview:"Preview",diff:"Diff"},nH={fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6},nO={width:48,minWidth:48,padding:"0 10px",textAlign:"right",color:"var(--text-dim)",background:"var(--bg-panel)",borderRight:"1px solid var(--border)",fontFamily:"var(--font-mono)",fontSize:11,fontStyle:"normal",fontVariantNumeric:"tabular-nums",lineHeight:"20.8px",userSelect:"none",flexShrink:0,verticalAlign:"top"};function nU(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,r.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]})}function n_(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?.closest(".file-source-line[data-line-number]")??null}function nV(e,t){if(!t||t.isCollapsed||0===t.rangeCount)return null;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer))return null;let r=n_(n.startContainer),i=n_(n.endContainer);if(!r||!i||!e.contains(r)||!e.contains(i))return null;let o=Number(r.dataset.lineNumber),l=Number(i.dataset.lineNumber);if(!Number.isInteger(o)||!Number.isInteger(l))return null;if(o<l){let e=r.querySelector(".file-source-line-content");if(e?.contains(n.startContainer)){let t=document.createRange();if(t.selectNodeContents(e),t.setStart(n.startContainer,n.startOffset),0===t.toString().length){let e=r.nextElementSibling;e instanceof HTMLElement&&e.matches(".file-source-line[data-line-number]")&&(o=Number((r=e).dataset.lineNumber))}}let t=i.querySelector(".file-source-line-content");if(t?.contains(n.endContainer)){let e=document.createRange();if(e.selectNodeContents(t),e.setEnd(n.endContainer,n.endOffset),0===e.toString().length){let e=i.previousElementSibling;e instanceof HTMLElement&&e.matches(".file-source-line[data-line-number]")&&(l=Number((i=e).dataset.lineNumber))}}}return o>l?null:{startLine:o,endLine:l}}function nq({rows:e,stylesheet:t,useInlineStyles:n,wrapLines:i}){return e.map((e,o)=>{let l=e.children??[],s=l[0]?.properties?.className,a=Array.isArray(s)&&s.includes("react-syntax-highlighter-line-number"),d=a?l[0]:null,c=a?l.slice(1):l;return(0,r.jsxs)("span",{className:"file-source-line","data-line-number":o+1,style:{display:"flex",minWidth:"100%"},children:[d&&(0,nF.Ay)({node:d,stylesheet:t,useInlineStyles:n,key:`source-line-number-${o}`}),(0,r.jsx)("span",{className:"file-source-line-content",style:{flex:"1 1 auto",minWidth:0,overflowWrap:i?"anywhere":"normal",whiteSpace:i?"pre-wrap":"pre"},children:c.map((e,r)=>(0,nF.Ay)({node:e,stylesheet:t,useInlineStyles:n,key:`source-token-${o}-${r}`}))})]},`source-line-${o}`)})}function nK(e,t,n,r={}){let i=q(e),o=new URLSearchParams({type:t});for(let[e,t]of(n&&o.set("sessionId",n),Object.entries(r)))void 0!==t&&o.set(e,String(t));return`/api/files/${i}?${o.toString()}`}function nJ({filePath:e,sourceSessionId:t}){let{t:n}=(0,s.s)();return(0,r.jsx)("a",{href:nK(e,"download",t),download:K(e),title:n("i18n.downloadFile"),"aria-label":n("i18n.downloadFile"),className:"file-viewer-icon-button",children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})}function nY(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function nZ({patch:e}){let t,{t:n}=(0,s.s)(),i=(t=tu(e))?t.flatMap(e=>e.rows.flatMap(e=>{if("hunk"===e.type)return[];if("context"===e.left.type&&"context"===e.right.type)return[{type:"unchanged",text:e.right.text,oldLineNo:e.left.lineNo,newLineNo:e.right.lineNo}];let t=[];return"removed"===e.left.type&&t.push({type:"removed",text:e.left.text,oldLineNo:e.left.lineNo,newLineNo:null}),"added"===e.right.type&&t.push({type:"added",text:e.right.text,oldLineNo:null,newLineNo:e.right.lineNo}),t})):[];if(!i.some(e=>"unchanged"!==e.type))return(0,r.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:n("i18n.noChanges")});let o=new Set(i.flatMap((e,t)=>"unchanged"!==e.type?[t]:[])),l=new Set;for(let e of o)for(let t=Math.max(0,e-3);t<=Math.min(i.length-1,e+3);t++)l.add(t);let a=[],d=0;for(;d<i.length;)if(l.has(d)){let e=[];for(;d<i.length&&l.has(d);)e.push(i[d]),d++;a.push({hidden:!1,lines:e})}else{let e=0;for(;d<i.length&&!l.has(d);)e++,d++;a.push({hidden:!0,count:e})}return(0,r.jsx)("div",{className:"file-diff-view",style:{width:"max-content",minWidth:"100%",...nH},children:a.map((e,t)=>{if(e.hidden)return(0,r.jsxs)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:["... ",e.count," unchanged lines ..."]},t);let n=e.lines.map((e,t)=>{let n="added"===e.type?"rgba(0,200,80,0.12)":"removed"===e.type?"rgba(240,60,60,0.14)":"transparent",i="added"===e.type?"+":"removed"===e.type?"-":" ",o="added"===e.type?"#4ade80":"removed"===e.type?"#f87171":"var(--text-dim)";return(0,r.jsxs)("div",{className:"file-diff-line",style:{display:"flex",minWidth:"100%",background:n,borderLeft:"added"===e.type?"3px solid #4ade80":"removed"===e.type?"3px solid #f87171":"3px solid transparent"},children:[(0,r.jsx)("span",{style:nO,children:"removed"===e.type?e.oldLineNo:e.newLineNo}),(0,r.jsx)("span",{style:{minWidth:16,padding:"0 6px",color:o,userSelect:"none",flexShrink:0,fontWeight:600},children:i}),(0,r.jsx)("span",{className:"file-diff-line-content",style:{flexShrink:0,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)"},children:e.text||"\xa0"})]},t)});return(0,r.jsx)("div",{children:n},t)})})}function nG({filePath:e,cwd:t,sourceSessionId:n}){let{t:o}=(0,s.s)(),[l,a]=(0,i.useState)(!1),[d,c]=(0,i.useState)(0),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(null),[x,f]=(0,i.useState)(null),m=(0,i.useRef)(null),v=K(e).toLowerCase().split(".").pop()??"";(0,i.useEffect)(()=>{c(0),p(null),g(null),f(null),a(!1),m.current&&(m.current.close(),m.current=null);let t=new EventSource(nK(e,"watch",n));return m.current=t,t.addEventListener("connected",()=>a(!0)),t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&p(t.size)}catch{}c(e=>e+1)}),t.addEventListener("error",()=>a(!1)),t.onerror=()=>a(!1),()=>{t.close(),m.current=null}},[e,n]);let y=nK(e,"read",n,d?{v:d}:void 0),b=null!=u?nY(u):null;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:Y(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:v||"image"}),h&&(0,r.jsxs)("span",{children:[h.w," \xd7 ",h.h]}),b&&(0,r.jsx)("span",{children:b}),(0,r.jsxs)("span",{title:o(l?"i18n.liveSync":"i18n.notWatching"),style:{display:"flex",alignItems:"center",gap:4,color:l?"#4ade80":"var(--text-dim)"},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:l?"#4ade80":"var(--border)",display:"inline-block",boxShadow:l?"0 0 4px #4ade80":"none"}}),l?"live":"static"]}),(0,r.jsx)(nJ,{filePath:e,sourceSessionId:n})]}),(0,r.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg-panel)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,backgroundImage:"linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px"},children:x?(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13},children:x}):(0,r.jsx)("img",{src:y,alt:e,onLoad:e=>{let t=e.currentTarget;g({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>f("Failed to load image"),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})})]})}function nX({filePath:e,cwd:t,sourceSessionId:n}){let{t:o}=(0,s.s)(),[l,a]=(0,i.useState)(!1),[d,c]=(0,i.useState)(0),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(null),[x,f]=(0,i.useState)(null),m=(0,i.useRef)(null),v=K(e).toLowerCase().split(".").pop()??"";(0,i.useEffect)(()=>{c(0),p(null),g(null),f(null),a(!1),m.current&&(m.current.close(),m.current=null);let t=new EventSource(nK(e,"watch",n));return m.current=t,t.addEventListener("connected",()=>a(!0)),t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&p(t.size)}catch{}g(null),f(null),c(e=>e+1)}),t.addEventListener("error",()=>a(!1)),t.onerror=()=>a(!1),()=>{t.close(),m.current=null}},[e,n]);let y=nK(e,"read",n,d?{v:d}:void 0);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)"},title:e,children:Y(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:v||"audio"}),null!=h&&(0,r.jsx)("span",{children:function(e){if(!Number.isFinite(e))return"";let t=Math.round(e),n=Math.floor(t/60);return`${n}:${String(t%60).padStart(2,"0")}`}(h)}),null!=u&&(0,r.jsx)("span",{children:nY(u)}),(0,r.jsxs)("span",{title:o(l?"i18n.liveSync":"i18n.notWatching"),style:{display:"flex",alignItems:"center",gap:4,color:l?"#4ade80":"var(--text-dim)"},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:l?"#4ade80":"var(--border)",display:"inline-block",boxShadow:l?"0 0 4px #4ade80":"none"}}),l?"live":"static"]}),(0,r.jsx)(nJ,{filePath:e,sourceSessionId:n})]}),(0,r.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"var(--bg-panel)"},children:(0,r.jsxs)("div",{style:{width:"min(680px, 100%)"},children:[x&&(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13,marginBottom:12,textAlign:"center"},children:x}),(0,r.jsx)("audio",{controls:!0,preload:"metadata",src:y,onLoadedMetadata:e=>g(e.currentTarget.duration),onError:()=>f("Failed to load audio"),style:{width:"100%"}},y)]})})]})}function nQ({filePath:e,cwd:t,sourceSessionId:n}){let{t:o}=(0,s.s)(),[l,a]=(0,i.useState)(!1),[d,c]=(0,i.useState)(0),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(null),x=(0,i.useRef)(null),f=nA(e),m="pdf"===f,v=m?nK(e,"read",n,d?{v:d}:void 0):nK(e,"preview",n,d?{v:d}:void 0);return(0,i.useEffect)(()=>{c(0),p(null),g(null),a(!1),x.current&&(x.current.close(),x.current=null),fetch(nK(e,"meta",n)).then(e=>e.json()).then(e=>{e.error&&g(e.error),"number"==typeof e.size&&(p(e.size),!m&&e.size>0xa00000&&g("DOCX too large for preview (>10MB)"))}).catch(e=>g(String(e)));let t=new EventSource(nK(e,"watch",n));return x.current=t,t.addEventListener("connected",()=>a(!0)),t.addEventListener("change",e=>{try{let t=JSON.parse(e.data);if("number"==typeof t.size&&(p(t.size),!m&&t.size>0xa00000))return void g("DOCX too large for preview (>10MB)")}catch{}g(null),c(e=>e+1)}),t.addEventListener("error",()=>a(!1)),t.onerror=()=>a(!1),()=>{t.close(),x.current=null}},[e,m,n]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:Y(e,t)}),(0,r.jsx)("span",{style:{marginLeft:"auto"},children:"docx"===f?"docx preview":"pdf"}),null!=u&&(0,r.jsx)("span",{children:nY(u)}),(0,r.jsx)(nJ,{filePath:e,sourceSessionId:n}),(0,r.jsxs)("span",{title:o(l?"i18n.liveSync":"i18n.notWatching"),style:{display:"flex",alignItems:"center",gap:4,color:l?"#4ade80":"var(--text-dim)",flexShrink:0},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:l?"#4ade80":"var(--border)",display:"inline-block",boxShadow:l?"0 0 4px #4ade80":"none"}}),l?"live":"static"]})]}),(0,r.jsx)("div",{style:{flex:1,minHeight:0,background:"var(--bg-panel)"},children:h?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:"#f87171",fontSize:13,textAlign:"center"},children:h}):(0,r.jsx)("iframe",{src:v,sandbox:m?void 0:"allow-same-origin",title:o("i18n.previewFile",{file:K(e)}),style:{width:"100%",height:"100%",border:"none",background:m?"var(--bg)":"#eef1f5"}},v)})]})}function n0({filePath:e,cwd:t,sourceSessionId:n,onOpenFile:i,onMentionLines:o,gitRefreshKey:l,initialDisplayMode:s}){let a;return null!==(nD[nA(e)]??null)?(0,r.jsx)(nG,{filePath:e,cwd:t,sourceSessionId:n}):null!==(nN[nA(e)]??null)?(0,r.jsx)(nX,{filePath:e,cwd:t,sourceSessionId:n}):null!==("pdf"===(a=nA(e))||"docx"===a?a:null)?(0,r.jsx)(nQ,{filePath:e,cwd:t,sourceSessionId:n}):(0,r.jsx)(n1,{filePath:e,cwd:t,sourceSessionId:n,onOpenFile:i,onMentionLines:o,gitRefreshKey:l,initialDisplayMode:s})}function n1({filePath:e,cwd:t,sourceSessionId:n,onOpenFile:o,onMentionLines:l,gitRefreshKey:a,initialDisplayMode:d}){let{isDark:c}=tr(),{t:u}=(0,s.s)(),[p,h]=(0,i.useState)(null),[g,x]=(0,i.useState)(null),[f,m]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!0),[b,k]=(0,i.useState)(null),[w,j]=(0,i.useState)("source"),[S,C]=(0,i.useState)(!1),[T,M]=(0,i.useState)(!1),R=(0,i.useRef)(null),I=(0,i.useRef)(0),L=(0,i.useRef)(null),[W,z]=(0,i.useState)(null),E=(0,i.useCallback)(e=>fetch(nK(e,"read",n)).then(e=>e.json()).then(e=>e.error?(k(e.error),null):(k(null),h(e),e)).catch(e=>(k(String(e)),null)),[n]),P=(0,i.useCallback)(async e=>{let n=++I.current;if(m(!0),!t){x(null),m(!1);return}try{let r=new URLSearchParams({cwd:t,path:e}),i=await fetch(`/api/git/diff?${r.toString()}`),o=await i.json();if(n!==I.current)return;x(i.ok&&o.supported&&"string"==typeof o.patch?o:null)}catch{n===I.current&&x(null)}finally{n===I.current&&m(!1)}},[t]);(0,i.useEffect)(()=>{y(!0),k(null),h(null),x(null),j("source"),C(!1),M(!1),R.current&&(R.current.close(),R.current=null),E(e).finally(()=>y(!1));let t=new EventSource(nK(e,"watch",n));return R.current=t,t.addEventListener("connected",()=>{M(!0)}),t.addEventListener("change",()=>{E(e),P(e)}),t.addEventListener("error",()=>{M(!1)}),t.onerror=()=>{M(!1)},()=>{t.close(),R.current=null}},[e,E,P,n]),(0,i.useEffect)(()=>{P(e)},[P,e,a]),(0,i.useEffect)(()=>{p?.language==="markdown"&&"diff"!==d&&j("preview")},[p?.language,d]);let $=g?.supported===!0&&"string"==typeof g.patch,F=$&&"deleted"===g.status;(0,i.useEffect)(()=>{$||"diff"!==w||j("source")},[w,$]),(0,i.useEffect)(()=>{F&&R.current&&(R.current.close(),R.current=null,M(!1))},[F]);let D=(0,i.useRef)(!1);(0,i.useEffect)(()=>{D.current=!1},[e]),(0,i.useEffect)(()=>{"diff"===d&&$&&!D.current&&(D.current=!0,j("diff"))},[d,$]);let N=(0,i.useMemo)(()=>p?.language==="markdown"?e2(p.content):"",[p]);(0,i.useEffect)(()=>{let e=()=>{let e=L.current;z(l&&"source"===w&&e?nV(e,window.getSelection()):null)};if(e(),l&&"source"===w)return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[p?.content,w,l]);let A=(0,i.useCallback)(n=>{l&&n&&l(Y(e,t),n.startLine,n.endLine)},[t,e,l]),B=(0,i.useCallback)(()=>{A(W)},[A,W]);if((0,i.useEffect)(()=>{if(!l||"source"!==w)return;let e=e=>{if(e.repeat||"i"!==e.key.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(t instanceof Element&&t.closest("input, textarea, [contenteditable='true']"))return;let n=L.current,r=n?nV(n,window.getSelection()):null;r&&(e.preventDefault(),A(r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,A,l]),v||"diff"===d&&f&&!p)return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:u("i18n.loading")});if(b&&!F)return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#f87171",fontSize:13},children:b});if(!p&&!F)return null;let H=p?.language??"text",O=p?.content??"",U="html"===H,_="markdown"===H,V=J(e),q=O.split("\n"),K=F?"diff":w,Z=F?["diff"]:["source",...U||_?["preview"]:[],...$?["diff"]:[]],G=F?u("files.deleted"):`${H} \xb7 ${q.length} lines \xb7 ${nY(p.size)}`;return(0,r.jsxs)("div",{className:"file-viewer-shell",style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{className:"file-viewer-toolbar",style:{display:"flex",alignItems:"center",gap:8,padding:"5px 12px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0},children:[(0,r.jsx)("span",{className:"file-viewer-path",style:{fontFamily:"var(--font-mono)"},title:e,children:Y(e,t)}),(0,r.jsx)("span",{className:"file-viewer-meta",title:G,children:G}),!F&&(0,r.jsx)("span",{title:T?u("i18n.liveSync"):u("i18n.notWatching"),"aria-label":T?u("i18n.liveSync"):u("i18n.notWatching"),className:"file-viewer-live-indicator",style:{background:T?"#4ade80":"var(--border)",boxShadow:T?"0 0 4px #4ade80":"none"}}),(0,r.jsxs)("div",{className:"file-viewer-controls",children:[Z.length>1&&(0,r.jsx)("div",{className:"file-viewer-mode-switch","aria-label":u("i18n.fileViewMode"),children:Z.map(e=>{let t=K===e;return(0,r.jsx)("button",{type:"button",onClick:()=>j(e),title:"diff"===e?u("i18n.compareHead"):void 0,"aria-pressed":t,className:"file-viewer-mode-button",style:{background:t?"var(--bg-selected)":"transparent",color:t?"var(--text)":"var(--text-muted)"},children:nB[e]},e)})}),(0,r.jsx)("div",{className:"file-viewer-actions",children:"source"===K&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:B,title:u("i18n.mentionSelectedLines"),"aria-label":u("i18n.mentionSelectedLines"),disabled:!W,className:"file-viewer-icon-button",children:(0,r.jsx)(nU,{})}),(0,r.jsx)("button",{type:"button",onClick:()=>C(e=>!e),title:S?u("i18n.disableWrap"):u("i18n.enableWrap"),"aria-label":S?u("i18n.disableWrap"):u("i18n.enableWrap"),"aria-pressed":S,className:"file-viewer-icon-button",style:{background:S?"var(--bg-selected)":"transparent",color:S?"var(--text)":"var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M3 12h15a3 3 0 1 1 0 6h-4"}),(0,r.jsx)("path",{d:"m16 16-2 2 2 2"}),(0,r.jsx)("path",{d:"M3 18h7"})]})})]})}),!F&&(0,r.jsx)(nJ,{filePath:e,sourceSessionId:n})]})]}),(0,r.jsx)("div",{ref:L,className:"file-viewer-content",style:{flex:1,overflow:"auto",background:"var(--bg)"},children:"diff"===K&&$?(0,r.jsx)(nZ,{patch:g.patch}):U&&"preview"===K?(0,r.jsx)("iframe",{srcDoc:O,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"var(--bg)"},title:u("i18n.htmlPreview")}):_&&"preview"===K?(0,r.jsx)("div",{className:"markdown-body markdown-file-preview",style:{padding:"24px 32px"},children:(0,r.jsx)(e_.oz,{remarkPlugins:e4,rehypePlugins:e6,components:{code({className:e,children:t,...n}){let i=e?.replace("language-","").toLowerCase()??"",o=String(t);return e?.includes("language-")||o.includes("\n")?"mermaid"===i?(0,r.jsx)(to,{code:o.replace(/\n$/,""),defaultPreview:!0}):(0,r.jsx)(ts,{code:o.replace(/\n$/,""),lang:i}):(0,r.jsx)("code",{className:e,...n,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),a({href:e,children:n,...i}){delete i.node;let l=o?eJ(e,V,t??V):null;return l&&o?(0,r.jsx)("a",{href:e,...i,onClick:e=>{e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),o(l))},children:n}):(0,r.jsx)("a",{href:e,...i,children:n})},img({src:e,alt:i,...o}){delete o.node;let l="string"==typeof e?eJ(e,V,t??V):null,s=l?nK(l,"read",n):e;return(0,r.jsx)("img",{src:s,alt:i??"",loading:"lazy",...o})}},children:N})}):(0,r.jsx)(e3.A,{className:S?"file-source-view is-wrapped":"file-source-view",language:"text"===H?"plaintext":H,style:c?e9.xJ:e9.vs,showLineNumbers:!0,lineNumberStyle:{...nO},customStyle:{margin:0,padding:0,border:0,background:"var(--bg)",...nH,width:S?"100%":"max-content",minWidth:"100%",minHeight:"100%",overflow:"visible"},codeTagProps:{style:{fontFamily:"var(--font-mono)",overflowWrap:S?"anywhere":"normal"}},renderer:e=>(0,r.jsx)(nq,{...e,wrapLines:S}),wrapLongLines:S,children:O})})]})}function n2({tabs:e,activeTabId:t,onSelectTab:n,onCloseTab:o}){let{t:l}=(0,s.s)(),[a,d]=(0,i.useState)(null);return(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",background:"var(--bg-panel)",overflowX:"auto",flexShrink:0,height:36},children:e.map(e=>{let i=e.id===t;return(0,r.jsxs)("div",{onClick:()=>n(e.id),onMouseDown:e=>{1===e.button&&e.preventDefault()},onAuxClick:t=>{1===t.button&&(t.preventDefault(),t.stopPropagation(),o(e.id))},style:{display:"flex",alignItems:"center",gap:6,height:36,paddingLeft:12,paddingRight:6,borderRight:"1px solid var(--border)",background:i?"var(--bg)":"var(--bg-panel)",cursor:"pointer",fontSize:12,color:i?"var(--text)":"var(--text-muted)",whiteSpace:"nowrap",maxWidth:180,minWidth:80,flexShrink:0,userSelect:"none",transition:"background 0.1s, color 0.1s"},children:[(0,r.jsx)("span",{style:{flexShrink:0,opacity:i?1:.7,display:"flex",alignItems:"center"},children:O(e.label,13)}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,fontWeight:i?500:400},title:e.filePath,children:e.label}),(0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),o(e.id)},onMouseEnter:()=>d(e.id),onMouseLeave:()=>d(null),style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,background:a===e.id?"var(--bg-hover)":"transparent",border:"none",borderRadius:4,color:a===e.id?"var(--text)":"var(--text-dim)",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s, color 0.1s"},title:l("i18n.close"),"aria-label":`${l("i18n.close")} ${e.label}`,children:(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[(0,r.jsx)("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),(0,r.jsx)("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]},e.id)})})}var n8=n(67381),n4=n(64433),n5=n(70350),n6=n(88195),n3=n(9312),n9=n(87275),n7=n(22008),re=n(95476),rt=n(35029),rn=n(14489),rr=n(78728),ri=n(19872),ro=n(7751),rl=n(92526),rs=n(48238),ra=n(57794),rd=n(41098),rc=n(84604),ru=n(15315),rp=n(74278),rh=n(55457),rg=n(71437),rx=n(29167),rf=n(97283),rm=n(34166),rv=n(33889),ry=n(85486),rb=n(74068),rk=n(83546),rw=n(83709);let rj={anthropic:{Icon:n8.A,hasColor:!1},openai:{Icon:n4.A,hasColor:!1},"openai-codex":{Icon:n4.A,hasColor:!1},google:{Icon:n5.A,hasColor:!0},"google-vertex":{Icon:n5.A,hasColor:!0},"ant-ling":{Icon:rv.A,hasColor:!0},deepseek:{Icon:n6.A,hasColor:!0},groq:{Icon:n3.A,hasColor:!1},mistral:{Icon:n9.A,hasColor:!0},moonshotai:{Icon:n7.A,hasColor:!1},"moonshotai-cn":{Icon:n7.A,hasColor:!1},moonshot:{Icon:n7.A,hasColor:!1},minimax:{Icon:re.A,hasColor:!0},"minimax-cn":{Icon:re.A,hasColor:!0},fireworks:{Icon:rt.A,hasColor:!0},huggingface:{Icon:rn.A,hasColor:!0},cerebras:{Icon:rr.A,hasColor:!0},openrouter:{Icon:ri.A,hasColor:!1},xai:{Icon:ro.A,hasColor:!1},"cloudflare-ai-gateway":{Icon:rl.A,hasColor:!0},"cloudflare-workers-ai":{Icon:rl.A,hasColor:!0},"vercel-ai-gateway":{Icon:rs.A,hasColor:!1},"github-copilot":{Icon:ra.A,hasColor:!1},"amazon-bedrock":{Icon:rd.A,hasColor:!0},"azure-openai-responses":{Icon:rc.A,hasColor:!0},"kimi-coding":{Icon:ru.A,hasColor:!0},nvidia:{Icon:ry.A,hasColor:!0},opencode:{Icon:rb.A,hasColor:!1},"opencode-go":{Icon:rb.A,hasColor:!1},qwen:{Icon:rp.A,hasColor:!0},xiaomi:{Icon:rk.A,hasColor:!1},"xiaomi-token-plan-ams":{Icon:rk.A,hasColor:!1},"xiaomi-token-plan-cn":{Icon:rk.A,hasColor:!1},"xiaomi-token-plan-sgp":{Icon:rk.A,hasColor:!1},zai:{Icon:rw.A,hasColor:!1},"zai-coding-cn":{Icon:rw.A,hasColor:!1},zhipu:{Icon:rh.A,hasColor:!0},cohere:{Icon:rg.A,hasColor:!0},perplexity:{Icon:rx.A,hasColor:!0},together:{Icon:rf.A,hasColor:!0},grok:{Icon:rm.A,hasColor:!1}},rS=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"];function rC({label:e,children:t}){return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsx)("label",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:500},children:e}),t]})}let rT={padding:"6px 9px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",width:"100%",boxSizing:"border-box"};function rM({value:e,onChange:t,placeholder:n,mono:i}){return(0,r.jsx)("input",{value:e,onChange:e=>t(e.target.value),placeholder:n,style:{...rT,fontFamily:i?"var(--font-mono)":"inherit"}})}function rR({value:e,onChange:t,placeholder:n,mono:o,onKeyDown:l,autoComplete:a="off",spellCheck:d=!1,style:c}){let[u,p]=(0,i.useState)(!1),{t:h}=(0,s.s)();return(0,i.useEffect)(()=>{e||p(!1)},[e]),(0,r.jsxs)("div",{style:{position:"relative",width:"100%",...c},children:[(0,r.jsx)("input",{type:u?"text":"password",value:e,onChange:e=>t(e.target.value),onKeyDown:l,placeholder:n,style:{...rT,paddingRight:34,fontFamily:o?"var(--font-mono)":"inherit"},autoComplete:a,spellCheck:d}),(0,r.jsx)("button",{type:"button",onClick:()=>p(e=>!e),"aria-label":h(u?"i18n.hideDetails":"i18n.showDetails"),title:h(u?"i18n.hideDetails":"i18n.showDetails"),style:{position:"absolute",right:5,top:"50%",transform:"translateY(-50%)",width:24,height:24,padding:0,border:"none",background:"transparent",color:"var(--text-dim)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:u?(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 20C7 20 2.73 16.89 1 12a18.45 18.45 0 0 1 5.06-6.94"}),(0,r.jsx)("path",{d:"M9.9 4.24A10.94 10.94 0 0 1 12 4c5 0 9.27 3.11 11 8a18.5 18.5 0 0 1-2.16 3.19"}),(0,r.jsx)("path",{d:"M14.12 14.12A3 3 0 0 1 9.88 9.88"}),(0,r.jsx)("path",{d:"M1 1l22 22"})]}):(0,r.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8S1 12 1 12Z"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})})]})}function rI({value:e,onChange:t,placeholder:n}){return(0,r.jsx)("input",{type:"number",value:e,onChange:e=>t(e.target.value),placeholder:n,style:rT})}function rL({value:e,onChange:t,options:n,required:i}){let{t:o}=(0,s.s)();return(0,r.jsxs)("select",{value:e,onChange:e=>t(e.target.value),style:{...rT,color:e?"var(--text)":"var(--text-dim)"},children:[!i&&(0,r.jsxs)("option",{value:"",children:["— ",o("i18n.default")," / none —"]}),n.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})}function rW({label:e,checked:t,onChange:n}){return(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:12,color:"var(--text-muted)"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:e=>n(e.target.checked),style:{width:13,height:13,accentColor:"var(--accent)",cursor:"pointer"}}),e]})}function rz({children:e}){return(0,r.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:e})}function rE({name:e,provider:t,onChange:n,onRename:o,onDelete:l,onAddModels:a}){let{t:d}=(0,s.s)(),[c,u]=(0,i.useState)(e),[p,h]=(0,i.useState)({phase:"idle"}),[g,x]=(0,i.useState)(""),[f,m]=(0,i.useState)([]),v=(0,i.useRef)(0),y=(0,i.useRef)(null);(0,i.useEffect)(()=>u(e),[e]);let b=(e,r)=>n({...t,[e]:r});(0,i.useEffect)(()=>{t.api||n({...t,api:"openai-completions"})},[t.api]),(0,i.useEffect)(()=>{v.current+=1,h({phase:"idle"}),x(""),m([])},[e,t.baseUrl,t.api,t.apiKey]);let k=(0,i.useCallback)(async()=>{if(!t.baseUrl?.trim()||"loading"===p.phase)return;let n=++v.current;h({phase:"loading"}),m([]);try{let r=await fetch("/api/models-config/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:{...t,models:void 0}})}),i=await r.json();if(n!==v.current)return;if(!r.ok||i.error||!i.models)return void h({phase:"error",message:i.error??`HTTP ${r.status}`});h({phase:"success",models:i.models,endpoint:i.endpoint??t.baseUrl})}catch(e){if(n!==v.current)return;h({phase:"error",message:e instanceof Error?e.message:String(e)})}},[p.phase,e,t]),w=new Set((t.models??[]).map(e=>e.id)),j="success"===p.phase?p.models:[],S=g.trim().toLocaleLowerCase(),C=j.filter(e=>!S||e.id.toLocaleLowerCase().includes(S)||e.name?.toLocaleLowerCase().includes(S)),T=C.slice(0,300),M=T.filter(e=>!w.has(e.id)).map(e=>e.id),R=f.filter(e=>!w.has(e)).length,I=M.length>0&&M.every(e=>f.includes(e)),L=!I&&M.some(e=>f.includes(e));return(0,i.useEffect)(()=>{y.current&&(y.current.indeterminate=L)},[L]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(rz,{children:d("i18n.provider")}),(0,r.jsx)("button",{onClick:l,style:{padding:"3px 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11},children:d("i18n.delete")})]}),(0,r.jsxs)(rC,{label:d("i18n.providerName"),children:[(0,r.jsx)(rM,{value:c,onChange:u,placeholder:"provider-name",mono:!0}),c!==e&&c.trim()&&(0,r.jsx)("button",{onClick:()=>o(c.trim()),style:{marginTop:4,padding:"3px 10px",background:"var(--accent)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:11,alignSelf:"flex-start"},children:d("i18n.rename")})]}),(0,r.jsx)(rC,{label:"Base URL",children:(0,r.jsx)(rM,{value:t.baseUrl??"",onChange:e=>b("baseUrl",e||void 0),placeholder:"https://api.example.com/v1",mono:!0})}),(0,r.jsxs)(rC,{label:"API Key",children:[(0,r.jsx)(rR,{value:t.apiKey??"",onChange:e=>b("apiKey",e||void 0),placeholder:"ENV_VAR_NAME, !shell-command, or literal key",mono:!0}),(0,r.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:["Prefix with ",(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:"!"})," to run a shell command, or use an env var name"]})]}),(0,r.jsx)(rC,{label:"API",children:(0,r.jsx)(rL,{value:t.api??"openai-completions",onChange:e=>b("api",e),options:rS,required:!0})}),(0,r.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:14,display:"flex",flexDirection:"column",gap:10},children:["success"!==p.phase&&(0,r.jsx)("button",{onClick:k,disabled:!t.baseUrl?.trim()||"loading"===p.phase,style:{alignSelf:"flex-start",height:30,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:t.baseUrl?.trim()&&"loading"!==p.phase?"var(--text-muted)":"var(--text-dim)",cursor:t.baseUrl?.trim()&&"loading"!==p.phase?"pointer":"not-allowed",fontSize:11},children:"loading"===p.phase?d("models.discoveryFetching"):d("models.discoveryFetch")}),"error"===p.phase&&(0,r.jsx)("div",{style:{padding:"7px 9px",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",fontSize:11,lineHeight:1.4},children:p.message}),"success"===p.phase&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{value:g,onChange:e=>x(e.target.value),placeholder:d("models.discoveryFilterPlaceholder",{count:p.models.length}),"aria-label":d("models.discoveryFilter"),style:{...rT,width:"100%",minWidth:0}}),(0,r.jsxs)("div",{style:{maxHeight:220,overflowY:"auto",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"},children:[(0,r.jsxs)("label",{style:{minHeight:32,padding:"5px 9px",display:"flex",alignItems:"center",gap:8,position:"sticky",top:0,zIndex:1,borderBottom:"1px solid var(--border)",background:"var(--bg)",cursor:M.length?"pointer":"default",color:"var(--text-muted)",fontSize:10,fontWeight:600},children:[(0,r.jsx)("input",{ref:y,type:"checkbox",checked:I,disabled:0===M.length,onChange:()=>{let e=new Set(M);m(t=>I?t.filter(t=>!e.has(t)):Array.from(new Set([...t,...M])))},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),d("models.discoverySelectShown")]}),0===T.length?(0,r.jsx)("div",{style:{padding:12,color:"var(--text-dim)",fontSize:11},children:d("models.discoveryNoMatches")}):T.map((e,t)=>{let n=w.has(e.id),i=f.includes(e.id);return(0,r.jsxs)("label",{style:{minHeight:36,padding:"6px 9px",display:"flex",alignItems:"center",gap:8,borderTop:0===t?"none":"1px solid var(--border)",cursor:n?"default":"pointer",opacity:n?.65:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:i||n,disabled:n,onChange:()=>{var t;return t=e.id,void m(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},style:{width:13,height:13,accentColor:"var(--accent)",flexShrink:0}}),(0,r.jsxs)("span",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:11},children:e.name??e.id}),e.name&&(0,r.jsx)("code",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10,fontFamily:"var(--font-mono)"},children:e.id})]}),n&&(0,r.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10},children:d("models.discoveryAdded")})]},e.id)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,r.jsx)("span",{title:p.endpoint,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:C.length>T.length?d("models.discoveryShowing",{shown:T.length,total:C.length}):d("models.discoveryFetched",{count:p.models.length})}),(0,r.jsx)("button",{onClick:()=>{if("success"!==p.phase)return;let e=new Set(f),t=p.models.filter(t=>e.has(t.id)&&!w.has(t.id));0!==t.length&&(a(t),m([]))},disabled:0===R,style:{height:28,padding:"0 11px",border:"none",borderRadius:5,background:R?"var(--accent)":"var(--bg-panel)",color:R?"#fff":"var(--text-dim)",cursor:R?"pointer":"not-allowed",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:R?d("models.discoveryAddSelectedCount",{count:R}):d("models.discoveryAddSelected")})]})]})]})]})}let rP=["off","minimal","low","medium","high","xhigh","max"],r$={off:"var(--text-dim)",minimal:"#6b7280",low:"#60a5fa",medium:"#a78bfa",high:"#f472b6",xhigh:"#fb923c",max:"#ef4444"};function rF({value:e,onChange:t}){let n=e??{},i=(e,r)=>{let i={...n};"omit"===r?delete i[e]:i[e]=r,t(Object.keys(i).length?i:void 0)};return(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:rP.map(e=>{let t=n[e],o=e in n?null===t?"null":"string":"omit",l="string"==typeof t?t:"",s=r$[e],a={padding:"4px 10px",fontSize:10,border:"none",cursor:"pointer",fontWeight:400,transition:"background 0.1s, color 0.1s",whiteSpace:"nowrap",background:"var(--bg-panel)",color:"var(--text-dim)"},d={background:"var(--accent)",color:"#fff",fontWeight:600};return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 4px",borderRadius:6,background:"transparent",border:"1px solid transparent"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,width:68,flexShrink:0},children:[(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:s,flexShrink:0,opacity:"null"===o?.3:1}}),(0,r.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:"null"===o?"var(--text-dim)":"var(--text-muted)",textDecoration:"null"===o?"line-through":"none"},children:e})]}),(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",flexShrink:0},children:[(0,r.jsx)("button",{onClick:()=>i(e,"omit"),style:{...a,..."omit"===o?d:{}},children:"Default"}),(0,r.jsx)("button",{onClick:()=>i(e,null),style:{...a,borderLeft:"1px solid var(--border)",..."null"===o?{background:"#ef4444",color:"#fff",fontWeight:600}:{}},children:"Disabled"})]}),(0,r.jsxs)("div",{style:{display:"flex",borderRadius:5,border:`1px solid ${"string"===o?"var(--accent)":"var(--border)"}`,overflow:"hidden",transition:"border-color 0.1s"},children:[(0,r.jsx)("button",{onClick:()=>i(e,l||e),style:{...a,..."string"===o?d:{},borderRight:"1px solid var(--border)",flexShrink:0},children:"Custom"}),(0,r.jsx)("input",{value:l,onChange:t=>i(e,t.target.value),onFocus:()=>{"string"!==o&&i(e,l||e)},placeholder:e,maxLength:10,style:{width:"12ch",background:"string"===o?"var(--bg)":"var(--bg-panel)",border:"none",outline:"none",color:"string"===o?"var(--text)":"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,padding:"4px 7px",transition:"background 0.1s, color 0.1s"}})]})]},e)})})}let rD={thinkingFormat:"deepseek",requiresReasoningContentOnAssistantMessages:!0};function rN({providerName:e,provider:t,model:n,onChange:o,onDelete:l}){let[a,d]=(0,i.useState)({phase:"idle"}),{t:c}=(0,s.s)(),[u,p]=(0,i.useState)({phase:"idle"}),h=(0,i.useRef)(0),g=(0,i.useRef)(null),x=(e,t)=>o({...n,[e]:t}),f=(()=>{if("idle"===a.phase)return null;if("testing"===a.phase)return c("i18n.testingModel");let e=[void 0!==a.latencyMs?`${a.latencyMs}ms`:null,void 0!==a.status?`HTTP ${a.status}`:null].filter(Boolean);return"success"===a.phase?[c("i18n.connected"),...e,a.responseText||null].filter(Boolean).join(" \xb7 "):[c("i18n.failed"),...e,a.message].filter(Boolean).join(" \xb7 ")})();(0,i.useEffect)(()=>{d({phase:"idle"})},[e,t.baseUrl,t.api,t.apiKey,n.id,n.api]),(0,i.useEffect)(()=>{h.current+=1,p({phase:"idle"}),g.current=null},[e,t.baseUrl,n.id]);let m=(0,i.useCallback)(async()=>{if(n.id.trim()&&"testing"!==a.phase){d({phase:"testing"});try{let r=await fetch("/api/models-config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerName:e,provider:t,model:n})}),i=await r.json();if(!r.ok||!i.ok)return void d({phase:"error",message:i.error??`HTTP ${r.status}`,latencyMs:i.latencyMs,status:i.status});d({phase:"success",latencyMs:i.latencyMs,status:i.status,responseText:i.responseText})}catch(e){d({phase:"error",message:e instanceof Error?e.message:String(e)})}}},[n,t,e,a.phase]),v=(0,i.useCallback)(async()=>{let r=n.id.trim();if(!r||"loading"===u.phase)return;let i=++h.current;p({phase:"loading"});try{let l=new URLSearchParams({q:r,provider:e,limit:"50"});t.baseUrl?.trim()&&l.set("baseUrl",t.baseUrl.trim());let s=await fetch(`/api/models-config/catalog?${l}`),a=await s.json();if(i!==h.current)return;if(!s.ok||a.error||!a.recommendation)return void p({phase:"error",message:a.error??`HTTP ${s.status}`});let d=function(e,t){let n={...e},r=0;if(!e.name?.trim()&&t.name&&(n.name=t.name,r+=1),void 0===e.reasoning&&!0===t.reasoning&&(n.reasoning=!0,r+=1),!e.input?.length&&t.input?.length&&(n.input=[...t.input],r+=1),void 0===e.contextWindow&&void 0!==t.contextWindow&&(n.contextWindow=t.contextWindow,r+=1),void 0===e.maxTokens&&void 0!==t.maxTokens&&(n.maxTokens=t.maxTokens,r+=1),t.cost){let i={...e.cost??{}},o=!1;for(let e of["input","output","cacheRead","cacheWrite"])void 0===i[e]&&void 0!==t.cost[e]&&(i[e]=t.cost[e],o=!0,r+=1);o&&(n.cost=i)}return{model:n,appliedCount:r}}(n,a.recommendation.preset);d.appliedCount>0&&(g.current=n,o(d.model)),p({phase:"success",recommendation:a.recommendation,appliedCount:d.appliedCount})}catch(e){if(i!==h.current)return;p({phase:"error",message:e instanceof Error?e.message:String(e)})}},[u.phase,n,o,t.baseUrl,e]),y=(()=>{if("success"!==u.phase)return null;let{recommendation:t,appliedCount:n}=u,r=n>0?c("models.catalogFilled",{count:n}):c("models.catalogNoEmptyFields");if("unreliable"===t.price.status){let e="no-exact-match"===t.price.reason?c("models.catalogNoExactMatch"):c("models.catalogPriceUnreliable");return`${r} \xb7 ${e}`}let i="provider"===t.price.method?c("models.catalogPriceProvider",{provider:t.price.providerName??t.price.providerId??e}):"base-url"===t.price.method?c("models.catalogPriceBaseUrl",{provider:t.price.providerName??t.price.providerId??e}):c("models.catalogPriceConsensus",{support:t.price.support,total:t.price.total});return`${r} \xb7 ${i}`})(),b="error"===u.phase?u.message:y,k="error"===u.phase?"#ef4444":"success"===u.phase&&"unreliable"===u.recommendation.price.status?"#d97706":"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(rz,{children:c("i18n.model")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f&&(0,r.jsx)("span",{title:f,style:{maxWidth:260,height:24,padding:"0 8px",border:`1px solid ${"error"===a.phase?"#fecaca":"success"===a.phase?"#bbf7d0":"var(--border)"}`,borderRadius:4,background:"error"===a.phase?"#fee2e2":"success"===a.phase?"#dcfce7":"#e5e7eb",color:"#111827",fontSize:11,display:"inline-flex",alignItems:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",boxSizing:"border-box"},children:f}),(0,r.jsxs)("button",{onClick:m,disabled:!n.id.trim()||"testing"===a.phase,title:c("i18n.testConnection"),style:{height:24,padding:"0 8px",background:"success"===a.phase?"#16a34a":"none",border:`1px solid ${"success"===a.phase?"#16a34a":"var(--border)"}`,borderRadius:4,color:"success"===a.phase?"#fff":n.id.trim()&&"testing"!==a.phase?"var(--text-muted)":"var(--text-dim)",cursor:n.id.trim()&&"testing"!==a.phase?"pointer":"not-allowed",fontSize:11,display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",gap:5},children:["success"===a.phase&&(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"testing"===a.phase?c("i18n.checking"):"success"===a.phase?c("common.ok"):c("i18n.test")]}),(0,r.jsx)("button",{onClick:l,style:{height:24,padding:"0 8px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:4,color:"#ef4444",cursor:"pointer",fontSize:11,boxSizing:"border-box"},children:c("i18n.remove")})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(rC,{label:"ID *",children:(0,r.jsx)(rM,{value:n.id,onChange:e=>x("id",e),placeholder:"model-id",mono:!0})}),(0,r.jsx)(rC,{label:"Name",children:(0,r.jsx)(rM,{value:n.name??"",onChange:e=>x("name",e||void 0),placeholder:"Display name"})})]}),(0,r.jsxs)("div",{style:{padding:"10px 0",borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{onClick:()=>void v(),disabled:!n.id.trim()||"loading"===u.phase,style:{height:28,padding:"0 10px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:n.id.trim()&&"loading"!==u.phase?"var(--text-muted)":"var(--text-dim)",cursor:n.id.trim()&&"loading"!==u.phase?"pointer":"not-allowed",fontSize:11},children:"loading"===u.phase?c("models.catalogFilling"):c("models.catalogFill")}),(0,r.jsx)("a",{href:"https://github.com/anomalyco/models.dev",target:"_blank",rel:"noreferrer",style:{marginLeft:"auto",color:"var(--text-dim)",fontSize:10,textDecoration:"none"},children:c("models.catalogSource")})]}),(0,r.jsxs)("div",{"aria-live":"polite",style:{marginTop:6,height:20,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:k,fontSize:10},children:[(0,r.jsx)("span",{title:b??void 0,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b}),g.current&&(0,r.jsx)("button",{onClick:()=>{let e=g.current;e&&(g.current=null,o(e),p({phase:"idle"}))},style:{flexShrink:0,padding:"0 2px",border:"none",background:"none",color:"var(--accent)",cursor:"pointer",fontSize:10},children:c("models.catalogUndo")})]})]}),(0,r.jsx)(rC,{label:"API override",children:(0,r.jsx)(rL,{value:n.api??"",onChange:e=>x("api",e||void 0),options:rS})}),(0,r.jsxs)("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[(0,r.jsx)(rW,{label:"Reasoning / thinking",checked:n.reasoning??!1,onChange:e=>x("reasoning",e||void 0)}),(0,r.jsx)(rW,{label:"Image input",checked:n.input?.includes("image")??!1,onChange:e=>x("input",e?["text","image"]:void 0)})]}),n.reasoning&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rW,{label:"DeepSeek thinking compat",checked:n.compat?.thinkingFormat==="deepseek",onChange:e=>o(function(e,t){if(t)return{...e,compat:{...e.compat??{},...rD}};if(!e.compat)return e;let n={...e.compat};return delete n.thinkingFormat,delete n.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(n).length?n:void 0}}(n,e))}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,r.jsx)(rz,{children:"Thinking level map"}),n.thinkingLevelMap&&(0,r.jsx)("button",{onClick:()=>x("thinkingLevelMap",void 0),style:{fontSize:10,padding:"2px 7px",background:"none",border:"1px solid var(--border)",borderRadius:4,color:"var(--text-dim)",cursor:"pointer"},children:"clear all"})]}),(0,r.jsx)(rF,{value:n.thinkingLevelMap,onChange:e=>x("thinkingLevelMap",e)})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,r.jsx)(rC,{label:"Context window (tokens)",children:(0,r.jsx)(rI,{value:void 0!==n.contextWindow?String(n.contextWindow):"",onChange:e=>x("contextWindow",e?parseInt(e):void 0),placeholder:"128000"})}),(0,r.jsx)(rC,{label:"Max output tokens",children:(0,r.jsx)(rI,{value:void 0!==n.maxTokens?String(n.maxTokens):"",onChange:e=>x("maxTokens",e?parseInt(e):void 0),placeholder:"16384"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(rz,{children:"Cost (per million tokens)"}),(0,r.jsx)("div",{style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:8},children:["input","output","cacheRead","cacheWrite"].map(e=>(0,r.jsx)(rC,{label:e,children:(0,r.jsx)(rI,{value:n.cost?.[e]!==void 0?String(n.cost[e]):"",onChange:t=>{let r;return r=parseFloat(t),void o({...n,cost:{...n.cost??{},[e]:isNaN(r)?void 0:r}})},placeholder:"0"})},e))})]})]})}function rA({provider:e,onRefresh:t}){let[n,o]=(0,i.useState)({phase:"idle"}),{t:l}=(0,s.s)(),[a,d]=(0,i.useState)(""),c=(0,i.useRef)(null),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{("auth"===n.phase||"prompt"===n.phase)&&setTimeout(()=>u.current?.focus(),50)},[n.phase]),(0,i.useEffect)(()=>{o({phase:"idle"}),d(""),c.current?.close(),c.current=null},[e.id]),(0,i.useEffect)(()=>()=>{c.current?.close()},[]);let p=(0,i.useCallback)(()=>{c.current?.close(),o({phase:"connecting"}),d("");let n=new EventSource(`/api/auth/login/${encodeURIComponent(e.id)}`);c.current=n,n.onmessage=e=>{let r=JSON.parse(e.data);"auth"===r.type?(o({phase:"auth",url:r.url,instructions:r.instructions??null,token:r.token}),window.open(r.url,"_blank","noopener,noreferrer")):"device_code"===r.type?(o({phase:"device_code",userCode:r.userCode,verificationUri:r.verificationUri,intervalSeconds:r.intervalSeconds??null,expiresInSeconds:r.expiresInSeconds??null}),window.open(r.verificationUri,"_blank","noopener,noreferrer")):"prompt_request"===r.type?o({phase:"prompt",message:r.message,placeholder:r.placeholder??null,token:r.token}):"select_request"===r.type?o({phase:"select",message:r.message,options:r.options??[],token:r.token}):"progress"===r.type?o({phase:"progress",message:r.message}):"success"===r.type?(n.close(),o({phase:"success"}),t()):"error"===r.type?(n.close(),o({phase:"error",message:r.message})):"cancelled"===r.type&&(n.close(),o({phase:"idle"}))},n.onerror=()=>{n.close(),o(e=>"success"===e.phase?e:{phase:"error",message:"Connection lost"})}},[e.id,t]),h=(0,i.useCallback)(async()=>{await fetch(`/api/auth/logout/${encodeURIComponent(e.id)}`,{method:"POST"}),o({phase:"idle"}),t()},[e.id,t]),g=(0,i.useCallback)(async(t,n)=>{if(n.trim()){o({phase:"progress",message:"Verifying…"});try{let r=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:n.trim()})});if(!r.ok){let e=await r.json().catch(()=>({}));o({phase:"error",message:e.error??`Server error ${r.status}`});return}d("")}catch(e){o({phase:"error",message:e instanceof Error?e.message:"Network error"})}}},[e.id]),x=(0,i.useCallback)(async(t,n)=>{o({phase:"progress",message:"Continuing…"});try{let r=await fetch(`/api/auth/login/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,code:n})});if(!r.ok){let e=await r.json().catch(()=>({}));o({phase:"error",message:e.error??`Server error ${r.status}`})}}catch(e){o({phase:"error",message:e instanceof Error?e.message:"Network error"})}},[e.id]),f="connecting"===n.phase||"progress"===n.phase||"auth"===n.phase||"device_code"===n.phase||"prompt"===n.phase||"select"===n.phase;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(rz,{children:l("i18n.subscription")}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.loggedIn?"#4ade80":"var(--border)",display:"inline-block"}}),(0,r.jsx)("span",{style:{fontSize:11,color:e.loggedIn?"#4ade80":"var(--text-dim)"},children:l(e.loggedIn?"i18n.connected":"i18n.notConnected")})]})]}),(0,r.jsxs)("div",{style:{minHeight:48},children:["idle"===n.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.loggedIn?"Already connected. You can re-login or disconnect.":`Connect your ${e.name} account.`}),"connecting"===n.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:l("i18n.openingBrowser")}),"select"===n.phase&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:n.message}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.options.map(e=>(0,r.jsx)("button",{onClick:()=>x(n.token,e.id),style:{padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",cursor:"pointer",fontSize:12,textAlign:"left"},children:e.label},e.id))})]}),("auth"===n.phase||"prompt"===n.phase)&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"auth"===n.phase?"Complete sign-in in the browser, then copy the redirect URL from the address bar and paste it below.":n.message}),"auth"===n.phase&&(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:["If the browser window did not open,"," ",(0,r.jsx)("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:"click here to open the login page"}),"."]}),(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("input",{ref:u,value:a,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&g(n.token,a)},placeholder:"auth"===n.phase?"http://localhost:1455/auth/callback?code=…":n.placeholder??"Enter value…",style:{flex:1,padding:"6px 9px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:12,outline:"none",fontFamily:"var(--font-mono)",boxSizing:"border-box"}}),(0,r.jsx)("button",{onClick:()=>g(n.token,a),disabled:!a.trim(),style:{padding:"6px 12px",background:a.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:a.trim()?"#fff":"var(--text-dim)",cursor:a.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:600,flexShrink:0},children:l("i18n.submit")})]})]}),"device_code"===n.phase&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:"Open the verification page and enter this code:"}),(0,r.jsx)("div",{style:{padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:5,color:"var(--text)",fontSize:16,fontWeight:700,fontFamily:"var(--font-mono)",letterSpacing:0},children:n.userCode}),(0,r.jsxs)("p",{style:{margin:0,fontSize:11,color:"var(--text-dim)",lineHeight:1.5},children:[(0,r.jsx)("a",{href:n.verificationUri,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",wordBreak:"break-all"},children:n.verificationUri}),n.expiresInSeconds?` Expires in ${Math.ceil(n.expiresInSeconds/60)} minutes.`:""]})]}),"progress"===n.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)"},children:n.message}),"success"===n.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#4ade80"},children:l("i18n.connectedSuccessfully")}),"error"===n.phase&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:n.message})]}),(0,r.jsx)("div",{style:{display:"flex",gap:8},children:f?(0,r.jsx)("button",{onClick:()=>{c.current?.close(),o({phase:"idle"})},style:{padding:"5px 12px",background:"none",border:"1px solid var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:l("i18n.cancel")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:p,style:{padding:"5px 14px",background:"var(--accent)",border:"none",borderRadius:5,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600},children:l(e.loggedIn?"i18n.relogin":"i18n.login")}),e.loggedIn&&(0,r.jsx)("button",{onClick:h,style:{padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:"pointer",fontSize:12},children:l("i18n.disconnect")})]})})]})}function rB({provider:e,onRefresh:t}){let[n,o]=(0,i.useState)(""),[l,a]=(0,i.useState)(!1),[d,c]=(0,i.useState)(!1),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(!1),{t:x}=(0,s.s)();(0,i.useEffect)(()=>{o(""),p(null),g(!1)},[e.id]);let f=(0,i.useCallback)(async()=>{if(n.trim()){a(!0),p(null),g(!1);try{let r=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n.trim()})}),i=await r.json();!r.ok||i.error?p(i.error??`HTTP ${r.status}`):(o(""),g(!0),setTimeout(()=>g(!1),2e3),t())}catch(e){p(String(e))}finally{a(!1)}}},[n,e.id,t]),m=(0,i.useCallback)(async()=>{c(!0),p(null);try{let n=await fetch(`/api/auth/api-key/${encodeURIComponent(e.id)}`,{method:"DELETE"}),r=await n.json();!n.ok||r.error?p(r.error??`HTTP ${n.status}`):t()}catch(e){p(String(e))}finally{c(!1)}},[e.id,t]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(rz,{children:"API Key"}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e.configured?"#4ade80":"var(--border)",display:"inline-block"}}),(0,r.jsx)("span",{style:{fontSize:11,color:e.configured?"#4ade80":"var(--text-dim)"},children:x(e.configured?"i18n.configured":"i18n.notConfigured")})]})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:e.configured?"API key is stored. Enter a new key below to replace it, or disconnect to remove it.":`Enter your ${e.displayName} API key to enable ${e.modelCount} model${1!==e.modelCount?"s":""}.`}),(0,r.jsx)(rC,{label:"API Key",children:(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)(rR,{value:n,onChange:o,onKeyDown:e=>{"Enter"===e.key&&n.trim()&&f()},placeholder:e.configured?"Enter new key to replace…":"sk-…",style:{flex:1},autoComplete:"off",spellCheck:!1,mono:!0}),(0,r.jsxs)("button",{onClick:f,disabled:l||!n.trim()||h,style:{padding:"6px 12px",background:h?"#16a34a":n.trim()?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:5,color:n.trim()||h?"#fff":"var(--text-dim)",cursor:l||!n.trim()||h?"not-allowed":"pointer",fontSize:12,fontWeight:600,flexShrink:0,display:"flex",alignItems:"center",gap:5},children:[h&&(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),x(h?"i18n.saved":l?"i18n.saving":"i18n.save")]})]})}),u&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:"#f87171"},children:u}),e.configured&&(0,r.jsx)("button",{onClick:m,disabled:d,style:{alignSelf:"flex-start",padding:"5px 12px",background:"none",border:"1px solid rgba(239,68,68,0.3)",borderRadius:5,color:"#ef4444",cursor:d?"not-allowed":"pointer",fontSize:12},children:x(d?"i18n.removing":"i18n.disconnect")})]})}function rH({id:e,size:t}){let n=rj[e];if(!n){let n=e.split(/[-_]/).filter(Boolean).slice(0,2).map(e=>e[0]).join("").toUpperCase()||"?";return(0,r.jsx)("span",{"aria-hidden":"true",style:{width:t,height:t,border:"1px solid var(--border)",borderRadius:4,color:"var(--text-dim)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:Math.max(8,Math.floor(.42*t)),fontWeight:700,lineHeight:1},children:n})}return n.hasColor?(0,r.jsx)(n.Icon,{size:t}):(0,r.jsx)(n.Icon,{size:t,style:{color:"var(--text-muted)"}})}function rO({oauthProviders:e,apiKeyProviders:t,onSelectOAuth:n,onSelectApiKey:o,onAddCustom:l,onClose:a}){let[d,c]=(0,i.useState)(""),{t:u}=(0,s.s)(),p=(0,i.useRef)(null);(0,i.useEffect)(()=>{setTimeout(()=>p.current?.focus(),30)},[]);let h=d.trim().toLowerCase(),g=e.filter(e=>!e.loggedIn&&(!h||e.name.toLowerCase().includes(h))),x=t.filter(e=>!e.configured&&(!h||e.displayName.toLowerCase().includes(h)||e.id.toLowerCase().includes(h))),f=!h||"custom".includes(h)||"openai-compatible".includes(h)||"anthropic-compatible".includes(h),m=g.length+x.length+ +!!f,v={display:"flex",flexDirection:"row",alignItems:"center",gap:8,padding:"10px 12px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:7,boxSizing:"border-box",cursor:"pointer",minWidth:0,textAlign:"left",transition:"border-color 0.12s, background 0.12s",width:"100%"};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&a()},children:(0,r.jsxs)("div",{style:{width:820,maxWidth:"calc(100vw - 32px)",maxHeight:"min(72vh, calc(100vh - 32px))",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.22)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--border)",flexShrink:0,display:"flex",alignItems:"center",gap:8},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,r.jsx)("input",{ref:p,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Escape"===e.key&&a()},placeholder:u("i18n.searchProviders"),style:{flex:1,background:"none",border:"none",outline:"none",color:"var(--text)",fontSize:13,boxSizing:"border-box"}})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:14},children:0===m?(0,r.jsx)("div",{style:{padding:"20px 0",fontSize:12,color:"var(--text-dim)",textAlign:"center"},children:u("i18n.noProviders")}):(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(240px, 100%), 1fr))",gap:8},children:[f&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:u("i18n.custom")}),f&&(0,r.jsxs)("button",{onClick:()=>{l(),a()},style:v,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"OpenAI / Anthropic compatible"}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:u("i18n.customEndpoint")})]}),(0,r.jsx)("span",{style:{width:26,height:26,borderRadius:5,background:"var(--bg-hover)",border:"1px dashed var(--border)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)"},children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),g.length>0&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*!!f,fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:u("i18n.subscriptions")}),g.map(e=>(0,r.jsxs)("button",{onClick:()=>{n(e.id),a()},style:v,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:"OAuth"})]}),(0,r.jsx)(rH,{id:e.id,size:28})]},e.id)),x.length>0&&(0,r.jsx)("div",{style:{gridColumn:"1 / -1",paddingTop:6*(g.length>0),fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em"},children:"API Key"}),x.map(e=>(0,r.jsxs)("button",{onClick:()=>{o(e.id),a()},style:v,onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName}),(0,r.jsxs)("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:2},children:[e.modelCount," models"]})]}),(0,r.jsx)(rH,{id:e.id,size:28})]},e.id))]})})]})})}function rU({onClose:e}){let t=tK(),{t:n}=(0,s.s)(),[o,l]=(0,i.useState)({providers:{}}),[a,d]=(0,i.useState)(!0),[c,u]=(0,i.useState)(!1),[p,h]=(0,i.useState)(null),[g,x]=(0,i.useState)(!1),[f,m]=(0,i.useState)(null),[v,y]=(0,i.useState)([]),[b,k]=(0,i.useState)([]),[w,j]=(0,i.useState)(!1),S=(0,i.useCallback)(()=>{fetch("/api/auth/providers").then(e=>e.json()).then(e=>y(e.providers)).catch(()=>{})},[]),C=(0,i.useCallback)(()=>{fetch("/api/auth/all-providers").then(e=>e.json()).then(e=>k(e.providers)).catch(()=>{})},[]),T=(0,i.useCallback)(()=>{S(),C()},[S,C]);(0,i.useEffect)(()=>{fetch("/api/models-config").then(e=>e.json()).then(e=>{let t=e.providers?e:{...e,providers:{}};l(t);let n=Object.keys(t.providers??{});n.length>0&&m({type:"provider",name:n[0]})}).catch(()=>l({providers:{}})).finally(()=>d(!1)),T()},[T]);let M=(0,i.useCallback)(()=>{let e="new-provider",t=1;for(;o.providers?.[e];)e=`new-provider-${t++}`;l(t=>({...t,providers:{...t.providers??{},[e]:{api:"openai-completions"}}})),m({type:"provider",name:e})},[o.providers]),R=(0,i.useCallback)((e,t)=>{l(n=>({...n,providers:{...n.providers??{},[e]:t}}))},[]),I=(0,i.useCallback)((e,t)=>{l(n=>{let r=Object.entries(n.providers??{}),i=r.findIndex(([t])=>t===e);return -1===i?n:(r[i]=[t,r[i][1]],{...n,providers:Object.fromEntries(r)})}),m(n=>n?"provider"===n.type&&n.name===e?{type:"provider",name:t}:"model"===n.type&&n.providerName===e?{...n,providerName:t}:n:n)},[]),L=(0,i.useCallback)(e=>{l(t=>{let n={...t.providers??{}};return delete n[e],{...t,providers:n}}),l(e=>{let t=Object.keys(e.providers??{});return m(t.length>0?{type:"provider",name:t[0]}:null),e})},[]),W=(0,i.useCallback)(e=>{l(t=>{let n=t.providers?.[e]??{},r=[...n.models??[],{id:""}];return{...t,providers:{...t.providers??{},[e]:{...n,models:r}}}}),l(t=>{let n=(t.providers?.[e]?.models?.length??1)-1;return m({type:"model",providerName:e,index:n}),t})},[]),z=(0,i.useCallback)((e,t)=>{l(n=>{let r=n.providers?.[e]??{},i=[...r.models??[]],o=new Set(i.map(e=>e.id));for(let e of t)o.has(e.id)||(o.add(e.id),i.push({id:e.id,name:e.name}));return{...n,providers:{...n.providers??{},[e]:{...r,models:i}}}})},[]),E=(0,i.useCallback)((e,t,n)=>{l(r=>{let i=r.providers?.[e]??{},o=[...i.models??[]];return o[t]=n,{...r,providers:{...r.providers??{},[e]:{...i,models:o}}}})},[]),P=(0,i.useCallback)((e,t)=>{l(n=>{let r=n.providers?.[e]??{},i=[...r.models??[]];return i.splice(t,1),{...n,providers:{...n.providers??{},[e]:{...r,models:i.length?i:void 0}}}}),m({type:"provider",name:e})},[]),$=(0,i.useCallback)(async()=>{u(!0),h(null),x(!1);try{let e=await fetch("/api/models-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),t=await e.json();!e.ok||t.error?h(t.error??`HTTP ${e.status}`):(x(!0),setTimeout(()=>x(!1),2e3))}catch(e){h(String(e))}finally{u(!1)}},[o]),F=Object.entries(o.providers??{}),D=v.filter(e=>e.loggedIn),N=b.filter(e=>e.configured),A=(()=>{if(!f)return null;if("oauth"===f.type){let e=v.find(e=>e.id===f.providerId);return e?(0,r.jsx)(rA,{provider:e,onRefresh:T},e.id):null}if("apikey"===f.type){let e=b.find(e=>e.id===f.providerId);return e?(0,r.jsx)(rB,{provider:e,onRefresh:T},e.id):null}if("provider"===f.type){let e=o.providers?.[f.name];return e?(0,r.jsx)(rE,{name:f.name,provider:e,onChange:e=>R(f.name,e),onRename:e=>I(f.name,e),onDelete:()=>L(f.name),onAddModels:e=>z(f.name,e)},f.name):null}let e=o.providers?.[f.providerName],t=e?.models?.[f.index];return t?(0,r.jsx)(rN,{providerName:f.providerName,provider:e,model:t,onChange:e=>E(f.providerName,f.index,e),onDelete:()=>P(f.providerName,f.index)},`${f.providerName}-${f.index}`):null})();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:t=>{t.target===t.currentTarget&&e()},children:(0,r.jsxs)("div",{style:{width:t?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:t?"calc(100dvh - 16px)":"78vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:n("common.models")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:"~/.pi/agent/models.json"})]}),(0,r.jsx)("button",{onClick:e,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:t?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:t?"100%":210,maxHeight:t?"40vh":void 0,borderRight:t?"none":"1px solid var(--border)",borderBottom:t?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:[D.map(e=>{let t=f?.type==="oauth"&&f.providerId===e.id;return(0,r.jsxs)("div",{onClick:()=>m({type:"oauth",providerId:e.id}),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(rH,{id:e.id,size:16}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id)}),N.map(e=>{let t=f?.type==="apikey"&&f.providerId===e.id;return(0,r.jsxs)("div",{onClick:()=>m({type:"apikey",providerId:e.id}),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",borderRadius:5,cursor:"pointer",background:t?"var(--bg-selected)":"none"},onMouseEnter:e=>{t||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{t||(e.currentTarget.style.background="none")},children:[(0,r.jsx)(rH,{id:e.id,size:16}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName})]},e.id)}),(D.length>0||N.length>0)&&F.length>0&&(0,r.jsx)("div",{style:{margin:"4px 8px",borderTop:"1px solid var(--border)"}}),a?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:n("i18n.loading")}):F.map(([e,t])=>{let i=f?.type==="provider"&&f.name===e,o=t.models??[];return(0,r.jsxs)("div",{style:{marginBottom:2},children:[(0,r.jsxs)("div",{onClick:()=>m({type:"provider",name:e}),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:i?"var(--bg-selected)":"none"},onMouseEnter:e=>{i||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{i||(e.currentTarget.style.background="none")},children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,r.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,r.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,r.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,r.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,r.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,r.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,r.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,r.jsx)("span",{style:{fontSize:12,fontWeight:i?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]}),o.map((t,i)=>{let o=f?.type==="model"&&f.providerName===e&&f.index===i;return(0,r.jsxs)("div",{onClick:()=>m({type:"model",providerName:e,index:i}),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px 5px 26px",borderRadius:5,cursor:"pointer",background:o?"var(--bg-selected)":"none"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{fontSize:11,fontFamily:"var(--font-mono)",color:t.id?"var(--text-muted)":"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.id||n("i18n.newModel")}),t.reasoning&&(0,r.jsx)("span",{style:{fontSize:9,padding:"1px 4px",background:"rgba(99,102,241,0.12)",color:"rgba(99,102,241,0.8)",borderRadius:3,flexShrink:0},children:"T"})]},i)}),(0,r.jsx)("div",{onClick:t=>{t.stopPropagation(),W(e)},style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px 4px 26px",borderRadius:5,cursor:"pointer",color:"var(--text-dim)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-dim)",e.currentTarget.style.background="none"},children:(0,r.jsxs)("span",{style:{fontSize:11},children:["+ ",n("i18n.model")]})})]},e)})]}),(0,r.jsx)("div",{style:{borderTop:"1px solid var(--border)",padding:"8px 6px"},children:(0,r.jsxs)("button",{onClick:()=>j(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:"100%",padding:"6px 0",background:"none",border:"1px dashed var(--border)",borderRadius:5,color:"var(--text-muted)",cursor:"pointer",fontSize:12},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.color="var(--accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.color="var(--text-muted)"},children:["+ ",n("i18n.addProvider")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:a?null:A??(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:n("i18n.selectProviderModel")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[p&&(0,r.jsx)("span",{style:{fontSize:12,color:"#f87171",flex:1},children:p}),(0,r.jsx)("button",{onClick:e,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:n("i18n.cancel")}),(0,r.jsxs)("button",{onClick:$,disabled:c||g,style:{position:"relative",padding:"6px 16px",minWidth:92,background:g?"#16a34a":c?"var(--bg-panel)":"var(--accent)",border:"none",borderRadius:6,color:g?"#fff":c?"var(--text-muted)":"#fff",cursor:c||g?"default":"pointer",fontSize:13,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"background-color 0.2s ease, color 0.2s ease",animation:g?"saved-pop 0.45s ease":void 0},children:[g&&(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:18,animation:"saved-check-draw 0.35s ease forwards",flexShrink:0},children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),(0,r.jsx)("span",{children:g?n("i18n.saved"):c?n("i18n.saving"):n("i18n.save")})]})]})]})}),w&&(0,r.jsx)(rO,{oauthProviders:v,apiKeyProviders:b,onSelectOAuth:e=>m({type:"oauth",providerId:e}),onSelectApiKey:e=>m({type:"apikey",providerId:e}),onAddCustom:M,onClose:()=>j(!1)})]})}function r_(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function rV(e){let t=e.sourceInfo?.source,n=e.sourceInfo?.scope;return"user"===n||"user"===t?"global":"project"===n||"project"===t?"project":"path"}function rq(e){let t=rV(e);return"path"===t?t:e.install?.skillsShUrl?`${t} / skills.sh`:t}function rK(e){return e.install?`${e.install.scope}\0${e.install.package}`:null}function rJ(e){return e?e.slice(0,8):"unknown"}function rY({enabled:e,loading:t,onToggle:n}){let{t:i}=(0,s.s)();return(0,r.jsx)("button",{onClick:n,disabled:t,title:i(e?"i18n.visibleInPrompt":"i18n.hiddenFromPrompt"),style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none"},children:(0,r.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function rZ({skill:e,cwd:t,onToggle:n,toggling:i,saveError:o,updateStatus:l,checkingUpdate:a,updating:d,updateError:c,onCheckUpdate:u,onUpdate:p}){let{t:h}=(0,s.s)(),g=rV(e),x=!e.disableModelInvocation;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===g?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===g?"rgba(99,102,241,0.8)":"var(--text-dim)"},children:g}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:function(e){if("project"===g&&e.startsWith(t)){let n=e.slice(t.length).replace(/^[/\\]/,"");return`./${n}`}return r_(e)}(e.filePath)}),(0,r.jsx)(rY,{enabled:x,loading:i,onToggle:()=>n(e)})]}),(0,r.jsxs)("div",{style:{minHeight:16,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,flexWrap:"wrap",textAlign:"right"},children:[!x&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)"},children:h("i18n.hiddenButInvocable")}),o&&(0,r.jsx)("span",{style:{fontSize:12,color:"#f87171",overflowWrap:"anywhere"},children:o})]})]}),e.install?.skillsShUrl&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Source"}),(0,r.jsx)("a",{href:e.install.skillsShUrl,target:"_blank",rel:"noreferrer",title:e.install.skillsShUrl,style:{display:"flex",alignItems:"center",gap:8,width:"fit-content",maxWidth:"100%",color:"var(--accent)",textDecoration:"none"},children:(0,r.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.install.skillsShUrl.replace(/^https?:\/\//,"")," ↗"]})})]}),e.install&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Version"}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-muted)"},children:rJ(l?.currentVersion??e.install.versionHash)}),e.install.canCheckForUpdates&&(0,r.jsx)("button",{onClick:u,disabled:a||d,style:{padding:"4px 9px",border:"1px solid var(--border)",borderRadius:5,background:"none",color:"var(--text-muted)",cursor:a||d?"not-allowed":"pointer",opacity:a||d?.5:1,fontSize:11},children:h("i18n.check")}),l?.state==="update-available"&&(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"#d97706"},children:rJ(l.latestVersion)}),(a||l&&"update-available"!==l.state)&&(0,r.jsx)("span",{style:{fontSize:12,color:a?"var(--accent)":l?.state==="up-to-date"?"#16a34a":l?.state==="error"?"#ef4444":"var(--text-dim)"},children:a?h("i18n.checking"):l?.state==="up-to-date"?h("i18n.upToDate"):l?.state==="unsupported"?h("i18n.automaticChecksUnavailable"):l?.message||h("i18n.checkFailed")}),l?.state==="update-available"&&(0,r.jsx)("button",{onClick:p,disabled:d||a,style:{padding:"4px 10px",border:"none",borderRadius:5,background:"var(--accent)",color:"#fff",cursor:d||a?"not-allowed":"pointer",opacity:d||a?.5:1,fontSize:11,fontWeight:600},children:h(d?"i18n.updating":"i18n.update")})]}),c&&(0,r.jsx)("span",{style:{fontSize:12,color:"#ef4444"},children:c})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Name"}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--text)"},children:e.name})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:"Description"}),(0,r.jsx)("span",{style:{fontSize:14,color:"var(--text-muted)",lineHeight:1.6},children:e.description})]})]})}function rG({cwd:e,installedPackages:t,projectResourcesLoaded:n,onInstalled:o}){let{t:l}=(0,s.s)(),[a,d]=(0,i.useState)(""),[c,u]=(0,i.useState)([]),[p,h]=(0,i.useState)(!1),[g,x]=(0,i.useState)(null),[f,m]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[b,k]=(0,i.useState)(new Set),[w,j]=(0,i.useState)("global"),S=(0,i.useRef)(null);(0,i.useEffect)(()=>{S.current?.focus()},[]);let C=(0,i.useCallback)(async e=>{if(e.trim()){h(!0),x(null),u([]);try{let t=await fetch("/api/skills/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim()})}),n=await t.json();if(n.error)return void x(n.error);u(n.results??[]),0===(n.results??[]).length&&x("No skills found")}catch(e){x(String(e))}finally{h(!1)}}},[]),T=(0,i.useCallback)(async t=>{m(t),y(null);try{let n=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({package:t,scope:w,cwd:e})}),r=await n.json();if(!n.ok||r.error)return void y(r.error??`HTTP ${n.status}`);k(e=>new Set(e).add(`${w}:${t}`)),o()}catch(e){y(String(e))}finally{m(null)}},[o,w,e]),M="global"===w?"~/.pi/agent/skills/":`${r_(e)}/.pi/skills/`;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:20},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:l("i18n.addSkill")}),(0,r.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,r.jsx)("input",{ref:S,value:a,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&C(a)},placeholder:l("i18n.skillSearchPlaceholder"),style:{flex:1,padding:"7px 10px",fontSize:13,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",outline:"none"}}),(0,r.jsx)("button",{onClick:()=>C(a),disabled:p||!a.trim(),style:{padding:"7px 16px",fontSize:13,borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",cursor:p||!a.trim()?"not-allowed":"pointer",opacity:p||!a.trim()?.5:1,flexShrink:0},children:p?l("i18n.searching"):l("i18n.search")})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("div",{style:{display:"flex",borderRadius:5,border:"1px solid var(--border)",overflow:"hidden",fontSize:12,flexShrink:0},children:["global","project"].map(e=>(0,r.jsx)("button",{onClick:()=>{("global"===e||n)&&j(e)},disabled:"project"===e&&!n,title:"project"!==e||n?void 0:l("trust.projectScopeUnavailable"),style:{padding:"3px 10px",border:"none",cursor:"project"!==e||n?"pointer":"not-allowed",background:w===e?"var(--bg-selected)":"none",color:w===e?"var(--text)":"var(--text-dim)",fontWeight:w===e?600:400,opacity:"project"!==e||n?1:.45,borderRight:"global"===e?"1px solid var(--border)":"none"},children:e},e))}),(0,r.jsxs)("span",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["→ ",M]})]}),g&&(0,r.jsx)("div",{style:{fontSize:12,color:"#f87171"},children:g}),v&&(0,r.jsx)("div",{style:{fontSize:12,color:"#f87171",wordBreak:"break-word"},children:v})]}),c.length>0?(0,r.jsx)("div",{style:{flex:1,overflowY:"auto"},children:c.map(e=>{let n=t[w].has(e.package)||b.has(`${w}:${e.package}`),i=f===e.package,o=e.package.indexOf("@"),s=o>-1?e.package.slice(0,o):e.package,a=o>-1?e.package.slice(o+1):null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"12px 0",borderBottom:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:3},children:a??s}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-dim)"},children:s}),(0,r.jsx)("span",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:500},children:e.installs}),e.url&&(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{fontSize:12,color:"var(--accent)",textDecoration:"none"},children:"skills.sh ↗"})]})]}),(0,r.jsx)("button",{onClick:()=>!n&&!i&&T(e.package),disabled:n||i||null!==f,style:{flexShrink:0,padding:"5px 14px",fontSize:12,fontWeight:500,borderRadius:5,border:"1px solid var(--border)",cursor:n||i||null!==f?"not-allowed":"pointer",background:n?"rgba(34,197,94,0.1)":"none",color:n?"#16a34a":i?"var(--accent)":"var(--text-muted)",transition:"color 0.12s"},children:n?`✓ ${l("i18n.installed")}`:i?l("i18n.installing"):l("i18n.install")})]},e.package)})}):!g&&!p&&(0,r.jsxs)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.8},children:["Search"," ",(0,r.jsx)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",style:{color:"var(--accent)",textDecoration:"none"},children:"skills.sh"})," ","to discover and install skills for your agent."]})]})}function rX({cwd:e,onClose:t}){let n=tK(),{t:o}=(0,s.s)(),[l,a]=(0,i.useState)([]),[d,c]=(0,i.useState)(!0),[u,p]=(0,i.useState)(null),[h,g]=(0,i.useState)(null),[x,f]=(0,i.useState)(new Set),[m,v]=(0,i.useState)(null),[y,b]=(0,i.useState)(!1),[k,w]=(0,i.useState)({}),[j,S]=(0,i.useState)(new Set),[C,T]=(0,i.useState)(!1),[M,R]=(0,i.useState)(null),[I,L]=(0,i.useState)(null),[W,z]=(0,i.useState)(!0),[E,P]=(0,i.useState)({}),$=(0,i.useCallback)(async()=>{c(!0),p(null);try{let t=await fetch(`/api/skills?cwd=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok||n.error)throw Error(n.error??`HTTP ${t.status}`);let r=n.skills??[];if(a(r),z(n.projectResourcesLoaded??!0),r.length>0&&!h){let e=r.find(e=>!e.disableModelInvocation)??r[0];g(e.filePath),e.disableModelInvocation&&P(t=>({...t,[rq(e)]:!0}))}return r}catch(e){return p(String(e)),[]}finally{c(!1)}},[e,h]);(0,i.useEffect)(()=>{w({}),L(null),$()},[e]);let F=(0,i.useCallback)(async t=>{let n=(t?[t]:l.filter(e=>!!e.install)).map(rK).filter(e=>!!e);if(0!==n.length){L(null),S(e=>new Set([...e,...n])),t||T(!0);try{let n=await fetch("/api/skills/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,package:t?.install?.package,scope:t?.install?.scope})}),r=await n.json();if(!n.ok||r.error)throw Error(r.error??`HTTP ${n.status}`);w(e=>{let t={...e};for(let e of r.updates??[])t[`${e.scope}\0${e.package}`]=e;return t})}catch(e){L(e instanceof Error?e.message:String(e))}finally{S(e=>{let t=new Set(e);for(let e of n)t.delete(e);return t}),t||T(!1)}}},[e,l]),D=(0,i.useCallback)(async t=>{if(!t.install)return;let n=rK(t);R(n),L(null);try{let r=await fetch("/api/skills/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,package:t.install.package,scope:t.install.scope})}),i=await r.json();if(!r.ok||i.error||!i.success)throw Error(i.error??`HTTP ${r.status}`);await $();let o=i.skill?.install?.versionHash;w(e=>({...e,[n]:{package:t.install.package,scope:t.install.scope,state:"up-to-date",currentVersion:o,latestVersion:o}}))}catch(e){L(e instanceof Error?e.message:String(e))}finally{R(null)}},[e,$]),N=(0,i.useCallback)(async e=>{let t=!e.disableModelInvocation;f(t=>new Set(t).add(e.filePath)),v(null);try{let n=await fetch("/api/skills",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:e.filePath,disableModelInvocation:t})}),r=await n.json();if(!n.ok||r.error)return void v(r.error??`HTTP ${n.status}`);a(n=>n.map(n=>n.filePath===e.filePath?{...n,disableModelInvocation:t}:n)),t&&P(t=>({...t,[rq(e)]:!0}))}catch(e){v(String(e))}finally{f(t=>{let n=new Set(t);return n.delete(e.filePath),n})}},[]),A=l.find(e=>e.filePath===h)??null;return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,r.jsxs)("div",{style:{width:n?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:n?"calc(100dvh - 16px)":"78vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:o("common.skills")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r_(e)})]}),(0,r.jsx)("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),!W&&(0,r.jsx)("div",{role:"status",style:{padding:"8px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",fontSize:12},children:o("trust.skillsNotLoaded")}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:n?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:n?"100%":210,maxHeight:n?"40vh":void 0,borderRight:n?"none":"1px solid var(--border)",borderBottom:n?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:d?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:o("i18n.loading")}):u?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#f87171"},children:u}):0===l.length?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:o("i18n.noSkills")}):(()=>{let e=[];for(let{label:t,matches:n}of[{label:"project / skills.sh",matches:e=>"project"===rV(e)&&!!e.install?.skillsShUrl},{label:"project",matches:e=>"project"===rV(e)&&!e.install?.skillsShUrl},{label:"global / skills.sh",matches:e=>"global"===rV(e)&&!!e.install?.skillsShUrl},{label:"global",matches:e=>"global"===rV(e)&&!e.install?.skillsShUrl},{label:"path",matches:e=>"path"===rV(e)}]){let r=l.filter(n);r.length>0&&e.push({label:t,skills:r})}let t=e=>{let t,n,i=!y&&h===e.filePath,l=e.disableModelInvocation;return(0,r.jsxs)("div",{onClick:()=>{g(e.filePath),b(!1)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:i?"var(--bg-selected)":"none"},onMouseEnter:e=>{i||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{i||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:l?"var(--border)":"var(--accent)",boxShadow:l?"none":"0 0 4px var(--accent)",transition:"background 0.15s, box-shadow 0.15s"}}),(0,r.jsx)("span",{style:{fontSize:12,fontWeight:i?600:400,color:l?"var(--text-dim)":"var(--text)",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(n=(t=rK(e))?k[t]:void 0,n?.state!=="update-available"?null:(0,r.jsx)("span",{title:o("i18n.updateAvailable"),style:{color:"#d97706",fontSize:13,lineHeight:1,flexShrink:0},children:"↑"}))]},e.filePath)};return e.map(({label:e,skills:n})=>{let i=n.filter(e=>!e.disableModelInvocation),l=n.filter(e=>e.disableModelInvocation),s=E[e]??!1;return(0,r.jsxs)("div",{style:{marginBottom:6},children:[(0,r.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em"},children:e}),i.map(t),l.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{onClick:()=>P(t=>({...t,[e]:!s})),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.06em",cursor:"pointer",userSelect:"none"},children:[(0,r.jsx)("span",{style:{fontSize:8},children:s?"▾":"▸"}),o("i18n.dormant")," (",l.length,")"]}),s&&l.map(t)]})]},e)})})()}),(0,r.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,r.jsxs)("div",{onClick:()=>b(!0),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,cursor:"pointer",background:y?"var(--bg-selected)":"none",color:y?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{y||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{y||(e.currentTarget.style.background="none")},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),o("i18n.addSkill")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:y?(0,r.jsx)(rG,{cwd:e,projectResourcesLoaded:W,installedPackages:{global:new Set(l.filter(e=>e.install?.scope==="global").map(e=>e.install.package)),project:new Set(l.filter(e=>e.install?.scope==="project").map(e=>e.install.package))},onInstalled:()=>{$()}}):d?null:A?(0,r.jsx)(rZ,{skill:A,cwd:e,onToggle:N,toggling:x.has(A.filePath),saveError:m,updateStatus:rK(A)?k[rK(A)]:void 0,checkingUpdate:!!rK(A)&&j.has(rK(A)),updating:M===rK(A),updateError:I,onCheckUpdate:()=>void F(A),onUpdate:()=>void D(A)},A.filePath):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:o("i18n.selectSkill")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[l.some(e=>!!e.install)&&(0,r.jsx)("button",{onClick:()=>void F(),disabled:C||null!==M,style:{padding:"6px 12px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:C||null!==M?"not-allowed":"pointer",opacity:C||null!==M?.5:1,fontSize:12},children:C?o("i18n.checking"):o("i18n.checkUpdates")}),Object.values(k).filter(e=>"update-available"===e.state).length>0&&(0,r.jsxs)("span",{style:{fontSize:12,color:"#d97706"},children:[Object.values(k).filter(e=>"update-available"===e.state).length," ",1===Object.values(k).filter(e=>"update-available"===e.state).length?o("i18n.update"):o("i18n.updates")]})]}),(0,r.jsx)("button",{onClick:t,style:{padding:"6px 14px",background:"none",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:13},children:o("i18n.close")})]})]})})}function rQ(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,"~")}function r0(e){let t=e.trim().match(/^\$?\s*pi\s+install\s+(\S+)\s*$/);return t?.[1]??e}function r1(e){return`${e.scope}\0${e.source}`}function r2(e,t){if(e.disabled)return t("i18n.disabled");let n=[e.counts.extensions?t("i18n.resourceCount",{count:e.counts.extensions,label:t("i18n.extensionShort")}):"",e.counts.skills?t("i18n.resourceCount",{count:e.counts.skills,label:t("i18n.skillShort")}):"",e.counts.prompts?t("i18n.resourceCount",{count:e.counts.prompts,label:t("i18n.promptShort")}):"",e.counts.themes?t("i18n.resourceCount",{count:e.counts.themes,label:t("i18n.themeShort")}):""].filter(Boolean);return n.length?n.join(" \xb7 "):t("i18n.noResources")}function r8(e,t){let n=[];return e.version&&n.push(t("i18n.installedVersion",{version:e.version})),e.configuredVersion&&n.push(t("i18n.configuredVersion",{version:e.configuredVersion})),n.length?n.join(" \xb7 "):t("i18n.unknown")}function r4(e){return"loaded"===e?"var(--accent)":"installed"===e?"#f59e0b":"disabled"===e?"var(--text-dim)":"#ef4444"}function r5({pkg:e}){let{t}=(0,s.s)(),n=[["extension",t("i18n.extensions")],["skill",t("i18n.skills")],["prompt",t("i18n.prompts")],["theme",t("i18n.themes")]].map(([t,n])=>({kind:t,label:n,resources:e.resources.filter(e=>e.kind===t)})).filter(e=>e.resources.length>0);return 0===n.length?(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)"},children:t(e.disabled?"i18n.packageDisabled":"i18n.noResolvedResources")}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:n.map((e,t)=>(0,r.jsxs)("div",{style:{borderTop:0===t?"none":"1px solid var(--border)",paddingTop:12*(0!==t)},children:[(0,r.jsx)("div",{style:{fontSize:10,fontWeight:700,color:"var(--text-dim)",textTransform:"uppercase",marginBottom:6},children:e.label}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.resources.map(e=>(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.path,children:e.name}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:1},title:e.path,children:e.relativePath})]},`${e.kind}:${e.path}`))})]},e.kind))})}function r6({scope:e}){return(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,flexShrink:0,background:"project"===e?"rgba(99,102,241,0.12)":"rgba(120,120,120,0.12)",color:"project"===e?"rgba(99,102,241,0.85)":"var(--text-dim)"},children:e})}function r3(e,t){return{padding:"6px 12px",background:t?"rgba(239,68,68,0.08)":"none",border:"1px solid var(--border)",borderRadius:6,color:t?"#ef4444":"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1}}function r9({enabled:e,loading:t,onToggle:n,label:i}){return(0,r.jsx)("button",{type:"button",onClick:n,disabled:t,title:i,"aria-label":i,"aria-pressed":e,style:{flexShrink:0,width:40,height:22,borderRadius:11,border:"none",padding:0,cursor:t?"wait":"pointer",background:e?"var(--accent)":"var(--border)",position:"relative",transition:"background 0.18s",outline:"none",opacity:t?.65:1},children:(0,r.jsx)("span",{style:{position:"absolute",top:3,left:e?21:3,width:16,height:16,borderRadius:"50%",background:"var(--bg)",boxShadow:"0 1px 4px rgba(0,0,0,0.22)",transition:"left 0.18s cubic-bezier(.4,0,.2,1)"}})})}function r7({value:e,projectResourcesLoaded:t,onChange:n}){let{t:i}=(0,s.s)();return(0,r.jsx)("div",{style:{display:"inline-flex",border:"1px solid var(--border)",borderRadius:7,overflow:"hidden",height:30},children:["global","project"].map(o=>{let l=e===o,s="project"===o&&!t;return(0,r.jsx)("button",{onClick:()=>{s||n(o)},disabled:s,title:s?i("trust.projectScopeUnavailable"):void 0,style:{width:76,border:"none",borderRight:"global"===o?"1px solid var(--border)":"none",background:l?"var(--bg-selected)":"none",color:l?"var(--text)":"var(--text-muted)",cursor:s?"not-allowed":"pointer",opacity:s?.45:1,fontSize:12},children:o},o)})})}function ie({cwd:e,source:t,scope:n,projectResourcesLoaded:o,busy:l,actionError:a,onSourceChange:d,onScopeChange:c,onInstall:u}){let{t:p}=(0,s.s)(),h=(0,i.useRef)(null);return(0,i.useEffect)(()=>{h.current?.focus()},[]),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:18,maxWidth:660,minHeight:"100%"},children:[(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[(0,r.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:p("i18n.addPlugin")}),(0,r.jsxs)("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:5,color:"var(--accent)",fontSize:12,textDecoration:"none",whiteSpace:"nowrap"},children:[(0,r.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 800 800","aria-hidden":"true",focusable:"false",style:{flexShrink:0},children:[(0,r.jsx)("path",{fill:"#000",fillRule:"evenodd",d:"M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z"}),(0,r.jsx)("path",{fill:"#000",d:"M517.36 400H634.72V634.72H517.36Z"})]}),"pi.dev/packages"]})]}),(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:"project"===n?`${rQ(e)}/.pi/agent/{npm,git}`:"~/.pi/agent/{npm,git}"})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("label",{htmlFor:"plugin-source",style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:"Source"}),(0,r.jsx)("input",{id:"plugin-source",ref:h,value:t,onChange:e=>d(e.target.value),onPaste:e=>{let t=e.clipboardData.getData("text"),n=r0(t);n!==t&&(e.preventDefault(),d(n))},onBlur:e=>d(r0(e.currentTarget.value)),placeholder:"npm:@scope/package",style:{width:"100%",height:36,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:13,outline:"none"},onKeyDown:e=>{"Enter"===e.key&&t.trim()&&!l&&u()}})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsx)(r7,{value:n,projectResourcesLoaded:o,onChange:c}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:l||!t.trim(),style:{...r3(l||!t.trim()),background:"var(--accent)",color:"white",borderColor:"var(--accent)"},children:p(l?"i18n.installing":"i18n.install")})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)"},children:"Examples"}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:["npm:@scope/pi-plugin","git:https://github.com/user/repo","/absolute/path/to/plugin"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>d(e),style:{width:"100%",minHeight:30,textAlign:"left",padding:"6px 9px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-dim)",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:11},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text-muted)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--bg-panel)",e.currentTarget.style.color="var(--text-dim)"},children:e},e))})]}),a&&(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444",whiteSpace:"pre-wrap"},children:a})]})}function it({pkg:e,cwd:t,busyKey:n,actionError:i,actionMessage:o,sessionId:l,onAction:a,onReloadSession:d}){let{t:c}=(0,s.s)(),u=r1(e),p=n?.endsWith(u)??!1,h="reload"===n,g=!e.disabled;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20,maxWidth:680},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12,minWidth:0,flexWrap:"wrap"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:180,flex:1},children:[(0,r.jsx)(r9,{enabled:g,loading:p||h,onToggle:()=>a(e.disabled?"enable":"disable",e),label:c(e.disabled?"i18n.enablePackage":"i18n.disablePackage")}),(0,r.jsx)(r6,{scope:e.scope}),e.disabled?(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:"rgba(120,120,120,0.12)",color:"var(--text-dim)"},children:c("i18n.disabled")}):e.filtered&&(0,r.jsx)("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:"rgba(245,158,11,0.12)",color:"#d97706"},children:c("i18n.filtered")}),(0,r.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.source})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,r.jsx)("button",{onClick:()=>a("update",e),disabled:p||h,style:r3(p||h),children:c(n===`update:${u}`?"i18n.updating":"i18n.update")}),(0,r.jsx)("button",{onClick:d,disabled:!l||h||p,style:r3(!l||h||p),title:c(l?"i18n.reloadSession":"i18n.openSessionToReload"),children:c(h?"i18n.reloading":"i18n.reloadSession")}),(0,r.jsx)("button",{onClick:()=>a("remove",e),disabled:p||h,style:r3(p||h,!0),children:c(n===`remove:${u}`?"i18n.removing":"i18n.remove")})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(96px, 130px) minmax(0, 1fr)",gap:"9px 14px",fontSize:12,lineHeight:1.45},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:c("i18n.status")}),(0,r.jsx)("div",{style:{color:r4(e.status),textTransform:"capitalize"},children:e.status}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:c("i18n.version")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)"},children:r8(e,c)}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:c("i18n.package")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:e.packageName??c("i18n.unknown")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:c("i18n.resources")}),(0,r.jsx)("div",{style:{color:"var(--text-muted)"},children:r2(e,c)}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:c("i18n.installedPath")}),(0,r.jsx)("div",{style:{color:e.installedPath?"var(--text-muted)":"#ef4444",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:e.installedPath?rQ(e.installedPath):c("i18n.notFound")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)"},children:c("i18n.cwd")}),(0,r.jsx)("div",{style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",overflowWrap:"anywhere"},children:rQ(t)})]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"var(--text)"},children:c("i18n.resolvedResources")}),(0,r.jsx)(r5,{pkg:e})]}),o&&(0,r.jsx)("div",{style:{fontSize:12,color:"#16a34a"},children:o}),i&&(0,r.jsx)("div",{style:{fontSize:12,color:"#ef4444",whiteSpace:"pre-wrap"},children:i})]})}function ir({cwd:e,sessionId:t,onClose:n,onReloaded:o}){let l=tK(),{t:a}=(0,s.s)(),[d,c]=(0,i.useState)(null),[u,p]=(0,i.useState)(!0),[h,g]=(0,i.useState)(null),[x,f]=(0,i.useState)(null),[m,v]=(0,i.useState)(!1),[y,b]=(0,i.useState)(""),[k,w]=(0,i.useState)("global"),[j,S]=(0,i.useState)(null),[C,T]=(0,i.useState)(null),[M,R]=(0,i.useState)(null),I=(0,i.useMemo)(()=>d?.packages??[],[d?.packages]),L=I.find(e=>r1(e)===x)??null,W=d?.projectResourcesLoaded??!0,z=(0,i.useMemo)(()=>["project","global"].map(e=>({scope:e,packages:I.filter(t=>t.scope===e)})).filter(e=>e.packages.length>0),[I]),E=(0,i.useCallback)(async()=>{p(!0),g(null);try{let t=await fetch(`/api/plugins?cwd=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok||n.error)throw Error(n.error??`HTTP ${t.status}`);c(n),v(e=>0===n.packages.length||e),f(e=>e&&n.packages.some(t=>r1(t)===e)?e:n.packages[0]?r1(n.packages[0]):null)}catch(e){g(e instanceof Error?e.message:String(e))}finally{p(!1)}},[e]);(0,i.useEffect)(()=>{E()},[E]);let P=(0,i.useCallback)(async(t,n)=>{let r=r1(n);S(`${t}:${r}`),T(null),R(null);try{let r=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,source:n.source,scope:n.scope,cwd:e})}),i=await r.json();if(!r.ok||i.error)throw Error(i.error??`HTTP ${r.status}`);c(i),"remove"===t?(f(i.packages[0]?r1(i.packages[0]):null),0===i.packages.length&&v(!0),R("Package removed.")):R({install:"Package installed.",update:"Package updated.",disable:"Package disabled.",enable:"Package enabled."}[t])}catch(e){T(e instanceof Error?e.message:String(e))}finally{S(null)}},[e]),$=(0,i.useCallback)(async()=>{let t=r0(y).trim();if(!t)return;b(t);let n=`${k}\0${t}`;S(`install:${n}`),T(null),R(null);try{var r;let i,o,l=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"install",source:t,scope:k,cwd:e})}),s=await l.json();if(!l.ok||s.error)throw Error(s.error??`HTTP ${l.status}`);c(s);let a=(r=s.packages,o=(i=t.trim()).startsWith("npm:")?i.slice(4):i,r.find(e=>e.scope===k&&e.source===i)??r.find(e=>e.scope===k&&e.source===`npm:${o}`)??r.find(e=>e.scope===k&&e.source.endsWith(i)));f(a?r1(a):n),v(!1),b(""),R("Package installed.")}catch(e){T(e instanceof Error?e.message:String(e))}finally{S(null)}},[e,k,y]),F=(0,i.useCallback)(async()=>{if(t){S("reload"),T(null),R(null);try{await nf(t,{type:"reload"}),o?.(),await E(),R("Session reloaded.")}catch(e){T(e instanceof Error?e.message:String(e))}finally{S(null)}}},[E,o,t]),D=j?.startsWith("install:")??!1;return(0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&n()},children:(0,r.jsxs)("div",{style:{width:l?"calc(100vw - 16px)":860,maxWidth:"calc(100vw - 16px)",height:l?"calc(100dvh - 16px)":"76vh",maxHeight:"calc(100dvh - 16px)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 18px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:a("common.plugins")}),(0,r.jsx)("code",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:rQ(e)})]}),(0,r.jsx)("button",{onClick:n,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1,padding:"2px 6px"},children:"\xd7"})]}),!W&&(0,r.jsx)("div",{role:"status",style:{padding:"8px 18px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",color:"var(--text-muted)",fontSize:12},children:a("trust.pluginsNotLoaded")}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:l?"column":"row",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{width:l?"100%":245,maxHeight:l?"40vh":void 0,borderRight:l?"none":"1px solid var(--border)",borderBottom:l?"1px solid var(--border)":"none",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg-panel)"},children:[(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"8px 6px"},children:u?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:12,color:"var(--text-muted)"},children:"Loading..."}):h?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"#ef4444"},children:h}):0===I.length?(0,r.jsx)("div",{style:{padding:"10px 8px",fontSize:11,color:"var(--text-dim)"},children:"No plugins configured"}):z.map(e=>(0,r.jsxs)("div",{style:{marginBottom:6},children:[(0,r.jsx)("div",{style:{padding:"4px 8px 3px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase"},children:e.scope}),e.packages.map(e=>{let t=r1(e),n=!m&&x===t;return(0,r.jsxs)("div",{onClick:()=>{f(t),v(!1),T(null),R(null)},style:{display:"flex",alignItems:"center",gap:7,padding:"8px 8px",borderRadius:5,cursor:"pointer",background:n?"var(--bg-selected)":"none"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="none")},children:[(0,r.jsx)("span",{style:{flexShrink:0,width:7,height:7,borderRadius:"50%",background:r4(e.status)}}),(0,r.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,r.jsx)("div",{style:{fontSize:12,fontWeight:n?600:400,color:"var(--text)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.source}),(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2},children:r2(e,a)}),(e.version||e.configuredVersion)&&(0,r.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2},children:r8(e,a)})]})]},t)})]},e.scope))}),(0,r.jsx)("div",{style:{padding:"8px 6px",borderTop:"1px solid var(--border)",flexShrink:0},children:(0,r.jsxs)("button",{type:"button",onClick:()=>{v(!0),T(null),R(null)},style:{display:"flex",alignItems:"center",gap:6,padding:"7px 8px",borderRadius:5,border:"none",width:"100%",cursor:"pointer",background:m?"var(--bg-selected)":"none",color:m?"var(--accent)":"var(--text-dim)",fontSize:12},onMouseEnter:e=>{m||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{m||(e.currentTarget.style.background="none")},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),a("i18n.addPlugin")]})})]}),(0,r.jsx)("div",{style:{flex:1,overflowY:"auto",padding:20},children:m?(0,r.jsx)(ie,{cwd:e,source:y,scope:k,projectResourcesLoaded:W,busy:D,actionError:C,onSourceChange:b,onScopeChange:w,onInstall:$}):u?null:L?(0,r.jsx)(it,{pkg:L,cwd:e,busyKey:j,actionError:C,actionMessage:M,sessionId:t,onAction:P,onReloadSession:F},r1(L)):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:13},children:a("i18n.selectPackage")})})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 18px",borderTop:"1px solid var(--border)",flexShrink:0},children:[(0,r.jsx)("div",{style:{minWidth:0,flex:1,fontSize:11,color:"var(--text-dim)",overflow:"hidden"},children:d?.diagnostics.length?(0,r.jsxs)("span",{title:d.diagnostics.map(e=>`${e.type}: ${e.source?`${e.source}: `:""}${e.message}`).join("\n"),style:{color:d.diagnostics.some(e=>"error"===e.type)?"#ef4444":"#d97706"},children:[d.diagnostics.length," diagnostic",1===d.diagnostics.length?"":"s"]}):(0,r.jsx)("span",{children:d?`${d.totals.extensions} ext \xb7 ${d.totals.skills} skills \xb7 ${d.totals.prompts} prompts \xb7 ${d.totals.themes} themes`:""})}),(0,r.jsx)("button",{onClick:()=>void E(),disabled:u||null!==j,style:r3(u||null!==j),children:a("i18n.refresh")}),(0,r.jsx)("button",{onClick:n,style:r3(!1),children:a("i18n.close")})]})]})})}function ii({cwd:e,busy:t,error:n,onCancel:i,onConfirm:o}){let{t:l}=(0,s.s)();return(0,r.jsx)("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0,0,0,0.4)"},onClick:e=>{t||e.target!==e.currentTarget||i()},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"project-trust-title",style:{width:440,maxWidth:"100%",border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-panel)",boxShadow:"0 12px 36px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:12,padding:"18px 18px 14px"},children:[(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0,marginTop:1},children:[(0,r.jsx)("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z"}),(0,r.jsx)("path",{d:"m9 12 2 2 4-4"})]}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{id:"project-trust-title",style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:l("trust.dialogTitle")}),(0,r.jsx)("div",{style:{marginTop:7,fontSize:12,lineHeight:1.6,color:"var(--text-muted)"},children:l("trust.dialogBody")}),(0,r.jsx)("code",{style:{display:"block",marginTop:10,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:5,background:"var(--bg)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:11,overflowWrap:"anywhere"},children:e}),n&&(0,r.jsx)("div",{role:"alert",style:{marginTop:10,color:"#ef4444",fontSize:12,lineHeight:1.5},children:n})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,padding:"10px 18px",borderTop:"1px solid var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:i,disabled:t,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:5,background:"transparent",color:"var(--text-muted)",cursor:t?"not-allowed":"pointer",fontSize:12},children:l("trust.cancel")}),(0,r.jsx)("button",{type:"button",onClick:o,disabled:t,style:{height:32,padding:"0 12px",border:"1px solid var(--accent)",borderRadius:5,background:"var(--accent)",color:"white",cursor:t?"wait":"pointer",opacity:t?.7:1,fontSize:12,fontWeight:600},children:l(t?"trust.trusting":"trust.trustProject")})]})]})})}function io(e){let t=e,n=t.compressedEntryIds?.length??0;for(;1===t.children.length;)t=t.children[0],n+=1+(t.compressedEntryIds?.length??0);return{node:t,skipped:n}}function il({node:e,activePathIds:t,depth:n,isLast:i,parentLines:o,onSelect:l}){let{node:s,skipped:a}=io(e),d=t.has(s.entry.id),c=t.has(e.entry.id)||t.has(s.entry.id),u=function(e){if("message"===e.type&&"message"in e){let t=e.message,n=t.content,r="";if("string"==typeof n?r=n:Array.isArray(n)&&(r=n.filter(e=>"text"===e.type).map(e=>e.text).join(" ")),r.length>40&&(r=r.slice(0,40)+"…"),r)return r;if("assistant"===t.role)return"[assistant]"}return e.type}(s.entry),p="message"===s.entry.type&&"message"in s.entry?s.entry.message.role:null;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",height:24,cursor:"pointer"},onClick:()=>l(s.entry.id),children:[o.map((e,t)=>(0,r.jsx)("div",{style:{width:16,flexShrink:0,position:"relative",height:"100%",alignSelf:"stretch"},children:e&&(0,r.jsx)("div",{style:{position:"absolute",left:7,top:0,bottom:0,width:1,background:"var(--border)"}})},t)),(0,r.jsxs)("div",{style:{width:16,flexShrink:0,position:"relative",height:"100%",alignSelf:"stretch"},children:[(0,r.jsx)("div",{style:{position:"absolute",left:7,top:0,bottom:i?"50%":0,width:1,background:"var(--border)"}}),(0,r.jsx)("div",{style:{position:"absolute",left:7,top:"50%",width:9,height:1,background:"var(--border)"}})]}),(0,r.jsx)("div",{style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:d?"var(--accent)":c?"var(--text-muted)":"var(--border)",border:d?"none":"1px solid var(--text-dim)",marginRight:6,transition:"background 0.12s"}}),p&&(0,r.jsx)("span",{style:{fontSize:9,fontFamily:"var(--font-mono)",color:"user"===p?"var(--accent)":"var(--text-dim)",background:"user"===p?"rgba(37,99,235,0.08)":"var(--bg-hover)",border:`1px solid ${"user"===p?"rgba(37,99,235,0.2)":"var(--border)"}`,borderRadius:3,padding:"0 4px",marginRight:5,flexShrink:0,lineHeight:"16px"},children:"user"===p?"U":"A"}),a>0&&(0,r.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",marginRight:5,flexShrink:0},children:["+",a]}),(0,r.jsx)("span",{style:{fontSize:11,color:d?"var(--text)":c?"var(--text-muted)":"var(--text-dim)",fontWeight:d?500:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:u})]}),s.children.map((e,a)=>(0,r.jsx)(il,{node:e,activePathIds:t,depth:n+1,isLast:a===s.children.length-1,parentLines:[...o,!i],onSelect:l},e.entry.id))]})}function is({tree:e,activeLeafId:t,onLeafChange:n,inline:o,containerRef:l,open:a,onToggle:d,hasSession:c,compact:u}){let{t:p}=(0,s.s)(),[h,g]=(0,i.useState)(!1),x=void 0!==a?a:h,f=(0,i.useRef)(null),[m,v]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!x||!o)return;let e=l?.current??f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();v({top:t.bottom,left:t.left,width:t.width})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[x,o,l]);let y=(0,i.useMemo)(()=>t?new Set(function e(n,r){for(let i of n){let n=[...r,i.entry.id];if(i.entry.id===t||i.compressedEntryIds?.includes(t))return n;let o=e(i.children,n);if(o)return o}return null}(e,[])??[]):new Set,[e,t]),b=(0,i.useCallback)(e=>{n(e)},[n]),k=c?!function e(t){for(let n of t)if(n.children.length>1||e(n.children))return!0;return!1}(e)?p("i18n.noBranches"):null:p("i18n.noActiveSession"),w=e.length>0?io(e[0]):null,j=w?.node??null,S=!k&&j&&j.children.length>1,C=(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:S?"var(--accent)":"var(--text-dim)",flexShrink:0},children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),T=(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:2,transform:x?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})});return o?(0,r.jsxs)("div",{style:{height:"100%",display:"flex",alignItems:"stretch"},children:[(0,r.jsxs)("button",{ref:f,onClick:()=>d?d():g(e=>!e),style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:x?"var(--bg-selected)":"none",border:"none",borderTop:x?"2px solid var(--accent)":"2px solid transparent",borderRight:"1px solid var(--border)",cursor:"pointer",color:x?"var(--text)":"var(--text-muted)",fontSize:11,whiteSpace:"nowrap",transition:"color 0.1s, background 0.1s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color=x?"var(--text)":"var(--text-muted)"},title:p("i18n.branches"),"aria-label":p("i18n.branches"),"aria-pressed":x,children:[C,!u&&(0,r.jsx)("span",{children:p("i18n.branches")})]}),x&&m&&(0,r.jsx)("div",{style:{position:"fixed",top:m.top,left:m.left,width:m.width,background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",zIndex:500},children:S&&j?(0,r.jsx)("div",{style:{padding:"4px 12px 8px 12px",maxHeight:260,overflowY:"auto"},children:j.children.map((e,t)=>(0,r.jsx)(il,{node:e,activePathIds:y,depth:0,isLast:t===j.children.length-1,parentLines:[],onSelect:b},e.entry.id))}):(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:k})})]}):(0,r.jsxs)("div",{style:{borderBottom:"1px solid var(--border)",background:"var(--bg)",flexShrink:0,position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>g(e=>!e),style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 12px",background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:11,textAlign:"left"},children:[C,(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:p("i18n.branches")}),T]}),x&&(0,r.jsx)("div",{style:{position:"absolute",top:"100%",left:0,right:0,background:"var(--bg)",borderBottom:"1px solid var(--border)",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",zIndex:100},children:S&&j?(0,r.jsx)("div",{style:{padding:"4px 12px 8px 12px",maxHeight:260,overflowY:"auto"},children:j.children.map((e,t)=>(0,r.jsx)(il,{node:e,activePathIds:y,depth:0,isLast:t===j.children.length-1,parentLines:[],onSelect:b},e.entry.id))}):(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:k??p("i18n.noBranches")})})]})}function ia(e,t,n){let r=Number.isFinite(e)?e:t,i=Math.max(t,n);return Math.round(Math.max(t,Math.min(i,r)))}function id(e,t){try{window.localStorage.setItem(e,String(t))}catch{}}function ic(e){let{ariaLabel:t,cssVariable:n,defaultWidth:r,getDefaultWidth:o,getMaxWidth:l,growthDirection:s,maxWidth:a,minWidth:d,storageKey:c,widthRef:u}=e,p=(0,i.useRef)(null),h=(0,i.useRef)(null),g=(0,i.useRef)(!1),[x,f]=(0,i.useState)(r),[m,v]=(0,i.useState)(!1),y=(0,i.useCallback)(()=>Math.min(a,Math.max(d,l())),[l,a,d]),b=(0,i.useCallback)(e=>ia(e,d,y()),[y,d]),k=(0,i.useCallback)(e=>{u.current=e,p.current?.style.setProperty(n,`${e}px`)},[n,u]),w=(0,i.useCallback)((e,t={})=>{let{forcePersist:n=!1,persist:r=!0}=t,i=b(e),o=i!==u.current;return k(i),f(i),r&&(o||n)&&id(c,i),i},[k,b,c,u]),j=(0,i.useCallback)(e=>{document.body.style.cursor=e.previousCursor,document.body.style.userSelect=e.previousUserSelect},[]),S=(0,i.useCallback)(e=>{let t=h.current;if(t&&t.pointerId===e){h.current=null,j(t),v(!1),w(u.current,{forcePersist:!0});try{t.target.hasPointerCapture(e)&&t.target.releasePointerCapture(e)}catch{}}},[w,j,u]),C=(0,i.useCallback)(e=>{if("mouse"===e.pointerType&&0!==e.button)return;e.preventDefault(),e.stopPropagation();let t=h.current;t&&S(t.pointerId);let n=e.currentTarget;n.focus({preventScroll:!0}),n.setPointerCapture(e.pointerId),h.current={pointerId:e.pointerId,startX:e.clientX,startWidth:u.current,target:n,previousCursor:document.body.style.cursor,previousUserSelect:document.body.style.userSelect},document.body.style.cursor="col-resize",document.body.style.userSelect="none",v(!0)},[S,u]),T=(0,i.useCallback)(e=>{let t=h.current;if(!t||t.pointerId!==e.pointerId)return;if("mouse"===e.pointerType&&0===e.buttons)return void S(e.pointerId);e.preventDefault();let n="right"===s?1:-1,r=b(t.startWidth+(e.clientX-t.startX)*n);k(r),e.currentTarget.setAttribute("aria-valuenow",String(r)),e.currentTarget.setAttribute("aria-valuetext",`${r} px`)},[k,b,S,s]),M=(0,i.useCallback)(e=>{S(e.pointerId)},[S]),R=(0,i.useCallback)(e=>{S(e.pointerId)},[S]),I=(0,i.useCallback)(e=>{S(e.pointerId)},[S]),L=(0,i.useCallback)(()=>{w(o?.()??r,{forcePersist:!0})},[w,r,o]),W=(0,i.useCallback)(()=>{w(u.current)},[w,u]),z=(0,i.useCallback)(e=>{let t=e.shiftKey?32:12,n="right"===s?"ArrowRight":"ArrowLeft",r="right"===s?"ArrowLeft":"ArrowRight";e.key===n?(e.preventDefault(),w(u.current+t,{forcePersist:!0})):e.key===r?(e.preventDefault(),w(u.current-t,{forcePersist:!0})):"Home"===e.key?(e.preventDefault(),w(d,{forcePersist:!0})):"End"===e.key?(e.preventDefault(),w(y(),{forcePersist:!0})):"Enter"===e.key&&(e.preventDefault(),L())},[w,y,s,d,L,u]);return(0,i.useEffect)(()=>{if(g.current)return;g.current=!0;let e=function(e){try{let t=window.localStorage.getItem(e);if(null===t)return null;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:null}catch{return null}}(c),t=w(e??o?.()??r,{persist:!1});null!==e&&e!==t&&id(c,t)},[w,r,o,c]),(0,i.useEffect)(()=>{if(!g.current)return;w(u.current);let e=()=>{w(u.current)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[w,u]),(0,i.useEffect)(()=>{if(!m)return;let e=()=>{let e=h.current;e&&S(e.pointerId)},t=()=>{"visible"!==document.visibilityState&&e()};return window.addEventListener("blur",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("blur",e),document.removeEventListener("visibilitychange",t)}},[S,m]),(0,i.useEffect)(()=>()=>{let e=h.current;e&&(h.current=null,j(e))},[j]),{isResizing:m,panelRef:p,reclampWidth:W,resetWidth:L,separatorProps:{"aria-label":t,"aria-orientation":"vertical","aria-valuemax":y(),"aria-valuemin":d,"aria-valuenow":x,"aria-valuetext":`${x} px`,onDoubleClick:L,onKeyDown:z,onLostPointerCapture:I,onPointerCancel:R,onPointerDown:C,onPointerMove:T,onPointerUp:M,role:"separator",tabIndex:0},width:x}}function iu(){let e,t,n,a,d,c,u,p,h,g,x,f,m,v,y=(0,o.useRouter)(),b=(0,o.useSearchParams)(),[k]=(0,i.useState)(()=>{let e;return{requestedCwd:e=b.get("cwd")?.trim()||null,sessionId:e?null:b.get("session")}}),{isDark:w,toggleTheme:j}=tr(),{locale:S,setLocale:C,t:T,supportedLocales:M}=(0,s.s)(),R=tK();(0,i.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{let n;!function({hasFocusedEditable:e,innerHeight:t,viewportHeight:n,viewportScale:r}){let i=.01>Math.abs(r-1);return e&&i&&t-n>1}({hasFocusedEditable:(n=document.activeElement)instanceof HTMLElement&&(n.isContentEditable||"INPUT"===n.tagName||"SELECT"===n.tagName||"TEXTAREA"===n.tagName),innerHeight:window.innerHeight,viewportHeight:e.height,viewportScale:e.scale})?t.style.removeProperty("--app-viewport-height"):(t.style.setProperty("--app-viewport-height",`${e.height}px`),(0!==window.scrollX||0!==window.scrollY)&&window.scrollTo(0,0))};return n(),e.addEventListener("resize",n),e.addEventListener("scroll",n),()=>{e.removeEventListener("resize",n),e.removeEventListener("scroll",n),t.style.removeProperty("--app-viewport-height")}},[]);let[I,L]=(0,i.useState)(null),[W,z]=(0,i.useState)(null),[E,P]=(0,i.useState)(()=>k.requestedCwd?"validating":"idle"),[$,F]=(0,i.useState)(null),[D,N]=(0,i.useState)(0),[A,B]=(0,i.useState)(0),[H,O]=(0,i.useState)(0),[U,_]=(0,i.useState)(!1),[V,q]=(0,i.useState)(0),[J,Y]=(0,i.useState)(!1),[Z,G]=(0,i.useState)(!1),[X,Q]=(0,i.useState)(null),[ee,et]=(0,i.useState)(!1),[en,er]=(0,i.useState)(!1),[ei,eo]=(0,i.useState)(null),[el,es]=(0,i.useState)(!0),[ea,ed]=(0,i.useState)(!1),[ec,eu]=(0,i.useState)(!1),ep=(0,i.useRef)(260),eh=(0,i.useRef)(560),eg=(0,i.useCallback)(()=>ia(.42*window.innerWidth,360,640),[]),ex=(0,i.useCallback)(()=>(function(e){let{viewportWidth:t,rightPanelOpen:n,rightPanelWidth:r}=e;if(t<=640)return 480;let i=t<960;return Math.min(480,t-(i?320:420)-(!i&&n?r:0))})({viewportWidth:window.innerWidth,rightPanelOpen:ea,rightPanelWidth:eh.current}),[ea]),ef=(0,i.useCallback)(()=>(function(e){let{viewportWidth:t,sidebarOpen:n,sidebarWidth:r}=e;return t<960?1200:Math.min(1200,t-420-(n?r:0))})({viewportWidth:window.innerWidth,sidebarOpen:el,sidebarWidth:ep.current}),[el]),em=ic({ariaLabel:T("layout.resizeSidebar"),cssVariable:"--sidebar-width",defaultWidth:260,getMaxWidth:ex,growthDirection:"right",maxWidth:480,minWidth:180,storageKey:"pi-sidebar-width",widthRef:ep}),ev=ic({ariaLabel:T("layout.resizeFilePanel"),cssVariable:"--right-panel-width",defaultWidth:560,getDefaultWidth:eg,getMaxWidth:ef,growthDirection:"left",maxWidth:1200,minWidth:300,storageKey:"pi-right-panel-width",widthRef:eh}),ey=em.reclampWidth,eb=ev.reclampWidth;(0,i.useEffect)(()=>{R&&es(!1)},[R]),(0,i.useEffect)(()=>{eu(!0)},[]),(0,i.useEffect)(()=>{ea&&(ey(),eb())},[eb,ey,ea]);let ew=(0,i.useRef)(null),ej=(0,i.useRef)(null),eS=(0,i.useRef)(null),[eC,eT]=(0,i.useState)([]),[eM,eR]=(0,i.useState)(null),eI=(0,i.useRef)(null),eL=(0,i.useCallback)((e,t,n)=>{eT(e),eR(t),eI.current=n},[]),eW=(0,i.useCallback)(e=>{eI.current?.(e)},[]),[ez,eE]=(0,i.useState)(null),eP=(0,i.useRef)(null),e$=(0,i.useCallback)(e=>{eE(e)},[]),[eF,eD]=(0,i.useState)(null),[eN,eA]=(0,i.useState)({kind:"idle"}),eB=(0,i.useRef)(null),eH=(0,i.useRef)(I?.id??null);eH.current=I?.id??null;let eO=(0,i.useCallback)(e=>{eD(e)},[]),[eU,e_]=(0,i.useState)(null),eV=(0,i.useRef)(null),eq=(0,i.useCallback)((e,t)=>{ti(t).then(()=>{eV.current&&clearTimeout(eV.current),e_(e),eV.current=setTimeout(()=>e_(null),1400)})},[]);(0,i.useEffect)(()=>()=>{eV.current&&clearTimeout(eV.current),eB.current&&clearTimeout(eB.current)},[]);let[eK,eJ]=(0,i.useState)(null),eY=(0,i.useCallback)(e=>{eJ(e)},[]),[eZ,eG]=(0,i.useState)(null),[eX,eQ]=(0,i.useState)(null),e0=(0,i.useCallback)(e=>{R&&es(!1),eG(t=>t===e?null:e)},[R]),e1=(0,i.useCallback)(()=>{R&&es(!1),eG("session")},[R]),e2=(0,i.useCallback)(()=>{R&&eG(null),es(e=>!e)},[R]);(0,i.useEffect)(()=>{if(!eZ||!ej.current)return;let e=()=>{let e=ej.current.getBoundingClientRect();if("language"===eZ&&!R&&eS.current){let t=eS.current.getBoundingClientRect(),n=Math.min(176,e.width),r=Math.min(t.left-1,Math.max(e.left,e.right-n));eQ({top:e.bottom,left:r,width:n});return}eQ({top:e.bottom,left:e.left,width:e.width})};e();let t=new ResizeObserver(e);return t.observe(ej.current),eS.current&&t.observe(eS.current),()=>t.disconnect()},[eZ,R]);let[e8,e4]=(0,i.useState)([]),[e5,e6]=(0,i.useState)(null),e3=(0,i.useCallback)((e,t)=>{ew.current?.insertText(tO(e,t))},[]),e9=(0,i.useCallback)(e=>{let t=e.map(e=>tO(e,!1)).join("");t&&ew.current?.insertText(t)},[]),e7=(0,i.useCallback)((e,t,n)=>{let r,i,o,l;ew.current?.insertText((r=Math.max(1,Math.min(t,n)),i=Math.max(1,Math.max(t,n)),o=e.includes(" ")?`@"${e}"`:`@${e}`,l=r===i?`:${r}`:`:${r}-${i}`,`${o}${l} `))},[]),te=k.sessionId,[tt,tn]=(0,i.useState)(null),to=(0,i.useRef)(null),[tl,ts]=(0,i.useState)(()=>!te),ta=(0,i.useRef)(!1);(0,i.useEffect)(()=>{let e=k.requestedCwd;if(!e)return;let t=new AbortController;return P("validating"),F(null),fetch("/api/cwd/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e}),signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok||!t.cwd)throw Error(t.error??`HTTP ${e.status}`);ta.current=!0,z(t.cwd),P("ready")}).catch(e=>{t.signal.aborted||(F(e instanceof Error?e.message:String(e)),P("error"))}),()=>t.abort()},[k]);let td=(0,i.useCallback)((e,t)=>{if(tn(e),!e)return;let n=t??e,r=to.current??(I?I.projectRoot??I.cwd:null);if(to.current=n,ta.current){ta.current=!1;return}r!==n&&(L(null),z(t=>t&&t!==e?null:t),B(e=>e+1),eT([]),eR(null),eE(null),eG(null),e4([]),e6(null),ed(!1),y.replace("/",{scroll:!1}))},[y,I]),tc=(0,i.useCallback)((e,t=!1)=>{z(null),L(e),B(e=>e+1),eE(null),ts(!0),R&&!t&&es(!1),t&&(ta.current=!0),t||y.replace(`?session=${encodeURIComponent(e.id)}`,{scroll:!1})},[y,R]),tu=(0,i.useCallback)((e,t)=>{L(null),z(t),B(e=>e+1),eT([]),eR(null),eE(null),eG(null),R&&es(!1),y.replace("/",{scroll:!1})},[y,R]);!function(e){let{onNewSession:t,activeCwd:n}=e;(0,i.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(!l)return;let t=e.target?.tagName;if("TEXTAREA"===t||"INPUT"===t)return;e.preventDefault(),l();return}if("n"===e.key&&e.ctrlKey&&e.altKey){if(!n||!t)return;e.preventDefault(),t(n)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,t])}({onNewSession:e=>tu(`kb-${Date.now()}`,e),activeCwd:tt});let tp=(0,i.useCallback)(e=>{fetch("/api/sessions").then(e=>e.ok?e.json():null).then(t=>{let n=t?.sessions.find(t=>t.id===e);n&&L(t=>t&&t.id===e&&!t.projectRoot?n:t)}).catch(()=>{})},[]),th=(0,i.useCallback)(e=>{z(null),L(e),N(e=>e+1),tp(e.id),y.replace(`?session=${encodeURIComponent(e.id)}`,{scroll:!1})},[y,tp]),tg=(0,i.useCallback)(()=>{N(e=>e+1),O(e=>e+1)},[]),tx=(0,i.useCallback)(async()=>{let e=I?.id;if(e&&"naming"!==eN.kind){eB.current&&clearTimeout(eB.current),eG(null),eA({kind:"naming"});try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/auto-name`,{method:"POST"}),n=await t.json().catch(()=>({}));if(!t.ok||!n.title)throw Error(n.error||`HTTP ${t.status}`);let r=n.title.trim();if(N(e=>e+1),eH.current!==e)return;L(t=>t?.id===e?{...t,name:r}:t),eD(t=>t?.sessionId===e?{...t,sessionName:r}:t),eA({kind:"success"}),eB.current=setTimeout(()=>eA({kind:"idle"}),1800)}catch(t){if(eH.current!==e)return;eA({kind:"error",message:t instanceof Error?t.message:String(t)}),eB.current=setTimeout(()=>eA({kind:"idle"}),5e3)}}},[eN.kind,I?.id]);(0,i.useEffect)(()=>{eB.current&&clearTimeout(eB.current),eA({kind:"idle"})},[I?.id]);let tf=(0,i.useCallback)(()=>{O(e=>e+1)},[]),tm=(0,i.useCallback)(e=>{N(e=>e+1),B(e=>e+1),z(null),L(t=>({...t??{path:"",cwd:"",created:"",modified:"",messageCount:0,firstMessage:""},id:e})),tp(e),y.replace(`?session=${encodeURIComponent(e)}`,{scroll:!1})},[y,tp]),tv=(0,i.useCallback)(()=>{ts(!0)},[]),ty=(0,i.useCallback)(e=>{if(N(e=>e+1),I?.id===e){let e=I.cwd;L(null),z(e??null),B(e=>e+1),eT([]),eR(null),eE(null),eG(null),y.replace("/",{scroll:!1})}},[I,y]),tb=(0,i.useCallback)((e,t,n)=>{let r=n?.sourceSessionId,i=n?.modeHint,o=`file:${e}`;e4(n=>{let l=n.find(e=>e.id===o);if(!l)return[...n,{id:o,label:t,filePath:e,sourceSessionId:r,initialDisplayMode:i}];let s=!r||l.sourceSessionId===r,a=!i||l.initialDisplayMode===i;return s&&a?n:n.map(e=>{if(e.id!==o)return e;let t={...e};return r&&(t.sourceSessionId=r),i&&(t.initialDisplayMode=i),t})}),e6(o),ed(!0),R&&es(!1)},[R]),tk=(0,i.useCallback)(e=>{tb(e,K(e),{sourceSessionId:I?.id??null})},[tb,I?.id]),tw=(0,i.useCallback)(e=>{e4(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&ed(!1),n}),e6(t=>{if(t!==e)return t;let n=e8.filter(t=>t.id!==e);return n.length>0?n[n.length-1].id:null})},[e8]),tj=(0,i.useCallback)(()=>{I&&window.open(`/api/sessions/${encodeURIComponent(I.id)}/export?inline=1`,"_blank","noopener,noreferrer")},[I]),tS=W??(null===I&&tt?tt:null),tC=null!==I||null!==tS,tT=I?.cwd??tS,tM=tl&&!tC;(0,i.useEffect)(()=>{if(Q(null),et(!1),eo(null),!tT)return;let e=new AbortController;return fetch(`/api/project-trust?cwd=${encodeURIComponent(tT)}`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);Q(t)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to load project trust:",e)}),()=>e.abort()},[tT]);let tR=(0,i.useCallback)(async()=>{if(tT&&!en){er(!0),eo(null);try{let e=await fetch("/api/project-trust",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:tT})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error??`HTTP ${e.status}`);Q(t),et(!1),q(e=>e+1),B(e=>e+1)}catch(e){eo(e instanceof Error?e.message:String(e))}finally{er(!1)}}},[en,tT]),tI=e8.find(e=>e.id===e5)??null,tL=tt?K(tt)||tt:null,tW=tL?`${tL} - Pi Web`:"Pi Web";(0,i.useEffect)(()=>{let e=()=>{document.title!==tW&&(document.title=tW)};e();let t=new MutationObserver(e);return t.observe(document.head,{childList:!0,subtree:!0,characterData:!0}),()=>t.disconnect()},[tW]);let tz=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ek,{selectedSessionId:I?.id??null,onSelectSession:tc,onNewSession:tu,initialSessionId:te,skipInitialProjectSelection:null!==k.requestedCwd,onInitialRestoreDone:tv,refreshKey:D,onSessionDeleted:ty,selectedCwd:I?.cwd??W??null,onCwdChange:td,onOpenFile:tb,explorerRefreshKey:H,onExplorerRefresh:tf,onAtMention:e3,onAtMentions:e9}),(0,r.jsx)("div",{style:{padding:"8px",flexShrink:0,display:"flex",justifyContent:"space-between",gap:4},children:[{label:T("common.models"),onClick:()=>_(!0),disabled:!1,icon:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,r.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,r.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,r.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,r.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,r.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,r.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,r.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,r.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]})},{label:T("common.skills"),onClick:()=>Y(!0),disabled:!tt&&!I?.cwd&&!W,icon:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),(0,r.jsx)("path",{d:"M2 17l10 5 10-5"}),(0,r.jsx)("path",{d:"M2 12l10 5 10-5"})]})},{label:T("common.plugins"),onClick:()=>G(!0),disabled:!tt&&!I?.cwd&&!W,icon:(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M9 7V2"}),(0,r.jsx)("path",{d:"M15 7V2"}),(0,r.jsx)("path",{d:"M6 13V8a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v5a6 6 0 0 1-12 0Z"}),(0,r.jsx)("path",{d:"M12 19v3"})]})}].map(({label:e,onClick:t,disabled:n,icon:i})=>(0,r.jsxs)("button",{onClick:t,disabled:n,title:e,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:n?"default":"pointer",fontSize:12,opacity:n?.35:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)",e.currentTarget.style.color="var(--text)")},onMouseLeave:e=>{e.currentTarget.style.background="none",e.currentTarget.style.color="var(--text-muted)"},children:[i,e]},e))})]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:`
|
|
3
|
+
@keyframes session-info-pop {
|
|
4
|
+
0% {
|
|
5
|
+
opacity: 0;
|
|
6
|
+
transform: translateY(-24px);
|
|
7
|
+
filter: blur(6px);
|
|
8
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0);
|
|
9
|
+
}
|
|
10
|
+
55% {
|
|
11
|
+
opacity: 1;
|
|
12
|
+
transform: translateY(0);
|
|
13
|
+
filter: blur(0);
|
|
14
|
+
background: color-mix(in srgb, var(--accent) 8%, var(--bg-panel));
|
|
15
|
+
box-shadow: 0 18px 44px rgba(37,99,235,0.16);
|
|
16
|
+
}
|
|
17
|
+
100% {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
transform: translateY(0);
|
|
20
|
+
filter: blur(0);
|
|
21
|
+
background: var(--bg-panel);
|
|
22
|
+
box-shadow: 0 10px 28px rgba(0,0,0,0.10);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
@keyframes session-info-light-wash {
|
|
26
|
+
0% {
|
|
27
|
+
opacity: 0;
|
|
28
|
+
transform: translateX(-110%) skewX(-16deg);
|
|
29
|
+
}
|
|
30
|
+
24% {
|
|
31
|
+
opacity: 0.42;
|
|
32
|
+
}
|
|
33
|
+
100% {
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: translateX(115%) skewX(-16deg);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
.session-info-popover {
|
|
39
|
+
position: relative;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
transform-origin: top right;
|
|
42
|
+
animation: session-info-pop 360ms ease-out both;
|
|
43
|
+
will-change: transform, opacity, filter, background, box-shadow;
|
|
44
|
+
}
|
|
45
|
+
.session-info-popover::after {
|
|
46
|
+
content: "";
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 0;
|
|
49
|
+
bottom: 0;
|
|
50
|
+
left: 0;
|
|
51
|
+
width: 44%;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 24%, transparent), transparent);
|
|
54
|
+
animation: session-info-light-wash 620ms ease-out both;
|
|
55
|
+
}
|
|
56
|
+
@media (prefers-reduced-motion: reduce) {
|
|
57
|
+
.session-info-popover,
|
|
58
|
+
.session-info-popover::after {
|
|
59
|
+
animation: none;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
@media (max-width: 640px) {
|
|
63
|
+
.sidebar-overlay-backdrop.sidebar-mobile-pending {
|
|
64
|
+
opacity: 0 !important;
|
|
65
|
+
pointer-events: none !important;
|
|
66
|
+
}
|
|
67
|
+
.sidebar-container.sidebar-mobile-pending.sidebar-open {
|
|
68
|
+
transform: translateX(calc(-100% - env(safe-area-inset-left)));
|
|
69
|
+
box-shadow: none;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`}),(0,r.jsxs)("div",{style:{display:"flex",width:"100%",height:"var(--app-viewport-height, 100dvh)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)",overflow:"hidden",background:"var(--bg)"},children:[(0,r.jsx)("div",{className:`sidebar-overlay-backdrop${ec?"":" sidebar-mobile-pending"}`,onClick:()=>es(!1),style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.4)",opacity:+!!el,pointerEvents:el?"auto":"none",transition:"opacity 0.25s ease"}}),(0,r.jsx)("div",{ref:em.panelRef,id:"session-sidebar",className:`sidebar-container${el?" sidebar-open":" sidebar-closed"}${ec?"":" sidebar-mobile-pending"}${em.isResizing?" sidebar-resizing":""}`,style:{"--sidebar-width":`${em.width}px`,background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,paddingTop:"env(safe-area-inset-top)",paddingBottom:"env(safe-area-inset-bottom)",zIndex:200},children:tz}),el&&(0,r.jsx)("div",{...em.separatorProps,"aria-controls":"session-sidebar",className:`panel-resize-handle sidebar-resize-handle${em.isResizing?" is-resizing":""}`,"data-resize-handle":"sidebar",title:`${T("layout.resizeSidebar")}: ${T("layout.resizeHint")}`}),(0,r.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[(0,r.jsxs)("div",{ref:ej,style:{display:"flex",alignItems:"center",flexShrink:0,borderBottom:"1px solid var(--border)",height:"calc(36px + env(safe-area-inset-top))",paddingTop:"env(safe-area-inset-top)",background:"var(--bg-panel)"},children:[(0,r.jsx)("button",{onClick:e2,title:el?T("sidebar.hide"):T("sidebar.show"),"aria-label":el?T("sidebar.hide"):T("sidebar.show"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:el?(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,r.jsx)("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}):(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,r.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,r.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),(0,r.jsx)("button",{onClick:e=>{let t=e.currentTarget.getBoundingClientRect();j({x:t.left+t.width/2,y:t.top+t.height/2})},title:w?T("theme.light"):T("theme.dark"),"aria-label":w?T("theme.light"):T("theme.dark"),"aria-pressed":w,style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"none",border:"none",borderRight:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--text-muted)"},children:w?(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,r.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,r.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,r.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,r.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,r.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,r.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,r.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,r.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),(0,r.jsx)("button",{ref:eS,type:"button",onClick:()=>e0("language"),title:T("common.language"),"aria-label":T("common.language"),"aria-haspopup":"menu","aria-expanded":"language"===eZ,"aria-pressed":"language"===eZ,style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"language"===eZ?"var(--bg-selected)":"none",border:"none",borderRight:"1px solid var(--border)",color:"language"===eZ?"var(--text)":"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="language"===eZ?"var(--text)":"var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"m5 8 6 6"}),(0,r.jsx)("path",{d:"m4 14 6-6 2-3"}),(0,r.jsx)("path",{d:"M2 5h12"}),(0,r.jsx)("path",{d:"M7 2h1"}),(0,r.jsx)("path",{d:"m22 22-5-10-5 10"}),(0,r.jsx)("path",{d:"M14 18h6"})]})}),tC&&X?.requiresTrust&&!X.trusted&&(0,r.jsxs)("button",{type:"button",onClick:()=>{eo(null),et(!0)},title:T("trust.resourcesNotLoaded"),"aria-label":T("trust.resourcesNotLoaded"),style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:R?"0 10px":"0 12px",background:"none",border:"none",borderRight:"1px solid var(--border)",color:"#d97706",cursor:"pointer",flexShrink:0,fontSize:11,whiteSpace:"nowrap"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z"}),(0,r.jsx)("path",{d:"M12 8v4"}),(0,r.jsx)("path",{d:"M12 16h.01"})]}),!R&&(0,r.jsx)("span",{children:T("trust.resourcesNotLoaded")})]}),tC&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"stretch",height:"100%"},children:[(0,r.jsxs)("button",{onClick:tj,disabled:!I,title:I?T("history.full"):T("history.unsaved"),"aria-label":T("history.full"),style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderTop:"2px solid transparent",borderRight:"1px solid var(--border)",color:I?"var(--text-muted)":"var(--text-dim)",cursor:I?"pointer":"not-allowed",opacity:I?1:.45,flexShrink:0,fontSize:11,whiteSpace:"nowrap",transition:"color 0.1s, background 0.1s, opacity 0.1s"},onMouseEnter:e=>{I&&(e.currentTarget.style.color="var(--text)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{e.currentTarget.style.color=I?"var(--text-muted)":"var(--text-dim)",e.currentTarget.style.background="none"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:I?"var(--text-muted)":"var(--text-dim)",flexShrink:0},children:[(0,r.jsx)("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"}),(0,r.jsx)("path",{d:"M12 7v5l3 2"})]}),!R&&(0,r.jsx)("span",{children:T("history.label")})]}),(e=!!(I&&(eF?.userMessages??I.messageCount)>0),t=!I||!e||"naming"===eN.kind,n="success"===eN.kind,a="error"===eN.kind,d="naming"===eN.kind?T("title.generating"):n?T("title.updated"):a?T("title.failed"):T("title.generate"),c=I?e?a?eN.message:T("title.generateSession"):T("title.noMessages"):T("title.unsaved"),(0,r.jsxs)("button",{type:"button",onClick:()=>void tx(),disabled:t,title:c,"aria-label":d,style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"none",border:"none",borderTop:"2px solid transparent",borderRight:"1px solid var(--border)",color:a?"#dc2626":n?"var(--accent)":t?"var(--text-dim)":"var(--text-muted)",cursor:t?"not-allowed":"pointer",opacity:t&&"naming"!==eN.kind?.45:1,flexShrink:0,fontSize:11,whiteSpace:"nowrap",transition:"color 0.1s, background 0.1s, opacity 0.1s"},onMouseEnter:e=>{t||(e.currentTarget.style.color=a?"#dc2626":"var(--text)",e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{e.currentTarget.style.color=a?"#dc2626":n?"var(--accent)":t?"var(--text-dim)":"var(--text-muted)",e.currentTarget.style.background="none"},children:["naming"===eN.kind?(0,r.jsxs)("svg",{className:"animate-spin",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),(0,r.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):n?(0,r.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"m15 4 5 5L7 22l-5-5Z"}),(0,r.jsx)("path",{d:"m14 5 5 5"}),(0,r.jsx)("path",{d:"M6 4V2M5 3H3M19 19v3M17.5 20.5h3"})]}),!R&&(0,r.jsx)("span",{children:d})]})),(0,r.jsx)(is,{tree:eC,activeLeafId:eM,onLeafChange:eW,inline:!0,compact:R,containerRef:ej,open:"branches"===eZ,onToggle:()=>e0("branches"),hasSession:!0}),(0,r.jsxs)("button",{ref:eP,onClick:()=>e0("system"),title:T("system.prompt"),"aria-label":T("system.prompt"),"aria-pressed":"system"===eZ,style:{display:"flex",alignItems:"center",gap:6,height:"100%",padding:"0 12px",background:"system"===eZ?"var(--bg-selected)":"none",border:"none",borderTop:"system"===eZ?"2px solid var(--accent)":"2px solid transparent",borderRight:"1px solid var(--border)",cursor:"pointer",color:"system"===eZ?"var(--text)":"var(--text-muted)",fontSize:11,whiteSpace:"nowrap",transition:"color 0.1s, background 0.1s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="system"===eZ?"var(--text)":"var(--text-muted)"},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:ez?"var(--accent)":"var(--text-dim)",flexShrink:0},children:[(0,r.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),(0,r.jsx)("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]}),!R&&(0,r.jsx)("span",{children:T("system.label")})]})]}),tC&&(eF||eK)&&(()=>{let e=eF?.tokens,t=eF?.cost??0,n=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),i=t>0?t>=.01?`$${t.toFixed(2)}`:"<$0.01":null,o="var(--text-muted)",l=null;if(eK?.contextWindow){let e=eK.percent;null!==e&&e>90?o="#ef4444":null!==e&&e>70&&(o="rgba(234,179,8,0.95)"),l=null!==e?`${e.toFixed(0)}% / ${n(eK.contextWindow)}`:`? / ${n(eK.contextWindow)}`}let s=[];if(e&&(s.push(`in: ${e.input.toLocaleString(S)}`),s.push(`out: ${e.output.toLocaleString(S)}`),s.push(`cache read: ${e.cacheRead.toLocaleString(S)}`),s.push(`cache write: ${e.cacheWrite.toLocaleString(S)}`),t>0&&s.push(`cost: $${t.toFixed(4)}`)),eK?.contextWindow){let e=eK.percent;s.push(`context: ${null!==e?e.toFixed(1)+"%":"unknown"} of ${eK.contextWindow.toLocaleString()} tokens`)}let a=s.join(" | ");return(0,r.jsxs)("button",{type:"button",onClick:()=>e0("session"),title:a||T("session.title"),"aria-label":T("session.title"),"aria-pressed":"session"===eZ,style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:10,paddingLeft:12,paddingRight:ea?12:48,height:"100%",background:"session"===eZ?"var(--bg-selected)":"none",border:"none",borderTop:"session"===eZ?"2px solid var(--accent)":"2px solid transparent",fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap",cursor:"pointer",fontVariantNumeric:"tabular-nums",transition:"color 0.1s, background 0.1s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color="session"===eZ?"var(--text)":"var(--text-muted)"},children:[R&&(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),!R&&e&&e.input>0&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"8.5",x2:"5",y2:"1.5"}),(0,r.jsx)("polyline",{points:"2 4 5 1.5 8 4"})]}),n(e.input)]}),!R&&e&&e.output>0&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,r.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),n(e.output)]}),!R&&e&&e.cacheRead>0&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M8.5 5a3.5 3.5 0 1 1-1-2.45"}),(0,r.jsx)("polyline",{points:"6.5 1.5 8.5 2.5 7.5 4.5"})]}),n(e.cacheRead)]}),!R&&i&&(0,r.jsx)("span",{style:{display:"flex",alignItems:"center",color:"var(--text)",fontWeight:500},children:i}),l&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:o},children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M1 9 L1 5 Q1 1 5 1 Q9 1 9 5 L9 9"}),(0,r.jsx)("line",{x1:"1",y1:"9",x2:"9",y2:"9"})]}),l]})]})})(),eZ&&eX&&(0,r.jsxs)("div",{style:{position:"fixed",top:eX.top,left:eX.left,width:eX.width,maxHeight:`calc(100dvh - ${eX.top}px)`,overflowY:"auto",zIndex:500},children:["language"===eZ&&(0,r.jsx)("div",{role:"menu","aria-label":T("common.language"),style:{background:"var(--bg-panel)",borderLeft:"1px solid var(--border)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)",overflow:"hidden",padding:4},children:M.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>{C(e.id),eG(null)},role:"menuitemradio","aria-checked":S===e.id,style:{display:"flex",alignItems:"center",width:"100%",height:34,padding:"0 10px",border:"none",borderRadius:4,background:S===e.id?"var(--bg-selected)":"transparent",color:"var(--text)",cursor:"pointer",textAlign:"left",fontSize:12,transition:"background 0.1s"},onMouseEnter:t=>{S!==e.id&&(t.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:t=>{S!==e.id&&(t.currentTarget.style.background="transparent")},children:(0,r.jsx)("span",{children:e.label})},e.id))}),"system"===eZ&&(0,r.jsx)("div",{style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:ez?(0,r.jsx)("div",{style:{maxHeight:"min(600px, 75vh)",overflowY:"auto",padding:"12px 16px",color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",fontFamily:"var(--font-mono)"},children:ez}):""===ez?(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:T("system.empty")}):(0,r.jsx)("div",{style:{padding:"10px 16px",fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:T("system.load")})}),"session"===eZ&&(0,r.jsx)("div",{className:"session-info-popover",style:{background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",boxShadow:"0 10px 28px rgba(0,0,0,0.10)",padding:"12px 16px"},children:eF?(u=[...eF.sessionName?[{label:T("session.name"),value:eF.sessionName,copyField:null}]:[],{label:T("session.file"),value:eF.sessionFile??T("session.inMemory"),copyField:"file"},{label:T("session.id"),value:eF.sessionId,copyField:"id"}],p=[[T("session.user"),eF.userMessages.toLocaleString(S)],[T("session.assistant"),eF.assistantMessages.toLocaleString(S)],[T("session.toolCalls"),eF.toolCalls.toLocaleString(S)],[T("session.toolResults"),eF.toolResults.toLocaleString(S)],[T("session.total"),eF.totalMessages.toLocaleString(S)]],h=[[T("session.input"),eF.tokens.input.toLocaleString(S)],[T("session.output"),eF.tokens.output.toLocaleString(S)],...eF.tokens.cacheRead>0?[[T("session.cacheRead"),eF.tokens.cacheRead.toLocaleString(S)]]:[],...eF.tokens.cacheWrite>0?[[T("session.cacheWrite"),eF.tokens.cacheWrite.toLocaleString(S)]]:[],[T("session.total"),eF.tokens.total.toLocaleString(S)]],g=eK??eF.contextUsage,f=[...eF.cost>0?[[T("session.cost"),`$${eF.cost.toFixed(4)}`]]:[],...g?.contextWindow?[[T("session.context"),`${null!==g.percent?`${g.percent.toFixed(1)}%`:"?"} / ${(x=g.contextWindow)>=1e6?`${(x/1e6).toFixed(1)}M`:x>=1e3?`${(x/1e3).toFixed(0)}k`:String(x)}`]]:[]],m=(e,t,n="left",i=!1)=>(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:e}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:i?"max-content max-content":"auto minmax(0, 1fr)",columnGap:i?14:12,rowGap:4,justifyContent:i?"start":void 0},children:t.map(([t,o])=>(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:t}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:i?"normal":"anywhere",textAlign:n,whiteSpace:"right"===n?"nowrap":"normal"},children:o})]},`${e}:${t}`))})]}),v=(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"var(--text)",marginBottom:6},children:T("session.infoSection")}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",columnGap:12,rowGap:8,alignItems:"start"},children:u.map(e=>{var t,n;let i;return(0,r.jsxs)("div",{style:{display:"contents"},children:[(0,r.jsx)("div",{style:{color:"var(--text-dim)",whiteSpace:"nowrap"},children:e.label}),(0,r.jsx)("div",{style:{color:"var(--text-muted)",minWidth:0,overflowWrap:"anywhere",wordBreak:"break-word",whiteSpace:"normal"},children:e.value}),(0,r.jsx)("div",{children:e.copyField?(t=e.copyField,n=e.value,i=eU===t,(0,r.jsx)("button",{type:"button",title:i?T("session.copied"):T("file"===t?"session.copyFile":"session.copyId"),onClick:()=>eq(t,n),style:{alignSelf:"start",display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,marginTop:-2,color:i?"var(--accent)":"var(--text-dim)",background:"transparent",border:"1px solid var(--border)",borderRadius:4,cursor:"pointer",flex:"0 0 auto",transition:"color 0.12s, border-color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--accent)",e.currentTarget.style.borderColor="var(--accent)",e.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:e=>{e.currentTarget.style.color=i?"var(--accent)":"var(--text-dim)",e.currentTarget.style.borderColor="var(--border)",e.currentTarget.style.background="transparent"},children:i?(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})):null})]},`session-info:${e.label}`)})})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:R?"1fr":"minmax(360px, 1.7fr) minmax(140px, 0.55fr) minmax(190px, 0.75fr)",gap:R?16:24,fontSize:12,lineHeight:1.5,fontFamily:"var(--font-mono)"},children:[v,m(T("session.messages"),p),m(T("session.tokens"),[...h,...f],"right",!0)]})):(0,r.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)",fontStyle:"italic"},children:T("session.load")})})]})]}),(0,r.jsx)("div",{style:{flex:1,overflow:"hidden",position:"relative"},children:tC?(0,r.jsx)(nW,{session:I,newSessionCwd:tS,onAgentEnd:tg,onSessionCreated:th,onSessionForked:tm,modelsRefreshKey:V,chatInputRef:ew,onBranchDataChange:eL,onSystemPromptChange:e$,onSessionStatsChange:eO,onSessionStatsPanelOpen:e1,onContextUsageChange:eY,onOpenFile:tk},A):"validating"===E?(0,r.jsxs)("div",{role:"status",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-muted)",textAlign:"center"},children:[(0,r.jsx)("div",{style:{fontSize:14,color:"var(--text)"},children:T("workspace.opening")}),(0,r.jsx)("div",{style:{maxWidth:"min(720px, 100%)",overflowWrap:"anywhere",fontFamily:"var(--font-mono)",fontSize:12},children:k.requestedCwd})]}):"error"===E?(0,r.jsxs)("div",{role:"alert",style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-muted)",textAlign:"center"},children:[(0,r.jsx)("div",{style:{fontSize:14,color:"#dc2626"},children:T("workspace.unable")}),(0,r.jsx)("div",{style:{maxWidth:"min(720px, 100%)",overflowWrap:"anywhere",fontFamily:"var(--font-mono)",fontSize:12},children:k.requestedCwd}),(0,r.jsx)("div",{style:{maxWidth:720,fontSize:12},children:$})]}):tM?tt?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:15},children:T("workspace.selectSession")}):(0,r.jsxs)("div",{style:{position:"absolute",top:12,left:12,display:"flex",alignItems:"flex-start",gap:8,userSelect:"none",pointerEvents:"none"},children:[(0,r.jsxs)("svg",{width:"44",height:"44",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.7,flexShrink:0},children:[(0,r.jsx)("line",{x1:"20",y1:"12",x2:"4",y2:"12"}),(0,r.jsx)("polyline",{points:"10 6 4 12 10 18"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{fontSize:18,fontWeight:600,color:"var(--text)",marginBottom:8},children:T("workspace.getStarted")}),(0,r.jsxs)("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.8},children:[(0,r.jsx)("span",{style:{color:"var(--text-dim)",marginRight:6},children:"1."}),T("workspace.selectProject"),(0,r.jsx)("br",{}),(0,r.jsx)("span",{style:{color:"var(--text-dim)",marginRight:6},children:"2."}),T("workspace.addModels")]})]})]}):null})]}),(0,r.jsx)("div",{"aria-hidden":"true",className:`right-panel-overlay-backdrop${ea?" is-open":""}`,onClick:()=>ed(!1)}),ea&&(0,r.jsx)("div",{...ev.separatorProps,"aria-controls":"file-panel",className:`panel-resize-handle right-panel-resize-handle${ev.isResizing?" is-resizing":""}`,"data-resize-handle":"right-panel",title:`${T("layout.resizeFilePanel")}: ${T("layout.resizeHint")}`}),(0,r.jsxs)("div",{ref:ev.panelRef,id:"file-panel",className:`right-panel-container${ea?" right-panel-open":" right-panel-closed"}${ev.isResizing?" right-panel-resizing":""}`,style:{"--right-panel-width":`${ev.width}px`,display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",background:"var(--bg)"},children:[(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,height:"calc(36px + env(safe-area-inset-top))",paddingTop:"env(safe-area-inset-top)",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)"},children:(0,r.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,r.jsx)(n2,{tabs:e8,activeTabId:e5??"",onSelectTab:e6,onCloseTab:tw})})}),(0,r.jsx)("div",{style:{flex:1,overflow:"hidden",paddingBottom:"env(safe-area-inset-bottom)"},children:tI?.filePath?(0,r.jsx)(n0,{filePath:tI.filePath,cwd:tt??void 0,sourceSessionId:tI.sourceSessionId,gitRefreshKey:H,initialDisplayMode:tI.initialDisplayMode,onMentionLines:ea?e7:void 0,onOpenFile:e=>tb(e,K(e),{sourceSessionId:tI.sourceSessionId})}):(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12},children:T("files.noneOpen")})})]})]}),(0,r.jsx)("button",{onClick:()=>ed(e=>!e),"aria-controls":"file-panel","aria-expanded":ea,title:ea?T("files.hidePanel"):T("files.showPanel"),"aria-label":ea?T("files.hidePanel"):T("files.showPanel"),style:{position:"fixed",top:"env(safe-area-inset-top)",right:"env(safe-area-inset-right)",zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,padding:0,background:"var(--bg-panel)",border:"none",borderLeft:"1px solid var(--border)",borderBottom:"1px solid var(--border)",color:ea?"var(--text)":"var(--text-muted)",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color="var(--text)"},onMouseLeave:e=>{e.currentTarget.style.color=ea?"var(--text)":"var(--text-muted)"},children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,r.jsx)("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}),U&&(0,r.jsx)(rU,{onClose:()=>{_(!1),q(e=>e+1)}}),ee&&tT&&(0,r.jsx)(ii,{cwd:tT,busy:en,error:ei,onCancel:()=>{en||et(!1)},onConfirm:()=>void tR()}),J&&tT&&(0,r.jsx)(rX,{cwd:tT,onClose:()=>Y(!1)}),Z&&tT&&(0,r.jsx)(ir,{cwd:tT,sessionId:I?.id??null,onClose:()=>G(!1),onReloaded:()=>B(e=>e+1)})]})}},39247:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>c,s:()=>u});var r=n(95155),i=n(12115);let o=new Map;function l(e){if(!e.id.trim())throw Error("Locale id must not be empty");if(o.has(e.id))throw Error(`Locale already registered: ${e.id}`);o.set(e.id,e)}function s(){return[...o.keys()]}l({id:"en",label:"English",messages:{"common.ok":"OK","common.language":"Language","common.models":"Models","common.skills":"Skills","common.plugins":"Plugins","sidebar.hide":"Hide sidebar","sidebar.show":"Show sidebar","theme.light":"Switch to light mode","theme.dark":"Switch to dark mode","history.full":"Full history","history.unsaved":"Full history is available after the session is saved","history.label":"Full history","title.generating":"Generating...","title.updated":"Title updated","title.failed":"Generation failed","title.generate":"Generate title","title.unsaved":"Title generation is available after the session is saved","title.noMessages":"Send a message before naming this session","title.generateSession":"Generate a session title","system.prompt":"System prompt","system.empty":"System prompt is empty (tools are disabled)","system.load":"Send a message to load the system prompt","system.label":"System","session.info":"Session info","session.name":"Name","session.file":"File","session.inMemory":"In-memory","session.id":"ID","session.user":"User","session.assistant":"Assistant","session.toolCalls":"Tool Calls","session.toolResults":"Tool Results","session.total":"Total","session.input":"Input","session.output":"Output","session.cacheRead":"Cache Read","session.cacheWrite":"Cache Write","session.cost":"Cost","session.context":"Context","session.copy":"Copy {value}","session.copied":"Copied","session.title":"Session info","session.load":"Send a message or run /session to load session info","session.infoSection":"Session Info","session.messages":"Messages","session.tokens":"Tokens","session.copyFile":"Copy file path","session.copyId":"Copy session ID","workspace.opening":"Opening workspace...","workspace.unable":"Unable to open workspace","workspace.selectSession":"Select a session from the sidebar","workspace.getStarted":"Get Started","workspace.selectProject":"Select a project directory from the sidebar","workspace.addModels":"Add models via the Models button at the bottom","workspace.stepProject":"Select a project directory from the sidebar","workspace.stepModels":"Add models via the Models button at the bottom","files.hidePanel":"Hide file panel","files.showPanel":"Show file panel","files.noneOpen":"No file open","layout.resizeSidebar":"Resize sidebar","layout.resizeFilePanel":"Resize file panel","layout.resizeHint":"Drag to resize. Double-click or press Enter to reset.","sidebar.new":"New","sidebar.newSessionTitle":"New session in {path}","sidebar.refresh":"Refresh","sidebar.selectProject":"Select project…","sidebar.filterProjects":"Filter projects…","sidebar.noMatchingProjects":"No matching projects","sidebar.useDefaultDirectory":"Use default directory","sidebar.customPath":"Custom path…","directoryPicker.selectDirectory":"Select directory","directoryPicker.goToParent":"Go to parent directory","directoryPicker.directoryPath":"Directory path","directoryPicker.goToDirectory":"Go to directory","directoryPicker.go":"Go","directoryPicker.loadingDirectories":"Loading directories…","directoryPicker.noSubdirectories":"No subdirectories","directoryPicker.openBeforeSelecting":"Open this path before selecting it","directoryPicker.selectCurrentDirectory":"Select current directory","directoryPicker.selectThisFolder":"Select this folder","directoryPicker.noDrives":"No drives found","sidebar.checking":"Checking…","sidebar.open":"Open","sidebar.cancel":"Cancel","sidebar.openRepoRoot":"Open repo root","sidebar.openRepoRootTitle":"Open the repository root to manage worktrees.","sidebar.gitRepoRootOnly":"Git repo root only","sidebar.gitRepoRootOnlyTitle":"Worktrees are available in Git repository roots.","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"Checking worktrees for this directory.","sidebar.filterWorktrees":"Filter worktrees…","sidebar.noMatchingWorktrees":"No matching worktrees","sidebar.switchWorktree":"Switch worktree","sidebar.switchWorktreeTitle":"Switch worktree: {path}","sidebar.main":"main","sidebar.forceRemoveCheckout":"Uncommitted changes. Force remove checkout?","sidebar.force":"Force","sidebar.createWorktreeTitle":"Create a worktree checkout for a branch","sidebar.newWorktree":"New worktree…","sidebar.branchName":"branch name","sidebar.creating":"Creating…","sidebar.create":"Create","sidebar.uploadFilesTitle":"Upload files to project root","sidebar.uploadFiles":"Upload files","sidebar.refreshExplorer":"Refresh explorer","sidebar.changedFiles":"{count} changed files","sidebar.loading":"Loading...","sidebar.noSessions":"No sessions found","sidebar.agentRunning":"Agent running…","sidebar.newActivity":"New activity","sidebar.newSessionActivity":"New session activity","sidebar.deleteSession":"Delete {title}?","sidebar.rename":"Rename","sidebar.delete":"Delete","sidebar.deleteWithShiftClick":"Delete (Shift+click to delete without confirmation)","sidebar.expandForks":"Expand forks","sidebar.collapseForks":"Collapse forks","sidebar.messagesCount":"{count} msgs","sidebar.worktreePath":"Worktree: {path}","sidebar.removeWorktreeTitle":"Remove worktree checkout {path}; the branch is kept","files.modified":"Modified","files.added":"Added","files.deleted":"Deleted","files.renamed":"Renamed","files.untracked":"Untracked","files.conflict":"Conflict","files.newlyUploaded":"Newly uploaded","files.containsChangedFiles":"Contains changed files","files.insertPath":"Insert path into chat","files.mention":"mention","files.download":"Download file","files.dismissError":"Dismiss error","files.addUploadedFile":"Add uploaded file to chat","files.addAllUploadedFiles":"Add all uploaded files to chat","files.dismissUploadResults":"Dismiss upload results","files.loading":"Loading files...","files.noFiles":"No files found","files.explorer":"Explorer","files.changedCount":"{count} files","files.changeStats":"{count} changed files, {additions} lines added, {deletions} lines deleted","files.conflictSummary":"{count} file{countSuffix} already exist: {files}","files.cannotReplace":"Cannot replace: {files}","files.replace":"Replace","files.skipExisting":"Skip existing","files.cancel":"Cancel","files.checking":"Checking files","files.uploading":"Uploading, {progress}%","files.rename":"Rename","files.moveToTrash":"Move to Trash","files.deleteFileWarning":'Move "{name}" to the trash? It cannot be undone.',"files.deleteFolderWarning":'Move folder "{name}" and all its contents to the trash? It cannot be undone.',"files.deleting":"Moving to trash...","files.newFile":"New File","files.newFolder":"New Folder","files.copyPath":"Copy Path","files.pathCopied":"Path copied to clipboard","files.nameExists":"A file or folder with that name already exists","files.invalidName":"Invalid file name","files.renameError":"Failed to rename","files.createError":"Failed to create","files.moveError":"Failed to move","files.copyFailed":"Failed to copy path to clipboard","chat.loadingSession":"Loading session...","chat.runningTool":"Running tool...","chat.runningNamedTool":"Running {name}...","chat.runningTools":"Running {names}...","chat.runningToolsMore":"Running {names} (+{count})...","chat.waitingModel":"Waiting for model...","chat.runningCommand":"Running command...","chat.thinking":"Thinking...","chat.processDetails":"Process details","chat.message":"message","chat.messages":"messages","chat.toolCall":"tool call","chat.toolCalls":"tool calls","chat.collapseProcess":"Collapse process details","chat.expandProcess":"Expand process details","chat.loadEarlier":"Scroll up to load earlier messages ({count} hidden)","chat.extensionRequest":"extension request","chat.cancel":"Cancel","chat.confirm":"Confirm","chat.submit":"Submit","chat.extensionInput":"Extension terminal input","chat.extensionPanel":"Extension panel","chat.close":"Close","chat.queued":"Queued \xb7 {count}","chat.recall":"Recall to input","chat.recallTitle":"Remove all queued messages and put them back into the input box for editing","chat.retrying":"Retrying ({attempt}/{max})…","chat.loadingCommands":"Loading commands...","chat.slashCommands":"Slash commands \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"No extension, prompt, or skill commands found","chat.match":"1 match","chat.matches":"{count} matches","chat.command":"1 command","chat.commands":"{count} commands","chat.loadingFiles":"Loading files...","chat.files":"Files \xb7 {label}{hint}","chat.searching":"Searching…","chat.noMatchingFiles":"No matching files","chat.searchingAll":" \xb7 searching all files…","chat.indexTruncated":" \xb7 index truncated","chat.steerPlaceholder":"Steer now / queue follow-up...","chat.agentPlaceholder":"Agent is running…","chat.messagePlaceholder":"Message… Type / for commands, @ for files","chat.steer":"Steer","chat.followUp":"Follow-up","chat.send":"Send","chat.attachImage":"Attach image","chat.filterModels":"Filter models…","chat.noMatchingModels":"No matching models","chat.moreControls":"More controls","chat.collapseControls":"Collapse controls","chat.shell":"Shell","chat.outputLocal":"output stays local","chat.outputModel":"output sent to model","chat.noTools":"No tools, read-only","chat.builtInTools":"{count} built-in tools","chat.allBuiltInTools":"All built-in tools","chat.changeReasoning":"Change reasoning level: {level}","chat.changeReasoningLabel":"Change reasoning level","chat.changeToolPreset":"Change tool preset","chat.stopCompaction":"Stop compaction","chat.compactContext":"Compact context","chat.compacting":"Compacting…","chat.compact":"Compact","chat.stopAgent":"Stop agent","chat.stop":"Stop","chat.disableSound":"Disable completion sound","chat.enableSound":"Enable completion sound","chat.thinkingUseDefault":"Use pi default","chat.thinkingOff":"Reasoning off","chat.thinkingMinimal":"Minimal reasoning","chat.thinkingLow":"Low reasoning","chat.thinkingMedium":"Medium reasoning","chat.thinkingHigh":"High reasoning","chat.thinkingXhigh":"Extra-high reasoning","chat.thinkingMax":"Max reasoning","chat.builtIn":"Built-in","chat.extensions":"Extensions","chat.prompts":"Prompts","chat.skills":"Skills","chat.dormant":"dormant","chat.commandCompact":"Compress context, optionally with instructions","chat.commandReload":"Reload extensions, skills, prompts, and tools","chat.commandName":"Set the session display name","chat.commandSession":"Show session message, token, and cost stats","chat.commandCopy":"Copy the last assistant message","chat.compacted":"Compacted","chat.tokensSaved":"{saved} saved","i18n.close":"Close","i18n.copy":"Copy","i18n.copied":"Copied","i18n.cancel":"Cancel","i18n.save":"Save","i18n.saving":"Saving…","i18n.saved":"Saved","i18n.remove":"Remove","i18n.removing":"Removing…","i18n.delete":"Delete","i18n.loading":"Loading...","i18n.search":"Search","i18n.refresh":"Refresh","i18n.update":"Update","i18n.updating":"Updating...","i18n.check":"Check","i18n.checking":"Checking...","i18n.install":"Install","i18n.installing":"Installing...","i18n.noResults":"No results","i18n.searchProviders":"Search providers…","i18n.noProviders":"No providers match","i18n.newModel":"new model","i18n.addProvider":"Add provider","i18n.selectProviderModel":"Select a provider or model","i18n.visibleInPrompt":"Visible in model prompt — click to disable","i18n.hiddenFromPrompt":"Hidden from model prompt — click to enable","i18n.dormant":"Dormant","i18n.hiddenButInvocable":"Hidden from model, still manually invocable","i18n.skillSearchPlaceholder":"e.g. react, testing, deploy","i18n.searching":"Searching…","i18n.noSkills":"No skills found","i18n.checkUpdates":"Check updates","i18n.updates":"updates","i18n.noResolvedResources":"No resolved resources","i18n.enablePackage":"Enable package","i18n.disablePackage":"Disable package","i18n.filtered":"filtered","i18n.openSessionToReload":"Open a session to reload","i18n.notFound":"Not found","i18n.noPlugins":"No plugins configured","trust.resourcesNotLoaded":"Restricted mode","trust.trustProject":"Trust project","trust.trusting":"Trusting...","trust.cancel":"Cancel","trust.dialogTitle":"Trust this project?","trust.dialogBody":"Project resources can run local code. Trust only projects whose contents you know.","trust.skillsNotLoaded":"Project skills are not loaded because this project is not trusted.","trust.pluginsNotLoaded":"Project plugins are not loaded because this project is not trusted.","trust.projectScopeUnavailable":"Project installs are unavailable while project resources are not loaded.","i18n.creatingSession":"Creating new session…","i18n.creating":"Creating…","i18n.subscription":"Subscription","i18n.subscriptions":"Subscriptions","i18n.customEndpoint":"Custom endpoint format","i18n.noChanges":"No changes","i18n.branches":"Branches","i18n.noActiveSession":"No active session","i18n.noBranches":"This session has no branches","i18n.source":"Source","i18n.preview":"Preview","i18n.diff":"Diff","i18n.downloadFile":"Download file","i18n.liveSync":"Live sync active","i18n.notWatching":"Not watching","i18n.fileViewMode":"File view mode","i18n.compareHead":"Compare working tree with HEAD","i18n.mentionSelectedLines":"Mention selected lines","i18n.disableWrap":"Disable word wrap","i18n.enableWrap":"Enable word wrap","i18n.htmlPreview":"HTML preview","i18n.previewFile":"Preview {file}","i18n.invalidMermaid":"Invalid Mermaid diagram","i18n.renderingMermaid":"Rendering Mermaid diagram","i18n.previewAfterStreaming":"Preview available after streaming","i18n.showMermaidSource":"Show Mermaid source","i18n.previewMermaid":"Preview Mermaid diagram","i18n.openMermaidViewer":"Open diagram viewer","i18n.mermaidViewer":"Mermaid diagram viewer","i18n.mermaidDiagram":"Mermaid diagram","i18n.zoomOut":"Zoom out","i18n.zoomIn":"Zoom in","i18n.fitToWidth":"Fit to width","models.discoveryFetching":"Importing models…","models.discoveryFetch":"Import models…","models.discoveryFilterPlaceholder":"Filter {count} models…","models.discoveryFilter":"Filter upstream models","models.discoverySelectShown":"Select shown","models.discoveryNoMatches":"No matching models.","models.discoveryAdded":"added","models.discoveryShowing":"Showing first {shown} of {total}","models.discoveryFetched":"{count} models fetched","models.discoveryAddSelected":"Add selected","models.discoveryAddSelectedCount":"Add selected ({count})","models.catalogSource":"source: models.dev ↗","models.catalogFilling":"Filling details…","models.catalogFill":"Fill model details","models.catalogFilled":"{count} fields filled","models.catalogNoEmptyFields":"No empty fields to fill","models.catalogNoExactMatch":"No exact models.dev match","models.catalogPriceProvider":"Price matched Provider {provider}","models.catalogPriceBaseUrl":"Price matched Base URL to {provider}","models.catalogPriceConsensus":"Price agreed by {support}/{total} records","models.catalogPriceUnreliable":"No reliable price found","models.catalogUndo":"Undo","i18n.testingModel":"Testing model connection...","i18n.connected":"Connected","i18n.failed":"Failed","i18n.test":"Test","i18n.testConnection":"Test model connection","i18n.provider":"Provider","i18n.model":"Model","i18n.providerName":"Provider name","i18n.rename":"Rename","i18n.default":"Default","i18n.disabled":"Disabled","i18n.noResources":"No resources","i18n.unknown":"Unknown","i18n.installedVersion":"installed {version}","i18n.configuredVersion":"configured {version}","i18n.extensions":"Extensions","i18n.prompts":"Prompts","i18n.themes":"Themes","i18n.resourceCount":"{count} {label}","i18n.extensionShort":"ext","i18n.skillShort":"skills","i18n.promptShort":"prompts","i18n.themeShort":"themes","i18n.custom":"Custom","i18n.clearAll":"clear all","i18n.connectedSuccessfully":"Connected successfully.","i18n.notConnected":"not connected","i18n.configured":"configured","i18n.notConfigured":"not configured","i18n.openingBrowser":"Opening browser…","i18n.submit":"Submit","i18n.login":"Login","i18n.relogin":"Re-login","i18n.disconnect":"Disconnect","i18n.networkError":"Network error","i18n.continuing":"Continuing…","i18n.skills":"Skills","i18n.plugins":"Plugins","i18n.addSkill":"Add skill","i18n.addPlugin":"Add plugin","i18n.selectSkill":"Select a skill","i18n.selectPackage":"Select a package","i18n.updateAvailable":"Update available","i18n.upToDate":"Up to date","i18n.automaticChecksUnavailable":"Automatic checks unavailable","i18n.checkFailed":"Check failed","i18n.installed":"Installed","i18n.status":"Status","i18n.version":"Version","i18n.package":"Package","i18n.resources":"Resources","i18n.installedPath":"Installed path","i18n.cwd":"CWD","i18n.resolvedResources":"Resolved Resources","i18n.reloadSession":"Reload session","i18n.reloading":"Reloading...","i18n.packageRemoved":"Package removed.","i18n.packageInstalled":"Package installed.","i18n.packageUpdated":"Package updated.","i18n.packageDisabled":"Package disabled.","i18n.packageEnabled":"Package enabled.","i18n.sessionReloaded":"Session reloaded.","i18n.thinking":"Thinking","i18n.loadingThinking":"Loading thinking...","i18n.copyMessage":"Copy message","i18n.editFromHere":"Edit from here","i18n.editFromHereTitle":"Edit from here — branches within this session","i18n.newSession":"New session","i18n.newSessionTitle":"New session — creates an independent copy from here","i18n.estimatedTokens":"Estimated token count while streaming","i18n.noOutput":"(no output)","i18n.noSummary":"(no summary)","i18n.conversationCompacted":"Conversation compacted","i18n.compactionDescription":"The conversation history before this point was compacted into the following summary:","i18n.fileContext":"File context: {details}","i18n.readFiles":"Read files","i18n.modifiedFiles":"Modified files","i18n.hiddenExtensionMessage":"hidden extension message","i18n.noMessage":"(no message)","i18n.showExtensionMessage":"Show extension message","i18n.collapse":"Collapse","i18n.expand":"Expand","i18n.hideDetails":"Hide details","i18n.showDetails":"Show details","i18n.thinkingUnavailable":"Thinking content unavailable","i18n.before":"Before","i18n.after":"After"}}),l({id:"zh-CN",label:"简体中文",messages:{"common.ok":"确定","common.language":"语言","common.models":"模型","common.skills":"技能","common.plugins":"插件","sidebar.hide":"隐藏侧边栏","sidebar.show":"显示侧边栏","theme.light":"切换到浅色模式","theme.dark":"切换到深色模式","history.full":"完整历史","history.unsaved":"会话保存后才能查看完整历史","history.label":"完整历史","title.generating":"正在生成...","title.updated":"标题已更新","title.failed":"生成失败","title.generate":"生成标题","title.unsaved":"会话保存后才能生成标题","title.noMessages":"请先发送消息,再为会话命名","title.generateSession":"生成会话标题","system.prompt":"系统提示词","system.empty":"系统提示词为空(工具已禁用)","system.load":"发送消息以加载系统提示词","system.label":"系统","session.info":"会话信息","session.name":"名称","session.file":"文件","session.inMemory":"内存中","session.id":"ID","session.user":"用户","session.assistant":"助手","session.toolCalls":"工具调用","session.toolResults":"工具结果","session.total":"总计","session.input":"输入","session.output":"输出","session.cacheRead":"缓存读取","session.cacheWrite":"缓存写入","session.cost":"费用","session.context":"上下文","session.copy":"复制{value}","session.copied":"已复制","session.title":"会话信息","session.load":"发送消息或运行 /session 以加载会话信息","session.infoSection":"会话信息","session.messages":"消息","session.tokens":"Token","session.copyFile":"复制文件路径","session.copyId":"复制会话 ID","workspace.opening":"正在打开工作区...","workspace.unable":"无法打开工作区","workspace.selectSession":"从侧边栏选择一个会话","workspace.getStarted":"开始使用","workspace.selectProject":"从侧边栏选择项目目录","workspace.addModels":"点击底部的“模型”按钮添加模型","workspace.stepProject":"从侧边栏选择项目目录","workspace.stepModels":"点击底部的“模型”按钮添加模型","files.hidePanel":"隐藏文件面板","files.showPanel":"显示文件面板","files.noneOpen":"没有打开的文件","layout.resizeSidebar":"调整侧边栏宽度","layout.resizeFilePanel":"调整文件面板宽度","layout.resizeHint":"拖动调整宽度。双击或按 Enter 恢复默认值。","sidebar.new":"新建","sidebar.newSessionTitle":"在 {path} 中新建会话","sidebar.refresh":"刷新","sidebar.selectProject":"选择项目…","sidebar.filterProjects":"筛选项目…","sidebar.noMatchingProjects":"没有匹配的项目","sidebar.useDefaultDirectory":"使用默认目录","sidebar.customPath":"自定义路径…","directoryPicker.selectDirectory":"选择目录","directoryPicker.goToParent":"转到上级目录","directoryPicker.directoryPath":"目录路径","directoryPicker.goToDirectory":"转到目录","directoryPicker.go":"转到","directoryPicker.loadingDirectories":"正在加载目录…","directoryPicker.noSubdirectories":"没有子目录","directoryPicker.openBeforeSelecting":"选择前请先打开此路径","directoryPicker.selectCurrentDirectory":"选择当前目录","directoryPicker.selectThisFolder":"选择此文件夹","directoryPicker.noDrives":"未找到盘符","sidebar.checking":"检查中…","sidebar.open":"打开","sidebar.cancel":"取消","sidebar.openRepoRoot":"打开仓库根目录","sidebar.openRepoRootTitle":"打开仓库根目录以管理 worktree。","sidebar.gitRepoRootOnly":"仅 Git 仓库根目录","sidebar.gitRepoRootOnlyTitle":"只能在 Git 仓库根目录使用 worktree。","sidebar.worktrees":"Worktrees...","sidebar.checkingWorktrees":"正在检查此目录的 worktree。","sidebar.filterWorktrees":"筛选 worktree…","sidebar.noMatchingWorktrees":"没有匹配的 worktree","sidebar.switchWorktree":"切换 worktree","sidebar.switchWorktreeTitle":"切换 worktree:{path}","sidebar.main":"主分支","sidebar.forceRemoveCheckout":"存在未提交的更改。强制移除 checkout?","sidebar.force":"强制移除","sidebar.createWorktreeTitle":"为分支创建 worktree checkout","sidebar.newWorktree":"新建 worktree…","sidebar.branchName":"分支名称","sidebar.creating":"创建中…","sidebar.create":"创建","sidebar.uploadFilesTitle":"将文件上传到项目根目录","sidebar.uploadFiles":"上传文件","sidebar.refreshExplorer":"刷新文件浏览器","sidebar.changedFiles":"{count} 个变更文件","sidebar.loading":"加载中...","sidebar.noSessions":"未找到会话","sidebar.agentRunning":"Agent 运行中…","sidebar.newActivity":"有新活动","sidebar.newSessionActivity":"会话有新活动","sidebar.deleteSession":"删除 {title}?","sidebar.rename":"重命名","sidebar.delete":"删除","sidebar.deleteWithShiftClick":"删除(按住 Shift 点击可跳过确认)","sidebar.expandForks":"展开分叉","sidebar.collapseForks":"折叠分叉","sidebar.messagesCount":"{count} 条消息","sidebar.worktreePath":"Worktree:{path}","sidebar.removeWorktreeTitle":"移除 worktree checkout {path};保留分支","files.modified":"已修改","files.added":"已添加","files.deleted":"已删除","files.renamed":"已重命名","files.untracked":"未跟踪","files.conflict":"冲突","files.newlyUploaded":"刚上传","files.containsChangedFiles":"包含已更改文件","files.insertPath":"将路径插入聊天","files.mention":"提及","files.download":"下载文件","files.dismissError":"关闭错误","files.addUploadedFile":"将上传的文件添加到聊天","files.addAllUploadedFiles":"将所有上传的文件添加到聊天","files.dismissUploadResults":"关闭上传结果","files.loading":"正在加载文件...","files.noFiles":"未找到文件","files.explorer":"文件浏览器","files.changedCount":"{count} 个文件","files.changeStats":"{count} 个变更文件,新增 {additions} 行,删除 {deletions} 行","files.conflictSummary":"已有 {count} 个文件:{files}","files.cannotReplace":"无法替换:{files}","files.replace":"替换","files.skipExisting":"跳过已有文件","files.cancel":"取消","files.checking":"正在检查文件","files.uploading":"正在上传,{progress}%","files.rename":"重命名","files.moveToTrash":"移到回收站","files.deleteFileWarning":"要将「{name}」移到回收站吗?此操作无法撤销。","files.deleteFolderWarning":"要将文件夹「{name}」及其所有内容移到回收站吗?此操作无法撤销。","files.deleting":"正在移到回收站…","files.newFile":"新建文件","files.newFolder":"新建文件夹","files.copyPath":"复制路径","files.pathCopied":"路径已复制到剪贴板","files.nameExists":"已存在同名文件或文件夹","files.invalidName":"文件名无效","files.renameError":"重命名失败","files.createError":"新建失败","files.moveError":"移动失败","files.copyFailed":"复制路径到剪贴板失败","chat.loadingSession":"正在加载会话...","chat.runningTool":"正在运行工具...","chat.runningNamedTool":"正在运行 {name}...","chat.runningTools":"正在运行 {names}...","chat.runningToolsMore":"正在运行 {names}(另有 {count} 个)...","chat.waitingModel":"正在等待模型...","chat.runningCommand":"正在运行命令...","chat.thinking":"正在思考...","chat.processDetails":"处理详情","chat.message":"条消息","chat.messages":"条消息","chat.toolCall":"次工具调用","chat.toolCalls":"次工具调用","chat.collapseProcess":"收起处理详情","chat.expandProcess":"展开处理详情","chat.loadEarlier":"向上滚动以加载更早的消息(隐藏 {count} 条)","chat.extensionRequest":"扩展请求","chat.cancel":"取消","chat.confirm":"确认","chat.submit":"提交","chat.extensionInput":"扩展终端输入","chat.extensionPanel":"扩展面板","chat.close":"关闭","chat.queued":"已排队 \xb7 {count}","chat.recall":"移回输入框","chat.recallTitle":"移除所有排队消息并将其放回输入框编辑","chat.retrying":"正在重试({attempt}/{max})…","chat.loadingCommands":"正在加载命令...","chat.slashCommands":"斜杠命令 \xb7 {label}","chat.tabEnter":"Tab / Enter","chat.noCommands":"未找到扩展、提示词或技能命令","chat.match":"1 个匹配项","chat.matches":"{count} 个匹配项","chat.command":"1 个命令","chat.commands":"{count} 个命令","chat.loadingFiles":"正在加载文件...","chat.files":"文件 \xb7 {label}{hint}","chat.searching":"搜索中…","chat.noMatchingFiles":"未找到匹配的文件","chat.searchingAll":" \xb7 正在搜索所有文件…","chat.indexTruncated":" \xb7 索引不完整","chat.steerPlaceholder":"立即引导 / 排队后续消息...","chat.agentPlaceholder":"Agent 运行中…","chat.messagePlaceholder":"消息…输入 / 使用命令,输入 @ 查找文件","chat.steer":"引导","chat.followUp":"后续消息","chat.send":"发送","chat.attachImage":"附加图片","chat.filterModels":"筛选模型…","chat.noMatchingModels":"没有匹配的模型","chat.moreControls":"更多控件","chat.collapseControls":"收起控件","chat.shell":"Shell","chat.outputLocal":"输出保留在本地","chat.outputModel":"输出发送给模型","chat.noTools":"不使用工具,仅只读","chat.builtInTools":"{count} 个内置工具","chat.allBuiltInTools":"全部内置工具","chat.changeReasoning":"更改推理级别:{level}","chat.changeReasoningLabel":"更改推理级别","chat.changeToolPreset":"更改工具预设","chat.stopCompaction":"停止压缩","chat.compactContext":"压缩上下文","chat.compacting":"正在压缩…","chat.compact":"压缩","chat.stopAgent":"停止 Agent","chat.stop":"停止","chat.disableSound":"关闭完成提示音","chat.enableSound":"开启完成提示音","chat.thinkingUseDefault":"使用 pi 默认设置","chat.thinkingOff":"关闭推理","chat.thinkingMinimal":"最低限度推理","chat.thinkingLow":"低强度推理","chat.thinkingMedium":"中等强度推理","chat.thinkingHigh":"高强度推理","chat.thinkingXhigh":"超高强度推理","chat.thinkingMax":"最高强度推理","chat.builtIn":"内置","chat.extensions":"扩展","chat.prompts":"提示词","chat.skills":"技能","chat.dormant":"休眠","chat.commandCompact":"压缩上下文,可选附加说明","chat.commandReload":"重新加载扩展、技能、提示词和工具","chat.commandName":"设置会话显示名称","chat.commandSession":"显示会话消息、Token 和费用统计","chat.commandCopy":"复制最后一条助手消息","chat.compacted":"已压缩","chat.tokensSaved":"节省 {saved}","i18n.close":"关闭","i18n.copy":"复制","i18n.copied":"已复制","i18n.cancel":"取消","i18n.save":"保存","i18n.saving":"保存中…","i18n.saved":"已保存","i18n.remove":"移除","i18n.removing":"移除中…","i18n.delete":"删除","i18n.loading":"加载中...","i18n.search":"搜索","i18n.refresh":"刷新","i18n.update":"更新","i18n.updating":"更新中...","i18n.check":"检查","i18n.checking":"检查中...","i18n.install":"安装","i18n.installing":"安装中...","i18n.noResults":"没有结果","i18n.searchProviders":"搜索 Provider…","i18n.noProviders":"没有匹配的 Provider","i18n.newModel":"新模型","i18n.addProvider":"添加 Provider","i18n.selectProviderModel":"选择 Provider 或模型","i18n.visibleInPrompt":"在模型提示词中可见,点击以禁用","i18n.hiddenFromPrompt":"在模型提示词中隐藏,点击以启用","i18n.dormant":"休眠","i18n.hiddenButInvocable":"对模型隐藏,仍可手动调用","i18n.skillSearchPlaceholder":"例如 react、testing、deploy","i18n.searching":"搜索中…","i18n.noSkills":"未找到技能","i18n.checkUpdates":"检查更新","i18n.updates":"项更新","i18n.noResolvedResources":"没有已解析资源","i18n.enablePackage":"启用包","i18n.disablePackage":"禁用包","i18n.filtered":"已筛选","i18n.openSessionToReload":"打开会话后才能重新加载","i18n.notFound":"未找到","i18n.noPlugins":"未配置插件","trust.resourcesNotLoaded":"受限模式","trust.trustProject":"信任项目","trust.trusting":"正在信任...","trust.cancel":"取消","trust.dialogTitle":"信任此项目?","trust.dialogBody":"项目资源可以运行本地代码。请仅信任你了解其内容的项目。","trust.skillsNotLoaded":"此项目尚未受信任,项目技能未加载。","trust.pluginsNotLoaded":"此项目尚未受信任,项目插件未加载。","trust.projectScopeUnavailable":"项目资源未加载时,无法安装到项目范围。","i18n.creatingSession":"正在创建新会话…","i18n.creating":"创建中…","i18n.subscription":"订阅","i18n.subscriptions":"订阅服务","i18n.customEndpoint":"自定义端点格式","i18n.noChanges":"没有更改","i18n.branches":"分支","i18n.noActiveSession":"没有活动会话","i18n.noBranches":"此会话没有分支","i18n.source":"源代码","i18n.preview":"预览","i18n.diff":"Diff","i18n.downloadFile":"下载文件","i18n.liveSync":"实时同步已启用","i18n.notWatching":"未监视","i18n.fileViewMode":"文件视图模式","i18n.compareHead":"比较工作区与 HEAD","i18n.mentionSelectedLines":"提及所选行","i18n.disableWrap":"禁用自动换行","i18n.enableWrap":"启用自动换行","i18n.htmlPreview":"HTML 预览","i18n.previewFile":"预览 {file}","i18n.invalidMermaid":"Mermaid 图表无效","i18n.renderingMermaid":"正在渲染 Mermaid 图表","i18n.previewAfterStreaming":"流式输出完成后可预览","i18n.showMermaidSource":"显示 Mermaid 源码","i18n.previewMermaid":"预览 Mermaid 图表","i18n.openMermaidViewer":"打开图表查看器","i18n.mermaidViewer":"Mermaid 图表查看器","i18n.mermaidDiagram":"Mermaid 图表","i18n.zoomOut":"缩小","i18n.zoomIn":"放大","i18n.fitToWidth":"适应宽度","models.discoveryFetching":"正在导入模型…","models.discoveryFetch":"导入模型…","models.discoveryFilterPlaceholder":"筛选 {count} 个模型…","models.discoveryFilter":"筛选上游模型","models.discoverySelectShown":"选择当前结果","models.discoveryNoMatches":"没有匹配的模型。","models.discoveryAdded":"已添加","models.discoveryShowing":"显示前 {shown} 个,共 {total} 个","models.discoveryFetched":"已获取 {count} 个模型","models.discoveryAddSelected":"添加所选模型","models.discoveryAddSelectedCount":"添加所选模型({count})","models.catalogSource":"来源:models.dev ↗","models.catalogFilling":"正在填入模型信息…","models.catalogFill":"填入模型信息","models.catalogFilled":"已填入 {count} 个字段","models.catalogNoEmptyFields":"没有需要填入的空字段","models.catalogNoExactMatch":"models.dev 中没有精确匹配","models.catalogPriceProvider":"价格已匹配 Provider {provider}","models.catalogPriceBaseUrl":"价格已按 Base URL 匹配 {provider}","models.catalogPriceConsensus":"价格得到 {support}/{total} 条记录支持","models.catalogPriceUnreliable":"未找到可靠价格","models.catalogUndo":"撤销","i18n.testingModel":"正在测试模型连接...","i18n.connected":"已连接","i18n.failed":"失败","i18n.test":"测试","i18n.testConnection":"测试模型连接","i18n.provider":"Provider","i18n.model":"模型","i18n.providerName":"Provider 名称","i18n.rename":"重命名","i18n.default":"默认","i18n.disabled":"已禁用","i18n.noResources":"没有资源","i18n.unknown":"未知","i18n.installedVersion":"已安装 {version}","i18n.configuredVersion":"已配置 {version}","i18n.extensions":"扩展","i18n.prompts":"提示词","i18n.themes":"主题","i18n.resourceCount":"{count}{label}","i18n.extensionShort":"扩展","i18n.skillShort":"技能","i18n.promptShort":"提示词","i18n.themeShort":"主题","i18n.custom":"自定义","i18n.clearAll":"清除全部","i18n.connectedSuccessfully":"连接成功。","i18n.notConnected":"未连接","i18n.configured":"已配置","i18n.notConfigured":"未配置","i18n.openingBrowser":"正在打开浏览器…","i18n.submit":"提交","i18n.login":"登录","i18n.relogin":"重新登录","i18n.disconnect":"断开连接","i18n.networkError":"网络错误","i18n.continuing":"继续中…","i18n.skills":"技能","i18n.plugins":"插件","i18n.addSkill":"添加技能","i18n.addPlugin":"添加插件","i18n.selectSkill":"选择技能","i18n.selectPackage":"选择包","i18n.updateAvailable":"有可用更新","i18n.upToDate":"已是最新","i18n.automaticChecksUnavailable":"自动检查不可用","i18n.checkFailed":"检查失败","i18n.installed":"已安装","i18n.status":"状态","i18n.version":"版本","i18n.package":"包","i18n.resources":"资源","i18n.installedPath":"安装路径","i18n.cwd":"CWD","i18n.resolvedResources":"已解析资源","i18n.reloadSession":"重新加载会话","i18n.reloading":"重新加载中...","i18n.packageRemoved":"包已移除。","i18n.packageInstalled":"包已安装。","i18n.packageUpdated":"包已更新。","i18n.packageDisabled":"包已禁用。","i18n.packageEnabled":"包已启用。","i18n.sessionReloaded":"会话已重新加载。","i18n.thinking":"思考","i18n.loadingThinking":"正在加载思考内容...","i18n.copyMessage":"复制消息","i18n.editFromHere":"从此处编辑","i18n.editFromHereTitle":"从此处编辑,此会话内创建分支","i18n.newSession":"新会话","i18n.newSessionTitle":"新会话,从此处创建独立副本","i18n.estimatedTokens":"流式输出期间的估算 Token 数","i18n.noOutput":"(无输出)","i18n.noSummary":"(无摘要)","i18n.conversationCompacted":"会话已压缩","i18n.compactionDescription":"此处之前的会话历史已压缩为以下摘要:","i18n.fileContext":"文件上下文:{details}","i18n.readFiles":"读取的文件","i18n.modifiedFiles":"修改的文件","i18n.hiddenExtensionMessage":"隐藏的扩展消息","i18n.noMessage":"(无消息)","i18n.showExtensionMessage":"显示扩展消息","i18n.collapse":"收起","i18n.expand":"展开","i18n.hideDetails":"隐藏详情","i18n.showDetails":"显示详情","i18n.thinkingUnavailable":"思考内容不可用","i18n.before":"之前","i18n.after":"之后"}});let a="pi-locale",d=(0,i.createContext)(null);function c({children:e}){let[t,n]=(0,i.useState)("en"),[l,u]=(0,i.useState)(!1),p=(0,i.useMemo)(()=>s().map(e=>o.get(e)).filter(e=>!!e),[]),h=(0,i.useMemo)(()=>Object.fromEntries(s().flatMap(e=>{let t=o.get(e);return t?[[e,t.messages]]:[]})),[]);(0,i.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(a);if("en"===e||"zh-CN"===e)return e}catch{}for(let e of window.navigator.languages.length?window.navigator.languages:[window.navigator.language]){let t=e.toLowerCase();if("en"===t||t.startsWith("en-"))break;if("zh"===t||t.startsWith("zh-"))return"zh-CN"}return"en"}();n(e),document.documentElement.lang=e,u(!0)},[]);let g=(0,i.useCallback)(e=>{if(o.get(e)){n(e),document.documentElement.lang=e;try{window.localStorage.setItem(a,e)}catch{}}},[]),x=(0,i.useCallback)((e,n)=>(function(e,t,n,r={}){let i=n[e]?.[t]??n.en?.[t];return void 0===i?t:function(e,t={}){return e.replace(/\{([\w.-]+)\}/g,(e,n)=>{let r=t[n];return void 0===r?e:String(r)})}(i,r)})(t,e,h,n),[t,h]),f=(0,i.useMemo)(()=>({locale:l?t:"en",setLocale:g,t:x,supportedLocales:p}),[l,t,g,x,p]);return(0,r.jsx)(d.Provider,{value:f,children:e})}function u(){let e=(0,i.useContext)(d);if(!e)throw Error("useI18n must be used inside I18nProvider");return e}},80034:(e,t,n)=>{Promise.resolve().then(n.bind(n,18382)),Promise.resolve().then(n.bind(n,39247))},88576:e=>{e.exports={preview:"ChatMinimap_preview__laAya",turn:"ChatMinimap_turn__fZuce",number:"ChatMinimap_number__3C_cY",content:"ChatMinimap_content__C7_ju",user:"ChatMinimap_user__WHJHv",userText:"ChatMinimap_userText__Nj9jo",assistant:"ChatMinimap_assistant__s6JLb",assistantJump:"ChatMinimap_assistantJump__3CM2M",outline:"ChatMinimap_outline__aleIF",heading:"ChatMinimap_heading__djZbv",paragraph:"ChatMinimap_paragraph__EqWlO"}}},e=>{e.O(0,[7523,7330,8311,8441,3794,7358],()=>e(e.s=80034)),_N_E=e.O()}]);
|