@rexvane/piweb 0.3.20 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +6 -4
  3. package/.next/build-manifest.json +5 -5
  4. package/.next/next-minimal-server.js.nft.json +1 -1
  5. package/.next/next-server.js.nft.json +1 -1
  6. package/.next/prerender-manifest.json +7 -7
  7. package/.next/react-loadable-manifest.json +12 -12
  8. package/.next/required-server-files.js +18 -2
  9. package/.next/required-server-files.json +18 -2
  10. package/.next/routes-manifest.json +12 -0
  11. package/.next/server/app/_global-error/page.js +2 -2
  12. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  13. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_global-error.html +1 -1
  15. package/.next/server/app/_global-error.meta +8 -0
  16. package/.next/server/app/_global-error.rsc +15 -11
  17. package/.next/server/app/_global-error.segments/_full.segment.rsc +15 -11
  18. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +20 -16
  19. package/.next/server/app/_global-error.segments/_tree.segment.rsc +3 -1
  20. package/.next/server/app/_not-found/page.js +1 -1
  21. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  22. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/_not-found.html +1 -1
  24. package/.next/server/app/_not-found.meta +8 -0
  25. package/.next/server/app/_not-found.rsc +17 -13
  26. package/.next/server/app/_not-found.segments/_full.segment.rsc +17 -13
  27. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +24 -20
  28. package/.next/server/app/_not-found.segments/_tree.segment.rsc +4 -2
  29. package/.next/server/app/api/agent/[id]/events/route.js +3 -3
  30. package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
  31. package/.next/server/app/api/agent/[id]/route.js +1 -1
  32. package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
  33. package/.next/server/app/api/agent/[id]/tree/route.js +1 -1
  34. package/.next/server/app/api/agent/[id]/tree/route.js.nft.json +1 -1
  35. package/.next/server/app/api/agent/new/route.js +1 -1
  36. package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
  37. package/.next/server/app/api/config/route.js +1 -1
  38. package/.next/server/app/api/config/route.js.nft.json +1 -1
  39. package/.next/server/app/api/files/route.js +1 -1
  40. package/.next/server/app/api/files/route.js.nft.json +1 -1
  41. package/.next/server/app/api/fs/route.js +1 -1
  42. package/.next/server/app/api/fs/route.js.nft.json +1 -1
  43. package/.next/server/app/api/git/route.js +4 -4
  44. package/.next/server/app/api/git/route.js.nft.json +1 -1
  45. package/.next/server/app/api/github/route.js +5 -0
  46. package/.next/server/app/api/github/route.js.nft.json +1 -0
  47. package/.next/server/app/api/github/route_client-reference-manifest.js +1 -0
  48. package/.next/server/app/api/growth/route.js +1 -1
  49. package/.next/server/app/api/growth/route.js.nft.json +1 -1
  50. package/.next/server/app/api/health/route.js +1 -1
  51. package/.next/server/app/api/health/route.js.nft.json +1 -1
  52. package/.next/server/app/api/models/defaults/route.js +1 -0
  53. package/.next/server/app/api/models/defaults/route.js.nft.json +1 -0
  54. package/.next/server/app/api/models/defaults/route_client-reference-manifest.js +1 -0
  55. package/.next/server/app/api/models/route.js +1 -1
  56. package/.next/server/app/api/models/route.js.nft.json +1 -1
  57. package/.next/server/app/api/pi-settings/route.js +1 -1
  58. package/.next/server/app/api/pi-settings/route.js.nft.json +1 -1
  59. package/.next/server/app/api/plugins/route.js +1 -1
  60. package/.next/server/app/api/plugins/route.js.nft.json +1 -1
  61. package/.next/server/app/api/prompts/route.js +1 -1
  62. package/.next/server/app/api/prompts/route.js.nft.json +1 -1
  63. package/.next/server/app/api/remote/route.js +3 -3
  64. package/.next/server/app/api/remote/route.js.nft.json +1 -1
  65. package/.next/server/app/api/security/route.js +1 -1
  66. package/.next/server/app/api/security/route.js.nft.json +1 -1
  67. package/.next/server/app/api/sessions/[id]/export/route.js +1 -1
  68. package/.next/server/app/api/sessions/[id]/export/route.js.nft.json +1 -1
  69. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  70. package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
  71. package/.next/server/app/api/sessions/import/route.js +2 -2
  72. package/.next/server/app/api/sessions/import/route.js.nft.json +1 -1
  73. package/.next/server/app/api/sessions/route.js +1 -1
  74. package/.next/server/app/api/sessions/route.js.nft.json +1 -1
  75. package/.next/server/app/api/skills/route.js +2 -2
  76. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  77. package/.next/server/app/api/update/route.js +2 -2
  78. package/.next/server/app/api/update/route.js.nft.json +1 -1
  79. package/.next/server/app/api/version/route.js +1 -1
  80. package/.next/server/app/api/version/route.js.nft.json +1 -1
  81. package/.next/server/app/api/web-auth/route.js +1 -1
  82. package/.next/server/app/api/web-auth/route.js.nft.json +1 -1
  83. package/.next/server/app/api/workspaces/route.js +1 -1
  84. package/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  85. package/.next/server/app/icon.svg/route.js +1 -1
  86. package/.next/server/app/icon.svg/route.js.nft.json +1 -1
  87. package/.next/server/app/icon.svg.meta +1 -1
  88. package/.next/server/app/index.html +1 -1
  89. package/.next/server/app/index.meta +8 -0
  90. package/.next/server/app/index.rsc +19 -13
  91. package/.next/server/app/index.segments/__PAGE__.segment.rsc +25 -19
  92. package/.next/server/app/index.segments/_full.segment.rsc +19 -13
  93. package/.next/server/app/index.segments/_tree.segment.rsc +3 -2
  94. package/.next/server/app/login/page.js +1 -1
  95. package/.next/server/app/login/page.js.nft.json +1 -1
  96. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  97. package/.next/server/app/login.html +1 -1
  98. package/.next/server/app/login.meta +8 -0
  99. package/.next/server/app/login.rsc +23 -17
  100. package/.next/server/app/login.segments/_full.segment.rsc +23 -17
  101. package/.next/server/app/login.segments/_tree.segment.rsc +4 -2
  102. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +30 -24
  103. package/.next/server/app/page.js +1 -1
  104. package/.next/server/app/page.js.nft.json +1 -1
  105. package/.next/server/app/page_client-reference-manifest.js +1 -1
  106. package/.next/server/app-paths-manifest.json +6 -4
  107. package/.next/server/chunks/229.js +1 -1
  108. package/.next/server/chunks/421.js +1 -0
  109. package/.next/server/chunks/430.js +215 -31
  110. package/.next/server/chunks/496.js +1 -1
  111. package/.next/server/chunks/538.js +1 -1
  112. package/.next/server/chunks/662.js +2 -0
  113. package/.next/server/chunks/686.js +1 -1
  114. package/.next/server/chunks/807.js +1 -1
  115. package/.next/server/chunks/813.js +23 -1
  116. package/.next/server/chunks/920.js +2 -2
  117. package/.next/server/chunks/924.js +1 -1
  118. package/.next/server/chunks/970.js +305 -0
  119. package/.next/server/instrumentation.js +1 -1
  120. package/.next/server/instrumentation.js.nft.json +1 -1
  121. package/.next/server/middleware-build-manifest.js +1 -1
  122. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  123. package/.next/server/middleware.js +185 -23
  124. package/.next/server/middleware.js.nft.json +1 -1
  125. package/.next/server/pages/404.html +1 -1
  126. package/.next/server/pages/500.html +1 -1
  127. package/.next/server/preview-props.json +5 -0
  128. package/.next/server/server-reference-manifest.json +1 -1
  129. package/.next/static/WMazYvD-gbeLsCUfUxvvM/_buildManifest.js +1 -0
  130. package/.next/static/chunks/316-698d10eb465bd8ef.js +1 -0
  131. package/.next/static/chunks/3794-0978865cda773008.js +52 -0
  132. package/.next/static/chunks/4673.4cf66cbdd8364c57.js +1 -0
  133. package/.next/static/chunks/4686-09fcd0028079006c.js +1 -0
  134. package/.next/static/chunks/4778.eddd3a5813f85824.js +1 -0
  135. package/.next/static/chunks/4bd1b696-e199e788e58acf79.js +1 -0
  136. package/.next/static/chunks/{5173.91ddb803785009f8.js → 5173.dfd1cbb795b9a21c.js} +1 -1
  137. package/.next/static/chunks/618.949981da99be7182.js +4 -0
  138. package/.next/static/chunks/7411.67366dc5032a141d.js +1 -0
  139. package/.next/static/chunks/8552.25c39ef4c995eba0.js +1 -0
  140. package/.next/static/chunks/app/_global-error/page-f977af7f858990a2.js +1 -0
  141. package/.next/static/chunks/app/api/agent/[id]/events/route-f977af7f858990a2.js +1 -0
  142. package/.next/static/chunks/app/api/agent/[id]/route-f977af7f858990a2.js +1 -0
  143. package/.next/static/chunks/app/api/agent/[id]/tree/route-f977af7f858990a2.js +1 -0
  144. package/.next/static/chunks/app/api/agent/new/route-f977af7f858990a2.js +1 -0
  145. package/.next/static/chunks/app/api/config/route-f977af7f858990a2.js +1 -0
  146. package/.next/static/chunks/app/api/files/route-f977af7f858990a2.js +1 -0
  147. package/.next/static/chunks/app/api/fs/route-f977af7f858990a2.js +1 -0
  148. package/.next/static/chunks/app/api/git/route-f977af7f858990a2.js +1 -0
  149. package/.next/static/chunks/app/api/github/route-f977af7f858990a2.js +1 -0
  150. package/.next/static/chunks/app/api/growth/route-f977af7f858990a2.js +1 -0
  151. package/.next/static/chunks/app/api/health/route-f977af7f858990a2.js +1 -0
  152. package/.next/static/chunks/app/api/models/defaults/route-f977af7f858990a2.js +1 -0
  153. package/.next/static/chunks/app/api/models/route-f977af7f858990a2.js +1 -0
  154. package/.next/static/chunks/app/api/pi-settings/route-f977af7f858990a2.js +1 -0
  155. package/.next/static/chunks/app/api/plugins/route-f977af7f858990a2.js +1 -0
  156. package/.next/static/chunks/app/api/prompts/route-f977af7f858990a2.js +1 -0
  157. package/.next/static/chunks/app/api/remote/route-f977af7f858990a2.js +1 -0
  158. package/.next/static/chunks/app/api/security/route-f977af7f858990a2.js +1 -0
  159. package/.next/static/chunks/app/api/sessions/[id]/export/route-f977af7f858990a2.js +1 -0
  160. package/.next/static/chunks/app/api/sessions/[id]/route-f977af7f858990a2.js +1 -0
  161. package/.next/static/chunks/app/api/sessions/import/route-f977af7f858990a2.js +1 -0
  162. package/.next/static/chunks/app/api/sessions/route-f977af7f858990a2.js +1 -0
  163. package/.next/static/chunks/app/api/skills/route-f977af7f858990a2.js +1 -0
  164. package/.next/static/chunks/app/api/update/route-f977af7f858990a2.js +1 -0
  165. package/.next/static/chunks/app/api/version/route-f977af7f858990a2.js +1 -0
  166. package/.next/static/chunks/app/api/web-auth/route-f977af7f858990a2.js +1 -0
  167. package/.next/static/chunks/app/api/workspaces/route-f977af7f858990a2.js +1 -0
  168. package/.next/static/chunks/app/page-fc4ed2ff29b6235e.js +1 -0
  169. package/.next/static/chunks/framework-47b723d27f4a4963.js +1 -0
  170. package/.next/static/chunks/main-5403f0764579e5fe.js +5 -0
  171. package/.next/static/chunks/next/dist/client/components/builtin/app-error-f977af7f858990a2.js +1 -0
  172. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-f977af7f858990a2.js +1 -0
  173. package/.next/static/chunks/next/dist/client/components/builtin/not-found-f977af7f858990a2.js +1 -0
  174. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f977af7f858990a2.js +1 -0
  175. package/.next/static/chunks/webpack-22ebffc20adb44ae.js +1 -0
  176. package/.next/static/css/6671d0d1589fdc0e.css +1 -0
  177. package/.next/static/css/{2959bd6b626b7ffe.css → f15a853af8b5127f.css} +1 -1
  178. package/.next/types/app/api/agent/[id]/events/route.ts +3 -1
  179. package/.next/types/app/api/agent/[id]/route.ts +3 -1
  180. package/.next/types/app/api/agent/[id]/tree/route.ts +3 -1
  181. package/.next/types/app/api/agent/new/route.ts +3 -1
  182. package/.next/types/app/api/config/route.ts +3 -1
  183. package/.next/types/app/api/files/route.ts +3 -1
  184. package/.next/types/app/api/fs/route.ts +3 -1
  185. package/.next/types/app/api/git/route.ts +3 -1
  186. package/.next/types/app/api/github/route.ts +355 -0
  187. package/.next/types/app/api/growth/route.ts +3 -1
  188. package/.next/types/app/api/health/route.ts +3 -1
  189. package/.next/types/app/api/models/defaults/route.ts +355 -0
  190. package/.next/types/app/api/models/route.ts +3 -1
  191. package/.next/types/app/api/pi-settings/route.ts +3 -1
  192. package/.next/types/app/api/plugins/route.ts +3 -1
  193. package/.next/types/app/api/prompts/route.ts +3 -1
  194. package/.next/types/app/api/remote/route.ts +3 -1
  195. package/.next/types/app/api/security/route.ts +3 -1
  196. package/.next/types/app/api/sessions/[id]/export/route.ts +3 -1
  197. package/.next/types/app/api/sessions/[id]/route.ts +3 -1
  198. package/.next/types/app/api/sessions/import/route.ts +3 -1
  199. package/.next/types/app/api/sessions/route.ts +3 -1
  200. package/.next/types/app/api/skills/route.ts +3 -1
  201. package/.next/types/app/api/update/route.ts +3 -1
  202. package/.next/types/app/api/version/route.ts +3 -1
  203. package/.next/types/app/api/web-auth/route.ts +3 -1
  204. package/.next/types/app/api/workspaces/route.ts +3 -1
  205. package/.next/types/app/layout.ts +4 -1
  206. package/.next/types/app/login/page.ts +4 -1
  207. package/.next/types/app/page.ts +4 -1
  208. package/.next/types/cache-life.d.ts +11 -43
  209. package/.next/types/routes.d.ts +3 -1
  210. package/.next/types/validator.ts +76 -2
  211. package/README.md +14 -5
  212. package/next.config.ts +4 -2
  213. package/package.json +2 -2
  214. package/scripts/release.mjs +1 -1
  215. package/src/app/api/agent/[id]/events/route.ts +42 -13
  216. package/src/app/api/files/route.ts +5 -2
  217. package/src/app/api/github/route.ts +26 -0
  218. package/src/app/api/models/defaults/route.ts +18 -0
  219. package/src/app/api/models/route.ts +24 -1
  220. package/src/app/api/update/route.ts +18 -2
  221. package/src/app/globals.css +275 -0
  222. package/src/components/AppShell.tsx +89 -33
  223. package/src/components/ChatInput.tsx +245 -63
  224. package/src/components/ChatWindow.tsx +123 -108
  225. package/src/components/ContextMeter.tsx +204 -123
  226. package/src/components/DrawerPanel.tsx +19 -26
  227. package/src/components/ExtensionUI.tsx +8 -2
  228. package/src/components/GitPanel.tsx +110 -40
  229. package/src/components/MarkdownBlock.tsx +333 -37
  230. package/src/components/ProjectPanel.tsx +55 -30
  231. package/src/components/PromptPanel.tsx +2 -4
  232. package/src/components/ProviderSetupModal.module.css +20 -0
  233. package/src/components/ProviderSetupModal.tsx +134 -29
  234. package/src/components/SettingsPanel.tsx +365 -80
  235. package/src/components/TrajectoryView.tsx +4 -6
  236. package/src/components/chat/chat-scroll.ts +18 -0
  237. package/src/components/composer/ComposerImages.tsx +306 -0
  238. package/src/components/update/CopyCommand.tsx +34 -0
  239. package/src/components/update/UpdateNotice.tsx +130 -0
  240. package/src/components/update/update-store.ts +155 -0
  241. package/src/hooks/useGrowth.ts +3 -0
  242. package/src/hooks/usePiWeb.ts +54 -27
  243. package/src/hooks/useWorkspaceFiles.ts +93 -0
  244. package/src/i18n.tsx +182 -6
  245. package/src/instrumentation-node.ts +3 -0
  246. package/src/lib/agent-manager.ts +193 -119
  247. package/src/lib/chat/event-stream.ts +113 -0
  248. package/src/lib/chat/stream-settings.ts +192 -0
  249. package/src/lib/files-service.ts +100 -1
  250. package/src/lib/format.ts +56 -0
  251. package/src/lib/git-service.ts +45 -13
  252. package/src/lib/github-identity.ts +245 -0
  253. package/src/lib/growth-service.ts +6 -2
  254. package/src/lib/hero-model-memory.ts +28 -0
  255. package/src/lib/model-defaults.ts +105 -0
  256. package/src/lib/model-draft.ts +257 -9
  257. package/src/lib/model-endpoint.ts +23 -0
  258. package/src/lib/model-files.ts +33 -0
  259. package/src/lib/models-service.ts +240 -78
  260. package/src/lib/pi.ts +27 -2
  261. package/src/lib/process-format.ts +3 -2
  262. package/src/lib/session/metrics.ts +31 -0
  263. package/src/lib/thinking-level.ts +39 -0
  264. package/src/lib/trajectory.ts +17 -3
  265. package/src/lib/types.ts +19 -1
  266. package/src/lib/update/startup-check.ts +117 -0
  267. package/src/lib/update-service.ts +23 -3
  268. package/src/lib/workspace-index.ts +270 -0
  269. package/.next/server/chunks/131.js +0 -1
  270. package/.next/server/chunks/243.js +0 -1
  271. package/.next/server/chunks/741.js +0 -165
  272. package/.next/static/_Y3Lq0lI5RJ1tFSOnDi0L/_buildManifest.js +0 -1
  273. package/.next/static/chunks/316-5ea443ee6b512aa9.js +0 -1
  274. package/.next/static/chunks/3794-3679f1c05160977c.js +0 -52
  275. package/.next/static/chunks/4673.8a5a9e6855350e34.js +0 -1
  276. package/.next/static/chunks/4686-b1e9fa876d0ea671.js +0 -1
  277. package/.next/static/chunks/4778.e4c9ed093a413bc4.js +0 -1
  278. package/.next/static/chunks/4bd1b696-93bf506b236d6248.js +0 -1
  279. package/.next/static/chunks/618.ee5d5bf1c647e483.js +0 -4
  280. package/.next/static/chunks/839.d3fe337a9117c325.js +0 -1
  281. package/.next/static/chunks/8552.6bfe3e101250b20f.js +0 -1
  282. package/.next/static/chunks/app/_global-error/page-b179d9f7f6f2daf9.js +0 -1
  283. package/.next/static/chunks/app/api/agent/[id]/events/route-b179d9f7f6f2daf9.js +0 -1
  284. package/.next/static/chunks/app/api/agent/[id]/route-b179d9f7f6f2daf9.js +0 -1
  285. package/.next/static/chunks/app/api/agent/[id]/tree/route-b179d9f7f6f2daf9.js +0 -1
  286. package/.next/static/chunks/app/api/agent/new/route-b179d9f7f6f2daf9.js +0 -1
  287. package/.next/static/chunks/app/api/config/route-b179d9f7f6f2daf9.js +0 -1
  288. package/.next/static/chunks/app/api/files/route-b179d9f7f6f2daf9.js +0 -1
  289. package/.next/static/chunks/app/api/fs/route-b179d9f7f6f2daf9.js +0 -1
  290. package/.next/static/chunks/app/api/git/route-b179d9f7f6f2daf9.js +0 -1
  291. package/.next/static/chunks/app/api/growth/route-b179d9f7f6f2daf9.js +0 -1
  292. package/.next/static/chunks/app/api/health/route-b179d9f7f6f2daf9.js +0 -1
  293. package/.next/static/chunks/app/api/models/route-b179d9f7f6f2daf9.js +0 -1
  294. package/.next/static/chunks/app/api/pi-settings/route-b179d9f7f6f2daf9.js +0 -1
  295. package/.next/static/chunks/app/api/plugins/route-b179d9f7f6f2daf9.js +0 -1
  296. package/.next/static/chunks/app/api/prompts/route-b179d9f7f6f2daf9.js +0 -1
  297. package/.next/static/chunks/app/api/remote/route-b179d9f7f6f2daf9.js +0 -1
  298. package/.next/static/chunks/app/api/security/route-b179d9f7f6f2daf9.js +0 -1
  299. package/.next/static/chunks/app/api/sessions/[id]/export/route-b179d9f7f6f2daf9.js +0 -1
  300. package/.next/static/chunks/app/api/sessions/[id]/route-b179d9f7f6f2daf9.js +0 -1
  301. package/.next/static/chunks/app/api/sessions/import/route-b179d9f7f6f2daf9.js +0 -1
  302. package/.next/static/chunks/app/api/sessions/route-b179d9f7f6f2daf9.js +0 -1
  303. package/.next/static/chunks/app/api/skills/route-b179d9f7f6f2daf9.js +0 -1
  304. package/.next/static/chunks/app/api/update/route-b179d9f7f6f2daf9.js +0 -1
  305. package/.next/static/chunks/app/api/version/route-b179d9f7f6f2daf9.js +0 -1
  306. package/.next/static/chunks/app/api/web-auth/route-b179d9f7f6f2daf9.js +0 -1
  307. package/.next/static/chunks/app/api/workspaces/route-b179d9f7f6f2daf9.js +0 -1
  308. package/.next/static/chunks/app/page-2e425ef83fba0782.js +0 -1
  309. package/.next/static/chunks/framework-c4e651fe89edfa91.js +0 -1
  310. package/.next/static/chunks/main-6159b22a8cb0b7c5.js +0 -5
  311. package/.next/static/chunks/next/dist/client/components/builtin/app-error-b179d9f7f6f2daf9.js +0 -1
  312. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-b179d9f7f6f2daf9.js +0 -1
  313. package/.next/static/chunks/next/dist/client/components/builtin/not-found-b179d9f7f6f2daf9.js +0 -1
  314. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b179d9f7f6f2daf9.js +0 -1
  315. package/.next/static/chunks/webpack-3614a8337843456b.js +0 -1
  316. package/.next/static/css/7391c42e1ae617f9.css +0 -1
  317. /package/.next/static/{_Y3Lq0lI5RJ1tFSOnDi0L → WMazYvD-gbeLsCUfUxvvM}/_ssgManifest.js +0 -0
@@ -0,0 +1,4 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[618],{618:(e,t,r)=>{"use strict";r.r(t),r.d(t,{TrajInspector:()=>b,TrajectoryView:()=>v});var n=r(5155),a=r(2115),s=r(9992),i=r(1859),l=r(3364),o=r(5821),c=r.n(o);let d={system:"SYSTEM",context:"CONTEXT",user:"USER",message:"ASSISTANT",tool:"TOOL",compacted:"COMPACT"};function u(e){return null==e?"—":(0,l.yj)(e)}function j(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function m(e){if(e.timing?.durationMs!=null)return e.timing.durationMs;let{ttftMs:t,decodeMs:r}=e.timing??{};if(null!=t||null!=r)return(t??0)+(r??0)}function h(e){return null==e?"—":e>=6e4?`${(e/6e4).toFixed(2)}m`:e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function x(e){return(e.preview||e.detail||e.thinking||e.title||d[e.kind]).replace(/\s+/g," ").trim()}function y(e){switch(e.kind){case"system":return"Pi SDK \xb7 AgentSession.systemPrompt";case"context":return`Pi ResourceLoader \xb7 ${e.title||"context"}`;case"user":return"Pi SessionManager \xb7 user message";case"message":return"Pi AgentSession \xb7 model response";case"tool":return`Pi AgentSession \xb7 tool execution${e.toolName?` \xb7 ${e.toolName}`:""}`;case"compacted":return"Pi SessionManager \xb7 compaction"}}function p(e,t){if(!t)return!0;let r=e.entry;return[r.kind,r.title,r.toolName,r.toolCallId,r.preview,r.detail,r.thinking,String(r.seq),e.turn?String(e.turn):""].filter(Boolean).join("\n").toLocaleLowerCase().includes(t)}function _({expanded:e}){return(0,n.jsx)("span",{className:c().foldIcon,"aria-hidden":!0,children:e?"⊟":"⊞"})}function g(){return(0,n.jsxs)("svg",{className:c().durationIcon,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"5.25"}),(0,n.jsx)("path",{d:"M8 4.75V8l2.25 1.5"})]})}function T({rows:e,actualDuration:t,matchedSeqs:r,selected:s,onSelect:l}){let{t:o}=(0,i.s)(),u=(0,a.useMemo)(()=>{if(!e.length)return[];let r=1/0,n=-1/0;for(let t of e)r=Math.min(r,t.entry.ts),n=Math.max(n,t.entry.ts+(m(t.entry)??0));let a=Math.max(n-r,1);return e.map((s,i)=>t&&n!==r?{row:s,left:(s.entry.ts-r)/a*100,width:Math.max((m(s.entry)??0)/a*100,.18)}:{row:s,left:i/e.length*100,width:Math.max(100/e.length-.12,.25)})},[t,e]);return(0,n.jsxs)("div",{className:c().timeline,"aria-label":o.trajTimeline,children:[(0,n.jsxs)("div",{className:c().laneLabels,"aria-hidden":!0,children:[(0,n.jsx)("span",{children:o.trajInput}),(0,n.jsx)("span",{children:o.trajModel}),(0,n.jsx)("span",{children:o.trajTools})]}),(0,n.jsx)("div",{className:c().timelineTrack,children:u.map(({row:e,left:t,width:a})=>{let i=e.entry,o=m(i),u=i.timing?.ttftMs,x=1===e.lane&&o&&null!=u?{background:`linear-gradient(to right, var(--traj-model-wait) 0 ${u/o*100}%, var(--traj-model) ${u/o*100}% 100%)`}:void 0;return(0,n.jsx)("button",{type:"button",className:c().timelineSpan,"data-kind":i.kind,"data-selected":s?.seq===i.seq||void 0,"data-muted":r&&!r.has(i.seq)?"true":void 0,"data-error":i.isError||void 0,style:{left:`${t}%`,width:`${a}%`,top:6+14*e.lane,...x},title:`${d[i.kind]} \xb7 ${j(i.ts)} \xb7 ${h(o)}`,onClick:()=>l({...i,...e.turn?{turn:e.turn}:{}})},`${i.seq}:${e.index}`)})})]})}function v({entries:e,selected:t,onSelect:r}){let{t:l}=(0,i.s)(),[o,j]=(0,a.useState)(!0),[y,b]=(0,a.useState)(!1),[k,N]=(0,a.useState)(!1),[S,f]=(0,a.useState)(""),A=(0,a.useMemo)(()=>{let t;return t=0,e.map((e,r)=>{"user"===e.kind&&(t+=1);let n=t>0?t:void 0,a="tool"===e.kind?2:+("message"===e.kind);return{entry:e,index:r,lane:a,...n?{turn:n}:{}}})},[e]),w=S.trim().toLocaleLowerCase(),z=(0,a.useMemo)(()=>w?new Set(A.filter(e=>p(e,w)).map(e=>e.entry.seq)):null,[w,A]),C=(0,a.useMemo)(()=>A.filter(e=>(!y||"tool"!==e.entry.kind)&&(!k||!!["system","context","user","compacted"].includes(e.entry.kind))&&p(e,w)).reverse(),[y,w,A,k]);return(0,n.jsxs)("div",{className:c().root,children:[(0,n.jsxs)("div",{className:c().toolbar,role:"toolbar","aria-label":l.tabTrajectory,children:[(0,n.jsxs)("div",{className:c().toolbarActions,children:[(0,n.jsxs)("button",{type:"button",className:c().toolbarButton,"aria-pressed":o,onClick:()=>j(e=>!e),children:[(0,n.jsx)(g,{}),"Duration"]}),(0,n.jsxs)("button",{type:"button",className:c().toolbarButton,"aria-pressed":k,onClick:()=>N(e=>!e),children:[(0,n.jsx)(_,{expanded:!k}),"Turns"]}),(0,n.jsxs)("button",{type:"button",className:c().toolbarButton,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,n.jsx)(_,{expanded:!y}),"Calls"]})]}),(0,n.jsxs)("label",{className:c().searchBox,children:[(0,n.jsx)(s.FG,{size:13}),(0,n.jsx)("input",{type:"search",value:S,onChange:e=>f(e.currentTarget.value),placeholder:l.trajSearchPlaceholder,"aria-label":l.trajSearchPlaceholder})]})]}),(0,n.jsx)(T,{rows:A,actualDuration:o,matchedSeqs:z,selected:t,onSelect:r}),(0,n.jsx)("div",{className:c().ledger,children:e.length?0===C.length?(0,n.jsx)("div",{className:c().empty,children:l.trajNoMatch}):(0,n.jsx)("div",{className:c().groupBody,children:C.map(e=>{let a=e.entry,s=a.tokens??{};return(0,n.jsxs)("button",{type:"button",className:c().row,"data-kind":a.kind,"data-environment":"system"===a.kind||"context"===a.kind||void 0,"data-selected":t?.seq===a.seq||void 0,onClick:()=>r({...a,...e.turn?{turn:e.turn}:{}}),children:[(0,n.jsx)("span",{className:c().kindTag,children:"tool"===a.kind&&a.toolName?a.toolName:d[a.kind]}),(0,n.jsx)("span",{className:c().rowText,title:x(a),children:x(a)||d[a.kind]}),(0,n.jsx)("span",{className:c().metric,children:u(s.input)}),(0,n.jsx)("span",{className:c().metric,children:u(s.output)}),(0,n.jsx)("span",{className:c().metric,children:a.thinking?"on":"—"}),(0,n.jsx)("span",{className:c().metric,children:h(m(a))})]},`${a.seq}:${e.index}`)})}):(0,n.jsx)("div",{className:c().empty,children:l.trajEmpty})})]})}function b({entry:e,onClose:t}){let{t:r}=(0,i.s)(),[l,o]=(0,a.useState)("summary"),x=e.toolName||d[e.kind],p="system"===e.kind?r.trajSystem:e.turn?`${r.trajTurn} ${e.turn}`:r.trajSession,_=e.detail||e.preview||e.thinking||"",g=[{id:"summary",label:r.trajSummary},{id:"preview",label:r.trajPreview},{id:"raw",label:r.trajRaw},{id:"source",label:r.trajSource}];return(0,n.jsxs)("div",{className:c().inspector,children:[(0,n.jsxs)("div",{className:c().inspectorHeader,children:[(0,n.jsx)("span",{className:c().inspectorTag,"data-kind":e.kind,children:x}),(0,n.jsxs)("span",{className:c().inspectorTitle,children:[p," \xb7 ","message"===e.kind?r.trajModel:x]}),(0,n.jsx)("button",{type:"button",className:c().closeButton,onClick:t,"aria-label":r.close,children:(0,n.jsx)(s.Bh,{size:15})})]}),(0,n.jsx)("div",{className:c().inspectorTabs,role:"tablist",children:g.map(e=>(0,n.jsx)("button",{type:"button",role:"tab","aria-selected":l===e.id,onClick:()=>o(e.id),children:e.label},e.id))}),(0,n.jsxs)("div",{className:c().inspectorBody,children:[e.encodingLoss&&(0,n.jsx)("p",{role:"status",style:{margin:"0 0 14px",color:"var(--dsw-warning, #d5a13b)",fontSize:13,lineHeight:1.55},children:r.encodingLossWarning}),"summary"===l&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("dl",{className:c().summaryList,children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.trajSource}),(0,n.jsx)("dd",{children:y(e)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.trajStatus}),(0,n.jsx)("dd",{"data-error":e.isError||void 0,children:e.isError?r.trajFailed:r.trajCompleted})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.duration}),(0,n.jsx)("dd",{children:h(m(e))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.trajStarted}),(0,n.jsx)("dd",{children:j(e.ts)})]}),e.tokens&&(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.trajTokens}),(0,n.jsxs)("dd",{children:["↑ ",u(e.tokens.input)," \xb7 ↓ ",u(e.tokens.output)," \xb7 cache ",u(e.tokens.cacheRead)]})]}),e.toolCallId&&(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:"Call ID"}),(0,n.jsx)("dd",{className:c().monoValue,children:e.toolCallId})]}),e.timing?.ttftMs!=null&&(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.ttft}),(0,n.jsx)("dd",{children:h(e.timing.ttftMs)})]}),e.timing?.decodeMs!=null&&(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:r.decode}),(0,n.jsx)("dd",{children:h(e.timing.decodeMs)})]})]}),_&&(0,n.jsx)(k,{title:r.trajPreview,value:_})]}),"preview"===l&&(0,n.jsx)(k,{title:e.thinking?r.trajThink:r.trajPreview,value:[e.thinking,e.detail||e.preview].filter(Boolean).join("\n\n"),empty:r.trajNoContent}),"raw"===l&&(0,n.jsx)(k,{title:"JSON",value:JSON.stringify(e,null,2),mono:!0}),"source"===l&&(0,n.jsx)(k,{title:r.trajSource,value:`${y(e)}
2
+
3
+ seq: ${e.seq}
4
+ timestamp: ${new Date(e.ts).toISOString()}`,mono:!0})]})]})}function k({title:e,value:t,empty:r,mono:a=!1}){return(0,n.jsxs)("section",{className:c().payloadSection,children:[(0,n.jsx)("h3",{children:e}),(0,n.jsx)("pre",{"data-mono":a||void 0,children:t||r||"—"})]})}},5821:e=>{e.exports={root:"TrajectoryAnalyzer_root__8OvwA",toolbar:"TrajectoryAnalyzer_toolbar__Oacl7",toolbarActions:"TrajectoryAnalyzer_toolbarActions__ifdiJ",toolbarButton:"TrajectoryAnalyzer_toolbarButton__4Z2x_",durationIcon:"TrajectoryAnalyzer_durationIcon__pqiw6",foldIcon:"TrajectoryAnalyzer_foldIcon__c33yJ",searchBox:"TrajectoryAnalyzer_searchBox__TCm2z",timeline:"TrajectoryAnalyzer_timeline__XCgCp",laneLabels:"TrajectoryAnalyzer_laneLabels__8izl9",timelineTrack:"TrajectoryAnalyzer_timelineTrack__PdeZf",timelineSpan:"TrajectoryAnalyzer_timelineSpan__VVeBw",ledger:"TrajectoryAnalyzer_ledger__zGjcd",groupBody:"TrajectoryAnalyzer_groupBody__K0fDf",row:"TrajectoryAnalyzer_row__IKBr_",metric:"TrajectoryAnalyzer_metric__mxU4O",kindTag:"TrajectoryAnalyzer_kindTag__GpW3j",inspectorTag:"TrajectoryAnalyzer_inspectorTag__rxP64",rowText:"TrajectoryAnalyzer_rowText__IS0ih",empty:"TrajectoryAnalyzer_empty__qw9mP",inspector:"TrajectoryAnalyzer_inspector__7AafK",inspectorHeader:"TrajectoryAnalyzer_inspectorHeader__cz73W",inspectorTitle:"TrajectoryAnalyzer_inspectorTitle__eEWJN",closeButton:"TrajectoryAnalyzer_closeButton__VxUyl",inspectorTabs:"TrajectoryAnalyzer_inspectorTabs__Kh_AZ",inspectorBody:"TrajectoryAnalyzer_inspectorBody__NugnH",summaryList:"TrajectoryAnalyzer_summaryList__vHd3B",monoValue:"TrajectoryAnalyzer_monoValue__7oDjZ",payloadSection:"TrajectoryAnalyzer_payloadSection__JPp_f"}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7411],{901:e=>{e.exports={mask:"ProviderSetupModal_mask__wwU3u",dialog:"ProviderSetupModal_dialog__BxSeI",builtinDialog:"ProviderSetupModal_builtinDialog__vA7_B",header:"ProviderSetupModal_header__Nvgmb",title:"ProviderSetupModal_title__ZIIXp",body:"ProviderSetupModal_body__QAlNu",builtinBody:"ProviderSetupModal_builtinBody___4EFo",field:"ProviderSetupModal_field__ZMO8M",label:"ProviderSetupModal_label__4_BYS",hint:"ProviderSetupModal_hint__yCwPV",input:"ProviderSetupModal_input__YZYV5",select:"ProviderSetupModal_select___PTpP",providerTrigger:"ProviderSetupModal_providerTrigger__TXtau",picker:"ProviderSetupModal_picker__VQdQc",providerText:"ProviderSetupModal_providerText__l9bwJ",providerName:"ProviderSetupModal_providerName__Hwwfg",providerMeta:"ProviderSetupModal_providerMeta____3za",menu:"ProviderSetupModal_menu__zO5CU",searchWrap:"ProviderSetupModal_searchWrap__5yw1r",searchIcon:"ProviderSetupModal_searchIcon__BZeD1",search:"ProviderSetupModal_search__j_n_8",providerList:"ProviderSetupModal_providerList__bMnFj",providerRow:"ProviderSetupModal_providerRow__Zf7fg",selectedMark:"ProviderSetupModal_selectedMark___8UDb",empty:"ProviderSetupModal_empty__4V1WK",advanced:"ProviderSetupModal_advanced__kWaTH",advancedButton:"ProviderSetupModal_advancedButton__efHwl",catalog:"ProviderSetupModal_catalog__mXakU",catalogHeader:"ProviderSetupModal_catalogHeader__0MDA4",catalogStatus:"ProviderSetupModal_catalogStatus__JRz0P",discoverButton:"ProviderSetupModal_discoverButton__GGuZX",discoverControls:"ProviderSetupModal_discoverControls___0_l8",allowPrivate:"ProviderSetupModal_allowPrivate__zZyZi",modelEmpty:"ProviderSetupModal_modelEmpty__h1N_8",modelList:"ProviderSetupModal_modelList__jkYVz",modelRow:"ProviderSetupModal_modelRow__mHfRv",removeModel:"ProviderSetupModal_removeModel___LjE1",addModel:"ProviderSetupModal_addModel__Q3KOU",error:"ProviderSetupModal_error__EAOK6",footer:"ProviderSetupModal_footer__zVp_c",footerButton:"ProviderSetupModal_footerButton__FL58k",primary:"ProviderSetupModal_primary__ArzeF",modelEntry:"ProviderSetupModal_modelEntry__G067u",rowToggle:"ProviderSetupModal_rowToggle__kc_Za",capacityRow:"ProviderSetupModal_capacityRow__0miDX",capacityField:"ProviderSetupModal_capacityField___TX70",capacityHint:"ProviderSetupModal_capacityHint__z_5re",rowError:"ProviderSetupModal_rowError__2vHrG",catalogError:"ProviderSetupModal_catalogError__ZL5D7",catalogHint:"ProviderSetupModal_catalogHint__ws49_",candidateMask:"ProviderSetupModal_candidateMask__YUZn7",candidateDialog:"ProviderSetupModal_candidateDialog__upECk",candidateHeader:"ProviderSetupModal_candidateHeader__bUvHV",candidateList:"ProviderSetupModal_candidateList__JRufC",candidateRow:"ProviderSetupModal_candidateRow__Omm_o",candidateTag:"ProviderSetupModal_candidateTag__lE99_",candidateId:"ProviderSetupModal_candidateId__7Hy7u",candidateName:"ProviderSetupModal_candidateName__D4rXE",candidateActions:"ProviderSetupModal_candidateActions__iptOe",candidateAll:"ProviderSetupModal_candidateAll__yhD_R",candidatePicked:"ProviderSetupModal_candidatePicked__cJ78H"}},6972:(e,t,a)=>{"use strict";a.d(t,{$n:()=>i,Iy:()=>k,Kx:()=>j,PM:()=>f,QW:()=>l,ie:()=>s,kh:()=>r,kk:()=>C,pb:()=>N,tu:()=>S});let s=["smooth","typewriter","fade","instant"],l=1,r=5,i={style:"smooth",speed:3,caret:!1},n="piweb.streamStyle",o="piweb.streamSpeed",d="piweb.streamCaret",c=[24,20,16,12,8],u=[14,10,7,5,3],p=[1,1,1,2,3],m=[140,110,90,70,50],h=[1,2,3,5,8];function x(e){return"smooth"===e||"instant"===e||"typewriter"===e||"fade"===e}function v(e){return Number.isFinite(e)?Math.max(l,Math.min(r,Math.round(e))):i.speed}function f(e){return c[v(e)-1]}function g(){try{let e=localStorage.getItem(n),t=Number.parseInt(localStorage.getItem(o)??"",10),a=localStorage.getItem(d);return{style:x(e)?e:i.style,speed:Number.isFinite(t)?v(t):i.speed,caret:null===a?i.caret:"1"===a||"true"===a}}catch{return i}}let b=null,y=new Set,w=!1;function j(){return b||(b=g()),b}function S(){return i}function N(e){return y.add(e),w||(w=!0,window.addEventListener("storage",e=>{if(null===e.key||e.key===n||e.key===o||e.key===d)for(let e of(b=g(),y))e()})),()=>{y.delete(e)}}function k(e){let t=j(),a={style:x(e.style)?e.style:t.style,speed:void 0===e.speed?t.speed:v(e.speed),caret:void 0===e.caret?t.caret:!0===e.caret};b=a;try{localStorage.setItem(n,a.style),localStorage.setItem(o,String(a.speed)),localStorage.setItem(d,a.caret?"1":"0")}catch{}for(let e of y)e();return a}function C(e,t,a){let s,l=e.length;if("instant"===a.style)return l;let r=l-t;if(r<=0)return l;let i=v(a.speed)-1;(s="typewriter"===a.style?t+Math.max(h[i],Math.ceil(r/90)):t+Math.min(m[i],Math.max(p[i],Math.ceil(r/u[i]))))>l&&(s=l),"fade"===a.style&&(s=function(e,t,a){if(a>=e.length)return e.length;for(let s=a-1;s>=t;s-=1)if(/\s/.test(e[s]))return s+1;return a}(e,t,s));var n=s;if(n<=0)return 0;if(n>=e.length)return e.length;let o=e.charCodeAt(n-1),d=e.charCodeAt(n);return o>=55296&&o<=56319&&d>=56320&&d<=57343?Math.min(n+1,e.length):n}},7411:(e,t,a)=>{"use strict";a.r(t),a.d(t,{PluginsSection:()=>Z,SettingsPanel:()=>$});var s=a(5155),l=a(2115),r=a(7650),i=a(560),n=a(9992);let o=[[/^amazon-bedrock$/,"bedrock-color"],[/^ant-ling$/,"antgroup-color"],[/^anthropic$/,"anthropic"],[/^azure-/,"azure-color"],[/^baseten$/,"baseten"],[/^cerebras$/,"cerebras-color"],[/^cloudflare-/,"cloudflare-color"],[/^deepseek$/,"deepseek-color"],[/^fireworks$/,"fireworks-color"],[/^github-copilot$/,"githubcopilot"],[/^google-vertex(?:-|$)/,"googlecloud-color"],[/^google$/,"google-color"],[/^groq$/,"groq"],[/^huggingface$/,"huggingface-color"],[/^kimi(?:-|$)/,"kimi-color"],[/^minimax/,"minimax-color"],[/^mistral$/,"mistral-color"],[/^moonshot(?:ai)?(?:-|$)/,"moonshot"],[/^nvidia$/,"nvidia-color"],[/^openai/,"openai"],[/^opencode(?:-|$)/,"opencode"],[/^openrouter$/,"openrouter-color"],[/^qwen(?:-|$)/,"qwen-color"],[/^together$/,"together-color"],[/^vercel(?:-|$)/,"vercel"],[/^xai$/,"xai"],[/^xiaomi(?:-|$)/,"xiaomimimo"],[/^zai(?:-|$)/,"zai"]];[...new Set(o.map(([,e])=>e))];let d=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,c=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"];function u(e){let t=new Set(c);return[...c,...[...new Set(e.filter(e=>e&&!t.has(e)))].sort()]}function p({id:e,name:t,size:a=36}){let l,r=o.find(([t])=>t.test(e))?.[1]??null;return(0,s.jsx)("span",{"aria-hidden":"true",className:"inline-flex flex-none items-center justify-center overflow-hidden",style:{width:a,height:a,borderRadius:Math.max(10,Math.round(.3*a)),background:"#f7f7f5",border:"0.5px solid rgba(0,0,0,.09)",color:"#18191b",fontSize:Math.max(10,Math.round(.32*a)),fontWeight:750,letterSpacing:"-0.03em"},children:r?(0,s.jsx)("img",{src:`/provider-icons/${r}.svg`,alt:"",width:Math.round(.66*a),height:Math.round(.66*a)}):(l=t.trim().split(/[\s_-]+/).filter(Boolean)).length>=2?(l[0][0]+l[1][0]).toUpperCase():(l[0]??e).slice(0,2).toUpperCase()})}var m=a(1859);function h(e){try{let t=new URL(e.trim()).hostname.replace(/^\[|\]$/g,"").toLowerCase();if(!t)return!1;if("localhost"===t||t.endsWith(".localhost")||t.endsWith(".local"))return!0;if(t.includes(":"))return"::1"===t||/^(fc|fd|fe80)/.test(t);let a=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(!a)return!1;let s=Number(a[1]),l=Number(a[2]);return 0===s||10===s||127===s||192===s&&168===l||172===s&&l>=16&&l<=31||169===s&&254===l}catch{return!1}}var x=a(2578),v=a(901),f=a.n(v);function g({mode:e,providers:t,catalogModelIds:a,existingIds:r,onClose:i,onSaveBuiltin:o,onSaveCustom:c,onOAuthLogin:v}){let{t:y}=(0,m.s)(),[w,j]=(0,l.useState)(t[0]?.id??""),[S,N]=(0,l.useState)(!1),[k,C]=(0,l.useState)(""),[_,z]=(0,l.useState)("api_key"),[P,M]=(0,l.useState)(""),[E,T]=(0,l.useState)(!1),[$,R]=(0,l.useState)(""),[D,F]=(0,l.useState)(""),[L,A]=(0,l.useState)(""),W=u(t.flatMap(e=>e.apis)),[O,I]=(0,l.useState)(W.includes("openai-completions")?"openai-completions":W[0]??"openai-completions"),[U,K]=(0,l.useState)([]),B=0===U.length&&!!$.trim()&&!!(P.trim()||h($)),[H,V]=(0,l.useState)(0),J=()=>{B&&V(e=>e+1)},[q,Q]=(0,l.useState)(!1),[G,Z]=(0,l.useState)(""),X=(0,l.useRef)(null),Y=t.find(e=>e.id===w),ee=(0,l.useMemo)(()=>new Set(a?.[w]??[]),[a,w]),et=t.filter(e=>{let t=k.trim().toLocaleLowerCase();return!t||e.name.toLocaleLowerCase().includes(t)||e.id.toLocaleLowerCase().includes(t)});(0,l.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),S?N(!1):i())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[i,S]),(0,l.useEffect)(()=>{if(!S)return;let e=e=>{X.current?.contains(e.target)||N(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]);let ea=(e,t)=>{K(a=>a.map((a,s)=>s===e?{...a,...t}:a))},es=(0,x.aK)(U),el=D.trim(),er=d.test(el),ei=er&&!r.includes(el)&&!!$.trim()&&U.length>0&&!es,en=!!Y&&("oauth"===_||!es),eo=(0,l.useRef)(!1),ed=async()=>{if(!eo.current&&("builtin"===e?en:ei)){eo.current=!0,Q(!0),Z("");try{let t;if("builtin"===e&&Y)if("oauth"===_&&v)t=await v(Y.id);else{let e=(0,x.Vt)({},{baseUrl:$,models:U},Y.apis[0]??"openai-completions",ee);t=await o({providerId:Y.id,apiKey:P.trim(),config:e})}else t=await c({providerId:el,config:{name:L.trim()||el,baseUrl:$.trim(),api:O,...P.trim()?{apiKey:P.trim()}:{},models:U.map(e=>(0,x.vV)(e))}});t.success?i():Z(t.error||y.toastError)}catch(e){Z(e instanceof Error?e.message:y.toastError)}finally{eo.current=!1,Q(!1)}}},ec=async t=>{if(!$.trim())throw Error(y.apiAddress);let a=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"discoverModels",baseUrl:$.trim(),api:"builtin"===e?Y?.apis[0]:O,apiKey:P.trim(),providerId:"builtin"===e?Y?.id:void 0,allowPrivate:t})}),s=await a.json();if(!a.ok||!s.success)throw Error(s.error||y.toastError);return(s.data.models??[]).map(x.SC)};return(0,s.jsx)("div",{className:f().mask,"data-provider-modal":"true",onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,s.jsxs)("section",{className:`${f().dialog} ${"builtin"===e?f().builtinDialog:""}`,role:"dialog","aria-modal":"true","aria-labelledby":"provider-setup-title",children:[(0,s.jsxs)("header",{className:f().header,children:[(0,s.jsx)("h2",{id:"provider-setup-title",className:f().title,children:"builtin"===e?y.addProvider:y.customProviderTitle}),(0,s.jsx)("button",{className:"icon-btn",title:y.close,"aria-label":y.close,onClick:i,children:(0,s.jsx)(n.Bh,{size:17})})]}),(0,s.jsxs)("div",{className:`${f().body} ${"builtin"===e?f().builtinBody:""}`,children:["builtin"===e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.providerLabel}),(0,s.jsxs)("div",{className:f().picker,ref:X,children:[(0,s.jsxs)("button",{className:f().providerTrigger,"data-open":S,onClick:()=>N(e=>!e),children:[Y?(0,s.jsx)(p,{id:Y.id,name:Y.name,size:34}):null,(0,s.jsxs)("span",{className:f().providerText,children:[(0,s.jsx)("span",{className:f().providerName,children:Y?.name??y.selectProvider}),Y?(0,s.jsx)("span",{className:f().providerMeta,children:Y.id}):null]}),(0,s.jsx)(n.Cd,{size:15})]}),S?(0,s.jsxs)("div",{className:f().menu,children:[(0,s.jsxs)("div",{className:f().searchWrap,children:[(0,s.jsx)("span",{className:f().searchIcon,children:(0,s.jsx)(n.FG,{size:15})}),(0,s.jsx)("input",{autoFocus:!0,className:f().search,value:k,onChange:e=>C(e.target.value),placeholder:y.searchProviders})]}),(0,s.jsxs)("div",{className:f().providerList,children:[et.map(e=>(0,s.jsxs)("button",{className:f().providerRow,"data-selected":e.id===w,onClick:()=>{j(e.id),z("api_key"),M(""),I(e.apis[0]??"openai-completions"),R(""),K([]),N(!1)},children:[(0,s.jsx)(p,{id:e.id,name:e.name,size:38}),(0,s.jsxs)("span",{className:f().providerText,children:[(0,s.jsx)("span",{className:f().providerName,children:e.name}),(0,s.jsxs)("span",{className:f().providerMeta,children:[e.id," \xb7 ",y.modelCount.replace("{count}",String(e.modelCount))]})]}),e.id===w?(0,s.jsx)("span",{className:f().selectedMark,children:(0,s.jsx)(n.df,{size:16})}):null]},e.id)),0===et.length?(0,s.jsx)("div",{className:f().empty,children:y.noProviderMatches}):null]})]}):null]})]}),Y?.authTypes.includes("oauth")&&v?(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.authMethod}),(0,s.jsxs)("select",{className:f().select,value:_,onChange:e=>z(e.target.value),children:[(0,s.jsx)("option",{value:"api_key",children:y.authMethodApiKey}),(0,s.jsx)("option",{value:"oauth",children:y.oauthLogin})]})]}):null,"api_key"===_?(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:Y?.apiKeyLabel??y.apiKey}),(0,s.jsx)("input",{className:f().input,type:"password",value:P,onChange:e=>M(e.target.value),placeholder:y.apiKeyOptional})]}):null,(0,s.jsxs)("div",{className:f().advanced,children:[(0,s.jsxs)("button",{className:f().advancedButton,"data-open":E,onClick:()=>T(e=>!e),children:[(0,s.jsx)(n.Cd,{size:15}),y.customSettings]}),E?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.apiAddress}),(0,s.jsx)("input",{className:f().input,value:$,onChange:e=>R(e.target.value),placeholder:Y?.baseUrl||y.providerDefault})]}),(0,s.jsx)(b,{models:U,setModels:K,updateModel:ea,inheritedCount:Y?.modelCount??0,catalogIds:ee,discover:ec,discoverDisabled:!$.trim()})]}):null]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.providerId}),(0,s.jsx)("input",{className:f().input,autoFocus:!0,value:D,onChange:e=>F(e.target.value.toLocaleLowerCase()),placeholder:"acme-gateway"}),(0,s.jsx)("div",{className:f().hint,children:y.providerIdHint}),el&&!er?(0,s.jsx)("div",{className:f().hint,style:{color:"var(--dsw-danger)"},children:y.providerIdInvalid}):null,el&&r.includes(el)?(0,s.jsx)("div",{className:f().hint,style:{color:"var(--dsw-danger)"},children:y.providerIdTaken}):null]}),(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.displayName}),(0,s.jsx)("input",{className:f().input,value:L,onChange:e=>A(e.target.value),placeholder:y.displayName})]}),(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.apiAddress}),(0,s.jsx)("input",{className:f().input,value:$,onChange:e=>R(e.target.value),onBlur:J,placeholder:"https://gateway.example/v1"})]}),(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.apiProtocol}),(0,s.jsx)("select",{className:f().select,value:O,onChange:e=>{I(e.target.value),J()},children:W.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("div",{className:f().field,children:[(0,s.jsx)("label",{className:f().label,children:y.apiKey}),(0,s.jsx)("input",{className:f().input,type:"password",value:P,onChange:e=>M(e.target.value),onBlur:J,placeholder:y.apiKeyOptional}),(0,s.jsx)("div",{className:f().hint,children:y.customApiKeyHint})]}),(0,s.jsx)(b,{models:U,setModels:K,updateModel:ea,discover:ec,discoverDisabled:!$.trim(),autoDiscover:B?{signature:`${$.trim()}|${O}|${P.trim()}`,privateHost:h($),trigger:H}:void 0})]}),G?(0,s.jsx)("div",{className:f().error,children:G}):null]}),(0,s.jsxs)("footer",{className:f().footer,children:[(0,s.jsx)("button",{className:f().footerButton,onClick:i,children:y.cancel}),(0,s.jsx)("button",{className:`${f().footerButton} ${f().primary}`,disabled:q||("builtin"===e?!en:!ei),onClick:ed,children:q?y.saving:"builtin"===e?y.save:y.createProvider})]})]})})}function b({models:e,setModels:t,updateModel:a,inheritedCount:r,catalogIds:i,discover:o,discoverDisabled:d,autoDiscover:c}){let{t:u}=(0,m.s)(),[p,h]=(0,l.useState)(new Set),[v,g]=(0,l.useState)(!1),[y,w]=(0,l.useState)(""),[j,S]=(0,l.useState)(!1),[N,k]=(0,l.useState)(null),[C,_]=(0,l.useState)(new Set),[z,P]=(0,l.useState)({}),M=(e,t,a)=>z[`${t}:${a}`]??(0,x.sm)(e[a]),E=(e,t,s)=>{P(a=>({...a,[`${e}:${t}`]:s})),a(e,{[t]:(0,x.KM)(s)})},T=e=>i?.has(e.trim())??!1,$=(0,l.useRef)(""),R=(0,l.useRef)(0),D=(0,l.useRef)(!1),F=(0,l.useRef)(0),[L,A]=(0,l.useState)(""),[W,O]=(0,l.useState)(0);(0,l.useEffect)(()=>{D.current&&(D.current=!1,R.current+=1,$.current="",A(""))},[c?.signature]),(0,l.useEffect)(()=>{if(!c||c.trigger===F.current||(F.current=c.trigger,!o||$.current===c.signature))return;$.current=c.signature,D.current=!0;let e=++R.current;A("loading");let a=t=>e===R.current&&(D.current=!1,A(t),!0);o(j||c.privateHost).then(e=>{a(e.length?"done":"empty")&&(O(e.length),t(t=>t.length?t:e))},()=>void a("failed"))},[c?.trigger]);let I=async()=>{if(o&&!v){D.current&&(D.current=!1,R.current+=1,$.current="",A("")),g(!0),w("");try{let t=await o(j);if(!t.length)return void w(u.discoverEmpty);let a=new Set(e.map(e=>e.id.trim()).filter(Boolean)),s=[...t.filter(e=>!T(e.id)),...t.filter(e=>T(e.id))];k(s),_(new Set(s.filter(e=>!a.has(e.id.trim())&&!T(e.id)).map(e=>e.id)))}catch(e){w(e instanceof Error?e.message:u.toastError)}finally{g(!1)}}},U=()=>{k(null),_(new Set)},K=N??[],B=K.filter(e=>!T(e.id)),H=B.length>0&&B.every(e=>C.has(e.id)),V=(0,x.aK)(e),J=e.some(e=>T(e.id));return(0,s.jsxs)("div",{className:f().catalog,children:[(0,s.jsxs)("div",{className:f().catalogHeader,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:f().label,children:u.modelCatalog}),(0,s.jsxs)("div",{className:f().catalogStatus,children:[r?u.usingDefaultModels.replace("{count}",String(r)):u.customModelsRequired,"loading"===L?` \xb7 ${u.autoDiscovering}`:null,"done"===L?` \xb7 ${u.autoDiscovered.replace("{n}",String(W))}`:null,"empty"===L?` \xb7 ${u.discoverEmpty}`:null,"failed"===L?` \xb7 ${u.autoDiscoverFailed}`:null]})]}),o?(0,s.jsxs)("div",{className:f().discoverControls,children:[(0,s.jsxs)("label",{className:f().allowPrivate,title:u.allowPrivateHint,children:[(0,s.jsx)("input",{type:"checkbox",checked:j,onChange:e=>S(e.target.checked)}),u.allowPrivateDiscovery]}),(0,s.jsx)("button",{className:f().discoverButton,disabled:d||v,onClick:()=>void I(),children:v?u.discoveringModels:u.discoverModels})]}):null]}),y?(0,s.jsx)("div",{className:f().catalogError,children:y}):null,e.length?(0,s.jsx)("div",{className:f().modelList,children:e.map((e,l)=>{let r=p.has(l),i=Number.isNaN(e.contextWindow)||Number.isNaN(e.maxTokens);return(0,s.jsxs)("div",{className:f().modelEntry,children:[(0,s.jsxs)("div",{className:f().modelRow,children:[(0,s.jsx)("button",{type:"button",className:f().rowToggle,title:u.capacityFields,onClick:()=>h(e=>{let t=new Set(e);return t.delete(l)||t.add(l),t}),children:(0,s.jsx)(n.Cd,{size:13,style:{transform:r?"rotate(0deg)":"rotate(-90deg)",transition:"transform 120ms ease"}})}),(0,s.jsx)("input",{className:f().input,style:{borderColor:e.id.trim()||V?.index!==l?void 0:"var(--dsw-danger)"},value:e.id,onChange:e=>a(l,{id:e.target.value}),placeholder:u.modelId}),(0,s.jsx)("input",{className:f().input,value:e.name,onChange:e=>a(l,{name:e.target.value}),placeholder:u.displayNameOptional}),(0,s.jsx)("button",{className:f().removeModel,title:u.delete,onClick:()=>{t(e=>e.filter((e,t)=>t!==l)),h(e=>{let t=new Set;for(let a of e)a!==l&&t.add(a>l?a-1:a);return t}),P(e=>{let t={};for(let[a,s]of Object.entries(e)){let e=Number(a.slice(0,a.indexOf(":")));e!==l&&(t[e>l?`${e-1}${a.slice(a.indexOf(":"))}`:a]=s)}return t})},children:(0,s.jsx)(n.Vd,{size:15})})]}),r?(0,s.jsxs)("div",{className:f().capacityRow,children:[(0,s.jsxs)("label",{className:f().capacityField,children:[(0,s.jsx)("span",{children:u.contextWindowLabel}),(0,s.jsx)("input",{className:f().input,style:{borderColor:Number.isNaN(e.contextWindow)?"var(--dsw-danger)":void 0},value:M(e,l,"contextWindow"),onChange:e=>E(l,"contextWindow",e.target.value),placeholder:"128K"})]}),(0,s.jsxs)("label",{className:f().capacityField,children:[(0,s.jsx)("span",{children:u.maxTokensLabel}),(0,s.jsx)("input",{className:f().input,style:{borderColor:Number.isNaN(e.maxTokens)?"var(--dsw-danger)":void 0},value:M(e,l,"maxTokens"),onChange:e=>E(l,"maxTokens",e.target.value),placeholder:"16K"})]}),(0,s.jsxs)("label",{className:f().capacityField,title:u.visionHint,children:[(0,s.jsx)("span",{children:u.visionLabel}),(0,s.jsxs)("select",{className:f().input,value:void 0===e.vision?"unset":e.vision?"image":"text",onChange:e=>{let t=e.target.value;a(l,{vision:"unset"===t?void 0:"image"===t})},children:[(0,s.jsx)("option",{value:"unset",children:u.visionUnset}),(0,s.jsx)("option",{value:"image",children:u.visionOn}),(0,s.jsx)("option",{value:"text",children:u.visionOff})]})]}),(0,s.jsx)("span",{className:f().capacityHint,children:u.capacityHint})]}):null,i?(0,s.jsx)("div",{className:f().rowError,children:u.capacityInvalid.replace("{n}",String(l+1))}):null]},l)})}):(0,s.jsx)("div",{className:f().modelEmpty,children:r?u.modelCatalogEmptyBuiltin:u.modelCatalogEmptyCustom}),J?(0,s.jsx)("div",{className:f().catalogHint,children:u.catalogOverrideHint}):null,(0,s.jsxs)("button",{className:f().addModel,onClick:()=>t(e=>[...e,{id:"",name:""}]),children:[(0,s.jsx)(n.Xh,{size:14}),u.addModel]}),N?(0,s.jsx)("div",{className:f().candidateMask,children:(0,s.jsxs)("div",{className:f().candidateDialog,role:"dialog","aria-modal":"true","aria-label":u.discoverModels,children:[(0,s.jsx)("div",{className:f().candidateHeader,children:(0,s.jsx)("span",{children:u.candidateTitle.replace("{count}",String(N.length))})}),(0,s.jsxs)("div",{className:f().candidateList,children:[K.map(e=>{let t=T(e.id);return(0,s.jsxs)("label",{className:f().candidateRow,"data-disabled":t||void 0,children:[(0,s.jsx)("input",{type:"checkbox",checked:!t&&C.has(e.id),disabled:t,onChange:()=>{let t;return t=e.id,_(e=>{let a=new Set(e);return a.delete(t)||a.add(t),a})}}),(0,s.jsx)("span",{className:f().candidateId,children:e.id}),e.name?(0,s.jsx)("span",{className:f().candidateName,children:e.name}):null,t?(0,s.jsx)("span",{className:f().candidateTag,children:u.candidateInCatalog}):null]},e.id)}),0===K.length?(0,s.jsx)("div",{className:f().modelEmpty,children:"—"}):null]}),(0,s.jsxs)("div",{className:f().candidateActions,children:[(0,s.jsxs)("label",{className:f().candidateAll,children:[(0,s.jsx)("input",{type:"checkbox",checked:H,disabled:0===B.length,onChange:()=>_(e=>{let t=new Set(e);return B.every(e=>t.has(e.id))?B.forEach(e=>t.delete(e.id)):B.forEach(e=>t.add(e.id)),t})}),u.candidateAll]}),(0,s.jsx)("span",{className:f().candidatePicked,children:u.candidatePicked.replace("{n}",String(C.size))}),(0,s.jsx)("button",{className:f().footerButton,onClick:U,children:u.cancel}),(0,s.jsx)("button",{className:`${f().footerButton} ${f().primary}`,disabled:0===C.size,onClick:()=>{N&&(t(e=>{let t=new Map(e.map(e=>[e.id.trim(),e]));for(let e of N){let a=e.id.trim();!a||!C.has(a)||t.has(a)||T(a)||t.set(a,e)}return[...t.values()]}),U())},children:u.candidateAdopt.replace("{n}",String(C.size))})]})]})}):null]})}var y=a(8155);function w({tone:e}){return(0,s.jsx)("span",{className:"inline-block h-[7px] w-[7px] flex-none rounded-full",style:{background:"on"===e?"var(--dsw-success)":"pending"===e?"var(--dsw-accent)":"var(--dsw-label-caption)"}})}function j({title:e,hint:t,children:a}){return(0,s.jsxs)("div",{className:"hairline-b flex flex-wrap items-start justify-between gap-4 pb-5",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",style:{minWidth:"45%"},children:[(0,s.jsx)("div",{style:{fontSize:14},children:e}),t?(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-label-caption)",lineHeight:1.55,marginTop:2},children:t}):null]}),(0,s.jsx)("div",{className:"flex-none",children:a})]})}function S({url:e,token:t}){let{t:a}=(0,m.s)(),[r,i]=(0,l.useState)("");(0,l.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(""),2e3);return()=>clearTimeout(e)},[r]);let n=t?`${e.replace(/\/+$/,"")}/?token=${encodeURIComponent(t)}`:e;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-mono hover:underline",style:{fontSize:12},children:e}),(0,s.jsx)("button",{type:"button",className:"btn-outline",style:{height:24,fontSize:12,paddingInline:8},onClick:()=>void(0,y.D)(n).then(e=>i(e?"ok":"fail")),children:"ok"===r?a.remoteLinkCopied:"fail"===r?a.copyFailed:a.copy})]})}function N(){let{t:e}=(0,m.s)(),[t,a]=(0,l.useState)(null),[r,i]=(0,l.useState)(!1),[n,o]=(0,l.useState)(""),d=(0,l.useRef)(!0),c=(0,l.useCallback)(async()=>{try{let t=await fetch("/api/remote",{cache:"no-store"}),s=await t.json();if(!d.current)return;s?.success?(a(s.data),o("")):o(s?.error??e.remoteFailed)}catch{d.current&&o(e.remoteFailed)}},[e]);(0,l.useEffect)(()=>(d.current=!0,c(),()=>{d.current=!1}),[c]);let u=!!(t?.public.running&&!t.public.ready);(0,l.useEffect)(()=>{if(!u)return;let e=setInterval(()=>void c(),2500);return()=>clearInterval(e)},[u,c]);let p=async t=>{if(!r){i(!0),o("");try{let s=await fetch("/api/remote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t})}),l=await s.json();l?.success?a(l.data):o(l?.error??e.remoteFailed)}catch{o(e.remoteFailed)}finally{d.current&&i(!1)}}},[h,x]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!h)return;let e=setTimeout(()=>x(!1),4e3);return()=>clearTimeout(e)},[h]);let v=async()=>{if(!h)return void x(!0);x(!1),o("");try{let t=await fetch("/api/web-auth?scope=all",{method:"DELETE"}),a=await t.json().catch(()=>null);if(!t.ok||!a?.success)throw Error(a?.error??e.remoteFailed);window.location.href="/login"}catch(t){d.current&&o(t instanceof Error?t.message:e.remoteFailed)}},f=t?.lan,g=t?.public,b=t?.blocked??null,y=f?.running?"on":"off",N=g?.running?g.ready?"on":"pending":"off";return(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("div",{style:{fontSize:15,fontWeight:500},children:e.setRemote}),(0,s.jsx)("span",{className:"rounded-md px-2 py-[2px]",style:{fontSize:11,background:"var(--dsw-hover)",color:"var(--dsw-label-secondary)"},children:e.remoteBuiltin})]}),(0,s.jsx)(j,{title:e.remoteLanTitle,hint:e.remoteLanHint,children:(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",style:{fontSize:13},children:[(0,s.jsx)(w,{tone:y}),(0,s.jsx)("span",{style:{color:f?.running?"var(--dsw-label-primary)":"var(--dsw-label-caption)"},children:f?.running?e.remoteRunning:e.remoteStopped})]}),(f?.urls??[]).map(e=>(0,s.jsx)(S,{url:e,token:t?.loginToken},e)),f?.error?(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-danger)"},children:f.error}):null]})}),(0,s.jsx)(j,{title:e.remotePublicTitle,hint:e.remotePublicHint,children:(0,s.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",style:{fontSize:13},children:[(0,s.jsx)(w,{tone:N}),(0,s.jsx)("span",{style:{color:g?.running?"var(--dsw-label-primary)":"var(--dsw-label-caption)"},children:g?.running?g.ready?e.remoteRunning:e.remotePending:e.remoteStopped})]}),g?.url?(0,s.jsx)(S,{url:g.url,token:t?.loginToken}):null,(0,s.jsx)("div",{className:"flex items-center gap-2",children:g?.running?(0,s.jsx)("button",{className:"btn-outline",style:{height:30,fontSize:13},disabled:r,onClick:()=>void p("stop"),children:e.remoteStop}):(0,s.jsx)("button",{className:"btn-primary-white",style:{height:30,fontSize:13},disabled:r||null!==b,onClick:()=>void p("start"),children:r?e.remoteWorking:e.remoteStart})})]})}),t&&"auth"!==b?(0,s.jsx)(j,{title:e.remoteSessionsTitle,hint:e.remoteSessionsHint,children:(0,s.jsx)("button",{className:"btn-outline",style:{height:30,fontSize:13,color:h?"var(--dsw-danger)":void 0},onClick:()=>void v(),children:h?e.remoteSignOutAllConfirm:e.remoteSignOutAll})}):null,b?(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-label-secondary)",lineHeight:1.6},children:"auth"===b?e.remoteBlockedAuth:e.remoteBlockedDev}):null,g&&!g.engineAvailable?(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-danger)",lineHeight:1.6},children:e.remoteEngineMissing}):null,g?.error?(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-danger)",lineHeight:1.6},children:g.error}):null,n?(0,s.jsx)("div",{role:"alert",style:{fontSize:12,color:"var(--dsw-danger)"},children:n}):null]})}var k=a(826),C=a(9591),_=a(3364),z=a(6540),P=a(922),M=a(6972);let E=["xai","openai-codex","anthropic","deepseek","openrouter","moonshotai","moonshotai-cn","kimi-coding","github-copilot","vercel-ai-gateway","opencode-go"];function T(e){return E.includes(e)}function $({open:e,onClose:t,cwd:a,toolPreset:r,onToolPresetChange:i,tools:o,onSetTools:d,onOpenFileContent:c}){let{t:u,lang:p,setLang:h}=(0,m.s)(),[x,v]=(0,l.useState)("general");if((0,l.useEffect)(()=>{if(!e)return;let a=e=>{"Escape"!==e.key||document.querySelector('[data-provider-modal="true"]')||t()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t]),!e)return null;let f=[{id:"general",label:u.setGeneral,icon:(0,s.jsx)(n.Ec,{size:15})},{id:"models",label:u.setModels,icon:(0,s.jsx)(n.se,{size:15})},{id:"tools",label:u.toolsSection,icon:(0,s.jsx)(n.DI,{size:15})},{id:"plugins",label:u.setPlugins,icon:(0,s.jsx)(n.q2,{size:15})},{id:"skills",label:u.setSkills,icon:(0,s.jsx)(n.i7,{size:15})},{id:"remote",label:u.setRemote,icon:(0,s.jsx)(n.an,{size:15})}];return(0,s.jsx)("div",{className:"modal-mask fixed inset-0 z-[100] flex items-center justify-center",onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,s.jsxs)("div",{className:"settings-dialog glass-modal flex overflow-hidden",style:{width:800,maxWidth:"calc(100vw - 48px)",height:"min(800px, calc(100vh - 48px))",borderRadius:32,boxShadow:"var(--dsw-elevation-prominent)"},children:[(0,s.jsxs)("div",{className:"settings-nav flex w-52 flex-none flex-col gap-0.5 py-4 pl-4 pr-3",children:[(0,s.jsx)("div",{className:"settings-title px-2 pb-3",style:{fontSize:16,fontWeight:500},children:u.settings}),f.map(e=>(0,s.jsxs)("button",{className:"flex h-[42px] items-center gap-2 rounded-xl px-3 text-left transition-colors",style:{paddingLeft:8,paddingRight:10,fontSize:14,background:x===e.id?"var(--dsw-active)":"transparent",color:x===e.id?"var(--dsw-label-primary)":"var(--dsw-label-secondary)"},onMouseEnter:t=>{x!==e.id&&(t.currentTarget.style.background="var(--dsw-hover)")},onMouseLeave:t=>{x!==e.id&&(t.currentTarget.style.background="transparent")},onClick:()=>v(e.id),children:[x===e.id?(0,s.jsx)("span",{style:{color:"var(--dsw-accent)"},children:e.icon}):e.icon,e.label]},e.id))]}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-6 py-3.5",children:[(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("button",{className:"btn-outline",style:{height:32,fontSize:13},onClick:()=>window.open("/api/config","_blank"),children:[(0,s.jsx)(n.FQ,{size:14})," ",u.openConfigFile]}),(0,s.jsx)("button",{className:"icon-btn",onClick:t,children:(0,s.jsx)(n.Bh,{size:15})})]}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:["general"===x&&(0,s.jsx)(R,{lang:p,setLang:h}),"models"===x&&(0,s.jsx)(B,{}),"skills"===x&&(0,s.jsx)(G,{cwd:a,onOpenFileContent:c}),"tools"===x&&(0,s.jsx)(Q,{toolPreset:r,onToolPresetChange:i,tools:o,onSetTools:d}),"plugins"===x&&(0,s.jsx)(Z,{cwd:a}),"remote"===x&&(0,s.jsx)(N,{})]})]})]})})}function R({lang:e,setLang:t}){let{t:a}=(0,m.s)(),[r,o]=(0,l.useState)("dsh"),[d,c]=(0,l.useState)("system"),[u,p]=(0,l.useState)(14),[h,x]=(0,l.useState)(14),[v,f]=(0,l.useState)(M.$n),[g,b]=(0,l.useState)("steer"),[y,w]=(0,l.useState)(null),[j,S]=(0,l.useState)(null),[N,k]=(0,l.useState)(null),[C,_]=(0,l.useState)(!0),[P,E]=(0,l.useState)(!1),[T,$]=(0,l.useState)(null),[U,K]=(0,l.useState)({reserveTokens:"",keepRecentTokens:"",maxRetries:"",baseDelayMs:""}),B=async()=>{_(!0),$(null);let e=async e=>{let t=await fetch(e),a=await t.json();if(!t.ok||!a.success)throw Error(a.error||`request failed (${t.status})`);return a.data},[t,a,s,l]=await Promise.allSettled([e("/api/security"),e("/api/pi-settings"),e("/api/version"),e("/api/web-auth")]);"fulfilled"===a.status?(w(a.value),K({reserveTokens:String(a.value.compaction.reserveTokens),keepRecentTokens:String(a.value.compaction.keepRecentTokens),maxRetries:String(a.value.retry.maxRetries),baseDelayMs:String(a.value.retry.baseDelayMs)})):w(null),"fulfilled"===s.status&&s.value?.piWeb?S({piWeb:s.value.piWeb,piEngine:s.value.piEngine}):S(null),"fulfilled"===l.status&&"boolean"==typeof l.value?.enabled?k({enabled:l.value.enabled,authenticated:!0===l.value.authenticated}):k(null),[t,a,s].some(e=>"rejected"===e.status)&&$("load"),_(!1)};(0,l.useEffect)(()=>{o((0,z.m6)()),c((0,z.Xf)());let e=parseInt(localStorage.getItem("piweb.fontSize")??"14",10);Number.isNaN(e)||p(e);let t=parseInt(localStorage.getItem("piweb.chatFontSize")??"14",10);Number.isNaN(t)||x(t),f((0,M.Kx)()),b((0,i.$h)()),B()},[]);let H=e=>f((0,M.Iy)(e)),V=async e=>{if(!y||P)return!1;E(!0),$(null);try{let t=await fetch("/api/pi-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok||!a.success)throw Error(a.error||"save failed");return w(a.data),!0}catch{return $("save"),!1}finally{E(!1)}},J=async(e,t)=>{if(!y)return;let a=U[t].trim(),s=Number(a);!a||!Number.isSafeInteger(s)||s<0||s>1e9?$("save"):s!==y[e][t]&&await V({[e]:{[t]:s}})},q=(e,t,a)=>(0,s.jsx)("input",{type:"number",min:0,value:U[t],disabled:!y||C||P,onChange:e=>K(a=>({...a,[t]:e.target.value})),onBlur:()=>void J(e,t),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"rounded-lg px-2 py-1",title:a,style:{width:90,textAlign:"right",background:"var(--dsw-hover)"}}),Q=[{id:"dsh",label:a.themeDsh,light:"#F9FAFB",dark:"#151517",accent:"#4176E6"},{id:"silver-steel",label:a.themeSilverSteel,light:"#F3F4F6",dark:"#1A1C24",accent:"#94A3B8"},{id:"limestone-coal",label:a.themeLimestoneCoal,light:"#F0EFEB",dark:"#171717",accent:"#CEB27E"},{id:"linen-moss",label:a.themeLinenMoss,light:"#F2F2EC",dark:"#1E211E",accent:"#A3B3A3"},{id:"nord-paper",label:a.themeNordPaper,light:"#FCFBF9",dark:"#2E3440",accent:"#88C0D0"},{id:"pebrel",label:a.themePebrel,light:"#F3F4F6",dark:"#0F111A",accent:"#52A8FF"}],G={smooth:{label:a.streamStyleSmooth,desc:a.streamStyleSmoothDesc},typewriter:{label:a.streamStyleTypewriter,desc:a.streamStyleTypewriterDesc},fade:{label:a.streamStyleFade,desc:a.streamStyleFadeDesc},instant:{label:a.streamStyleInstant,desc:a.streamStyleInstantDesc}},Z={1:a.streamSpeed1,2:a.streamSpeed2,3:a.streamSpeed3,4:a.streamSpeed4,5:a.streamSpeed5};return(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(C||T)&&(0,s.jsxs)("div",{role:T?"alert":"status",className:"flex items-center gap-3 rounded-lg px-3 py-2",style:{background:"var(--dsw-hover)",color:T?"var(--dsw-danger)":"var(--dsw-label-secondary)"},children:[(0,s.jsx)("span",{className:"flex-1",children:"load"===T?a.settingsLoadFailed:"save"===T?a.settingsSaveFailed:a.settingsLoading}),"load"===T&&(0,s.jsx)("button",{type:"button",className:"pw-chip",onClick:()=>void B(),children:a.settingsRetry})]}),(0,s.jsx)(A,{title:a.language,children:(0,s.jsx)(L,{value:e,options:[{value:"zh",label:"中文"},{value:"en",label:"English"}],onChange:e=>t(e)})}),(0,s.jsx)(W,{title:a.appearance,children:(0,s.jsx)("div",{className:"flex w-full flex-wrap gap-2",children:Q.map(e=>(0,s.jsxs)("button",{className:"flex flex-col items-center justify-center gap-1 transition-colors",style:{flex:"1 1 150px",padding:"20px 32px",borderRadius:20,border:`0.5px solid ${r===e.id?"var(--dsw-border-strong)":"var(--dsw-border-l4)"}`,background:r===e.id?"var(--dsw-module-platform)":"transparent",color:"var(--dsw-label-primary)",fontSize:14,lineHeight:"22px"},"aria-pressed":r===e.id,onClick:()=>{var t;o(t=e.id),(0,z.kK)(t,d)},children:[(0,s.jsxs)("span",{className:"flex items-center overflow-hidden rounded-md",style:{border:"0.5px solid var(--dsw-border-l3)",width:42,height:20},children:[(0,s.jsx)("span",{style:{background:e.light,flex:1,height:"100%"}}),(0,s.jsx)("span",{style:{background:e.dark,flex:1,height:"100%"}})]}),(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"inline-block rounded-full",style:{width:8,height:8,background:e.accent}}),e.label]})]},e.id))})}),(0,s.jsx)(W,{title:a.appearanceMode,children:(0,s.jsx)("div",{className:"flex w-full flex-wrap gap-2",children:[{id:"light",label:a.themeLight},{id:"dark",label:a.themeDark},{id:"system",label:a.themeSystem}].map(e=>(0,s.jsx)("button",{className:"flex flex-col items-center justify-center gap-1 transition-colors",style:{flex:"1 1 120px",padding:"16px 24px",borderRadius:20,border:`0.5px solid ${d===e.id?"var(--dsw-border-strong)":"var(--dsw-border-l4)"}`,background:d===e.id?"var(--dsw-module-platform)":"transparent",color:"var(--dsw-label-primary)",fontSize:14,lineHeight:"22px"},"aria-pressed":d===e.id,onClick:()=>{var t;c(t=e.id),(0,z.kK)(r,t)},children:e.label},e.id))})}),(0,s.jsx)(A,{title:a.fontUiSize,desc:a.fontUiSizeDesc,children:(0,s.jsx)(O,{value:u,onChange:e=>{let t=Math.max(12,Math.min(18,e));p(t),localStorage.setItem("piweb.fontSize",String(t)),document.documentElement.style.setProperty("--dsh-content-font-size",`${t}px`),document.documentElement.style.setProperty("--dsh-content-font-delta",`${t-14}px`)},max:18})}),(0,s.jsx)(A,{title:a.fontChatSize,desc:a.fontChatSizeDesc,children:(0,s.jsx)(O,{value:h,onChange:e=>{let t=Math.max(12,Math.min(20,e));x(t),localStorage.setItem("piweb.chatFontSize",String(t)),document.documentElement.style.setProperty("--piweb-chat-font-size",`${t}px`)},max:20})}),(0,s.jsx)(A,{title:a.fontUiFamily,desc:a.fontUiFamilyDesc,children:(0,s.jsx)(I,{scope:"ui"})}),(0,s.jsx)(A,{title:a.fontMonoFamily,desc:a.fontMonoFamilyDesc,children:(0,s.jsx)(I,{scope:"mono"})}),(0,s.jsx)(W,{title:a.streamStyleTitle,desc:a.streamStyleDesc,children:(0,s.jsx)("div",{className:"flex w-full flex-wrap gap-2",children:M.ie.map(e=>{let t=v.style===e;return(0,s.jsxs)("button",{type:"button",className:"flex flex-col items-start gap-1 text-left transition-colors",style:{flex:"1 1 150px",padding:"12px 16px",borderRadius:14,border:`0.5px solid ${t?"var(--dsw-border-strong)":"var(--dsw-border-l4)"}`,background:t?"var(--dsw-module-platform)":"transparent",color:"var(--dsw-label-primary)",lineHeight:"18px"},"aria-pressed":t,onClick:()=>H({style:e}),children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",style:{fontSize:14},children:[t?(0,s.jsx)(n.df,{size:13}):null,G[e].label]}),(0,s.jsx)("span",{style:{fontSize:11.5,color:"var(--dsw-label-caption)"},children:G[e].desc})]},e)})})}),(0,s.jsx)(W,{title:a.streamSpeedTitle,desc:a.streamSpeedDesc,children:(0,s.jsx)("div",{className:"flex w-full flex-wrap gap-2",children:Array.from({length:M.kh-M.QW+1},(e,t)=>M.QW+t).map(e=>{let t=v.speed===e;return(0,s.jsx)("button",{type:"button",className:"transition-colors disabled:opacity-50",disabled:"instant"===v.style,style:{flex:"1 1 84px",padding:"10px 8px",borderRadius:12,border:`0.5px solid ${t?"var(--dsw-border-strong)":"var(--dsw-border-l4)"}`,background:t?"var(--dsw-module-platform)":"transparent",color:t?"var(--dsw-label-primary)":"var(--dsw-label-secondary)",fontSize:13},"aria-pressed":t,onClick:()=>H({speed:e}),children:Z[e]},e)})})}),(0,s.jsx)(A,{title:a.streamCaretTitle,desc:a.streamCaretDesc,children:(0,s.jsx)("button",{type:"button",className:"relative h-5 w-9 flex-none rounded-full transition-colors",style:{background:v.caret?"var(--dsw-accent)":"var(--dsw-border-l3)"},role:"switch","aria-checked":v.caret,"aria-label":a.streamCaretTitle,onClick:()=>H({caret:!v.caret}),children:(0,s.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all",style:{left:v.caret?18:2}})})}),(0,s.jsx)(A,{title:a.enterBehavior,desc:a.enterBehaviorDesc,children:(0,s.jsx)(L,{value:g,options:[{value:"steer",label:a.enterSteer},{value:"queue",label:a.enterQueue}],onChange:e=>{b(e),(0,i.vf)(e)}})}),(0,s.jsx)(A,{title:a.autoCompact,desc:a.autoCompactDesc,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{disabled:!y||P,className:"relative h-5 w-9 flex-none rounded-full transition-colors",style:{background:y?.compaction.enabled?"var(--dsw-accent)":"var(--dsw-border-l3)"},role:"switch","aria-checked":y?.compaction.enabled??!1,onClick:()=>void V({compaction:{enabled:!y?.compaction.enabled}}),children:(0,s.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all",style:{left:y?.compaction.enabled?18:2}})}),q("compaction","reserveTokens",a.reserveTokens),q("compaction","keepRecentTokens",a.keepRecentTokens)]})}),(0,s.jsx)(A,{title:a.autoRetry,desc:a.autoRetryDesc,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{disabled:!y||P,className:"relative h-5 w-9 flex-none rounded-full transition-colors",style:{background:y?.retry.enabled?"var(--dsw-accent)":"var(--dsw-border-l3)"},role:"switch","aria-checked":y?.retry.enabled??!1,onClick:()=>void V({retry:{enabled:!y?.retry.enabled}}),children:(0,s.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all",style:{left:y?.retry.enabled?18:2}})}),q("retry","maxRetries",a.maxRetries),q("retry","baseDelayMs",a.baseDelayMs)]})}),(0,s.jsx)(A,{title:a.versionPiweb,desc:a.versionPiwebDesc,children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)(D,{href:"https://github.com/RexVane/PiWeb",value:j?.piWeb}),(0,s.jsx)(F,{target:"piweb"})]})}),(0,s.jsx)(A,{title:a.versionPi,desc:a.versionPiDesc,children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)(D,{href:"https://github.com/earendil-works/pi",value:j?.piEngine}),(0,s.jsx)(F,{target:"pi"})]})}),N?.enabled?(0,s.jsx)(A,{title:a.webAuth,desc:a.webAuthTokenOn,children:(0,s.jsx)("button",{className:"btn-outline",style:{height:30,padding:"0 14px",fontSize:12.5},onClick:async()=>{await fetch("/api/web-auth",{method:"DELETE"}).catch(()=>{}),window.location.href="/login"},children:a.logout})}):null]})}function D({href:e,value:t}){return(0,s.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",style:{fontFamily:"var(--font-mono)",fontSize:13,color:"var(--dsw-label-secondary)",textDecoration:"none"},onMouseEnter:e=>e.currentTarget.style.color="var(--dsw-accent)",onMouseLeave:e=>e.currentTarget.style.color="var(--dsw-label-secondary)",children:t??"—"})}function F({target:e}){let{t}=(0,m.s)(),{phase:a,latest:r,command:i,error:n,busy:o}=(0,C.M)().targets[e];if((0,l.useEffect)(()=>{(0,C.fT)()},[]),"idle"===a||"latest"===a||"error"===a){let l="latest"===a?t.upToDate:"error"===a?o?t.updateBusy:t.updateFailed:t.checkUpdate;return(0,s.jsx)("button",{type:"button",className:"btn-outline",style:{height:26,padding:"0 10px",fontSize:12,color:"latest"===a?"var(--dsw-label-tertiary)":"error"===a?"var(--dsw-danger)":"var(--dsw-label-primary)"},title:n||void 0,disabled:"checking"===a||"updating"===a,onClick:()=>void(0,C.Ug)(e),children:l})}return"available"===a?i?(0,s.jsxs)("span",{className:"flex flex-col items-end gap-0.5",style:{maxWidth:300},children:[(0,s.jsx)(k.H,{command:i}),(0,s.jsx)("span",{style:{fontSize:11,color:"var(--dsw-label-tertiary)",textAlign:"right"},children:t.updateManualHint})]}):(0,s.jsx)("button",{type:"button",className:"btn-primary-white",style:{height:26,padding:"0 12px",fontSize:12},onClick:()=>void(0,C.PG)(e),children:t.updateTo.replace("{v}",r)}):"updated"===a?(0,s.jsxs)("span",{className:"flex flex-col items-end gap-0.5",style:{maxWidth:280,textAlign:"right"},children:[(0,s.jsx)("span",{style:{fontSize:12,color:"var(--dsw-success)"},children:t.updatedTo.replace("{v}",r)}),(0,s.jsx)("span",{style:{fontSize:11,color:"var(--dsw-label-tertiary)"},children:t.updateRestartHint})]}):(0,s.jsxs)("span",{className:"flex items-center gap-1.5",style:{fontSize:12,color:"var(--dsw-label-tertiary)"},children:[(0,s.jsx)("span",{className:"h-3 w-3 flex-none animate-spin rounded-full border-2 border-current border-t-transparent"}),"updating"===a?t.updatingNow:t.checkingUpdate]})}function L({value:e,options:t,onChange:a,width:i,disabled:o}){let[d,c]=(0,l.useState)(!1),[u,p]=(0,l.useState)(null),m=(0,l.useRef)(null),h=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!d)return;let e=m.current?.getBoundingClientRect();e&&p({left:e.left,top:e.bottom+6,bottom:e.top-6});let t=e=>{m.current?.contains(e.target)||h.current?.contains(e.target)||c(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[d]),(0,l.useEffect)(()=>{o&&c(!1)},[o]);let x=t.find(t=>t.value===e);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{ref:m,className:"select-chip","data-open":d,disabled:o,onClick:()=>c(e=>!e),children:[x?.label??e,(0,s.jsx)("span",{className:"chevron",children:(0,s.jsx)(n.Cd,{size:14})})]}),d&&!o&&u&&(0,r.createPortal)((0,s.jsx)("div",{ref:h,className:"popover fixed z-[130] p-1.5 shadow-xl",style:{left:u.left,top:Math.min(u.top,window.innerHeight-40),minWidth:i??140,width:"max-content",maxHeight:280,overflowY:"auto"},children:t.map(t=>{let l=t.value===e;return(0,s.jsxs)("button",{className:"flex w-full items-center justify-between gap-3 rounded-xl px-3.5 py-2 text-left transition-colors",style:{background:l?"var(--dsw-accent-soft)":"transparent"},onMouseEnter:e=>{l||(e.currentTarget.style.background="var(--dsw-hover)")},onMouseLeave:e=>{l||(e.currentTarget.style.background="transparent")},onClick:()=>{a(t.value),c(!1)},children:[(0,s.jsx)("span",{style:{fontSize:13.5,color:l?"var(--dsw-accent)":"var(--dsw-label-primary)",whiteSpace:"nowrap"},children:t.label}),l&&(0,s.jsx)("span",{style:{display:"inline-flex",color:"var(--dsw-accent)",flex:"none"},children:(0,s.jsx)(n.df,{size:14})})]},t.value)})}),document.body)]})}function A({title:e,desc:t,children:a}){return(0,s.jsxs)("div",{className:"hairline-b flex items-center justify-between gap-6 pb-5",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{style:{fontSize:14,fontWeight:400},children:e}),t&&(0,s.jsx)("div",{className:"mt-0.5",style:{fontSize:12,color:"var(--dsw-label-caption)"},children:t})]}),(0,s.jsx)("div",{className:"flex-none",children:a})]})}function W({title:e,desc:t,children:a}){return(0,s.jsxs)("div",{className:"hairline-b flex flex-col gap-3 pb-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontSize:14,fontWeight:400},children:e}),t&&(0,s.jsx)("div",{className:"mt-0.5",style:{fontSize:12,color:"var(--dsw-label-caption)"},children:t})]}),a]})}function O({value:e,onChange:t,max:a}){return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{className:"icon-btn",style:{width:26,height:26,border:"0.5px solid var(--dsw-border-l3)",borderRadius:8},disabled:e<=12,onClick:()=>t(e-1),"aria-label":"decrease font size",children:"−"}),(0,s.jsxs)("button",{style:{minWidth:48,textAlign:"center",fontSize:13,color:14===e?"var(--dsw-label-tertiary)":"var(--dsw-label-primary)"},title:"reset",onClick:()=>t(14),children:[e," px"]}),(0,s.jsx)("button",{className:"icon-btn",style:{width:26,height:26,border:"0.5px solid var(--dsw-border-l3)",borderRadius:8},disabled:e>=a,onClick:()=>t(e+1),"aria-label":"increase font size",children:"+"})]})}function I({scope:e}){let{t,lang:a}=(0,m.s)(),[r,i]=(0,l.useState)(null),[n,o]=(0,l.useState)(""),[d,c]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let t=(0,P.ll)(e),a=t?.startsWith(P.D8)?t.slice(P.D8.length):null;i(t),c(null!==a),o(a??"")},[e]);let u=t=>{o(t);let a=t.trim()?P.D8+t.trim():null;i(a),(0,P.di)(e,a)},p=d?P.D8:r??P.Z$[e][0].id;return(0,s.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,s.jsx)(L,{value:p,width:220,options:[...P.Z$[e].map(e=>({value:e.id,label:"zh"===a?e.label.zh:e.label.en})),{value:P.D8,label:t.fontCustom}],onChange:t=>{if(t===P.D8){c(!0),u(n);return}c(!1),i(t),(0,P.di)(e,t)}}),d&&(0,s.jsx)("input",{value:n,onChange:e=>u(e.target.value),placeholder:t.fontCustomPlaceholder,style:{height:30,width:260,padding:"0 10px",fontSize:13,background:"var(--dsw-input-major)",border:"0.5px solid var(--dsw-border-l3)",borderRadius:8,color:"var(--dsw-label-primary)"}})]})}let U={contextWindow:"",maxTokens:"",vision:""};function K({gaps:e,providerLabel:t,busy:a,onSave:r}){let{t:i}=(0,m.s)(),[o,d]=(0,l.useState)({}),c=e=>`${e.provider}\0${e.index}`,u=e=>o[c(e)]??U,p=(e,t)=>d(a=>({...a,[c(e)]:{...a[c(e)]??U,...t}})),h=e.filter(e=>e.missing.includes("input")),v=e=>d(t=>{let a={...t};for(let t of h)a[c(t)]={...a[c(t)]??U,vision:e};return a}),f=!1,g=[];for(let t of e){let e=o[c(t)];if(!e)continue;let a=t.missing.includes("contextWindow")?(0,x.KM)(e.contextWindow):void 0,s=t.missing.includes("maxTokens")?(0,x.KM)(e.maxTokens):void 0;if(Number.isNaN(a)||Number.isNaN(s)){f=!0;continue}let l=t.missing.includes("input")&&e.vision?"image"===e.vision:void 0;(void 0!==a||void 0!==s||void 0!==l)&&g.push({provider:t.provider,index:t.index,id:t.id,contextWindow:a,maxTokens:s,vision:l})}let b=async()=>{await r(g)&&d({})},y=(e,t,l)=>{if(!e.missing.includes(t))return(0,s.jsxs)("span",{className:"truncate",style:{fontFamily:"var(--font-mono)",color:"var(--dsw-label-secondary)"},children:[(0,s.jsxs)("span",{className:"sm:hidden",style:{color:"var(--dsw-label-caption)"},children:[l," "]}),(0,x.sm)(e[t])||"—"]});let r=u(e)[t];return(0,s.jsx)("input",{className:"pw-audit-field",style:{fontFamily:"var(--font-mono)"},value:r,onChange:a=>p(e,{[t]:a.target.value}),placeholder:l,"aria-label":`${e.id} ${l}`,"aria-invalid":Number.isNaN((0,x.KM)(r))||void 0,disabled:a})};return(0,s.jsxs)("section",{className:"flex flex-col gap-3 rounded-2xl p-4",style:{border:"0.5px solid var(--dsw-border-l3)",background:"var(--dsw-hover)"},"data-testid":"model-audit",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)(n.PP,{size:16,style:{flex:"none",marginTop:1,color:"var(--dsw-warn)"}}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{style:{fontSize:13.5,fontWeight:600},children:i.modelAuditTitle.replace("{n}",String(e.length))}),(0,s.jsx)("div",{className:"mt-1",style:{fontSize:12,color:"var(--dsw-label-caption)",lineHeight:1.65},children:i.modelAuditDesc.replace("{ctx}",(0,x.sm)(x.C.contextWindow)).replace("{out}",(0,x.sm)(x.C.maxTokens))})]})]}),(0,s.jsxs)("div",{style:{fontSize:12.5},role:"table","aria-label":i.modelAuditTitle.replace("{n}",String(e.length)),children:[(0,s.jsxs)("div",{role:"row",className:"hidden gap-x-2 px-1 pb-1.5 sm:grid sm:grid-cols-[minmax(0,1fr)_92px_92px_108px]",style:{fontSize:11.5,color:"var(--dsw-label-caption)"},children:[(0,s.jsx)("span",{role:"columnheader",children:i.modelAuditColModel}),(0,s.jsx)("span",{role:"columnheader",children:i.modelAuditColContext}),(0,s.jsx)("span",{role:"columnheader",children:i.modelAuditColOutput}),(0,s.jsx)("span",{role:"columnheader",children:i.modelAuditColVision})]}),(0,s.jsx)("div",{className:"max-h-[320px] overflow-y-auto",style:{borderTop:"0.5px solid var(--dsw-border-l2)"},children:e.map(e=>(0,s.jsxs)("div",{role:"row",className:"grid grid-cols-3 items-center gap-x-2 gap-y-1.5 px-1 py-2 sm:grid-cols-[minmax(0,1fr)_92px_92px_108px]",style:{borderBottom:"0.5px solid var(--dsw-border-l1)"},children:[(0,s.jsxs)("div",{role:"cell",className:"col-span-3 min-w-0 sm:col-span-1",title:`${e.provider} / ${e.id}`,children:[(0,s.jsx)("div",{className:"truncate",style:{fontWeight:500},children:e.name??e.id}),(0,s.jsxs)("div",{className:"truncate",style:{fontSize:11.5,fontFamily:"var(--font-mono)",color:"var(--dsw-label-caption)"},children:[t(e.provider)," / ",e.id]})]}),(0,s.jsx)("div",{role:"cell",className:"min-w-0",children:y(e,"contextWindow",i.modelAuditColContext)}),(0,s.jsx)("div",{role:"cell",className:"min-w-0",children:y(e,"maxTokens",i.modelAuditColOutput)}),(0,s.jsx)("div",{role:"cell",className:"min-w-0",children:e.missing.includes("input")?(0,s.jsxs)("select",{className:"pw-audit-field",value:u(e).vision,onChange:t=>p(e,{vision:t.target.value}),"aria-label":`${e.id} ${i.modelAuditColVision}`,disabled:a,children:[(0,s.jsx)("option",{value:"",children:i.visionUnset}),(0,s.jsx)("option",{value:"image",children:i.visionOn}),(0,s.jsx)("option",{value:"text",children:i.visionOff})]}):(0,s.jsx)("span",{style:{color:"var(--dsw-label-secondary)"},children:e.vision?i.visionOn:i.visionOff})})]},c(e)))})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[h.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{style:{fontSize:12,color:"var(--dsw-label-caption)"},children:i.modelAuditVisionQuick}),(0,s.jsx)("button",{className:"btn-outline",style:{height:28,padding:"0 11px",fontSize:12.5},disabled:a,onClick:()=>v("image"),children:i.modelAuditVisionOn}),(0,s.jsx)("button",{className:"btn-outline",style:{height:28,padding:"0 11px",fontSize:12.5},disabled:a,onClick:()=>v("text"),children:i.modelAuditVisionOff})]}):null,(0,s.jsx)("span",{className:"flex-1"}),(0,s.jsx)("button",{className:"btn-primary-white",style:{height:32},disabled:a||f||0===g.length,onClick:()=>void b(),children:a?i.saving:g.length?i.modelAuditSave.replace("{n}",String(g.length)):i.modelAuditSaveIdle})]})]})}function B(){let{t:e}=(0,m.s)(),[t,a]=(0,l.useState)([]),[r,i]=(0,l.useState)({providers:{}}),[o,d]=(0,l.useState)(null),[c,h]=(0,l.useState)(new Set),[v,f]=(0,l.useState)({}),[y,w]=(0,l.useState)(null),[j,S]=(0,l.useState)(""),[N,k]=(0,l.useState)(null),[C,z]=(0,l.useState)(""),[P,M]=(0,l.useState)(""),[E,$]=(0,l.useState)("openai-completions"),[R,D]=(0,l.useState)(""),[F,A]=(0,l.useState)([]),[W,O]=(0,l.useState)(""),[I,U]=(0,l.useState)(""),[B,q]=(0,l.useState)([]),[Q,G]=(0,l.useState)(!1),[Z,X]=(0,l.useState)(!1),[Y,ee]=(0,l.useState)(null),[et,ea]=(0,l.useState)(null),[es,el]=(0,l.useState)(null),[er,ei]=(0,l.useState)([]),[en,eo]=(0,l.useState)(""),[ed,ec]=(0,l.useState)(null),[eu,ep]=(0,l.useState)(!1),em=(0,l.useMemo)(()=>{for(let e=er.length-1;e>=0;e--){let t=er[e];if(t.startsWith("{"))try{let e=JSON.parse(t);if("device_code"===e.type&&"string"==typeof e.verificationUri)return{userCode:"string"==typeof e.userCode?e.userCode:"",verificationUri:e.verificationUri,instructions:""};if("auth_url"===e.type&&"string"==typeof e.url)return{userCode:"",verificationUri:e.url,instructions:"string"==typeof e.instructions?e.instructions:""}}catch{}}return null},[er]),eh=(0,l.useRef)(null);(0,l.useEffect)(()=>{em?.verificationUri&&eh.current!==em.verificationUri&&(eh.current=em.verificationUri,window.open(em.verificationUri,"_blank","noopener"))},[em]);let ex=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/models?custom=1"),t=await e.json();if(!e.ok||!t.success)throw Error(t.error||"failed to load model configuration");let s=JSON.parse(t.data.customProviders?.content??"{}");if(!s||"object"!=typeof s||Array.isArray(s)||void 0!==s.providers&&(!s.providers||"object"!=typeof s.providers||Array.isArray(s.providers)))throw Error("invalid model configuration");a(t.data.providers),f(t.data.catalogModelIds??{}),h(new Set(t.data.customProviders?.secretProviderIds??[])),i({...s,providers:s.providers??{}}),d("string"==typeof t.data.customProviders?.revision?t.data.customProviders.revision:null)}catch(e){d(null),ee({ok:!1,msg:e instanceof Error?e.message:"failed to load model configuration"})}},[]);(0,l.useEffect)(()=>{ex()},[ex]),(0,l.useEffect)(()=>{let e;if(!et)return;let t=!0,a=!1,s=async()=>{try{let e=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"loginState",providerId:et})}),s=await e.json();if(!t||!s.success)return;el(s.data.prompt),ei(s.data.notifyLog??[]),s.data.done&&(a=!0,ec({ok:!s.data.error,msg:s.data.error??et+" ✓"}),s.data.error||ex())}catch{}finally{t&&!a&&(e=setTimeout(s,1500))}};return s(),()=>{t=!1,e&&clearTimeout(e)}},[et,ex]);let[ev,ef]=(0,l.useState)(null),[eg,eb]=(0,l.useState)(!1),[ey,ew]=(0,l.useState)(!1),ej=(0,l.useCallback)(async e=>{eb(!0),ew(!1);try{let t=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"providerUsage",providerId:"xai",force:e})}),a=await t.json();if(!t.ok||!a.success)throw Error(a.error||"usage probe failed");ef(a.data.usage??null)}catch{ew(!0)}finally{eb(!1)}},[]),[eS,eN]=(0,l.useState)({}),[ek,eC]=(0,l.useState)(null),[e_,ez]=(0,l.useState)({}),eP=(0,l.useCallback)(async(e,t)=>{eC(e),ez(t=>({...t,[e]:!1}));try{let a=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"providerUsage",providerId:e,force:t})}),s=await a.json();if(!a.ok||!s.success)throw Error(s.error||"usage probe failed");eN(t=>({...t,[e]:s.data.usage??null}))}catch{ez(t=>({...t,[e]:!0}))}finally{eC(t=>t===e?null:t)}},[]),eM=(0,l.useRef)(new Set);(0,l.useEffect)(()=>{for(let e of t)!e.authReady||!T(e.id)||"xai"===e.id||eM.current.has(e.id)||(eM.current.add(e.id),eP(e.id,!1))},[t,eP]);let eE=e=>`${"USD"===e.currency?"$":"CNY"===e.currency?"\xa5":""}${e.amount}${e.currency&&"USD"!==e.currency&&"CNY"!==e.currency?` ${e.currency}`:""}`,eT=(t,a)=>{ee({ok:t,msg:a??(t?e.toastSaved:e.toastError)}),setTimeout(()=>ee(null),2400)},e$=async t=>{try{let e=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await e.json();return e.ok?a:{...a,success:!1,error:a.error||`request failed (${e.status})`}}catch(t){return{success:!1,error:t instanceof Error?t.message:e.toastError}}},eR=(0,l.useMemo)(()=>(0,x.Ik)(r.providers??{}),[r]),[eD,eF]=(0,l.useState)(!1),eL=async t=>{let a=await e$(t);return eT(a.success,a.success&&a.data?.requiresSessionReopen?e.modelConfigReopen:a.error),a.success&&await ex(),a},eA=async t=>{if(et)try{let a=await e$({action:"loginAnswer",providerId:et,text:t});if(!a.success||a.data?.delivered!==!0)throw Error(a.error||e.toastError);eo("")}catch(t){eT(!1,t instanceof Error?t.message:e.toastError)}},eW=async()=>{if(et)try{let t=await e$({action:"loginCancel",providerId:et});if(!t.success)throw Error(t.error||e.toastError);ea(null)}catch(t){eT(!1,t instanceof Error?t.message:e.toastError)}},eO=new Set(Object.keys(r.providers??{})),eI=t.filter(e=>e.authReady||e.authConfigured||e.keyManaged||eO.has(e.id)),eU=t.filter(e=>e.builtIn&&!eI.some(t=>t.id===e.id)),eK=async e=>{if(null===o){let e={success:!1,error:"Reload model configuration before saving."};return eT(!1,e.error),e}return eL({action:"saveCustomProviders",revision:o,content:JSON.stringify({...r,providers:e},null,2)})},eB=async e=>{let{providers:t,filled:a}=(0,x.Ki)(r.providers??{},e);if(!a)return!0;eF(!0);try{return!!(await eK(t)).success}finally{eF(!1)}},eH=e=>t.find(t=>t.id===e)?.name??e,eV=e=>new Set(v[e]??[]),eJ=(e,t)=>{let a={...r.providers};if((0,x.Gy)(t)&&!c.has(e)){if(!Object.prototype.hasOwnProperty.call(a,e))return null;delete a[e]}else a[e]=t;return a},eq=async()=>{if(!Q&&!(0,x.aK)(F)&&P.trim()){G(!0);try{let e={...r.providers},t=y??C.trim(),a=e[t]??{};t!==C.trim()&&delete e[t],e[C.trim()]=(0,x.Vt)(a,{name:W,baseUrl:P,api:E,apiKey:R,models:F}),(await eK(e)).success&&w(null)}finally{G(!1)}}},eQ=async e=>{if(!Q&&!(0,x.aK)(B)){G(!0);try{let t=(0,x.Vt)(r.providers[e.id]??{},{baseUrl:I,models:B},e.apis[0]??"openai-completions",eV(e.id)),a=eJ(e.id,t),s=a?await eK(a):{success:!0};s.success&&j.trim()&&(eL({action:"setKey",providerId:e.id,apiKey:j.trim()}),ec(null),ea(e.id)),s.success&&w(null)}finally{G(!1)}}},eG=async a=>{if(!window.confirm(e.confirmRemoveProvider.replace("{name}",eH(a))))return;let s={...r.providers};delete s[a];let l=t.find(e=>e.id===a);if(l?.builtIn)try{await eL({action:"removeKey",providerId:a})}catch{}(await eK(s)).success&&w(null)},eZ=async({providerId:e,apiKey:t,config:a})=>{let s=eJ(e,{...r.providers[e],...a}),l=s?await eK(s):{success:!0};return l.success&&t&&(e$({action:"setKey",providerId:e,apiKey:t}),ec(null),ea(e)),l},eX=async({providerId:e,config:t})=>eK({...r.providers,[e]:t}),eY=async e=>{let t=await e$({action:"loginStart",providerId:e});return t.success?(ec(null),ea(e),{success:!0}):{success:!1,error:t.error}};return(0,s.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontSize:14,fontWeight:400},children:e.modelsTitle}),(0,s.jsx)("div",{className:"mt-0.5",style:{fontSize:12.5,color:"var(--dsw-label-caption)"},children:e.modelsDesc}),(0,s.jsx)("div",{className:"mt-1",style:{fontSize:12,color:"var(--dsw-label-caption)"},children:e.customModelIdentityNotice})]}),Y&&(0,s.jsx)("div",{className:"rounded-xl px-3 py-2",style:{fontSize:12.5,background:Y.ok?"rgba(34,197,94,.1)":"rgba(236,19,19,.1)",color:Y.ok?"var(--dsw-success)":"var(--dsw-danger)"},children:Y.msg}),(0,s.jsx)("div",{className:"flex flex-col gap-2.5",children:eI.map(a=>{var l,i,d;let m,h,v,f,g=eO.has(a.id)&&!a.builtIn,N=y===a.id;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col overflow-hidden rounded-2xl px-4 py-3",style:{border:"0.5px solid var(--dsw-border-l2)"},children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2",children:[(0,s.jsx)(p,{id:a.id,name:eH(a.id),size:34}),(0,s.jsxs)("div",{className:"min-w-[132px] flex-1",children:[(0,s.jsx)("div",{className:"truncate",style:{fontSize:14,fontWeight:500},children:eH(a.id)}),(0,s.jsxs)("div",{className:"truncate",style:{fontSize:11.5,color:"var(--dsw-label-caption)"},children:[a.id,a.baseUrl?` \xb7 ${a.baseUrl}`:""]})]}),g&&(0,s.jsx)("span",{className:"flex-none rounded-md px-1.5 py-0.5",style:{fontSize:10.5,border:"0.5px solid var(--dsw-border-l3)",color:"var(--dsw-label-tertiary)"},children:e.customBadge}),(0,s.jsx)("span",{className:"inline-block h-2 w-2 flex-none rounded-full",style:{background:a.authReady?"var(--dsw-success)":"var(--dsw-danger)"},title:a.authError||(a.authReady?e.providerReady:e.authUnavailable)}),(0,s.jsx)("span",{className:"flex-none rounded-md px-1.5 py-0.5",style:{fontSize:10.5,border:"0.5px solid var(--dsw-border-l3)",color:"var(--dsw-label-tertiary)"},children:e.credentialSource.replace("{source}","stored"===(m=a.authSource)?"auth.json":"runtime"===m?e.authSourceRuntime:"environment"===m?e.authSourceEnvironment:"models_json_key"===m?"models.json":"models_json_command"===m?e.authSourceCommand:"fallback"===m?e.authSourceProvider:a.resolvedAuthSource||e.authUnavailable)}),(0,s.jsx)("button",{className:"btn-outline flex-none whitespace-nowrap",style:{height:28,padding:"0 12px",fontSize:12},onClick:()=>{var e;let s;return w(y===(e=a.id)?null:e),S(""),G(!1),X(!1),s=r.providers[e],void(eO.has(e)&&!t.find(t=>t.id===e)?.builtIn?(z(e),M(s?.baseUrl??""),$(s?.api??"openai-completions"),D(""),O("string"==typeof s?.name?s.name:""),A((s?.models??[]).map(x.Lg))):(U("string"==typeof s?.baseUrl?s.baseUrl:""),q((0,x.xe)(s))))},children:e.edit}),"oauth"===a.storedAuthType&&(0,s.jsx)("button",{className:"flex-none whitespace-nowrap",style:{height:28,padding:"0 12px",fontSize:12,color:"var(--dsw-danger)"},onClick:async()=>{window.confirm(e.confirmRemoveOAuth.replace("{name}",eH(a.id)))&&await eL({action:"removeKey",providerId:a.id})},children:e.removeOAuth}),a.authTypes?.includes("oauth")&&(0,s.jsx)("button",{className:"btn-outline flex-none whitespace-nowrap",style:{height:28,padding:"0 12px",fontSize:12},onClick:()=>{ec(null),eL({action:"loginStart",providerId:a.id}),ea(a.id)},children:e.oauthLogin}),eO.has(a.id)&&(0,s.jsx)("button",{className:"flex-none whitespace-nowrap",style:{fontSize:12.5,color:"var(--dsw-danger)"},onClick:()=>eG(a.id),children:e.delete})]}),"xai"===a.id&&a.authReady&&(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2 pt-3",style:{borderTop:"0.5px solid var(--dsw-border-l2)",fontSize:11.5,color:"var(--dsw-label-tertiary)"},children:[ev?(0,s.jsxs)("span",{children:[e.usageQuotaLabel," \xb7 ",ev.model," \xb7 ",e.usageRequests," ",ev.requestRemaining.toLocaleString(),"/",ev.requestLimit.toLocaleString()," \xb7 Tokens ",(i=ev.tokenRemaining,(0,_.yj)(i)),"/",(d=ev.tokenLimit,(0,_.yj)(d))]}):(0,s.jsx)("span",{children:ey?e.usageProbeFailed:e.usageProbeDisclosure}),(0,s.jsx)("button",{type:"button",className:"pw-chip",disabled:eg,title:e.usageProbeDisclosure,onClick:()=>void ej(!0),children:eg?e.usageProbing:ev?e.usageRefresh:e.usageProbe})]}),T(a.id)&&"xai"!==a.id&&a.authReady&&(0,s.jsx)("div",{className:"mt-3 flex flex-col gap-1.5 pt-3",style:{borderTop:"0.5px solid var(--dsw-border-l2)",fontSize:11.5,color:"var(--dsw-label-tertiary)"},children:(h=eS[l=a.id],v=ek===l,f=e_[l],(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[!h&&(0,s.jsx)("span",{children:f?e.usageProbeFailed:v?e.queryingQuota:e.usageReadOnlyDisclosure}),h?.kind==="quota"&&h.planType&&(0,s.jsxs)("span",{children:[e.usagePlan," ",V(h.planType)]}),h?.kind==="balance"&&h.primary&&(0,s.jsxs)("span",{children:["used"===h.primaryKey?e.usageBalanceUsed:e.usageQuotaRemaining," ",(0,s.jsx)("span",{style:{color:"var(--dsw-label-secondary)"},children:eE(h.primary)})]}),(0,s.jsx)("button",{type:"button",className:"pw-chip",disabled:v,title:e.usageReadOnlyDisclosure,onClick:()=>void eP(l,!0),children:v?e.usageProbing:h?e.usageRefresh:e.usageProbe})]}),h?.kind==="balance"&&h.details.length>0&&(0,s.jsx)("span",{children:h.details.map(t=>{var a;return`${"granted"===(a=t.key)?e.usageBalanceGranted:"toppedUp"===a?e.usageBalanceToppedUp:"voucher"===a?e.usageBalanceVoucher:"cash"===a?e.usageBalanceCash:"used"===a?e.usageBalanceUsed:e.usageBalanceLimit} ${eE(t)}`}).join(" \xb7 ")}),h?.kind==="quota"&&0===h.windows.length&&(0,s.jsxs)("span",{children:[e.usageQuotaRemaining," —"]}),h?.kind==="quota"&&h.windows.map((t,a)=>{var l;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{style:{width:84,flex:"none"},children:(t=>{var a,s,l,r;if(void 0!==t.limitWindowSeconds){let r;return`${"weekly"==(r=604800===(s=a=t.limitWindowSeconds)?"weekly":2592e3===s?"monthly":s<86400?"hours":"days")?e.usageWindowWeekly:"monthly"===r?e.usageWindowMonthly:("hours"===r?e.usageWindowHours:e.usageWindowDays).replace("{n}",String(Math.round(a/("hours"===r?3600:86400))))}${t.variant?` (${"opus"===(l=t.variant)?e.usageVariantOpus:"code"===l?e.usageVariantCode:V(l)})`:""}`}return t.name?"premium"===(r=t.name)?e.usageWindowPremium:"chat"===r?e.usageWindowChat:"completions"===r?e.usageWindowCompletions:"rolling"===r?e.usageWindowRolling:V(r):""})(t)}),(0,s.jsxs)("span",{style:{width:92,flex:"none"},children:[e.usageQuotaRemaining," ",t.remainingPercent,"%"]}),(0,s.jsxs)("span",{children:[e.usageReset," ",function(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}(t.resetAt)]}),(0,s.jsx)("div",{className:"h-1 overflow-hidden rounded-full",style:{width:120,flex:"none",background:"var(--dsw-border-l2)"},children:(0,s.jsx)("div",{className:"h-full rounded-full",style:{width:`${t.remainingPercent}%`,background:(l=t.remainingPercent)<30?"var(--dsw-danger)":l<=60?"var(--dsw-warning)":"var(--dsw-success)"}})})]},`${t.limitWindowSeconds??t.name??"window"}-${t.variant??""}-${a}`)})]}))})]}),N&&(0,s.jsx)("div",{className:"mt-2 rounded-2xl p-4",style:{border:"0.5px solid var(--dsw-border-l2)"},children:g?(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)(J,{label:e.apiKey,children:(0,s.jsx)("input",{type:"password",value:R,onChange:e=>D(e.target.value),className:H,placeholder:c.has(a.id)?e.apiKeyStored:e.apiKeyOptional})}),(0,s.jsx)(J,{label:e.displayName,children:(0,s.jsx)("input",{value:W,onChange:e=>O(e.target.value),className:H,placeholder:a.id})}),(0,s.jsx)(J,{label:e.baseUrl,children:(0,s.jsx)("input",{value:P,onChange:e=>M(e.target.value),className:H,placeholder:"https://api.example.com/v1"})}),(0,s.jsx)(J,{label:e.apiType,children:(0,s.jsx)(L,{value:E,options:u([E,...a.apis]).map(e=>({value:e,label:e})),onChange:$})}),(0,s.jsx)(b,{models:F,setModels:A,updateModel:(e,t)=>A(a=>a.map((a,s)=>s===e?{...a,...t}:a)),discover:async t=>{let s=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"discoverModels",providerId:a.id,baseUrl:P.trim(),api:E,apiKey:R.trim(),allowPrivate:t})}),l=await s.json();if(!l.success)throw Error(l.error||e.toastError);return(l.data.models??[]).map(x.SC)},discoverDisabled:!P.trim()}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{className:"btn-outline",style:{height:32},disabled:Q,onClick:()=>w(null),children:e.cancel}),(0,s.jsx)("button",{className:"btn-primary-white",disabled:Q||!P.trim()||!!(0,x.aK)(F)||!F.some(e=>e.id.trim()),onClick:()=>void eq(),children:Q?e.saving:e.save})]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)(J,{label:e.apiKey,children:(0,s.jsx)("input",{type:"password",value:j,onChange:e=>S(e.target.value),className:H,placeholder:a.keyManaged?e.apiKeyStored:a.apiKeyLabel??e.apiKey})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-xl px-2 py-2 text-left transition-colors",style:{fontSize:13,color:"var(--dsw-label-secondary)",background:Z?"var(--dsw-hover)":"transparent"},onClick:()=>X(e=>!e),children:[(0,s.jsx)("span",{style:{display:"inline-flex",transform:Z?"none":"rotate(-90deg)",transition:"transform 120ms ease"},children:(0,s.jsx)(n.Cd,{size:13})}),e.customSettings]}),Z?(0,s.jsxs)("div",{className:"flex flex-col gap-3 pl-1 pt-2",children:[(0,s.jsx)(J,{label:e.baseUrl,children:(0,s.jsx)("input",{value:I,onChange:e=>U(e.target.value),className:H,placeholder:a.baseUrl??e.providerDefault})}),(0,s.jsx)(b,{models:B,setModels:q,updateModel:(e,t)=>q(a=>a.map((a,s)=>s===e?{...a,...t}:a)),inheritedCount:a.modelCount,catalogIds:eV(a.id),discover:async t=>{let s=await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"discoverModels",providerId:a.id,baseUrl:I.trim()||a.baseUrl||"",api:a.apis[0],apiKey:j.trim(),allowPrivate:t})}),l=await s.json();if(!l.success)throw Error(l.error||e.toastError);return(l.data.models??[]).map(x.SC)},discoverDisabled:!(I.trim()||a.baseUrl)})]}):null]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[a.keyManaged&&(0,s.jsx)("button",{style:{fontSize:12.5,color:"var(--dsw-danger)"},disabled:Q,onClick:async()=>{if("oauth"===a.storedAuthType){if(!window.confirm(e.confirmRemoveOAuth.replace("{name}",a.name)))return}else if(!window.confirm(e.confirmRemoveKey.replace("{name}",a.name)))return;(await eL({action:"removeKey",providerId:a.id})).success&&w(null)},children:"oauth"===a.storedAuthType?e.removeOAuth:e.removeKey}),(0,s.jsx)("button",{className:"btn-outline",style:{height:32},disabled:Q,onClick:()=>w(null),children:e.cancel}),(0,s.jsx)("button",{className:"btn-primary-white",disabled:Q||null===o||!!(0,x.aK)(B),onClick:()=>void eQ({id:a.id,apis:a.apis}),children:Q?e.saving:e.save})]})]})})]},a.id)})}),eR.length>0?(0,s.jsx)(K,{gaps:eR,providerLabel:eH,busy:eD||null===o,onSave:eB}):null,(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsxs)("button",{className:"flex flex-1 items-center justify-center gap-2 rounded-2xl px-4 py-3.5 transition-colors",style:{border:"0.5px solid var(--dsw-border-l3)",fontSize:14},onMouseEnter:e=>e.currentTarget.style.background="var(--dsw-hover)",onMouseLeave:e=>e.currentTarget.style.background="transparent",onClick:()=>k("builtin"),children:[(0,s.jsx)(n.Xh,{size:15}),e.addProvider]}),(0,s.jsxs)("button",{className:"flex flex-1 items-center justify-center gap-2 rounded-2xl px-4 py-3.5 transition-colors",style:{border:"0.5px solid var(--dsw-border-l3)",fontSize:14},onMouseEnter:e=>e.currentTarget.style.background="var(--dsw-hover)",onMouseLeave:e=>e.currentTarget.style.background="transparent",onClick:()=>k("custom"),children:[(0,s.jsx)(n.Xh,{size:15}),e.addCustomProvider]})]}),N?(0,s.jsx)(g,{mode:N,providers:eU,catalogModelIds:v,existingIds:t.map(e=>e.id),onClose:()=>k(null),onSaveBuiltin:eZ,onSaveCustom:eX,onOAuthLogin:eY}):null,et&&(0,s.jsx)("div",{className:"modal-mask fixed inset-0 z-[120] flex items-center justify-center",onMouseDown:e=>{e.target===e.currentTarget&&eW()},children:(0,s.jsxs)("div",{className:"glass-modal flex flex-col gap-4 p-6",style:{width:460,maxWidth:"92vw",borderRadius:24,boxShadow:"var(--dsw-elevation-prominent)"},children:[(0,s.jsxs)("div",{style:{fontSize:15,fontWeight:600},children:[e.oauthLogin," \xb7 ",et]}),em&&!ed?(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("div",{style:{fontSize:13,color:"var(--dsw-label-primary)"},children:e.oauthDevicePrompt}),em.instructions?(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-label-tertiary)"},children:em.instructions}):null,(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("a",{href:em.verificationUri,target:"_blank",rel:"noreferrer",className:"btn-primary-white",style:{fontSize:12.5,textDecoration:"none"},children:e.oauthOpenAuth}),em.userCode?(0,s.jsx)("button",{className:"btn-outline",style:{height:32},onClick:()=>{if(!em?.userCode)return;let e=em.userCode,t=()=>{ep(!0),setTimeout(()=>ep(!1),2e3)};navigator.clipboard.writeText(e).then(t).catch(()=>{let a=document.createElement("textarea");a.value=e,document.body.appendChild(a),a.select(),document.execCommand("copy"),a.remove(),t()})},children:eu?e.oauthCodeCopied:`${e.oauthDeviceCode}: ${em.userCode}`}):null]})]}):er.length>0?(0,s.jsx)("div",{className:"flex flex-col gap-0.5",style:{fontSize:12,color:"var(--dsw-label-tertiary)"},children:er.slice(-3).map((e,t)=>(0,s.jsx)("div",{className:"truncate",children:e},t))}):null,ed?(0,s.jsx)("div",{style:{fontSize:13,color:ed.ok?"var(--dsw-success)":"var(--dsw-danger)"},children:ed.ok?et+" ✓":ed.msg}):es?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{fontSize:13.5,color:"var(--dsw-label-primary)"},children:es.message}),es.message.match(/https?:\/\/[^\s)]+/)&&(0,s.jsx)("a",{href:es.message.match(/https?:\/\/[^\s)]+/)[0],target:"_blank",rel:"noreferrer",className:"break-all",style:{fontSize:12.5,color:"var(--dsw-accent)"},children:es.message.match(/https?:\/\/[^\s)]+/)[0]}),es.options?.length?(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:es.options.map(e=>(0,s.jsx)("button",{className:"btn-outline",style:{height:34,justifyContent:"flex-start",textAlign:"left"},onClick:()=>{eA(e.value)},children:e.label},e.value))}):(0,s.jsx)("input",{autoFocus:!0,type:"secret"===es.type?"password":"text",value:en,onChange:e=>eo(e.target.value),placeholder:es.placeholder??"",className:"w-full rounded-xl px-3 py-2",style:{fontSize:13,background:"var(--dsw-hover)"},onKeyDown:e=>{"Enter"===e.key&&!e.nativeEvent.isComposing&&en.trim()&&eA(en.trim())}}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{style:{fontSize:12,color:"var(--dsw-label-caption)"},children:e.oauthWait}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{className:"btn-outline",style:{height:32},onClick:()=>{eW()},children:e.oauthCancel}),!es.options?.length&&(0,s.jsx)("button",{className:"btn-primary-white",disabled:!en.trim(),style:{opacity:en.trim()?1:.5},onClick:()=>{eA(en.trim())},children:e.confirm})]})]})]}):(0,s.jsx)("div",{style:{fontSize:13,color:"var(--dsw-label-tertiary)"},children:e.oauthWait}),ed&&(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)("button",{className:"btn-primary-white",onClick:()=>ea(null),children:e.close})})]})})]})}let H="w-full rounded-xl px-3 py-2";function V(e){return 0===e.length?e:e[0].toUpperCase()+e.slice(1)}function J({label:e,children:t}){return(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-1",style:{fontSize:12,color:"var(--dsw-label-caption)"},children:e}),t]})}let q={read:{zh:"读取文件",en:"Read files"},bash:{zh:"执行 Shell 命令",en:"Run shell commands"},powershell:{zh:"执行 PowerShell",en:"Run PowerShell"},edit:{zh:"编辑文件",en:"Edit files"},write:{zh:"写入文件",en:"Write files"},grep:{zh:"搜索文件内容",en:"Search file contents"},find:{zh:"按名称查找文件",en:"Find files by name"},ls:{zh:"列出目录内容",en:"List directories"}};function Q({toolPreset:e,onToolPresetChange:t,tools:a,onSetTools:l}){let{t:r,lang:i}=(0,m.s)(),n=new Set(a?.active??[]),o=a?.all??[];return(0,s.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontSize:14,fontWeight:400},children:r.toolsSection}),(0,s.jsx)("div",{className:"mt-0.5",style:{fontSize:12.5,color:"var(--dsw-label-caption)"},children:r.toolsSectionDesc})]}),(0,s.jsx)(A,{title:r.securityToolPreset,desc:r.securityToolPresetDesc,children:(0,s.jsx)(L,{value:e,options:[{value:"readonly",label:r.toolReadonly},{value:"standard",label:r.toolStandard},{value:"full",label:r.toolFull}],onChange:e=>t(e)})}),0===o.length?(0,s.jsx)("div",{className:"rounded-2xl p-4",style:{border:"0.5px dashed var(--dsw-border-l3)",fontSize:12.5,color:"var(--dsw-label-caption)"},children:r.toolsNoSession}):(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",style:{fontSize:12,color:"var(--dsw-label-caption)"},children:[(0,s.jsx)("span",{style:{fontWeight:600},children:r.toolsCurrentSession}),(0,s.jsx)("span",{children:r.toolsActiveCount.replace("{n}",String(n.size)).replace("{total}",String(o.length))})]}),o.map(e=>{let t,a=n.has(e.name),r=e.description||((t=q[e.name])?"zh"===i?t.zh:t.en:"");return(0,s.jsxs)("div",{className:"flex items-center gap-3 rounded-2xl px-4 py-2.5",style:{border:"0.5px solid var(--dsw-border-l2)"},children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{style:{fontSize:13.5,fontWeight:500,fontFamily:"var(--font-mono)"},children:e.name}),r&&(0,s.jsx)("div",{className:"truncate",style:{fontSize:11.5,color:"var(--dsw-label-caption)"},children:r})]}),(0,s.jsx)("button",{className:"relative h-5 w-9 flex-none rounded-full transition-colors",style:{background:a?"var(--dsw-accent)":"var(--dsw-border-l3)"},role:"switch","aria-checked":a,"aria-label":e.name,disabled:!l||a&&n.size<=1,onClick:()=>{var t;return t=e.name,void(!l||l(n.has(t)?[...n].filter(e=>e!==t):[...n,t]))},children:(0,s.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all",style:{left:a?18:2}})})]},e.name)})]})]})}function G({cwd:e,onOpenFileContent:t}){let{t:a}=(0,m.s)(),[r,i]=(0,l.useState)([]),n=(0,l.useCallback)(async()=>{let t=await fetch(`/api/skills${e?`?cwd=${encodeURIComponent(e)}`:""}`),a=await t.json();a.success&&i(a.data.skills)},[e]);(0,l.useEffect)(()=>{n()},[n]);let o=async t=>{let a=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"toggle",filePath:t.filePath,disabled:!t.disabled,cwd:e})});(await a.json()).success&&n()},d=async a=>{let s=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",filePath:a.filePath,cwd:e})}),l=await s.json();l.success&&t?.(a.filePath,l.data.content)},[c,u]=(0,l.useState)(null),p=async t=>{if(!window.confirm(a.confirmDeleteSkill.replace("{name}",t.name)))return;u(null);let s=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",filePath:t.filePath,cwd:e})}),l=await s.json();l.success?n():u(l.error||a.toastError)};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("div",{style:{fontSize:12,color:"var(--dsw-label-caption)"},children:a.skillsDesc}),c&&(0,s.jsx)("div",{role:"alert",className:"rounded-lg px-3 py-2",style:{fontSize:12.5,background:"var(--dsw-hover)",color:"var(--dsw-danger)"},children:c}),0===r.length&&(0,s.jsx)("div",{style:{fontSize:13,color:"var(--dsw-label-caption)"},children:"—"}),(0,s.jsx)("div",{className:"flex flex-col gap-2",children:r.map(e=>{let t;return(0,s.jsx)("div",{className:"rounded-2xl px-4 py-3",style:{border:"0.5px solid var(--dsw-border-l2)"},children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{style:{fontSize:13.5,fontWeight:500},children:e.name}),(0,s.jsx)("span",{className:"rounded-full px-2 py-0.5",style:{fontSize:10,background:"var(--dsw-hover)",color:"var(--dsw-label-tertiary)"},children:"global"===(t=e.scope)?a.scopeGlobal:"project"===t?a.scopeProject:a.scopePackage})]}),(0,s.jsx)("div",{className:"mt-0.5 truncate",style:{fontSize:12,color:"var(--dsw-label-caption)"},title:e.description,children:e.description})]}),(0,s.jsx)("button",{className:"rounded-lg px-2.5 py-1",style:{fontSize:11.5,color:"var(--dsw-label-tertiary)"},onClick:()=>d(e),children:a.viewSkillFile}),"package"!==e.scope&&(0,s.jsx)("button",{className:"rounded-lg px-2.5 py-1",style:{fontSize:11.5,color:"var(--dsw-danger)"},title:a.deleteSkillHint,onClick:()=>void p(e),children:a.delete}),"package"===e.scope&&(0,s.jsx)("span",{style:{fontSize:10.5,color:"var(--dsw-label-caption)"},title:a.skillDeletePackageHint,children:a.skillDeletePackageHint}),(0,s.jsx)("button",{className:"relative h-5 w-9 flex-none rounded-full transition-colors",style:{background:e.disabled?"var(--dsw-border-l3)":"var(--dsw-accent)"},role:"switch","aria-checked":!e.disabled,onClick:()=>o(e),children:(0,s.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all",style:{left:e.disabled?2:18}})})]})},e.filePath)})})]})}function Z({cwd:e}){let{t,lang:a}=(0,m.s)(),r=e=>window.confirm(t.confirmUninstallPackage.replace("{source}",e)),[i,o]=(0,l.useState)("config"),[d,c]=(0,l.useState)([]),[u,p]=(0,l.useState)([]),[h,x]=(0,l.useState)(""),[v,f]=(0,l.useState)(new Set),[g,b]=(0,l.useState)(""),[y,w]=(0,l.useState)(!1),[j,S]=(0,l.useState)(!1),[N,k]=(0,l.useState)(null),[C,_]=(0,l.useState)(null),[z,P]=(0,l.useState)(null),M=(0,l.useRef)(null);(0,l.useEffect)(()=>{let e=e=>{e.target instanceof Node&&M.current?.contains(e.target)||P(null)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[]);let E=(0,l.useCallback)(async()=>{let t=await fetch(`/api/plugins${e?`?cwd=${encodeURIComponent(e)}`:""}`),a=await t.json();a.success&&(c(a.data.packages),p(a.data.extensions))},[e]);(0,l.useEffect)(()=>{E()},[E]);let T=(e,a)=>{_({ok:e,msg:a??(e?t.toastSaved:t.toastError),loading:!1}),setTimeout(()=>_(null),2600)},$=async(a,s={},l,r,i)=>{S(!0),l&&k(l),r&&_({ok:!0,msg:r,loading:!0});try{let l=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a,cwd:e,...s})}),r=await l.json();if(r.success)return T(!0,i??("toggle"===a?s.disabled?t.disabled:t.enabled:t.toastSaved)),await E(),!0;return T(!1,r.error??t.toastError),!1}catch(e){return T(!1,e?.message??t.toastError),!1}finally{S(!1),k(null)}},R=e=>f(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a}),D=e=>{if(e.startsWith("builtin:"))return"builtin";let t=e.replace(/\\/g,"/");return t.includes("/.pi/agent/npm/")||t.includes("/.pi/agent/git/")?"package":t.includes("/.pi/agent/")?"global":(t.includes("/.pi/"),"project")},F=u.filter(e=>"package"!==D(e.path)),L=h.trim().toLowerCase(),A=[...d.map(e=>({key:`pkg:${e.scope}:${e.source}`,kind:"package",name:e.source.replace(/^npm:/,"").replace(/^git[^:]*:/,""),p:e})),...F.map(e=>({key:`ext:${e.path}`,kind:"extension",name:e.name,e}))].filter(e=>!L||e.name.toLowerCase().includes(L));return(0,s.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontSize:20,fontWeight:600,color:"var(--dsw-label-primary)"},children:t.setPlugins}),(0,s.jsx)("div",{className:"mt-1",style:{fontSize:13,color:"var(--dsw-label-tertiary)"},children:t.pluginPageDesc})]}),C&&(0,s.jsxs)("div",{className:"fixed top-6 left-1/2 -translate-x-1/2 z-[9999] flex items-center gap-2.5 px-4 py-2 rounded-xl shadow-2xl transition-all pointer-events-none",style:{fontSize:13,fontWeight:500,background:"var(--dsw-surface-l1, #1e2025)",border:C.loading?"1px solid var(--dsw-border-l3)":C.ok?"1px solid rgba(34,197,94,.4)":"1px solid rgba(236,19,19,.4)",color:C.loading?"var(--dsw-label-primary)":C.ok?"var(--dsw-success)":"var(--dsw-danger)",backdropFilter:"blur(12px)",boxShadow:"0 10px 30px rgba(0,0,0,0.5)"},children:[C.loading&&(0,s.jsx)("span",{className:"h-3.5 w-3.5 flex-none animate-spin rounded-full border-2 border-current border-t-transparent"}),(0,s.jsx)("span",{children:C.msg})]}),(0,s.jsxs)("div",{className:"hairline-b flex items-center gap-6",children:[(0,s.jsx)("button",{className:"settings-tab-underline","data-active":"config"===i,onClick:()=>o("config"),children:t.pluginConfig}),(0,s.jsx)("button",{className:"settings-tab-underline","data-active":"list"===i,onClick:()=>o("list"),children:t.pluginList})]}),"config"===i&&(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-2xl px-4 py-3",style:{border:"0.5px solid var(--dsw-border-l2)"},children:[(0,s.jsx)("div",{style:{fontSize:13.5,fontWeight:500},children:t.addPackage}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("input",{value:g,onChange:e=>b(e.target.value),placeholder:t.addPackagePlaceholder,className:"min-w-0 flex-1 rounded-xl px-3 py-2",style:{fontSize:13,background:"var(--dsw-hover)",border:"0.5px solid var(--dsw-border-l2)",fontFamily:"var(--font-mono)"},onKeyDown:e=>{"Enter"===e.key&&g.trim()&&!j&&$("install",{source:g.trim(),local:y},void 0,t.installing,t.installSuccess).then(e=>{e&&b("")})}}),(0,s.jsxs)("label",{className:"flex items-center gap-1.5",style:{fontSize:12.5,color:"var(--dsw-label-secondary)"},children:[(0,s.jsx)("input",{type:"checkbox",checked:y,onChange:e=>w(e.target.checked),disabled:!e}),t.installLocal]}),(0,s.jsx)("button",{className:"btn-primary-white",style:{height:32,padding:"0 14px"},disabled:!g.trim()||j,onClick:()=>void $("install",{source:g.trim(),local:y},void 0,t.installing,t.installSuccess).then(e=>{e&&b("")}),children:t.install})]})]}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsxs)("button",{className:"btn-outline",style:{height:30,fontSize:12.5},disabled:j,onClick:async()=>{S(!0);try{let a=await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reload",cwd:e})}),s=await a.json();T(s.success,s.success?t.reloadedSessions.replace("{loaders}",String(s.data?.loaders??0)).replace("{sessions}",String(s.data?.sessions??0)):s.error),s.success&&await E()}finally{S(!1)}},children:[(0,s.jsx)(n.Ct,{size:13})," ",t.reloadExtensions]})}),0===F.length&&(0,s.jsx)("div",{style:{fontSize:12.5,color:"var(--dsw-label-caption)"},children:t.extensionsEmpty}),F.map(e=>{let a,l=`ext:${e.path}`,r=v.has(l),i=D(e.path);return(0,s.jsxs)("div",{className:"rounded-2xl",style:{border:"0.5px solid var(--dsw-border-l2)"},children:[(0,s.jsxs)("button",{className:"flex w-full items-center gap-3 px-4 py-3.5 text-left",onClick:()=>R(l),children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",style:{fontSize:14,fontWeight:500},children:[(0,s.jsx)("span",{children:e.name}),e.error&&(0,s.jsx)("span",{className:"rounded px-1.5 py-0.5",style:{fontSize:10.5,color:"var(--dsw-danger)",background:"var(--pw-danger-soft, rgba(236,19,19,.12))"},children:t.extensionLoadError}),!e.error&&(a=!0===e.disabled,(0,s.jsxs)("span",{className:"flex flex-none items-center gap-1.5 rounded-md px-1.5 py-0.5",style:{fontSize:10.5,...a?{background:"var(--dsw-selector)",color:"var(--dsw-label-tertiary)"}:{background:"rgba(34,197,94,.12)",color:"var(--dsw-success)"}},children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full",style:{background:a?"var(--dsw-label-tertiary)":"var(--dsw-success)"}}),a?t.disabled:t.enabled]}))]}),(0,s.jsx)("div",{className:"truncate",style:{fontSize:12,color:e.error?"var(--dsw-danger)":"var(--dsw-label-caption)"},title:e.error??e.path,children:e.error??e.path})]}),(0,s.jsx)("span",{className:"chevron",style:{color:"var(--dsw-label-tertiary)",display:"inline-flex",transform:r?"rotate(180deg)":"none",transition:"transform 120ms var(--ds-ease-in-out)"},children:(0,s.jsx)(n.Cd,{size:14})})]}),r&&(0,s.jsxs)("div",{className:"hairline-t flex flex-col gap-1.5 px-4 py-3",style:{fontSize:12,color:"var(--dsw-label-secondary)"},children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)("span",{className:"rounded-md px-1.5 py-0.5",style:{fontSize:10.5,border:"0.5px solid var(--dsw-border-l3)",color:"var(--dsw-label-tertiary)"},children:"global"===i?t.scopeGlobal:"project"===i?t.scopeProject:"builtin"===i?t.promptToolBuiltin:t.scopePackage})}),(0,s.jsx)("div",{className:"break-all",style:{fontFamily:"var(--font-mono)",fontSize:11.5,color:"var(--dsw-label-caption)"},children:e.path})]})]},l)})]}),"list"===i&&(0,s.jsxs)("div",{className:"flex flex-col gap-3.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl px-3.5 py-2.5 transition-colors",style:{background:"var(--dsw-hover)",border:"0.5px solid var(--dsw-border-l2)"},children:[(0,s.jsx)(n.FG,{size:15,style:{color:"var(--dsw-label-caption)"}}),(0,s.jsx)("input",{value:h,onChange:e=>x(e.target.value),placeholder:t.searchPlugins,className:"w-full bg-transparent outline-none",style:{fontSize:13,color:"var(--dsw-label-primary)"}})]}),(0,s.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,s.jsx)("span",{style:{fontSize:13.5,fontWeight:600,color:"var(--dsw-label-primary)"},children:t.pluginList}),(0,s.jsx)("span",{style:{fontSize:12,color:"var(--dsw-label-caption)"},children:A.length})]}),0===A.length?(0,s.jsx)("div",{style:{fontSize:12.5,color:"var(--dsw-label-caption)"},children:t.packagesEmpty}):(0,s.jsx)("div",{className:"grid grid-cols-1 items-start sm:grid-cols-2 gap-2.5",children:A.map(e=>{let l=v.has(e.key),i="package"===e.kind?!0===e.p.disabled:!0===e.e.disabled,o=z===e.key,d=N===e.key;return(0,s.jsxs)("div",{className:"flex flex-col rounded-xl transition-colors",style:{background:"var(--dsw-hover)",border:"0.5px solid var(--dsw-border-l2)"},children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 px-3.5",style:{height:44},children:[(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium text-[var(--dsw-label-primary)] cursor-pointer select-none",style:{fontSize:13.5},onClick:()=>R(e.key),title:e.name,children:e.name}),(0,s.jsxs)("div",{ref:o?M:void 0,className:"relative flex-none",children:[(0,s.jsxs)("button",{type:"button",className:"flex min-w-[86px] items-center justify-center rounded-lg px-3 transition-colors cursor-pointer select-none disabled:cursor-wait",style:{gap:7,height:30,background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.08)"},"aria-haspopup":"menu","aria-expanded":o,disabled:d,onClick:t=>{t.stopPropagation(),P(t=>t===e.key?null:e.key)},children:[d?(0,s.jsx)("span",{className:"h-3 w-3 flex-none animate-spin rounded-full border border-[var(--dsw-label-tertiary)] border-t-transparent"}):i?null:(0,s.jsx)("span",{className:"h-2 w-2 flex-none rounded-full",style:{background:"#22c55e",boxShadow:"0 0 5px rgba(34, 197, 94, 0.4)"}}),(0,s.jsx)("span",{style:{fontSize:12,fontWeight:500,color:i?"var(--dsw-label-tertiary)":"var(--dsw-success)",lineHeight:1},children:i?t.disabled:t.enabled}),(0,s.jsx)(n.Cd,{size:13,style:{color:"var(--dsw-label-tertiary)",transform:o?"rotate(180deg)":"none",transition:"transform 140ms ease"}})]}),o&&(0,s.jsxs)("div",{className:"popover absolute right-0 top-full mt-1.5 z-50 w-36 py-1 rounded-xl shadow-xl",role:"menu",style:{background:"var(--dsw-surface-l1, #1e2025)",border:"0.5px solid var(--dsw-border-l3)",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5)"},children:[(0,s.jsx)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors hover:bg-[var(--dsw-hover)] cursor-pointer",style:{color:i?"var(--dsw-success)":"var(--dsw-label-primary)"},disabled:j,onClick:()=>{P(null),$("toggle","package"===e.kind?{kind:"package",source:e.p.source,scope:e.p.scope,disabled:!i}:{kind:"extension",path:e.e.path,disabled:!i},e.key,i?"zh"===a?"正在启用...":"Enabling...":"zh"===a?"正在停用...":"Disabling...",i?t.enabled:t.disabled)},children:i?t.enablePlugin:t.disablePlugin}),"package"===e.kind&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors hover:bg-[var(--dsw-hover)] cursor-pointer disabled:opacity-50",style:{color:"var(--dsw-label-secondary)"},disabled:j,onClick:()=>{P(null),$("update",{source:e.p.source},e.key,t.updating,t.updateSuccess)},children:t.update}),(0,s.jsx)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors hover:bg-[var(--dsw-hover)] cursor-pointer disabled:opacity-50",style:{color:"var(--dsw-danger)"},disabled:j,onClick:()=>{P(null),r(e.p.source)&&$("remove",{source:e.p.source,local:"project"===e.p.scope},e.key,t.uninstalling,t.uninstallSuccess)},children:t.uninstall})]}),(0,s.jsx)("div",{className:"my-1 border-t border-[var(--dsw-border-l1)]"}),(0,s.jsx)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors hover:bg-[var(--dsw-hover)] cursor-pointer",style:{color:"var(--dsw-label-tertiary)"},onClick:()=>{R(e.key),P(null)},children:l?"zh"===a?"收起详情":"Hide details":"zh"===a?"查看详情":"View details"})]})]})]}),l&&(0,s.jsx)("div",{className:"hairline-t flex flex-col gap-2 px-3.5 py-3",style:{fontSize:12},children:"package"===e.kind?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"break-all",style:{color:"var(--dsw-label-tertiary)",fontSize:11.5},children:e.p.source}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"rounded-md px-1.5 py-0.5",style:{fontSize:10.5,border:"0.5px solid var(--dsw-border-l3)",color:"var(--dsw-label-tertiary)"},children:"user"===e.p.scope?t.scopeGlobal:t.scopeProject}),(0,s.jsxs)("span",{style:{color:"var(--dsw-label-caption)",fontSize:11.5},children:[t.resources,": ",e.p.resources.extensions," ext \xb7 ",e.p.resources.skills," skills \xb7 ",e.p.resources.prompts," prompts"]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-3 pt-1",children:[(0,s.jsx)("button",{disabled:j,style:{fontSize:12,color:"var(--dsw-label-secondary)"},className:"hover:underline cursor-pointer disabled:opacity-50",onClick:()=>void $("update",{source:e.p.source},e.key,t.updating,t.updateSuccess),children:t.update}),(0,s.jsx)("button",{disabled:j,style:{fontSize:12,color:"var(--dsw-danger)"},className:"hover:underline cursor-pointer disabled:opacity-50",onClick:()=>{r(e.p.source)&&$("remove",{source:e.p.source,local:"project"===e.p.scope},e.key,t.uninstalling,t.uninstallSuccess)},children:t.uninstall})]})]}):(0,s.jsx)("div",{className:"break-all",style:{fontFamily:"var(--font-mono)",fontSize:11.5,color:"var(--dsw-label-caption)"},children:e.e.path})})]},e.key)})})]})]})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8552],{6972:(e,t,n)=>{n.d(t,{$n:()=>i,Iy:()=>v,Kx:()=>b,PM:()=>x,QW:()=>l,ie:()=>r,kh:()=>s,kk:()=>M,pb:()=>F,tu:()=>S});let r=["smooth","typewriter","fade","instant"],l=1,s=5,i={style:"smooth",speed:3,caret:!1},c="piweb.streamStyle",a="piweb.streamSpeed",u="piweb.streamCaret",o=[24,20,16,12,8],d=[14,10,7,5,3],f=[1,1,1,2,3],h=[140,110,90,70,50],m=[1,2,3,5,8];function p(e){return"smooth"===e||"instant"===e||"typewriter"===e||"fade"===e}function g(e){return Number.isFinite(e)?Math.max(l,Math.min(s,Math.round(e))):i.speed}function x(e){return o[g(e)-1]}function y(){try{let e=localStorage.getItem(c),t=Number.parseInt(localStorage.getItem(a)??"",10),n=localStorage.getItem(u);return{style:p(e)?e:i.style,speed:Number.isFinite(t)?g(t):i.speed,caret:null===n?i.caret:"1"===n||"true"===n}}catch{return i}}let w=null,j=new Set,k=!1;function b(){return w||(w=y()),w}function S(){return i}function F(e){return j.add(e),k||(k=!0,window.addEventListener("storage",e=>{if(null===e.key||e.key===c||e.key===a||e.key===u)for(let e of(w=y(),j))e()})),()=>{j.delete(e)}}function v(e){let t=b(),n={style:p(e.style)?e.style:t.style,speed:void 0===e.speed?t.speed:g(e.speed),caret:void 0===e.caret?t.caret:!0===e.caret};w=n;try{localStorage.setItem(c,n.style),localStorage.setItem(a,String(n.speed)),localStorage.setItem(u,n.caret?"1":"0")}catch{}for(let e of j)e();return n}function M(e,t,n){let r,l=e.length;if("instant"===n.style)return l;let s=l-t;if(s<=0)return l;let i=g(n.speed)-1;(r="typewriter"===n.style?t+Math.max(m[i],Math.ceil(s/90)):t+Math.min(h[i],Math.max(f[i],Math.ceil(s/d[i]))))>l&&(r=l),"fade"===n.style&&(r=function(e,t,n){if(n>=e.length)return e.length;for(let r=n-1;r>=t;r-=1)if(/\s/.test(e[r]))return r+1;return n}(e,t,r));var c=r;if(c<=0)return 0;if(c>=e.length)return e.length;let a=e.charCodeAt(c-1),u=e.charCodeAt(c);return a>=55296&&a<=56319&&u>=56320&&u<=57343?Math.min(c+1,e.length):c}},8552:(e,t,n)=>{n.r(t),n.d(t,{MarkdownBlock:()=>g,StreamingMarkdownBlock:()=>F,createStreamingSplitter:()=>k,default:()=>v,splitOpenFence:()=>b,splitStreamingMarkdown:()=>S});var r=n(5155),l=n(2115),s=n(8426),i=n(3437),c=n(7890),a=n(4965),u=n(9992),o=n(8155),d=n(6972),f=n(1859);function h({text:e}){let[t,n]=(0,l.useState)(!1),[s,i]=(0,l.useState)(!1),{t:c}=(0,f.s)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"icon-btn",title:s?c.copyFailed:c.copy,"aria-label":c.copy,onClick:()=>{(0,o.D)(e).then(e=>{n(e),i(!e),setTimeout(()=>{n(!1),i(!1)},1200)})},children:t?(0,r.jsx)(u.df,{size:14}):(0,r.jsx)(u.sS,{size:14})}),s&&(0,r.jsx)("span",{role:"alert",style:{fontSize:11,color:"var(--dsw-danger)"},children:c.copyFailed})]})}function m({src:e,alt:t,title:n}){let[s,i]=(0,l.useState)(!1),{t:c}=(0,f.s)(),a="string"==typeof e?e:"";if(!a)return null;if(s||function(e){try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}}(a))return(0,r.jsx)("img",{src:a,alt:t??"",title:n});let u=a;try{u=new URL(a).host||a}catch{}return(0,r.jsxs)("button",{type:"button",className:"btn-outline",style:{height:26,padding:"0 10px",fontSize:12},title:a,onClick:()=>i(!0),children:[c.externalImage,t?`:${t}`:"","(",u,")"]})}let p=(0,l.memo)(function({text:e}){return(0,r.jsx)(s.oz,{remarkPlugins:[c.A],rehypePlugins:[[i.A,{detect:!1,ignoreMissing:!0}]],components:{a:({node:e,...t})=>(0,r.jsx)("a",{...t,target:"_blank",rel:"noopener noreferrer"}),img:({src:e,alt:t,title:n})=>(0,r.jsx)(m,{src:e,alt:t,title:n}),pre:({node:e,children:t,...n})=>(0,r.jsxs)("div",{className:"md-code-block",children:[(0,r.jsx)("div",{className:"md-code-copy",children:(0,r.jsx)(h,{text:function e(t){return t?"string"==typeof t.value?t.value:t.children?.map(e).join("")??"":""}(e)})}),(0,r.jsx)("pre",{...n,children:t})]})},children:e})}),g=(0,l.memo)(function({text:e}){return(0,r.jsx)("div",{className:"md",children:(0,r.jsx)(p,{text:e})})}),x=/^ {0,3}(?:[-*+]|\d+[.)])\s/,y=/^ {0,3}(`{3,}|~{3,})(.*)$/,w=/^[ \t]+\S/;function j(e,t){let n=y.exec(t);if(!n)return null;let[,r,l]=n;return e.inFence?r[0]===e.char&&r.length>=e.length&&""===l.trim()?(e.inFence=!1,"close"):null:"`"===r[0]&&l.includes("`")?null:(e.inFence=!0,e.char=r[0],e.length=r.length,"open")}function k(){let e="",t=0,n={inFence:!1,char:"",length:0},r=0,l=!1,s=!0,i=[];return{update(c){for(c.startsWith(e)||(e="",t=0,n={inFence:!1,char:"",length:0},r=0,l=!1,s=!0,i=[]),e=c;t<c.length;){let e=c.indexOf("\n",t);if(-1===e)break;let a=c.slice(t,e),u=n.inFence,o=j(n,a),d=""===a.trim();if(!n.inFence&&d){let t=e+1,n=c.indexOf("\n",t),s=c.slice(t,-1===n?c.length:n),a=w.test(s);if(!(-1!==n||t<c.length&&""!==s.trim()&&(a||!l)))break;if(!(a||l&&x.test(s))&&""!==s.trim()){let e=c.slice(r,t);e.trim()&&i.push(e),r=t}}!u&&!d&&(x.test(a)?l=!0:("open"===o?w.test(a):!s||w.test(a))||(l=!1)),u&&n.inFence||(s=d),t=e+1}return{blocks:i.slice(),tail:c.slice(r),tailInFence:n.inFence}}}}function b(e){let t={inFence:!1,char:"",length:0},n=-1,r=0,l="",s=0;for(;s<e.length;){let i=e.indexOf("\n",s);if(-1===i)break;let c=e.slice(s,i);"open"===j(t,c)&&(n=s,r=i+1,l=(y.exec(c)?.[2]??"").trim().split(/\s+/)[0]??""),s=i+1}if(-1===n||!t.inFence)return{before:e,lang:"",code:""};let i=e.slice(r),c=i.slice(i.lastIndexOf("\n")+1),a=c.trimStart();return a&&c.length-a.length<=3&&a[0]===t.char&&/^(`+|~+)\s*$/.test(a)&&(i=i.slice(0,i.length-c.length)),{before:e.slice(0,n),lang:l,code:i}}function S(e){return k().update(e)}let F=(0,l.memo)(function({text:e,live:t=!0}){let n,s=(0,l.useSyncExternalStore)(d.pb,d.Kx,d.tu),i=(0,l.useContext)(a.d),c=(0,l.useRef)(null);c.current||(c.current=k());let[u,o]=(0,l.useState)(()=>({shown:e,...c.current.update(e)})),f=(0,l.useRef)(u),m=(0,l.useRef)(e),x=(0,l.useRef)(s),y=(0,l.useRef)(null),w=e=>{let t={shown:e,...c.current.update(e)};f.current=t,o(t)},j=()=>{null!==y.current&&clearTimeout(y.current),y.current=null},S=()=>{y.current=null;let e=m.current,t=f.current.shown;if(t===e)return;if(!e.startsWith(t))return void w(e);let n=x.current;w(e.slice(0,(0,d.kk)(e,t.length,n))),y.current=setTimeout(S,(0,d.PM)(n.speed))},F=()=>{if(null!==y.current)return;let e=x.current;if("instant"===e.style){f.current.shown!==m.current&&w(m.current);return}y.current=setTimeout(S,(0,d.PM)(e.speed))};(0,l.useEffect)(()=>{m.current=e,e!==f.current.shown&&F()},[e]),(0,l.useEffect)(()=>{if(x.current=s,f.current.shown!==m.current){if("instant"===s.style){j(),w(m.current);return}F()}},[s]),(0,l.useEffect)(()=>()=>j(),[]);let v=!t&&u.shown===e;if((0,l.useLayoutEffect)(()=>{i?.shouldPin()&&i.pin()},[u,v,i]),v)return(0,r.jsx)(g,{text:e});let{shown:M,blocks:N,tail:I,tailInFence:C}=u;if(C){let{before:e,lang:t,code:l}=b(I);n=(0,r.jsxs)(r.Fragment,{children:[e.trim()?(0,r.jsx)(p,{text:e}):null,(0,r.jsxs)("div",{className:"md-code-block",children:[(0,r.jsx)("div",{className:"md-code-copy",children:(0,r.jsx)(h,{text:l})}),(0,r.jsx)("pre",{children:(0,r.jsx)("code",{className:t?`hljs language-${t}`:void 0,children:l})})]})]})}else n=(0,r.jsx)(p,{text:I});return(0,r.jsxs)("div",{className:s.caret?"md pw-stream pw-stream-caret":"md pw-stream","data-stream-style":s.style,"data-stream-pending":M===e?void 0:"",children:[N.map((e,t)=>(0,r.jsx)(p,{text:e},t)),I?(0,r.jsx)("div",{className:"pw-stream-tail",children:n},"tail"):null]})}),v=g}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[552,635,1097,2138,2164,2437,2772,2836,2909,2922,4459,4896,5221,5368,5907,6031,6450,6819,6849,6884,6988,7203,7822,7844,7851,8091,8167,8651,9223,9742,9799,9968],{4441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=4441)),_N_E=_.O()}]);